Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f

- **Restore HTTP LAN and VPN access.** Browser UUID generation now works without secure-context-only `crypto.randomUUID()`, preventing the "Something went wrong" crash when opening the app or creating a session.
- **Open live subagent transcripts without waiting forever.** Transcript pages now read the subagent's on-disk artifact directly instead of waiting for its busy agent process to answer first.
- **Make cross-session message approval coherent across a cluster.** Choose whether every `send_to_session` call asks first, or sessions may message any session within the cluster without asking.

### Added

Expand Down
7 changes: 7 additions & 0 deletions app/api/web-settings/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export async function PUT(req: Request) {
patch.agentToolsEnabled = payload.agentToolsEnabled;
}

if (payload.agentMessagePermission !== undefined) {
if (payload.agentMessagePermission !== "alwaysAsk" && payload.agentMessagePermission !== "trustCluster") {
return Response.json({ error: 'agentMessagePermission must be "alwaysAsk" or "trustCluster"', code: "invalid_settings" }, { status: 400 });
}
patch.agentMessagePermission = payload.agentMessagePermission;
}

if (payload.githubWritesUnasked !== undefined) {
if (typeof payload.githubWritesUnasked !== "boolean") {
return Response.json({ error: "githubWritesUnasked must be a boolean", code: "invalid_settings" }, { status: 400 });
Expand Down
105 changes: 105 additions & 0 deletions components/SettingsConfig.agent-messages.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import "../tests/setup-dom.mjs";
import assert from "node:assert/strict";
import test from "node:test";
import { act, createElement } from "react";
const { cleanup, fireEvent, render, waitFor, within } = await import("@testing-library/react/pure.js");
const { SettingsConfig } = await import("./SettingsConfig");

const noop = () => {};
const settle = () => act(() => new Promise((resolve) => setTimeout(resolve, 20)));
const settingsProps = {
activeTab: "system",
toolCallsDefaultCollapsed: false, onToolCallsDefaultCollapsedChange: noop,
hideToolActivity: false, onHideToolActivityChange: noop,
expandThinkingByDefault: false, onExpandThinkingByDefaultChange: noop, onHideThinkingBlockChange: noop,
providerUsageVisible: false, onProviderUsageVisibleChange: noop,
scopeNativeSelectAll: false, onScopeNativeSelectAllChange: noop,
openUrlAutomatically: false, onOpenUrlAutomaticallyChange: noop,
cwd: null, remoteHost: false, sessionId: null,
onModelsSaved: noop, onPluginsReloaded: noop,
appUpdate: null, onRefreshAppUpdate: async () => null,
onRequestAppUpdate: noop, onSelectTab: noop, onClose: noop,
};

async function choose(select, name) {
fireEvent.click(select);
const list = await waitFor(() => within(document.body).getByRole("listbox"));
const option = within(list).getByRole("option", { name, exact: true });
fireEvent.pointerDown(option, { pointerType: "mouse" });
fireEvent.click(option);
await settle();
}

test("agent message approval loads and saves the trust-cluster policy", async (t) => {
const puts = [];
const originalFetch = globalThis.fetch;
globalThis.fetch = async (url, init) => {
if (String(url) === "/api/web-settings") {
if (init?.method === "PUT") {
puts.push(init.body);
return Response.json({ agentMessagePermission: "trustCluster" });
}
return Response.json({ agentMessagePermission: "alwaysAsk" });
}
return Response.json({});
};
t.after(() => {
cleanup();
globalThis.fetch = originalFetch;
});

const { container } = render(createElement(SettingsConfig, settingsProps));
await settle();
const select = within(container).getByRole("combobox", { name: "Agent message approval" });
assert.equal(select.textContent, "Always ask");
await choose(select, "Trust cluster");
assert.deepEqual(puts, ['{"agentMessagePermission":"trustCluster"}']);
assert.equal(select.textContent, "Trust cluster");
});

test("agent message approval shows unavailable instead of inventing a policy while loading fails", async (t) => {
const pending = Promise.withResolvers();
const originalFetch = globalThis.fetch;
globalThis.fetch = async (url) => String(url) === "/api/web-settings" ? pending.promise : Response.json({});
t.after(() => {
cleanup();
globalThis.fetch = originalFetch;
});

const { container } = render(createElement(SettingsConfig, settingsProps));
const select = await waitFor(() => within(container).getByRole("combobox", { name: "Agent message approval" }));
assert.equal(select.disabled, true);
assert.equal(select.textContent, "Unavailable");
pending.resolve(new Response(null, { status: 503 }));
await settle();
assert.equal(select.disabled, true);
assert.equal(select.textContent, "Unavailable");
});

test("an uncertain agent message approval save reloads the committed policy", async (t) => {
let saveAttempted = false;
let loadsAfterSave = 0;
const originalFetch = globalThis.fetch;
globalThis.fetch = async (url, init) => {
if (String(url) !== "/api/web-settings") return Response.json({});
if (init?.method === "PUT") {
saveAttempted = true;
throw new TypeError("Failed to fetch");
}
if (saveAttempted) loadsAfterSave++;
return Response.json({ agentMessagePermission: saveAttempted ? "trustCluster" : "alwaysAsk" });
};
t.after(() => {
cleanup();
globalThis.fetch = originalFetch;
});

const { container } = render(createElement(SettingsConfig, settingsProps));
await settle();
const select = within(container).getByRole("combobox", { name: "Agent message approval" });
await choose(select, "Trust cluster");
assert.equal(saveAttempted, true);
assert.ok(loadsAfterSave > 0);
assert.equal(select.disabled, false);
assert.equal(select.textContent, "Trust cluster");
});
59 changes: 58 additions & 1 deletion components/SettingsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from "@/lib/notification-client";
import { BROWSER_TRANSPORTS, type BrowserTransport } from "@/lib/event-stream-protocol";
import { setConnectionDiagnosticsEnabled, useConnectionDiagnosticsEnabled } from "@/lib/connection-diagnostics-prefs";
import type { GithubActionsOperation, GithubActionsPermission, GithubActionsPermissions } from "@/lib/web-settings";
import type { AgentMessagePermission, GithubActionsOperation, GithubActionsPermission, GithubActionsPermissions } from "@/lib/web-settings";
const SettingsTabLoading = () => {
const { t } = useI18n();
return <div role="status" style={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center", color: "var(--text-muted)", fontSize: "var(--text-sm)" }}>{t("settingsConfig.loadingSettings")}</div>;
Expand Down Expand Up @@ -205,6 +205,7 @@ const SETTING_INDEX: SettingIndexEntry[] = [
// Windows Background Service & System Tray
{ id: "auto-resume-sessions", tab: "system", sectionKey: "settingsConfig.systemUpdates", labelKey: "settingsConfig.autoResumeSessions", descKey: "settingsConfig.autoResumeSessionsDesc", fallbackSection: "System", fallbackLabel: "Resume running sessions after a restart", fallbackDesc: "When omp-web restarts while agents are working, restart those sessions and tell each agent: \"Session interrupted and resumed. Continue as you would have done without the interruption.\" Work in progress at the moment of the restart, such as a running command, is lost." },
{ id: "agent-tools-cross-session", tab: "system", sectionKey: "settingsConfig.systemUpdates", labelKey: "settingsConfig.agentTools", descKey: "settingsConfig.agentToolsDesc", fallbackSection: "System", fallbackLabel: "Agent tools (cross-session)", fallbackDesc: "Allow cross-session tools and GitHub tools for watching and reading issues and pull requests, writing comments and threads, and managing Actions workflow runs. Requires the GitHub CLI (gh) installed and logged in on this server." },
{ id: "agent-message-permission", tab: "system", sectionKey: "settingsConfig.systemUpdates", labelKey: "settingsConfig.agentMessagePermission", descKey: "settingsConfig.agentMessagePermissionDesc", fallbackSection: "System", fallbackLabel: "Agent message approval", fallbackDesc: "Always ask before send_to_session, or trust sends between cluster members." },
{ id: "github-writes-unasked", tab: "system", sectionKey: "settingsConfig.systemUpdates", labelKey: "settingsConfig.githubWritesUnasked", descKey: "settingsConfig.githubWritesUnaskedDesc", fallbackSection: "System", fallbackLabel: "Allow agent GitHub writes without asking", fallbackDesc: "Let agents post comments, reply in review threads and resolve threads through this server's gh login without a confirmation each time. Off: each of those comment and thread writes asks in the session first." },
{ id: "github-actions-dispatch", tab: "system", sectionKey: "settingsConfig.systemUpdates", labelKey: "settingsConfig.githubActionsDispatch", descKey: "settingsConfig.githubActionsDispatchDesc", fallbackSection: "System", fallbackLabel: "Dispatch workflows", fallbackDesc: "Choose whether agents may start GitHub Actions workflows." },
{ id: "github-actions-cancel", tab: "system", sectionKey: "settingsConfig.systemUpdates", labelKey: "settingsConfig.githubActionsCancel", descKey: "settingsConfig.githubActionsCancelDesc", fallbackSection: "System", fallbackLabel: "Cancel workflow runs", fallbackDesc: "Choose whether agents may cancel running GitHub Actions workflows." },
Expand Down Expand Up @@ -345,6 +346,61 @@ function AgentToolsSetting() {
);
}

function AgentMessagePermissionSetting() {
const { t } = useI18n();
const [permission, setPermission] = useState<AgentMessagePermission | null>(null);
const [saving, setSaving] = useState(false);
const load = useCallback(async (response?: Response): Promise<AgentMessagePermission | null> => {
try {
const res = response ?? await fetch("/api/web-settings");
if (!res.ok) return null;
const value = (await res.json() as { agentMessagePermission?: unknown }).agentMessagePermission;
return value === "alwaysAsk" || value === "trustCluster" ? value : null;
} catch {
return null;
}
}, []);
useEffect(() => {
let alive = true;
void load().then((value) => { if (alive) setPermission(value); });
return () => { alive = false; };
}, [load]);
const change = async (next: AgentMessagePermission) => {
setSaving(true);
try {
const res = await fetch("/api/web-settings", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ agentMessagePermission: next }),
});
const saved = await load(res);
if (!saved) throw new Error(`HTTP ${res.status}`);
setPermission(saved);
} catch (error) {
setPermission(null);
toast.error(t("settingsConfig.agentMessagePermissionSaveFailed"), error instanceof Error ? error.message : String(error));
setPermission(await load());
} finally {
setSaving(false);
}
};
return (
<NativeSetting searchId="agent-message-permission" label={t("settingsConfig.agentMessagePermission")} description={t("settingsConfig.agentMessagePermissionDesc")}>
<ThemedSelect
style={nativeSelectStyle}
value={permission ?? "unknown"}
disabled={permission === null || saving}
options={[
...(permission === null ? [{ value: "unknown", label: t("settingsConfig.agentMessagePermissionUnavailable") }] : []),
{ value: "alwaysAsk", label: t("settingsConfig.agentMessagePermissionAlwaysAsk") },
{ value: "trustCluster", label: t("settingsConfig.agentMessagePermissionTrustCluster") },
]}
onChange={(next) => void change(next as AgentMessagePermission)}
/>
</NativeSetting>
);
}

function GithubWritesSetting() {
const { t } = useI18n();
// null until loaded, and after a failed load: showing "off" there could hide writes the server allows.
Expand Down Expand Up @@ -1957,6 +2013,7 @@ export function SettingsConfig({ activeTab, toolCallsDefaultCollapsed, onToolCal
<AutoResumeSessionsSetting />

<AgentToolsSetting />
<AgentMessagePermissionSetting />

<GithubWritesSetting />

Expand Down
Loading
Loading