From c24d26946889d1780e88bc7f1f0ef2640c32248c Mon Sep 17 00:00:00 2001 From: estib Date: Mon, 19 May 2025 15:14:40 +0200 Subject: [PATCH 1/4] fix(commit-view): clear commit inputs on cancel actions Clear commit title and description fields when canceling commit or edit actions in NewCommitView and CommitView components. This ensures that stale input data is not retained, improving user experience and preventing accidental reuse of previous commit messages. --- apps/desktop/src/components/v3/CommitView.svelte | 8 +++++++- apps/desktop/src/components/v3/NewCommitView.svelte | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/components/v3/CommitView.svelte b/apps/desktop/src/components/v3/CommitView.svelte index b23111a2ec..0d62a1851a 100644 --- a/apps/desktop/src/components/v3/CommitView.svelte +++ b/apps/desktop/src/components/v3/CommitView.svelte @@ -118,6 +118,12 @@ if (!canEdit()) return; await modeService!.enterEditMode(commitKey.commitId, stackId); } + + function cancelEdit() { + setMode('view'); + commitTitle.current = ''; + commitDescription.current = ''; + } @@ -139,7 +145,7 @@ stackId={env.stackId} action={() => editCommitMessage()} actionLabel="Save" - onCancel={() => setMode('view')} + onCancel={cancelEdit} initialTitle={parsedMessage.title} initialMessage={parsedMessage.description} loading={messageUpdateResult.current.isLoading} diff --git a/apps/desktop/src/components/v3/NewCommitView.svelte b/apps/desktop/src/components/v3/NewCommitView.svelte index 3abb410b56..32dea1124b 100644 --- a/apps/desktop/src/components/v3/NewCommitView.svelte +++ b/apps/desktop/src/components/v3/NewCommitView.svelte @@ -240,6 +240,8 @@ function cancel() { drawer?.onClose(); + projectState.commitTitle.set(''); + projectState.commitDescription.set(''); } From cf0695d49a10552fcf7d19c7b16b0330ab4f6f0a Mon Sep 17 00:00:00 2001 From: estib Date: Mon, 19 May 2025 15:15:49 +0200 Subject: [PATCH 2/4] fix: update commit title state handling in editor component --- apps/desktop/src/components/v3/CommitMessageEditor.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop/src/components/v3/CommitMessageEditor.svelte b/apps/desktop/src/components/v3/CommitMessageEditor.svelte index 13adb9ead2..7c39d463d1 100644 --- a/apps/desktop/src/components/v3/CommitMessageEditor.svelte +++ b/apps/desktop/src/components/v3/CommitMessageEditor.svelte @@ -147,7 +147,7 @@ value={effectiveTitleValue} oninput={(e: Event) => { const input = e.currentTarget as HTMLInputElement; - projectState.commitTitle.current = input.value; + titleText.current = input.value; }} onkeydown={(e: KeyboardEvent) => { if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) { From d962b1bb06eea075cb43392926fb1fcf75ccd9fe Mon Sep 17 00:00:00 2001 From: estib Date: Mon, 19 May 2025 15:16:30 +0200 Subject: [PATCH 3/4] testing: instrument the cancel button Instrument the cancel button in the commit message editor --- apps/desktop/src/components/v3/editor/EditorFooter.svelte | 5 ++++- apps/desktop/src/lib/testing/testIds.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/components/v3/editor/EditorFooter.svelte b/apps/desktop/src/components/v3/editor/EditorFooter.svelte index 1e2ed8d381..5c9e1df106 100644 --- a/apps/desktop/src/components/v3/editor/EditorFooter.svelte +++ b/apps/desktop/src/components/v3/editor/EditorFooter.svelte @@ -1,4 +1,5 @@ diff --git a/apps/desktop/src/lib/testing/testIds.ts b/apps/desktop/src/lib/testing/testIds.ts index 191579e3e2..3b66377716 100644 --- a/apps/desktop/src/lib/testing/testIds.ts +++ b/apps/desktop/src/lib/testing/testIds.ts @@ -28,6 +28,7 @@ export enum TestId { CommitDrawerTitleInput = 'commit-drawer-title-input', CommitDrawerDescriptionInput = 'commit-drawer-description-input', CommitDrawerActionButton = 'commit-drawer-action-button', + CommitDrawerCancelButton = 'commit-drawer-cancel-button', CommitDrawerTitle = 'commit-drawer-title', CommitDrawerDescription = 'commit-drawer-description', UncommittedChanges_FileList = 'uncommitted-changes-file-list', From f43a65d255fb85bf43bebb69a101175607ba39ba Mon Sep 17 00:00:00 2001 From: estib Date: Mon, 19 May 2025 15:19:19 +0200 Subject: [PATCH 4/4] test: Extend commit message update tests Cover the instance in which the user starts editing a commit and then cancels the operation. This should clear the cached message --- apps/desktop/cypress/e2e/commitActions.cy.ts | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/apps/desktop/cypress/e2e/commitActions.cy.ts b/apps/desktop/cypress/e2e/commitActions.cy.ts index 1f0cec3ae2..974fc86acd 100644 --- a/apps/desktop/cypress/e2e/commitActions.cy.ts +++ b/apps/desktop/cypress/e2e/commitActions.cy.ts @@ -535,6 +535,54 @@ describe('Commit Actions with lots of uncommitted changes', () => { cy.getByTestId('commit-row', commitTitle).should('be.visible'); } + + // Start editing the commits and cancel + for (let i = TIMES; i < TIMES * 2; i++) { + const commitTitle = `Commit title ${i + 1}`; + const commitDescription = `Commit description ${i + 1}`; + + const newCommitTitle = `New commit title ${i + 1}`; + const newCommitDescription = `New commit description ${i + 1}`; + + // Click on the first commit + cy.getByTestId('commit-row', commitTitle).should('contain', commitTitle).click(); + + // Should open the commit drawer + cy.get('.commit-view').first().should('contain', commitTitle); + + // Click on the edit message button + cy.getByTestId('commit-drawer-action-edit-message').should('contain', 'Edit message').click(); + + // Should open the commit rename drawer + cy.getByTestId('edit-commit-message-drawer').should('be.visible'); + + // Should have the original commit message, and be focused + cy.getByTestId('commit-drawer-title-input') + .should('have.value', commitTitle) + .should('be.visible') + .should('be.enabled') + .clear() + .type(newCommitTitle); // Type the new commit message title + + // Type in a description + cy.getByTestId('commit-drawer-description-input') + .should('be.visible') + .should('contain', commitDescription) + .click() + .clear() + .type(newCommitDescription); // Type the new commit message body + + // Click on the save button + cy.getByTestId('commit-drawer-cancel-button') + .should('be.visible') + .should('be.enabled') + .click(); + + cy.getByTestId('edit-commit-message-drawer').should('not.exist'); + + cy.getByTestId('commit-drawer-title').should('contain', commitTitle); + cy.getByTestId('commit-drawer-description').should('contain', commitDescription); + } }); });