Open tasks managed elsewhere as read-only history in the command center (#44969)

## Why

The command center previously refused to open tasks managed by another app server, preventing users from viewing their saved history.

## What changed

- Fall back to a frozen, read-only history snapshot when attaching fails because another server owns the task. Preserve drafts and skip buffered request replay and paused-goal prompts while viewing.
- Keep the snapshot when reopening the displayed task, and allow explicit retry to attach once the other server releases it.
- Allow pasting into the command center while a read-only conversation is displayed, while keeping the conversation composer protected.
- Box the TUI startup future to keep it out of the CLI caller's frame.

## Testing

Add coverage for read-only history, draft and selection preservation, retry before and after ownership release, and history-read failure without leaving the current conversation. Assert that opening a read-only task does not start a turn and that the TUI startup future remains below 64 KiB.

GitOrigin-RevId: f1bdb5b2d9182079de4e53346a56742a4a02a1c7
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-12 04:28:14 +00:00
1 parent 53ff712a48
commit 7efb0262d6
6 files changed
+304 -53

No files matched your search

+17 -2
View File
@@ -1014,12 +1014,13 @@ pub async fn run_main(
explicit_remote_endpoint: Option<RemoteAppServerEndpoint>,
) -> std::io::Result<AppExitInfo> {
system_motion::initialize().await;
match startup_orchestration::run_main_inner(
// Keep the startup future out of the CLI caller's frame while the TUI is running.
match Box::pin(startup_orchestration::run_main_inner(
cli,
arg0_paths,
loader_overrides,
explicit_remote_endpoint,
)
))
.await
{
Err(err) if startup_draft::StartupCancelled::matches(&err) => Ok(AppExitInfo {
@@ -2194,6 +2195,7 @@ pub(crate) mod tests {
use super::*;
use crate::legacy_core::config::ConfigBuilder;
use crate::legacy_core::config::ConfigOverrides;
use clap::Parser;
use codex_app_server_protocol::AskForApproval;
use codex_app_server_protocol::ClientRequest;
use codex_app_server_protocol::RequestId;
@@ -2205,6 +2207,19 @@ pub(crate) mod tests {
use serial_test::serial;
use tempfile::TempDir;
#[test]
fn tui_startup_future_stays_bounded() {
let future = run_main(
Cli::parse_from(["codex"]),
Arg0DispatchPaths::default(),
LoaderOverrides::default(),
/*explicit_remote_endpoint*/ None,
);
let size = std::mem::size_of_val(&future);
assert!(size < 64 * 1024, "TUI startup future is {size} bytes");
}
async fn build_config(temp_dir: &TempDir) -> std::io::Result<Config> {
ConfigBuilder::default()
.codex_home(temp_dir.path().to_path_buf())