Add /archive slash command (#25027)

## Why

TUI users can archive saved sessions from other surfaces, but there is
no in-session command for archiving the active session. Since archiving
the active session also exits the TUI, the command should ask for
explicit confirmation instead of firing immediately.

I'm also working on [a companion
PR](https://github.com/openai/codex/pull/25021) that adds `codex
archive` and `codex unarchive` top-level CLI commands.

## What changed

- Adds a new `/archive` slash command described as `archive this session
and exit`.
- Shows a confirmation dialog with `No, don't archive` selected first
and `Yes, archive and exit` as the explicit action.
- On confirmation, calls the existing `thread/archive` app-server RPC
for the active main session and exits after success.
- Keeps `/archive` disabled while a task is running and unavailable in
side conversations.

## Verification

Added focused TUI coverage for the `/archive` confirmation flow,
disabled-while-task-running behavior, and the `/ar` slash-command popup
snapshot.
This commit is contained in:
Eric Traut authored and GitHub committed 2026-05-29 11:07:19 -07:00
1 parent 1333f4a689
commit 36cd36626d
9 files changed
+168

No files matched your search

+30
View File
@@ -121,6 +121,9 @@ impl App {
}
}
}
AppEvent::ArchiveCurrentThread => {
return Ok(self.archive_current_thread(app_server).await);
}
AppEvent::ForkCurrentSession => {
self.session_telemetry.counter(
"codex.thread.fork",
@@ -2146,4 +2149,31 @@ impl App {
}
}
}
pub(super) async fn archive_current_thread(
&mut self,
app_server: &mut AppServerSession,
) -> AppRunControl {
let Some(thread_id) = self.active_thread_id.or(self.chat_widget.thread_id()) else {
self.chat_widget
.add_error_message("A thread must start before it can be archived.".to_string());
return AppRunControl::Continue;
};
if self.side_threads.contains_key(&thread_id) {
self.chat_widget.add_error_message(
"'/archive' is unavailable in side conversations. Press Ctrl+C to return to the main thread first."
.to_string(),
);
return AppRunControl::Continue;
}
match app_server.thread_archive(thread_id).await {
Ok(()) => AppRunControl::Exit(ExitReason::UserRequested),
Err(err) => {
self.chat_widget
.add_error_message(format!("Failed to archive current thread: {err}"));
AppRunControl::Continue
}
}
}
}