Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): preserve panel state across workspace refreshes #8968

Mergedmaria-rcksmerged 1 commit intomain fromrefs/pull/8968/headmerged by maria-rcks View on GitHub

maria-rckscommented

Workspace refreshes no longer reset collapsed diff files or rebuild the file tree. The diff now separates stable file identity from per-file content versions, while the file browser applies incremental path changes so unchanged elements stay mounted.

Verified with 12 focused tests, targeted lint and formatting, web typecheck, and the matched UI evidence below.

Evidence

Base: state lost after refreshBranch: state preserved after refresh
Base after refresh expands both filesBranch after refresh keeps five files collapsed

Watch the real-app agent edit test

Real app flow: the branch diff stays open while GPT-5.6-Sol edits the expanded file; the other files remain collapsed through the live refresh.

Written with gpt-5.6-sol in the Codex harness.


Note

Low Risk UI state and reconciliation logic only; no auth, data persistence, or API contract changes. Risk is mainly regressions in diff rendering or file tree sync after refresh.

Overview Workspace refreshes no longer wipe collapsed diff files or rebuild the entire file tree from scratch. The diff panel now tracks each file with a stable identity key (previous + current paths) separate from a per-file content version, so unchanged files keep collapse state and only edited files get a new render version in AnnotatableCodeView.

DiffPanel also exposes loadDiffFiles through a stable ref-backed callback so CodeView options do not churn when the git loader is recreated on refresh.

The file browser applies incremental path add/remove batches via buildFileTreePathUpdates instead of resetPaths on every entry refresh; the first successful load still resets the tree. It skips reconciliation until entries have loaded (entriesQuery.data !== null).

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6ead33dc78da67c8c81b74f01eb0e1435b14e100. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Preserve diff panel and file tree state across workspace refreshes

  • DiffPanel now identifies diff files by previous/current path via buildFileDiffIdentityKey instead of the cache key, and computes a per-file content version with buildFileDiffContentVersion so only changed files re-render.
  • AnnotatableCodeView prepends fileVersion into its item version hash, limiting reconciliation to files whose diff content actually changed.
  • FileBrowserPanel replaces full tree resets with incremental batched updates: new buildFileTreePathUpdates computes a minimal set of add/remove operations, collapsing deleted subtrees into a single recursive remove.
  • Risk: previousTreePathsRef in FileBrowserPanel.tsx now starts as null; first population calls model.resetPaths while subsequent updates rely on buildFileTreePathUpdates correctness — any path-order mismatch could produce stale tree nodes.
Macroscope summarized 6ead33d.

Summary by CodeRabbit

  • Bug Fixes

    • Improved diff rendering so file identity remains stable while content updates refresh correctly.
    • Preserved code annotations and view state more reliably when file contents change.
    • Improved file browser synchronization by applying only incremental path changes.
    • Correctly handles deleted folders and unchanged file trees.
  • Tests

    • Added coverage for diff versioning and file tree path reconciliation.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Path: .coderabbit.yaml

      Review profile: CHILL

      Plan: Team

      Run ID: f012d321-79f9-4510-947c-39c0108b6084

      📥 Commits

      Reviewing files that changed from the base of the PR and between 41adccc83e819c286dcdf32cd8b5f55af8bb0b49 and cbb0b3dc6c3cf48006b4a30ee581e68f53ec34d4.

      📒 Files selected for processing (7)
      • apps/web/src/components/DiffPanel.tsx
      • apps/web/src/components/diffs/AnnotatableCodeView.tsx
      • apps/web/src/components/files/FileBrowserPanel.tsx
      • apps/web/src/components/files/fileTreePathReconciliation.test.ts
      • apps/web/src/components/files/fileTreePathReconciliation.ts
      • apps/web/src/lib/diffRendering.test.ts
      • apps/web/src/lib/diffRendering.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The diff view now separates file identity from content versioning and stabilizes file loading callbacks. The file browser now reconciles tree paths incrementally, including recursive subtree removal.

      Changes

      Diff reconciliation

      Layer / File(s)Summary
      Diff identity and content versioning
      apps/web/src/lib/diffRendering.ts, apps/web/src/lib/diffRendering.test.ts, apps/web/src/components/DiffPanel.tsx, apps/web/src/components/diffs/AnnotatableCodeView.tsx
      The diff view uses stable identity keys and deterministic content versions. Content versions now affect annotatable code view item versions. Tests cover unchanged and changed files across diff versions.
      Diff content loader stability
      apps/web/src/components/DiffPanel.tsx
      The current file-content loader is tracked separately from a stable callback. The callback delegates through a ref and throws when no loader is available.

      File tree reconciliation

      Layer / File(s)Summary
      Incremental file tree synchronization
      apps/web/src/components/files/FileBrowserPanel.tsx, apps/web/src/components/files/fileTreePathReconciliation.ts, apps/web/src/components/files/fileTreePathReconciliation.test.ts
      The file browser resets paths only on the first populated run. Later changes use batched additions and removals. Deleted directory subtrees use recursive removal, with tests for changed, deleted, and identical paths.

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

      Merge Risk: ⚪ Minimal · up to cbb0b

      This change preserves diff collapse state and incrementally updates the file tree during workspace refreshes; no actionable merge-blocking risk remains after normal checks and review.

      Suggested reviewers: juliusmarminge, stienswout

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 7 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly and concisely describes the primary change: preserving panel state across workspace refreshes.
      Description check✅ PassedThe description explains what changed, why it changed, verification performed, and UI evidence. It omits the template headings and checklist, but it provides the required information and is substantia…
      Full details: Description check

      Explanation

      The description explains what changed, why it changed, verification performed, and UI evidence. It omits the template headings and checklist, but it provides the required information and is substantially complete.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Comment `@coderabbitai help` to get the list of available commands.
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 6ead33d

      Macroscope's review found this PR approvable — This is a focused web bug fix that preserves existing file-tree and diff-panel state during refreshes using localized reconciliation and per-file rendering versions. The changes are self-contained, tested, and introduce no schema, security, billing, deployment, or static-analysis configuration impact.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ad8549a7afb8398db8a0cc5843854e2073c8fa2a. Configure [here](https://www.cursor.com/dashboard/bugbot).
      apps/web/src/components/DiffPanel.tsx line 330Resolvedby maria-rcks
    5. maria-rcks merged thisf2a914b

    6. maria-rcks closed this

Sign in to join this conversation.