Add a managed worktree browser to the TUI (#43286)

## What changed

Add a searchable “Browse worktrees” option to `/worktree` for local repositories with worktrees enabled. List checkouts from the repository's configured pool, show owner metadata, and let users resume an owner thread or copy a worktree's working directory.

Load worktrees asynchronously and discard results after the loading popup is dismissed or the request context changes. Ignore actions from stale requests and offer copying when owner metadata is missing or invalid.

## Testing

Add popup snapshots and tests for search, resume and copy actions, stale results, and disabled local worktree operations. Extend lifecycle coverage to verify discovery from repository subdirectories and handling of missing or invalid owner metadata.

GitOrigin-RevId: 2b7e694a133278da640b6bb275fd5c1202b271c7
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-06 21:36:02 +00:00
1 parent 8d7cc24a87
commit b053ef9e5a
13 files changed
+457 -3

No files matched your search

@@ -0,0 +1,12 @@
---
source: tui/src/chatwidget/tests/worktree_picker_tests.rs
assertion_line: 114
expression: "render_bottom_popup(&chat, 80)"
---
Worktree
/repo/worktree
› 1. Resume owner thread
2. Copy working directory
Press enter to confirm or esc to go back
@@ -0,0 +1,12 @@
---
source: tui/src/chatwidget/tests/worktree_picker_tests.rs
assertion_line: 100
expression: "render_bottom_popup(&chat, 80)"
---
Managed worktrees
Select a worktree to resume its owner or copy its working directory
› /repo/worktree Owner: 00000000-0000-0000-0000-000000000001
Press enter to confirm or esc to go back
@@ -0,0 +1,10 @@
---
source: tui/src/chatwidget/tests/worktree_picker_tests.rs
assertion_line: 90
expression: "render_bottom_popup(&chat, 80)"
---
Managed worktrees
› Loading worktrees…
Press enter to confirm or esc to go back
@@ -1,12 +1,15 @@
---
source: tui/src/chatwidget/tests/slash_commands.rs
source: tui/src/chatwidget/tests/worktree_picker_tests.rs
assertion_line: 71
expression: popup
---
Create a new worktree
Worktrees
› 1. Continue current conversation Preserve this conversation in the new
checkout
2. Start new conversation Open a fresh conversation in the new
checkout
3. Browse worktrees Resume an owner thread or copy a working
directory
Press enter to confirm or esc to go back