-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix: warn when a pending edit is not accepted #7540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JohnMcLear
merged 2 commits into
ether:develop
from
JohnMcLear:fix-unaccepted-commit-warning
Apr 19, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -655,6 +655,14 @@ const pad = { | |
| pad.handleOptionsChange(opts); | ||
| } | ||
| }, | ||
| showUnacceptedCommitWarning: () => { | ||
| $.gritter.add({ | ||
| title: html10n.get('pad.gritter.unacceptedCommit.title'), | ||
| text: html10n.get('pad.gritter.unacceptedCommit.text'), | ||
| sticky: true, | ||
| class_name: 'disconnected unsaved-warning', | ||
| }); | ||
| }, | ||
| handleChannelStateChange: (newState, message) => { | ||
| const oldFullyConnected = !!padconnectionstatus.isFullyConnected(); | ||
| const wasConnecting = (padconnectionstatus.getStatus().what === 'connecting'); | ||
|
|
@@ -692,6 +700,7 @@ const pad = { | |
| padimpexp.disable(); | ||
|
|
||
| padconnectionstatus.disconnected(message); | ||
| if (pad.collabClient.hasUnacceptedCommit()) pad.showUnacceptedCommitWarning(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Pending edits only warned on disconnect The new UX warning for unaccepted commits is only shown when the channel enters DISCONNECTED, so users can still have locally-applied edits pending acceptance with no in-UI indication during the pending state. This fails the requirement to indicate the pending state itself (and clear/update once accepted). Agent Prompt
|
||
| } | ||
| const newFullyConnected = !!padconnectionstatus.isFullyConnected(); | ||
| if (newFullyConnected !== oldFullyConnected) { | ||
|
|
||
39 changes: 39 additions & 0 deletions
39
src/tests/frontend-new/specs/unaccepted_commit_warning.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import {expect, test} from '@playwright/test'; | ||
| import {clearPadContent, goToNewPad, writeToPad} from '../helper/padHelper'; | ||
|
|
||
| test.describe('unaccepted commit warning', () => { | ||
| test('hasUnacceptedCommit clears once the server acknowledges the commit', | ||
| async ({page}) => { | ||
| await goToNewPad(page); | ||
| await clearPadContent(page); | ||
| await writeToPad(page, 'trigger a commit'); | ||
|
|
||
| // Wait for the commit to round-trip. The fix clears the pending marker inside | ||
| // acceptCommit(); without it the boolean stays true indefinitely. | ||
| await expect.poll(async () => await page.evaluate(() => | ||
| (window as any).pad?.collabClient?.hasUnacceptedCommit?.() ?? null, | ||
| ), {timeout: 10000}).toBe(false); | ||
| }); | ||
|
|
||
| test('disconnect with a pending commit surfaces the unsaved-edit gritter', | ||
| async ({page}) => { | ||
| await goToNewPad(page); | ||
| await page.waitForFunction(() => (window as any).pad?.collabClient != null); | ||
|
|
||
| await page.evaluate(() => { | ||
| const p: any = (window as any).pad; | ||
| // Force the pending-commit predicate to true and simulate a disconnect so | ||
| // the warning code path executes deterministically. | ||
| p.collabClient.hasUnacceptedCommit = () => true; | ||
| p.handleChannelStateChange('DISCONNECTED', { | ||
| type: 'disconnect', | ||
| explanation: 'test', | ||
| cause: 'test', | ||
| forIE: false, | ||
| canRetry: false, | ||
| }); | ||
| }); | ||
|
|
||
| await expect(page.locator('.unsaved-warning').first()).toBeVisible(); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. No test for unaccepted warning
📘 Rule violation☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools