Lightweight coding agent that runs in your terminal
Rust
[app-server] add fuzzyFileSearch/sessionCompleted (#11773)
Jeremy Rosee4f8263798dc
diff --git a/codex-rs/app-server-protocol/schema/json/FuzzyFileSearchSessionCompletedNotification.json b/codex-rs/app-server-protocol/schema/json/FuzzyFileSearchSessionCompletedNotification.jsonnew file mode 100644index 0000000000..c8924e77ca--- /dev/null+++ b/codex-rs/app-server-protocol/schema/json/FuzzyFileSearchSessionCompletedNotification.json@@ -0,0 +1,13 @@+{+ "$schema": "http://json-schema.org/draft-07/schema#",+ "properties": {+ "sessionId": {+ "type": "string"+ }+ },+ "required": [+ "sessionId"+ ],+ "title": "FuzzyFileSearchSessionCompletedNotification",+ "type": "object"+}\ No newline at end of filediff --git a/codex-rs/app-server-protocol/schema/json/ServerNotification.json b/codex-rs/app-server-protocol/schema/json/ServerNotification.jsonindex 3277e5650f..c6b84ac5dc 100644--- a/codex-rs/app-server-protocol/schema/json/ServerNotification.json+++ b/codex-rs/app-server-protocol/schema/json/ServerNotification.json@@ -3752,6 +3752,17 @@],"type": "object"},+ "FuzzyFileSearchSessionCompletedNotification": {+ "properties": {+ "sessionId": {+ "type": "string"+ }+ },+ "required": [+ "sessionId"+ ],+ "type": "object"+ },"FuzzyFileSearchSessionUpdatedNotification": {"properties": {"files": {@@ -8290,6 +8301,26 @@"title": "FuzzyFileSearch/sessionUpdatedNotification","type": "object"},+ {+ "properties": {+ "method": {+ "enum": [+ "fuzzyFileSearch/sessionCompleted"+ ],+ "title": "FuzzyFileSearch/sessionCompletedNotificationMethod",+ "type": "string"+ },+ "params": {+ "$ref": "#/definitions/FuzzyFileSearchSessionCompletedNotification"+ }+ },+ "required": [+ "method",+ "params"+ ],+ "title": "FuzzyFileSearch/sessionCompletedNotification",+ "type": "object"+ },{"description": "Notifies the user of world-writable directories on Windows, which cannot be protected by the sandbox.","properties": {diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.jsonindex d808219e40..f2c2ca55d5 100644--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json@@ -5412,6 +5412,19 @@],"type": "object"},+ "FuzzyFileSearchSessionCompletedNotification": {+ "$schema": "http://json-schema.org/draft-07/schema#",+ "properties": {+ "sessionId": {+ "type": "string"+ }+ },+ "required": [+ "sessionId"+ ],+ "title": "FuzzyFileSearchSessionCompletedNotification",+ "type": "object"+ },"FuzzyFileSearchSessionUpdatedNotification": {"$schema": "http://json-schema.org/draft-07/schema#","properties": {@@ -8503,6 +8516,26 @@"title": "FuzzyFileSearch/sessionUpdatedNotification","type": "object"},+ {+ "properties": {+ "method": {+ "enum": [+ "fuzzyFileSearch/sessionCompleted"+ ],+ "title": "FuzzyFileSearch/sessionCompletedNotificationMethod",+ "type": "string"+ },+ "params": {+ "$ref": "#/definitions/FuzzyFileSearchSessionCompletedNotification"+ }+ },+ "required": [+ "method",+ "params"+ ],+ "title": "FuzzyFileSearch/sessionCompletedNotification",+ "type": "object"+ },{"description": "Notifies the user of world-writable directories on Windows, which cannot be protected by the sandbox.","properties": {diff --git a/codex-rs/app-server-protocol/schema/typescript/FuzzyFileSearchSessionCompletedNotification.ts b/codex-rs/app-server-protocol/schema/typescript/FuzzyFileSearchSessionCompletedNotification.tsnew file mode 100644index 0000000000..f4dc7fac11--- /dev/null+++ b/codex-rs/app-server-protocol/schema/typescript/FuzzyFileSearchSessionCompletedNotification.ts@@ -0,0 +1,5 @@+// GENERATED CODE! DO NOT MODIFY BY HAND!++// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.++export type FuzzyFileSearchSessionCompletedNotification = { sessionId: string, };diff --git a/codex-rs/app-server-protocol/schema/typescript/ServerNotification.ts b/codex-rs/app-server-protocol/schema/typescript/ServerNotification.tsindex 0e49c060c0..ffc39598b6 100644--- a/codex-rs/app-server-protocol/schema/typescript/ServerNotification.ts+++ b/codex-rs/app-server-protocol/schema/typescript/ServerNotification.ts@@ -2,6 +2,7 @@// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.import type { AuthStatusChangeNotification } from "./AuthStatusChangeNotification";+import type { FuzzyFileSearchSessionCompletedNotification } from "./FuzzyFileSearchSessionCompletedNotification";import type { FuzzyFileSearchSessionUpdatedNotification } from "./FuzzyFileSearchSessionUpdatedNotification";import type { LoginChatGptCompleteNotification } from "./LoginChatGptCompleteNotification";import type { SessionConfiguredNotification } from "./SessionConfiguredNotification";@@ -38,4 +39,4 @@ import type { WindowsWorldWritableWarningNotification } from "./v2/WindowsWorldW/*** Notification sent from the server to the client.*/-export type ServerNotification = { "method": "error", "params": ErrorNotification } | { "method": "thread/started", "params": ThreadStartedNotification } | { "method": "thread/name/updated", "params": ThreadNameUpdatedNotification } | { "method": "thread/tokenUsage/updated", "params": ThreadTokenUsageUpdatedNotification } | { "method": "turn/started", "params": TurnStartedNotification } | { "method": "turn/completed", "params": TurnCompletedNotification } | { "method": "turn/diff/updated", "params": TurnDiffUpdatedNotification } | { "method": "turn/plan/updated", "params": TurnPlanUpdatedNotification } | { "method": "item/started", "params": ItemStartedNotification } | { "method": "item/completed", "params": ItemCompletedNotification } | { "method": "rawResponseItem/completed", "params": RawResponseItemCompletedNotification } | { "method": "item/agentMessage/delta", "params": AgentMessageDeltaNotification } | { "method": "item/plan/delta", "params": PlanDeltaNotification } | { "method": "item/commandExecution/outputDelta", "params": CommandExecutionOutputDeltaNotification } | { "method": "item/commandExecution/terminalInteraction", "params": TerminalInteractionNotification } | { "method": "item/fileChange/outputDelta", "params": FileChangeOutputDeltaNotification } | { "method": "item/mcpToolCall/progress", "params": McpToolCallProgressNotification } | { "method": "mcpServer/oauthLogin/completed", "params": McpServerOauthLoginCompletedNotification } | { "method": "account/updated", "params": AccountUpdatedNotification } | { "method": "account/rateLimits/updated", "params": AccountRateLimitsUpdatedNotification } | { "method": "app/list/updated", "params": AppListUpdatedNotification } | { "method": "item/reasoning/summaryTextDelta", "params": ReasoningSummaryTextDeltaNotification } | { "method": "item/reasoning/summaryPartAdded", "params": ReasoningSummaryPartAddedNotification } | { "method": "item/reasoning/textDelta", "params": ReasoningTextDeltaNotification } | { "method": "thread/compacted", "params": ContextCompactedNotification } | { "method": "deprecationNotice", "params": DeprecationNoticeNotification } | { "method": "configWarning", "params": ConfigWarningNotification } | { "method": "fuzzyFileSearch/sessionUpdated", "params": FuzzyFileSearchSessionUpdatedNotification } | { "method": "windows/worldWritableWarning", "params": WindowsWorldWritableWarningNotification } | { "method": "account/login/completed", "params": AccountLoginCompletedNotification } | { "method": "authStatusChange", "params": AuthStatusChangeNotification } | { "method": "loginChatGptComplete", "params": LoginChatGptCompleteNotification } | { "method": "sessionConfigured", "params": SessionConfiguredNotification };+export type ServerNotification = { "method": "error", "params": ErrorNotification } | { "method": "thread/started", "params": ThreadStartedNotification } | { "method": "thread/name/updated", "params": ThreadNameUpdatedNotification } | { "method": "thread/tokenUsage/updated", "params": ThreadTokenUsageUpdatedNotification } | { "method": "turn/started", "params": TurnStartedNotification } | { "method": "turn/completed", "params": TurnCompletedNotification } | { "method": "turn/diff/updated", "params": TurnDiffUpdatedNotification } | { "method": "turn/plan/updated", "params": TurnPlanUpdatedNotification } | { "method": "item/started", "params": ItemStartedNotification } | { "method": "item/completed", "params": ItemCompletedNotification } | { "method": "rawResponseItem/completed", "params": RawResponseItemCompletedNotification } | { "method": "item/agentMessage/delta", "params": AgentMessageDeltaNotification } | { "method": "item/plan/delta", "params": PlanDeltaNotification } | { "method": "item/commandExecution/outputDelta", "params": CommandExecutionOutputDeltaNotification } | { "method": "item/commandExecution/terminalInteraction", "params": TerminalInteractionNotification } | { "method": "item/fileChange/outputDelta", "params": FileChangeOutputDeltaNotification } | { "method": "item/mcpToolCall/progress", "params": McpToolCallProgressNotification } | { "method": "mcpServer/oauthLogin/completed", "params": McpServerOauthLoginCompletedNotification } | { "method": "account/updated", "params": AccountUpdatedNotification } | { "method": "account/rateLimits/updated", "params": AccountRateLimitsUpdatedNotification } | { "method": "app/list/updated", "params": AppListUpdatedNotification } | { "method": "item/reasoning/summaryTextDelta", "params": ReasoningSummaryTextDeltaNotification } | { "method": "item/reasoning/summaryPartAdded", "params": ReasoningSummaryPartAddedNotification } | { "method": "item/reasoning/textDelta", "params": ReasoningTextDeltaNotification } | { "method": "thread/compacted", "params": ContextCompactedNotification } | { "method": "deprecationNotice", "params": DeprecationNoticeNotification } | { "method": "configWarning", "params": ConfigWarningNotification } | { "method": "fuzzyFileSearch/sessionUpdated", "params": FuzzyFileSearchSessionUpdatedNotification } | { "method": "fuzzyFileSearch/sessionCompleted", "params": FuzzyFileSearchSessionCompletedNotification } | { "method": "windows/worldWritableWarning", "params": WindowsWorldWritableWarningNotification } | { "method": "account/login/completed", "params": AccountLoginCompletedNotification } | { "method": "authStatusChange", "params": AuthStatusChangeNotification } | { "method": "loginChatGptComplete", "params": LoginChatGptCompleteNotification } | { "method": "sessionConfigured", "params": SessionConfiguredNotification };diff --git a/codex-rs/app-server-protocol/schema/typescript/index.ts b/codex-rs/app-server-protocol/schema/typescript/index.tsindex 2e7446a3db..ef17362ffd 100644--- a/codex-rs/app-server-protocol/schema/typescript/index.ts+++ b/codex-rs/app-server-protocol/schema/typescript/index.ts@@ -78,6 +78,7 @@ export type { FunctionCallOutputPayload } from "./FunctionCallOutputPayload";export type { FuzzyFileSearchParams } from "./FuzzyFileSearchParams";export type { FuzzyFileSearchResponse } from "./FuzzyFileSearchResponse";export type { FuzzyFileSearchResult } from "./FuzzyFileSearchResult";+export type { FuzzyFileSearchSessionCompletedNotification } from "./FuzzyFileSearchSessionCompletedNotification";export type { FuzzyFileSearchSessionUpdatedNotification } from "./FuzzyFileSearchSessionUpdatedNotification";export type { GetAuthStatusParams } from "./GetAuthStatusParams";export type { GetAuthStatusResponse } from "./GetAuthStatusResponse";diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rsindex bc91341166..af56408c8f 100644--- a/codex-rs/app-server-protocol/src/protocol/common.rs+++ b/codex-rs/app-server-protocol/src/protocol/common.rs@@ -758,6 +758,13 @@ pub struct FuzzyFileSearchSessionUpdatedNotification {pub files: Vec<FuzzyFileSearchResult>,}+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]+#[serde(rename_all = "camelCase")]+#[ts(rename_all = "camelCase")]+pub struct FuzzyFileSearchSessionCompletedNotification {+ pub session_id: String,+}+server_notification_definitions! {/// NEW NOTIFICATIONSError => "error" (v2::ErrorNotification),@@ -791,6 +798,7 @@ server_notification_definitions! {DeprecationNotice => "deprecationNotice" (v2::DeprecationNoticeNotification),ConfigWarning => "configWarning" (v2::ConfigWarningNotification),FuzzyFileSearchSessionUpdated => "fuzzyFileSearch/sessionUpdated" (FuzzyFileSearchSessionUpdatedNotification),+ FuzzyFileSearchSessionCompleted => "fuzzyFileSearch/sessionCompleted" (FuzzyFileSearchSessionCompletedNotification),/// Notifies the user of world-writable directories on Windows, which cannot be protected by the sandbox.WindowsWorldWritableWarning => "windows/worldWritableWarning" (v2::WindowsWorldWritableWarningNotification),diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.mdindex 39ddc73c65..2805c65030 100644--- a/codex-rs/app-server/README.md+++ b/codex-rs/app-server/README.md@@ -535,6 +535,13 @@ Examples:- Opt out of legacy session setup event: `codex/event/session_configured`- Opt out of streamed agent text deltas: `item/agentMessage/delta`+### Fuzzy file search events (experimental)++The fuzzy file search session API emits per-query notifications:++- `fuzzyFileSearch/sessionUpdated` — `{ sessionId, query, files }` with the current matching files for the active query.+- `fuzzyFileSearch/sessionCompleted` — `{ sessionId, query }` once indexing/matching for that query has completed.+### Turn eventsThe app-server streams JSON-RPC notifications while a turn is running. Each turn starts with `turn/started` (initial `turn`) and ends with `turn/completed` (final `turn` status). Token usage events stream separately via `thread/tokenUsage/updated`. Clients subscribe to the events they care about, rendering each item incrementally as updates arrive. The per-item lifecycle is always: `item/started` → zero or more item-specific deltas → `item/completed`.diff --git a/codex-rs/app-server/src/fuzzy_file_search.rs b/codex-rs/app-server/src/fuzzy_file_search.rsindex cb1f61c362..d40d3fc242 100644--- a/codex-rs/app-server/src/fuzzy_file_search.rs+++ b/codex-rs/app-server/src/fuzzy_file_search.rs@@ -6,6 +6,7 @@ use std::sync::atomic::AtomicBool;use std::sync::atomic::Ordering;use codex_app_server_protocol::FuzzyFileSearchResult;+use codex_app_server_protocol::FuzzyFileSearchSessionCompletedNotification;use codex_app_server_protocol::FuzzyFileSearchSessionUpdatedNotification;use codex_app_server_protocol::ServerNotification;use codex_file_search as file_search;@@ -195,6 +196,20 @@ impl SessionReporterImpl {outgoing.send_server_notification(notification).await;});}++ fn send_complete(&self) {+ if self.shared.canceled.load(Ordering::Relaxed) {+ return;+ }+ let session_id = self.shared.session_id.clone();+ let outgoing = self.shared.outgoing.clone();+ self.shared.runtime.spawn(async move {+ let notification = ServerNotification::FuzzyFileSearchSessionCompleted(+ FuzzyFileSearchSessionCompletedNotification { session_id },+ );+ outgoing.send_server_notification(notification).await;+ });+ }}impl file_search::SessionReporter for SessionReporterImpl {@@ -202,7 +217,9 @@ impl file_search::SessionReporter for SessionReporterImpl {self.send_snapshot(snapshot);}- fn on_complete(&self) {}+ fn on_complete(&self) {+ self.send_complete();+ }}fn collect_files(snapshot: &file_search::FileSearchSnapshot) -> Vec<FuzzyFileSearchResult> {diff --git a/codex-rs/app-server/tests/suite/fuzzy_file_search.rs b/codex-rs/app-server/tests/suite/fuzzy_file_search.rsindex ffa4fa2cca..b6932560f0 100644--- a/codex-rs/app-server/tests/suite/fuzzy_file_search.rs+++ b/codex-rs/app-server/tests/suite/fuzzy_file_search.rs@@ -1,6 +1,7 @@use anyhow::Result;use anyhow::anyhow;use app_test_support::McpProcess;+use codex_app_server_protocol::FuzzyFileSearchSessionCompletedNotification;use codex_app_server_protocol::FuzzyFileSearchSessionUpdatedNotification;use codex_app_server_protocol::JSONRPCResponse;use codex_app_server_protocol::RequestId;@@ -13,6 +14,7 @@ const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secsconst SHORT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_millis(500);const STOP_GRACE_PERIOD: std::time::Duration = std::time::Duration::from_millis(250);const SESSION_UPDATED_METHOD: &str = "fuzzyFileSearch/sessionUpdated";+const SESSION_COMPLETED_METHOD: &str = "fuzzyFileSearch/sessionCompleted";#[derive(Clone, Copy, Debug, PartialEq, Eq)]enum FileExpectation {@@ -60,6 +62,29 @@ async fn wait_for_session_updated();}+async fn wait_for_session_completed(+ mcp: &mut McpProcess,+ session_id: &str,+) -> Result<FuzzyFileSearchSessionCompletedNotification> {+ for _ in 0..20 {+ let notification = timeout(+ DEFAULT_READ_TIMEOUT,+ mcp.read_stream_until_notification_message(SESSION_COMPLETED_METHOD),+ )+ .await??;+ let params = notification+ .params+ .ok_or_else(|| anyhow!("missing notification params"))?;+ let payload =+ serde_json::from_value::<FuzzyFileSearchSessionCompletedNotification>(params)?;+ if payload.session_id == session_id {+ return Ok(payload);+ }+ }++ anyhow::bail!("did not receive expected session completion for sessionId={session_id}");+}+async fn assert_update_request_fails_for_missing_session(mcp: &mut McpProcess,session_id: &str,@@ -271,12 +296,41 @@ async fn test_fuzzy_file_search_session_streams_updates() -> Result<()> {assert_eq!(payload.files.len(), 1);assert_eq!(payload.files[0].root, root_path);assert_eq!(payload.files[0].path, "alpha.txt");+ let completed = wait_for_session_completed(&mut mcp, session_id).await?;+ assert_eq!(completed.session_id, session_id);mcp.stop_fuzzy_file_search_session(session_id).await?;Ok(())}+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]+async fn test_fuzzy_file_search_session_no_updates_after_complete_until_query_edited() -> Result<()>+{+ let codex_home = TempDir::new()?;+ let root = TempDir::new()?;+ std::fs::write(root.path().join("alpha.txt"), "contents")?;+ let mut mcp = initialized_mcp(&codex_home).await?;++ let root_path = root.path().to_string_lossy().to_string();+ let session_id = "session-complete-invariant";+ mcp.start_fuzzy_file_search_session(session_id, vec![root_path])+ .await?;++ mcp.update_fuzzy_file_search_session(session_id, "alp")+ .await?;+ wait_for_session_updated(&mut mcp, session_id, "alp", FileExpectation::NonEmpty).await?;+ wait_for_session_completed(&mut mcp, session_id).await?;+ assert_no_session_updates_for(&mut mcp, session_id, STOP_GRACE_PERIOD, SHORT_READ_TIMEOUT)+ .await?;++ mcp.update_fuzzy_file_search_session(session_id, "alpha")+ .await?;+ wait_for_session_updated(&mut mcp, session_id, "alpha", FileExpectation::NonEmpty).await?;++ Ok(())+}+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]async fn test_fuzzy_file_search_session_update_before_start_errors() -> Result<()> {let codex_home = TempDir::new()?;@@ -345,6 +399,7 @@ async fn test_fuzzy_file_search_session_multiple_query_updates_work() -> Result<alp_payload.files.iter().all(|file| file.root == root_path),true);+ wait_for_session_completed(&mut mcp, session_id).await?;mcp.update_fuzzy_file_search_session(session_id, "zzzz").await?;@@ -352,6 +407,7 @@ async fn test_fuzzy_file_search_session_multiple_query_updates_work() -> Result<wait_for_session_updated(&mut mcp, session_id, "zzzz", FileExpectation::Any).await?;assert_eq!(zzzz_payload.query, "zzzz");assert_eq!(zzzz_payload.files.is_empty(), true);+ wait_for_session_completed(&mut mcp, session_id).await?;Ok(())}