Skip to content

feat: add hooks configuration section to TUI settings#3

Merged
zxh3 merged 4 commits into
mainfrom
feat/hooks-configuration-tui
Jan 20, 2026
Merged

feat: add hooks configuration section to TUI settings#3
zxh3 merged 4 commits into
mainfrom
feat/hooks-configuration-tui

Conversation

@zxh3
Copy link
Copy Markdown
Owner

@zxh3 zxh3 commented Jan 20, 2026

Summary

Complete hooks system for worktree lifecycle events:

  • Hooks execution: Run shell commands on post-create, post-select, post-delete, post-rename events
  • TUI settings: Configure hooks in the Settings dialog with multi-line editing support
  • Environment variables: WT_NAME, WT_PATH, WT_BRANCH, WT_REPO_ID, WT_HOOK (+ WT_OLD_NAME, WT_OLD_PATH for rename)
  • Per-repo overrides: Configure different hooks for different repositories

Files changed

File Description
src/lib/config.ts Add hooks schema (HookType, HookCommand, HooksSchema)
src/lib/hooks.ts Hook execution logic with timeout and error handling
src/utils/compat.ts Add execShellCommand for cross-platform shell execution
src/commands/new.ts Execute post-create hooks
src/commands/rm.ts Execute post-delete hooks
src/commands/mv.ts Execute post-rename hooks
src/tui/App.tsx Execute post-select hooks on worktree selection
src/tui/components/SettingsDialog.tsx Add hooks configuration UI
src/tui/components/CreateDialog.tsx Execute post-create hooks
src/tui/components/DeleteConfirm.tsx Execute post-delete hooks
image

Test plan

  • bun test - all 134 tests pass
  • bun run typecheck - passes
  • bun run lint - passes
  • Manual: Configure hooks in TUI settings, verify they execute on lifecycle events

🤖 Generated with Claude Code

zxh3 and others added 4 commits January 20, 2026 15:05
Add a user-friendly hooks configuration section to the Settings dialog
that allows users to view and edit hook commands for all 4 lifecycle
events: post-create, post-select, post-delete, and post-rename.

Features:
- Display single commands inline (e.g., "npm install")
- Display multi-command hooks as numbered list with "[N commands]"
- Edit hooks with Tab to add lines, j/k to navigate, d to delete
- Support for both global hooks and per-repo hook overrides
- Show "(not set)" for undefined hooks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove flaky tests that depended on writing/reading config files.
The tests now verify the UI structure (hooks section, all 4 hook types,
help text) without relying on specific config values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add HookType, HookCommand, and HooksSchema types to config.ts
to support hooks configuration in the TUI settings dialog.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add complete hooks system that executes shell commands on worktree
lifecycle events (post-create, post-select, post-delete, post-rename).

- Add hooks.ts with hook execution logic, environment variables, timeout support
- Integrate hooks into commands (new, rm, mv) and TUI (App, CreateDialog, DeleteConfirm)
- Add execShellCommand utility to compat.ts for cross-platform shell execution
- Add comprehensive tests for hooks functionality

Environment variables available to hooks:
- WT_NAME, WT_PATH, WT_BRANCH, WT_REPO_ID, WT_HOOK
- WT_OLD_NAME, WT_OLD_PATH (for post-rename)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@zxh3 zxh3 merged commit d9a3796 into main Jan 20, 2026
2 checks passed
@zxh3 zxh3 deleted the feat/hooks-configuration-tui branch January 20, 2026 23:13
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