@devries-cameron20 / t3code Mirror · read-only / commits / 5fa95d99af
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 14:45 UTC

fix(opencode): wait for the whole listening line before reading the server address (#28348)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Victor committed Nov 14, 2026 at 06:53 UTC 5fa95d99af98f2f9928186acc409b583742d3df5
2 files changed +13 -2
packages/provider-opencode/src/server/OpenCodeRuntime.cliParsers.test.ts
+10
@@ -4,6 +4,16 @@ import { describe, it } from "vite-plus/test";
4
5 import * as OpenCodeRuntime from "./OpenCodeRuntime.ts";
6
7 +describe("parseServerUrlFromOutput", () => {
8 + it.each([
9 + ["opencode server listening on http://127.0.0.1:4096", null],
10 + ["opencode server listening on http://127.0.0.1:40961\n", "http://127.0.0.1:40961"],
11 + ["opencode server listening on http://127.0.0.1:40961\r\n", "http://127.0.0.1:40961"],
12 + ])("reads only a newline-terminated ready line: %j", (output, expected) => {
13 + NodeAssert.equal(OpenCodeRuntime.parseServerUrlFromOutput(output), expected);
14 + });
15 +});
16 +
17 describe("toOpenCodeFileParts", () => {
18 const attachment = (mimeType: string, sizeBytes = 12) => ({
19 type: "file" as const,
packages/provider-opencode/src/server/OpenCodeRuntime.ts
+3 -2
@@ -368,8 +368,9 @@ export class OpenCodeRuntime extends Context.Service<
368 }
369 >()("@t3tools/provider-opencode/server/OpenCodeRuntime") {}
370
371 -function parseServerUrlFromOutput(output: string): string | null {
372 - for (const line of output.split("\n")) {
371 +export function parseServerUrlFromOutput(output: string): string | null {
372 + // The last element is an unfinished line; a chunk can end mid-URL.
373 + for (const line of output.split("\n").slice(0, -1)) {
374 const match = line.match(/server listening on\s+(https?:\/\/[^\s]+)/i);
375 if (match?.[1]) return match[1];
376 }