mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Report workspace kind on TUI composer turns (#63545)
## Why A TUI composer prompt does not supply `workspace_kind`. The app server can derive it from the thread's current project assignment. ## What changed Use the staged assignment until the thread is saved, then read the persisted assignment on each new composer turn. Use `project` or `projectless` as a fallback for model request metadata and turn analytics. Explicit client metadata takes precedence, and the inferred value stays with the originating turn. ## Testing Cover the model request header and analytics event on the first turn, on a follow-up, and after removing the project assignment. Unit tests cover explicit metadata precedence and verify that MCP requests, extensions, and child agents do not inherit the inferred value. GitOrigin-RevId: 62b88484dd4028a6b72584999e0fa9b84e6e3b03
This commit is contained in:
committed by
copyberry
parent
a90526e8a7
commit
baf9b39b16
@@ -473,6 +473,24 @@ impl TurnRequestProcessor {
|
||||
Ok((thread_id, thread))
|
||||
}
|
||||
|
||||
async fn thread_workspace_kind(&self, thread: &CodexThread) -> Option<String> {
|
||||
let db = thread.state_db()?;
|
||||
let thread_id = thread.startup_metadata().thread_id;
|
||||
// Saving a new thread consumes its staged assignment, so read staging first.
|
||||
let staged_project_id = self
|
||||
.thread_manager
|
||||
.thread_store()
|
||||
.read_pending_thread_metadata(thread_id)
|
||||
.await
|
||||
.ok()?
|
||||
.and_then(|patch| patch.project_id.flatten());
|
||||
let assigned = db
|
||||
.thread_has_project(thread_id, staged_project_id.as_deref())
|
||||
.await
|
||||
.ok()?;
|
||||
Some(if assigned { "project" } else { "projectless" }.to_owned())
|
||||
}
|
||||
|
||||
async fn ensure_direct_input_allowed(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
@@ -647,6 +665,14 @@ impl TurnRequestProcessor {
|
||||
.inspect_err(|error| {
|
||||
self.track_error_response(&request_id, error, /*error_type*/ None);
|
||||
})?;
|
||||
// TUI composer prompts carry a client message ID. Helper requests omit it.
|
||||
let inferred_workspace_kind = if app_server_client_name.as_deref() == Some("codex-tui")
|
||||
&& params.client_user_message_id.is_some()
|
||||
{
|
||||
self.thread_workspace_kind(&thread).await
|
||||
} else {
|
||||
None
|
||||
};
|
||||
Self::set_app_server_client_info(
|
||||
thread.as_ref(),
|
||||
app_server_client_name,
|
||||
@@ -729,6 +755,7 @@ impl TurnRequestProcessor {
|
||||
TurnInputRequest::new(input)
|
||||
.with_thread_settings(thread_settings)
|
||||
.on_start(TurnStartOptions {
|
||||
inferred_workspace_kind,
|
||||
turn_trigger: params.turn_trigger,
|
||||
parent_turn_id: params.parent_turn_id,
|
||||
root_turn_id: params.root_turn_id,
|
||||
|
||||
Reference in New Issue
Block a user