mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
## Why Conversation search results can point users to saved transcripts. Users need to be able to follow those links without leaving their terminal session. ## What changed - Make Markdown links such as `[Review notes](codex://threads/<id>)` open the linked conversation from chat and transcript views. In the resume picker, follow the link to another transcript preview. - Resolve nested agent links through their owning session and select the requested agent. Show archived conversations in read-only mode and let users explicitly reopen them. - Include the Markdown link format in thread search results, including archived results. ## Testing Add coverage for thread link parsing and activation, nested agent navigation, archived thread reopening, and mouse capture during transcript preview transitions. GitOrigin-RevId: 40a39c43acf643b97e066ba663aefcf9cda0bc81
87 lines
2.9 KiB
Rust
87 lines
2.9 KiB
Rust
//! Archive notifications freeze cached threads; external unarchive resumes the displayed thread.
|
|
//! Archive metadata is separate from attachment; archived channels only replay cached events.
|
|
|
|
use super::*;
|
|
use crate::chatwidget::ReadOnlyThread;
|
|
|
|
pub(super) fn update_archived_thread(
|
|
app: &mut App,
|
|
thread_id: ThreadId,
|
|
notification: &ServerNotification,
|
|
) {
|
|
let Some(channel) = app.thread_event_channels.get_mut(&thread_id) else {
|
|
return;
|
|
};
|
|
match notification {
|
|
ServerNotification::ThreadArchived(_) => {
|
|
channel.archived = true;
|
|
channel.mark_replay_only();
|
|
}
|
|
ServerNotification::ThreadUnarchived(_) if channel.archived => {
|
|
channel.archived = false;
|
|
}
|
|
_ => return,
|
|
}
|
|
let resume = !channel.archived;
|
|
if app.current_displayed_thread_id() == Some(thread_id) {
|
|
show_cached_read_only_thread(app, thread_id);
|
|
if resume {
|
|
app.app_event_tx
|
|
.send(AppEvent::ResumeUnarchivedThread(thread_id));
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(super) async fn resume_displayed_thread(
|
|
app: &mut App,
|
|
tui: &mut tui::Tui,
|
|
app_server: &mut AppServerSession,
|
|
thread_id: ThreadId,
|
|
) {
|
|
if app.primary_thread_id != Some(thread_id) {
|
|
if let Some(channel) = app.thread_event_channels.get_mut(&thread_id) {
|
|
channel.archived = false;
|
|
}
|
|
if let Err(error) = app.select_agent_thread(tui, app_server, thread_id).await {
|
|
app.chat_widget
|
|
.add_error_message(format!("Failed to reopen agent: {error}"));
|
|
}
|
|
return;
|
|
}
|
|
let target = SessionTarget {
|
|
backend_id: app_server.backend_id(),
|
|
path: app
|
|
.primary_session_configured
|
|
.as_ref()
|
|
.and_then(|session| session.rollout_path.clone()),
|
|
thread_id,
|
|
cwd: None,
|
|
history_mode: None,
|
|
};
|
|
if let Ok(AppRunControl::Exit(_)) = app.resume_target_session(tui, app_server, target).await {
|
|
app.app_event_tx.send(AppEvent::Exit(ExitMode::Immediate));
|
|
}
|
|
// A writer conflict does not establish that the thread was unarchived.
|
|
// Keep the archive flag if resume could not replace the archived view.
|
|
if app.current_displayed_thread_id() == Some(thread_id)
|
|
&& !app.chat_widget.is_archived_view()
|
|
&& let Some(channel) = app.thread_event_channels.get_mut(&thread_id)
|
|
{
|
|
channel.archived = false;
|
|
}
|
|
}
|
|
|
|
pub(super) fn show_cached_read_only_thread(app: &mut App, thread_id: ThreadId) {
|
|
let Some(channel) = app.thread_event_channels.get(&thread_id) else {
|
|
return;
|
|
};
|
|
let reason = if channel.archived {
|
|
ReadOnlyThread::Archived
|
|
} else if channel.attachment() == ThreadEventAttachment::ExternalWriter {
|
|
ReadOnlyThread::ExternalWriter
|
|
} else {
|
|
return;
|
|
};
|
|
app.chat_widget.show_read_only_thread(reason);
|
|
}
|