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

@@ -164,6 +164,35 @@ impl ChatWidget {
SlashCommand::New => {
self.app_event_tx.send(AppEvent::NewSession);
}
SlashCommand::Archive => {
self.bottom_pane.show_selection_view(SelectionViewParams {
title: Some("Archive this session?".to_string()),
subtitle: Some(
"Are you sure? This will archive the current session and exit Codex"
.to_string(),
),
footer_hint: Some(standard_popup_hint_line()),
items: vec![
SelectionItem {
name: "No, don't archive".to_string(),
description: Some("Return to the current session".to_string()),
dismiss_on_select: true,
..Default::default()
},
SelectionItem {
name: "Yes, archive and exit".to_string(),
description: Some("Archive this session now".to_string()),
actions: vec![Box::new(|tx| {
tx.send(AppEvent::ArchiveCurrentThread);
})],
dismiss_on_select: true,
..Default::default()
},
],
..Default::default()
});
self.request_redraw();
}
SlashCommand::Clear => {
self.app_event_tx.send(AppEvent::ClearUi);
}
@@ -949,6 +978,7 @@ impl ChatWidget {
| SlashCommand::TestApproval => QueueDrain::Continue,
SlashCommand::Feedback
| SlashCommand::New
| SlashCommand::Archive
| SlashCommand::Clear
| SlashCommand::Resume
| SlashCommand::Fork