Skip to content

Conversation

@jnywong
Copy link
Contributor

@jnywong jnywong commented Dec 11, 2025

  • Adds a user-friendly error message when a merge conflict is detected
  • Keeps the scary terminal panel hidden
  • Adds a button to backup working directory and pull a fresh copy of the target repo into a new directory
Before After
Screenshot 2025-12-11 at 17 36 40 Screenshot 2026-01-13 at 10 29 36Error log dialog closed by default with more user-friendly error message
Screenshot 2026-01-13 at 10 29 57 Error dialog open with copy error button

todo

  • fix failing tests
  • write tests
  • update docs

Closes #280 and closes 2i2c-org/infrastructure#7085

@jnywong
Copy link
Contributor Author

jnywong commented Dec 11, 2025

Hey @balajialg and @ryanlovett, this still needs a bit more work, but the proof of concept is there. I would love to get a bit of feedback from you as to whether you think a student would find this useful or not – I am trying to be careful with the wording here and not assume any prior git knowledge.

@jnywong jnywong marked this pull request as ready for review January 7, 2026 14:39
@jnywong
Copy link
Contributor Author

jnywong commented Jan 7, 2026

@yuvipanda I've gotten positive feedback via email from @balajialg and incorporated their suggestions, so this one is ready for your approval.

url.searchParams.append("backup", "true");

if (s.includes("merge"))
return `<p class="lead">Unresolvable conflicts detected while syncing</p><p><strong>Proceed without syncing</strong> to continue with the current state of your repository without updates.</p><p><strong>(Recommended) Backup and resync</strong> to backup the current state of your repository and sync updates into a new separate folder:<ul>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick response here is that this looks prone to cross site scripting attacks since the url and other things are end user controlled. I'll take a more detailed look later, but can you check that to see?

Copy link
Contributor Author

@jnywong jnywong Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL parameter backup only triggers code I wrote that is executed server-side, so I think I am okay with that being safe.

The error message contained in s comes from an event source listening to the backend running the git operation (and is the same one overlaid on top of the progress bar) so I don't think an attacker can hijack this to return an error message of their choosing.

The helper message

return `<p class="lead">Unresolvable conflicts detected while syncing</p...`

is not user controlled. It is rendered via innerHTML, but since the content is statically authored by me, I don't think this introduces an XSS vuln. However, if this content were ever made dynamic in the future, it would need to be sanitised.

It's possible that I am missing something though – let me know if so.

@nthiery
Copy link

nthiery commented Jan 12, 2026

Up to the caveat of internationalization for our French speaking students here, this looks very clear and simple, and a nice improvement on top of @cmarmo's previous step. Given the base line in the current release (where the students really don't know what to do in case of failure), and if there is no technical security barrier, I'd would be up for having this merged with a new release ASAP. Then, I'll be happy to test it on the battlefield with our hundreds of students and provide feedback to polish it more if needed :-)

@nthiery
Copy link

nthiery commented Jan 12, 2026

Looking at the screen again: I would put first the explanation (merge conflict), and then the two buttons giving the choice of action for the user (proceed without syncing / Backup and resync), both in orange/warning style (as both are not dangerous but imperfect).

I am not sure about the "copy error" button. It's not a dangerous action (so not in red). It's not an alternative to the two other actions either. It's natural to keep it close to the error message. Maybe just having a "copy" icon to the right of the error message, close to the click to show hide error log as it is of the same nature?

@jnywong
Copy link
Contributor Author

jnywong commented Jan 12, 2026

Hey @nthiery thank you for your feedback 🙏

I agree with your comments, I will iterate on the UI and come back with more consistent button placement and stylings.

@jnywong jnywong marked this pull request as draft January 12, 2026 16:30
@jnywong jnywong marked this pull request as ready for review January 12, 2026 17:20
@jnywong
Copy link
Contributor Author

jnywong commented Jan 12, 2026

I've updated the top card with screenshots of the UI changes :)

@nthiery
Copy link

nthiery commented Jan 12, 2026

That was quick!

Presumably the two buttons can be on the same line to save vertical space. And highlight that it's about choosing between the two.

I am not sure whether one of the two options should be more recommended than the other. In my use cases, I would tend to recommend to not sync: not receiving the latest improvements to the training material is a slight annoyance. But having to juggle with one's work that has been moved away can be pretty confusing if the student does not understand what happened; and some (fragile) work to put things back in place. I can hear the 'I lost all my work!'.

"""
with Remote() as remote, Pusher(remote) as pusher:
pusher.push_file('README.md', '1')
puller = Puller(remote)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Puller class is intended to be invoked as a context manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need two different Puller objects since

  1. the first one does the initial sync with backup not set
  2. the second one triggers the merge conflict with backup=true.

If nested two different context managers to invoke them, then the exiting the first one would fail because the backup strategy would rename the first puller.path and so there would be no temporary folder to cleanup in the puller.__exit__ teardown.

Comment on lines 619 to 620
puller_backup.__exit__
puller.__exit__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both puller and puller_backup are invoked as context managers, these won't be needed! Although, right now they're not actually being invoked here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah you're right, puller.__exit__ would at least complain if I thought it was trying to rmtree a folder that was renamed and no longer exists. I'll double-check that cleanup is happening as I expect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K yeah, I've opted to just cleanup the pulled folders with af44677 and get rid of the unused .__exit__ calls.

@jnywong
Copy link
Contributor Author

jnywong commented Jan 13, 2026

I am not sure whether one of the two options should be more recommended than the other.

Thank you for this perspective. I had high-pressure exam situations in mind (@balajialg) when making this recommendation, but with your feedback I will leave these 2 options as neutral since context matters here when making this choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

(Part 1) Design and integrate dedicated handler for merge errors Add a reset function

4 participants