Skip to content

fix(integrations): notice Jira and Linear state changes from other processes - #28594

Merged
nwparker merged 3 commits into
mainfrom
nwparker/integration-state-reload
Oct 14, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/integration-state-reload

Conversation

@nwparker

@nwparker nwparker commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​630 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​610
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​181 $\color{#cf222e}{\Huge{\mathbf{−}}}$​175 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

Connect Jira or Linear in one Orca process, and another process on the same host could keep saying it was disconnected until you restarted it. It could also keep using an old API token after another process replaced or removed it. The other process now notices connection, selection, and credential-file changes on its next read.

What Changed

Jira site records and the Linear workspace registry reuse saved metadata only while the file identity is unchanged. Their token caches use the same file check, retaining at most 128 credential/error entries per integration. Status checks read file metadata without decrypting tokens. An actual Jira or Linear action decrypts the current credential once and reuses it until the file changes. Local token writes invalidate the cache so an overlapping writer cannot pin an older token as current.

Cached account metadata retains accounts whose token is temporarily absent; status and request readers check current token presence each time. This lets a restored token become usable without another metadata write. Existing requests keep their captured account and cancellation signal, and Linear's optional credential revision remains intact.

The cache reuses Orca's existing precise file-stat signature, extracted from the daemon hash cache without changing its behavior. File IDs and nanosecond timestamps detect same-size replacements; the backing path also belongs to the cache identity. Encryption and saved file formats are unchanged.

Why

Every Orca process on a host reads the same integration files, but the old metadata caches loaded once and decrypted tokens stayed in memory after external replacement or removal. A file check gives current reads fresh state without polling, watchers, repeated JSON parsing, or status-triggered keychain prompts. Stamping before reading ensures a write during the read is reconsidered on the next read.

Adapted from PR #13125 by Minho Yi (@tisohjung), credited in the commit. This version preserves bounded credential storage, removes the unchecked generic cast, and reuses the existing file identity implementation.

Linked Issue

References #13125. The source PR records a separately reproduced storage bug with no dedicated issue; no duplicate issue created.

Visual Proof

N/A — storage-cache invalidation only; no layout, controls, or interaction flow changes. Production Jira and Linear readers are exercised against externally rewritten temporary files in the regression tests.

Testing

  • Live two-app integration check; no live Jira/Linear accounts or real credential files used.
  • 108 automated tests pass across nine suites: metadata cache, token cache, Jira client/scoped authentication/search cancellation/attachment images, Linear client/credential reset, and existing daemon hash cache.
  • Nine new Jira/Linear token rotation, removal, and restoration regressions failed before the token-cache correction; all pass afterward. Earlier metadata connection/disconnect/selection regressions also failed with the original caches.
  • Tests cover unchanged-file memoization, absent/empty/deleted files, same-size atomic replacement with preserved modification time, path changes, rotation during decryption, bounded credential/error storage and eviction order, keychain approval retry, lazy status checks, legacy Linear credentials, external credential revisions, and captured request ownership/signals.
  • ORCA_BACKGROUND_LAUNCH=1 GOMAXPROCS=2 node config/scripts/run-vitest.mjs run --config config/vitest.config.ts src/main/integration-state-file-cache.test.ts src/main/integration-token-file-cache.test.ts src/main/jira/client.test.ts src/main/jira/client-scoped-token.test.ts src/main/jira/jira-search-abort.test.ts src/main/jira/attachment-images.test.ts src/main/linear/client.test.ts src/main/linear/linear-workspace-registry.test.ts src/main/daemon/daemon-host-file-hash-cache.test.ts --maxWorkers=2
  • Changed-code quality, focused anti-slop, formatting, and diff checks pass. Focus-read gate passes at 1,119 reads. The final base-only rebase preserves all 13 changed-file hashes.
  • Rebased onto main 51173e45d45a, including the landed scoped Jira authentication. Gateway validation, email-free scoped credentials, persisted gateway URLs, account identity and captured requests are preserved; only two import conflicts needed reconciliation. Both earlier CI failures stopped on an unrelated duplicate now property in session code; the updated base contains that correction. Final full typecheck/build and new-head CI remain to run.
  • Tested on macOS using temporary files and a mocked secret store. Linux/Windows, live SSH, and actual OS keychain prompts remain for CI/integration testing.

Review

Code merge risk: Low; final full checks are pending. Independent review of both the token correction and its composition with landed authentication found no concrete blocker. The change uses one existing file-identity mechanism for metadata and credentials. Status remains lazy, errors and tokens stay bounded, and current requests keep their captured owners/signals. External token rotation/removal no longer leaves a usable stale credential in the cache. A write concurrent with an already-started read may reach that read; its older stamp forces the next read to retry. Simultaneous full-file writes still have the existing last-writer behavior. This updates subsequent credential reads; issue text and images already retained by other caches follow their existing lifecycle. Token-file changes do not clear the host attachment cache (96 entries / 24 MiB / 30 minutes) or notify existing renderer image/Blob state; a mounted Blob may remain visible until invalidation or unmount. Disconnecting or reconnecting through this process still clears the host attachment cache. The legacy Linear viewer JSON remains load-once; its token reloads, but external edits to that legacy display metadata remain outside this change.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer source or artifacts copied.

Notes

Each execution host reads its own existing integration directory; no local-only or Git-worktree assumption. macOS/Linux/Windows use Node filesystem calls and existing path builders. WSL/SSH ownership stays on the host. No RPC, streams, published schema, or mixed-version wire changes. Mobile clients benefit through host status reads. The first explicit action after a local credential save now reads the actual file instead of trusting an in-memory token seeded by that save.

Checklist

  • Small and focused
  • ELI5, before/after, mechanism, and choice explained
  • Visual proof is N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH, folder-workspace, mobile, and compatibility impact considered
  • Full lint/typecheck/test/build: 108 focused tests and changed quality pass; final full checks remain

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bce59cbe-2055-45c0-97f4-6d85a6327fd6
📥 Commits

Reviewing files that changed from the base of the PR and between 5e1c117 and 8d2a02e.

📒 Files selected for processing: 8
  • src/main/daemon/daemon-host-file-hash-cache.ts
  • src/main/file-stat-signature.ts
  • src/main/integration-state-file-cache.test.ts
  • src/main/integration-state-file-cache.ts
  • src/main/jira/client.test.ts
  • src/main/jira/site-credential-store.ts
  • src/main/linear/client.test.ts
  • src/main/linear/linear-workspace-registry.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The change adds a shared file-stat signature and a generic cache for integration state files. Jira site data and Linear workspace data now use the cache, which reloads data when the file path or stat signature changes. New tests cover cache behavior and status updates after integration state changes.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 8d2a0

No merge-blocking issue was established for this change; merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed 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 18 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: detecting Jira and Linear state changes made by other processes.
Description check Passed The description is detailed and covers the required explanation, changes, rationale, testing, review, compatibility considerations, and checklist. It also documents that full checks remain pending and…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • 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

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

@nwparker
nwparker force-pushed the nwparker/integration-state-reload branch from 8d2a02e to cc8e924 Compare October 14, 2026 09:47
@nwparker
nwparker force-pushed the nwparker/integration-state-reload branch from fc726f5 to 0c8d141 Compare October 14, 2026 10:22
@nwparker
nwparker merged commit 5ae088a into main Oct 14, 2026
9 checks passed
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