fix: warn when a pending edit is not accepted#7540
fix: warn when a pending edit is not accepted#7540JohnMcLear wants to merge 1 commit intoether:developfrom
Conversation
Show a gritter warning only when the pad disconnects while a local commit is still awaiting acceptance, leaving normal editing UI unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Review Summary by QodoWarn when pending edit is not accepted on disconnect
WalkthroughsDescription• Clear pending commit marker when ACCEPT_COMMIT arrives • Show gritter warning only on disconnect with unaccepted edits • Add localized strings for unsaved edit warning • Export method to check for unaccepted commits Diagramflowchart LR
A["Commit sent<br/>stateMessage set"] -->|ACCEPT_COMMIT| B["Clear stateMessage<br/>setStateIdle"]
C["Pad disconnects"] -->|hasUnacceptedCommit| D{stateMessage<br/>!= null?}
D -->|Yes| E["Show gritter warning<br/>Unsaved edit"]
D -->|No| F["Normal disconnect"]
File Changes1. src/static/js/collab_client.ts
|
Code Review by Qodo
1. Pending edits only warned on disconnect
|
| padimpexp.disable(); | ||
|
|
||
| padconnectionstatus.disconnected(message); | ||
| if (pad.collabClient.hasUnacceptedCommit()) pad.showUnacceptedCommitWarning(); |
There was a problem hiding this comment.
1. Pending edits only warned on disconnect 📎 Requirement gap ☼ Reliability
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
## Issue description
The UI warning for unaccepted commits is only displayed upon disconnect, not throughout the entire pending-acceptance window. Compliance requires a clear indication whenever a commit is pending (until `ACCEPT_COMMIT` clears it).
## Issue Context
A pending commit is tracked via `stateMessage` and exposed as `hasUnacceptedCommit()`, and `stateMessage` is cleared in `acceptCommit()`. However, the UI only calls `showUnacceptedCommitWarning()` inside the `DISCONNECTED` channel state, so users may still believe edits are saved while connected.
## Fix Focus Areas
- src/static/js/pad.ts[658-665]
- src/static/js/pad.ts[703-703]
- src/static/js/collab_client.ts[142-151]
- src/static/js/collab_client.ts[492-500]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| showUnacceptedCommitWarning: () => { | ||
| $.gritter.add({ | ||
| title: html10n.get('pad.gritter.unacceptedCommit.title'), | ||
| text: html10n.get('pad.gritter.unacceptedCommit.text'), | ||
| sticky: true, | ||
| class_name: 'disconnected unsaved-warning', | ||
| }); | ||
| }, |
There was a problem hiding this comment.
2. No test for unaccepted warning 📘 Rule violation ☼ Reliability
This bug fix changes client behavior around pending commits and disconnect warnings but does not include any regression test in the change set. Without an automated test, the issue can reappear undetected if the fix is reverted or refactored.
Agent Prompt
## Issue description
The PR changes client behavior for pending commits/disconnect warnings but does not add a regression test that would fail without the fix.
## Issue Context
A suitable regression test should assert at least one of:
- `stateMessage`/pending marker is cleared when `ACCEPT_COMMIT` is processed (so `hasUnacceptedCommit()` flips to `false`).
- The warning UI is triggered when a disconnect occurs while a commit is pending.
## Fix Focus Areas
- src/static/js/collab_client.ts[142-151]
- src/static/js/collab_client.ts[492-500]
- src/static/js/pad.ts[658-665]
- src/static/js/pad.ts[703-703]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
Testing
Refs #5109
~20 seconds to get this error tho... might be too long for good UX