Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

refactor: split settings page and fix logs panel test mock (#386)

luigiagentd6e86974af9a
diff --git a/.github/workflows/reusable-go.yml b/.github/workflows/reusable-go.yml
index c635dffb..3d529193 100644
--- a/.github/workflows/reusable-go.yml
+++ b/.github/workflows/reusable-go.yml
@@ -29,7 +29,11 @@ jobs:
- name: Format check
run: |
- unformatted=$(gofmt -l .)
+ mapfile -t go_files < <(git ls-files -- '*.go')
+ unformatted=""
+ if [ ${#go_files[@]} -gt 0 ]; then
+ unformatted=$(gofmt -l "${go_files[@]}")
+ fi
if [ -n "$unformatted" ]; then
echo "Files not formatted:"
echo "$unformatted"
diff --git a/dashboard/src/activities/ActivityExplorer.tsx b/dashboard/src/activities/ActivityExplorer.tsx
index be590f91..2b39d6fe 100644
--- a/dashboard/src/activities/ActivityExplorer.tsx
+++ b/dashboard/src/activities/ActivityExplorer.tsx
@@ -110,7 +110,6 @@ export default function ActivityExplorer({
return () => {
cancelled = true;
};
- // eslint-disable-next-line react-hooks/exhaustive-deps
}, [queryKey]);
const stats = useMemo(() => {
diff --git a/dashboard/src/activities/ActivityPage.test.tsx b/dashboard/src/activities/ActivityPage.test.tsx
index 58fecd8b..7402ac28 100644
--- a/dashboard/src/activities/ActivityPage.test.tsx
+++ b/dashboard/src/activities/ActivityPage.test.tsx
@@ -91,10 +91,9 @@ describe("ActivityPage", () => {
expect(fetchActivity).toHaveBeenCalled();
});
- expect(screen.getByText("Request timeline")).toBeInTheDocument();
expect(screen.getByText("/tabs/tab_123/action")).toBeInTheDocument();
expect(screen.getByText("agent:cli")).toBeInTheDocument();
- expect(screen.getByText("tab:tab_123")).toBeInTheDocument();
+ expect(screen.getAllByText("tab:tab_123").length).toBeGreaterThan(0);
});
it("defaults to the current running profile and tab", async () => {
diff --git a/dashboard/src/activities/ActivityPage.tsx b/dashboard/src/activities/ActivityPage.tsx
index 8cef888c..266c6b6c 100644
--- a/dashboard/src/activities/ActivityPage.tsx
+++ b/dashboard/src/activities/ActivityPage.tsx
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useLocation } from "react-router-dom";
import { useAppStore } from "../stores/useAppStore";
import type { ActivityFilters } from "./types";
-import ActivityExplorer from "./ActivityExplorer";
+import AgentActivityWorkspace from "./AgentActivityWorkspace";
interface ActivityPageLocationState {
profileName?: string;
@@ -123,10 +123,10 @@ export default function ActivityPage() {
}, [derivedInitialFilters, didAutoSelect]);
return (
- <ActivityExplorer
- title="Request timeline"
- summaryLabel="Activity"
+ <AgentActivityWorkspace
initialFilters={initialFilters}
+ defaultSidebarTab="activities"
+ hiddenSources={["dashboard"]}
/>
);
}
diff --git a/dashboard/src/activities/AgentActivityWorkspace.tsx b/dashboard/src/activities/AgentActivityWorkspace.tsx
new file mode 100644
index 00000000..5dc60156
--- /dev/null
+++ b/dashboard/src/activities/AgentActivityWorkspace.tsx
@@ -0,0 +1,239 @@
+import { useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
+import { useAppStore } from "../stores/useAppStore";
+import * as api from "../services/api";
+import type { Agent, InstanceTab } from "../types";
+import { fetchActivity } from "./api";
+import AgentStreamPanel from "./AgentStreamPanel";
+import AgentWorkspaceSidebar from "./AgentWorkspaceSidebar";
+import {
+ buildActivityQuery,
+ defaultActivityFilters,
+ sameActivityFilters,
+} from "./helpers";
+import type { ActivityFilters, DashboardActivityEvent } from "./types";
+
+type WorkspaceTab = "agents" | "activities";
+
+interface Props {
+ initialFilters?: Partial<ActivityFilters>;
+ defaultSidebarTab?: WorkspaceTab;
+ hiddenSources?: string[];
+}
+
+export default function AgentActivityWorkspace({
+ initialFilters,
+ defaultSidebarTab = "agents",
+ hiddenSources = [],
+}: Props) {
+ const { instances, profiles } = useAppStore();
+ const [sidebarTab, setSidebarTab] = useState<WorkspaceTab>(defaultSidebarTab);
+ const [filters, setFilters] = useState<ActivityFilters>({
+ ...defaultActivityFilters,
+ ...initialFilters,
+ });
+ const [events, setEvents] = useState<DashboardActivityEvent[]>([]);
+ const [tabs, setTabs] = useState<InstanceTab[]>([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState("");
+ const [refreshNonce, setRefreshNonce] = useState(0);
+
+ const deferredFilters = useDeferredValue(filters);
+ const query = useMemo(
+ () => buildActivityQuery(deferredFilters),
+ [deferredFilters],
+ );
+ const queryKey = JSON.stringify(query);
+ const stableQuery = useRef(query);
+ stableQuery.current = query;
+
+ useEffect(() => {
+ setSidebarTab(defaultSidebarTab);
+ }, [defaultSidebarTab]);
+
+ useEffect(() => {
+ const next = {
+ ...defaultActivityFilters,
+ ...initialFilters,
+ };
+ setFilters((current) =>
+ sameActivityFilters(current, next) ? current : next,
+ );
+ }, [initialFilters]);
+
+ useEffect(() => {
+ let cancelled = false;
+ void api
+ .fetchAllTabs()
+ .then((response) => {
+ if (!cancelled) {
+ setTabs(response);
+ }
+ })
+ .catch(() => {
+ if (!cancelled) {
+ setTabs([]);
+ }
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+
+ useEffect(() => {
+ let cancelled = false;
+ const load = async () => {
+ setLoading(true);
+ setError("");
+ try {
+ const response = await fetchActivity(stableQuery.current);
+ if (cancelled) return;
+ setEvents(response.events);
+ } catch (err) {
+ if (cancelled) return;
+ setError(
+ err instanceof Error ? err.message : "Failed to load activity",
+ );
+ } finally {
+ if (!cancelled) {
+ setLoading(false);
+ }
+ }
+ };
+ void load();
+ return () => {
+ cancelled = true;
+ };
+ }, [queryKey, refreshNonce]);
+
+ const filteredInstances = useMemo(
+ () =>
+ filters.profileName === ""
+ ? instances
+ : instances.filter(
+ (instance) => instance.profileName === filters.profileName,
+ ),
+ [filters.profileName, instances],
+ );
+
+ const visibleTabs = useMemo(
+ () =>
+ filters.instanceId === ""
+ ? tabs
+ : tabs.filter((tab) => tab.instanceId === filters.instanceId),
+ [filters.instanceId, tabs],
+ );
+
+ const visibleEvents = useMemo(
+ () => events.filter((event) => !hiddenSources.includes(event.source)),
+ [events, hiddenSources],
+ );
+
+ const visibleAgents = useMemo<Agent[]>(() => {
+ const byId = new Map<string, Agent>();
+ for (const event of visibleEvents) {
+ const agentId = event.agentId?.trim() || "anonymous";
+ const existing = byId.get(agentId);
+ if (!existing) {
+ byId.set(agentId, {
+ id: agentId,
+ name: agentId,
+ connectedAt: event.timestamp,
+ lastActivity: event.timestamp,
+ requestCount: 1,
+ });
+ continue;
+ }
+ existing.requestCount += 1;
+ if (
+ new Date(event.timestamp).getTime() >
+ new Date(existing.lastActivity || existing.connectedAt).getTime()
+ ) {
+ existing.lastActivity = event.timestamp;
+ }
+ }
+
+ return [...byId.values()].sort(
+ (left, right) =>
+ new Date(right.lastActivity || right.connectedAt).getTime() -
+ new Date(left.lastActivity || left.connectedAt).getTime(),
+ );
+ }, [visibleEvents]);
+
+ const summary = useMemo(() => {
+ const agentsSeen = new Set(
+ visibleEvents.map((event) => event.agentId).filter(Boolean),
+ );
+ const tabsSeen = new Set(
+ visibleEvents.map((event) => event.tabId).filter(Boolean),
+ );
+ const instancesSeen = new Set(
+ visibleEvents.map((event) => event.instanceId).filter(Boolean),
+ );
+ return `${visibleEvents.length} events • ${agentsSeen.size} agents • ${tabsSeen.size} tabs • ${instancesSeen.size} instances`;
+ }, [visibleEvents]);
+
+ const updateFilter = (key: keyof ActivityFilters, value: string) => {
+ setFilters((current) => ({ ...current, [key]: value }));
+ };
+
+ const handleProfileChange = (value: string) => {
+ setFilters((current) => ({
+ ...current,
+ profileName: value,
+ instanceId:
+ value === "" ||
+ filteredInstances.some((instance) => instance.id === current.instanceId)
+ ? current.instanceId
+ : "",
+ tabId: value === "" ? current.tabId : "",
+ }));
+ };
+
+ const handleInstanceChange = (value: string) => {
+ setFilters((current) => ({
+ ...current,
+ instanceId: value,
+ tabId:
+ value === "" || visibleTabs.some((tab) => tab.id === current.tabId)
+ ? current.tabId
+ : "",
+ }));
+ };
+
+ const clearFilters = () => {
+ setFilters({ ...defaultActivityFilters });
+ };
+
+ return (
+ <div className="flex h-full min-h-0 flex-col overflow-hidden xl:flex-row">
+ <AgentStreamPanel
+ filters={filters}
+ events={visibleEvents}
+ summary={summary}
+ error={error}
+ loading={loading}
+ onClearFilters={clearFilters}
+ onFilterChange={updateFilter}
+ />
+
+ <AgentWorkspaceSidebar
+ sidebarTab={sidebarTab}
+ visibleAgents={visibleAgents}
+ activeAgentId={filters.agentId}
+ filters={filters}
+ profiles={profiles}
+ filteredInstances={filteredInstances}
+ visibleTabs={visibleTabs}
+ loading={loading}
+ onSidebarTabChange={setSidebarTab}
+ onSelectAgent={(agentId) => updateFilter("agentId", agentId)}
+ onClearAgentSelection={() => updateFilter("agentId", "")}
+ onClearFilters={clearFilters}
+ onRefresh={() => setRefreshNonce((current) => current + 1)}
+ onFilterChange={updateFilter}
+ onProfileChange={handleProfileChange}
+ onInstanceChange={handleInstanceChange}
+ />
+ </div>
+ );
+}
diff --git a/dashboard/src/activities/AgentStreamPanel.tsx b/dashboard/src/activities/AgentStreamPanel.tsx
new file mode 100644
index 00000000..d1148243
--- /dev/null
+++ b/dashboard/src/activities/AgentStreamPanel.tsx
@@ -0,0 +1,219 @@
+import { EmptyState } from "../components/atoms";
+import { Badge } from "../components/atoms";
+import { activityMethodVariant, activityStatusVariant } from "./helpers";
+import type { ActivityFilters, DashboardActivityEvent } from "./types";
+
+function formatTime(ts: string): string {
+ return new Date(ts).toLocaleTimeString("en-GB", {
+ hour: "2-digit",
+ minute: "2-digit",
+ second: "2-digit",
+ });
+}
+
+function eventIcon(event: DashboardActivityEvent): string {
+ if (event.action === "click" || event.action === "dblclick") return "👆";
+ if (event.action === "type") return "⌨️";
+ if (event.action === "hover") return "🖱️";
+ if (event.path.includes("/navigate")) return "🧭";
+ if (event.path.includes("/snapshot")) return "📸";
+ if (event.path.includes("/screencast")) return "🖥️";
+ return "📝";
+}
+
+function FilterPill({
+ label,
+ onClick,
+}: {
+ label: string;
+ onClick: () => void;
+}) {
+ return (
+ <button
+ type="button"
+ className="rounded-sm border border-border-subtle bg-white/3 px-1.5 py-0.5 text-[0.62rem] font-semibold tracking-[0.08em] text-text-secondary transition-all hover:border-primary/30 hover:bg-primary/10 hover:text-primary"
+ onClick={onClick}
+ title={label}
+ >
+ <span className="block truncate">{label}</span>
+ </button>
+ );
+}
+
+function ActiveFilterBar({
+ filters,
+ onClear,
+}: {
+ filters: ActivityFilters;
+ onClear: () => void;
+}) {
+ const activeFilters = [
+ filters.agentId ? `agent:${filters.agentId}` : "",
+ filters.profileName ? `profile:${filters.profileName}` : "",
+ filters.instanceId ? `instance:${filters.instanceId}` : "",
+ filters.tabId ? `tab:${filters.tabId}` : "",
+ filters.action ? `action:${filters.action}` : "",
+ filters.source ? `source:${filters.source}` : "",
+ filters.sessionId ? `session:${filters.sessionId}` : "",
+ filters.pathPrefix ? `path:${filters.pathPrefix}` : "",
+ ].filter(Boolean);
+
+ if (activeFilters.length === 0) {
+ return null;
+ }
+
+ return (
+ <div className="flex flex-wrap items-center gap-2 border-b border-border-subtle px-4 py-2">
+ {activeFilters.map((filter) => (
+ <span
+ key={filter}
+ className="dashboard-mono rounded-sm border border-primary/20 bg-primary/10 px-2 py-1 text-[0.68rem] text-text-secondary"
+ >
+ {filter}
+ </span>
+ ))}
+ <button
+ type="button"
+ className="ml-auto text-[0.68rem] font-semibold uppercase tracking-[0.12em] text-text-muted transition-colors hover:text-text-primary"
+ onClick={onClear}
+ >
+ Clear filters
+ </button>
+ </div>
+ );
+}
+
+function StreamRow({
+ event,
+ onFilterChange,
+}: {
+ event: DashboardActivityEvent;
+ onFilterChange: (key: keyof ActivityFilters, value: string) => void;
+}) {
+ return (
+ <div className="border-b border-border-subtle/70 px-4 py-3 text-sm transition-colors hover:bg-white/2">
+ <div className="flex items-start gap-3">
+ <span className="pt-0.5 text-lg">{eventIcon(event)}</span>
+ <span className="dashboard-mono w-18 shrink-0 pt-0.5 text-xs text-text-muted">
+ {formatTime(event.timestamp)}
+ </span>
+ <div className="min-w-0 flex-1">
+ <div className="flex flex-wrap items-center gap-2">
+ <Badge variant={activityMethodVariant(event.method)}>
+ {event.method}
+ </Badge>
+ <Badge variant={activityStatusVariant(event.status)}>
+ {event.status}
+ </Badge>
+ {event.source && <Badge>{event.source}</Badge>}
+ {event.action && <Badge variant="warning">{event.action}</Badge>}
+ <span className="dashboard-mono min-w-0 flex-1 truncate text-text-secondary">
+ {event.path}
+ </span>
+ </div>
+
+ <div className="mt-1 flex flex-wrap items-center gap-1.5">
+ {event.tabId && (
+ <FilterPill
+ label={`tab:${event.tabId}`}
+ onClick={() => onFilterChange("tabId", event.tabId || "")}
+ />
+ )}
+ {event.profileName && (
+ <FilterPill
+ label={`profile:${event.profileName}`}
+ onClick={() =>
+ onFilterChange("profileName", event.profileName || "")
+ }
+ />
+ )}
+ {event.instanceId && (
+ <FilterPill
+ label={`instance:${event.instanceId}`}
+ onClick={() =>
+ onFilterChange("instanceId", event.instanceId || "")
+ }
+ />
+ )}
+ {event.url && (
+ <span className="dashboard-mono min-w-0 truncate text-[0.68rem] text-text-muted">
+ {event.url}
+ </span>
+ )}
+ </div>
+ </div>
+
+ <div className="flex shrink-0 flex-col items-end gap-1.5">
+ <span className="dashboard-mono text-xs text-text-muted">
+ {event.durationMs}ms
+ </span>
+ {event.agentId && (
+ <FilterPill
+ label={`agent:${event.agentId}`}
+ onClick={() => onFilterChange("agentId", event.agentId || "")}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
+
+interface AgentStreamPanelProps {
+ filters: ActivityFilters;
+ events: DashboardActivityEvent[];
+ summary: string;
+ error: string;
+ loading: boolean;
+ onClearFilters: () => void;
+ onFilterChange: (key: keyof ActivityFilters, value: string) => void;
+}
+
+export default function AgentStreamPanel({
+ filters,
+ events,
+ summary,
+ error,
+ loading,
+ onClearFilters,
+ onFilterChange,
+}: AgentStreamPanelProps) {
+ return (
+ <section className="flex min-h-0 flex-1 flex-col overflow-hidden">
+ <div className="flex items-center justify-between border-b border-border-subtle bg-bg-surface px-4 py-3">
+ <div></div>
+ <div className="dashboard-mono text-[0.72rem] text-text-muted">
+ {summary}
+ </div>
+ </div>
+
+ <ActiveFilterBar filters={filters} onClear={onClearFilters} />
+
+ {error && (
+ <div className="border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-xs text-destructive">
+ {error}
+ </div>
+ )}
+
+ <div className="min-h-0 flex-1 overflow-auto">
+ {!loading && events.length === 0 ? (
+ <EmptyState
+ icon="📡"
+ title="No matching activity"
+ description="Adjust the filters or generate some traffic from the CLI, MCP, or dashboard."
+ />
+ ) : (
+ <div>
+ {events.map((event, index) => (
+ <StreamRow
+ key={`${event.requestId || event.timestamp}-${index}`}
+ event={event}
+ onFilterChange={onFilterChange}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ </section>
+ );
+}
diff --git a/dashboard/src/activities/AgentWorkspaceSidebar.tsx b/dashboard/src/activities/AgentWorkspaceSidebar.tsx
new file mode 100644
index 00000000..7f4e55b0
--- /dev/null
+++ b/dashboard/src/activities/AgentWorkspaceSidebar.tsx
@@ -0,0 +1,114 @@
+import { AgentItem } from "../components/molecules";
+import type { Agent, Instance, InstanceTab, Profile } from "../types";
+import ActivityFilterMenu from "./ActivityFilterMenu";
+import type { ActivityFilters } from "./types";
+
+type WorkspaceTab = "agents" | "activities";
+
+interface AgentWorkspaceSidebarProps {
+ sidebarTab: WorkspaceTab;
+ visibleAgents: Agent[];
+ activeAgentId: string;
+ filters: ActivityFilters;
+ profiles: Profile[];
+ filteredInstances: Instance[];
+ visibleTabs: InstanceTab[];
+ loading: boolean;
+ onSidebarTabChange: (tab: WorkspaceTab) => void;
+ onSelectAgent: (agentId: string) => void;
+ onClearAgentSelection: () => void;
+ onClearFilters: () => void;
+ onRefresh: () => void;
+ onFilterChange: (key: keyof ActivityFilters, value: string) => void;
+ onProfileChange: (value: string) => void;
+ onInstanceChange: (value: string) => void;
+}
+
+export default function AgentWorkspaceSidebar({
+ sidebarTab,
+ visibleAgents,
+ activeAgentId,
+ filters,
+ profiles,
+ filteredInstances,
+ visibleTabs,
+ loading,
+ onSidebarTabChange,
+ onSelectAgent,
+ onClearAgentSelection,
+ onClearFilters,
+ onRefresh,
+ onFilterChange,
+ onProfileChange,
+ onInstanceChange,
+}: AgentWorkspaceSidebarProps) {
+ return (
+ <aside className="order-2 flex w-full shrink-0 flex-col overflow-hidden border-t border-border-subtle bg-bg-surface xl:order-0 xl:w-80 xl:border-t-0 xl:border-l">
+ <div className="flex border-b border-border-subtle">
+ {[
+ { id: "agents" as const, label: "Agents" },
+ { id: "activities" as const, label: "Activities" },
+ ].map((tab) => (
+ <button
+ key={tab.id}
+ type="button"
+ className={`flex-1 border-b px-4 py-3 text-sm font-semibold transition-colors ${
+ sidebarTab === tab.id
+ ? "border-primary bg-primary/8 text-text-primary"
+ : "border-transparent text-text-muted hover:bg-bg-elevated hover:text-text-primary"
+ }`}
+ onClick={() => onSidebarTabChange(tab.id)}
+ >
+ {tab.label}
+ </button>
+ ))}
+ </div>
+
+ {sidebarTab === "agents" ? (
+ <div className="min-h-0 flex-1 overflow-auto p-2">
+ {visibleAgents.length === 0 ? (
+ <div className="py-8 text-center text-sm text-text-muted">
+ <div className="mb-2 text-2xl">🦀</div>
+ No agent activity observed yet
+ </div>
+ ) : (
+ <div className="flex flex-col gap-1">
+ <button
+ type="button"
+ className={`rounded-sm px-3 py-2 text-left text-sm transition-all ${
+ activeAgentId === ""
+ ? "border border-primary/30 bg-primary/10 text-primary"
+ : "border border-transparent text-text-muted hover:bg-bg-elevated"
+ }`}
+ onClick={onClearAgentSelection}
+ >
+ All Agents
+ </button>
+ {visibleAgents.map((agent) => (
+ <AgentItem
+ key={agent.id}
+ agent={agent}
+ selected={activeAgentId === agent.id}
+ onClick={() => onSelectAgent(agent.id)}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ ) : (
+ <ActivityFilterMenu
+ filters={filters}
+ profileOptions={profiles}
+ instanceOptions={filteredInstances}
+ tabOptions={visibleTabs}
+ loading={loading}
+ onClear={onClearFilters}
+ onRefresh={onRefresh}
+ onFilterChange={onFilterChange}
+ onProfileChange={onProfileChange}
+ onInstanceChange={onInstanceChange}
+ />
+ )}
+ </aside>
+ );
+}
diff --git a/dashboard/src/activities/AgentsPage.test.tsx b/dashboard/src/activities/AgentsPage.test.tsx
new file mode 100644
index 00000000..22fb8fde
--- /dev/null
+++ b/dashboard/src/activities/AgentsPage.test.tsx
@@ -0,0 +1,123 @@
+import { render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { MemoryRouter } from "react-router-dom";
+import AgentsPage from "./AgentsPage";
+import { useAppStore } from "../stores/useAppStore";
+
+vi.mock("./api", () => ({
+ fetchActivity: vi.fn(),
+}));
+
+vi.mock("../services/api", () => ({
+ fetchAllTabs: vi.fn(),
+}));
+
+import { fetchActivity } from "./api";
+import { fetchAllTabs } from "../services/api";
+
+describe("AgentsPage", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ useAppStore.setState({
+ agents: [
+ {
+ id: "cli",
+ name: "CLI",
+ connectedAt: "2026-03-16T08:00:00Z",
+ lastActivity: "2026-03-16T08:10:00Z",
+ requestCount: 3,
+ },
+ ],
+ profiles: [],
+ instances: [],
+ currentTabs: {},
+ });
+ vi.mocked(fetchAllTabs).mockResolvedValue([]);
+ vi.mocked(fetchActivity).mockResolvedValue({
+ count: 3,
+ events: [
+ {
+ timestamp: "2026-03-16T09:00:00Z",
+ source: "cli",
+ requestId: "req_123",
+ agentId: "cli",
+ method: "POST",
+ path: "/tabs/tab_123/action",
+ status: 200,
+ durationMs: 87,
+ action: "click",
+ },
+ {
+ timestamp: "2026-03-16T09:00:01Z",
+ source: "dashboard",
+ requestId: "req_124",
+ method: "GET",
+ path: "/profiles",
+ status: 200,
+ durationMs: 22,
+ },
+ {
+ timestamp: "2026-03-16T09:00:02Z",
+ source: "server",
+ requestId: "req_125",
+ method: "GET",
+ path: "/health",
+ status: 200,
+ durationMs: 11,
+ },
+ ],
+ });
+ });
+
+ it("defaults the right rail to Agents", async () => {
+ render(
+ <MemoryRouter>
+ <AgentsPage />
+ </MemoryRouter>,
+ );
+
+ await waitFor(() => {
+ expect(fetchActivity).toHaveBeenCalled();
+ });
+
+ expect(screen.getByRole("button", { name: "Agents" })).toHaveClass(
+ "bg-primary/8",
+ );
+ expect(screen.queryByText("Request timeline")).not.toBeInTheDocument();
+ });
+
+ it("switches to Activities and shows the filter stack", async () => {
+ render(
+ <MemoryRouter>
+ <AgentsPage />
+ </MemoryRouter>,
+ );
+
+ await waitFor(() => {
+ expect(fetchActivity).toHaveBeenCalled();
+ });
+
+ await userEvent.click(screen.getByRole("button", { name: "Activities" }));
+
+ expect(screen.getByLabelText("Profile")).toBeInTheDocument();
+ expect(screen.getByLabelText("Agent")).toBeInTheDocument();
+ });
+
+ it("filters dashboard and server source events out of the agents stream", async () => {
+ render(
+ <MemoryRouter>
+ <AgentsPage />
+ </MemoryRouter>,
+ );
+
+ await waitFor(() => {
+ expect(fetchActivity).toHaveBeenCalled();
+ });
+
+ expect(screen.getByText("/tabs/tab_123/action")).toBeInTheDocument();
+ expect(screen.queryByText("/profiles")).not.toBeInTheDocument();
+ expect(screen.queryByText("/health")).not.toBeInTheDocument();
+ expect(screen.getByText(/1 events • 1 agents/)).toBeInTheDocument();
+ });
+});
diff --git a/dashboard/src/activities/AgentsPage.tsx b/dashboard/src/activities/AgentsPage.tsx
index e9802783..b621769c 100644
--- a/dashboard/src/activities/AgentsPage.tsx
+++ b/dashboard/src/activities/AgentsPage.tsx
@@ -1,144 +1,10 @@
-import { EmptyState } from "../components/atoms";
-import { AgentItem } from "../components/molecules";
-import { useAppStore } from "../stores/useAppStore";
-import ActivityLine from "./ActivityLine";
-
-const filters = [
- { key: "all", label: "All" },
- { key: "progress", label: "Progress" },
- { key: "tool_call", label: "Tool Calls" },
- { key: "navigate", label: "Navigate" },
- { key: "snapshot", label: "Snapshot" },
- { key: "action", label: "Actions" },
-];
+import AgentActivityWorkspace from "./AgentActivityWorkspace";
export default function AgentsPage() {
- const {
- agents,
- selectedAgentId,
- events,
- eventFilter,
- setSelectedAgentId,
- setEventFilter,
- } = useAppStore();
-
- const filteredEvents = events.filter((e) => {
- if (selectedAgentId && e.agentId !== selectedAgentId) return false;
- if (eventFilter === "all") return true;
- if (eventFilter === "progress" || eventFilter === "tool_call") {
- return e.channel === eventFilter;
- }
- if (eventFilter === "action") return e.type === "action";
- return e.type === eventFilter;
- });
-
return (
- <div className="flex h-full flex-col sm:flex-row">
- <div className="order-2 shrink-0 border-t border-border-subtle bg-bg-surface sm:hidden">
- <div className="flex items-center gap-2 overflow-x-auto px-4 py-3">
- <button
- className={`shrink-0 rounded-full px-4 py-2 text-sm font-medium transition-all ${
- !selectedAgentId
- ? "bg-primary text-white"
- : "bg-bg-elevated text-text-secondary hover:bg-bg-elevated/80"
- }`}
- onClick={() => setSelectedAgentId(null)}
- >
- All
- </button>
- {agents.map((agent) => (
- <button
- key={agent.id}
- className={`shrink-0 rounded-full px-4 py-2 text-sm font-medium transition-all ${
- selectedAgentId === agent.id
- ? "bg-primary text-white"
- : "bg-bg-elevated text-text-secondary hover:bg-bg-elevated/80"
- }`}
- onClick={() => setSelectedAgentId(agent.id)}
- >
- {agent.name || agent.id}
- </button>
- ))}
- </div>
- </div>
-
- <div className="flex flex-1 flex-col overflow-hidden">
- <div className="flex items-center justify-between border-b border-border-subtle bg-bg-surface px-4 py-3">
- <div>
- <div className="dashboard-section-label mb-1">Agent Stream</div>
- <h2 className="text-sm font-semibold text-text-secondary">
- Live Reasoning Feed
- </h2>
- </div>
- <div className="flex gap-1">
- {filters.map((f) => (
- <button
- key={f.key}
- className={`rounded-sm border px-2.5 py-1.5 text-xs font-semibold uppercase tracking-[0.08em] transition-all ${
- eventFilter === f.key
- ? "border-primary/30 bg-primary/10 text-primary"
- : "border-transparent text-text-muted hover:border-border-subtle hover:bg-bg-elevated hover:text-text-secondary"
- }`}
- onClick={() => setEventFilter(f.key)}
- >
- {f.label}
- </button>
- ))}
- </div>
- </div>
-
- <div className="flex-1 overflow-auto">
- {filteredEvents.length === 0 ? (
- <EmptyState title="Waiting for events..." icon="📡" />
- ) : (
- filteredEvents.map((event) => (
- <ActivityLine key={event.id} event={event} />
- ))
- )}
- </div>
- </div>
-
- <div className="order-1 hidden w-80 shrink-0 border-l border-border-subtle bg-bg-surface sm:block">
- <div className="border-b border-border-subtle px-4 py-3">
- <div className="dashboard-section-label mb-1">Agents</div>
- <h2 className="text-sm font-semibold text-text-secondary">
- Agent Workspace
- </h2>
- <p className="mt-2 text-xs leading-5 text-text-muted">
- Agent-centric layout foundation. Session drill-down can layer in
- next without changing the main stream area.
- </p>
- </div>
- <div className="p-2">
- {agents.length === 0 ? (
- <div className="py-8 text-center text-sm text-text-muted">
- <div className="mb-2 text-2xl">🦀</div>
- No agent activity observed yet
- </div>
- ) : (
- <div className="flex flex-col gap-1">
- <button
- className={`rounded-sm px-3 py-2 text-left text-sm transition-all ${
- !selectedAgentId
- ? "border border-primary/30 bg-primary/10 text-primary"
- : "border border-transparent text-text-muted hover:bg-bg-elevated"
- }`}
- onClick={() => setSelectedAgentId(null)}
- >
- All Agents
- </button>
- {agents.map((agent) => (
- <AgentItem
- key={agent.id}
- agent={agent}
- selected={selectedAgentId === agent.id}
- onClick={() => setSelectedAgentId(agent.id)}
- />
- ))}
- </div>
- )}
- </div>
- </div>
- </div>
+ <AgentActivityWorkspace
+ defaultSidebarTab="agents"
+ hiddenSources={["dashboard", "server"]}
+ />
);
}
diff --git a/dashboard/src/components/instances/InstanceListItem.test.tsx b/dashboard/src/components/instances/InstanceListItem.test.tsx
deleted file mode 100644
index 60fb218a..00000000
--- a/dashboard/src/components/instances/InstanceListItem.test.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import { render, screen } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-import { describe, it, expect, vi } from "vitest";
-import InstanceListItem from "./InstanceListItem";
-import type { Instance } from "../../generated/types";
-
-const mockInstance: Instance = {
- id: "inst_123",
- profileId: "prof_456",
- profileName: "test-profile",
- port: "9868",
- headless: false,
- status: "running",
- startTime: new Date().toISOString(),
- attached: false,
-};
-
-describe("InstanceListItem", () => {
- it("renders instance name and port", () => {
- render(
- <InstanceListItem
- instance={mockInstance}
- tabCount={5}
- selected={false}
- onClick={() => {}}
- />,
- );
-
- expect(screen.getByText("test-profile")).toBeInTheDocument();
- expect(screen.getByText(":9868 · 5 tabs")).toBeInTheDocument();
- });
-
- it("shows running status badge", () => {
- const { container } = render(
- <InstanceListItem
- instance={mockInstance}
- tabCount={0}
- selected={false}
- onClick={() => {}}
- />,
- );
-
- expect(container.querySelector(".bg-success")).toBeInTheDocument();
- });
-
- it("shows error status for errored instances", () => {
- const errorInstance = { ...mockInstance, status: "error" };
- const { container } = render(
- <InstanceListItem
- instance={errorInstance}
- tabCount={0}
- selected={false}
- onClick={() => {}}
- />,
- );
-
- expect(container.querySelector(".bg-destructive")).toBeInTheDocument();
- });
-
- it("applies selected styles when selected", () => {
- render(
- <InstanceListItem
- instance={mockInstance}
- tabCount={0}
- selected={true}
- onClick={() => {}}
- />,
- );
-
- const button = screen.getByRole("button");
- expect(button).toHaveClass("border-primary");
- });
-
- it("calls onClick when clicked", async () => {
- const handleClick = vi.fn();
- render(
- <InstanceListItem
- instance={mockInstance}
- tabCount={0}
- selected={false}
- onClick={handleClick}
- />,
- );
-
- await userEvent.click(screen.getByRole("button"));
- expect(handleClick).toHaveBeenCalledTimes(1);
- });
-});
diff --git a/dashboard/src/components/tabs/IdBadge.test.tsx b/dashboard/src/components/molecules/IdBadge.test.tsx
similarity index 100%
rename from dashboard/src/components/tabs/IdBadge.test.tsx
rename to dashboard/src/components/molecules/IdBadge.test.tsx
diff --git a/dashboard/src/components/tabs/IdBadge.tsx b/dashboard/src/components/molecules/IdBadge.tsx
similarity index 100%
rename from dashboard/src/components/tabs/IdBadge.tsx
rename to dashboard/src/components/molecules/IdBadge.tsx
diff --git a/dashboard/src/components/molecules/NavBar.tsx b/dashboard/src/components/molecules/NavBar.tsx
index dd5ec691..c745a235 100644
--- a/dashboard/src/components/molecules/NavBar.tsx
+++ b/dashboard/src/components/molecules/NavBar.tsx
@@ -13,7 +13,6 @@ interface Tab {
const tabs: Tab[] = [
{ id: "monitoring", path: "/dashboard/monitoring", label: "Monitoring" },
- { id: "activity", path: "/dashboard/activity", label: "Activity" },
{ id: "agents", path: "/dashboard/agents", label: "Agents" },
{ id: "profiles", path: "/dashboard/profiles", label: "Profiles" },
{ id: "settings", path: "/dashboard/settings", label: "Settings" },
diff --git a/dashboard/src/components/molecules/index.ts b/dashboard/src/components/molecules/index.ts
index 08d952a3..87e0b8df 100644
--- a/dashboard/src/components/molecules/index.ts
+++ b/dashboard/src/components/molecules/index.ts
@@ -2,11 +2,8 @@ export { default as TabsLayout } from "./TabsLayout";
export { default as EmptyView } from "./EmptyView";
export { default as NavBar } from "./NavBar";
export { default as CreateProfileModal } from "./CreateProfileModal";
-export { default as ProfileCard } from "../profiles/ProfileCard";
-export { default as ProfileDetailsPanel } from "../profiles/ProfileDetailsPanel";
export { default as StartInstanceModal } from "./StartInstanceModal";
export { default as ScreencastTile } from "../screencast/ScreencastTile";
-export { InstanceTabsPanel, TabItem } from "../tabs";
export { default as AgentItem } from "./AgentItem";
export { default as ActivityLine } from "../../activities/ActivityLine";
export { default as TabsChart } from "./TabsChart";
diff --git a/dashboard/src/components/instances/InstanceCard.tsx b/dashboard/src/instances/InstanceCard.tsx
similarity index 94%
rename from dashboard/src/components/instances/InstanceCard.tsx
rename to dashboard/src/instances/InstanceCard.tsx
index 3baf7a85..307d6f0c 100644
--- a/dashboard/src/components/instances/InstanceCard.tsx
+++ b/dashboard/src/instances/InstanceCard.tsx
@@ -1,5 +1,5 @@
-import { Card, Badge, Button, StatusDot } from "../atoms";
-import type { Instance } from "../../types";
+import { Card, Badge, Button, StatusDot } from "../components/atoms";
+import type { Instance } from "../types";
interface Props {
instance: Instance;
diff --git a/dashboard/src/components/instances/InstanceListItem.tsx b/dashboard/src/instances/InstanceListItem.tsx
similarity index 98%
rename from dashboard/src/components/instances/InstanceListItem.tsx
rename to dashboard/src/instances/InstanceListItem.tsx
index 584d4520..2710a7cc 100644
--- a/dashboard/src/components/instances/InstanceListItem.tsx
+++ b/dashboard/src/instances/InstanceListItem.tsx
@@ -1,4 +1,4 @@
-import type { Instance } from "../../generated/types";
+import type { Instance } from "../generated/types";
interface Props {
instance: Instance;
diff --git a/dashboard/src/pages/MonitoringPage.tsx b/dashboard/src/pages/MonitoringPage.tsx
index 2bdb7a4e..3b9dc6b8 100644
--- a/dashboard/src/pages/MonitoringPage.tsx
+++ b/dashboard/src/pages/MonitoringPage.tsx
@@ -3,8 +3,8 @@ import { useNavigate } from "react-router-dom";
import { useAppStore } from "../stores/useAppStore";
import { EmptyState, ErrorBoundary } from "../components/atoms";
import { TabsChart } from "../components/molecules";
-import InstanceListItem from "../components/instances/InstanceListItem";
-import InstanceTabsPanel from "../components/tabs/InstanceTabsPanel";
+import InstanceListItem from "../instances/InstanceListItem";
+import InstanceTabsPanel from "../tabs/InstanceTabsPanel";
import * as api from "../services/api";
export default function MonitoringPage() {
diff --git a/dashboard/src/pages/ProfilesPage.tsx b/dashboard/src/pages/ProfilesPage.tsx
index 0043d4a3..d588d46b 100644
--- a/dashboard/src/pages/ProfilesPage.tsx
+++ b/dashboard/src/pages/ProfilesPage.tsx
@@ -2,13 +2,13 @@ import { useEffect, useState, useMemo } from "react";
import { useLocation } from "react-router-dom";
import { useAppStore } from "../stores/useAppStore";
import { Toolbar, EmptyState, Button, Badge } from "../components/atoms";
+import * as api from "../services/api";
+import type { Profile } from "../generated/types";
import {
CreateProfileModal,
- ProfileDetailsPanel,
StartInstanceModal,
} from "../components/molecules";
-import * as api from "../services/api";
-import type { Profile } from "../generated/types";
+import ProfileDetailsPanel from "../profiles/ProfileDetailsPanel";
function getProfileKey(profile: Profile) {
return profile.id || profile.name;
@@ -206,7 +206,7 @@ export default function ProfilesPage() {
/>
) : (
<div className="flex h-full min-h-0 flex-col gap-4 lg:flex-row">
- <div className="dashboard-panel flex max-h-[22rem] w-full shrink-0 flex-col overflow-hidden lg:max-h-none lg:w-80">
+ <div className="dashboard-panel flex max-h-88 w-full shrink-0 flex-col overflow-hidden lg:max-h-none lg:w-80">
<div className="border-b border-border-subtle px-4 py-3">
<div className="dashboard-section-label mb-1">Profiles</div>
<div className="flex items-center justify-between gap-3">
diff --git a/dashboard/src/pages/SettingsPage.tsx b/dashboard/src/pages/SettingsPage.tsx
index 06352c3f..e233f111 100644
--- a/dashboard/src/pages/SettingsPage.tsx
+++ b/dashboard/src/pages/SettingsPage.tsx
@@ -1,180 +1,122 @@
-import type { FormEvent } from "react";
+import type { Dispatch, FormEvent, SetStateAction } from "react";
import { useEffect, useMemo, useState } from "react";
-import { useAppStore } from "../stores/useAppStore";
import { Button, Card, Input, Modal } from "../components/atoms";
-import * as api from "../services/api";
import { credentialUsername, storeTokenCredential } from "../services/auth";
+import * as api from "../services/api";
+import { useAppStore } from "../stores/useAppStore";
import type {
BackendConfig,
BackendConfigState,
- BackendIDPIConfig,
- BackendSecurityConfig,
LocalDashboardSettings,
} from "../types";
-
-type SectionId =
- | "dashboard"
- | "defaults"
- | "orchestration"
- | "security"
- | "security-idpi"
- | "profiles"
- | "network"
- | "browser"
- | "timeouts";
+import { BrowserSettingsSection } from "./settings/BrowserSettingsSection";
+import { DashboardSettingsSection } from "./settings/DashboardSettingsSection";
+import { DefaultsSettingsSection } from "./settings/DefaultsSettingsSection";
+import { NetworkSettingsSection } from "./settings/NetworkSettingsSection";
+import { OrchestrationSettingsSection } from "./settings/OrchestrationSettingsSection";
+import { ProfilesSettingsSection } from "./settings/ProfilesSettingsSection";
+import { SecurityIdpiSettingsSection } from "./settings/SecurityIdpiSettingsSection";
+import { SecuritySettingsSection } from "./settings/SecuritySettingsSection";
+import {
+ backendSaveNotice,
+ sections,
+ type SectionId,
+ type UpdateBackendSection,
+} from "./settings/settingsShared";
+import { TimeoutsSettingsSection } from "./settings/TimeoutsSettingsSection";
type PendingElevatedAction = "save" | null;
-const sections: Array<{
- id: SectionId;
- label: string;
- description: string;
-}> = [
- {
- id: "dashboard",
- label: "Dashboard",
- description: "Local monitoring and screencast preferences.",
- },
- {
- id: "defaults",
- label: "Instance Defaults",
- description: "How new managed browser instances launch.",
- },
- {
- id: "orchestration",
- label: "Orchestration",
- description: "Routing strategy, port range, and allocation policy.",
- },
- {
- id: "security",
- label: "Security",
- description: "Sensitive endpoint gates and access controls.",
+function renderActiveSection(
+ activeSection: SectionId,
+ options: {
+ apiTokenMissing: boolean;
+ attachWildcard: boolean;
+ backendConfig: BackendConfig;
+ backendState: BackendConfigState | null;
+ idpiDomainsConfigured: boolean;
+ idpiEnabled: boolean;
+ idpiWildcard: boolean;
+ localSettings: LocalDashboardSettings;
+ nonLoopbackBind: boolean;
+ sensitiveEndpointsEnabled: boolean;
+ setLocalSettings: Dispatch<SetStateAction<LocalDashboardSettings>>;
+ updateBackendSection: UpdateBackendSection;
},
- {
- id: "security-idpi",
- label: "Security IDPI",
- description: "Indirect prompt injection website and content defenses.",
- },
- {
- id: "profiles",
- label: "Profiles",
- description: "Shared profile storage and default profile behavior.",
- },
- {
- id: "network",
- label: "Network & Attach",
- description: "Server binding, auth, and attach policy.",
- },
- {
- id: "browser",
- label: "Browser Runtime",
- description: "Chrome binary, version, flags, and extensions.",
- },
- {
- id: "timeouts",
- label: "Timeouts",
- description: "Action, navigation, shutdown, and wait timing.",
- },
-];
-
-const fieldClass =
- "w-full rounded-sm border border-border-subtle bg-[rgb(var(--brand-surface-code-rgb)/0.72)] px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-all duration-150 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20";
-
-function backendSaveNotice(state: BackendConfigState | null): string {
- if (state?.restartRequired) {
- return "Backend config saved. Dynamic changes were applied where possible. Restart advised for server-level changes.";
+) {
+ switch (activeSection) {
+ case "dashboard":
+ return (
+ <DashboardSettingsSection
+ localSettings={options.localSettings}
+ setLocalSettings={options.setLocalSettings}
+ />
+ );
+ case "defaults":
+ return (
+ <DefaultsSettingsSection
+ backendConfig={options.backendConfig}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
+ case "orchestration":
+ return (
+ <OrchestrationSettingsSection
+ backendConfig={options.backendConfig}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
+ case "security":
+ return (
+ <SecuritySettingsSection
+ backendConfig={options.backendConfig}
+ sensitiveEndpointsEnabled={options.sensitiveEndpointsEnabled}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
+ case "security-idpi":
+ return (
+ <SecurityIdpiSettingsSection
+ backendConfig={options.backendConfig}
+ idpiDomainsConfigured={options.idpiDomainsConfigured}
+ idpiEnabled={options.idpiEnabled}
+ idpiWildcard={options.idpiWildcard}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
+ case "profiles":
+ return (
+ <ProfilesSettingsSection
+ backendConfig={options.backendConfig}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
+ case "network":
+ return (
+ <NetworkSettingsSection
+ apiTokenMissing={options.apiTokenMissing}
+ attachWildcard={options.attachWildcard}
+ backendConfig={options.backendConfig}
+ backendState={options.backendState}
+ nonLoopbackBind={options.nonLoopbackBind}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
+ case "browser":
+ return (
+ <BrowserSettingsSection
+ backendConfig={options.backendConfig}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
+ case "timeouts":
+ return (
+ <TimeoutsSettingsSection
+ backendConfig={options.backendConfig}
+ updateBackendSection={options.updateBackendSection}
+ />
+ );
}
- return "Backend config saved. Dynamic changes were applied where possible.";
-}
-
-const selectClass =
- "rounded-sm border border-border-subtle bg-[rgb(var(--brand-surface-code-rgb)/0.72)] px-3 py-2 text-sm text-text-primary transition-all duration-150 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20";
-
-type SecurityEndpointKey = Exclude<keyof BackendSecurityConfig, "attach">;
-type IDPIToggleKey = Exclude<
- keyof BackendIDPIConfig,
- "allowedDomains" | "customPatterns"
->;
-
-const securityEndpointRows = [
- ["allowEvaluate", "Allow evaluate"],
- ["allowMacro", "Allow macro"],
- ["allowScreencast", "Allow screencast"],
- ["allowDownload", "Allow download"],
- ["allowUpload", "Allow upload"],
-] as const satisfies ReadonlyArray<readonly [SecurityEndpointKey, string]>;
-
-const idpiToggleRows = [
- ["enabled", "Enable IDPI", "Turn on indirect prompt injection defenses."],
- [
- "strictMode",
- "Strict mode",
- "Block disallowed domains and suspicious content instead of only warning.",
- ],
- [
- "scanContent",
- "Scan content",
- "Inspect extracted text and snapshots for prompt-injection patterns.",
- ],
- [
- "wrapContent",
- "Wrap content",
- "Mark returned page text as untrusted content for downstream consumers.",
- ],
-] as const satisfies ReadonlyArray<readonly [IDPIToggleKey, string, string]>;
-
-function csvToList(value: string): string[] {
- return value
- .split(",")
- .map((item) => item.trim())
- .filter(Boolean);
-}
-
-function listToCsv(value: string[]): string {
- return value.join(", ");
-}
-
-function SectionCard({
- title,
- description,
- children,
-}: {
- title: string;
- description: string;
- children: React.ReactNode;
-}) {
- return (
- <Card className="p-5">
- <div className="mb-5 border-b border-border-subtle pb-4">
- <div className="dashboard-section-label mb-2">Settings</div>
- <h3 className="text-lg font-semibold text-text-primary">{title}</h3>
- <p className="mt-2 max-w-2xl text-sm leading-6 text-text-muted">
- {description}
- </p>
- </div>
- <div className="space-y-4">{children}</div>
- </Card>
- );
-}
-
-function SettingRow({
- label,
- description,
- children,
-}: {
- label: string;
- description: string;
- children: React.ReactNode;
-}) {
- return (
- <div className="flex flex-col gap-3 rounded-sm border border-border-subtle bg-black/10 p-4 lg:flex-row lg:items-center lg:justify-between">
- <div className="max-w-xl">
- <div className="text-sm font-medium text-text-primary">{label}</div>
- <p className="mt-1 text-xs leading-5 text-text-muted">{description}</p>
- </div>
- <div className="w-full max-w-md">{children}</div>
- </div>
- );
}
export default function SettingsPage() {
@@ -218,13 +160,12 @@ export default function SettingsPage() {
setServerInfo(health);
}
} catch (e) {
- const message =
- e instanceof Error ? e.message : "Failed to load settings";
- setError(message);
+ setError(e instanceof Error ? e.message : "Failed to load settings");
} finally {
setLoading(false);
}
};
+
load();
}, [setServerInfo]);
@@ -242,8 +183,8 @@ export default function SettingsPage() {
),
[backendConfig, backendState],
);
- const hasBackendChanges = hasBackendConfigChanges;
+ const hasBackendChanges = hasBackendConfigChanges;
const hasChanges = hasDashboardChanges || hasBackendChanges;
const restartRequired =
backendState?.restartRequired || serverInfo?.restartRequired || false;
@@ -277,10 +218,7 @@ export default function SettingsPage() {
)
: false;
- const updateBackendSection = <K extends keyof BackendConfig>(
- section: K,
- patch: Partial<BackendConfig[K]>,
- ) => {
+ const updateBackendSection: UpdateBackendSection = (section, patch) => {
setBackendConfig((current) =>
current
? {
@@ -301,7 +239,9 @@ export default function SettingsPage() {
};
const handleSave = async () => {
- if (!hasChanges || !backendConfig) return;
+ if (!hasChanges || !backendConfig) {
+ return;
+ }
setSaving(true);
setError("");
@@ -340,9 +280,7 @@ export default function SettingsPage() {
setPendingElevatedAction("save");
return;
}
- const message =
- e instanceof Error ? e.message : "Failed to save settings";
- setError(message);
+ setError(e instanceof Error ? e.message : "Failed to save settings");
} finally {
setSaving(false);
}
@@ -377,9 +315,9 @@ export default function SettingsPage() {
await handleSave();
}
} catch (e) {
- const message =
- e instanceof Error ? e.message : "Failed to verify API token";
- setElevationError(message);
+ setElevationError(
+ e instanceof Error ? e.message : "Failed to verify API token",
+ );
} finally {
setElevating(false);
}
@@ -436,6 +374,7 @@ export default function SettingsPage() {
</div>
)}
</div>
+
<Modal
open={pendingElevatedAction !== null}
onClose={closeElevationPrompt}
@@ -535,1070 +474,20 @@ export default function SettingsPage() {
<div className="text-sm text-text-muted">Loading settings…</div>
</Card>
) : (
- <>
- {activeSection === "dashboard" && (
- <SectionCard
- title="Dashboard Preferences"
- description="These controls affect this dashboard UI only. They are stored locally in your browser and do not require a backend restart."
- >
- <SettingRow
- label="Screencast frame rate"
- description="Controls how often live previews request new frames."
- >
- <div className="flex items-center gap-3">
- <input
- type="range"
- min={1}
- max={15}
- value={localSettings.screencast.fps}
- onChange={(e) =>
- setLocalSettings({
- ...localSettings,
- screencast: {
- ...localSettings.screencast,
- fps: Number(e.target.value),
- },
- })
- }
- className="w-full"
- />
- <span className="dashboard-mono w-16 text-right text-sm text-text-secondary">
- {localSettings.screencast.fps} fps
- </span>
- </div>
- </SettingRow>
- <SettingRow
- label="Screencast quality"
- description="JPEG quality for tab preview streams."
- >
- <div className="flex items-center gap-3">
- <input
- type="range"
- min={10}
- max={80}
- value={localSettings.screencast.quality}
- onChange={(e) =>
- setLocalSettings({
- ...localSettings,
- screencast: {
- ...localSettings.screencast,
- quality: Number(e.target.value),
- },
- })
- }
- className="w-full"
- />
- <span className="dashboard-mono w-16 text-right text-sm text-text-secondary">
- {localSettings.screencast.quality}%
- </span>
- </div>
- </SettingRow>
- <SettingRow
- label="Screencast width"
- description="Maximum preview width for live tiles."
- >
- <select
- value={localSettings.screencast.maxWidth}
- onChange={(e) =>
- setLocalSettings({
- ...localSettings,
- screencast: {
- ...localSettings.screencast,
- maxWidth: Number(e.target.value),
- },
- })
- }
- className={selectClass}
- >
- {[400, 600, 800, 1024, 1280].map((width) => (
- <option key={width} value={width}>
- {width}px
- </option>
- ))}
- </select>
- </SettingRow>
- <SettingRow
- label="Memory metrics"
- description="Enable per-tab heap collection in the dashboard. Useful for debugging, but heavier."
- >
- <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
- <input
- type="checkbox"
- checked={localSettings.monitoring.memoryMetrics}
- onChange={(e) =>
- setLocalSettings({
- ...localSettings,
- monitoring: {
- ...localSettings.monitoring,
- memoryMetrics: e.target.checked,
- },
- })
- }
- className="h-4 w-4"
- />
- Enable
- </label>
- </SettingRow>
- <SettingRow
- label="Polling interval"
- description="How frequently the dashboard asks the backend for fresh metrics."
- >
- <div className="flex items-center gap-3">
- <input
- type="range"
- min={5}
- max={120}
- step={5}
- value={localSettings.monitoring.pollInterval}
- onChange={(e) =>
- setLocalSettings({
- ...localSettings,
- monitoring: {
- ...localSettings.monitoring,
- pollInterval: Number(e.target.value),
- },
- })
- }
- className="w-full"
- />
- <span className="dashboard-mono w-16 text-right text-sm text-text-secondary">
- {localSettings.monitoring.pollInterval}s
- </span>
- </div>
- </SettingRow>
- <SettingRow
- label="Reasoning output"
- description="Choose whether the live agent feed shows tool calls, progress updates, or both."
- >
- <select
- value={localSettings.agents.reasoningMode}
- onChange={(e) =>
- setLocalSettings({
- ...localSettings,
- agents: {
- ...localSettings.agents,
- reasoningMode: e.target.value as
- | "tool_calls"
- | "progress"
- | "both",
- },
- })
- }
- className={selectClass}
- >
- <option value="tool_calls">Tool calls only</option>
- <option value="progress">Progress only</option>
- <option value="both">Both</option>
- </select>
- </SettingRow>
- </SectionCard>
- )}
-
- {activeSection === "defaults" && (
- <SectionCard
- title="Instance Defaults"
- description="These values are written to config and used for new managed instances. Existing running instances keep their current runtime."
- >
- <SettingRow
- label="Mode"
- description="Default browser mode for new launches."
- >
- <select
- value={backendConfig.instanceDefaults.mode}
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- mode: e.target
- .value as BackendConfig["instanceDefaults"]["mode"],
- })
- }
- className={selectClass}
- >
- <option value="headless">Headless</option>
- <option value="headed">Headed</option>
- </select>
- </SettingRow>
- <SettingRow
- label="Stealth level"
- description="Bot detection evasion profile. Higher levels may affect error monitoring and certain browser features."
- >
- <div className="space-y-2">
- <select
- value={backendConfig.instanceDefaults.stealthLevel}
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- stealthLevel: e.target
- .value as BackendConfig["instanceDefaults"]["stealthLevel"],
- })
- }
- className={selectClass}
- >
- <option value="light">Light</option>
- <option value="medium">Medium</option>
- <option value="full">Full</option>
- </select>
- <div className="rounded-sm border border-border-subtle bg-black/10 px-3 py-2 text-xs leading-5 text-text-muted">
- {backendConfig.instanceDefaults.stealthLevel ===
- "light" && (
- <div className="space-y-2">
- <div>
- <strong className="text-text-secondary">
- Light:
- </strong>{" "}
- Default baseline stealth. Keeps the lowest-risk
- launch and JS contract while hiding basic
- automation markers.
- </div>
- <div className="text-success/80">
- ✓ Default product security baseline
- </div>
- <div className="text-success/80">
- ✓ No intentional API realism or security tradeoff
- </div>
- </div>
- )}
- {backendConfig.instanceDefaults.stealthLevel ===
- "medium" && (
- <div className="space-y-2">
- <div>
- <strong className="text-warning">Medium:</strong>{" "}
- Non-default risk mode. Adds Client Hints,
- `chrome.runtime` shims, iframe propagation, stack
- filtering, and native-looking function masking to
- improve anti-bot compatibility.
- </div>
- <div className="text-warning/80">
- ⚠ Alters browser-visible APIs and error/stack
- behavior. Monitoring and debugging tools may see
- different results.
- </div>
- <div className="text-warning/80">
- ⚠ Permissions and compatibility shims can return
- intentionally altered values. Do not use this as
- the default safety baseline.
- </div>
- <div className="text-warning/80">
- ⚠ Reports that require explicitly enabling Medium
- should be treated as opt-in risk acceptance, not
- default-path behavior.
- </div>
- </div>
- )}
- {backendConfig.instanceDefaults.stealthLevel ===
- "full" && (
- <div className="space-y-2">
- <div>
- <strong className="text-destructive">
- Full:
- </strong>{" "}
- Highest-risk non-default mode. Adds graphics,
- canvas, audio, system-color, and WebRTC
- alterations on top of Medium.
- </div>
- <div className="text-destructive/80">
- ⚠ Browser output is intentionally less native and
- less stable. Rendering, media, and networking
- behavior may break or drift from real Chrome.
- </div>
- <div className="text-destructive/80">
- ⚠ This mode is not an acceptable default security
- posture. Only enable it when you explicitly accept
- the tradeoff surface.
- </div>
- <div className="text-destructive/80">
- ⚠ Reports that depend on enabling Full should be
- triaged as non-default operator risk unless a
- default-path bypass is shown.
- </div>
- <div className="text-destructive/80">
- ⚠ WebRTC, WebGL, canvas, and audio behavior can
- all diverge from baseline Chrome.
- </div>
- </div>
- )}
- </div>
- </div>
- </SettingRow>
- <SettingRow
- label="Tab eviction policy"
- description="How PinchTab behaves when a managed instance reaches its tab limit."
- >
- <select
- value={backendConfig.instanceDefaults.tabEvictionPolicy}
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- tabEvictionPolicy: e.target
- .value as BackendConfig["instanceDefaults"]["tabEvictionPolicy"],
- })
- }
- className={selectClass}
- >
- <option value="reject">Reject new tabs</option>
- <option value="close_oldest">Close oldest</option>
- <option value="close_lru">
- Close least recently used
- </option>
- </select>
- </SettingRow>
- <SettingRow
- label="Max tabs"
- description="Maximum number of tabs per managed instance."
- >
- <input
- type="number"
- min={1}
- value={backendConfig.instanceDefaults.maxTabs}
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- maxTabs: Number(e.target.value),
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Max parallel tabs"
- description="Set to 0 to auto-detect from CPU count."
- >
- <input
- type="number"
- min={0}
- value={backendConfig.instanceDefaults.maxParallelTabs}
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- maxParallelTabs: Number(e.target.value),
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Timezone"
- description="Optional timezone override for launched instances."
- >
- <input
- value={backendConfig.instanceDefaults.timezone}
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- timezone: e.target.value,
- })
- }
- placeholder="Europe/Rome"
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="User agent"
- description="Optional override applied to new managed instances."
- >
- <input
- value={backendConfig.instanceDefaults.userAgent}
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- userAgent: e.target.value,
- })
- }
- placeholder="Custom user agent"
- className={fieldClass}
- />
- </SettingRow>
- {[
- ["blockImages", "Block images"],
- ["blockMedia", "Block media"],
- ["blockAds", "Block ads"],
- ["noAnimations", "Disable CSS animations"],
- ["noRestore", "Skip session restore"],
- ].map(([key, label]) => (
- <SettingRow
- key={key}
- label={label}
- description="Applies to newly launched managed instances."
- >
- <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
- <input
- type="checkbox"
- checked={
- backendConfig.instanceDefaults[
- key as keyof BackendConfig["instanceDefaults"]
- ] as boolean
- }
- onChange={(e) =>
- updateBackendSection("instanceDefaults", {
- [key]: e.target.checked,
- } as Partial<BackendConfig["instanceDefaults"]>)
- }
- className="h-4 w-4"
- />
- Enable
- </label>
- </SettingRow>
- ))}
- </SectionCard>
- )}
-
- {activeSection === "orchestration" && (
- <SectionCard
- title="Orchestration"
- description="Port range and allocation policy can be applied immediately for future launches. Strategy and restart-policy changes require a dashboard restart because strategy routes and lifecycle state are registered at startup."
- >
- <SettingRow
- label="Strategy"
- description="Controls instance lifecycle and how shorthand routes are routed."
- >
- <select
- value={backendConfig.multiInstance.strategy}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- strategy: e.target
- .value as BackendConfig["multiInstance"]["strategy"],
- })
- }
- className={selectClass}
- >
- <option value="always-on">Always on</option>
- <option value="simple">Simple</option>
- <option value="explicit">Explicit</option>
- <option value="simple-autorestart">
- Simple autorestart
- </option>
- <option value="no-instance">No instance (hub)</option>
- </select>
- <div className="mt-2 text-[11px] leading-relaxed text-text-muted">
- {backendConfig.multiInstance.strategy === "always-on" &&
- "Launches a default instance at boot and relaunches on crash."}
- {backendConfig.multiInstance.strategy === "simple" &&
- "Launches one instance on first request. No auto-restart."}
- {backendConfig.multiInstance.strategy === "explicit" &&
- "All instances managed via API. No automatic launches."}
- {backendConfig.multiInstance.strategy ===
- "simple-autorestart" &&
- "Launches on first request and relaunches on crash."}
- {backendConfig.multiInstance.strategy === "no-instance" &&
- "No local Chrome processes. Acts as a hub for remote bridges only."}
- </div>
- </SettingRow>
- <SettingRow
- label="Allocation policy"
- description="Determines how running instances are chosen for shorthand requests."
- >
- <select
- value={backendConfig.multiInstance.allocationPolicy}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- allocationPolicy: e.target
- .value as BackendConfig["multiInstance"]["allocationPolicy"],
- })
- }
- className={selectClass}
- >
- <option value="fcfs">First available</option>
- <option value="round_robin">Round robin</option>
- <option value="random">Random</option>
- </select>
- </SettingRow>
- <SettingRow
- label="Instance port start"
- description="Lower bound for auto-allocated instance ports."
- >
- <input
- type="number"
- min={1}
- value={backendConfig.multiInstance.instancePortStart}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- instancePortStart: Number(e.target.value),
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Instance port end"
- description="Upper bound for auto-allocated instance ports."
- >
- <input
- type="number"
- min={1}
- value={backendConfig.multiInstance.instancePortEnd}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- instancePortEnd: Number(e.target.value),
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- {(backendConfig.multiInstance.strategy === "always-on" ||
- backendConfig.multiInstance.strategy ===
- "simple-autorestart") && (
- <>
- <SettingRow
- label="Max restarts"
- description="Maximum restart attempts. Use -1 for unlimited, 0 for no restarts."
- >
- <input
- type="number"
- min={-1}
- value={
- backendConfig.multiInstance.restart.maxRestarts
- }
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- maxRestarts: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Initial backoff"
- description="Delay in seconds before the first restart attempt."
- >
- <input
- type="number"
- min={1}
- value={
- backendConfig.multiInstance.restart.initBackoffSec
- }
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- initBackoffSec: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Max backoff"
- description="Upper bound in seconds for exponential restart backoff."
- >
- <input
- type="number"
- min={1}
- value={
- backendConfig.multiInstance.restart.maxBackoffSec
- }
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- maxBackoffSec: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Stable after"
- description="Seconds the instance must stay healthy before the restart counter resets."
- >
- <input
- type="number"
- min={1}
- value={
- backendConfig.multiInstance.restart.stableAfterSec
- }
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- stableAfterSec: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- </>
- )}
- </SectionCard>
- )}
-
- {activeSection === "security" && (
- <SectionCard
- title="Security"
- description="These controls define what risky capabilities PinchTab exposes."
- >
- <div
- className={`rounded-sm px-4 py-3 text-sm leading-6 ${
- sensitiveEndpointsEnabled
- ? "border border-destructive/35 bg-destructive/10 text-destructive"
- : "border border-warning/25 bg-warning/10 text-warning"
- }`}
- >
- {sensitiveEndpointsEnabled
- ? "One or more sensitive endpoint families are enabled. Features like script execution, downloads, uploads, and live capture can expose high-risk capabilities. Only enable them in trusted environments. You are responsible for securing network access, authentication, and downstream use."
- : "These endpoint families can expose high-risk capabilities when enabled. Only turn them on in trusted environments, and only when you accept responsibility for network access, authentication, and downstream use."}
- </div>
- {securityEndpointRows.map(([key, label]) => (
- <SettingRow
- key={key}
- label={label}
- description="Controls whether the corresponding endpoint family is enabled."
- >
- <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
- <input
- type="checkbox"
- checked={backendConfig.security[key]}
- onChange={(e) =>
- updateBackendSection("security", {
- [key]: e.target.checked,
- } as Partial<
- Pick<BackendSecurityConfig, SecurityEndpointKey>
- >)
- }
- className="h-4 w-4"
- />
- Enable
- </label>
- </SettingRow>
- ))}
- </SectionCard>
- )}
-
- {activeSection === "security-idpi" && (
- <SectionCard
- title="Security IDPI"
- description="Indirect prompt injection controls restrict which websites are allowed and add protections around extracted content before it reaches downstream automation."
- >
- <div
- className={`mb-4 rounded-sm px-4 py-3 text-sm leading-6 ${
- !idpiEnabled || !idpiDomainsConfigured
- ? "border border-destructive/35 bg-destructive/10 text-destructive"
- : idpiWildcard
- ? "border border-warning/25 bg-warning/10 text-warning"
- : "border border-success/25 bg-success/10 text-success"
- }`}
- >
- {!idpiEnabled
- ? "IDPI is disabled. Browser content is not being filtered by website allowlist or content protections."
- : !idpiDomainsConfigured
- ? "The website whitelist is not set to a restricted domain list. This is the main IDPI defense and should be configured."
- : idpiWildcard
- ? "The website whitelist contains '*', which effectively disables domain restriction."
- : "IDPI is enforcing a specific website whitelist and content protections."}
- </div>
- {idpiToggleRows.map(([key, label, description]) => (
- <SettingRow
- key={key}
- label={label}
- description={description}
- >
- <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
- <input
- type="checkbox"
- checked={backendConfig.security.idpi[key]}
- onChange={(e) =>
- updateBackendSection("security", {
- idpi: {
- ...backendConfig.security.idpi,
- [key]: e.target.checked,
- },
- })
- }
- className="h-4 w-4"
- />
- Enable
- </label>
- </SettingRow>
- ))}
- <SettingRow
- label="Allowed websites"
- description="Comma-separated domain allowlist for web content. Use exact hosts or patterns like *.example.com."
- >
- <div className="space-y-2">
- <input
- value={listToCsv(
- backendConfig.security.idpi.allowedDomains,
- )}
- onChange={(e) =>
- updateBackendSection("security", {
- idpi: {
- ...backendConfig.security.idpi,
- allowedDomains: csvToList(e.target.value),
- },
- })
- }
- className={fieldClass}
- placeholder="127.0.0.1, localhost, ::1"
- />
- <div className="rounded-sm border border-warning/25 bg-warning/10 px-3 py-2 text-xs leading-5 text-warning">
- Keep this list narrow. Empty or wildcard entries weaken
- the main IDPI boundary. Allowing non-local or
- non-trusted sites increases browser attack surface even
- when IDPI is enabled.
- </div>
- </div>
- </SettingRow>
- <SettingRow
- label="Custom patterns"
- description="Optional comma-separated phrases to treat as suspicious prompt-injection content."
- >
- <input
- value={listToCsv(
- backendConfig.security.idpi.customPatterns,
- )}
- onChange={(e) =>
- updateBackendSection("security", {
- idpi: {
- ...backendConfig.security.idpi,
- customPatterns: csvToList(e.target.value),
- },
- })
- }
- className={fieldClass}
- placeholder="ignore previous instructions, exfiltrate data"
- />
- </SettingRow>
- </SectionCard>
- )}
-
- {activeSection === "profiles" && (
- <SectionCard
- title="Profiles"
- description="Profile storage is host-level. Changing the base directory requires restart because the profile manager and orchestrator are created with it at boot."
- >
- <SettingRow
- label="Profiles base directory"
- description="Root directory where browser profiles are stored."
- >
- <input
- value={backendConfig.profiles.baseDir}
- onChange={(e) =>
- updateBackendSection("profiles", {
- baseDir: e.target.value,
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Default profile"
- description="Profile name used when the server needs an implicit default."
- >
- <input
- value={backendConfig.profiles.defaultProfile}
- onChange={(e) =>
- updateBackendSection("profiles", {
- defaultProfile: e.target.value,
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- </SectionCard>
- )}
-
- {activeSection === "network" && (
- <SectionCard
- title="Network & Attach"
- description="Port and bind changes require a restart. API token management is handled outside the dashboard."
- >
- <SettingRow
- label="Server port"
- description="HTTP port for the dashboard process."
- >
- <input
- value={backendConfig.server.port}
- onChange={(e) =>
- updateBackendSection("server", { port: e.target.value })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Bind address"
- description="Network interface the dashboard process binds to. Keeping 127.0.0.1 or localhost limits direct reachability to the local machine."
- >
- <div className="space-y-2">
- <input
- value={backendConfig.server.bind}
- onChange={(e) =>
- updateBackendSection("server", {
- bind: e.target.value,
- })
- }
- className={fieldClass}
- />
- {nonLoopbackBind ? (
- <div className="rounded-sm border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs leading-5 text-destructive/80">
- A non-loopback bind is a documented, non-default,
- security-reducing configuration change. It may expose
- the server beyond the local machine unless another
- network boundary still restricts access. Keep a token
- set and review proxy or port-publishing behavior
- explicitly.
- </div>
- ) : (
- <div className="rounded-sm border border-warning/25 bg-warning/10 px-3 py-2 text-xs leading-5 text-warning">
- Loopback bind keeps direct server reachability local.
- Moving to <code>0.0.0.0</code> or another non-local
- address widens the trust boundary.
- </div>
- )}
- </div>
- </SettingRow>
- <SettingRow
- label="API token"
- description="Bearer token required by authenticated requests when set. The dashboard never returns it and does not manage it."
- >
- <div className="space-y-2">
- <div className="text-xs leading-5 text-text-muted">
- {backendState?.tokenConfigured
- ? "Token configured. Manage rotation through the CLI or config file; the current value is never returned by the server."
- : "No token configured. Set one through the CLI or config file."}
- </div>
- {apiTokenMissing && (
- <div className="rounded-sm border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs leading-5 text-destructive">
- No API token is set. Anyone who can reach this server
- can access exposed endpoints. Keep it on trusted local
- networks only, or configure a strong token through the
- CLI or config file. You are responsible for protecting
- access.
- </div>
- )}
- </div>
- </SettingRow>
- <SettingRow
- label="State directory"
- description="Base state path used by managed child instances."
- >
- <input
- value={backendConfig.server.stateDir}
- onChange={(e) =>
- updateBackendSection("server", {
- stateDir: e.target.value,
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Trust proxy headers"
- description="Trust X-Forwarded-Proto, X-Forwarded-Host, and Forwarded headers for origin checks. Enable only when PinchTab runs behind a trusted reverse proxy (e.g. Caddy, nginx)."
- >
- <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
- <input
- type="checkbox"
- checked={
- backendConfig.server.trustProxyHeaders ?? false
- }
- onChange={(e) =>
- updateBackendSection("server", {
- trustProxyHeaders: e.target.checked,
- })
- }
- className="accent-primary"
- />
- {backendConfig.server.trustProxyHeaders
- ? "Enabled"
- : "Disabled"}
- </label>
- </SettingRow>
- <SettingRow
- label="Allow attach"
- description="Permit attaching PinchTab to externally managed Chrome sessions."
- >
- <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
- <input
- type="checkbox"
- checked={backendConfig.security.attach.enabled}
- onChange={(e) =>
- updateBackendSection("security", {
- attach: {
- ...backendConfig.security.attach,
- enabled: e.target.checked,
- },
- })
- }
- className="h-4 w-4"
- />
- Enable
- </label>
- </SettingRow>
- <SettingRow
- label="Allowed attach hosts"
- description={
- 'Comma-separated host allowlist for attach requests. Only include hosts you control and trust. Using "*" disables host allowlisting.'
- }
- >
- <div className="space-y-2">
- <input
- value={listToCsv(
- backendConfig.security.attach.allowHosts,
- )}
- onChange={(e) =>
- updateBackendSection("security", {
- attach: {
- ...backendConfig.security.attach,
- allowHosts: csvToList(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- {attachWildcard ? (
- <div className="rounded-sm border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs leading-5 text-destructive/80">
- <code>allowHosts: ["*"]</code> is a documented,
- non-default, security-reducing override. It disables
- host allowlisting entirely and allows remote attach
- requests to any reachable host with an allowed scheme.
- Use it only on isolated, operator-controlled networks.
- </div>
- ) : (
- <div className="rounded-sm border border-warning/25 bg-warning/10 px-3 py-2 text-xs leading-5 text-warning">
- Hosts in this allowlist may be used for remote attach
- requests. Broad or untrusted entries expand the trust
- boundary and can expose external Chrome sessions and
- browser contents.
- </div>
- )}
- </div>
- </SettingRow>
- <SettingRow
- label="Allowed attach schemes"
- description="Comma-separated scheme allowlist, usually ws and wss."
- >
- <input
- value={listToCsv(
- backendConfig.security.attach.allowSchemes,
- )}
- onChange={(e) =>
- updateBackendSection("security", {
- attach: {
- ...backendConfig.security.attach,
- allowSchemes: csvToList(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- </SectionCard>
- )}
-
- {activeSection === "browser" && (
- <SectionCard
- title="Browser Runtime"
- description="These settings are written into the generated child config for new managed instances."
- >
- <SettingRow
- label="Chrome version"
- description="Version string used in generated UA/fingerprint defaults."
- >
- <input
- value={backendConfig.browser.version}
- onChange={(e) =>
- updateBackendSection("browser", {
- version: e.target.value,
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Chrome binary"
- description="Optional path override for the Chrome executable."
- >
- <input
- value={backendConfig.browser.binary}
- onChange={(e) =>
- updateBackendSection("browser", {
- binary: e.target.value,
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Extra flags"
- description="Additional Chrome flags appended when launching managed instances."
- >
- <input
- value={backendConfig.browser.extraFlags}
- onChange={(e) =>
- updateBackendSection("browser", {
- extraFlags: e.target.value,
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Extension paths"
- description="Comma-separated extension directories to load."
- >
- <input
- value={listToCsv(backendConfig.browser.extensionPaths)}
- onChange={(e) =>
- updateBackendSection("browser", {
- extensionPaths: csvToList(e.target.value),
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- </SectionCard>
- )}
-
- {activeSection === "timeouts" && (
- <SectionCard
- title="Timeouts"
- description="Runtime timing defaults written into new child configs. Existing running instances keep their current timeouts."
- >
- {[
- [
- "actionSec",
- "Action timeout",
- "Maximum time for action requests.",
- ],
- [
- "navigateSec",
- "Navigate timeout",
- "Maximum time for navigation requests.",
- ],
- [
- "shutdownSec",
- "Shutdown timeout",
- "Grace period before force-closing a child process.",
- ],
- [
- "waitNavMs",
- "Wait-after-navigation delay",
- "Post-navigation stabilization delay in milliseconds.",
- ],
- ].map(([key, label, description]) => (
- <SettingRow
- key={key}
- label={label}
- description={description}
- >
- <input
- type="number"
- min={0}
- value={
- backendConfig.timeouts[
- key as keyof BackendConfig["timeouts"]
- ]
- }
- onChange={(e) =>
- updateBackendSection("timeouts", {
- [key]: Number(e.target.value),
- } as Partial<BackendConfig["timeouts"]>)
- }
- className={fieldClass}
- />
- </SettingRow>
- ))}
- </SectionCard>
- )}
- </>
+ renderActiveSection(activeSection, {
+ apiTokenMissing,
+ attachWildcard,
+ backendConfig,
+ backendState,
+ idpiDomainsConfigured,
+ idpiEnabled,
+ idpiWildcard,
+ localSettings,
+ nonLoopbackBind,
+ sensitiveEndpointsEnabled,
+ setLocalSettings,
+ updateBackendSection,
+ })
)}
</div>
</div>
diff --git a/dashboard/src/pages/settings/BrowserSettingsSection.tsx b/dashboard/src/pages/settings/BrowserSettingsSection.tsx
new file mode 100644
index 00000000..af170741
--- /dev/null
+++ b/dashboard/src/pages/settings/BrowserSettingsSection.tsx
@@ -0,0 +1,78 @@
+import type { BackendConfig } from "../../types";
+import type { UpdateBackendSection } from "./settingsShared";
+import { csvToList, fieldClass, listToCsv } from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface BrowserSettingsSectionProps {
+ backendConfig: BackendConfig;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function BrowserSettingsSection({
+ backendConfig,
+ updateBackendSection,
+}: BrowserSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Browser Runtime"
+ description="These settings are written into the generated child config for new managed instances."
+ >
+ <SettingRow
+ label="Chrome version"
+ description="Version string used in generated UA/fingerprint defaults."
+ >
+ <input
+ value={backendConfig.browser.version}
+ onChange={(e) =>
+ updateBackendSection("browser", {
+ version: e.target.value,
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Chrome binary"
+ description="Optional path override for the Chrome executable."
+ >
+ <input
+ value={backendConfig.browser.binary}
+ onChange={(e) =>
+ updateBackendSection("browser", {
+ binary: e.target.value,
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Extra flags"
+ description="Additional Chrome flags appended when launching managed instances."
+ >
+ <input
+ value={backendConfig.browser.extraFlags}
+ onChange={(e) =>
+ updateBackendSection("browser", {
+ extraFlags: e.target.value,
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Extension paths"
+ description="Comma-separated extension directories to load."
+ >
+ <input
+ value={listToCsv(backendConfig.browser.extensionPaths)}
+ onChange={(e) =>
+ updateBackendSection("browser", {
+ extensionPaths: csvToList(e.target.value),
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/DashboardSettingsSection.tsx b/dashboard/src/pages/settings/DashboardSettingsSection.tsx
new file mode 100644
index 00000000..55515f47
--- /dev/null
+++ b/dashboard/src/pages/settings/DashboardSettingsSection.tsx
@@ -0,0 +1,172 @@
+import type { Dispatch, SetStateAction } from "react";
+import type { LocalDashboardSettings } from "../../types";
+import { selectClass } from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface DashboardSettingsSectionProps {
+ localSettings: LocalDashboardSettings;
+ setLocalSettings: Dispatch<SetStateAction<LocalDashboardSettings>>;
+}
+
+export function DashboardSettingsSection({
+ localSettings,
+ setLocalSettings,
+}: DashboardSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Dashboard Preferences"
+ description="These controls affect this dashboard UI only. They are stored locally in your browser and do not require a backend restart."
+ >
+ <SettingRow
+ label="Screencast frame rate"
+ description="Controls how often live previews request new frames."
+ >
+ <div className="flex items-center gap-3">
+ <input
+ type="range"
+ min={1}
+ max={15}
+ value={localSettings.screencast.fps}
+ onChange={(e) =>
+ setLocalSettings((current) => ({
+ ...current,
+ screencast: {
+ ...current.screencast,
+ fps: Number(e.target.value),
+ },
+ }))
+ }
+ className="w-full"
+ />
+ <span className="dashboard-mono w-16 text-right text-sm text-text-secondary">
+ {localSettings.screencast.fps} fps
+ </span>
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="Screencast quality"
+ description="JPEG quality for tab preview streams."
+ >
+ <div className="flex items-center gap-3">
+ <input
+ type="range"
+ min={10}
+ max={80}
+ value={localSettings.screencast.quality}
+ onChange={(e) =>
+ setLocalSettings((current) => ({
+ ...current,
+ screencast: {
+ ...current.screencast,
+ quality: Number(e.target.value),
+ },
+ }))
+ }
+ className="w-full"
+ />
+ <span className="dashboard-mono w-16 text-right text-sm text-text-secondary">
+ {localSettings.screencast.quality}%
+ </span>
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="Screencast width"
+ description="Maximum preview width for live tiles."
+ >
+ <select
+ value={localSettings.screencast.maxWidth}
+ onChange={(e) =>
+ setLocalSettings((current) => ({
+ ...current,
+ screencast: {
+ ...current.screencast,
+ maxWidth: Number(e.target.value),
+ },
+ }))
+ }
+ className={selectClass}
+ >
+ {[400, 600, 800, 1024, 1280].map((width) => (
+ <option key={width} value={width}>
+ {width}px
+ </option>
+ ))}
+ </select>
+ </SettingRow>
+ <SettingRow
+ label="Memory metrics"
+ description="Enable per-tab heap collection in the dashboard. Useful for debugging, but heavier."
+ >
+ <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
+ <input
+ type="checkbox"
+ checked={localSettings.monitoring.memoryMetrics}
+ onChange={(e) =>
+ setLocalSettings((current) => ({
+ ...current,
+ monitoring: {
+ ...current.monitoring,
+ memoryMetrics: e.target.checked,
+ },
+ }))
+ }
+ className="h-4 w-4"
+ />
+ Enable
+ </label>
+ </SettingRow>
+ <SettingRow
+ label="Polling interval"
+ description="How frequently the dashboard asks the backend for fresh metrics."
+ >
+ <div className="flex items-center gap-3">
+ <input
+ type="range"
+ min={5}
+ max={120}
+ step={5}
+ value={localSettings.monitoring.pollInterval}
+ onChange={(e) =>
+ setLocalSettings((current) => ({
+ ...current,
+ monitoring: {
+ ...current.monitoring,
+ pollInterval: Number(e.target.value),
+ },
+ }))
+ }
+ className="w-full"
+ />
+ <span className="dashboard-mono w-16 text-right text-sm text-text-secondary">
+ {localSettings.monitoring.pollInterval}s
+ </span>
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="Reasoning output"
+ description="Choose whether the live agent feed shows tool calls, progress updates, or both."
+ >
+ <select
+ value={localSettings.agents.reasoningMode}
+ onChange={(e) =>
+ setLocalSettings((current) => ({
+ ...current,
+ agents: {
+ ...current.agents,
+ reasoningMode: e.target.value as
+ | "tool_calls"
+ | "progress"
+ | "both",
+ },
+ }))
+ }
+ className={selectClass}
+ >
+ <option value="tool_calls">Tool calls only</option>
+ <option value="progress">Progress only</option>
+ <option value="both">Both</option>
+ </select>
+ </SettingRow>
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/DefaultsSettingsSection.tsx b/dashboard/src/pages/settings/DefaultsSettingsSection.tsx
new file mode 100644
index 00000000..96d324e7
--- /dev/null
+++ b/dashboard/src/pages/settings/DefaultsSettingsSection.tsx
@@ -0,0 +1,234 @@
+import type { BackendConfig } from "../../types";
+import type { UpdateBackendSection } from "./settingsShared";
+import {
+ fieldClass,
+ instanceDefaultsBooleanRows,
+ selectClass,
+} from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface DefaultsSettingsSectionProps {
+ backendConfig: BackendConfig;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function DefaultsSettingsSection({
+ backendConfig,
+ updateBackendSection,
+}: DefaultsSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Instance Defaults"
+ description="These values are written to config and used for new managed instances. Existing running instances keep their current runtime."
+ >
+ <SettingRow
+ label="Mode"
+ description="Default browser mode for new launches."
+ >
+ <select
+ value={backendConfig.instanceDefaults.mode}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ mode: e.target.value as BackendConfig["instanceDefaults"]["mode"],
+ })
+ }
+ className={selectClass}
+ >
+ <option value="headless">Headless</option>
+ <option value="headed">Headed</option>
+ </select>
+ </SettingRow>
+ <SettingRow
+ label="Stealth level"
+ description="Bot detection evasion profile. Higher levels may affect error monitoring and certain browser features."
+ >
+ <div className="space-y-2">
+ <select
+ value={backendConfig.instanceDefaults.stealthLevel}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ stealthLevel: e.target
+ .value as BackendConfig["instanceDefaults"]["stealthLevel"],
+ })
+ }
+ className={selectClass}
+ >
+ <option value="light">Light</option>
+ <option value="medium">Medium</option>
+ <option value="full">Full</option>
+ </select>
+ <div className="rounded-sm border border-border-subtle bg-black/10 px-3 py-2 text-xs leading-5 text-text-muted">
+ {backendConfig.instanceDefaults.stealthLevel === "light" && (
+ <div className="space-y-2">
+ <div>
+ <strong className="text-text-secondary">Light:</strong>{" "}
+ Default baseline stealth. Keeps the lowest-risk launch and JS
+ contract while hiding basic automation markers.
+ </div>
+ <div className="text-success/80">
+ ✓ Default product security baseline
+ </div>
+ <div className="text-success/80">
+ ✓ No intentional API realism or security tradeoff
+ </div>
+ </div>
+ )}
+ {backendConfig.instanceDefaults.stealthLevel === "medium" && (
+ <div className="space-y-2">
+ <div>
+ <strong className="text-warning">Medium:</strong> Non-default
+ risk mode. Adds Client Hints, `chrome.runtime` shims, iframe
+ propagation, stack filtering, and native-looking function
+ masking to improve anti-bot compatibility.
+ </div>
+ <div className="text-warning/80">
+ ⚠ Alters browser-visible APIs and error/stack behavior.
+ Monitoring and debugging tools may see different results.
+ </div>
+ <div className="text-warning/80">
+ ⚠ Permissions and compatibility shims can return intentionally
+ altered values. Do not use this as the default safety
+ baseline.
+ </div>
+ <div className="text-warning/80">
+ ⚠ Reports that require explicitly enabling Medium should be
+ treated as opt-in risk acceptance, not default-path behavior.
+ </div>
+ </div>
+ )}
+ {backendConfig.instanceDefaults.stealthLevel === "full" && (
+ <div className="space-y-2">
+ <div>
+ <strong className="text-destructive">Full:</strong>{" "}
+ Highest-risk non-default mode. Adds graphics, canvas, audio,
+ system-color, and WebRTC alterations on top of Medium.
+ </div>
+ <div className="text-destructive/80">
+ ⚠ Browser output is intentionally less native and less stable.
+ Rendering, media, and networking behavior may break or drift
+ from real Chrome.
+ </div>
+ <div className="text-destructive/80">
+ ⚠ This mode is not an acceptable default security posture.
+ Only enable it when you explicitly accept the tradeoff
+ surface.
+ </div>
+ <div className="text-destructive/80">
+ ⚠ Reports that depend on enabling Full should be triaged as
+ non-default operator risk unless a default-path bypass is
+ shown.
+ </div>
+ <div className="text-destructive/80">
+ ⚠ WebRTC, WebGL, canvas, and audio behavior can all diverge
+ from baseline Chrome.
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="Tab eviction policy"
+ description="How PinchTab behaves when a managed instance reaches its tab limit."
+ >
+ <select
+ value={backendConfig.instanceDefaults.tabEvictionPolicy}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ tabEvictionPolicy: e.target
+ .value as BackendConfig["instanceDefaults"]["tabEvictionPolicy"],
+ })
+ }
+ className={selectClass}
+ >
+ <option value="reject">Reject new tabs</option>
+ <option value="close_oldest">Close oldest</option>
+ <option value="close_lru">Close least recently used</option>
+ </select>
+ </SettingRow>
+ <SettingRow
+ label="Max tabs"
+ description="Maximum number of tabs per managed instance."
+ >
+ <input
+ type="number"
+ min={1}
+ value={backendConfig.instanceDefaults.maxTabs}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ maxTabs: Number(e.target.value),
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Max parallel tabs"
+ description="Set to 0 to auto-detect from CPU count."
+ >
+ <input
+ type="number"
+ min={0}
+ value={backendConfig.instanceDefaults.maxParallelTabs}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ maxParallelTabs: Number(e.target.value),
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Timezone"
+ description="Optional timezone override for launched instances."
+ >
+ <input
+ value={backendConfig.instanceDefaults.timezone}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ timezone: e.target.value,
+ })
+ }
+ placeholder="Europe/Rome"
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="User agent"
+ description="Optional override applied to new managed instances."
+ >
+ <input
+ value={backendConfig.instanceDefaults.userAgent}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ userAgent: e.target.value,
+ })
+ }
+ placeholder="Custom user agent"
+ className={fieldClass}
+ />
+ </SettingRow>
+ {instanceDefaultsBooleanRows.map(([key, label]) => (
+ <SettingRow
+ key={key}
+ label={label}
+ description="Applies to newly launched managed instances."
+ >
+ <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
+ <input
+ type="checkbox"
+ checked={backendConfig.instanceDefaults[key]}
+ onChange={(e) =>
+ updateBackendSection("instanceDefaults", {
+ [key]: e.target.checked,
+ } as Partial<BackendConfig["instanceDefaults"]>)
+ }
+ className="h-4 w-4"
+ />
+ Enable
+ </label>
+ </SettingRow>
+ ))}
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/NetworkSettingsSection.tsx b/dashboard/src/pages/settings/NetworkSettingsSection.tsx
new file mode 100644
index 00000000..46b28b22
--- /dev/null
+++ b/dashboard/src/pages/settings/NetworkSettingsSection.tsx
@@ -0,0 +1,197 @@
+import type { BackendConfig, BackendConfigState } from "../../types";
+import type { UpdateBackendSection } from "./settingsShared";
+import { csvToList, fieldClass, listToCsv } from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface NetworkSettingsSectionProps {
+ apiTokenMissing: boolean;
+ attachWildcard: boolean;
+ backendConfig: BackendConfig;
+ backendState: BackendConfigState | null;
+ nonLoopbackBind: boolean;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function NetworkSettingsSection({
+ apiTokenMissing,
+ attachWildcard,
+ backendConfig,
+ backendState,
+ nonLoopbackBind,
+ updateBackendSection,
+}: NetworkSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Network & Attach"
+ description="Port and bind changes require a restart. API token management is handled outside the dashboard."
+ >
+ <SettingRow
+ label="Server port"
+ description="HTTP port for the dashboard process."
+ >
+ <input
+ value={backendConfig.server.port}
+ onChange={(e) =>
+ updateBackendSection("server", { port: e.target.value })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Bind address"
+ description="Network interface the dashboard process binds to. Keeping 127.0.0.1 or localhost limits direct reachability to the local machine."
+ >
+ <div className="space-y-2">
+ <input
+ value={backendConfig.server.bind}
+ onChange={(e) =>
+ updateBackendSection("server", {
+ bind: e.target.value,
+ })
+ }
+ className={fieldClass}
+ />
+ {nonLoopbackBind ? (
+ <div className="rounded-sm border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs leading-5 text-destructive/80">
+ A non-loopback bind is a documented, non-default,
+ security-reducing configuration change. It may expose the server
+ beyond the local machine unless another network boundary still
+ restricts access. Keep a token set and review proxy or
+ port-publishing behavior explicitly.
+ </div>
+ ) : (
+ <div className="rounded-sm border border-warning/25 bg-warning/10 px-3 py-2 text-xs leading-5 text-warning">
+ Loopback bind keeps direct server reachability local. Moving to{" "}
+ <code>0.0.0.0</code> or another non-local address widens the trust
+ boundary.
+ </div>
+ )}
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="API token"
+ description="Bearer token required by authenticated requests when set. The dashboard never returns it and does not manage it."
+ >
+ <div className="space-y-2">
+ <div className="text-xs leading-5 text-text-muted">
+ {backendState?.tokenConfigured
+ ? "Token configured. Manage rotation through the CLI or config file; the current value is never returned by the server."
+ : "No token configured. Set one through the CLI or config file."}
+ </div>
+ {apiTokenMissing && (
+ <div className="rounded-sm border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs leading-5 text-destructive">
+ No API token is set. Anyone who can reach this server can access
+ exposed endpoints. Keep it on trusted local networks only, or
+ configure a strong token through the CLI or config file. You are
+ responsible for protecting access.
+ </div>
+ )}
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="State directory"
+ description="Base state path used by managed child instances."
+ >
+ <input
+ value={backendConfig.server.stateDir}
+ onChange={(e) =>
+ updateBackendSection("server", {
+ stateDir: e.target.value,
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Trust proxy headers"
+ description="Trust X-Forwarded-Proto, X-Forwarded-Host, and Forwarded headers for origin checks. Enable only when PinchTab runs behind a trusted reverse proxy (e.g. Caddy, nginx)."
+ >
+ <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
+ <input
+ type="checkbox"
+ checked={backendConfig.server.trustProxyHeaders ?? false}
+ onChange={(e) =>
+ updateBackendSection("server", {
+ trustProxyHeaders: e.target.checked,
+ })
+ }
+ className="accent-primary"
+ />
+ {backendConfig.server.trustProxyHeaders ? "Enabled" : "Disabled"}
+ </label>
+ </SettingRow>
+ <SettingRow
+ label="Allow attach"
+ description="Permit attaching PinchTab to externally managed Chrome sessions."
+ >
+ <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
+ <input
+ type="checkbox"
+ checked={backendConfig.security.attach.enabled}
+ onChange={(e) =>
+ updateBackendSection("security", {
+ attach: {
+ ...backendConfig.security.attach,
+ enabled: e.target.checked,
+ },
+ })
+ }
+ className="h-4 w-4"
+ />
+ Enable
+ </label>
+ </SettingRow>
+ <SettingRow
+ label="Allowed attach hosts"
+ description='Comma-separated host allowlist for attach requests. Only include hosts you control and trust. Using "*" disables host allowlisting.'
+ >
+ <div className="space-y-2">
+ <input
+ value={listToCsv(backendConfig.security.attach.allowHosts)}
+ onChange={(e) =>
+ updateBackendSection("security", {
+ attach: {
+ ...backendConfig.security.attach,
+ allowHosts: csvToList(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ {attachWildcard ? (
+ <div className="rounded-sm border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs leading-5 text-destructive/80">
+ <code>allowHosts: ["*"]</code> is a documented, non-default,
+ security-reducing override. It disables host allowlisting entirely
+ and allows remote attach requests to any reachable host with an
+ allowed scheme. Use it only on isolated, operator-controlled
+ networks.
+ </div>
+ ) : (
+ <div className="rounded-sm border border-warning/25 bg-warning/10 px-3 py-2 text-xs leading-5 text-warning">
+ Hosts in this allowlist may be used for remote attach requests.
+ Broad or untrusted entries expand the trust boundary and can
+ expose external Chrome sessions and browser contents.
+ </div>
+ )}
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="Allowed attach schemes"
+ description="Comma-separated scheme allowlist, usually ws and wss."
+ >
+ <input
+ value={listToCsv(backendConfig.security.attach.allowSchemes)}
+ onChange={(e) =>
+ updateBackendSection("security", {
+ attach: {
+ ...backendConfig.security.attach,
+ allowSchemes: csvToList(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/OrchestrationSettingsSection.tsx b/dashboard/src/pages/settings/OrchestrationSettingsSection.tsx
new file mode 100644
index 00000000..769f4401
--- /dev/null
+++ b/dashboard/src/pages/settings/OrchestrationSettingsSection.tsx
@@ -0,0 +1,187 @@
+import type { BackendConfig } from "../../types";
+import type { UpdateBackendSection } from "./settingsShared";
+import { fieldClass, selectClass } from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface OrchestrationSettingsSectionProps {
+ backendConfig: BackendConfig;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function OrchestrationSettingsSection({
+ backendConfig,
+ updateBackendSection,
+}: OrchestrationSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Orchestration"
+ description="Port range and allocation policy can be applied immediately for future launches. Strategy and restart-policy changes require a dashboard restart because strategy routes and lifecycle state are registered at startup."
+ >
+ <SettingRow
+ label="Strategy"
+ description="Controls instance lifecycle and how shorthand routes are routed."
+ >
+ <select
+ value={backendConfig.multiInstance.strategy}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ strategy: e.target
+ .value as BackendConfig["multiInstance"]["strategy"],
+ })
+ }
+ className={selectClass}
+ >
+ <option value="always-on">Always on</option>
+ <option value="simple">Simple</option>
+ <option value="explicit">Explicit</option>
+ <option value="simple-autorestart">Simple autorestart</option>
+ <option value="no-instance">No instance (hub)</option>
+ </select>
+ <div className="mt-2 text-[11px] leading-relaxed text-text-muted">
+ {backendConfig.multiInstance.strategy === "always-on" &&
+ "Launches a default instance at boot and relaunches on crash."}
+ {backendConfig.multiInstance.strategy === "simple" &&
+ "Launches one instance on first request. No auto-restart."}
+ {backendConfig.multiInstance.strategy === "explicit" &&
+ "All instances managed via API. No automatic launches."}
+ {backendConfig.multiInstance.strategy === "simple-autorestart" &&
+ "Launches on first request and relaunches on crash."}
+ {backendConfig.multiInstance.strategy === "no-instance" &&
+ "No local Chrome processes. Acts as a hub for remote bridges only."}
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="Allocation policy"
+ description="Determines how running instances are chosen for shorthand requests."
+ >
+ <select
+ value={backendConfig.multiInstance.allocationPolicy}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ allocationPolicy: e.target
+ .value as BackendConfig["multiInstance"]["allocationPolicy"],
+ })
+ }
+ className={selectClass}
+ >
+ <option value="fcfs">First available</option>
+ <option value="round_robin">Round robin</option>
+ <option value="random">Random</option>
+ </select>
+ </SettingRow>
+ <SettingRow
+ label="Instance port start"
+ description="Lower bound for auto-allocated instance ports."
+ >
+ <input
+ type="number"
+ min={1}
+ value={backendConfig.multiInstance.instancePortStart}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ instancePortStart: Number(e.target.value),
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Instance port end"
+ description="Upper bound for auto-allocated instance ports."
+ >
+ <input
+ type="number"
+ min={1}
+ value={backendConfig.multiInstance.instancePortEnd}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ instancePortEnd: Number(e.target.value),
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ {(backendConfig.multiInstance.strategy === "always-on" ||
+ backendConfig.multiInstance.strategy === "simple-autorestart") && (
+ <>
+ <SettingRow
+ label="Max restarts"
+ description="Maximum restart attempts. Use -1 for unlimited, 0 for no restarts."
+ >
+ <input
+ type="number"
+ min={-1}
+ value={backendConfig.multiInstance.restart.maxRestarts}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ maxRestarts: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Initial backoff"
+ description="Delay in seconds before the first restart attempt."
+ >
+ <input
+ type="number"
+ min={1}
+ value={backendConfig.multiInstance.restart.initBackoffSec}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ initBackoffSec: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Max backoff"
+ description="Upper bound in seconds for exponential restart backoff."
+ >
+ <input
+ type="number"
+ min={1}
+ value={backendConfig.multiInstance.restart.maxBackoffSec}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ maxBackoffSec: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Stable after"
+ description="Seconds the instance must stay healthy before the restart counter resets."
+ >
+ <input
+ type="number"
+ min={1}
+ value={backendConfig.multiInstance.restart.stableAfterSec}
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ stableAfterSec: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ </>
+ )}
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/ProfilesSettingsSection.tsx b/dashboard/src/pages/settings/ProfilesSettingsSection.tsx
new file mode 100644
index 00000000..5960adff
--- /dev/null
+++ b/dashboard/src/pages/settings/ProfilesSettingsSection.tsx
@@ -0,0 +1,50 @@
+import type { BackendConfig } from "../../types";
+import type { UpdateBackendSection } from "./settingsShared";
+import { fieldClass } from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface ProfilesSettingsSectionProps {
+ backendConfig: BackendConfig;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function ProfilesSettingsSection({
+ backendConfig,
+ updateBackendSection,
+}: ProfilesSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Profiles"
+ description="Profile storage is host-level. Changing the base directory requires restart because the profile manager and orchestrator are created with it at boot."
+ >
+ <SettingRow
+ label="Profiles base directory"
+ description="Root directory where browser profiles are stored."
+ >
+ <input
+ value={backendConfig.profiles.baseDir}
+ onChange={(e) =>
+ updateBackendSection("profiles", {
+ baseDir: e.target.value,
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Default profile"
+ description="Profile name used when the server needs an implicit default."
+ >
+ <input
+ value={backendConfig.profiles.defaultProfile}
+ onChange={(e) =>
+ updateBackendSection("profiles", {
+ defaultProfile: e.target.value,
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/SecurityIdpiSettingsSection.tsx b/dashboard/src/pages/settings/SecurityIdpiSettingsSection.tsx
new file mode 100644
index 00000000..fc908453
--- /dev/null
+++ b/dashboard/src/pages/settings/SecurityIdpiSettingsSection.tsx
@@ -0,0 +1,113 @@
+import type { BackendConfig } from "../../types";
+import type { UpdateBackendSection } from "./settingsShared";
+import {
+ csvToList,
+ fieldClass,
+ idpiToggleRows,
+ listToCsv,
+} from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface SecurityIdpiSettingsSectionProps {
+ backendConfig: BackendConfig;
+ idpiEnabled: boolean;
+ idpiDomainsConfigured: boolean;
+ idpiWildcard: boolean;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function SecurityIdpiSettingsSection({
+ backendConfig,
+ idpiEnabled,
+ idpiDomainsConfigured,
+ idpiWildcard,
+ updateBackendSection,
+}: SecurityIdpiSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Security IDPI"
+ description="Indirect prompt injection controls restrict which websites are allowed and add protections around extracted content before it reaches downstream automation."
+ >
+ <div
+ className={`mb-4 rounded-sm px-4 py-3 text-sm leading-6 ${
+ !idpiEnabled || !idpiDomainsConfigured
+ ? "border border-destructive/35 bg-destructive/10 text-destructive"
+ : idpiWildcard
+ ? "border border-warning/25 bg-warning/10 text-warning"
+ : "border border-success/25 bg-success/10 text-success"
+ }`}
+ >
+ {!idpiEnabled
+ ? "IDPI is disabled. Browser content is not being filtered by website allowlist or content protections."
+ : !idpiDomainsConfigured
+ ? "The website whitelist is not set to a restricted domain list. This is the main IDPI defense and should be configured."
+ : idpiWildcard
+ ? "The website whitelist contains '*', which effectively disables domain restriction."
+ : "IDPI is enforcing a specific website whitelist and content protections."}
+ </div>
+ {idpiToggleRows.map(([key, label, description]) => (
+ <SettingRow key={key} label={label} description={description}>
+ <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
+ <input
+ type="checkbox"
+ checked={backendConfig.security.idpi[key]}
+ onChange={(e) =>
+ updateBackendSection("security", {
+ idpi: {
+ ...backendConfig.security.idpi,
+ [key]: e.target.checked,
+ },
+ })
+ }
+ className="h-4 w-4"
+ />
+ Enable
+ </label>
+ </SettingRow>
+ ))}
+ <SettingRow
+ label="Allowed websites"
+ description="Comma-separated domain allowlist for web content. Use exact hosts or patterns like *.example.com."
+ >
+ <div className="space-y-2">
+ <input
+ value={listToCsv(backendConfig.security.idpi.allowedDomains)}
+ onChange={(e) =>
+ updateBackendSection("security", {
+ idpi: {
+ ...backendConfig.security.idpi,
+ allowedDomains: csvToList(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ placeholder="127.0.0.1, localhost, ::1"
+ />
+ <div className="rounded-sm border border-warning/25 bg-warning/10 px-3 py-2 text-xs leading-5 text-warning">
+ Keep this list narrow. Empty or wildcard entries weaken the main
+ IDPI boundary. Allowing non-local or non-trusted sites increases
+ browser attack surface even when IDPI is enabled.
+ </div>
+ </div>
+ </SettingRow>
+ <SettingRow
+ label="Custom patterns"
+ description="Optional comma-separated phrases to treat as suspicious prompt-injection content."
+ >
+ <input
+ value={listToCsv(backendConfig.security.idpi.customPatterns)}
+ onChange={(e) =>
+ updateBackendSection("security", {
+ idpi: {
+ ...backendConfig.security.idpi,
+ customPatterns: csvToList(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ placeholder="ignore previous instructions, exfiltrate data"
+ />
+ </SettingRow>
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/SecuritySettingsSection.tsx b/dashboard/src/pages/settings/SecuritySettingsSection.tsx
new file mode 100644
index 00000000..6cdd3cc3
--- /dev/null
+++ b/dashboard/src/pages/settings/SecuritySettingsSection.tsx
@@ -0,0 +1,59 @@
+import type { BackendConfig, BackendSecurityConfig } from "../../types";
+import type {
+ SecurityEndpointKey,
+ UpdateBackendSection,
+} from "./settingsShared";
+import { securityEndpointRows } from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface SecuritySettingsSectionProps {
+ backendConfig: BackendConfig;
+ sensitiveEndpointsEnabled: boolean;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function SecuritySettingsSection({
+ backendConfig,
+ sensitiveEndpointsEnabled,
+ updateBackendSection,
+}: SecuritySettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Security"
+ description="These controls define what risky capabilities PinchTab exposes."
+ >
+ <div
+ className={`rounded-sm px-4 py-3 text-sm leading-6 ${
+ sensitiveEndpointsEnabled
+ ? "border border-destructive/35 bg-destructive/10 text-destructive"
+ : "border border-warning/25 bg-warning/10 text-warning"
+ }`}
+ >
+ {sensitiveEndpointsEnabled
+ ? "One or more sensitive endpoint families are enabled. Features like script execution, downloads, uploads, and live capture can expose high-risk capabilities. Only enable them in trusted environments. You are responsible for securing network access, authentication, and downstream use."
+ : "These endpoint families can expose high-risk capabilities when enabled. Only turn them on in trusted environments, and only when you accept responsibility for network access, authentication, and downstream use."}
+ </div>
+ {securityEndpointRows.map(([key, label]) => (
+ <SettingRow
+ key={key}
+ label={label}
+ description="Controls whether the corresponding endpoint family is enabled."
+ >
+ <label className="flex items-center justify-end gap-3 text-sm text-text-secondary">
+ <input
+ type="checkbox"
+ checked={backendConfig.security[key]}
+ onChange={(e) =>
+ updateBackendSection("security", {
+ [key]: e.target.checked,
+ } as Partial<Pick<BackendSecurityConfig, SecurityEndpointKey>>)
+ }
+ className="h-4 w-4"
+ />
+ Enable
+ </label>
+ </SettingRow>
+ ))}
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/SettingsSharedComponents.tsx b/dashboard/src/pages/settings/SettingsSharedComponents.tsx
new file mode 100644
index 00000000..e3bccb57
--- /dev/null
+++ b/dashboard/src/pages/settings/SettingsSharedComponents.tsx
@@ -0,0 +1,45 @@
+import type { ReactNode } from "react";
+import { Card } from "../../components/atoms";
+
+export function SectionCard({
+ title,
+ description,
+ children,
+}: {
+ title: string;
+ description: string;
+ children: ReactNode;
+}) {
+ return (
+ <Card className="p-5">
+ <div className="mb-5 border-b border-border-subtle pb-4">
+ <div className="dashboard-section-label mb-2">Settings</div>
+ <h3 className="text-lg font-semibold text-text-primary">{title}</h3>
+ <p className="mt-2 max-w-2xl text-sm leading-6 text-text-muted">
+ {description}
+ </p>
+ </div>
+ <div className="space-y-4">{children}</div>
+ </Card>
+ );
+}
+
+export function SettingRow({
+ label,
+ description,
+ children,
+}: {
+ label: string;
+ description: string;
+ children: ReactNode;
+}) {
+ return (
+ <div className="flex flex-col gap-3 rounded-sm border border-border-subtle bg-black/10 p-4 lg:flex-row lg:items-center lg:justify-between">
+ <div className="max-w-xl">
+ <div className="text-sm font-medium text-text-primary">{label}</div>
+ <p className="mt-1 text-xs leading-5 text-text-muted">{description}</p>
+ </div>
+ <div className="w-full max-w-md">{children}</div>
+ </div>
+ );
+}
diff --git a/dashboard/src/pages/settings/TimeoutsSettingsSection.tsx b/dashboard/src/pages/settings/TimeoutsSettingsSection.tsx
new file mode 100644
index 00000000..e944921c
--- /dev/null
+++ b/dashboard/src/pages/settings/TimeoutsSettingsSection.tsx
@@ -0,0 +1,37 @@
+import type { BackendConfig } from "../../types";
+import type { UpdateBackendSection } from "./settingsShared";
+import { fieldClass, timeoutRows } from "./settingsShared";
+import { SectionCard, SettingRow } from "./SettingsSharedComponents";
+
+interface TimeoutsSettingsSectionProps {
+ backendConfig: BackendConfig;
+ updateBackendSection: UpdateBackendSection;
+}
+
+export function TimeoutsSettingsSection({
+ backendConfig,
+ updateBackendSection,
+}: TimeoutsSettingsSectionProps) {
+ return (
+ <SectionCard
+ title="Timeouts"
+ description="Runtime timing defaults written into new child configs. Existing running instances keep their current timeouts."
+ >
+ {timeoutRows.map(([key, label, description]) => (
+ <SettingRow key={key} label={label} description={description}>
+ <input
+ type="number"
+ min={0}
+ value={backendConfig.timeouts[key]}
+ onChange={(e) =>
+ updateBackendSection("timeouts", {
+ [key]: Number(e.target.value),
+ } as Partial<BackendConfig["timeouts"]>)
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ ))}
+ </SectionCard>
+ );
+}
diff --git a/dashboard/src/pages/settings/settingsShared.ts b/dashboard/src/pages/settings/settingsShared.ts
new file mode 100644
index 00000000..c8cf06ee
--- /dev/null
+++ b/dashboard/src/pages/settings/settingsShared.ts
@@ -0,0 +1,157 @@
+import type {
+ BackendConfig,
+ BackendConfigState,
+ BackendIDPIConfig,
+ BackendSecurityConfig,
+} from "../../types";
+
+export type SectionId =
+ | "dashboard"
+ | "defaults"
+ | "orchestration"
+ | "security"
+ | "security-idpi"
+ | "profiles"
+ | "network"
+ | "browser"
+ | "timeouts";
+
+export const sections: Array<{
+ id: SectionId;
+ label: string;
+ description: string;
+}> = [
+ {
+ id: "dashboard",
+ label: "Dashboard",
+ description: "Local monitoring and screencast preferences.",
+ },
+ {
+ id: "defaults",
+ label: "Instance Defaults",
+ description: "How new managed browser instances launch.",
+ },
+ {
+ id: "orchestration",
+ label: "Orchestration",
+ description: "Routing strategy, port range, and allocation policy.",
+ },
+ {
+ id: "security",
+ label: "Security",
+ description: "Sensitive endpoint gates and access controls.",
+ },
+ {
+ id: "security-idpi",
+ label: "Security IDPI",
+ description: "Indirect prompt injection website and content defenses.",
+ },
+ {
+ id: "profiles",
+ label: "Profiles",
+ description: "Shared profile storage and default profile behavior.",
+ },
+ {
+ id: "network",
+ label: "Network & Attach",
+ description: "Server binding, auth, and attach policy.",
+ },
+ {
+ id: "browser",
+ label: "Browser Runtime",
+ description: "Chrome binary, version, flags, and extensions.",
+ },
+ {
+ id: "timeouts",
+ label: "Timeouts",
+ description: "Action, navigation, shutdown, and wait timing.",
+ },
+];
+
+export const fieldClass =
+ "w-full rounded-sm border border-border-subtle bg-[rgb(var(--brand-surface-code-rgb)/0.72)] px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-all duration-150 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20";
+
+export const selectClass =
+ "rounded-sm border border-border-subtle bg-[rgb(var(--brand-surface-code-rgb)/0.72)] px-3 py-2 text-sm text-text-primary transition-all duration-150 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20";
+
+export type UpdateBackendSection = <K extends keyof BackendConfig>(
+ section: K,
+ patch: Partial<BackendConfig[K]>,
+) => void;
+
+export type SecurityEndpointKey = Exclude<
+ keyof BackendSecurityConfig,
+ "attach" | "idpi"
+>;
+export type IDPIToggleKey = Exclude<
+ keyof BackendIDPIConfig,
+ "allowedDomains" | "customPatterns"
+>;
+
+export const securityEndpointRows = [
+ ["allowEvaluate", "Allow evaluate"],
+ ["allowMacro", "Allow macro"],
+ ["allowScreencast", "Allow screencast"],
+ ["allowDownload", "Allow download"],
+ ["allowUpload", "Allow upload"],
+] as const satisfies ReadonlyArray<readonly [SecurityEndpointKey, string]>;
+
+export const idpiToggleRows = [
+ ["enabled", "Enable IDPI", "Turn on indirect prompt injection defenses."],
+ [
+ "strictMode",
+ "Strict mode",
+ "Block disallowed domains and suspicious content instead of only warning.",
+ ],
+ [
+ "scanContent",
+ "Scan content",
+ "Inspect extracted text and snapshots for prompt-injection patterns.",
+ ],
+ [
+ "wrapContent",
+ "Wrap content",
+ "Mark returned page text as untrusted content for downstream consumers.",
+ ],
+] as const satisfies ReadonlyArray<readonly [IDPIToggleKey, string, string]>;
+
+export const instanceDefaultsBooleanRows = [
+ ["blockImages", "Block images"],
+ ["blockMedia", "Block media"],
+ ["blockAds", "Block ads"],
+ ["noAnimations", "Disable CSS animations"],
+ ["noRestore", "Skip session restore"],
+] as const;
+
+export const timeoutRows = [
+ ["actionSec", "Action timeout", "Maximum time for action requests."],
+ ["navigateSec", "Navigate timeout", "Maximum time for navigation requests."],
+ [
+ "shutdownSec",
+ "Shutdown timeout",
+ "Grace period before force-closing a child process.",
+ ],
+ [
+ "waitNavMs",
+ "Wait-after-navigation delay",
+ "Post-navigation stabilization delay in milliseconds.",
+ ],
+] as const;
+
+export function csvToList(value: string): string[] {
+ return value
+ .split(",")
+ .map((item) => item.trim())
+ .filter(Boolean);
+}
+
+export function listToCsv(value: string[]): string {
+ return value.join(", ");
+}
+
+export function backendSaveNotice(state: BackendConfigState | null): string {
+ if (state?.restartRequired) {
+ return "Backend config saved. Dynamic changes were applied where possible. Restart advised for server-level changes.";
+ }
+ return "Backend config saved. Dynamic changes were applied where possible.";
+}
diff --git a/dashboard/src/components/profiles/InstanceLogsPanel.test.tsx b/dashboard/src/profiles/InstanceLogsPanel.test.tsx
similarity index 98%
rename from dashboard/src/components/profiles/InstanceLogsPanel.test.tsx
rename to dashboard/src/profiles/InstanceLogsPanel.test.tsx
index dc88d437..c54845cc 100644
--- a/dashboard/src/components/profiles/InstanceLogsPanel.test.tsx
+++ b/dashboard/src/profiles/InstanceLogsPanel.test.tsx
@@ -7,7 +7,7 @@ const { fetchInstanceLogs, subscribeToInstanceLogs } = vi.hoisted(() => ({
subscribeToInstanceLogs: vi.fn(),
}));
-vi.mock("../../services/api", () => ({
+vi.mock("../services/api", () => ({
fetchInstanceLogs,
subscribeToInstanceLogs,
}));
diff --git a/dashboard/src/components/profiles/InstanceLogsPanel.tsx b/dashboard/src/profiles/InstanceLogsPanel.tsx
similarity index 97%
rename from dashboard/src/components/profiles/InstanceLogsPanel.tsx
rename to dashboard/src/profiles/InstanceLogsPanel.tsx
index 48fd9aba..42c996e2 100644
--- a/dashboard/src/components/profiles/InstanceLogsPanel.tsx
+++ b/dashboard/src/profiles/InstanceLogsPanel.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
-import * as api from "../../services/api";
+import * as api from "../services/api";
interface Props {
instanceId?: string;
diff --git a/dashboard/src/components/profiles/ProfileBasicInfoPanel.tsx b/dashboard/src/profiles/ProfileBasicInfoPanel.tsx
similarity index 92%
rename from dashboard/src/components/profiles/ProfileBasicInfoPanel.tsx
rename to dashboard/src/profiles/ProfileBasicInfoPanel.tsx
index b5d24f4a..17bbe2f3 100644
--- a/dashboard/src/components/profiles/ProfileBasicInfoPanel.tsx
+++ b/dashboard/src/profiles/ProfileBasicInfoPanel.tsx
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
-import { Input } from "../atoms";
-import type { Profile } from "../../generated/types";
+import { Input } from "../components/atoms";
+import type { Profile } from "../generated/types";
interface Props {
profile: Profile;
diff --git a/dashboard/src/components/profiles/ProfileCard.test.tsx b/dashboard/src/profiles/ProfileCard.test.tsx
similarity index 98%
rename from dashboard/src/components/profiles/ProfileCard.test.tsx
rename to dashboard/src/profiles/ProfileCard.test.tsx
index 69b19035..6c11004d 100644
--- a/dashboard/src/components/profiles/ProfileCard.test.tsx
+++ b/dashboard/src/profiles/ProfileCard.test.tsx
@@ -2,7 +2,7 @@ import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, it, expect, vi } from "vitest";
import ProfileCard from "./ProfileCard";
-import type { Profile, Instance } from "../../types";
+import type { Profile, Instance } from "../types";
const mockProfile: Profile = {
id: "prof_123",
diff --git a/dashboard/src/components/profiles/ProfileCard.tsx b/dashboard/src/profiles/ProfileCard.tsx
similarity index 96%
rename from dashboard/src/components/profiles/ProfileCard.tsx
rename to dashboard/src/profiles/ProfileCard.tsx
index 3001e1ec..ca88084f 100644
--- a/dashboard/src/components/profiles/ProfileCard.tsx
+++ b/dashboard/src/profiles/ProfileCard.tsx
@@ -1,5 +1,5 @@
-import { Card, Badge, Button } from "../atoms";
-import type { Profile, Instance } from "../../types";
+import { Card, Badge, Button } from "../components/atoms";
+import type { Profile, Instance } from "../types";
interface Props {
profile: Profile;
diff --git a/dashboard/src/components/profiles/ProfileDetailsPanel.tsx b/dashboard/src/profiles/ProfileDetailsPanel.tsx
similarity index 96%
rename from dashboard/src/components/profiles/ProfileDetailsPanel.tsx
rename to dashboard/src/profiles/ProfileDetailsPanel.tsx
index d3efd30f..21d3fa27 100644
--- a/dashboard/src/components/profiles/ProfileDetailsPanel.tsx
+++ b/dashboard/src/profiles/ProfileDetailsPanel.tsx
@@ -5,9 +5,9 @@ import ProfileBasicInfoPanel from "./ProfileBasicInfoPanel";
import ProfileLiveViewPanel from "./ProfileLiveViewPanel";
import ProfileToolbar from "./ProfileToolbar";
import { InstanceTabsPanel } from "../tabs";
-import { TabsLayout, EmptyView } from "../molecules";
-import type { Profile, Instance, InstanceTab } from "../../generated/types";
-import * as api from "../../services/api";
+import { TabsLayout, EmptyView } from "../components/molecules";
+import type { Profile, Instance, InstanceTab } from "../generated/types";
+import * as api from "../services/api";
interface Props {
profile: Profile | null;
diff --git a/dashboard/src/components/profiles/ProfileLiveViewPanel.tsx b/dashboard/src/profiles/ProfileLiveViewPanel.tsx
similarity index 84%
rename from dashboard/src/components/profiles/ProfileLiveViewPanel.tsx
rename to dashboard/src/profiles/ProfileLiveViewPanel.tsx
index 9ad98c71..5cffcc78 100644
--- a/dashboard/src/components/profiles/ProfileLiveViewPanel.tsx
+++ b/dashboard/src/profiles/ProfileLiveViewPanel.tsx
@@ -1,6 +1,6 @@
-import type { Instance, InstanceTab } from "../../generated/types";
-import ScreencastTile from "../screencast/ScreencastTile";
-import { EmptyView } from "../molecules";
+import type { Instance, InstanceTab } from "../generated/types";
+import ScreencastTile from "../components/screencast/ScreencastTile";
+import { EmptyView } from "../components/molecules";
interface Props {
instance?: Instance;
diff --git a/dashboard/src/components/profiles/ProfileMetaInfoPanel.tsx b/dashboard/src/profiles/ProfileMetaInfoPanel.tsx
similarity index 98%
rename from dashboard/src/components/profiles/ProfileMetaInfoPanel.tsx
rename to dashboard/src/profiles/ProfileMetaInfoPanel.tsx
index d52cb442..ffdb9687 100644
--- a/dashboard/src/components/profiles/ProfileMetaInfoPanel.tsx
+++ b/dashboard/src/profiles/ProfileMetaInfoPanel.tsx
@@ -1,4 +1,4 @@
-import type { Profile, Instance } from "../../generated/types";
+import type { Profile, Instance } from "../generated/types";
interface Props {
profile: Profile;
diff --git a/dashboard/src/components/profiles/ProfileToolbar.tsx b/dashboard/src/profiles/ProfileToolbar.tsx
similarity index 95%
rename from dashboard/src/components/profiles/ProfileToolbar.tsx
rename to dashboard/src/profiles/ProfileToolbar.tsx
index 23aaa52c..98d99d0d 100644
--- a/dashboard/src/components/profiles/ProfileToolbar.tsx
+++ b/dashboard/src/profiles/ProfileToolbar.tsx
@@ -1,6 +1,6 @@
import { useState } from "react";
-import { Button } from "../atoms";
-import type { Profile, Instance } from "../../generated/types";
+import { Button } from "../components/atoms";
+import type { Profile, Instance } from "../generated/types";
interface Props {
profile: Profile;
diff --git a/dashboard/src/services/api.test.ts b/dashboard/src/services/api.test.ts
new file mode 100644
index 00000000..a2bf5dcd
--- /dev/null
+++ b/dashboard/src/services/api.test.ts
@@ -0,0 +1,61 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { createProfile, fetchProfiles, probeBackendAuth } from "./api";
+
+describe("api request headers", () => {
+ beforeEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it("tags dashboard GET requests with the dashboard source header", async () => {
+ const fetchMock = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => [],
+ });
+ vi.stubGlobal("fetch", fetchMock);
+
+ await fetchProfiles();
+
+ const [, init] = fetchMock.mock.calls[0] as [string, RequestInit];
+ expect(new Headers(init.headers).get("X-PinchTab-Source")).toBe(
+ "dashboard",
+ );
+ expect(init.credentials).toBe("same-origin");
+ });
+
+ it("preserves request headers while tagging dashboard POST requests", async () => {
+ const fetchMock = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => ({ status: "ok", id: "prof_123", name: "demo" }),
+ });
+ vi.stubGlobal("fetch", fetchMock);
+
+ await createProfile({ name: "demo" });
+
+ const [, init] = fetchMock.mock.calls[0] as [string, RequestInit];
+ const headers = new Headers(init.headers);
+ expect(headers.get("Content-Type")).toBe("application/json");
+ expect(headers.get("X-PinchTab-Source")).toBe("dashboard");
+ });
+
+ it("tags auth probe requests too", async () => {
+ const fetchMock = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => ({
+ version: "test",
+ uptime: 1,
+ profiles: 0,
+ instances: 0,
+ agents: 0,
+ authRequired: true,
+ }),
+ });
+ vi.stubGlobal("fetch", fetchMock);
+
+ await probeBackendAuth();
+
+ const [, init] = fetchMock.mock.calls[0] as [string, RequestInit];
+ expect(new Headers(init.headers).get("X-PinchTab-Source")).toBe(
+ "dashboard",
+ );
+ });
+});
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.ts
index 98210dfa..5cc6c6f6 100644
--- a/dashboard/src/services/api.ts
+++ b/dashboard/src/services/api.ts
@@ -29,6 +29,8 @@ import {
import { dispatchAuthRequired, sameOriginUrl } from "./auth";
const BASE = ""; // Uses proxy in dev
+const DASHBOARD_SOURCE_HEADER = "X-PinchTab-Source";
+const DASHBOARD_SOURCE = "dashboard";
type RequestMeta = {
suppressAuthRedirect?: boolean;
@@ -74,7 +76,7 @@ async function request<T>(
meta?: RequestMeta,
): Promise<T> {
const res = await fetch(BASE + url, {
- ...options,
+ ...withDashboardSource(options),
credentials: "same-origin",
});
if (!res.ok) {
@@ -93,7 +95,7 @@ async function requestText(
meta?: RequestMeta,
): Promise<string> {
const res = await fetch(BASE + url, {
- ...options,
+ ...withDashboardSource(options),
credentials: "same-origin",
});
if (!res.ok) {
@@ -112,7 +114,7 @@ async function requestBlob(
meta?: RequestMeta,
): Promise<Blob> {
const res = await fetch(BASE + url, {
- ...options,
+ ...withDashboardSource(options),
credentials: "same-origin",
});
if (!res.ok) {
@@ -125,6 +127,15 @@ async function requestBlob(
return res.blob();
}
+function withDashboardSource(options?: RequestInit): RequestInit {
+ const headers = new Headers(options?.headers);
+ headers.set(DASHBOARD_SOURCE_HEADER, DASHBOARD_SOURCE);
+ return {
+ ...options,
+ headers,
+ };
+}
+
// Profiles — endpoint is /profiles (no /api prefix)
export async function fetchProfiles(): Promise<Profile[]> {
return request<Profile[]>("/profiles");
@@ -314,6 +325,7 @@ export async function probeBackendAuth(): Promise<{
health?: DashboardServerInfo;
}> {
const res = await fetch(BASE + "/health", {
+ ...withDashboardSource(),
credentials: "same-origin",
});
if (res.ok) {
diff --git a/dashboard/src/components/tabs/InstanceTabsPanel.test.tsx b/dashboard/src/tabs/InstanceTabsPanel.test.tsx
similarity index 98%
rename from dashboard/src/components/tabs/InstanceTabsPanel.test.tsx
rename to dashboard/src/tabs/InstanceTabsPanel.test.tsx
index 6dac847f..c8c59970 100644
--- a/dashboard/src/components/tabs/InstanceTabsPanel.test.tsx
+++ b/dashboard/src/tabs/InstanceTabsPanel.test.tsx
@@ -1,7 +1,7 @@
import { render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it } from "vitest";
-import type { InstanceTab } from "../../generated/types";
+import type { InstanceTab } from "../generated/types";
import InstanceTabsPanel from "./InstanceTabsPanel";
const tabs: InstanceTab[] = [
diff --git a/dashboard/src/components/tabs/InstanceTabsPanel.tsx b/dashboard/src/tabs/InstanceTabsPanel.tsx
similarity index 97%
rename from dashboard/src/components/tabs/InstanceTabsPanel.tsx
rename to dashboard/src/tabs/InstanceTabsPanel.tsx
index 46570523..085b442b 100644
--- a/dashboard/src/components/tabs/InstanceTabsPanel.tsx
+++ b/dashboard/src/tabs/InstanceTabsPanel.tsx
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from "react";
-import type { InstanceTab } from "../../generated/types";
+import type { InstanceTab } from "../generated/types";
import TabBar from "./TabBar";
import SelectedTabPanel from "./SelectedTabPanel";
diff --git a/dashboard/src/components/tabs/SelectedTabPanel.tsx b/dashboard/src/tabs/SelectedTabPanel.tsx
similarity index 91%
rename from dashboard/src/components/tabs/SelectedTabPanel.tsx
rename to dashboard/src/tabs/SelectedTabPanel.tsx
index 79a74170..63f58e04 100644
--- a/dashboard/src/components/tabs/SelectedTabPanel.tsx
+++ b/dashboard/src/tabs/SelectedTabPanel.tsx
@@ -1,8 +1,8 @@
import { useMemo, useState } from "react";
-import { ActivityExplorer } from "../../activities";
-import type { InstanceTab } from "../../generated/types";
-import { TabsLayout, EmptyView } from "../molecules";
-import ScreencastTile from "../screencast/ScreencastTile";
+import { ActivityExplorer } from "../activities";
+import type { InstanceTab } from "../generated/types";
+import { TabsLayout, EmptyView } from "../components/molecules";
+import ScreencastTile from "../components/screencast/ScreencastTile";
import SelectedTabTitle from "./SelectedTabTitle";
interface Props {
diff --git a/dashboard/src/components/tabs/SelectedTabTitle.tsx b/dashboard/src/tabs/SelectedTabTitle.tsx
similarity index 84%
rename from dashboard/src/components/tabs/SelectedTabTitle.tsx
rename to dashboard/src/tabs/SelectedTabTitle.tsx
index 8067a03f..3f9268dd 100644
--- a/dashboard/src/components/tabs/SelectedTabTitle.tsx
+++ b/dashboard/src/tabs/SelectedTabTitle.tsx
@@ -1,5 +1,5 @@
-import type { InstanceTab } from "../../generated/types";
-import IdBadge from "./IdBadge";
+import type { InstanceTab } from "../generated/types";
+import IdBadge from "../components/molecules/IdBadge";
interface Props {
tab: InstanceTab;
diff --git a/dashboard/src/components/tabs/TabBar.tsx b/dashboard/src/tabs/TabBar.tsx
similarity index 97%
rename from dashboard/src/components/tabs/TabBar.tsx
rename to dashboard/src/tabs/TabBar.tsx
index 51ddfac0..14d7d0f8 100644
--- a/dashboard/src/components/tabs/TabBar.tsx
+++ b/dashboard/src/tabs/TabBar.tsx
@@ -1,5 +1,5 @@
-import type { InstanceTab } from "../../generated/types";
-import * as api from "../../services/api";
+import type { InstanceTab } from "../generated/types";
+import * as api from "../services/api";
interface Props {
tabs: InstanceTab[];
diff --git a/dashboard/src/components/tabs/TabItem.tsx b/dashboard/src/tabs/TabItem.tsx
similarity index 89%
rename from dashboard/src/components/tabs/TabItem.tsx
rename to dashboard/src/tabs/TabItem.tsx
index ea587720..0139ab8b 100644
--- a/dashboard/src/components/tabs/TabItem.tsx
+++ b/dashboard/src/tabs/TabItem.tsx
@@ -1,4 +1,4 @@
-import type { InstanceTab } from "../../generated/types";
+import type { InstanceTab } from "../generated/types";
interface Props {
tab: InstanceTab;
diff --git a/dashboard/src/components/tabs/index.ts b/dashboard/src/tabs/index.ts
similarity index 80%
rename from dashboard/src/components/tabs/index.ts
rename to dashboard/src/tabs/index.ts
index 72b04cfe..9ba86887 100644
--- a/dashboard/src/components/tabs/index.ts
+++ b/dashboard/src/tabs/index.ts
@@ -3,4 +3,4 @@ export { default as SelectedTabPanel } from "./SelectedTabPanel";
export { default as SelectedTabTitle } from "./SelectedTabTitle";
export { default as TabBar } from "./TabBar";
export { default as TabItem } from "./TabItem";
-export { default as IdBadge } from "./IdBadge";
+export { default as IdBadge } from "../components/molecules/IdBadge";