Skip to content

feat: enrich worktrees status section with wt list data#124

Open
actionshrimp wants to merge 2 commits intomainfrom
feature/worktrunk-status-enrichment
Open

feat: enrich worktrees status section with wt list data#124
actionshrimp wants to merge 2 commits intomainfrom
feature/worktrunk-status-enrichment

Conversation

@actionshrimp
Copy link
Owner

Summary

Builds on PR #123 (worktrunk core). Runs wt list --format=json in parallel with git worktree list during status refresh and renders richer worktree rows.

  • Parallel wt list fetch in state/init.lua (step 8) — only when worktrunk is active
  • worktrunk/parse.lua: new M.merge(worktrees, infos) helper — matches by branch name, attaches WorktreeInfo as .wt on WorktreeEntry
  • git/parse.lua: adds wt?: WorktreeInfo field to WorktreeEntry type
  • status_sections.lua: renders ↑N ↓N ● [C] enrichment between branch name and path when .wt data is present
  • Calls mark_operation_time before launching wt list so the watcher cooldown covers it (prevents spurious stale indicators)

Enriched display:
```
Worktrees (3)
feature/auth ↑2 ↓0 ● ../worktrees/feature-auth/

  • main ../worktrees/main/
    fix/bug-123 ↑1 ↓2 [C] ../worktrees/bugfix-login/
    ```

Where: ↑/↓ = ahead/behind main, = dirty working tree, [C] = conflicts

Test plan

  • make test — all 655 tests pass
  • make lint — clean
  • Unit: make test-file FILE=tests/unit/test_worktrunk_enrich.lua (8 tests)
  • E2E (guarded, needs wt): make test-file FILE=tests/e2e/test_worktree_status_enriched.lua
  • Manual: open a repo with multiple worktrees and wt installed, press gr — worktree rows should show ahead/behind/dirty info

Run wt list --format=json in parallel with git worktree list during
status refresh (when worktrunk is active). Merge results by branch name,
attaching WorktreeInfo as a .wt field on WorktreeEntry. Render ahead/behind
main, dirty indicator (●), and conflict state ([C]) in the worktrees section.

Also calls mark_operation_time before wt.list so the watcher cooldown
covers the external wt process, preventing spurious stale indicators.
Two-pass render: build status strings first (using wt.symbols when
available, falling back to structured main_state/ahead/behind data),
compute max width, then render with fixed-width status column so paths
align. Extracts status_str() into worktrunk/parse.lua for testability.
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