Add protected main worktree branch for all projects#8
Merged
Conversation
When a project is added to the branches view, the main worktree is now automatically added as a branch. This allows users to switch branches on the main worktree without creating a separate worktree. Changes: - Add is_main_worktree field to Branch struct and database schema - Auto-create main worktree branch when creating a git project - Add get_current_branch() function to detect the current branch - Prevent deletion of main worktree branches in UI - Update TypeScript types to include isMainWorktree field Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When a new project is added, the backend automatically creates a main worktree branch entry. However, the UI wasn't reloading branches after project creation, so the main worktree branch never appeared in the UI. This fix makes handleNewProjectCreated async and calls loadData() after adding the project to ensure the auto-created main worktree branch is fetched and displayed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Projects created before the main worktree feature was added don't have a main worktree branch entry in the database. This fix ensures that when listing branches for a project, the main worktree branch is auto-created if it doesn't exist. This provides backward compatibility and ensures consistent behavior across all projects, regardless of when they were created. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add ability to delete projects from the settings modal without requiring the project to be empty. The delete button is now available in the project settings, making it easier to remove projects while preserving the main worktree branch and git repository. Changes: - Add "Delete Project" button to ProjectSettingsModal footer - Add confirmation dialog for project deletion - Wire up onDeleted callback to remove project from BranchHome list - Clarify in dialog that main worktree and repository won't be deleted Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Make project deletion more discoverable by always showing the delete button in the project header, not just for empty projects. Users can now easily delete any project directly from the project view. Changes: - Remove isEmpty condition from delete button visibility - Update button title from "Remove project" to "Delete project" - Fix TypeScript type narrowing in onDeleted callback Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
baxen
previously approved these changes
Feb 7, 2026
Collaborator
baxen
left a comment
There was a problem hiding this comment.
this works for me, but as a followup we need to figure out what we will do with the original working dir. i'm still tempted to enforce worktrees of some kind
… new worktree Allow switching the checked-out branch on any worktree (including main) via a clickable branch name in the card header. Rename "New Branch" buttons to "New Worktree" throughout the UI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pass onBranchUpdated callback from BranchHome to BranchCard so the parent branches array updates when a branch switch occurs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove local-only filter so remote tracking branches are available. For remote branches, strip the remote prefix (e.g. origin/) when checking out so git creates a local tracking branch automatically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
baxen
approved these changes
Feb 7, 2026
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.
Summary
Introduces automatic tracking of the main repository worktree as a protected, non-deletable branch for every project. This ensures users always have a reference to their primary working directory and prevents accidental deletion of the main worktree.

Changes
is_main_worktreeboolean column to the branches table with automatic migration for existing databasesget_current_branch()utility to reliably detect the active branch name, handling detached HEAD states gracefullyArchitectural Decisions