Repository navigation
fix(jira): stop the paired web client crashing on a missing Jira status - #25579
Conversation
The paired web client has no Jira preload, so window.api.jira.status() resolves undefined from the fallback proxy. Since #24376 the first status check stored that undefined and the sidebar crashed reading `.connected`. Parse the status reply at the runtime-client boundary so every reader gets a well-formed JiraConnectionStatus.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Missing-status normalization — new
parseJiraConnectionStatusreturns{ connected: false, viewer: null }for any reply that isn't an object with a booleanconnected, a record-or-nullviewer, and an array-or-absentsites, which is what stops the web client storingundefinedasjiraStatus. - Applied at all three status producers —
jiraStatusandjiraSelectSiteinruntime-jira-client.tsandjiraReadStatusinruntime-jira-summary-client.ts, covering both the local preload and remote-runtime RPC paths;jira-connection-actions.tsis untouched, so #24376's refresh behavior is preserved. - Crash-reproducing store test —
jira-web-client-status.test.tsdrivescheckJiraConnectionwith the realwithFallback({}, [])proxy aswindow.apiand asserts the store settles on{ connected: false, viewer: null }withjiraStatusChecked: true. - Parser unit tests —
runtime-jira-connection-status.test.tspins undefined/null/array/non-boolean/non-object/non-array inputs and well-formed pass-through with exacttoEqualassertions.
The diagnosis checks out: web-preload-api.ts wires linear via createRuntimeNamespaceApi (which throws when no runtime is active) but has no jira namespace, so window.api.jira.status() resolves undefined through the generic fallback while Linear correctly lands in its store catch. I verified the fix locally against the changed and importing modules: 56 tests pass, oxlint on changed files and pnpm tc:web are clean.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)📝 WalkthroughWalkthroughThe Jira status parser validates values returned by runtime clients and normalizes a missing viewer to null. The status and site-selection operations, along with Priority: ⬇️ Low Merge Risk: 🔵 Low · up to A malformed Jira reply can still crash a site-dependent view. The risk is narrow, but nested status validation should be fixed before merging. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The change handles missing Jira status safely without adding access or privileges. No material security risk was found in the compared changes. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2af8ee8c-a5c6-4732-87ee-596075d68294
📒 Files selected for processing (5)
src/renderer/src/runtime/runtime-jira-client.tssrc/renderer/src/runtime/runtime-jira-connection-status.test.tssrc/renderer/src/runtime/runtime-jira-connection-status.tssrc/renderer/src/runtime/runtime-jira-summary-client.tssrc/renderer/src/store/slices/jira-web-client-status.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| !(value.viewer === undefined || value.viewer === null || isRecord(value.viewer)) || | ||
| !(value.sites === undefined || Array.isArray(value.sites)) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
sed -n '1,50p' src/shared/jira-types.ts
rg -n -C 3 '(jiraStatus|status)\??\.(sites|viewer)' src/renderer/src --glob '*.ts' --glob '*.tsx'Repository: stablyai/orca
Length of output: 8163
🏁 Script executed:
printf '%s\n' '--- parser ---'
nl -ba src/renderer/src/runtime/runtime-jira-connection-status.ts
printf '%s\n' '--- direct parser callers ---'
rg -n -C 5 -F 'parseJiraConnectionStatus' src/renderer/src --glob '*.ts' --glob '*.tsx' || test "$?" -eq 1
printf '%s\n' '--- jira-self-user complete source ---'
nl -ba src/renderer/src/components/jira-self-user.ts
printf '%s\n' '--- jira-self-user callers ---'
rg -n -C 4 -F 'getJiraSelfUser' src/renderer/src --glob '*.ts' --glob '*.tsx' || test "$?" -eq 1
printf '%s\n' '--- relevant Jira site consumers ---'
rg -n -C 3 '(sites|candidate)\.(find|map)|sites\[[^]]+\]\.(id|siteUrl|email|displayName|accountId)' src/renderer/src --glob '*.ts' --glob '*.tsx' || test "$?" -eq 1Repository: stablyai/orca
Length of output: 22751
Validate nested Jira status fields before the type assertion.
A status with connected: true and sites: [null] passes the parser. When getJiraSelfUser receives that status with a truthy siteId, its .find callback reads candidate.id and can throw. Validate the viewer fields and every site element before returning the status.
🐛 Suggested fix
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}
+function isJiraViewer(value: unknown): boolean {
+ return (
+ isRecord(value) &&
+ typeof value.accountId === 'string' &&
+ typeof value.displayName === 'string' &&
+ (typeof value.email === 'string' || value.email === null) &&
+ (value.avatarUrl === undefined || typeof value.avatarUrl === 'string')
+ )
+}
+
+function isJiraSite(value: unknown): boolean {
+ return (
+ isRecord(value) &&
+ typeof value.id === 'string' &&
+ typeof value.siteUrl === 'string' &&
+ typeof value.email === 'string' &&
+ typeof value.displayName === 'string' &&
+ typeof value.accountId === 'string' &&
+ (value.authType === undefined || value.authType === 'cloud' || value.authType === 'server')
+ )
+}
+
// Why: the paired web client has no Jira preload, so its fallback proxy resolves
// undefined; any reply the store's status comparisons can't read is disconnected.
export function parseJiraConnectionStatus(value: unknown): JiraConnectionStatus {
if (
!isRecord(value) ||
typeof value.connected !== 'boolean' ||
- !(value.viewer === undefined || value.viewer === null || isRecord(value.viewer)) ||
- !(value.sites === undefined || Array.isArray(value.sites))
+ !(value.viewer === undefined || value.viewer === null || isJiraViewer(value.viewer)) ||
+ !(
+ value.sites === undefined ||
+ (Array.isArray(value.sites) && value.sites.every(isJiraSite))
+ )
) {Source: Learnings
|
Review of merged #25579 against current What I checked: the merged diff and the current callers; the local preload, remote environment RPC, and site-selection paths; all Jira status readers that can write store state; the status type assertion; and the focused parser, web-fallback, runtime-client, and Jira-store tests. P0: none. P1: none. P2: P3: none. Results: the focused command passed 58 tests: Verdict: #25579 fixes the reported paired-web-client crash at the correct runtime-client boundary and covers all three status reads, including remote RPC and site selection, but the P2 malformed-nested-data gap needs #25656. The follow-up’s self-review found no remaining P0-P2 findings. |

ELI5
Since #24376, opening a paired Orca web client crashes straight to "Orca web hit a renderer error. Retry the web client or reconnect to the paired runtime." instead of showing the app.
The web client has no way to ask about Jira, so its Jira status check gets back nothing, and that "nothing" was saved as the Jira status; the sidebar then crashed reading it.
This PR makes the Jira status read treat a missing or malformed answer as "Jira not connected", which is what the web client effectively showed before #24376.
What Changed
Before: the paired web client crashes during its first render with
TypeError: Cannot read properties of undefined (reading 'connected')atuse-integration-connection-status.ts(facts.jiraStatus.connected); the desktop app is unaffected.After: the paired web client renders normally and shows Jira as not connected, as it did before #24376.
Cause: the web client's
window.apihas nojiranamespace (web-preload-api.tswireslinearbut neverjira), sowindow.api.jira.status()falls through to the web fallback proxy, which resolvesundefined.Before #24376,
hasJiraStatusChanged(previous, undefined)threw, and the surroundingcatchkept the default{ connected: false }, which hid the bad value by accident.#24376 rightly made the status refresh whenever the provider context changes (
jiraStatusContextKey !== contextKey || hasJiraStatusChanged(...)), so on the first check that comparison short-circuits andundefinedis stored asjiraStatus.Fix: a new
parseJiraConnectionStatus(src/renderer/src/runtime/runtime-jira-connection-status.ts) checks each status reply where it enters the renderer and returns{ connected: false, viewer: null }unless the reply has a booleanconnected, an object-or-nullviewer, and an array-or-absentsites(the fields the store's comparisons read).It is applied to all three reads that produce a
JiraConnectionStatus(jiraStatus,jiraSelectSite,jiraReadStatus), on both the local preload path and the remote-runtime RPC path, so no store field the UI reads can be set toundefinedfrom here.#24376's behavior is kept: the status still refreshes whenever the context key changes, and the store logic in
jira-connection-actions.tsis untouched.Why
The preload/RPC reply is outside input, so checking it once where it enters is the fix for this whole class, rather than another
?.in one reader or a second guard in the store next to the existing ones.I did not wire
jirainto the web client'swindow.api: the web client has never exposed Jira, and turning it on means checking that roughly 20 local Jira calls (search cancellation, issue-summary cancellation, image payload streaming) match the runtime RPC methods one-for-one; that is a feature, not a crash fix.Other integrations: there is no shared status read to fix. Linear's web namespace is wired to the runtime (
linear.statusRPC), so it gets a real reply, and its status check would throw into itscatchrather than storeundefined. GitHub and GitLab status comes from preflight, which the readers already access with optional chaining (preflightStatus?.gh?.installed).Linked Issue
No issue; found while bisecting a red
tests/e2e/paired-startup-exec-readiness.spec.tson main to #24376.Visual Proof
N/A: no new UI. The paired-client e2e below asserts the sidebar renders; before this fix the same spec times out because the whole web client is replaced by the error screen.
Testing
New
src/renderer/src/store/slices/jira-web-client-status.test.tsreproduces the crash path with the real web fallback proxy aswindow.api:checkJiraConnection()resolves without throwing and the store keepsjiraStatus = { connected: false, viewer: null }withjiraStatusChecked = true.Ablation: with only the runtime-client changes reverted, that test fails with
expected undefined to deeply equal { connected: false, viewer: null }, the exact state that crashed the sidebar.New
runtime-jira-connection-status.test.tscovers undefined, null, array, non-booleanconnected, non-objectviewer, non-arraysites, a well-formed status passing through, and a missingviewerfilled withnull.Vitest on the new tests plus every test of a changed module's importers: 10 files, 101 tests, all pass.
tests/e2e/paired-startup-exec-readiness.spec.tsheadless test (:122, "recovers the same startup exec through an isolated headless orca serve") on macOS: passes in 3.2 s; on clean main it times out at the paired client's[data-worktree-sidebar]wait. The@headfultest was not run locally.pnpm tc:web, oxlint on changed files, andpnpm run check:code-quality:changed: all pass. No user-facing strings changed.Platforms: macOS locally. The change is renderer-only and platform-neutral; the remote-runtime path (SSH or paired runtime) goes through the same parser.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Author: @BrennanKB5
Backwards compatibility: an older remote host that omits
viewernow reads asviewer: nullinstead ofundefined; a well-formed reply is otherwise passed through unchanged.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)