Skip to content

Persist diff view state across tab switches and reloads#724

Merged
selfcontained merged 3 commits into
mainfrom
agt_90359e63a565/agent-63a565
Jul 7, 2026
Merged

Persist diff view state across tab switches and reloads#724
selfcontained merged 3 commits into
mainfrom
agt_90359e63a565/agent-63a565

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

  • Persist collapsed files, collapsed directories, and scroll position in the Changes tab per agent via Jotai atomFamily backed by localStorage
  • Scroll position is debounced (300ms) and restored once when landing on an agent's tab (survives page reloads and tab switches without fighting background refetches)
  • Stale localStorage entries are cleaned up when agents are archived

Changed files

  • apps/web/src/lib/store.tsDiffViewState type, diffViewStateAtomFamily, reconcileDiffViewStateStorage
  • apps/web/src/components/app/changes-tab.tsx — replaced ephemeral useState with atom-backed state, lifted collapsedDirs from FileTree, added scroll tracking/restore
  • apps/web/src/hooks/use-media-sidebar-state.ts — added diff view state cleanup call

Test plan

  • Type check (pnpm run check)
  • Production build (pnpm run finalize:web)
  • E2E tests (172 passed)
  • Store unit tests (8 passed)
  • Frontend UX review (approved after 2 rounds)
  • Product review (approved after 2 rounds)
  • Manual: collapse files, scroll, switch to Terminal and back — state preserved
  • Manual: reload the page — collapse state and scroll position restored
  • Manual: switch between agents — each agent has its own collapse/scroll state
  • Manual: archive an agent — its localStorage entry is cleaned up

selfcontained and others added 3 commits July 6, 2026 18:39
Null out scrollTimerRef after the debounce fires so the cleanup
only flushes for genuinely pending timers.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Track the last restored agent ID instead of a boolean so the
scroll position is correctly restored per agent when the
ChangesTab component is reused across agent switches.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@selfcontained
selfcontained merged commit 053763c into main Jul 7, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_90359e63a565/agent-63a565 branch July 7, 2026 01:04
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