Skip to content

Optimize hidden chat subscriptions and tab projections - #36047

Merged
AmethystLiang merged 8 commits into
mainfrom
AmethystLiang/perf-hidden-chat-indexes
Oct 29, 2026
Merged

AmethystLiang merged 8 commits into
mainfrom
AmethystLiang/perf-hidden-chat-indexes

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​351 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​343
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​366 $\color{#cf222e}{\Huge{\mathbf{−}}}$​76 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​290

Problem

Hidden chats and large tab layouts were doing repeated work for updates that did not affect them, causing unnecessary rerenders, layout reads, and rescans.

Solution

Only update the chat or tab whose relevant data changed. Cache unchanged ownership and request data, skip hidden-pane layout reads, and reuse shared layout diffs.

ELI5

Hidden chats now stay quiet unless something relevant to that specific chat changes.

What Changed

  • Scoped launch-directory and runtime-context subscriptions to each chat tab.
  • Skipped transcript scroll-margin layout reads while panes are hidden.
  • Incrementally patched tab-bar agent and fallback projections from shared layout diffs.
  • Reused AI Vault title request membership for owner-only updates and released closed-tab cached state.
  • Added performance, regression, garbage-collection, and fuzz coverage.

Why

This prevents broad status, rank, catalog, and layout updates from making every retained chat or tab redo work when only one item changed.

Linked Issue

Fixes #

Visual Proof

N/A — no visual or interaction change; this is an internal performance optimization.

Testing

  • Automated tests added/updated for subscription fanout, hidden transcript behavior, projection diffs, AI Vault cache cleanup, and fuzz equivalence.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

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

Considered security, cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, backwards compatibility, and performance. No user-facing behavior change intended.

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)

… rescanning every layout

The shared TabBar agent projection rebuilt agent types and tab-wide chat
fallback safety from every terminal layout (~2.5k at the captured scale) and
every status row whenever either map's identity changed. Status pings that
keep each pane's agent type now reuse the cached projection, and layout edits
re-resolve only the added, replaced or removed tabs. Key reorders, agent-type
changes and added/removed status rows still take the full projection.
…very agent conversation

The AI Vault title subscription ran two full agent-conversation collections
(every terminal tab, retained, sleeping and live record) whenever any owner
input changed identity, including worktree rank/unread patches and unrelated
settings writes. Compare worktree rows through the existing owner-rows token
so rank-only patches skip the check, and reuse the conversation workspace set
while the agent/tab maps it reads are unchanged, so owner-only updates compare
only those workspaces' hosts. Real host moves still schedule a title rescan.
… feed ticks

Each host status feed tick re-captured every structured chat member on that
host (hundreds at the captured scale), resolving each tab's owner about three
times plus companion pin checks, even though a status event names one
session. Members whose feed facts (summary, observation, failure, sleep and
launch directory) and tab are unchanged since their last consumed capture are
now skipped, and tab owners are cached until an owner input changes, with
worktree rows compared through the rank-insensitive owner-rows token.

An input is marked consumed only after projection returns normally, so a
throwing store commit still retries on the next emission. The bridge remains
the only writer of slept-at and launch-directory pins, so skipping unchanged
members does not drop a needed re-assertion.
…idden chats

The transcript window re-read its scroll margin through an offsetTop walk in
a dependency-free layout effect, so every render of every retained chat forced
a synchronous layout read, including display:none panes where the walk cannot
produce a margin. The read now runs only while the pane is visible; becoming
visible re-renders and measures, and mount/resize measurements are unchanged.
…y mounted chat

useNativeChatImageRuntimeContext shallow-subscribed each chat root to
worktree rows, runtime environments, SSH state and other owner maps, then
resolved the context in render. A worktree rank patch or a host catalog
timestamp refresh replaced one of those maps and re-rendered the whole
NativeChatStructuredSession of every mounted chat, hidden ones included (57 of
57 probes per write in the subscription benchmark). The selector now resolves
the context itself and keeps the previous identity while the result is
shallow-equal, so chats re-render only when their route or path changes.
- Use a stable PRNG that exercises the full operation space
- Assert tab, agent, layout, and operation coverage
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

This PR reduces repeated work in retained chats and tab bars.

  • Chat updates refresh only the tabs whose session facts or directory changed.
  • Hidden chat panes skip scroll-margin layout reads.
  • Tab bars patch agent and fallback results for changed layouts.
  • AI Vault title syncing reuses request membership and checks only relevant ownership changes.

No actionable issues were found. Tests were inspected but not run.

Reviews (1) · Last reviewed commit: "Strengthen tab agent projection fuzz cov..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 54a9e59d-9c1b-4343-8593-f4d56f062e6c
Commits

Reviewing files that changed from the base of the PR and between f87d68b and 3428620.

Files selected for processing: 12
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.launch-directory.test.tsx
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.tsx
  • src/renderer/src/components/native-chat/native-chat-file-link.ts
  • src/renderer/src/components/native-chat/native-chat-image-runtime-context.test.ts
  • src/renderer/src/components/native-chat/native-chat-image-runtime-context.ts
  • src/renderer/src/components/native-chat/native-chat-subscriptions.performance.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-transcript-window.options.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-transcript-window.ts
  • src/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.test.ts
  • src/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.ts
  • src/renderer/src/lib/ai-vault-tab-title-sync-inputs.test.ts
  • src/renderer/src/lib/ai-vault-tab-title-sync-inputs.ts

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

Walkthrough

The changes add cached owner and projection inputs to the structured-session status bridge. Native-chat file-link and image runtime-context selectors now track the selected tab’s launch-directory pin. Tab-agent selectors incrementally update projections after status or layout changes. Title-sync input comparison caches request worktree IDs. Transcript scroll-margin measurement now runs only when the pane is visible.

Priority: Low

Merge Risk: Minimal · up to 34286

The change reduces hidden-chat and tab-bar update work without a user-facing behavior change, and no actionable merge-blocking risk remains after review.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description clearly explains the problem, solution, scope, testing, and lack of user-facing changes. However, the required Linked Issue is incomplete as Fixes #, and the validation checklist doe… Add a valid issue reference after Fixes #. Confirm that lint, typecheck, tests, and build pass, or state that CI will cover them. Complete the self-review checklist if applicable.
Docstring Coverage Warning Docstring coverage is 22.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title is concise and accurately summarizes the main changes: optimizing hidden chat subscriptions and tab projections.
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.
Full details: Description check

Explanation

The description clearly explains the problem, solution, scope, testing, and lack of user-facing changes. However, the required Linked Issue is incomplete as Fixes #, and the validation checklist does not confirm the required checks or CI coverage.

Resolution

Add a valid issue reference after Fixes #. Confirm that lint, typecheck, tests, and build pass, or state that CI will cover them. Complete the self-review checklist if applicable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 22.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 22 functions across 12 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

@AmethystLiang
AmethystLiang merged commit cb21824 into main Oct 29, 2026
37 of 40 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