Repository navigation
feat(apps): keep unsaved app form changes across app updates - #645
Merged
Merged
Conversation
When an app generation changed while a remotely rendered dialog had unsaved changes, the platform remounted the view and the draft was lost without a word. The old view cannot save after an update: the server refuses its frame as a stale generation, so frontend and backend never mix. The draft now moves to the new generation instead. - The form store reports the fields the user changed and did not save, per form ID, and takes such drafts in a new view. Each draft returns when its form first arrives in the new generation: on the fields the form still has, as an unsaved change the app hears about; fields it no longer has are left out and named. - AppUiFrame hands the drafts from one view to the next of the same session, app, slot and host, through a context. A new generation, a reconnect or a retry takes them; a closed dialog drops them, and no other host, session or app ever sees them. - The view shows a notice that the app was updated and the changes were kept, with the left-out fields, until the user dismisses it. The close guard still holds for the restored draft. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This was referenced Nov 30, 2026
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.
Summary
Part of closing #626 (generation cutover without dropping unsaved changes).
Before: when an app generation changed while a remotely rendered dialog had unsaved changes, the platform remounted the view and the draft was lost without a word.
Why it cannot simply wait: the old view cannot save after an update. The server refuses its frame as a stale generation (
activeAppUi→staleGeneration), so the old frontend never talks to the new backend. As agreed with the maintainer, the draft now moves to the new generation instead.How it works
remote-forms.ts):unsavedDrafts()reports, per form ID, the fields the user changed and did not save.carry(drafts)gives those drafts to a new view. Each draft returns when its form first arrives: on the fields the form still has, as an unsaved change. The app hears about it through its formchangeevent, so its save state follows.carryResult().AppUiFrame+appDraftHandoffContext.ts):AppUiFrameremounts on a new generation, a reconnect or a retry. The old view keeps its drafts in a layout-effect cleanup; the new view takes them in its layout effect.CarriedDraftsNotice): the view says the app was updated and the changes were kept, and names left-out fields, until the user dismisses it. The dialog's close guard still holds for the restored draft.Tests
remote-forms.test.ts:changeevent;remote-app-dialogs.test.tsx: a typed interval survives a generation remount of the view. The form is unsaved with Save enabled, the notice shows, and it can be dismissed.bun run typecheck;oxlint, both configs, on the changed files;bun test --isolatefor lib/AppUi, features/AppUi, AppUiDevPreview, layouts, ProxyHostManagement, lib/Language and architecture: 449 pass.🤖 Generated with Claude Code