Skip to content

fix(runtime): stop rejecting ui.set when Linear or Jira resume fields are present - #10715

Merged
OrcaWin merged 3 commits into
stablyai:mainfrom
giraphant:fix/client-ui-schema-task-resume-fields
Jul 27, 2026
Merged

OrcaWin merged 3 commits into
stablyai:mainfrom
giraphant:fix/client-ui-schema-task-resume-fields

Conversation

@giraphant

@giraphant giraphant commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The runtime ui.set RPC rejects any UI-state update that carries linearMode, linearContext, jiraPreset, or jiraQuery.

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 fails safeParse and the dispatcher returns INVALID_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:set IPC 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 with shared/types.ts; no behavior is added.

The same fix was previously authored by @brennanb2025 in fa88ee4 and 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 lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

The existing accepts persisted literal UI arrays and nested UI state case in client-ui.test.ts was 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 because updateUIState is never called at all.

pnpm test reports 8 pre-existing failing files on my machine (window.localStorage undefined 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:

  • Root cause vs. symptom — traced both write paths (ui:set IPC → persistence.updateUI with no validation; ui.set RPC → strict Zod → dispatcher.ts INVALID_ARGUMENT) to confirm the drift is the actual defect and that the desktop path genuinely cannot hit it.
  • Whole-payload rejection — verified .strict() rejects rather than strips, so the blast radius is the entire update, not one field.
  • Schema/type parity — diffed every key of TaskResumeState in shared/types.ts against the schema; these four were the only gaps.
  • Cross-platform (macOS/Linux/Windows) — no platform-dependent code touched: no paths, no shell invocation, no keyboard shortcuts or accelerators, no Electron platform APIs. The affected transport is the runtime RPC layer, which is platform-independent.
  • SSH / remote — this is precisely the path that was broken; relay and SSH-paired clients share the RPC dispatcher and are fixed by the same change.
  • Git provider compatibility — not applicable, no Git or provider code touched.

Flagged and resolved: my first draft of the linearContext sub-object omitted .strict(), which would have made it laxer than its sibling schemas. Corrected before commit.

Security Audit

  • Input handling — this widens accepted input on a client-facing RPC, so it is the relevant risk. Each added field is constrained to the narrowest form matching the type: three z.enum()s over closed value sets, one z.string(), and a .strict() object for linearContext. No z.any(), no z.record(), no passthrough. The parent object stays .strict(), so this does not open the door to arbitrary keys.
  • Command execution / path handling — none. These values are persisted state read back by the renderer, never interpolated into a shell command or a filesystem path.
  • Auth / secrets — none touched. No credential or token field is involved.
  • IPC — no new IPC surface; an existing method's schema is corrected to match its documented type.
  • Dependencies — none added.

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.

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

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Expanded TaskResumeState with Linear mode/context and Jira preset/query fields. Extended persisted UI validation with additional view, display, setup-guide, and mobile dismissal fields, plus compile-time schema parity checks. Added ui.set coverage for individual fields, nested resume state, and the complete debounced App writer payload.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: accepting Linear and Jira resume fields in ui.set instead of rejecting them.
Description check ✅ Passed The description covers all required sections from the template and includes testing, review, security, and notes details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Comment @coderabbitai help to get the list of available commands.

@nwparker nwparker added the bug Something isn't working label Jul 27, 2026
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.
@OrcaWin

OrcaWin commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Reviewed with an independent reproduction. Confirming your diagnosis and extending it.

Verified. TaskResumeState is .strict() and listed only 6 of 10 fields. I reproduced invalid_argument with the exact message Unrecognized key: "linearMode" for each of the four missing fields, and confirmed .strict() rejects the whole payload rather than stripping the unknown key. Your desktop-immunity claim also checks out: src/main/ipc/ui.ts:63 handles ui:set with no schema, which is exactly why this stayed invisible on desktop.

What the fix missed. The same .strict() drift exists one level up in UiUpdate, where 8 more renderer-written keys were unlisted. The worst is showDotfilesByWorktree — it rides App.tsx's 150ms debounced writer, so a single dotfile toggle caused a paired client to lose sidebar widths, sort/group preferences, repo filters and agent acknowledgements in the same rejected call. activeView is written on every top-level view switch and was rejected every time.

Pushed to this branch. Rather than extend the hand-listing, I added an AssertNoMissingKeys type so any future field added to PersistedUIState or TaskResumeState becomes a typecheck error naming the missing key. Parity had drifted by hand across at least three separate PRs (#3966, #2238, #9002), so the root cause is the manual process, not any one omission. Main-owned state stays an explicit allow-list — remote clients still cannot write star-nag or window state, and the pre-existing tests proving that still pass.

The file split was required to satisfy max-lines; I did not add a disable, per AGENTS.md.

Validation: 515 tests passing across src/main/runtime/rpc/methods/, typecheck exit 0.

Thanks for finding this — the mobile/web-only failure mode made it genuinely easy to miss.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/ui-state-schema-parity.ts (1)

1-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep 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 essential activeView compatibility 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

📥 Commits

Reviewing files that changed from the base of the PR and between b67b4a8 and c5bdca4.

📒 Files selected for processing (4)
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/main/runtime/rpc/methods/client-ui.test.ts
  • src/main/runtime/rpc/methods/task-resume-state-schema.ts
  • src/main/runtime/rpc/methods/ui-state-schema-parity.ts

@OrcaWin

OrcaWin commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Follow-up on my review above — a status note so this is not silently stuck.

My review fixes are on this branch (c5bdca4b): the UiUpdate parity gaps and the AssertNoMissingKeys type that turns future drift into a typecheck error. 515 tests pass and typecheck exits 0 against the base this branch sits on.

But the branch now conflicts with main, which moved during review. The conflict is small and purely additive — main added hideCliCreatedWorkspaces and hideDetachedHeadWorkspaces to the same UiUpdate object where my change added showDotfilesByWorktree. All three belong; resolving means keeping every line from both sides.

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 .github/workflows/pr.yml — GitHub then refuses the push because my token lacks the workflow OAuth scope. It inspects every incoming commit, not the net diff, so there is no way around it from my side even though this PR changes no workflow file.

To move this forward, please merge main into your branch and keep both sides of the conflict in client-ui-schemas.ts. Once it is mergeable, CI should run and this is ready.

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.

@OrcaWin
OrcaWin merged commit cef52c6 into stablyai:main Jul 27, 2026
22 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants