Skip to content

perf(app): gate right-panel context and files tabs when inactive#854

Merged
Astro-Han merged 2 commits into
devfrom
claude/right-panel-gate-inactive-work
May 23, 2026
Merged

perf(app): gate right-panel context and files tabs when inactive#854
Astro-Han merged 2 commits into
devfrom
claude/right-panel-gate-inactive-work

Conversation

@Astro-Han

Copy link
Copy Markdown
Owner

Summary

Wrap SessionContextTab and FilesTab in <Show when={sidePanelTab() === ...}> so inactive right-panel tab content fully unmounts instead of staying live.

Two-line change at session-side-panel.tsx:411-413 and session-side-panel.tsx:543-545, matching the existing terminal pattern at line 531.

Why

Area B right-panel audit (#602) found that Context and Files tab content stayed mounted while the user was on another tab, doing real work:

  • SessionContextTab recomputes metrics / breakdown / systemPrompt memos and queues a requestAnimationFrame on every message-length change
  • FilesTab runs file.load() for each previewable artifact and calls platform.statPaths whenever props.files changes — and props.files itself reacts to Review state, so this fires while users review diffs

This contributes to the typing-lag observation in #615. The other right-panel tabs (Status, Review inner, Terminal) already have explicit guards; Context and Files were the two arms that slipped through.

The fix is not "completely stop all Context-related work" — the tab strip itself, including any per-tab indicators, is unaffected. Only the tab body content unmounts.

Related Issue

Refs #602 (Area B right-panel rewrite)
Contributes to #615 (session UI typing lag)

Human Review Status

Pending

Review Focus

  • The Show wrap correctness — does it correctly match each tab id?
  • Whether full unmount (vs gating only the heavy effects) is the right choice. Trade-off accepted: Context Accordion expansion state and Files scroll position are lost across remount. Context scroll position is preserved via the existing view().scroll("context") store; Files scroll persistence is not currently implemented and can be added separately if it becomes user-visible.
  • Pattern consistency with terminal at line 531.

Risk Notes

  • Behavior change: previously inactive Context/Files tabs kept their internal state (open Accordion items, Files scroll position). After this PR, that state resets on tab switch. Accepted as part of the perf win per the audit recommendation.
  • No platform, packaging, or shell surface touched.
  • No new dependencies.

How To Verify

typecheck:                bun run typecheck — 8/8 packages pass
lint:                     bun run lint packages/app/src/pages/session/session-side-panel.tsx — clean
focused tests:            bun test --preload ./happydom.ts \
                            src/pages/session/session-side-panel.test.tsx \
                            src/pages/session/right-panel-tabs.test.ts \
                            src/pages/session/migrate-session-view.test.ts
                          — 46 pass, 0 fail
visual check (snap):      bun run snap app-shell — passed, screenshot reviewed at
                            docs/design/preview/screenshots/app-shell.png;
                            sidebar + center chat + right-pane rendering unchanged

Manual desktop walk-through of all four tabs (Status / Files / Review / Context) deferred — change is purely additive control flow that mirrors the existing terminal pattern (line 531), and the active-tab render path is unchanged. Reviewer is welcome to request a dev:desktop recording if tab-switching dynamic verification is desired.

Screenshots or Recordings

docs/design/preview/screenshots/app-shell.png regenerated; no visible diff from baseline. Default app-shell snap does not exercise the right panel in an open state, so this confirms no regression to the default surface but does not visually demonstrate the gated tabs.

Checklist

  • Type label — this PR carries exactly one of bug, enhancement, task, documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.
  • Routing labels — this PR carries at least one of app, ui, platform, harness, ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.
  • Priority label — this PR carries exactly one of P0, P1, P2, P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.
  • Human Review Status above is set to Pending, Approved by @<reviewer>, or Not required: <reason> (default is Pending; "not required" is restricted to bot-authored low-risk PRs).
  • I linked the related issue, or stated in Summary why there is no issue.
  • I described the review focus and any meaningful risks.
  • I replaced the example block in How To Verify with the real verification steps and the key result for each.
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope.
  • (conditional) I manually checked visible UI or copy changes when needed, with screenshots or recordings. Leave unticked only if no visible UI or copy changed.
  • (conditional) I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes. Leave unticked only if no platform/packaging surface was touched.
  • (conditional) I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant. Leave unticked only if none of those surfaces was touched.
  • I reviewed the final diff for unrelated changes and suspicious dependency changes.
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English.

Wrap SessionContextTab and FilesTab in <Show when={sidePanelTab() === ...}>
to match the existing terminal-tab pattern. Inactive tab content fully
unmounts instead of staying live, so memos, effects, file.load(), and
platform.statPaths no longer run when the user is on another tab.

The tab strip itself is unaffected.

Refs #602
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 31 minutes and 22 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 04ce33fb-fb1d-4d2d-a525-c72e062a41cf

📥 Commits

Reviewing files that changed from the base of the PR and between 9d8fd29 and 1cb66b5.

📒 Files selected for processing (2)
  • packages/app/src/pages/session/session-side-panel.test.tsx
  • packages/app/src/pages/session/session-side-panel.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/right-panel-gate-inactive-work

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 and usage tips.

@github-actions github-actions Bot added app Application behavior and product flows ui Design system and user interface P2 Medium priority labels May 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested priority: P2 (includes user-path files (packages/app/src/pages/session/session-side-panel.tsx)).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@Astro-Han Astro-Han added the enhancement New feature or request label May 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the SessionSidePanel component to conditionally render the FilesTab and SessionContextTab using the Show component based on the active tab state. This change likely improves performance by preventing unnecessary mounting of tab content when it is not visible. I have no feedback to provide as there are no review comments.

@github-actions

github-actions Bot commented May 23, 2026

Copy link
Copy Markdown

Perf delta summary

Comparator: pass

Profile / Scenario interaction median interaction worst long task max tbt frame gap p95 frame gap max jank count cls status
default / homepage-cold 24 -> 32 (+8) 40 -> 40 (0) 74 -> 64 (-10) 24 -> 14 (-10) 16.8 -> 16.8 (0) 183.3 -> 116.6 (-66.7) 2 -> 3 (+1) 0 -> 0 (0) pass
default / tool-default-open-heavy-bash 16 -> 16 (0) 24 -> 24 (0) 77 -> 74 (-3) 43 -> 41 (-2) 50 -> 50 (0) 116.7 -> 116.7 (0) 3 -> 3 (0) 0 -> 0 (0) pass

Add source-grep contract tests in session-side-panel.test.tsx that assert
each tab body (files, context, terminal) sits inside a Show wrapper keyed
to its sidePanelTab id. Matches the project pattern in no-mode-picker.test.ts.

Catches the most likely regressions: tab-id typos, copy-paste mistakes,
and any future change that drops the Show wrap.

A full render test for these wrappers would need to mock the entire
SessionSidePanel context surface; source-grep covers the same regression
shapes at much lower maintenance cost.

Refs #602
Addresses P3 review feedback on #854
@Astro-Han

Copy link
Copy Markdown
Owner Author

Re: P3 — added a source-grep contract test in session-side-panel.test.tsx that asserts each tab body (files, context, terminal) sits inside a <Show when={sidePanelTab() === "<id>"}> wrapper. Matches the project pattern from no-mode-picker.test.ts.

This catches the regression shapes you flagged:

  • Tab-id typo (e.g. === "filles")
  • <Show> wrap accidentally removed
  • Future "let's drop guards for consistency" change

Also covers the terminal tab so it can't be removed alongside the new ones.

What this does NOT cover: Kobalte Tabs behavior changes. A full render test would catch that, but for this scope it would need to mock the entire SessionSidePanel context surface; the cost felt high relative to the marginal coverage. Happy to escalate to a render test if you'd prefer.

Pushed as 1cb66b5359.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows enhancement New feature or request P2 Medium priority ui Design system and user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant