Skip to content

Expand C-c a w into a worktree action menu - #504

Merged
tninja merged 2 commits into
mainfrom
kang_bug_fix
Sep 3, 2026
Merged

Expand C-c a w into a worktree action menu#504
tninja merged 2 commits into
mainfrom
kang_bug_fix

Conversation

@tninja

@tninja tninja commented Sep 3, 2026

Copy link
Copy Markdown
Owner

C-c a w only offered worktree creation. The "open the centralized worktree directory" action was hidden behind a C-u prefix — invisible in the transient menu, and mislabeled as "status" when it actually runs Dired. Closes #501.

Replaced the prefix-arg dispatch in ai-code-git-worktree-action with a completing-read over four named commands, following the existing ai-code-derive-architecture-document pattern:

  • New branch and worktreeai-code-git-worktree-branch, kept as the completion default so w RET behaves exactly as w did before
  • Open worktree directory (Dired) — the old C-u branch, extracted into a new ai-code-git-worktree-open-dir command
  • Visit existing worktreemagit-worktree-status
  • Delete worktreemagit-worktree-delete

Dispatch uses call-interactively rather than funcall, since every candidate has its own interactive spec that reads arguments. The ai-code-git-worktree-root check also moved out of the entry point into ai-code--validate-git-worktree-root, called only by the two actions that need it — otherwise users without that variable configured would be blocked from deleting or visiting worktrees, which do not depend on it at all. ai-code-git-worktree-branch never had this check and now gets it: with the root nil, expand-file-name silently fell back to a relative path and created a worktree inside the repository.

Verification: test_ai-code-git.el 24/24 — the three prefix-behavior tests are replaced by nine covering the completion default, all four dispatch paths, the Magit-backed entries working with ai-code-git-worktree-root unset, and the new open-dir error cases. test_ai-code.el 50/50, including the ai-code--menu-agile-development transient assertions touched by the label change. Both changed sources byte-compile and pass checkdoc with no warnings.

Out of scope: magit-worktree-delete still does not clean up the task-file symlink association or session-link records that ai-code--worktree-create-and-link-task-file sets up. The real task file lives in the main repo's .ai.code.files/, so nothing is lost.

@tninja

tninja commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	ai-code-git.el

Co-authored-by: tninja <714625+tninja@users.noreply.github.com>

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in b11224f by merging main into this branch and reconciling the ai-code-git.el conflict.

@tninja
tninja merged commit b360006 into main Sep 3, 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.

C-c a w should show more options of worktree

2 participants