Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(settings): say a saved browser proxy is saved instead of showing an empty field (#7766)

Ooi Pin June6eca8ac14b1
diff --git a/server/routes/config-browser-proxy.test.ts b/server/routes/config-browser-proxy.test.ts
index 20f9737402..836d03a3e1 100644
--- a/server/routes/config-browser-proxy.test.ts
+++ b/server/routes/config-browser-proxy.test.ts
@@ -1,8 +1,14 @@
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+
import { describe, expect, it } from "vitest";
+import { launchVerificationServer } from "../../scripts/control-omb.ts";
import type { RequestAuth } from "../request-auth.ts";
import { createConfigRoutes, type ConfigRouteDeps } from "./config.ts";
+const PROXY = "socks5://127.0.0.1:1080";
+
describe("Team Cloud browser proxy configuration", () => {
it("refuses an admin's proxy change before writing shared config", async () => {
const replies: Array<{ status: number; body: unknown }> = [];
@@ -23,3 +29,38 @@ describe("Team Cloud browser proxy configuration", () => {
expect(replies).toEqual([{ status: 403, body: { error: "Only the Team Cloud owner can configure the browser proxy." } }]);
});
});
+
+describe("local desktop browser proxy configuration", () => {
+ it("saves a socks5 address, reports that it is saved, and does not echo the address", async () => {
+ const fixture = await launchVerificationServer();
+ const api = async (method: "GET" | "PATCH", body?: unknown) => {
+ const response = await fetch(`${fixture.info.url}/api/config`, {
+ method,
+ headers: { "content-type": "application/json", origin: fixture.info.url },
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
+ });
+ const data: unknown = await response.json();
+ return { status: response.status, data };
+ };
+ try {
+ const before = await api("GET");
+ expect(before.status).toBe(200);
+ expect((before.data as { browserEngine?: { proxySaved?: boolean } }).browserEngine?.proxySaved).not.toBe(true);
+
+ const saved = await api("PATCH", { browserEngine: { egress: { proxy: PROXY } } });
+ expect(saved.status).toBe(200);
+
+ const read = await api("GET");
+ expect(read.status).toBe(200);
+ expect((read.data as { browserEngine?: { proxySaved?: boolean } }).browserEngine?.proxySaved).toBe(true);
+ expect(JSON.stringify(read.data)).not.toContain(PROXY);
+
+ const disk = JSON.parse(readFileSync(join(fixture.info.dataDir, "config.json"), "utf8")) as {
+ browserEngine?: { egress?: { proxy?: string } };
+ };
+ expect(disk.browserEngine?.egress?.proxy).toBe(PROXY);
+ } finally {
+ await fixture.close();
+ }
+ }, 60_000);
+});
diff --git a/src/components/BrowserSettingsRows.test.ts b/src/components/BrowserSettingsRows.test.ts
index d0d5a31ee0..185ff2e7cb 100644
--- a/src/components/BrowserSettingsRows.test.ts
+++ b/src/components/BrowserSettingsRows.test.ts
@@ -141,6 +141,28 @@ describe("Built-in browser proxy setting", () => {
expect(fixture.dispatch.mock.calls[0]![0].config.browserEngine.proxyConfigured).toBe(true);
});
+ it("keeps a reopened saved proxy empty and says it is saved", async () => {
+ const saved = { features: { browser: true }, browserEngine: { kind: "engine", proxySaved: true, proxyConfigured: true } };
+ fixture.config = { features: { browser: true }, browserEngine: { kind: "engine", proxyConfigured: false } };
+ fixture.api.mockResolvedValue(saved);
+ show();
+ const input = host.querySelector<HTMLInputElement>('input[aria-label="SOCKS5 proxy"]')!;
+ expect(input.placeholder).toBe("socks5://127.0.0.1:1080");
+ flushSync(() => {
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(input, "socks5://127.0.0.1:1080");
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+ });
+ flushSync(() => [...host.querySelectorAll<HTMLButtonElement>("button")].find((button) => button.textContent === "Save")?.click());
+ await vi.waitFor(() => expect(fixture.dispatch).toHaveBeenCalledWith({ type: "configStatus", config: saved }));
+ flushSync(() => root.unmount());
+ root = createRoot(host);
+ show();
+ const again = host.querySelector<HTMLInputElement>('input[aria-label="SOCKS5 proxy"]')!;
+ expect(again.value).toBe("");
+ expect(again.placeholder).toBe("Proxy saved. Enter a new address to replace it.");
+ expect([...host.querySelectorAll("button")].some((button) => button.textContent === "Remove")).toBe(true);
+ });
+
it("hides the shared proxy control from Team Cloud admins who are not the owner", () => {
owner.value = true;
fixture.config = { team: { id: "team", name: "Team" }, features: { browser: true }, browserEngine: { kind: "engine", proxyEditable: false } };
diff --git a/src/components/BrowserSettingsRows.tsx b/src/components/BrowserSettingsRows.tsx
index 6ca7dd3ee9..8ed0d8c13a 100644
--- a/src/components/BrowserSettingsRows.tsx
+++ b/src/components/BrowserSettingsRows.tsx
@@ -118,7 +118,7 @@ export function BrowserProxyRow() {
aria-label={t("settings.browser.proxy")}
autoComplete="off"
spellCheck={false}
- placeholder="socks5://127.0.0.1:1080"
+ placeholder={saved ? t("settings.browser.proxySavedPlaceholder") : "socks5://127.0.0.1:1080"}
value={endpoint}
onChange={(event) => setEndpoint(event.target.value)}
className="min-w-0 flex-1 rounded-lg border border-control bg-app px-3 py-2 text-[13px] text-ink sm:w-64 sm:flex-none"
diff --git a/src/locales/en.json b/src/locales/en.json
index e94b846413..460e0396ea 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -11627,6 +11627,7 @@
"settings.browser.proxyInactive": "Saved, but active only with the built-in browser on supported hosts.",
"settings.browser.proxySave": "Save",
"settings.browser.proxyClear": "Remove",
+ "settings.browser.proxySavedPlaceholder": "Proxy saved. Enter a new address to replace it.",
"together.onCloud": "On My Cloud",
"together.onComputer": "On this computer",
"together.state.asleep": "My Cloud is asleep. Open a bot to wake it.",