feat: worktrunk (wt) core integration#123
Merged
actionshrimp merged 6 commits intomainfrom Mar 12, 2026
Merged
Conversation
Adds lua/gitlad/worktrunk/parse.lua with WorktreeInfo type and parse_list() for NDJSON output from `wt list --format=json`, and lua/gitlad/worktrunk/init.lua with is_installed, is_active, list, switch, merge, remove, and copy_ignored async CLI wrappers. Includes a representative NDJSON fixture and unit tests for both the parser and the detection/is_active logic.
Adds worktrunk, copy_ignored_on_create, and copy_ignored_from fields
to GitladWorktreeConfig with safe defaults ("auto", "never", "trunk").
When worktrunk (wt) is installed and cfg.worktree.worktrunk != "never", M.open() now bifurcates into _open_worktrunk_popup or _open_git_popup. The worktrunk popup provides Switch (s/S), Merge (m), and Remove (R) sections wired to wt CLI, plus a "Git Worktree" escape hatch section reusing all existing git worktree action implementations verbatim. Includes unit tests for popup structure/bifurcation logic and a guarded e2e test (skipped when wt is not in PATH).
Adds lua/gitlad/popups/worktree_merge.lua with switches (no-squash, no-rebase, no-remove, no-verify), a target branch option (=t), and a single merge action (m) that calls wt.merge(). Reachable via the `m` action in the worktrunk worktree popup.
- Adds -i (copy-ignored) switch with persist_key=wt_copy_ignored to the worktrunk popup so users can toggle copy-ignored per-session and have it persist across popup invocations - Adds ci (Copy ignored files) action under a Steps heading for running wt step copy-ignored immediately against the current or context worktree - _wt_create_and_switch now checks the -i switch and cfg.worktree.copy_ignored_on_create to decide whether to run copy-ignored automatically after creating a new worktree Unit tests cover the new switch (persist_key) and ci action. Guarded e2e test for wt switch/remove ops (skipped without wt).
The actual wt CLI outputs a JSON array, not NDJSON. Updated parse.lua to handle JSON arrays (with NDJSON fallback), updated the fixture and parse unit tests to match the real format. Also fixed existing e2e worktree tests that were failing because wt is installed locally and the popup was bifurcating into worktrunk mode. Fixed worktrunk_ops e2e test to not pre-initialize globals to false (wait_for_var checks ~= nil, so false would return immediately). Fixed worktrunk_popup e2e tests to use the correct state/workflow API.
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
Builds on PR #122 (persistent popup switches). Wires up the
wtworktrunk CLI as a first-class worktree workflow layer.lua/gitlad/worktrunk/— async wrappers around thewtCLI:is_installed,is_active,list,switch,merge,remove,copy_ignoredworktreeconfig fields:worktrunk("auto"|"always"|"never"),copy_ignored_on_create,copy_ignored_from%/Z) into a worktrunk-oriented mode whenwtis installed (auto-detected), with Switch/Merge/Remove/Steps sections plus a "Git Worktree" escape hatch for raw git opswt mergepopup with no-squash/no-rebase/no-remove/no-verify switches and a target-branch option-i(copy-ignored) switch and acistandalone step actionHow to test
Prerequisites
The worktrunk features require the
wtCLI to be installed. Without it in PATH, the popup silently falls back to the standard git mode — no config needed.Default behaviour (auto-detect)
:Gitlad%(orZ) to open the worktree popupwtinstalled: popup is titledWorktrees [worktrunk]with Switch / Merge / Remove / Steps sections + "Git Worktree" escape hatchwt: standard popup, unchangedForce git mode (even if wt installed)
Worktrunk popup keys
-iswt list)Swt switch -c <branch>)mRwt remove)ciwt step copy-ignorednowb/c/k/g/l/u/pwt Merge popup (
m→ opens separate popup)-s/-r/-R/-v=tmwt mergeRunning tests
Notes
wt list --format=jsonoutputs a JSON array (not NDJSON). The parser handles both formats.worktrunk = "never"so they're stable regardless of whetherwtis installed locally.