Repository navigation
fix(agent): make the session picker fast and readable - #420
Conversation
List sessions from Codex's state DB, scope Red sessions to the workspace, match titles before the slower text search, resume only Red threads from this workspace, strip Red's context and recap from labels, peeks and restored prompts, keep the model header after a picker restore, reset the selection on a new scope or query, and let Ctrl-U clear the search field.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68496f9766
ℹ️ 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".
| red::state_patch(AgentState { model_info: event.model_info, accepted_model: Json {}, turn_model_info: Json {} }); | ||
| // The thread's model follows in its own event, which can arrive before the | ||
| // pane state names the restored thread. | ||
| red::state_patch(AgentState { session_id: event.thread_id }); |
There was a problem hiding this comment.
Check the displayed thread before replacing its session ID
When switching sessions while the pane already contains a conversation, this assignment makes shows_thread(event.thread_id) compare the restored ID against itself. Since switching also clears resume_age, the existing nonempty transcript makes that predicate true, so load_conversation(event) is skipped. The pane consequently keeps displaying the previous session's messages even though subsequent prompts go to the selected session. Determine whether the restored thread is already displayed before updating session_id, or update it after the transcript-loading decision.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, fixed in c9dc257. session_restored now decides whether the thread is already shown before it sets session_id. session_id is still set before the model event arrives, so the header fix stays. The restore test now switches from a shown conversation to a picked thread and checks that the picked transcript is rendered. It fails without the fix.
| if request.sessions.len() >= MAX_LISTED_SESSIONS { | ||
| let more = request.more || next_cursor.is_some() || wants_contents(&request); | ||
| return finish(request.sessions, more, request_id, events).await; |
There was a problem hiding this comment.
Search conversation contents even when title matches reach the cap
When a query matches at least 200 session titles, this early return also runs for requests with search_contents: true, before they can transition to ListPhase::Contents. The picker's second request therefore repeats the title results without ever issuing thread/search; a newer session matching only in its conversation text cannot appear, despite the documented promise to return the 200 most recently updated matches. Apply the display cap without skipping the contents phase, then retain the newest matches from the merged results.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, fixed in c9dc257. Each phase now stops at the cap on its own: titles stop at 200 matches, and the text search still runs and stops at 200 hits. finish then keeps the 200 newest of the merged results and sets more. The integration test's capped query now gets a text-only match newer than every title match, and that match comes first.
…omposer The pane header squeezed Sessions, New and Clear into [S] [N] [C] buttons, and the picker's scope was only a word in the title, with its Alt-s hint cut off at the end of the hint row. Picker contexts can now declare tabs, which the host shows in a row under the search field and switches by click or shortcut, emitting context_tab. Pane actions left out of the header are listed as key hints under the composer. The picker hint row now leaves out whole hints that don't fit.
The file tree keeps the outer edge when both are docked on the same side, whichever opened first.
…he cap Naming the restored thread before checking whether the pane shows it made every switch look like the thread already on screen, so the old transcript stayed. A query matching 200 titles also skipped the text search, hiding newer sessions that match only in their conversation.
#420 stopped drawing brackets around header actions, so the RPC panel test could no longer find "[Run]" to click.
* chore(release): write the v0.10.0 release campaign Replace the v0.9.1 stories with this release's, update the README's release section, which still described the v0.8.2 notify-only updater, and list the host API 0.21.0 symbols added by #420. * docs(agent): describe the session picker's scope tabs * test(rpc): find the Run panel action without header brackets #420 stopped drawing brackets around header actions, so the RPC panel test could no longer find "[Run]" to click.
The Agent session picker (
Alt-s,:AgentSessions) worked after #416, but trying it against a real Codex history (about 2,300 threads) showed it was slow and hard to read. The default Red scope took about 10 s to load, because Codex doesn't tag Red's threads, so Red paged through every thread, rescanning rollouts, and opened files to find its own. A search took 20 to 30 s before anything appeared. The Red scope also listed Red sessions from every directory, and Enter resumed one into the current workspace even though the thread kept its old working directory. Red threads have no name, so their rows showed the raw first prompt with Red's editor context glued on ("Reply with just OK.Active editor context from file:///…"), and conversations resumed after an interruption all read "Previous conversation (the last turn was interrupted): …". The peek and the restored transcript showed the same text. After resuming from the picker, the header said "Codex" instead of the model. Switching scope left the cursor at an arbitrary row, andCtrl-Udidn't clear the search field. The pane header also squeezed Sessions, New and Clear into cryptic[S] [N] [C]buttons, and the picker's scope was only a word in the title, with itsAlt-shint cut off at the end of the hint row.What changed
Faster listing.
thread/listnow asks Codex to answer from its state DB (useStateDbOnly) rather than rescanning every rollout: listing all 2,267 threads went from 7.7 s to 0.2 s. The Red and This workspace scopes pass the workspace to Codex as acwdfilter. A thread is recognized as Red's from its recordedoriginatorwhen Codex has one, and otherwise from the rollout's first line as before. Codex has compressed older rollouts to.jsonl.zstwhile still listing the.jsonlpath, so that fallback now also reads the compressed file, using the pure-Rustruzstddecoder.Search in two steps. A query first matches thread names and first prompts in Red itself (every word, ignoring case), which takes well under a second. The picker then asks for a text search with
thread/search, shows "Searching conversation text…" meanwhile, and merges the content matches in, adding snippets to rows it already shows.AgentListSessionsgains an optionalsearch_contentsargument for this (host API 0.21.0 is still unreleased).Scopes and resuming. The Red scope now lists Red sessions from this workspace. A session gains a
resumableflag, set only for a Red thread from this workspace, and the picker resumes only those. Any other session, including a Red one from another directory, continues in a new thread here and is labelled "Continue here" or "Continue in Red".Readable rows. Labels, peeks and restored transcripts drop the editor context Red sends after a prompt, and show only the follow-up a recap was sent with (
typed_promptinsrc/agent_conversation.rs, shared by all three). The recap and context text are built from the same constants.Model header. Codex reports the model of a resumed thread right after restoring it, in the same batch, before Red tells the plugin which thread is active, so the plugin dropped the event. The pane now takes the thread id from the restore event itself.
Selection. Changing scope or query starts the list again at its first row: replacing a picker's blocks with an empty list now resets the host's selection, and the plugin does that before showing new results. Selecting the first row scrolls its group heading back into view. The peek uses the row the host shows as selected, which it didn't always do before.
Scope tabs. The picker shows its scopes as tabs under the search field: Red, This workspace, All Codex. The selected one is highlighted, a click selects one, and
Tab/Shift-Tab(orAlt-s) move to the next or previous. On narrow panes the tabs use short labels, and then show only the selected scope.EnterTextPanelContextoptions gaintabs,tabandtab_shortcutfor this, and the host emitscontext_tabwith the tab's id. The hint row no longer carries the scope, and leaves out whole hints rather than cutting one off.Pane actions. Sessions, New and Clear moved out of the header to a row of key hints under the composer (
Alt-s sessions · Alt-n new · Alt-c clear), which can be clicked. Any composer panel lists the actions it declares withshow_in_header: falsethere. The header keeps only the close button, drawn without brackets.Pane on the left. The Agent pane now opens on the left. When the file tree is open too, the tree keeps the outer edge, whichever opened first: docked side panels without a composer are placed before conversation panes on the same side.
Ctrl-w Lstill moves the pane right, per workspace.Search field.
Ctrl-Uin Insert mode deletes back to the start of the line, in the session search and the composer alike.How to Test
Alt-s. The Red list should appear within about a second, with labels that are just the prompts you typed.Alt-stwice to go through This workspace and All Codex. Each should load in well under a second and start with the first row selected. In All Codex, a Red session from another directory should say "Continue here".Ctrl-U: the field should clear and the full list return.Alt-p. The peek should show the highlighted session, without any "Active editor context" block.Tab,Shift-Tab,Alt-sand clicking a tab all switch it, and narrowing the pane switches to "Red Here All". Press Esc: the header shows only the model and×, and the row under the composer readsAlt-s sessions · Alt-n new · Alt-c clear; clicking "Alt-n new" starts a new conversation.:NeoTree) before or after it: the tree is always at the left edge, with the pane between it and the editor.Targeted tests:
cargo test --test codex_app_server direct_app_server_lists_searches_and_continues_sessions_for_red: the state-DB listing, the workspace filter, originators, title and text search, and the cap.cargo test --lib codex::sessions: labels, peeks, title matching, and compressed rollouts.cargo test --lib bundled_agent_session_browser_cycles_scope_and_continues_in_the_same_panecargo test --lib bundled_agent_plugin_restores_the_bound_codex_thread_and_keeps_input_open: the model header after a picker restore.cargo test --lib temporary_picker_starts_over_at_its_first_row_and_headingcargo test --lib restored_prompts_leave_out_the_recap_and_context_red_sentcargo test --lib picker_tabs_show_the_scope_and_switch_it_by_click_or_shortcutcargo test --lib composer_lists_the_pane_actions_left_out_of_the_headercargo test --lib file_tree_stays_outside_a_conversation_pane_on_the_same_sidecargo test --lib control_u_deletes_to_the_start_of_the_line_in_insert_mode