refactor(source-control): unify UI state into SourceControlState - #131
Merged
ClaudiaFang merged 1 commit intoAug 22, 2026
Merged
ClaudiaFang merged 1 commit into
ClaudiaFang merged 1 commit into
Conversation
PR131 / Phase 2 — reorganize Source Control UI state from scattered View-local fields + direct store access into one SourceControlState container, with the ViewModel as the single facade the View reads from and mutates through. Pure refactor; no behavior change (all 553 tests pass). State model (new src/logic/source-control/state/): - SourceControlState: thin container composing the change model + every UI state slice (selection, operation, filter, expanded nodes, selected change). Not a god-object — each slice keeps its own invariants/methods. - SelectionState: moved/renamed from PushSelectionStore (same API). - OperationState: moved from src/logic/source-control/ (incl. 'conflict' status from PR #130). - FilterState / ExpandedNodesState / SelectedChangeState: new slices that previously lived as View-local fields (active filter, collapsed sections/folders, selected change id). Facade: - SourceControlViewModel is constructed from SourceControlState and is the sole mutation surface (setFilter, toggleSection/Folder, selectForPush/ deselectFromPush, selectForDiff/clearSelection, getCollapsedFolders, setOperationResult/clear). The View reaches no store directly. - SourceControlView holds no state of its own and mutates only through the ViewModel; getFilter/getSelectedChangeId moved to the ViewModel. Constructor is now (viewModel, callbacks). - main.ts / SourceControlItemView construct SourceControlState; plugin exposes sourceControlState (replaces pushSelectionStore/operationState). - SourceControlFilter.matchesFilter selection param type is SelectionState. Tests: moved OperationState/PushSelectionStore tests into state/ (renamed to SelectionState.test.ts); new FilterState/ExpandedNodesState/SelectedChangeState tests; updated ViewModel/View/ItemView/ActionService tests for the new construction. Verification: npx eslint . — 0 errors; npm run build — PASS incl. Obsidian 1.11.0 compatibility; npx vitest run — 59 files / 553 tests.
|
ClaudiaFang
merged commit Aug 22, 2026
925a5e8
into
feat/source-control-integration
18 checks passed
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.



PR131 — Phase 2: unify state model
Stacks on PR #130 (
feat/source-control-integrationb3379b7). Reorganizes Source Control UI state from scattered View-local fields + direct store access into oneSourceControlStatecontainer, with the ViewModel as the single facade. Pure refactor — no behavior change (all 553 tests pass).State model (new
src/logic/source-control/state/)SourceControlState— thin container composing the change model + every UI state slice. Not a god-object: each slice keeps its own invariants.SelectionState— moved/renamed fromPushSelectionStore(same API).OperationState— moved (incl.'conflict'status from PR feat(source-control): integrate execution result and conflict status #130).FilterState/ExpandedNodesState/SelectedChangeState— new slices that previously lived as View-local fields (active filter, collapsed sections/folders, selected change id).Facade
SourceControlViewModelis constructed fromSourceControlStateand is the sole mutation surface (setFilter,toggleSection/Folder,selectForPush/deselectFromPush,selectForDiff/clearSelection,getCollapsedFolders,setOperationResult/clear). The View reaches no store directly.SourceControlViewholds no state and mutates only through the ViewModel;getFilter/getSelectedChangeIdmoved to the ViewModel. Constructor is now(viewModel, callbacks).main.ts/SourceControlItemViewconstructSourceControlState; plugin exposessourceControlState(replacespushSelectionStore/operationState).SourceControlFilter.matchesFilterselection param type isSelectionState.Tests
Moved
OperationState/PushSelectionStoretests intostate/(renamedSelectionState.test.ts); newFilterState/ExpandedNodesState/SelectedChangeStatetests; updated ViewModel/View/ItemView/ActionService tests for the new construction.Verification
Notes
sync-status-viewview type +open-sync-statuscommand id for pinned-leaf migration (per user decision).