Expose thread originators through the app-server API (#42458)

## What changed

- Add the creation-time `originator` to app-server thread responses and `thread/started` notifications.
- Persist originators in thread metadata and preserve the first recorded value across list, read, resume, rollout, and SQLite paths.
- Add an `originators` allowlist to `thread/list` for hosted backends. The local app-server accepts omitted or empty values but rejects nonempty filters.

## Testing

- Cover originator persistence across server restarts and list, read, and resume requests.
- Verify local `thread/list` handling for nonempty, omitted, null, and empty originator filters.
- Heap-allocate large TUI dispatcher futures in affected tests to keep them within the Windows test-thread stack.

GitOrigin-RevId: 73ad6e61b8fdd2d93a22d1f971723a19ec7be3fc
This commit is contained in:
Can Sar authored and copyberry committed 2026-09-03 06:02:25 +00:00
1 parent 8ff74cc9b1
commit 728cb12fe5
75 files changed
+511 -12

No files matched your search

@@ -3128,6 +3128,7 @@ mod tests {
request_id: RequestId::Integer(7),
response: v2::ThreadStartResponse {
thread: v2::Thread {
originator: None,
environments: None,
id: "67e55044-10b1-426f-9247-bb680e5fe0c8".to_string(),
extra: None,
@@ -3210,6 +3211,7 @@ mod tests {
"path": null,
"cwd": absolute_path_string("tmp"),
"cliVersion": "0.0.0",
"originator": null,
"source": "exec",
"canAcceptDirectInput": null,
"threadSource": null,
@@ -272,6 +272,7 @@ fn thread_resume_params_accept_turns_page_bootstrap() {
fn thread_resume_response_round_trips_initial_turns_page() {
let response = ThreadResumeResponse {
thread: Thread {
originator: Some("future_client".to_string()),
environments: Some(vec![ThreadEnvironment {
environment_id: "remote".to_string(),
cwd: LegacyAppPathString::from_string(r"C:\workspace"),
@@ -335,6 +336,7 @@ fn thread_resume_response_round_trips_initial_turns_page() {
};
let value = serde_json::to_value(&response).expect("serialize thread resume response");
assert_eq!(value["thread"]["originator"], json!("future_client"));
assert_eq!(
value["thread"]["environments"],
json!([{
@@ -359,12 +361,14 @@ fn thread_resume_response_round_trips_initial_turns_page() {
legacy_thread_fields.remove("sectionEnteredAt");
legacy_thread_fields.remove("projectId");
legacy_thread_fields.remove("environments");
legacy_thread_fields.remove("originator");
let legacy_thread =
serde_json::from_value::<Thread>(legacy_thread).expect("deserialize legacy thread");
assert_eq!(legacy_thread.section, None);
assert_eq!(legacy_thread.section_entered_at, None);
assert_eq!(legacy_thread.project_id, None);
assert_eq!(legacy_thread.environments, None);
assert_eq!(legacy_thread.originator, None);
assert_eq!(
value.get("initialTurnsPage"),
@@ -1386,6 +1386,11 @@ pub struct ThreadListParams {
/// are returned. When omitted or empty, defaults to interactive sources.
#[ts(optional = nullable)]
pub source_kinds: Option<Vec<ThreadSourceKind>>,
/// Optional originator allowlist, matching any supplied value exactly.
/// Supported by hosted backends only; the local app-server rejects a nonempty list.
/// Omitted or empty lists leave originators unrestricted.
#[ts(optional = nullable)]
pub originators: Option<Vec<String>>,
/// Optional archived filter; when set to true, only archived threads are returned.
/// If false or null, only non-archived threads are returned.
#[ts(optional = nullable)]
@@ -264,6 +264,9 @@ pub struct Thread {
pub cwd: AbsolutePathBuf,
/// Version of the CLI that created the thread.
pub cli_version: String,
/// Originator recorded when the thread was created, independent of its current client or executor.
/// Null when the recorded originator is unavailable.
pub originator: Option<String>,
/// Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).
pub source: SessionSource,
/// Whether the app server accepts direct turn input for this loaded thread.
@@ -319,6 +322,7 @@ struct ThreadCompatibility {
path: Option<PathBuf>,
cwd: AbsolutePathBuf,
cli_version: String,
originator: Option<String>,
source: SessionSource,
can_accept_direct_input: Option<bool>,
thread_source: Option<ThreadSource>,
@@ -358,6 +362,7 @@ impl<'de> Deserialize<'de> for Thread {
path: thread.path,
cwd: thread.cwd,
cli_version: thread.cli_version,
originator: thread.originator,
source: thread.source,
can_accept_direct_input: thread.can_accept_direct_input,
thread_source: thread.thread_source,