fix(desktop): preserve commit reword drafts across navigation#14361
Open
ameyypawar wants to merge 2 commits into
Open
fix(desktop): preserve commit reword drafts across navigation#14361ameyypawar wants to merge 2 commits into
ameyypawar wants to merge 2 commits into
Conversation
Reword (edit commit message) drafts lived only in the editor component's local state, so switching context unmounted the editor and discarded the draft. New-commit drafts already survive via `lane.newCommitMessage`. Persist the reword draft per-commit in lane UI state: seed the editor from it, save it on every change, and clear it on save or explicit cancel. The draft now survives navigating away and back; only Cancel discards it. Fixes gitbutlerapp#13287
Add a per-commit `editCommitMessage` slot to lane UI state, and make CommitView seed the reword editor from it, persist on every change, and clear it on save / explicit cancel. Fixes gitbutlerapp#13287
Collaborator
|
Thanks for giving it a shot. Could you please add before and after videos? This would make it so much easier to get started with the review. |
Contributor
Author
after.mov |
Contributor
Author
before.mov |
Byron
reviewed
Jun 26, 2026
Byron
left a comment
Collaborator
There was a problem hiding this comment.
Thanks a lot for the videos!
In the interest of time, I didn't validate this locally, just because I think the PR should receive its final approval from @mtsgrd. To me the code looks good and quite minimal, but I am missing the big picture to truly judge its fitness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reword (edit commit message) drafts were lost on context switch — start editing a commit's message, navigate to another commit/branch/repo, come back, and the draft is gone. New-commit drafts already survive.
Cause:
CommitView.sveltemounted the reword editor seeded from the original message with noonChange, so the draft lived only in the editor's local state and was destroyed when the editor unmounted on context switch.NewCommitViewavoids this by persisting intolane.newCommitMessage(redux).Fix: mirror that, scoped to reword — persist the draft per-commit in lane UI state, seed the editor from it, clear it on save or explicit cancel:
lib/commits/editCommitDraft.ts— pureresolveEditDraft/applyEditDraftUpdatehelpers (+EditCommitMessagetype), with unit tests.lib/state/uiState.svelte.ts— addeditCommitMessageto laneStackState.components/commit/CommitView.svelte— seed from the draft, persist on change, clear on save + explicit cancel.Behavior: navigate away / close the drawer → draft preserved; return → restored; Cancel → discarded; Save → cleared. (
RichTextEditoronly seeds when empty, so restore happens on remount and there's no caret reset while typing.)Two design points worth a maintainer call (cc @PavelLaptev, per the issue thread):
prettier,eslint,svelte-check(0 errors / 0 warnings), and the new vitest suite (7 cases) pass locally.Fixes #13287