Skip to content

fix(source-control): unify diff views and focus state - #723

Open
beruro wants to merge 2 commits into
developfrom
junyu/fix-source-control-diff-views
Open

fix(source-control): unify diff views and focus state#723
beruro wants to merge 2 commits into
developfrom
junyu/fix-source-control-diff-views

Conversation

@beruro

@beruro beruro commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

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

  • The Unified/Split choice is intentionally global across Git review surfaces; users who previously expected a per-surface choice will now see their latest choice reused everywhere.
  • Worktree isolation relies on GitFile.repoRoot; a non-host worktree record without that metadata is excluded instead of being allowed to leak into the active scope.
  • Malformed persisted values fall back to Unified. No existing persistence key, IPC contract, wire format, or backend schema is migrated.
  • Compact provenance-table diffs remain intentionally Unified, and two unused legacy diff abstractions retain local defaults rather than introducing a shared-layer dependency on the workstation store.
  • Browser-only visual verification is unavailable because ORGII requires Tauri window metadata during initialization. The changed behavior is covered at component and state boundaries, but final in-app visual QA is still recommended.

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.
  • ESLint over every changed .ts / .tsx file — passed locally.
  • Prettier over all 34 changed files — passed locally.
  • git diff --check origin/develop...HEAD — passed.
  • GitHub CI Type check — passed.
  • GitHub CI full-repository lint — passed.
  • GitHub CI Rust clippy — passed.
  • GitHub CI full unit suite — 986 files / 8079 tests passed; 6 tests in WorkItemDescriptionEditing.test.ts failed because ResizeObserver is 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 nor useElementDimensions.ts is changed here.
  • Running the failing WorkItem test alone on a detached latest origin/develop worktree 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.

@beruro
beruro marked this pull request as ready for review August 6, 2026 14:43
Pre-commit hook ran. Total eslint: 0, total circular: 0
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.

2 participants