Repository navigation
fix(integrations): notice Jira and Linear state changes from other processes - #28594
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
8d2a02e to
cc8e924
Compare
Adapt PR #13125 and reuse the existing precise file identity signature for cache invalidation. Co-authored-by: Minho Yi <[email protected]>
fc726f5 to
0c8d141
Compare
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
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=251173e45d45a, 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 duplicatenowproperty in session code; the updated base contains that correction. Final full typecheck/build and new-head CI remain to run.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
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