Skip to content

feat(apps): keep unsaved app form changes across app updates - #645

Merged
RentnerKev merged 2 commits into
mainfrom
rentner/feat/carry-drafts-across-app-updates
Nov 30, 2026
Merged

RentnerKev merged 2 commits into
mainfrom
rentner/feat/carry-drafts-across-app-updates

Conversation

@RentnerKev

Copy link
Copy Markdown
Member

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

  • Form store (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 form change event, so its save state follows.
    • Fields the new generation's form no longer has are left out and named in carryResult().
  • Handoff (AppUiFrame + appDraftHandoffContext.ts):
    • The keyed view below AppUiFrame remounts 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.
    • Drafts pass only between views of the same session, app, slot and host, and only once. A closed dialog drops them with its frame.
  • Notice (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.
  • Translations in all eight locales.

Tests

  • remote-forms.test.ts:
    • only changed fields travel and return on the same form;
    • a removed field is reported, not sent;
    • the app gets a change event;
    • later updates follow the usual rules;
    • clean forms carry nothing;
    • unclaimed drafts travel on;
    • the handoff passes drafts once and never to another host or session.
  • 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.
  • Ran locally:
    • bun run typecheck;
    • oxlint, both configs, on the changed files;
    • bun test --isolate for lib/AppUi, features/AppUi, AppUiDevPreview, layouts, ProxyHostManagement, lib/Language and architecture: 449 pass.

🤖 Generated with Claude Code

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]>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1da9c20 and 6cbdb74.

Files selected for processing: 15

  • web/src/features/AppUi/AppUiFrame.tsx
  • web/src/features/AppUi/Components/RemoteAppView/Components/CarriedDraftsNotice.tsx
  • web/src/features/AppUi/Components/RemoteAppView/index.tsx
  • web/src/features/AppUi/appDraftHandoffContext.ts
  • web/src/lib/AppUi/remote-forms.ts
  • web/src/lib/Language/Locales/de.json
  • web/src/lib/Language/Locales/en.json
  • web/src/lib/Language/Locales/es.json
  • web/src/lib/Language/Locales/fr.json
  • web/src/lib/Language/Locales/it.json
  • web/src/lib/Language/Locales/nl.json
  • web/src/lib/Language/Locales/pl.json
  • web/src/lib/Language/Locales/pt.json
  • web/src/tests/features/AppUi/remote-app-dialogs.test.tsx
  • web/src/tests/lib/AppUi/remote-forms.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@RentnerKev
RentnerKev merged commit 394e53f into main Nov 30, 2026
11 checks passed
@RentnerKev
RentnerKev deleted the rentner/feat/carry-drafts-across-app-updates branch November 30, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant