Repository navigation
fix(runtime): stop rejecting ui.set when Linear or Jira resume fields are present - #10715
Conversation
… are present The renderer persists linearMode, linearContext, jiraPreset, and jiraQuery in TaskResumeState, but the strict Zod schema on the runtime ui.set RPC omitted them. Because the schema is strict, an unlisted key fails safeParse and the dispatcher returns INVALID_ARGUMENT instead of stripping it, so paired web/mobile/relay clients had their whole UI-state update rejected whenever any of these fields was present. Desktop is unaffected — it writes through the ui:set IPC handler, which has no schema. The fields were added by stablyai#3966 (linearMode/linearContext) and stablyai#2238 (jira*) without updating the schema; this only restores parity with shared/types.ts. Co-authored-by: brennanb2025 <[email protected]> Co-Authored-By: Claude <[email protected]>
📝 WalkthroughWalkthroughExpanded 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
The PR correctly identified that TaskResumeState's strict Zod guard was missing linearMode/linearContext/jiraPreset/jiraQuery, so any paired web/mobile/relay client that opened Linear or Jira had its ENTIRE ui.set payload rejected with invalid_argument. That part is verified and kept. The same drift existed at the UiUpdate level and the PR did not cover it. Eight more keys the renderer writes through ui.set were unlisted: - activeView, written by App.tsx on every top-level view switch (stablyai#9002) - showDotfilesByWorktree, which rides App.tsx's 150ms debounced writer, so a single dotfile toggle dropped sidebar widths, sort/group prefs, repo filters and agent acknowledgements for that client - setupGuideSidebarDismissed, setupGuideBrowserMilestoneMigrated, setupGuideBrowserMilestoneLegacyComplete, browserImportHintHidden, mobileEmulatorTabIntroDismissed, mobileEmulatorAgentSetupDismissed Root cause is that schema/type parity was maintained by hand with nothing enforcing it, so this recurred across stablyai#3966, stablyai#2238, stablyai#9002 and others. AssertNoMissingKeys now turns a field added to PersistedUIState or TaskResumeState without a schema entry into a typecheck error naming the missing key. Main-owned state (star-nag, tray notice, popout bounds) is an explicit allow-list, so remote clients still cannot write it — the existing "rejects star-nag persisted state mutations" tests still pass. Split TaskResumeState into its own module and the assertion helper into ui-state-schema-parity.ts to stay under max-lines without a disable. Tests: one case per drifted field plus the full App writer payload; 14 fail when the schema is reverted, all pass with it.
|
Reviewed with an independent reproduction. Confirming your diagnosis and extending it. Verified. What the fix missed. The same Pushed to this branch. Rather than extend the hand-listing, I added an The file split was required to satisfy Validation: 515 tests passing across Thanks for finding this — the mobile/web-only failure mode made it genuinely easy to miss. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/ui-state-schema-parity.ts (1)
1-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep the new implementation comments concise. Reduce these to a single non-obvious rationale where needed; the detailed RPC failure narrative belongs in tests, PR context, or docs.
src/main/runtime/rpc/methods/ui-state-schema-parity.ts#L1-L10: condense the JSDoc to the parity assertion’s purpose.src/main/runtime/rpc/methods/client-ui-schemas.ts#L168-L170: reduce to the essentialactiveViewcompatibility rationale.src/main/runtime/rpc/methods/client-ui-schemas.ts#L207-L208: reduce to the essential payload-rejection rationale.src/main/runtime/rpc/methods/client-ui-schemas.ts#L264-L265: reduce to the essential strict-schema rationale.src/main/runtime/rpc/methods/client-ui-schemas.ts#L293-L296: reduce to the allow-list rationale.src/main/runtime/rpc/methods/client-ui.test.ts#L531-L534: reduce to the reason for per-field cases.src/main/runtime/rpc/methods/client-ui.test.ts#L577-L578: reduce to the combined-payload test rationale.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a0897754-d46d-4bc4-b588-a82d192a37cb
📒 Files selected for processing (4)
src/main/runtime/rpc/methods/client-ui-schemas.tssrc/main/runtime/rpc/methods/client-ui.test.tssrc/main/runtime/rpc/methods/task-resume-state-schema.tssrc/main/runtime/rpc/methods/ui-state-schema-parity.ts
|
Follow-up on my review above — a status note so this is not silently stuck. My review fixes are on this branch ( But the branch now conflicts with I resolved it locally and verified it (612 tests, typecheck 0), but I cannot push the resolution. Both merging and rebasing pull main's own commits onto your fork, and two of those touch To move this forward, please merge Worth restating: the underlying bug is live on main right now — any paired web/mobile client that has opened Linear or Jira is silently losing its entire UI-state update. Worth unblocking. |
… are present (stablyai#10715) Reviewed with an independent reproduction. Extended the fix to the UiUpdate parity gaps one level up, and added a typecheck-level assertion so future field drift fails the build instead of silently rejecting paired-client payloads.
Summary
The runtime
ui.setRPC rejects any UI-state update that carrieslinearMode,linearContext,jiraPreset, orjiraQuery.The renderer persists all four in
TaskResumeState, but the Zod schema guarding the RPC only lists six of the type's ten fields. The schema is.strict(), so an unlisted key failssafeParseand the dispatcher returnsINVALID_ARGUMENT— Zod does not strip it, the whole payload is dropped. A paired web/mobile/relay client therefore loses its entire UI-state update whenever any of these fields is present, which is any session where the user has opened Linear or Jira.Desktop is unaffected: it writes through the
ui:setIPC handler, which has no schema. That is why this has gone unnoticed.The fields were added by #3966 (
linearMode,linearContext) and #2238 (jira*) without a matching schema update. This only restores parity withshared/types.ts; no behavior is added.The same fix was previously authored by @brennanb2025 in
fa88ee4and explicitly written to be cherry-pickable, but the branch it lived on was reverted and it was lost. This reuses that work, with credit.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildThe existing
accepts persisted literal UI arrays and nested UI statecase inclient-ui.test.tswas extended with all four fields. It is a genuine regression test, not a restatement of the schema: revert the schema change and the test fails becauseupdateUIStateis never called at all.pnpm testreports 8 pre-existing failing files on my machine (window.localStorageundefined under this environment, e.g.use-markup-draw-hint.test.ts,agent-exec-handler.test.ts). I confirmed these are unrelated by stashing this change and re-running them on a clean tree — they fail identically.AI Review Report
Reviewed with Claude Code. Risks checked:
ui:setIPC →persistence.updateUIwith no validation;ui.setRPC → strict Zod →dispatcher.tsINVALID_ARGUMENT) to confirm the drift is the actual defect and that the desktop path genuinely cannot hit it..strict()rejects rather than strips, so the blast radius is the entire update, not one field.TaskResumeStateinshared/types.tsagainst the schema; these four were the only gaps.Flagged and resolved: my first draft of the
linearContextsub-object omitted.strict(), which would have made it laxer than its sibling schemas. Corrected before commit.Security Audit
z.enum()s over closed value sets, onez.string(), and a.strict()object forlinearContext. Noz.any(), noz.record(), no passthrough. The parent object stays.strict(), so this does not open the door to arbitrary keys.No follow-up needed.
Notes
No platform-specific behavior.
This overlaps textually with the same Zod block in the Linear view-state PR I am opening alongside this one; whichever merges second needs a trivial rebase. The two are independent in substance — this one is a pre-existing bug fix and stands on its own.
I do not use X, so no handle for the shoutout.
ELI5
Saving UI state that included Linear or Jira resume fields failed entirely because the server schema rejected unknown keys. Those fields are accepted so resume state for Tasks clients is not dropped.