Skip to content

fix(jira): stop the paired web client crashing on a missing Jira status - #25579

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-web-client-jira-status-crash
Oct 5, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-web-client-jira-status-crash

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21

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') at use-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.api has no jira namespace (web-preload-api.ts wires linear but never jira), so window.api.jira.status() falls through to the web fallback proxy, which resolves undefined.

Before #24376, hasJiraStatusChanged(previous, undefined) threw, and the surrounding catch kept 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 and undefined is stored as jiraStatus.

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 boolean connected, an object-or-null viewer, and an array-or-absent sites (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 to undefined from here.

#24376's behavior is kept: the status still refreshes whenever the context key changes, and the store logic in jira-connection-actions.ts is 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 jira into the web client's window.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.status RPC), so it gets a real reply, and its status check would throw into its catch rather than store undefined. 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.ts on 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

New src/renderer/src/store/slices/jira-web-client-status.test.ts reproduces the crash path with the real web fallback proxy as window.api: checkJiraConnection() resolves without throwing and the store keeps jiraStatus = { connected: false, viewer: null } with jiraStatusChecked = 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.ts covers undefined, null, array, non-boolean connected, non-object viewer, non-array sites, a well-formed status passing through, and a missing viewer filled with null.

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.ts headless 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 @headful test was not run locally.

pnpm tc:web, oxlint on changed files, and pnpm 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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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 viewer now reads as viewer: null instead of undefined; a well-formed reply is otherwise passed through unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 5, 2026 13:28

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Missing-status normalization — new parseJiraConnectionStatus returns { connected: false, viewer: null } for any reply that isn't an object with a boolean connected, a record-or-null viewer, and an array-or-absent sites, which is what stops the web client storing undefined as jiraStatus.
  • Applied at all three status producers — jiraStatus and jiraSelectSite in runtime-jira-client.ts and jiraReadStatus in runtime-jira-summary-client.ts, covering both the local preload and remote-runtime RPC paths; jira-connection-actions.ts is untouched, so #24376's refresh behavior is preserved.
  • Crash-reproducing store test — jira-web-client-status.test.ts drives checkJiraConnection with the real withFallback({}, []) proxy as window.api and asserts the store settles on { connected: false, viewer: null } with jiraStatusChecked: true.
  • Parser unit tests — runtime-jira-connection-status.test.ts pins undefined/null/array/non-boolean/non-object/non-array inputs and well-formed pass-through with exact toEqual assertions.

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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered
📝 Walkthrough

Walkthrough

The Jira status parser validates values returned by runtime clients and normalizes a missing viewer to null. The status and site-selection operations, along with jiraReadStatus, now parse results from their RPC and local API paths. Tests cover parser inputs and the web client’s unwired Jira preload.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 2931c

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 Review

Security architecture risk: ⚪ Minimal · up to 2931c

The change handles missing Jira status safely without adding access or privileges. No material security risk was found in the compared changes.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed exposure is bounded to existing Jira connection-state consumers for the selected local or environment provider. Normalization does not introduce a new caller, destination, credential-bearing request or authorization operation.

Trust Boundaries and Controls

  • observed — Provider responses are now treated as unknown at the RPC result boundary and undergo shallow validation before entering typed connection state. Malformed top-level replies become disconnected rather than granting a connected state. Nested data remains accepted as before, so this is not a complete schema-validation or authorization control.

Resilience and Maintainability Implications

  • observed — Status reads retain generation and runtime-context checks on both success and failure. Site-selection completion rejects stale mutations, aborts or clears in-flight reads, and commits status with empty read caches in one store update. A malformed successful reply now follows that cleanup path with disconnected status; rejected calls still reject. These controls limit stale-provider and old-site state contamination.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix for the paired web client crash caused by a missing Jira status.
Description check ✅ Passed The description covers the required sections with a clear explanation of the cause, change, rationale, testing, and platform impact. It states that no issue is linked; the template requires one for ou…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

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

@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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2af8ee8c-a5c6-4732-87ee-596075d68294
📥 Commits

Reviewing files that changed from the base of the PR and between d173514 and 2931c06.

📒 Files selected for processing (5)
  • src/renderer/src/runtime/runtime-jira-client.ts
  • src/renderer/src/runtime/runtime-jira-connection-status.test.ts
  • src/renderer/src/runtime/runtime-jira-connection-status.ts
  • src/renderer/src/runtime/runtime-jira-summary-client.ts
  • src/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.

Comment on lines +13 to +14
!(value.viewer === undefined || value.viewer === null || isRecord(value.viewer)) ||
!(value.sites === undefined || Array.isArray(value.sites))

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.

🗄️ 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 1

Repository: 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

@brennanb2025
brennanb2025 merged commit f250db5 into main Oct 5, 2026
55 checks passed
brennanb2025 added a commit that referenced this pull request Oct 5, 2026
…rompt-on-command-line

Main now carries #24257 (squashed as 761d63a) and #25579, so this PR's diff is its own changes
again. #24257's files are identical on both sides; no conflicts.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review of merged #25579 against current origin/main (merge commit f250db55b77).

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: src/renderer/src/runtime/runtime-jira-connection-status.ts:14 accepts any array as sites, including an array containing null or an incomplete site. The returned value is asserted as JiraConnectionStatus, but the connected desktop settings view dereferences site.id, so a malformed remote status can still crash the renderer. I opened draft follow-up #25656 to validate nested viewer/site fields and every remaining status field before storing the reply; its new malformed-site and malformed-viewer cases fail with the merged parser.

P3: none.

Results: the focused command passed 58 tests: node_modules/.bin/vitest run --config config/vitest.config.ts --exclude '**/*real-cli*' --exclude '**/*real-binary*' src/renderer/src/runtime/runtime-jira-connection-status.test.ts src/renderer/src/store/slices/jira-web-client-status.test.ts src/renderer/src/runtime/runtime-jira-client.test.ts src/renderer/src/store/slices/jira.test.ts.

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.

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