Add submodule management and collapsible Worktree/Tags panels #45

Merged
Christoph merged 2 commits from enhance-ui into main 2026-09-16 20:59:41 +00:00
Owner

This change adds first-class submodule support in the backend and UI adjustments to the left sidebar (new Worktree and Tags panels that can be collapsed and persist size/state). The clone implementation was changed to initialize submodules automatically (including nested submodules) during clone.

What changed (summary):

  • Submodule backend: a new module src-tauri/src/git/submodules.rs implements listing, adding, initializing/updating, staging references and syncing submodule URLs. It exposes Tauri commands: list_submodules, add_submodule and submodule_action (registered in src-tauri/src/main.rs).
  • Clone behavior: src-tauri/src/git.rs was modified so run_git_clone_command passes --recurse-submodules by default to git clone, and parse_custom_clone_flags now rejects conflicting custom flags such as --no-recurse-submodules, --no-recursive and --remote-submodules.
  • UI: App.svelte now imports WorktreePanel and TagsPanel, adds persistent keys and state for collapsing and resizing those panels (new stored keys and load/store logic), and wires submodule-related state variables for loading/initializing submodules.
  • Documentation: README.md updated with a Submodules section describing behavior (automatic initialization on clone, submodule dialog capabilities, and examples of operations).
  • Tests: unit tests were added/extended for nested submodules and submodule operations (tests appear in src-tauri/src/git.rs and src-tauri/src/git/submodules.rs).

Why this matters (behavioral evidence from the diff):

  • Cloning now runs git clone --recurse-submodules (code: run_git_clone_command adds --recurse-submodules), so clones should automatically download and initialize submodules (including nested ones) at their recorded commits. There are new tests that validate that nested submodules are downloaded at the recorded commits and that submodule status shows initialized modules.
  • The new submodules.rs implements safe path checks, discovery of submodules from the index and .gitmodules, operations that call git submodule update --init --checkout (with --recursive when requested), and commands to add/sync/stage references. The Tauri commands expose this functionality to the UI.
  • App.svelte changes show the UI impact: new import of TagsPanel and WorktreePanel, new stored keys and collapsed state variables, and hooks for listing/adding/submodule actions.

Tests and execution:

  • New unit tests are included (git clone/submodule related tests added). No test execution results were provided.

Recommended reviewer checks:

  • Run the backend unit tests (cargo test in src-tauri) locally to confirm the new tests pass.
  • Verify a real or local file:// repository with nested submodules: clone it via the application or run the code path that uses run_git_clone_command to confirm submodules are initialized at recorded commits and nested modules are present but not updated to newer unpinned commits.
  • In the running app, confirm Worktree and Tags panels are present in the left sidebar, can be collapsed/expanded, and their sizes/state persist.
  • Exercise submodule operations from the UI (list, initialize/update, stage, sync, add) and confirm the commands call the expected git submodule actions and that errors for dirty/uninitialized states are surfaced.

Compatibility / notes:

  • Clone behavior changed to include submodule initialization by default; this is a concrete behavioral change evident in the clone command construction. If callers relied on clones not fetching submodules, they will now get submodules fetched and initialized unless the code path that constructs custom clone flags is adjusted elsewhere.
  • parse_custom_clone_flags now rejects certain flags that would conflict with the enforced recurse-submodules behavior; callers that pass those flags will receive an error from parse_custom_clone_flags as added in the diff.

Files of interest (high level):

  • Added: src-tauri/src/git/submodules.rs (implements submodule logic and tests)
  • Modified: src-tauri/src/git.rs (clone behavior, tests, and flag parsing)
  • Modified: src-tauri/src/main.rs (registers new Tauri commands)
  • Modified: src/App.svelte (imports and state for Worktree/Tags panels and submodule UI state)
  • Modified: README.md (Submodules documentation)

No test execution results were provided.

This change adds first-class submodule support in the backend and UI adjustments to the left sidebar (new Worktree and Tags panels that can be collapsed and persist size/state). The clone implementation was changed to initialize submodules automatically (including nested submodules) during clone. What changed (summary): - Submodule backend: a new module src-tauri/src/git/submodules.rs implements listing, adding, initializing/updating, staging references and syncing submodule URLs. It exposes Tauri commands: list_submodules, add_submodule and submodule_action (registered in src-tauri/src/main.rs). - Clone behavior: src-tauri/src/git.rs was modified so run_git_clone_command passes --recurse-submodules by default to git clone, and parse_custom_clone_flags now rejects conflicting custom flags such as --no-recurse-submodules, --no-recursive and --remote-submodules. - UI: App.svelte now imports WorktreePanel and TagsPanel, adds persistent keys and state for collapsing and resizing those panels (new stored keys and load/store logic), and wires submodule-related state variables for loading/initializing submodules. - Documentation: README.md updated with a Submodules section describing behavior (automatic initialization on clone, submodule dialog capabilities, and examples of operations). - Tests: unit tests were added/extended for nested submodules and submodule operations (tests appear in src-tauri/src/git.rs and src-tauri/src/git/submodules.rs). Why this matters (behavioral evidence from the diff): - Cloning now runs git clone --recurse-submodules (code: run_git_clone_command adds --recurse-submodules), so clones should automatically download and initialize submodules (including nested ones) at their recorded commits. There are new tests that validate that nested submodules are downloaded at the recorded commits and that submodule status shows initialized modules. - The new submodules.rs implements safe path checks, discovery of submodules from the index and .gitmodules, operations that call git submodule update --init --checkout (with --recursive when requested), and commands to add/sync/stage references. The Tauri commands expose this functionality to the UI. - App.svelte changes show the UI impact: new import of TagsPanel and WorktreePanel, new stored keys and collapsed state variables, and hooks for listing/adding/submodule actions. Tests and execution: - New unit tests are included (git clone/submodule related tests added). No test execution results were provided. Recommended reviewer checks: - Run the backend unit tests (cargo test in src-tauri) locally to confirm the new tests pass. - Verify a real or local file:// repository with nested submodules: clone it via the application or run the code path that uses run_git_clone_command to confirm submodules are initialized at recorded commits and nested modules are present but not updated to newer unpinned commits. - In the running app, confirm Worktree and Tags panels are present in the left sidebar, can be collapsed/expanded, and their sizes/state persist. - Exercise submodule operations from the UI (list, initialize/update, stage, sync, add) and confirm the commands call the expected git submodule actions and that errors for dirty/uninitialized states are surfaced. Compatibility / notes: - Clone behavior changed to include submodule initialization by default; this is a concrete behavioral change evident in the clone command construction. If callers relied on clones not fetching submodules, they will now get submodules fetched and initialized unless the code path that constructs custom clone flags is adjusted elsewhere. - parse_custom_clone_flags now rejects certain flags that would conflict with the enforced recurse-submodules behavior; callers that pass those flags will receive an error from parse_custom_clone_flags as added in the diff. Files of interest (high level): - Added: src-tauri/src/git/submodules.rs (implements submodule logic and tests) - Modified: src-tauri/src/git.rs (clone behavior, tests, and flag parsing) - Modified: src-tauri/src/main.rs (registers new Tauri commands) - Modified: src/App.svelte (imports and state for Worktree/Tags panels and submodule UI state) - Modified: README.md (Submodules documentation) No test execution results were provided.
Christoph added 2 commits 2026-09-16 20:59:29 +00:00
Add a new backend module to manage Git submodules (list, initialize/update,
stage, sync, add) and expose Tauri commands (list_submodules,
submodule_action, add_submodule). The implementation enforces safe relative
paths, a maximum nesting depth, and guards (dirty/conflicted checks and
initialization/no-op semantics) to avoid unsafe operations.

Refactor clone logic to a testable run_git_clone_command and enable
automatic initialization of submodules during clone by passing
--recurse-submodules. Also disallow certain submodule-related custom clone
flags so callers cannot override this behaviour.

Update README with a Submodules section and add frontend components and types
to surface submodule UI (dialogs, toolbar badge). Unit tests were added for
submodule discovery, initialization/update semantics, and recursive clone
behavior.
Add two new sidebar components (WorktreePanel, TagsPanel) and integrate them
into the compact left navigation layout:

- Wire up imports and rendering in App.svelte, including collapse toggles and
  resize handles for both panels. Persisted heights (localStorage) and keyboard
  resizing are supported; heights are clamped between 80 and 420px with a 140px
  default.
- Extend buildLeftSidebarRows and left-sidebar grid/template styles to include
  the new panels and reduce panel-handle thickness. Add extensive CSS for the
  compact accordion navigation, worktree and tags lists.
- Move tag and worktree management UI out of BranchPanel (remove tag props),
  and add dedicated handlers in App.svelte for the new panels.
- Refactor worktree loading: introduce a worktreeLoadId to guard async
  refreshWorktrees() calls and avoid race conditions. refreshWorktrees(path?)
  now takes an optional path and updates worktree state only when the request
  is still relevant.
- Small behavioral tweaks: stash panel default collapsed state changed to true
  and the explorer resize-handle visibility condition adjusted.

This commit only adds the UI/UX integration and local persistence for the new
panels and their resizing/refresh behavior.
Christoph added 1 commit 2026-09-16 20:59:39 +00:00
Christoph merged commit 3ef2941190 into main 2026-09-16 20:59:41 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Christoph/GitLite#45