Skip to content

Avoid downloading unchanged paired-runtime session history - #27383

Merged
nwparker merged 3 commits into
mainfrom
nwparker/perf-session-list-unchanged-response
Oct 11, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/perf-session-list-unchanged-response

Conversation

@nwparker

@nwparker nwparker commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​568 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​564
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251 $\color{#cf222e}{\Huge{\mathbf{−}}}$​70 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​181

ELI5

Refreshing Agent Session History at a finite history depth on a selected paired runtime now sends a small confirmation when its contents have not changed, so an idle refresh does not compete with terminal traffic for a multi-megabyte download.

What Changed

The host scans with the existing freshness policy, then fingerprints the complete projected reply except its scan timestamp. An opted-in caller with the same fingerprint receives an unchanged confirmation and reuses the exact history it already displays. The existing 15-second main-process cache also holds compact confirmations for matching callers, without retaining another history body or changing its expiry.

Older clients receive the existing full reply. Older hosts ignore the optional request field and return full history. Force refreshes still rescan and return full history. Host, project and depth changes start with a full reply; unlimited-depth, all-host, local and SSH views keep their current path.

Why

A read-only scan of 1,000 actual local sessions produced a 1,854,465-byte full reply and a 164-byte unchanged reply: 99.99% fewer bytes. Fingerprinting the complete result took 4.12 ms median / 4.39 ms p95 locally. This removes redundant transfer while preserving previews, titles, structured ownership, warnings and scan freshness. Raising cache lifetimes would retain more memory or stale data; compressing the connection would still resend unchanged history.

Thanks to @mmarabel for the measurements and proposal in #27277; credited as a commit co-author.

Linked Issue

Fixes #27277

Visual Proof

The history contents, layout and interactions stay the same. Attached fixture screenshots show the full reply and compact unchanged reply preserving the same expanded history. Hidden Electron/CDP validation checks unchanged refreshes retain rows and previews, changed content updates, and host/depth switches use full replies. This rendered check used scripted IPC replies and synthetic visibility events; the protocol is covered by focused tests, without a live paired-network check.

Testing

  • I manually tested these changes locally (hidden Electron/CDP)
  • Automated tests added/updated
  • Meaningful regression fails before this change: opting in returns no fingerprint on the base branch.
  • Focused coverage checks full/unchanged and old-peer replies, force rescans, same-timestamp content changes, previews, issues, concurrent callers, scope/depth isolation, cancellation, result identity and strict 15-second cache disposal.
  • Local macOS: 200 tests across 19 relevant suites; 43 affected tests rechecked after the final unlimited-depth gate. Node/web typechecks, changed-code quality gate, changed-file lint and RPC catalog verification passed.
  • Hidden Electron/CDP after rebuilding final code: full/unchanged preserves rows, previews and expanded content; same-timestamp changes update titles/replies and new rows; host/depth switches and unlimited refreshes return full history. CI covers other platforms.

Review

Independent wire review and additional real-hook lifecycle checks passed. The content fingerprint is stateless and computed after caller-specific projection, so it does not depend on process lifetime or share another client's cache body.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The optimization currently applies to a selected paired-runtime host. No negative user-facing trade-offs identified. A changed list costs one additional JSON/hash pass before its full transfer; legacy and unlimited-history calls do not compute a fingerprint.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Fixture before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and compatibility considered
  • CI passes

Full reply fixture with expanded history

Compact unchanged reply preserves the same expanded history

Keep selected finite-depth history refreshes content-conditional while preserving scans, full old-peer replies, force refreshes and the existing cache lifetime.

Co-authored-by: mmarabel <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The change adds fingerprint-based conditional replies for AI Vault session lists. Runtime hosts compute fingerprints without scannedAt and return an unchanged marker with empty session and issue lists when the supplied fingerprint matches. IPC forwarding and cache reuse apply exact fingerprint and depth checks. For eligible renderer refreshes, the client reuses its saved result or retries without the conditional fingerprint when it cannot validate an unchanged reply.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 352ea

Session history refreshes should work as intended. One unlikely edge case could return an empty session list from the cache instead of rescanning. It is easy to guard against, and the risk is low.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 22 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 and concisely describes the main change: avoiding downloads of unchanged paired-runtime session history.
Description check Passed The description is complete and aligned with the template. It explains the user impact, implementation, motivation, linked issue, visual proof, testing, compatibility, performance, and scope. The CI c…
Linked Issues check Passed Issue [#27277] requires a small reply for an unchanged finite-depth session-history refresh on a selected paired runtime, while preserving compatibility with older peers. The host computes a SHA-256 f…
Out of Scope Changes check Passed The changes stay within [#27277]. They update the session-list protocol, runtime scan path, paired-host cache, and Agents-panel refresh path to avoid retransmitting unchanged finite-depth history. The…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • 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.

@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/ipc/ai-vault-host-leg-cache.ts (1)

75-76: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Normalize afterFingerprint before comparing it with result.fingerprint.

afterFingerprint can be null or undefined. result.fingerprint is string | undefined. When a cached compact result has no fingerprint, undefined === undefined is true for a fingerprint-less request. The cache then returns the empty unchanged body to a reader that never asked for a conditional reply. The host RPC always sets a fingerprint on unchanged results, so this is unlikely in practice. The cache should still not depend on that.

Require a truthy fingerprint in both checks.

Proposed fix
-    (!cached.result.unchanged ||
-      (cached.depth === args.depth && cached.result.fingerprint === args.afterFingerprint))
+    (!cached.result.unchanged ||
+      (cached.depth === args.depth &&
+        !!args.afterFingerprint &&
+        cached.result.fingerprint === args.afterFingerprint))
-    (!current.result.unchanged ||
-      (current.depth === args.depth && current.result.fingerprint === args.afterFingerprint))
+    (!current.result.unchanged ||
+      (current.depth === args.depth &&
+        !!args.afterFingerprint &&
+        current.result.fingerprint === args.afterFingerprint))

Also applies to: 100-101


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fa958303-d809-49db-bd30-e37297532be9
📥 Commits

Reviewing files that changed from the base of the PR and between 1743a37 and 352ea3b.

📒 Files selected for processing (3)
  • src/main/ipc/ai-vault-host-leg-cache-retention.test.ts
  • src/main/ipc/ai-vault-host-leg-cache.ts
  • src/main/ipc/ai-vault.ts

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

@nwparker
nwparker merged commit c2c63e7 into main Oct 11, 2026
31 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.

[Bug]: Agents panel re-downloads the full session list from a paired host on every refresh, even when nothing changed

1 participant