Skip to content

feat: add main-repo worktree mode for topics#3

Merged
ByteMirror merged 15 commits intomainfrom
fabian.urbanek/worktree-manageent
Feb 23, 2026
Merged

feat: add main-repo worktree mode for topics#3
ByteMirror merged 15 commits intomainfrom
fabian.urbanek/worktree-manageent

Conversation

@ByteMirror
Copy link
Copy Markdown
Owner

@ByteMirror ByteMirror commented Feb 23, 2026

Summary

  • Replaces SharedWorktree bool on Topic with a TopicWorktreeMode string enum (per_instance, shared, main_repo)
  • Adds a third topic mode: Main repo (no worktree) — instances run directly in the repository directory without creating a new git branch or worktree
  • Swaps the old Y/N "Create shared worktree?" confirmation with a 3-item picker at topic creation time

What changed

Layer Change
session/topic.go TopicWorktreeMode enum + IsSharedWorktree() / IsMainRepo() helpers
session/topic_storage.go New worktree_mode JSON field; legacy shared_worktree bool is auto-migrated on read
session/instance.go mainRepo bool field + GetWorkingPath() (returns worktree path or repo path)
session/instance_lifecycle.go StartInMainRepo() method; Pause()/Resume() guarded against nil worktree
app/app_input.go ConfirmationOverlayPickerOverlay with 3 options; MainRepo dispatch branch
app/app_state.go 5 GetGitWorktree() callers replaced with GetWorkingPath()
app/app_brain.go MainRepo dispatch branch for brain-spawned instances
app/app.go View: stateNewTopicConfirm now renders pickerOverlay (not confirmationOverlay)

UX

When creating a topic (T), instead of a Y/N dialog the user sees:

Worktree mode for 'my-topic'
  ▸ Per-instance worktrees
    Shared worktree
    Main repo (no worktree)

Backward compatibility

Existing topics stored with "shared_worktree": true/false are automatically migrated to the new enum on first read. No manual migration required.

Test plan

  • Create a topic, verify picker shows all 3 options
  • Select Main repo — instance starts, working directory is the repo root (not a worktree)
  • Select Per-instance worktrees — existing behavior unchanged
  • Select Shared worktree — existing behavior unchanged
  • Restart hivemind — topics survive restart with correct mode
  • Old topics (no worktree_mode in JSON) load correctly as per-instance or shared

The handleDefaultKeys function returns early for any key not in
GlobalKeyStringsMap, making the previous default-case A check dead code.
Add KeyAutomations constant, register "A" in the map, and use a proper
case in the switch.
Replace the consecutive text-input modal chain (name → instructions →
schedule) with a single AutomationForm that shows all three fields at
once inside the automations modal. Tab/Shift+Tab moves between fields,
Ctrl+S saves, Esc cancels.

Also adds edit support: press 'e' on a selected automation to open the
same form pre-populated. Toggle is now 't' to free up 'e' for edit.
Introduces TopicWorktreeMode string enum (per_instance, shared,
main_repo) on Topic, with IsSharedWorktree/IsMainRepo helpers and a
default of per_instance in NewTopic. Updates topic_storage.go to
serialise WorktreeMode and migrate legacy SharedWorktree bool on read.
@ByteMirror ByteMirror force-pushed the fabian.urbanek/worktree-manageent branch from a1f3a6c to bd99679 Compare February 23, 2026 16:32
@ByteMirror ByteMirror merged commit 6fa7aa2 into main Feb 23, 2026
6 checks passed
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.

1 participant