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
@@ -3,6 +3,7 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use codex_protocol::ThreadId;
|
||||
use sqlx::QueryBuilder;
|
||||
use sqlx::Row;
|
||||
use sqlx::Sqlite;
|
||||
@@ -23,6 +24,24 @@ const PROJECT_SELECT: &str = "SELECT projects.*,
|
||||
FROM projects";
|
||||
|
||||
impl StateRuntime {
|
||||
/// Use the staged project only until the thread has a row in SQLite.
|
||||
pub async fn thread_has_project(
|
||||
&self,
|
||||
thread_id: ThreadId,
|
||||
staged_project_id: Option<&str>,
|
||||
) -> anyhow::Result<bool> {
|
||||
Ok(sqlx::query_scalar(
|
||||
"SELECT COALESCE(
|
||||
(SELECT project_id IS NOT NULL FROM threads WHERE id = ?),
|
||||
EXISTS (SELECT 1 FROM projects WHERE id = ?)
|
||||
)",
|
||||
)
|
||||
.bind(thread_id.to_string())
|
||||
.bind(staged_project_id)
|
||||
.fetch_one(self.pool.as_ref())
|
||||
.await?)
|
||||
}
|
||||
|
||||
pub async fn set_thread_project(
|
||||
&self,
|
||||
thread_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user