History

fix(provider): preserve IPv6 display targets

Julius Marminge committed 4 months ago

Commit 65249641 parent 65ff0462 files · +19 −2Browse files

Unified · Split

2 files
  1. apps/server/src/provider/Layers/OpenCodeProvider.test.ts +18 −0
  2. apps/server/src/provider/Layers/OpenCodeProvider.ts +1 −2
apps/server/src/provider/Layers/OpenCodeProvider.test.ts+18−0
@@ -250,4 +250,22 @@ it.layer(testLayer)("checkOpenCodeProviderStatus with configured server URL", (i · 249 unmodified lines
250250 );
251251 }),
252252 );
253+
254+ it.effect("keeps IPv6 brackets in configured server diagnostics", () =>
255+ Effect.gen(function* () {
256+ runtimeMock.state.inventoryError = new Error("fetch failed: connect ECONNREFUSED ::1:9999");
257+ const snapshot = yield* checkOpenCodeProviderStatus(
258+ makeOpenCodeSettings({
259+ serverUrl: "http://[::1]:9999/private",
260+ serverPassword: "secret-password",
261+ }),
262+ process.cwd(),
263+ );
264+
265+ NodeAssert.equal(
266+ snapshot.message,
267+ "Couldn't reach the configured OpenCode server at http://[::1]:9999. Check that the server is running and the URL is correct.",
268+ );
269+ }),
270+ );
253271 });
apps/server/src/provider/Layers/OpenCodeProvider.ts+1−2
@@ -62,8 +62,7 @@ function normalizedErrorMessage(cause: unknown): string | undefined { · 61 unmodified lines
6262 function openCodeServerDisplayTarget(input: string): string | undefined {
6363 try {
6464 const url = new URL(input);
65− const port = url.port === "" ? "" : `:${url.port}`;
66− return `${url.protocol}//${url.hostname}${port}`;
65+ return `${url.protocol}//${url.host}`;
6766 } catch {
6867 return undefined;
6968 }