fix(source-control): unify diff views and focus state - #723
Open
beruro wants to merge 2 commits into
Open
Conversation
beruro
marked this pull request as ready for review
August 6, 2026 14:43
Pre-commit hook ran. Total eslint: 0, total circular: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Source Control exposed inconsistent diff presentation controls: Focus, commit, and pull-request diffs owned separate local Unified/Split state, while All Changes and Session Replay were hard-coded to Unified and offered no switch. Focus could also show an unrelated Git navigation placeholder or retain a stale file when the active repo/worktree or staged filter changed.
Solution
Introduce one persisted, normalized diff-view preference and use it across working-tree, commit, pull-request, aggregate, and replay diff surfaces. Add the Unified/Split selector to All Changes and Session Replay, and pass the selected mode through aggregate diff sections.
Model Source Control mode changes and remembered file selection as explicit transitions. All Changes now remembers the latest inspected file for Focus hand-off; Focus shows a select-file empty state when no valid target exists. Main-pane derivation now filters both aggregate files and focused files by the active repo/worktree root and staged/unstaged filter.
Add component, persistence, state-transition, scope, filter, and empty-state regression coverage, plus the required frontend UI audit report.
Potential risks
GitFile.repoRoot; a non-host worktree record without that metadata is excluded instead of being allowed to leak into the active scope.Verification
pnpm exec vitest run src/modules/WorkStation/CodeEditor/Panels/EditorMainPane/components/SourceControlHeaderContent.test.ts src/store/workstation/codeEditor/diffViewModeAtom.test.ts src/modules/WorkStation/CodeEditor/Panels/EditorMainPane/content/__tests__/sourceControlMainProps.test.ts src/modules/WorkStation/CodeEditor/__tests__/sourceControlStateTransitions.test.ts src/modules/WorkStation/CodeEditor/Panels/EditorMainPane/content/__tests__/FocusView.emptyState.test.ts src/hooks/workStation/git/__tests__/useGitDiffState.test.ts— 6 files, 31 tests passed on the clean latest-develop worktree..ts/.tsxfile — passed locally.git diff --check origin/develop...HEAD— passed.WorkItemDescriptionEditing.test.tsfailed becauseResizeObserveris absent in the CI test environment. This is the same pre-existing develop failure seen on merged PR Unify activity timeline loading and surfaces #722 (982 files / 8065 tests passed with the identical 6 failures), and neither the failing test noruseElementDimensions.tsis changed here.origin/developworktree passed 9/9, confirming the failure is full-suite environment contamination rather than this Source Control diff.Audit
Frontend UI audit:
docs/frontend-ui-audit-2026-08-05/DiffViewConsistency.md. Architecture review covered compiler/build health, source ownership, canonical types, state semantics, invalid persisted data, dependency direction, naming, and scope/filter resolver symmetry. Wire protocol and dual-runtime initialization layers were not applicable.