From b8e59902a72b651efcb3c0debe648b8a8a5bac99 Mon Sep 17 00:00:00 2001 From: Khaliq Date: Fri, 20 Mar 2026 12:32:53 +0100 Subject: [PATCH 1/3] fix: detect Codex boot marker format in PTY startup gate The PTY startup gate only matched Claude's boot message format ("booting mcp server: relaycast") but Codex outputs a different format ("Starting MCP servers (0/2): relay, relaycast"). This caused Codex agents to fall through to the 25s timeout fallback every time. Add find_relaycast_boot_marker() that matches both formats, so Codex agents pass the startup gate immediately when their MCP server loads. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/pty_worker.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/pty_worker.rs b/src/pty_worker.rs index dbdd73a67..5be01e251 100644 --- a/src/pty_worker.rs +++ b/src/pty_worker.rs @@ -29,6 +29,27 @@ const STARTUP_BUFFER_KEEP: usize = 8_000; const PROMPT_WINDOW_BYTES: usize = 800; const RELAYCAST_BOOT_MARKER: &str = "booting mcp server: relaycast"; +/// Detect the relaycast MCP boot marker in output. Different CLIs emit +/// different boot messages: +/// - Claude: "booting mcp server: relaycast" +/// - Codex: "Starting MCP servers (0/2): relay, relaycast" +/// Returns the byte offset of the end of the marker, or None if not found. +fn find_relaycast_boot_marker(lower_output: &str) -> Option { + // Claude-style marker + if let Some(idx) = lower_output.find(RELAYCAST_BOOT_MARKER) { + return Some(idx + RELAYCAST_BOOT_MARKER.len()); + } + // Codex-style marker: "starting mcp server" with "relaycast" nearby + if let Some(idx) = lower_output.find("starting mcp server") { + // Look for "relaycast" within the same line (next ~200 chars) + let search_end = (idx + 200).min(lower_output.len()); + if let Some(rc_idx) = lower_output[idx..search_end].find("relaycast") { + return Some(idx + rc_idx + "relaycast".len()); + } + } + None +} + fn append_bounded(buf: &mut String, text: &str, max: usize, keep: usize) { buf.push_str(text); if buf.len() > max { @@ -408,13 +429,13 @@ pub(crate) async fn run_pty_worker(cmd: PtyCommand) -> Result<()> { let mut just_saw_relaycast_boot = false; if !saw_relaycast_boot { let lower_startup = startup_output.to_ascii_lowercase(); - if let Some(marker_idx) = lower_startup.find(RELAYCAST_BOOT_MARKER) + if let Some(marker_end_offset) = find_relaycast_boot_marker(&lower_startup) { saw_relaycast_boot = true; just_saw_relaycast_boot = true; let marker_end = floor_char_boundary( &startup_output, - marker_idx + RELAYCAST_BOOT_MARKER.len(), + marker_end_offset, ); post_boot_output.clear(); append_bounded( From 8cf338cba9a59321ebe9f3719fca22d8a5f7c302 Mon Sep 17 00:00:00 2001 From: Khaliq Date: Fri, 20 Mar 2026 12:46:47 +0100 Subject: [PATCH 2/3] fix: use floor_char_boundary to prevent panic on non-ASCII PTY output Co-Authored-By: Claude Opus 4.6 (1M context) --- src/pty_worker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pty_worker.rs b/src/pty_worker.rs index 5be01e251..a751e6dd7 100644 --- a/src/pty_worker.rs +++ b/src/pty_worker.rs @@ -42,7 +42,7 @@ fn find_relaycast_boot_marker(lower_output: &str) -> Option { // Codex-style marker: "starting mcp server" with "relaycast" nearby if let Some(idx) = lower_output.find("starting mcp server") { // Look for "relaycast" within the same line (next ~200 chars) - let search_end = (idx + 200).min(lower_output.len()); + let search_end = floor_char_boundary(lower_output, (idx + 200).min(lower_output.len())); if let Some(rc_idx) = lower_output[idx..search_end].find("relaycast") { return Some(idx + rc_idx + "relaycast".len()); } From 5fcaa296295321370ff681c385f1ae552be3c97c Mon Sep 17 00:00:00 2001 From: Khaliq Date: Fri, 20 Mar 2026 13:20:50 +0100 Subject: [PATCH 3/3] fix: resolve clippy doc_lazy_continuation warning in pty_worker Add blank line before "Returns" paragraph in doc comment to satisfy clippy::doc_lazy_continuation lint. Co-Authored-By: Claude Opus 4.6 --- src/pty_worker.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pty_worker.rs b/src/pty_worker.rs index a751e6dd7..fd9eed991 100644 --- a/src/pty_worker.rs +++ b/src/pty_worker.rs @@ -33,6 +33,7 @@ const RELAYCAST_BOOT_MARKER: &str = "booting mcp server: relaycast"; /// different boot messages: /// - Claude: "booting mcp server: relaycast" /// - Codex: "Starting MCP servers (0/2): relay, relaycast" +/// /// Returns the byte offset of the end of the marker, or None if not found. fn find_relaycast_boot_marker(lower_output: &str) -> Option { // Claude-style marker