A desktop coding agent with free access to frontier models.
TypeScript
Brand guarded browser permission prompts without changing approval requests
Slendywy7e8779c82550
diff --git a/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsx b/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsxindex 0bdef30d..dc8f54d0 100644--- a/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsx+++ b/apps/app/src/react-app/domains/session/chat/permission-approval-modal.tsx@@ -13,6 +13,7 @@ import {} from "@/components/ui/alert-dialog";import { Button } from "@/components/ui/button";import { t } from "@/i18n";+import { displayRuntimeBrand } from "@/lib/display-runtime-brand";import type { PendingPermission } from "@/app/types";type PermissionPresentation = {@@ -65,7 +66,7 @@ function readablePermissionLabel(permission: string): string {if (permission === "todowrite") return t("session.permission_kind_todowrite");if (permission === "question") return t("session.permission_kind_question");if (permission === "skill") return t("session.permission_kind_skill");- return permission;+ return displayRuntimeBrand(permission);}function permissionCopy(permission: string): Pick<PermissionPresentation, "title" | "message"> {@@ -141,7 +142,7 @@ export function permissionDetailRows(metadata: Record<string, unknown>): Permissseen.add(item.labelKey);rows.push({label: t(item.labelKey),- value,+ value: displayRuntimeBrand(value),multiline: item.multiline,});}@@ -150,7 +151,7 @@ export function permissionDetailRows(metadata: Record<string, unknown>): Permissfunction stringifyMetadata(metadata: Record<string, unknown>, safeStringify?: (value: unknown) => string) {try {- return safeStringify ? safeStringify(metadata) : JSON.stringify(metadata, null, 2);+ return displayRuntimeBrand(safeStringify ? safeStringify(metadata) : JSON.stringify(metadata, null, 2));} catch {return t("session.permission_metadata_unavailable");}@@ -176,7 +177,7 @@ function describePermissionRequest(permission: PendingPermission): PermissionPremessage: t("session.doom_loop_message"),permissionLabel: t("session.doom_loop_label"),scopeLabel: tool ? t("session.doom_loop_tool_label") : t("session.doom_loop_repeated_call_label"),- scopeValue: tool ?? (patterns.length ? patterns.join(", ") : t("session.doom_loop_repeated_tool_call")),+ scopeValue: displayRuntimeBrand(tool ?? (patterns.length ? patterns.join(", ") : t("session.doom_loop_repeated_tool_call"))),isDoomLoop: true,note: t("session.doom_loop_note"),};@@ -188,7 +189,7 @@ function describePermissionRequest(permission: PendingPermission): PermissionPremessage: copy.message,permissionLabel: readablePermissionLabel(permission.permission),scopeLabel: t("session.scope_label"),- scopeValue: patterns.join(", ") || t("session.permission_scope_empty"),+ scopeValue: displayRuntimeBrand(patterns.join(", ") || t("session.permission_scope_empty")),isDoomLoop: false,note: null,};@@ -275,7 +276,7 @@ export function PermissionApprovalModal(props: PermissionApprovalModalProps) {data-permission-source="child-session"className="mt-2 text-[12px] font-medium text-amber-11">- {t("session.permission_requested_by", { session: props.sourceTitle })}+ {t("session.permission_requested_by", { session: displayRuntimeBrand(props.sourceTitle) })}</div>) : null}</div>@@ -402,7 +403,7 @@ export function PermissionApprovalPanel(props: PermissionApprovalModalProps) {data-permission-source="child-session"className="mt-1 text-[12px] font-medium leading-5 text-amber-11">- {t("session.permission_requested_by", { session: props.sourceTitle })}+ {t("session.permission_requested_by", { session: displayRuntimeBrand(props.sourceTitle) })}</div>) : null}{presentation.note ? (diff --git a/apps/app/src/react-app/shell/session-route.tsx b/apps/app/src/react-app/shell/session-route.tsxindex e5f23402..bbfcf5b5 100644--- a/apps/app/src/react-app/shell/session-route.tsx+++ b/apps/app/src/react-app/shell/session-route.tsx@@ -2576,7 +2576,7 @@ export function SessionRoute() {description: "Dev-only eval hook that creates a child session blocked on a permission request.",sideEffect: "mutation",disabled: !selectedWorkspaceId || !selectedSessionId,- execute: () => {+ execute: (args) => {if (!selectedWorkspaceId || !selectedSessionId) {return { ok: false, error: "No session is selected." };}@@ -2585,6 +2585,10 @@ export function SessionRoute() {);if (!parent) return { ok: false, error: "The selected session is unavailable." };+ const browserBranding = typeof args === "object" && args !== null+ && Reflect.get(args, "browserBranding") === true;+ const browserTool = "opencode-chrome-devtools_browser_open";+const childSessionId = `${selectedSessionId}:eval-child`;// Match a real session.created event: a concurrent list snapshot must// not remove this newly seeded child before its approval is answered.@@ -2592,9 +2596,12 @@ export function SessionRoute() {const request: PendingPermission = {id: `${selectedSessionId}:eval-child-permission`,sessionID: childSessionId,- permission: "bash",- patterns: ["git status --short --branch"],- metadata: {+ permission: browserBranding ? browserTool : "bash",+ patterns: browserBranding ? [browserTool] : ["git status --short --branch"],+ metadata: browserBranding ? {+ tool: browserTool,+ description: "OpenCode browser access",+ } : {command: "git status --short --branch",description: "Inspect the delegated task workspace",},diff --git a/apps/app/tests/permission-approval-modal.test.ts b/apps/app/tests/permission-approval-modal.test.tsindex f4a03ac2..ca1f803c 100644--- a/apps/app/tests/permission-approval-modal.test.ts+++ b/apps/app/tests/permission-approval-modal.test.ts@@ -98,6 +98,26 @@ describe("permission approval modal helpers", () => {expect(html).not.toContain("Approve todowrite?");});+ test("brands guarded browser permissions without changing the permission request", () => {+ const permission = pendingPermission({+ permission: "opencode-chrome-devtools_browser_open",+ patterns: ["opencode-chrome-devtools_browser_open"],+ metadata: { tool: "opencode-chrome-devtools_browser_open", description: "OpenCode browser access" },+ });+ const original = structuredClone(permission);+ const html = renderToStaticMarkup(React.createElement(PermissionApprovalPanel, {+ permission,+ sourceTitle: "OpenCode browser task",+ respondPermission: () => {},+ }));+ expect(html).toContain("Approve omnirush-chrome-devtools_browser_open?");+ expect(html).toContain("OmniRush browser access");+ expect(html).toContain("Requested by OmniRush browser task");+ expect(html.toLowerCase()).not.toContain("opencode");+ expect(permission).toEqual(original);+ expect(buttonText(html)).toEqual(["Deny", "Allow once", "Allow for session"]);+ });+test("identifies a permission requested by a child session", () => {const html = renderToStaticMarkup(React.createElement(PermissionApprovalPanel, {diff --git a/evals/specs/unfinished-tool-lifecycle.e2e.test.ts b/evals/specs/unfinished-tool-lifecycle.e2e.test.tsindex 564db8f0..9a0f8cc2 100644--- a/evals/specs/unfinished-tool-lifecycle.e2e.test.ts+++ b/evals/specs/unfinished-tool-lifecycle.e2e.test.ts@@ -27,4 +27,21 @@ test("unfinished current-turn tools expose active, waiting, and unknown outcomesawait user.notSee({ text: /Waiting for your action/ });await user.notSee("Running command, reading 1 file");});++ await step("guarded browser permission labels and details use OmniRush", async () => {+ await arrangeControl(seed, world.app, "eval.child_permission.seed", { browserBranding: true });+ await arrangeControl(seed, world.app, "eval.task_activity.seed", {+ childSessionId: `${world.session.sessionId}:eval-child`,+ });+ await user.see({ text: "Approve omnirush-chrome-devtools_browser_open?" });+ await user.notSee({ text: /opencode/i });+ // Seeded tool events need no model; dismiss the fixture's empty model picker.+ await user.press("Escape");+ await user.click({ text: "Details" });+ await user.see({ text: /OmniRush browser access/ });+ await user.notSee({ text: /opencode/i });+ await user.click("Allow once");+ await user.notSee({ text: "Approve omnirush-chrome-devtools_browser_open?" });+ await user.notSee({ text: /Requested by Investigate the deployment failure/ });+ });});