Skip to content

perf(shell): make settled transcript cards free per frame - #3490

Merged
Alan-TheGentleman merged 1 commit into
mainfrom
perf/shell-settled-card-cache
Nov 23, 2026
Merged

Alan-TheGentleman merged 1 commit into
mainfrom
perf/shell-settled-card-cache

Conversation

@Alan-TheGentleman

@Alan-TheGentleman Alan-TheGentleman commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Settled transcript cards (quiet tool cards, background-job notices, agent results and settled agent tool results) keep one rendered frame keyed by width, card style and render revision, so a finished card costs nothing on later frames.
  • Cards that are still changing (running tools, live elapsed time, new output, expand/collapse, theme or card-style change, resize) re-render exactly as before.

Changes

File Change
lib/shell-card.ts One cached frame per card component, keyed by width, style and revision; invalidate() clears it
lib/background-jobs-tools.ts Completed job and monitor notices use the cached frame
extensions/gentle-agents.ts Agent notices and settled agent tool results use the cached frame
extensions/quiet-tools.ts Bash heading frames follow the live card-content preference; cached body
tests/shell-render-cache-runtime.test.ts Wrap-count, invalidation, lifecycle, mouse and byte-identical frame tests; opt-in frame benchmark

Test plan

  • node --experimental-strip-types --test on this state's files (render cache, shell-card, gentle-agents, background-jobs, quiet tools, changes, gentle-shell, desktop RPC/feed, change-diff) with --test-concurrency=1: 973 tests, 972 pass, 0 fail, 1 skipped (opt-in benchmark). scripts/check-types.mjs: 0 diagnostics.
  • RED on the base: 12 settled cards ran the wrap path 156 times over 13 frames instead of 12.
  • 45 ANSI frames compared byte for byte against the base renderer (agent notice, job notice, agent tool result, Bash), including resize, theme, expansion, new output and failure; an independent verifier added 54,549 + 88,821 bytes of frame captures, all identical.
  • Synthetic 80-card frame: median 4.216 ms -> 0.005 ms; p95 5.044 ms -> 0.011 ms. Live session profile while a tool runs: the renderCard wrap path (25-33 % of the main thread before) no longer appears.

Chain context

📍 main ← #3490 cards
     └─ #3491 Git reader
     └─ #3492 untracked counts
     └─ #3493 idle Changes load

Refs #2921
Refs #3489

Summary by CodeRabbit

  • Performance
    • Improved responsiveness when agent, job, Bash, and tool cards are rendered repeatedly, including as their content or display settings change.
    • Card layouts continue to adapt to different widths, and live updates such as Bash output and job status remain reflected.

Settled cards (quiet tools, background jobs, agent results) keep one
rendered frame keyed by width, card style and revision, so a finished card
costs nothing on later frames; cards still changing re-render as before.
Frames are byte-identical to the previous renderer. Runtime render-cache
tests added.

Refs #2921
Refs #3489
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds shared row caching for transcript cards and applies it to agent results, job notices, and tool cards. Runtime tests cover cache reuse, rendering updates, invalidation, and Bash output behavior.

Changes: Transcript card caching

Layer / File(s) Summary
Shared card cache
lib/shell-card.ts
CardFrame reuses rendered rows when width, card style, and revision match. cachedCard adapts a width-based renderer to a Component and forwards invalidation.
Agent and job renderer adapters
extensions/gentle-agents.ts, lib/background-jobs-tools.ts
Agent result renderers and job notices use cachedCard. Partial agent tool results remain uncached.
Tool card caching and runtime coverage
extensions/quiet-tools.ts, tests/shell-render-cache-runtime.test.ts
Tool card headings and bodies use CardFrame. Bash heading revisions include pending status and, for Bash cards, the minimal Card content preference. Runtime tests cover cache reuse, rendering changes, invalidation, live Bash output, timers, and an optional benchmark.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

  • Issue 3489 reports repeated rendering and text wrapping for finished cards. This change caches settled agent, job, and tool card rendering, but does not address Changes scanning or Git read failures.

Possibly related PRs

Suggested reviewers: decode2, carolitascl

Merge Risk: Minimal · up to bae87

This change caches settled transcript cards so later frames cost almost nothing, and it keeps re-rendering cards that are still changing. No merge-blocking defect was found. Expansion, resize, theme changes and live output continue to re-render, and runtime tests cover those cases.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "perf(shell): make settled transcript cards free per frame" matches the main change. The PR adds a one-frame cache (CardFrame and cachedCard in lib/shell-card.ts) so settled transcript cards…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "perf(shell): make settled transcript cards free per frame" matches the main change. The PR adds a one-frame cache (CardFrame and cachedCard in lib/shell-card.ts) so settled transcript cards skip re-rendering on later frames, while changing cards still re-render. The title is concise, specific, and uses a conventional commit prefix. It does not list every touched file, which is acceptable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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: ASSERTIVE
  • Plan: Team
  • Run ID: af2ed39e-9468-42c6-a93c-9506bcd437c7
Commits

Reviewing files that changed from the base of the PR and between be74d44 and bae87d8.

Files selected for processing: 5

  • extensions/gentle-agents.ts
  • extensions/quiet-tools.ts
  • lib/background-jobs-tools.ts
  • lib/shell-card.ts
  • tests/shell-render-cache-runtime.test.ts

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

@Alan-TheGentleman
Alan-TheGentleman merged commit ccf9864 into main Nov 23, 2026
10 checks passed
@Alan-TheGentleman
Alan-TheGentleman deleted the perf/shell-settled-card-cache branch November 23, 2026 15:38
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