Skip to content

fix(ai-vault): preserve transient panel state#9419

Open
just-zzp wants to merge 1 commit into
stablyai:mainfrom
just-zzp:fix/agent-session-history-state
Open

fix(ai-vault): preserve transient panel state#9419
just-zzp wants to merge 1 commit into
stablyai:mainfrom
just-zzp:fix/agent-session-history-state

Conversation

@just-zzp

@just-zzp just-zzp commented Jul 19, 2026

Copy link
Copy Markdown

Summary

  • Preserve the Agent Session History scope preference (Workspace, Project, or All) when the Agents panel is unmounted while switching right-sidebar tabs.
  • Preserve collapsed agent groups and expanded session details across the same tab switches.
  • Fall back to All when the preferred context is unavailable without forgetting the preference, and restore it when that context returns.
  • Keep this state renderer-session-only and bound each disclosure cache to 512 entries.

Fixes #9418

Related: #8146, #8961

Screenshots

The screenshots use mock sessions only; no personal session data is included.

Before

Project is selected, the Codex session details are expanded, and the Claude group is collapsed.

Agent Session History before switching tabs: Project selected, Codex session expanded, Claude group collapsed

Explorer

The right sidebar is switched away from Agents to Explorer.

Right sidebar switched from Agents to Explorer

After

Returning to Agents restores the selected scope and both disclosure states.

Agent Session History after returning: Project and disclosure states restored

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Validation completed:

  • Targeted Agent Session History suite: 16 files, 169 tests passed.
  • Added regression coverage for panel remounts, unavailable Workspace/Project context, explicit All selection, rapid toggles, and bounded disclosure caches.
  • All three TypeScript project checks passed.
  • Changed-file lint and formatting checks passed.
  • Reliability manifest: 43 gates passed; max-lines ratchet and diff checks passed.
  • Electron main/preload/renderer/web/relay/CLI builds passed; both native macOS build targets passed on a separate retry after the sandbox blocked the Swift cache.
  • Full pnpm lint is blocked by the pre-existing switch-exhaustiveness-check error in src/renderer/src/components/skills/skill-freshness-group.tsx:101; changed files are clean.
  • Full pnpm test on locally available Node 26 completed with 31,702 passed, 52 skipped, and 36 failures across six unrelated files. All 36 failures are caused by Node 26 exposing an unavailable experimental window.localStorage without --localstorage-file; the run also reported one unrelated WSL relay EPIPE. This repository requires Node 24, which was not installed locally.

Mock-data UI automation also asserted the state after an Agents → Explorer → Agents round trip: Project selected, Claude group collapsed, and session details expanded.

AI Review Report

Two independent reviews found no blocking or major issue. They explicitly checked scope normalization and preference restoration, remount behavior, rapid toggles, stable group/session keys, bounded memory use, render-path performance, and compatibility with the existing persisted sort/group/agent filters. One review recommended explicit Workspace fallback coverage; that regression test was added.

Cross-platform compatibility was reviewed for macOS, Linux, and Windows. This is renderer-only state management and does not change shortcuts, labels, paths, shell behavior, or Electron platform APIs. SSH, remote, WSL, and local sessions use the same opaque host-aware session IDs, with no local-only assumption. Agent, integration, GitHub/GitLab, and other git-provider behavior remains provider-neutral. No layout, color, typography, spacing, or design-token behavior changed.

Security Audit

The new cache stores only typed scope values and opaque group/session keys in renderer memory. It is bounded to 512 entries per disclosure set and resets on app reload. The review found no new user-input parsing, command execution, file/path handling, authentication, secrets, dependency, network, persistent-storage, or IPC surface. No follow-up security work is required.

Notes

  • App reload intentionally resets this transient state.
  • Search query, execution-host selector, and scroll position remain outside this PR.
  • Screenshots contain mock data only.
  • Local validation used Node 26 because the repository-required Node 24 was unavailable; CI remains the authoritative Node 24 run.
  • X handle: N/A (none is listed on the just-zzp GitHub profile).

@just-zzp
just-zzp marked this pull request as ready for review July 19, 2026 04:42
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 995256ae-08f1-486f-8c34-469b0deee19d

📥 Commits

Reviewing files that changed from the base of the PR and between 02ff7c7 and 515e6cd.

📒 Files selected for processing (6)
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-panel-transient-state.test.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-panel-transient-state.ts
  • src/renderer/src/components/right-sidebar/ai-vault-scope-state.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-scope-state.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/right-sidebar/ai-vault-scope-state.ts

📝 Walkthrough

Walkthrough

AI Vault transient UI state is centralized in a cached hook that manages scope selection, collapsed groups, and expanded session details. Scope normalization handles unavailable project or workspace contexts, while disclosure state is bounded and resettable for tests. The panel and virtual session list now consume this shared state through props and callbacks. Tests cover persistence across remounts, context changes, explicit scope selection, rapid toggles, eviction limits, cache clearing, and scope normalization.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: preserving AI vault panel transient state.
Description check ✅ Passed The description matches the template with summary, screenshots, testing, AI review, security audit, and notes.
Linked Issues check ✅ Passed The changes implement the requested tab-switch persistence for scope, collapsed groups, and session details, with renderer-session fallback behavior.
Out of Scope Changes check ✅ Passed The diff stays focused on the AI vault transient-state fix and related tests, with no clear unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 self-requested a review July 19, 2026 06:23
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]: Agent Session History scope and disclosure state reset after switching sidebar tabs

1 participant