Summary
Migrate the Source Control panel from hand-rolled section navigation, scroll, and collapse state to quadraui::compose::SidebarSystem.
The SC panel has the most state machine code of any sidebar (~641 lines of navigation/input handling). It uses source_control_to_tree_view() with Decoration::Header sections (Staged, Changes, Worktrees, Log). SidebarSystem replaces the core section-walk, scroll, collapse, and selection logic — the domain-specific handlers (stage, commit, push, discard) remain on the engine and dispatch from SidebarEvent matches.
Prereqs
Engine fields replaced by SidebarSystem
| Field |
Purpose |
SidebarSystem equivalent |
sc_selected |
flat row index |
per-section selection |
sc_sections_expanded: [bool; 4] |
collapse state |
SidebarSystem internal collapse |
sc_has_focus |
keyboard focus |
SidebarSystem focus state |
Fields that remain (domain-specific): sc_file_statuses, sc_worktrees, sc_log, sc_ahead/behind, sc_commit_message, sc_commit_cursor, sc_commit_input_active, sc_button_focused/hovered, sc_branch_picker_*, sc_help_open, sc_diff_rx, sc_diff_pending_win.
Migration steps
- Define 4
SidebarSectionDefs: "staged", "changes", "worktrees", "log"
- Each frame: call
sidebar.set_rows(section, rows) from source_control_to_tree_view() data
- Replace the j/k/Tab/Enter navigation in
handle_sc_key() with sidebar.handle() + SidebarEvent dispatch
- Keep domain actions (
s stage, d discard, c commit, p push, etc.) as post-event handlers that match on SidebarEvent::RowSelected
- Remove the 3 engine fields listed above
- The commit input sub-mode (
sc_commit_input_active) is orthogonal — it intercepts before SidebarSystem and stays as-is
- TUI + GTK: replace bespoke tree paint with
sidebar.render(backend, rect)
- Update tests in
source_control.rs
Complexity note
SC has the richest interaction surface: commit input mode, branch picker popup, button bar keyboard nav, and help dialog. These are not sidebar state machine concerns — they are modal overlays that intercept before the sidebar handler runs. The migration only replaces the section/scroll/selection plumbing, which is the duplicated part.
Key files
src/core/engine/mod.rs — remove sc_selected, sc_sections_expanded, sc_has_focus
src/core/engine/source_control.rs — replace navigation in handle_sc_key(), keep domain actions
src/render.rs — adapt source_control_to_tree_view() to feed SidebarSystem::set_rows()
src/tui_main/panels.rs — replace SC render
src/main.rs — replace GTK SC render
Reference
See JDonaghy/quadraui#63 for the complete migration guide with code examples.
Summary
Migrate the Source Control panel from hand-rolled section navigation, scroll, and collapse state to
quadraui::compose::SidebarSystem.The SC panel has the most state machine code of any sidebar (~641 lines of navigation/input handling). It uses
source_control_to_tree_view()withDecoration::Headersections (Staged, Changes, Worktrees, Log). SidebarSystem replaces the core section-walk, scroll, collapse, and selection logic — the domain-specific handlers (stage, commit, push, discard) remain on the engine and dispatch fromSidebarEventmatches.Prereqs
Engine fields replaced by SidebarSystem
sc_selectedsc_sections_expanded: [bool; 4]SidebarSysteminternal collapsesc_has_focusSidebarSystemfocus stateFields that remain (domain-specific):
sc_file_statuses,sc_worktrees,sc_log,sc_ahead/behind,sc_commit_message,sc_commit_cursor,sc_commit_input_active,sc_button_focused/hovered,sc_branch_picker_*,sc_help_open,sc_diff_rx,sc_diff_pending_win.Migration steps
SidebarSectionDefs:"staged","changes","worktrees","log"sidebar.set_rows(section, rows)fromsource_control_to_tree_view()datahandle_sc_key()withsidebar.handle()+SidebarEventdispatchsstage,ddiscard,ccommit,ppush, etc.) as post-event handlers that match onSidebarEvent::RowSelectedsc_commit_input_active) is orthogonal — it intercepts before SidebarSystem and stays as-issidebar.render(backend, rect)source_control.rsComplexity note
SC has the richest interaction surface: commit input mode, branch picker popup, button bar keyboard nav, and help dialog. These are not sidebar state machine concerns — they are modal overlays that intercept before the sidebar handler runs. The migration only replaces the section/scroll/selection plumbing, which is the duplicated part.
Key files
src/core/engine/mod.rs— removesc_selected,sc_sections_expanded,sc_has_focussrc/core/engine/source_control.rs— replace navigation inhandle_sc_key(), keep domain actionssrc/render.rs— adaptsource_control_to_tree_view()to feedSidebarSystem::set_rows()src/tui_main/panels.rs— replace SC rendersrc/main.rs— replace GTK SC renderReference
See JDonaghy/quadraui#63 for the complete migration guide with code examples.