indexzero / indexzero/try.rs

[TUI]: Prompt to attach a branch when graduating a detached worktree

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Existing issues
  • I searched the existing issues for this interaction.
Current workflow

try worktree <name> intentionally creates a detached worktree. Ctrl-G later moves that worktree to a permanent location, but it does not attach HEAD to a branch.

As a result, the TUI can report a successful graduation while leaving the promoted project detached. Users must know to run this manually before or after graduation:

git switch -c <branch>

The distinction between moving a worktree and attaching its Git HEAD is not visible in the current interaction.

Proposed interaction

When Ctrl-G is used on a detached Git worktree, the TUI should detect the detached state and prompt the user to attach it to a branch.

The prompt should:

  1. Explain that the selected worktree has a detached HEAD.
  2. Offer an inferred branch name derived from the graduation/worktree name.
  3. Allow the branch name to be edited.
  4. Run the equivalent of git switch -c <branch> before moving the worktree when confirmed.
  5. Allow the user to decline and graduate while detached.

No attachment prompt is needed for a worktree already associated with a branch or for a non-Git directory.

Why this improves the TUI

Branch attachment is part of promoting an ephemeral detached worktree into maintained work. Prompting at the transition point makes the Git state explicit, avoids orphaned commits, and removes a prerequisite that users otherwise have to discover outside try.

Acceptance criteria
  • Ctrl-G detects whether a selected Git worktree is detached.
  • Detached worktrees receive an attach-branch prompt before the move.
  • The prompt includes an editable inferred branch name.
  • Confirming performs branch attachment before git worktree move.
  • Declining preserves the existing detached graduation behavior.
  • Escape cancels without attaching or moving.
  • Attachment failure prevents the move and displays an actionable error.
  • Already-attached worktrees and normal directories are not prompted.
  • Tests cover confirm, edit, decline, cancel, failure, and already-attached states.
try version

try v0.1.0

Shell

zsh

Additional context

The same behavior should be available non-interactively through the proposed try graduate --attach CLI.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Ctrl-G graduation flow and trace the proposed try graduate --attach entry point, then inspect how Git worktree state and TUI prompts are handled. Done means detached worktrees support editable branch attachment, confirmation, decline, cancellation, and actionable failure handling, with coverage for all listed states while preserving existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, rust
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.