Defer resume picker and directory changes to a fresh TUI stack (#43376)

## Why

Session transitions need stack headroom for embedded-server initialization and configuration loading. Running them inside event dispatch risks exhausting the TUI thread's stack.

## What changed

- Queue `/resume` and valid `/cd` requests for processing after event dispatch returns.
- Reject additional `/cd` requests while one is pending, and recheck the source session, working directory, idle state, and remote-environment restrictions before applying it.

## Testing

Add a Unix PTY regression test that exercises `/resume`, worktree conversation forks, `/cd`, and new worktree conversations through the real TUI event loop. Update the directory-change test to verify that dispatch queues the request without immediately changing configuration.

GitOrigin-RevId: 4950921931dfaba9e55e6bb04f98f7ba64b72122
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-07 06:43:23 +00:00
1 parent 694b6319d3
commit 5ecb3afd1b
11 files changed
+283 -5

No files matched your search

+2 -2
View File
@@ -9,8 +9,8 @@ impl App {
tui: &mut tui::Tui,
app_server: &mut AppServerSession,
) -> Result<AppRunControl> {
// This runs inside the active TUI event future. Starting a second embedded server
// inline can exhaust that thread's stack while initializing its auth manager.
// Keep embedded-server initialization on its own runtime task as well as opening the
// picker on a fresh event-loop iteration; its auth manager needs more stack headroom.
let picker_config = self.config.clone();
let picker_target = self.app_server_target.clone();
let picker_state_db = self.state_db.clone();