Skip to content

refactor(session-history): one decision for a row's open and resume offers - #28360

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/session-history-panel-refactor
Oct 14, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/session-history-panel-refactor

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​98 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​68
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​242 $\color{#cf222e}{\Huge{\mathbf{−}}}$​119 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​123

ELI5

The Agents panel in the right sidebar (Agent Session History) lists past agent conversations and lets you reopen them. PR #28133 will show the same panel in a dialog when you type /resume in a chat. To prepare for that, this PR tidies the panel's code first, with no change you can see: the sidebar looks and behaves exactly as before.

What Changed

Before and after, for the user: nothing changes. Same rows, same buttons, same greyed-out ▶ where a session can't resume, same scopes and search.

Mechanism:

  • One function for a row's ▶, switch-to-open-pane, Resume in New Native Chat and Resume in New CLI offers. On main, the row worked out ▶'s greyed-out state from the session's resume gating and the search hit, and gated the switch-to-pane, Resume in New Native Chat and Resume in New CLI offers inline. A new function, resolveAiVaultSessionRowChatActions (ai-vault-session-chat-action.ts), now decides those four, with the same rules as before. feat(native-chat): /resume in a structured chat opens Agent Session History #28133's Enter key reads the same function, so Enter matches what those buttons offer. The row's other actions (Resume in Worktree / New Tab, Continue in New Session, Copy Resume, drag to resume) keep their own checks, unchanged.
  • Two blocks moved out of AiVaultPanel.tsx unchanged: the host-scope menu (useAiVaultPanelHostScope in ai-vault-host-scope.ts) and the per-session "where does this live, where would it resume" lookups (use-ai-vault-panel-session-resume.ts). This keeps the panel under the file-length limit once feat(native-chat): /resume in a structured chat opens Agent Session History #28133 adds to it.
  • The session-list request reads the panel's workspace through one selector (selectAiVaultPanelWorkspace in ai-vault-panel-workspace.ts). For the active workspace it returns exactly what the old inline code did. feat(native-chat): /resume in a structured chat opens Agent Session History #28133 uses the same selector to bind a panel to a chat's own workspace.

Why

The /resume dialog in #28133 is the same panel mounted a second time, and its Enter key has to follow the same rules as the row buttons. Putting those rules in one function first means Enter can't drift from the buttons. Doing the refactor in its own PR keeps it reviewable as a pure move, with moved code that isn't also being edited. The alternative, leaving this inside #28133, mixed a refactor with a feature in one diff.

Linked Issue

N/A: maintainer PR. It prepares #28133 (/resume in native chat opens Agent Session History).

Visual Proof

N/A: no visual or interaction change. The sidebar renders and behaves the same; this only moves and consolidates code.

Testing

  • I manually tested these changes locally (no rendered check: there is no visible change, so only the automated suites below were run)
  • Automated tests added/updated
    • New: ai-vault-session-chat-action.test.ts pins what feat(native-chat): /resume in a structured chat opens Agent Session History #28133 depends on: ▶ resumes only while it is enabled and shown, and a search hit whose transcript is gone offers nothing.
    • Updated: the tab-bar parity test (tab-session-history-switch.parity.test.ts) now runs the panel's real hook and the row's real function, instead of a hand copy of them.
    • All test files under src/renderer/src/components/right-sidebar/ and src/renderer/src/components/tab-bar/ pass (372 files, 3160 tests).
    • pnpm tc:web passes. pnpm run check:code-quality:changed passes.
    • orca-ci-checks passed 23 of 24. The one failure is the typecheck:ci step, which runs bun check; this machine's bun has no check script. The plain pnpm run typecheck step in the same run passes, and CI covers the bun step.
  • Platforms: macOS locally. Nothing here touches processes, paths or shortcuts.

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

  • SSH / remote and folder workspaces: the selector uses the same lookup as before, which covers folder and floating workspaces and resolves the active workspace on its own host.
  • Mobile and mixed versions: renderer-only; no wire changes.
  • Performance: unchanged; the moved hooks keep the same memoization.

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)

A session row decided "can ▶ resume this" twice: once for the button's
disabled state and again inside its click handler, and the chat/CLI and
switch-to-pane offers were each gated inline. A second caller of those
offers would have had to copy the same conditions again.

- One projection, resolveAiVaultSessionRowChatActions, now decides every
  open/resume offer a row makes; ▶'s greyed-out state and its target come
  from the same value.
- The panel's host-scope menu and per-session resume lookups move into
  their own hooks unchanged, and the session-list request reads the
  panel's workspace through one selector.

The sidebar behaves exactly as before.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/session-history-panel-refactor branch from 395ccd2 to d29a88e Compare October 13, 2026 18:31
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready to merge (first of two)

Why this exists. #28133 lets you type /resume in a native chat to open Agent Session History in a dialog. To host the same panel a second time, bound to a chat's workspace, the panel needed some reshaping first. This PR is that reshaping, split out so it can be reviewed as a pure refactor.

What changes for the user: nothing. The right sidebar's Agents → Agent Session History panel looks and behaves exactly as before.

What moved:

  • Two pieces of the panel (host scope and per-row resume) moved into their own hooks, word for word.
  • The workspace lookup now uses one selector shared with the session list request.
  • ▶, switch-to-open-pane, Resume in New Native Chat and Resume in New CLI now take their decision from one function. feat(native-chat): /resume in a structured chat opens Agent Session History #28133's keyboard Enter uses that same function, so it can never disagree with the buttons.

Verified:

  • A refactor audit confirmed the moved code is verbatim and ▶'s enabled state and target match main for every kind of row.
  • A readiness checklist found nothing.
  • On the M4Air, QA compared the sidebar panel against main and found it identical.
  • The parity test runs the real extracted hook and row function.
  • Merged with current main with no conflicts, and CI is green.

Deferred: nothing.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 13, 2026 23:31
@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f2bcf69d-8d3c-4962-a4c2-f2dc9a14ac7a
📥 Commits

Reviewing files that changed from the base of the PR and between 335cc32 and 22d5ca5.

📒 Files selected for processing: 9
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/AiVaultVirtualRow.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-host-scope.ts
  • src/renderer/src/components/right-sidebar/ai-vault-panel-session-list-request.ts
  • src/renderer/src/components/right-sidebar/ai-vault-panel-workspace.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-chat-action.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-chat-action.ts
  • src/renderer/src/components/right-sidebar/use-ai-vault-panel-session-resume.ts
  • src/renderer/src/components/tab-bar/tab-session-history-switch.parity.test.ts

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

📝 Walkthrough

The panel now delegates workspace lookup, execution-host scope, and session resume derivation to shared helpers. A row-action resolver determines jump availability, resume state, and resume targets. Unit and parity tests cover the resolver and compare its targets with tab-session switch results.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 22d5c

No behavior regression requiring a fix before merge is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main refactor: centralizing decisions for a session row’s open and resume actions.
Description check Passed The description is complete and relevant. It explains the user-visible impact, implementation changes, motivation, testing, platform considerations, and checklist status. It also documents the unavail…
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.
  • 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.

@brennanb2025
brennanb2025 merged commit d7f7474 into main Oct 14, 2026
54 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/session-history-panel-refactor branch October 14, 2026 00:06
@brennanb2025
brennanb2025 restored the brennanb2025/session-history-panel-refactor branch October 14, 2026 00:06
@brennanb2025
brennanb2025 deleted the brennanb2025/session-history-panel-refactor branch October 14, 2026 00:06
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