From 7dcf19d9028c27fdfb96fe0788c229908a416e01 Mon Sep 17 00:00:00 2001 From: Benjamin Jesuiter Date: Fri, 9 Jan 2026 12:21:13 +0100 Subject: [PATCH 1/8] fix(ui): default to relative paths for control UI assets Changes the default base path from "/" to "./" so the control UI works correctly when served under a custom basePath (e.g., /jbclawd/). Previously, assets were referenced with absolute paths like /assets/..., which failed when the UI was served under a subpath. With relative paths (./assets/...), the browser resolves them relative to the HTML location, making the UI work regardless of the configured basePath. --- ui/vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/vite.config.ts b/ui/vite.config.ts index 30dbd25a3..c347c2b0e 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -14,7 +14,7 @@ function normalizeBase(input: string): string { export default defineConfig(({ command }) => { const envBase = process.env.CLAWDBOT_CONTROL_UI_BASE_PATH?.trim(); - const base = envBase ? normalizeBase(envBase) : "/"; + const base = envBase ? normalizeBase(envBase) : "./"; return { base, publicDir: path.resolve(here, "public"), From 92b792b3f034cf8a01ee48d3290773402189a165 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 15:05:47 +0100 Subject: [PATCH 2/8] fix: land #569 (thanks @bjesuiter) --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 1 + scripts/ci-sanitize-output.mjs | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 scripts/ci-sanitize-output.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1922b98e5..c3057a34b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: command: pnpm lint - runtime: node task: test - command: pnpm test + command: node scripts/ci-sanitize-output.mjs pnpm test - runtime: node task: build command: pnpm build diff --git a/CHANGELOG.md b/CHANGELOG.md index 46037f224..55eef4a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - WhatsApp: group `/model list` output by provider for scannability. (#456) - thanks @mcinteerj - Hooks: allow per-hook model overrides for webhook/Gmail runs (e.g. GPT 5 Mini). - Control UI: logs tab opens at the newest entries (bottom). +- Control UI: default to relative paths for control UI assets. (#569) — thanks @bjesuiter - Control UI: add Docs link, remove chat composer divider, and add New session button. - Control UI: link sessions list to chat view. (#471) — thanks @HazAT - Control UI: show/patch per-session reasoning level and render extracted reasoning in chat. diff --git a/scripts/ci-sanitize-output.mjs b/scripts/ci-sanitize-output.mjs new file mode 100644 index 000000000..9c9b12012 --- /dev/null +++ b/scripts/ci-sanitize-output.mjs @@ -0,0 +1,37 @@ +import { spawn } from "node:child_process"; + +function sanitizeBuffer(input) { + const out = Buffer.allocUnsafe(input.length); + for (let i = 0; i < input.length; i++) { + const b = input[i]; + // Keep: tab/newline/carriage return + printable ASCII; replace everything else. + out[i] = b === 9 || b === 10 || b === 13 || (b >= 32 && b <= 126) ? b : 63; + } + return out; +} + +const [command, ...args] = process.argv.slice(2); +if (!command) { + process.stderr.write( + "Usage: node scripts/ci-sanitize-output.mjs [args...]\n", + ); + process.exit(2); +} + +const child = spawn(command, args, { + stdio: ["ignore", "pipe", "pipe"], + shell: process.platform === "win32", +}); + +child.stdout.on("data", (chunk) => { + process.stdout.write(sanitizeBuffer(Buffer.from(chunk))); +}); + +child.stderr.on("data", (chunk) => { + process.stderr.write(sanitizeBuffer(Buffer.from(chunk))); +}); + +child.on("exit", (code, signal) => { + if (signal) process.exit(1); + process.exit(code ?? 1); +}); From 59d942c9ec197bab57cfdba1ba9f476653d573dd Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 15:20:03 +0100 Subject: [PATCH 3/8] fix: unblock CI on main (#569) (thanks @bjesuiter) --- src/agents/auth-profiles.ts | 4 +- src/auto-reply/reply.ts | 1 + src/auto-reply/reply/directive-handling.ts | 50 +++++++++++++++------- src/cli/models-cli.ts | 8 +++- src/commands/models/auth-order.ts | 43 +++++++++++++------ 5 files changed, 73 insertions(+), 33 deletions(-) diff --git a/src/agents/auth-profiles.ts b/src/agents/auth-profiles.ts index c2ac71824..037ca0d29 100644 --- a/src/agents/auth-profiles.ts +++ b/src/agents/auth-profiles.ts @@ -718,9 +718,7 @@ export async function setAuthProfileOrder(params: { const providerKey = normalizeProviderId(params.provider); const sanitized = params.order && Array.isArray(params.order) - ? params.order - .map((entry) => String(entry).trim()) - .filter(Boolean) + ? params.order.map((entry) => String(entry).trim()).filter(Boolean) : []; const deduped: string[] = []; diff --git a/src/auto-reply/reply.ts b/src/auto-reply/reply.ts index b787c0faa..fd44cca22 100644 --- a/src/auto-reply/reply.ts +++ b/src/auto-reply/reply.ts @@ -582,6 +582,7 @@ export async function getReplyFromConfig( directives, effectiveModelDirective, cfg, + agentDir, sessionEntry, sessionStore, sessionKey, diff --git a/src/auto-reply/reply/directive-handling.ts b/src/auto-reply/reply/directive-handling.ts index ce5248966..406329b85 100644 --- a/src/auto-reply/reply/directive-handling.ts +++ b/src/auto-reply/reply/directive-handling.ts @@ -88,7 +88,9 @@ const resolveAuthLabel = async ( mode: ModelAuthDetailMode = "compact", ): Promise<{ label: string; source: string }> => { const formatPath = (value: string) => shortenHomePath(value); - const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }); + const store = ensureAuthProfileStore(agentDir, { + allowKeychainPrompt: false, + }); const order = resolveAuthProfileOrder({ cfg, store, provider }); const providerKey = normalizeProviderId(provider); const lastGood = (() => { @@ -121,7 +123,8 @@ const resolveAuthLabel = async ( const configProfile = cfg.auth?.profiles?.[profileId]; const missing = !profile || - (configProfile?.provider && configProfile.provider !== profile.provider) || + (configProfile?.provider && + configProfile.provider !== profile.provider) || (configProfile?.mode && configProfile.mode !== profile.type && !(configProfile.mode === "oauth" && profile.type === "token")); @@ -170,7 +173,11 @@ const resolveAuthLabel = async ( if (lastGood && profileId === lastGood) flags.push("lastGood"); if (isProfileInCooldown(store, profileId)) { const until = store.usageStats?.[profileId]?.cooldownUntil; - if (typeof until === "number" && Number.isFinite(until) && until > now) { + if ( + typeof until === "number" && + Number.isFinite(until) && + until > now + ) { flags.push(`cooldown ${formatUntil(until)}`); } else { flags.push("cooldown"); @@ -197,7 +204,11 @@ const resolveAuthLabel = async ( Number.isFinite(profile.expires) && profile.expires > 0 ) { - flags.push(profile.expires <= now ? "expired" : `exp ${formatUntil(profile.expires)}`); + flags.push( + profile.expires <= now + ? "expired" + : `exp ${formatUntil(profile.expires)}`, + ); } const suffix = flags.length > 0 ? ` (${flags.join(", ")})` : ""; return `${profileId}=token:${maskApiKey(profile.token)}${suffix}`; @@ -218,7 +229,11 @@ const resolveAuthLabel = async ( Number.isFinite(profile.expires) && profile.expires > 0 ) { - flags.push(profile.expires <= now ? "expired" : `exp ${formatUntil(profile.expires)}`); + flags.push( + profile.expires <= now + ? "expired" + : `exp ${formatUntil(profile.expires)}`, + ); } const suffixLabel = suffix ? ` ${suffix}` : ""; const suffixFlags = flags.length > 0 ? ` (${flags.join(", ")})` : ""; @@ -242,7 +257,8 @@ const resolveAuthLabel = async ( if (customKey) { return { label: maskApiKey(customKey), - source: mode === "verbose" ? `models.json: ${formatPath(modelsPath)}` : "", + source: + mode === "verbose" ? `models.json: ${formatPath(modelsPath)}` : "", }; } return { label: "missing", source: "missing" }; @@ -803,16 +819,16 @@ export async function handleDirectiveOnly(params: { } modelSelection = resolved.selection; if (modelSelection) { - if (directives.rawModelProfile) { - const profileResolved = resolveProfileOverride({ - rawProfile: directives.rawModelProfile, - provider: modelSelection.provider, - cfg: params.cfg, - agentDir, - }); - if (profileResolved.error) { - return { text: profileResolved.error }; - } + if (directives.rawModelProfile) { + const profileResolved = resolveProfileOverride({ + rawProfile: directives.rawModelProfile, + provider: modelSelection.provider, + cfg: params.cfg, + agentDir, + }); + if (profileResolved.error) { + return { text: profileResolved.error }; + } profileOverride = profileResolved.profileId; } const nextLabel = `${modelSelection.provider}/${modelSelection.model}`; @@ -960,6 +976,7 @@ export async function persistInlineDirectives(params: { directives: InlineDirectives; effectiveModelDirective?: string; cfg: ClawdbotConfig; + agentDir?: string; sessionEntry?: SessionEntry; sessionStore?: Record; sessionKey?: string; @@ -993,6 +1010,7 @@ export async function persistInlineDirectives(params: { formatModelSwitchEvent, agentCfg, } = params; + const { agentDir } = params; let { provider, model } = params; if (sessionEntry && sessionStore && sessionKey) { diff --git a/src/cli/models-cli.ts b/src/cli/models-cli.ts index dd2ca826b..ce897d66d 100644 --- a/src/cli/models-cli.ts +++ b/src/cli/models-cli.ts @@ -392,7 +392,9 @@ export function registerModelsCli(program: Command) { order .command("set") - .description("Set per-agent auth order override (locks rotation to this list)") + .description( + "Set per-agent auth order override (locks rotation to this list)", + ) .requiredOption("--provider ", "Provider id (e.g. anthropic)") .option("--agent ", "Agent id (default: configured default agent)") .argument("", "Auth profile ids (e.g. anthropic:claude-cli)") @@ -414,7 +416,9 @@ export function registerModelsCli(program: Command) { order .command("clear") - .description("Clear per-agent auth order override (fall back to config/round-robin)") + .description( + "Clear per-agent auth order override (fall back to config/round-robin)", + ) .requiredOption("--provider ", "Provider id (e.g. anthropic)") .option("--agent ", "Agent id (default: configured default agent)") .action(async (opts) => { diff --git a/src/commands/models/auth-order.ts b/src/commands/models/auth-order.ts index e0429a372..4af49e63c 100644 --- a/src/commands/models/auth-order.ts +++ b/src/commands/models/auth-order.ts @@ -1,16 +1,22 @@ -import { resolveAgentDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; import { + resolveAgentDir, + resolveDefaultAgentId, +} from "../../agents/agent-scope.js"; +import { + type AuthProfileStore, ensureAuthProfileStore, setAuthProfileOrder, - type AuthProfileStore, } from "../../agents/auth-profiles.js"; import { normalizeProviderId } from "../../agents/model-selection.js"; import { loadConfig } from "../../config/config.js"; +import { normalizeAgentId } from "../../routing/session-key.js"; import type { RuntimeEnv } from "../../runtime.js"; import { shortenHomePath } from "../../utils.js"; -import { normalizeAgentId } from "../../routing/session-key.js"; -function resolveTargetAgent(cfg: ReturnType, raw?: string): { +function resolveTargetAgent( + cfg: ReturnType, + raw?: string, +): { agentId: string; agentDir: string; } { @@ -37,7 +43,9 @@ export async function modelsAuthOrderGetCommand( const cfg = loadConfig(); const { agentId, agentDir } = resolveTargetAgent(cfg, opts.agent); - const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }); + const store = ensureAuthProfileStore(agentDir, { + allowKeychainPrompt: false, + }); const order = describeOrder(store, provider); if (opts.json) { @@ -59,9 +67,13 @@ export async function modelsAuthOrderGetCommand( runtime.log(`Agent: ${agentId}`); runtime.log(`Provider: ${provider}`); - runtime.log(`Auth file: ${shortenHomePath(`${agentDir}/auth-profiles.json`)}`); runtime.log( - order.length > 0 ? `Order override: ${order.join(", ")}` : "Order override: (none)", + `Auth file: ${shortenHomePath(`${agentDir}/auth-profiles.json`)}`, + ); + runtime.log( + order.length > 0 + ? `Order override: ${order.join(", ")}` + : "Order override: (none)", ); } @@ -75,8 +87,13 @@ export async function modelsAuthOrderClearCommand( const cfg = loadConfig(); const { agentId, agentDir } = resolveTargetAgent(cfg, opts.agent); - const updated = await setAuthProfileOrder({ agentDir, provider, order: null }); - if (!updated) throw new Error("Failed to update auth-profiles.json (lock busy?)."); + const updated = await setAuthProfileOrder({ + agentDir, + provider, + order: null, + }); + if (!updated) + throw new Error("Failed to update auth-profiles.json (lock busy?)."); runtime.log(`Agent: ${agentId}`); runtime.log(`Provider: ${provider}`); @@ -94,7 +111,9 @@ export async function modelsAuthOrderSetCommand( const cfg = loadConfig(); const { agentId, agentDir } = resolveTargetAgent(cfg, opts.agent); - const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }); + const store = ensureAuthProfileStore(agentDir, { + allowKeychainPrompt: false, + }); const providerKey = normalizeProviderId(provider); const requested = (opts.order ?? []) .map((entry) => String(entry).trim()) @@ -120,10 +139,10 @@ export async function modelsAuthOrderSetCommand( provider, order: requested, }); - if (!updated) throw new Error("Failed to update auth-profiles.json (lock busy?)."); + if (!updated) + throw new Error("Failed to update auth-profiles.json (lock busy?)."); runtime.log(`Agent: ${agentId}`); runtime.log(`Provider: ${provider}`); runtime.log(`Order override: ${describeOrder(updated, provider).join(", ")}`); } - From d5b826ffc89104b41ab315369c10c66212088267 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 15:25:33 +0100 Subject: [PATCH 4/8] fix: restore openUrl import --- src/commands/configure.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/configure.ts b/src/commands/configure.ts index f915f439e..d75a1527e 100644 --- a/src/commands/configure.ts +++ b/src/commands/configure.ts @@ -80,6 +80,7 @@ import { DEFAULT_WORKSPACE, ensureWorkspaceAndSessions, guardCancel, + openUrl, printWizardHeader, probeGatewayReachable, randomToken, From d28c266771de164379933516ccfd4d7d0e6f464b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 15:31:34 +0100 Subject: [PATCH 5/8] fix: sanitize Windows test output --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3057a34b..f07011dbe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,12 +102,12 @@ jobs: - runtime: node task: lint command: pnpm lint - - runtime: node - task: test - command: pnpm test - - runtime: node - task: build - command: pnpm build + - runtime: node + task: test + command: node scripts/ci-sanitize-output.mjs pnpm test + - runtime: node + task: build + command: pnpm build - runtime: node task: protocol command: pnpm protocol:check From 5f4eb8b5098ce7f673f8a823301a8eaf6daa6164 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 15:34:41 +0100 Subject: [PATCH 6/8] style: format cli files --- src/cli/gateway-cli.ts | 5 ++++- src/cli/profile.test.ts | 7 +------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cli/gateway-cli.ts b/src/cli/gateway-cli.ts index 11ecd42b9..f478b3293 100644 --- a/src/cli/gateway-cli.ts +++ b/src/cli/gateway-cli.ts @@ -180,7 +180,10 @@ async function ensureDevWorkspace(dir: string) { path.join(resolvedDir, "TOOLS.md"), DEV_TOOLS_TEMPLATE, ); - await writeFileIfMissing(path.join(resolvedDir, "USER.md"), DEV_USER_TEMPLATE); + await writeFileIfMissing( + path.join(resolvedDir, "USER.md"), + DEV_USER_TEMPLATE, + ); await writeFileIfMissing( path.join(resolvedDir, "HEARTBEAT.md"), DEV_HEARTBEAT_TEMPLATE, diff --git a/src/cli/profile.test.ts b/src/cli/profile.test.ts index daf51071d..e67657713 100644 --- a/src/cli/profile.test.ts +++ b/src/cli/profile.test.ts @@ -23,12 +23,7 @@ describe("parseCliProfileArgs", () => { }); it("still accepts global --dev before subcommand", () => { - const res = parseCliProfileArgs([ - "node", - "clawdbot", - "--dev", - "gateway", - ]); + const res = parseCliProfileArgs(["node", "clawdbot", "--dev", "gateway"]); if (!res.ok) throw new Error(res.error); expect(res.profile).toBe("dev"); expect(res.argv).toEqual(["node", "clawdbot", "gateway"]); From 2aeeeff65f0b3d1800c2db0be878f5482e14219e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 15:39:16 +0100 Subject: [PATCH 7/8] ci: sanitize CI test output --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f07011dbe..28a2739b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,12 +102,12 @@ jobs: - runtime: node task: lint command: pnpm lint - - runtime: node - task: test - command: node scripts/ci-sanitize-output.mjs pnpm test - - runtime: node - task: build - command: pnpm build + - runtime: node + task: test + command: node scripts/ci-sanitize-output.mjs pnpm test + - runtime: node + task: build + command: pnpm build - runtime: node task: protocol command: pnpm protocol:check From 9af5b1380317e67eacd1d86720372f795053fee4 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 15:47:26 +0100 Subject: [PATCH 8/8] test: make withTempHome cross-platform --- src/auto-reply/reply.triggers.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/auto-reply/reply.triggers.test.ts b/src/auto-reply/reply.triggers.test.ts index d5017a3fa..c4c67945a 100644 --- a/src/auto-reply/reply.triggers.test.ts +++ b/src/auto-reply/reply.triggers.test.ts @@ -53,13 +53,27 @@ vi.mock("../web/session.js", () => webMocks); async function withTempHome(fn: (home: string) => Promise): Promise { const base = await fs.mkdtemp(join(tmpdir(), "clawdbot-triggers-")); const previousHome = process.env.HOME; + const previousUserProfile = process.env.USERPROFILE; + const previousHomeDrive = process.env.HOMEDRIVE; + const previousHomePath = process.env.HOMEPATH; process.env.HOME = base; + if (process.platform === "win32") { + process.env.USERPROFILE = base; + const driveMatch = base.match(/^([A-Za-z]:)(.*)$/); + if (driveMatch) { + process.env.HOMEDRIVE = driveMatch[1]; + process.env.HOMEPATH = driveMatch[2] || "\\"; + } + } try { vi.mocked(runEmbeddedPiAgent).mockClear(); vi.mocked(abortEmbeddedPiRun).mockClear(); return await fn(base); } finally { process.env.HOME = previousHome; + process.env.USERPROFILE = previousUserProfile; + process.env.HOMEDRIVE = previousHomeDrive; + process.env.HOMEPATH = previousHomePath; await fs.rm(base, { recursive: true, force: true }); } }