diff --git a/scripts/testing/ci-retry-list.json b/scripts/testing/ci-retry-list.json index 90b819f61..77bccfc0d 100644 --- a/scripts/testing/ci-retry-list.json +++ b/scripts/testing/ci-retry-list.json @@ -66,7 +66,7 @@ }, { "file": "server/post-to-room.test.ts", - "test": "limits counted per turn on a bearer that outlives the turn > stops a turn at its third room post, and the next turn may post again", + "test": "limits counted per turn on a bearer that outlives the turn > stops a turn at its eighth room post by default, takes the configured cap, and the next turn may post again", "owner": "siddharth", "reason": "Failed once in the 0.2.33 release CI (run 45993068105, ubuntu shard 5 or parallel-threads, a different test each attempt); passes locally on a quiet machine.", "since": "2026-11-27" diff --git a/server/system-proxy.test.ts b/server/system-proxy.test.ts index 86dd4ab1b..37dfdecfa 100644 --- a/server/system-proxy.test.ts +++ b/server/system-proxy.test.ts @@ -106,7 +106,7 @@ describe("installSystemProxy", () => { it("sends the harness's own fetch through the proxy the computer's settings name", async () => { const proxy = await fakeProxy(); const parent = fakeParent(() => `PROXY 127.0.0.1:${proxy.port}; DIRECT`); - installSystemProxy(parent, {}); + await installSystemProxy(parent, {}); const response = await fetch("http://models.example.test/api.json"); expect(await response.text()).toBe("via proxy"); @@ -122,7 +122,7 @@ describe("installSystemProxy", () => { const proxy = await fakeProxy(); const target = await listen((_request, response) => response.end("direct")); const parent = fakeParent((request) => (request.url.includes("bypassed") ? "DIRECT" : `PROXY 127.0.0.1:${proxy.port}`)); - installSystemProxy(parent, {}); + await installSystemProxy(parent, {}); await fetch("http://models.example.test/a").then((response) => response.text()); await fetch("http://models.example.test/b").then((response) => response.text()); @@ -143,7 +143,7 @@ describe("installSystemProxy", () => { const own = await fakeProxy(); const target = await listen((_request, response) => response.end("direct")); const parent = fakeParent(() => `PROXY 127.0.0.1:${system.port}`); - installSystemProxy(parent, { HTTP_PROXY: `http://127.0.0.1:${own.port}` }); + await installSystemProxy(parent, { HTTP_PROXY: `http://127.0.0.1:${own.port}` }); expect(await (await fetch("http://models.example.test/")).text()).toBe("via proxy"); expect(await (await fetch(`http://127.0.0.1:${target.port}/`)).text()).toBe("direct"); diff --git a/server/system-proxy.ts b/server/system-proxy.ts index b3c328c6e..45f5cbe62 100644 --- a/server/system-proxy.ts +++ b/server/system-proxy.ts @@ -1,8 +1,10 @@ import { randomUUID } from "node:crypto"; -import { Agent, EnvHttpProxyAgent, ProxyAgent, Socks5ProxyAgent, setGlobalDispatcher, type Dispatcher } from "undici"; import { isIP } from "node:net"; +import type { Dispatcher } from "undici"; import { addressClass } from "../electron/egress-addresses.mjs"; +type Undici = typeof import("undici"); + /** asked of the desktop main process: `rule` is Chromium's `session.resolveProxy` answer for `url` (PAC syntax, * "PROXY host:port; DIRECT"), so the computer's own proxy settings, PAC script and WPAD apply; null when it has none */ export type ProxyResolveRequest = { type: "duskbot:resolve-proxy"; requestId: string; url: string }; @@ -63,12 +65,14 @@ export const envProxySet = (env: NodeJS.ProcessEnv) => PROXY_ENV.some((name) => * environment wins, otherwise each origin goes where Chromium's resolver says (cached for `ttlMs`). Engines, MCP * servers and the bot box are separate processes and keep their own env. */ -export function systemProxyDispatcher({ resolve, env = process.env, ttlMs = 60_000, now = Date.now }: { +export function systemProxyDispatcher({ resolve, env = process.env, ttlMs = 60_000, now = Date.now, undici }: { resolve: (url: string) => Promise; env?: NodeJS.ProcessEnv; ttlMs?: number; now?: () => number; + undici: Undici; }): Dispatcher { + const { Agent, EnvHttpProxyAgent, ProxyAgent, Socks5ProxyAgent } = undici; const direct = new Agent(); const fromEnv = envProxySet(env) ? new EnvHttpProxyAgent({ httpProxy: env.http_proxy || env.HTTP_PROXY || "", @@ -107,14 +111,15 @@ export function systemProxyDispatcher({ resolve, env = process.env, ttlMs = 60_0 type ParentPort = { on(event: "message", listener: (event: { data?: unknown }) => void): void; postMessage(message: object): void }; -export function installSystemProxy(port: ParentPort, env: NodeJS.ProcessEnv = process.env): void { +export async function installSystemProxy(port: ParentPort, env: NodeJS.ProcessEnv = process.env): Promise { + const undici = await import("undici"); const resolver = createProxyResolver((message) => { try { port.postMessage(message); return true; } catch { return false; } }); port.on("message", ({ data }) => { resolver.receive(data); }); - setGlobalDispatcher(systemProxyDispatcher({ resolve: resolver.resolve, env })); + undici.setGlobalDispatcher(systemProxyDispatcher({ resolve: resolver.resolve, env, undici })); } // Only Electron's utility process supplies parentPort (the desktop app's harness); plain Node leaves it absent. const parentPort = (process as NodeJS.Process & { parentPort?: ParentPort }).parentPort; -if (parentPort) installSystemProxy(parentPort); +if (parentPort) await installSystemProxy(parentPort); diff --git a/src/components/BotSettingsDialog.simple.test.ts b/src/components/BotSettingsDialog.simple.test.ts index 197f6ec42..faf742523 100644 --- a/src/components/BotSettingsDialog.simple.test.ts +++ b/src/components/BotSettingsDialog.simple.test.ts @@ -1041,6 +1041,20 @@ describe("the Where it works page", () => { (warning.props.onConfirm as () => void)(); expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "updateBot", botId: "scout", patch: { computer: "local", acknowledgeLocalAuto: true } }); }); + + it("on Windows offers the bot's own server field even when no default server is set up", () => { + fixture.capabilities = { host: { platform: "win32" } }; + fixture.storeState = { ...fixture.storeState, config: { vps: { configured: false, sshAlias: "" } } }; + try { + const rendered = where(makeBot({ computer: "local" })); + expect(rendered.html).toContain('aria-label="Server (SSH alias)"'); + expect(rendered.html).toContain('placeholder="My-vps"'); + expect(rendered.html).toContain("Type an SSH alias from your SSH config. Only this bot uses it."); + expect(where(makeBot({ vpsAlias: "studio-vps" })).html).toContain('value="studio-vps"'); + } finally { + fixture.capabilities = undefined; + } + }); }); @@ -1058,6 +1072,14 @@ describe("the Where it works sheet", () => { expect(patch).toHaveBeenLastCalledWith({ computer: "vm" }); expect(find(sheet(makeBot({ computer: "vm" })), "data-panel-choice", "vm").props.checked).toBe(true); }); + + it("carries the same per-bot server field on the bot panel's Computer tab", () => { + fixture.storeState = { ...fixture.storeState, config: { vps: { configured: false, sshAlias: "" } } }; + const rendered = sheet(makeBot({ computer: "local", vpsAlias: "studio-vps" })); + expect(rendered.html).toContain('aria-label="Server (SSH alias)"'); + expect(rendered.html).toContain('value="studio-vps"'); + expect(rendered.html).toContain("Type an SSH alias from your SSH config. Only this bot uses it."); + }); }); describe("the drill-in pages", () => { const PAGE = {