Skip to content

feat(agent): resume previous conversations - #414

Merged
fcoury-oai merged 13 commits into
mainfrom
fcoury/agent-session-resume
Oct 20, 2026
Merged

fcoury-oai merged 13 commits into
mainfrom
fcoury/agent-session-resume

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Red persists Agent conversations, but there is no in-pane way to find and reopen them. Starting a new conversation should not make earlier Red or Codex work difficult to recover, and browsing history should not discard the current transcript position or unsent draft.

This change:

  • adds an embedded session picker to the Agent pane, available from Sessions, Alt-s, and :AgentSessions
  • supports debounced search across Red, the current workspace, or all Codex conversations, with per-workspace query and selection memory
  • adds an optional, read-only preview of the selected session's latest exchange without resuming or mutating it
  • resumes Red-owned threads directly and continues external Codex conversations in a new Red-owned thread with editor tools enabled
  • keeps the current live conversation until the replacement restores successfully, returning to it if switching fails
  • restores persisted transcript annotations from Codex thread history and recognizes legacy Red sessions from rollout metadata
  • documents the new host API 0.21 session and temporary-panel-context surface, plus the Agent pane shortcuts

How to Test

  1. Open the Agent pane, complete a turn, type an unsent follow-up, and move away from the transcript tail.
  2. Press Alt-s. Search the list, use Alt-s to cycle Red, This workspace, and All Codex, move with arrows or Ctrl-j / Ctrl-k, and toggle the latest-exchange preview with Alt-p.
  3. Press Esc. The original conversation, transcript position, focus, and unsent draft should be restored exactly.
  4. Reopen the picker and press Enter on a previous Red session. Its transcript and any surviving annotations should be restored in the same pane.
  5. Select a non-Red Codex session from the workspace or all-session scope. Its user and assistant history should continue in a new Red-owned thread with Red's editor tools available; if restoration fails, the prior live conversation should remain usable.

Focused automated validation:

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-features --lib session (75 passed)
  • cargo test --all-features --test codex_app_server direct_app_server_lists_searches_and_continues_sessions_for_red
  • cargo test --all-features --lib annotation (27 passed)

@fcoury-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T21:44:43.313147Z 1d654ec Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d654ecff0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor.rs Outdated
Comment on lines +12287 to +12291
let command = if resume {
CodexCommand::ResumeSession {
cwd,
session_id: session_id.clone(),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject browser sessions with incompatible tool contracts

When a legacy Red session is selected, resume routes it directly to ResumeSession without the tool-contract compatibility check used by AgentResumeSession immediately above. The picker deliberately discovers legacy Red rollouts, whose snapshots default to contract version 0, and Codex cannot replace a persisted thread's dynamic-tool catalog on resume; consequently these sessions can run with stale tool schemas instead of remaining transcript-only and starting a compatible thread. Determine compatibility from the persisted metadata or continue such sessions in a fresh thread rather than resuming them directly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prepared in local commit 7b089e1: direct resume now requires a known matching tool-contract version. Unknown or obsolete catalogs continue user/assistant history in a fresh Red thread with the current editor tools. Added coverage for missing, legacy, and matching versions. The full library suite passes (2739 tests), and all-targets/all-features clippy passes. Publication is currently blocked by PushPatrol and requires a manual push; leaving this thread open until the commit is visible on the PR.

Comment thread plugins/agent.hk
Comment on lines +897 to +903
fn session_browser_query_changed(query: String) {
if !state().session_browser_open || query == state().session_browser_query { return; }
red::state_patch(AgentState { session_browser_query: query });
let previous = red::string(state().session_browser_debounce, "");
if previous != "" { red::execute("CancelTimeout", previous); }
let timer = red::execute("SetTimeout", 150);
red::state_patch(AgentState { session_browser_debounce: timer });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear stale session rows while search is pending

After the query changes, the old result blocks and session_browser_results remain active until the 150 ms debounce and server request complete. During that interval, pressing Enter emits activate_block for the still-selected old row rather than filter_submit, so typing a query and immediately confirming can switch to a session that does not match the entered query. Clear or disable the existing action rows when scheduling the search, or reject activation unless the current query equals session_browser_results_query.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prepared in local commit 7b089e1: session activation is rejected while the query differs from the query that produced the displayed results. Query changes also invalidate the outstanding request so a late response cannot be relabeled as current. Extended the bundled picker regression test to type a new query and immediately activate an old row. The full library suite passes (2739 tests), and all-targets/all-features clippy passes. Publication is currently blocked by PushPatrol and requires a manual push; leaving this thread open until the commit is visible on the PR.

@fcoury-oai
fcoury-oai merged commit 068407b into main Oct 20, 2026
17 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/agent-session-resume branch October 20, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant