Skip to content

feat(desktop): promote worktrees & submodules to header + harden worktree engine#35

Open
t1gu1 wants to merge 14 commits into
devlint:mainfrom
t1gu1:style/move-submodules-and-worktree
Open

feat(desktop): promote worktrees & submodules to header + harden worktree engine#35
t1gu1 wants to merge 14 commits into
devlint:mainfrom
t1gu1:style/move-submodules-and-worktree

Conversation

@t1gu1
Copy link
Copy Markdown
Contributor

@t1gu1 t1gu1 commented May 26, 2026

Changes

  • Move worktree and submodule actions from BranchMenu accordion to standalone header buttons (matching tags/stash pattern)
  • Fix porcelain parser: capture lock_reason, prunable status, is_main attribute
  • Fix gitWorktreeAdd: return real HEAD SHA instead of empty string
  • Fix status: distinguish conflicted vs modified, expose has_upstream
  • Restore Prune button (gated on prunable worktrees)
  • Add prunable badge + alert banner in WorktreeManager
  • Include remote tracking branches in worktree add form
  • Expose gitWorktreeRepair API (Rust + TS), called silently on modal mount
  • Replace hardcoded CSS values with design tokens
image

@t1gu1 t1gu1 changed the title Style/move submodules and worktree Style/move submodules and worktree out of the Actions menu May 26, 2026
@t1gu1
Copy link
Copy Markdown
Contributor Author

t1gu1 commented May 27, 2026

@devlint
I take a time to test a bit the Worktrees and it feels like it could need some love to works better with the graph and the switch branch in general.

I feel like we could almost keep it hide in the BranchMenu "Advanced" just because i think it dont works as flawlessly as it should. WDYT?

But submodules seems to works fine for what I test of it.

@devlint devlint changed the title Style/move submodules and worktree out of the Actions menu feat(desktop): promote worktrees & submodules to header + harden worktree engine May 28, 2026
@devlint
Copy link
Copy Markdown
Owner

devlint commented May 28, 2026

Hey @t1gu1 — totally agree with the "hub" framing, keeping both buttons in the header. ✅

While reviewing I took the opportunity to harden the worktree engine alongside your UI changes. Here's what was updated:
Parser (git worktree list --porcelain)
The parser now reads the main attribute introduced in git 2.36 to identify the main worktree (instead of assuming it's always the first entry). It also captures the lock reason and prunable reason when they appear inline on the same line, which is how git actually formats them.
Status
has_upstream is now properly detected (via git rev-list HEAD...@{upstream}) so we can distinguish "synced at 0" from "no remote configured". Conflicted files (UU, AA, DD…) are counted separately from regular modifications.
Worktree add
The returned entry now includes the real HEAD SHA instead of an empty string.
UI

  • Prune button restored, gated on actually-prunable worktrees
  • Prunable badge + alert banner when stale metadata is detected
  • Remote tracking branches included in the add form
  • gitWorktreeRepair called silently on modal mount (covers the "repo moved manually" case)
  • Hardcoded CSS values replaced with design tokens

Feel free to take a look — happy to merge once you're good with it.

@t1gu1 t1gu1 force-pushed the style/move-submodules-and-worktree branch from 2defce5 to bf974de Compare May 28, 2026 20:03
@t1gu1
Copy link
Copy Markdown
Contributor Author

t1gu1 commented May 29, 2026

I did some test and that's good!

I added a small tiny feature after testing

New worktrees are now created in a dedicated .worktrees sibling directory relative to the main repository, enforcing a consistent organizational structure. To align with standard worktree conventions, the UI has been updated to place the Branch field first. The system then automatically derives and pre-fills the default worktree path based on the selected branch, improving the user experience and reducing manual errors.

On the backend, both the Node.js and Rust worktree creation commands proactively generate any necessary parent directories, preventing failures if the target path's parent does not yet exist.

While the path is pre-filled automatically for convenience, it is not rigidly imposed and can be freely customized by the user.

image image

@t1gu1
Copy link
Copy Markdown
Contributor Author

t1gu1 commented May 29, 2026

Fixed an issue where the available branches for creating a worktree were not displayed after a user opened a worktree and then navigated back to the project.

Also, branches already associated with an existing worktree are now disabled in the branch selection dropdown and marked as 'already in use'. This prevents accidental creation of duplicate worktrees and improves user guidance.

In the same way of the last point, I Introduces a new icon to visually mark worktree branches. This enhances visibility in the branch selector, commit graph, and search palette, providing better context for repository management.


Previously, when try to go on a worktree branch, Git command failures in the backend would often return generic errors (e.g., "Command failed with exit code 1"), which made troubleshooting difficult for users.

Now there is a more understandable message.

image
image image

Guillaume Huard Hughes and others added 14 commits May 29, 2026 11:02
Move worktree and submodule actions out of the BranchMenu "Advanced"
accordion into standalone header buttons, matching tags/stash visibility.
Removes the accordion disclosure pattern from BranchMenu entirely.

🪄 Commit via GitWand
…ree' button

This change streamlines the worktree management interface by removing the dedicated cleanup and prune functionalities. The primary 'New Worktree' action is now repositioned to the modal footer with a distinct style for improved prominence and user experience.
Enrich WorktreeEntry and WorkspaceRepoStatus with lock reason, prunable
state, upstream presence and conflict count; fix porcelain parser and
return real HEAD on add. Surface prune action, prunable alerts, conflict
pills and remote branches in WorktreeManager, with matching i18n keys.

🪄 Commit via GitWand
Extract pure parsing helpers from ops.rs into a TS module so the
porcelain, status, and quick-path derivation logic can be covered
by vitest without a real git repo or Tauri runtime.

🪄 Commit via GitWand
Silently runs `git worktree repair` when the manager opens to recover
from repos moved manually on disk. Idempotent and near-free when the
links are already valid.

🪄 Commit via GitWand
Automatically creates missing parent directories when adding a new worktree, preventing `git worktree add` failures.
Derives new worktree paths into a dedicated `.{main}.worktrees` directory for better organization.
Pre-fills the worktree path in the UI based on the selected or new branch.
…data

WorktreeManager and SearchPalette now emit events on mount to trigger a refresh
of relevant data (branches, repository log) from the parent `App.vue`.
This prevents stale information from being displayed if data has changed
while these components were not active.
Branches already associated with an existing worktree are now disabled in the branch selection dropdown and marked as 'already in use'. This prevents accidental creation of duplicate worktrees and improves user guidance.

The manual path input field has also been removed from the creation form, as worktree paths are now automatically derived and pre-filled, simplifying the user interface.
Introduces a new icon to visually mark branches that are currently checked out in a Git worktree. This enhances visibility in the branch selector, commit graph, and search palette, providing better context for repository management.
Previously, Git command failures in the backend would often return generic error messages (e.g., "Command failed with exit code 1"). This change updates the backend to capture and return the `stderr` output from executed Git commands, which typically contains much more informative error details directly from Git.

The frontend now consumes these richer error messages, allowing for more specific and user-friendly error feedback. A dedicated translation has been added to handle cases where a user attempts to switch to a branch already checked out in another worktree. This significantly improves the diagnostic clarity for users encountering Git-related issues.
@t1gu1 t1gu1 force-pushed the style/move-submodules-and-worktree branch from a8ea22d to 10364d8 Compare May 29, 2026 15:03
@t1gu1
Copy link
Copy Markdown
Contributor Author

t1gu1 commented May 29, 2026

@devlint I just fix the conflict. ✅

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