Check folder consent before creating or resuming TUI tasks (#44755)

## What changed

- Check directory trust when dispatching tasks from Agent Command Center, resuming sessions, and opening loaded tasks.
- Return connected users to Agent Command Center when they cancel folder consent. Clear launch prompts and images on startup cancellation, and restore the composer draft when task dispatch is canceled.
- Reload local configuration after saving folder trust and review startup hooks before creating a new task.
- Label connected consent screens with “Back to Agent Command Center”; retain quit behavior for embedded sessions.

## Testing

Add a terminal integration test covering unknown and untrusted folders, server-authoritative trust, cancellation and retry, resumed tasks with changed directories, and hook review before task creation. Update consent-screen snapshots.

GitOrigin-RevId: db88d2113fd47bc4c57369cc20ebf3042e6fb7ab
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-11 07:13:19 +00:00
1 parent b9934480bf
commit 02a8f038b8
20 files changed
+544 -42

No files matched your search

+29 -11
View File
@@ -1035,7 +1035,7 @@ pub async fn run_main(
#[allow(clippy::too_many_arguments)]
async fn run_ratatui_app(
cli: Cli,
mut cli: Cli,
arg0_paths: Arg0DispatchPaths,
loader_overrides: LoaderOverrides,
strict_config: bool,
@@ -1328,7 +1328,7 @@ async fn run_ratatui_app(
};
let use_fork = cli.fork_picker || cli.fork_last || cli.fork_session_id.is_some();
let session_selection = if cli.agents_overview {
let mut session_selection = if cli.agents_overview {
resume_picker::SessionSelection::AgentsOverview
} else if use_fork {
if let Some(id_str) = cli.fork_session_id.as_deref() {
@@ -1753,15 +1753,33 @@ async fn run_ratatui_app(
trust_decision_was_made = true;
}
} else if consent.should_exit {
shutdown_startup_session(Some(app_server), &mut terminal_restore_guard).await;
return Ok(AppExitInfo {
token_usage: crate::token_usage::TokenUsage::default(),
thread_id: None,
resume_hint: None,
disconnect_info: None,
update_action: None,
exit_reason: ExitReason::UserRequested,
});
if matches!(app_server_target, AppServerTarget::Embedded) {
shutdown_startup_session(Some(app_server), &mut terminal_restore_guard).await;
return Ok(AppExitInfo {
token_usage: crate::token_usage::TokenUsage::default(),
thread_id: None,
resume_hint: None,
disconnect_info: None,
update_action: None,
exit_reason: ExitReason::UserRequested,
});
}
if !uses_remote_workspace {
config = load_config_or_exit_with_fallback_cwd(
cli_kv_overrides.clone(),
overrides.clone(),
loader_overrides.clone(),
cloud_config_bundle.clone(),
strict_config,
Some(current_cwd.to_path_buf()),
managed_worktree.as_ref(),
)
.await;
}
session_selection = resume_picker::SessionSelection::AgentsOverview;
cli.prompt = None;
cli.images.clear();
startup_draft.update_session_selection(&mut tui, &session_selection)?;
}
}
startup_draft.apply_config(&config);