Open-source AI browser agent for Chrome and Firefox (monorepo) π§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Side panel: move the permission switch from the header to the composer toolbar
Claude92d4baa1da62
diff --git a/docs/prompt-injection-defense.md b/docs/prompt-injection-defense.mdindex cff669fdf..57337cac3 100644--- a/docs/prompt-injection-defense.md+++ b/docs/prompt-injection-defense.md@@ -38,8 +38,8 @@ them in sync β the test suite asserts the pure modules are byte-identical.- Code: `permission-gate.js` (`capabilityFor`, `requiredHosts`,`PermissionManager`); the gate loop in `agent.js _executeToolBatch`.- User control: Settings β Permissions (review/revoke grants + the master- switch "Ask before consequential actions"). The side panel header's- warning button toggles the same master switch; it never answers a pending+ switch "Ask before consequential actions"). The warning button in the side panel's+ composer toolbar toggles the same master switch; it never answers a pendingpermission card.4. **Output sanitizer (Layer 4).** Model output is HTML-escaped and only`[label](url)` markdown becomes an allowlisted (http/https/mailto) link β nodiff --git a/docs/slash-commands.md b/docs/slash-commands.mdindex bd15d4c33..2cec849ea 100644--- a/docs/slash-commands.md+++ b/docs/slash-commands.md@@ -36,7 +36,7 @@ for its available flags.| `/teach --end` | Stop teaching and compile the captured actions into a value-free saved workflow || `/allow-api` | **Per-conversation API mutation override.** See [below](#allow-api). || `/foreground [prompt]` | Run one local task in the foreground for visual compatibility |-| `/dangerously-skip-permissions` | **Global permission-prompt bypass.** Turns off `Ask before consequential actions` without opening Settings. WebBrain will act without per-site prompts until you re-enable the setting (Settings β Permissions, or the warning button in the side panel header). |+| `/dangerously-skip-permissions` | **Global permission-prompt bypass.** Turns off `Ask before consequential actions` without opening Settings. WebBrain will act without per-site prompts until you re-enable the setting (Settings β Permissions, or the warning button next to the microphone in the side panel composer). || `/compact` | Force context compaction for the current conversation || `/verbose` | Toggle verbose/compact tool display || `/reset` | Clear the conversation and all per-conversation flags |diff --git a/src/chrome/src/ui/sidepanel.html b/src/chrome/src/ui/sidepanel.htmlindex 2811cf7e1..4011291c5 100644--- a/src/chrome/src/ui/sidepanel.html+++ b/src/chrome/src/ui/sidepanel.html@@ -208,27 +208,6 @@<button type="button" class="ui-scale-reset" data-ui-scale-action="reset" data-i18n="sp.ui_scale.reset"></button></div></div>- <div id="permission-gate-menu" class="permission-gate-menu">- <button type="button" id="btn-permission-gate" aria-haspopup="true" aria-expanded="false" aria-controls="permission-gate-popover" data-i18n-title="sp.permissions.button" data-i18n-aria-label="sp.permissions.button">- <svg data-icon="triangle-alert" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">- <path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/>- <path d="M12 9v4"/>- <path d="M12 17h.01"/>- </svg>- </button>- <div id="permission-gate-popover" class="permission-gate-popover hidden" role="group" aria-labelledby="permission-gate-label">- <label class="permission-gate-row" for="toggle-permission-gate-header">- <span class="permission-gate-copy">- <span id="permission-gate-label" class="permission-gate-title" data-i18n="st.perms.gate.label">Ask before consequential actions</span>- <span id="permission-gate-desc" class="permission-gate-desc" data-i18n="sp.permissions.gate_desc">WebBrain asks the first time it clicks, types, downloads or runs code on a site.</span>- </span>- <input type="checkbox" id="toggle-permission-gate-header" class="permission-gate-input" role="switch" aria-describedby="permission-gate-desc permission-gate-off-note" checked>- <span class="permission-gate-switch" aria-hidden="true"></span>- </label>- <p id="permission-gate-off-note" class="permission-gate-off-note hidden" data-i18n="sp.permissions.gate_off">Off: WebBrain acts on every site without asking.</p>- <button type="button" id="btn-permission-gate-settings" class="permission-gate-settings" data-i18n="sp.permissions.manage">Manage site permissions</button>- </div>- </div><button id="btn-settings" data-i18n-title="sp.btn.settings"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/>@@ -435,6 +414,27 @@><span aria-hidden="true">β’</span></button><span id="status-dot" class="status-dot offline" data-i18n-title="sp.status.disconnected"></span><span class="composer-toolbar-spacer" aria-hidden="true"></span>+ <div id="permission-gate-menu" class="permission-gate-menu">+ <button type="button" id="btn-permission-gate" aria-haspopup="true" aria-expanded="false" aria-controls="permission-gate-popover" data-i18n-title="sp.permissions.button" data-i18n-aria-label="sp.permissions.button">+ <svg data-icon="triangle-alert" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">+ <path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/>+ <path d="M12 9v4"/>+ <path d="M12 17h.01"/>+ </svg>+ </button>+ <div id="permission-gate-popover" class="permission-gate-popover hidden" role="group" aria-labelledby="permission-gate-label">+ <label class="permission-gate-row" for="toggle-permission-gate-panel">+ <span class="permission-gate-copy">+ <span id="permission-gate-label" class="permission-gate-title" data-i18n="st.perms.gate.label">Ask before consequential actions</span>+ <span id="permission-gate-desc" class="permission-gate-desc" data-i18n="sp.permissions.gate_desc">WebBrain asks the first time it clicks, types, downloads or runs code on a site.</span>+ </span>+ <input type="checkbox" id="toggle-permission-gate-panel" class="permission-gate-input" role="switch" aria-describedby="permission-gate-desc permission-gate-off-note" checked>+ <span class="permission-gate-switch" aria-hidden="true"></span>+ </label>+ <p id="permission-gate-off-note" class="permission-gate-off-note hidden" data-i18n="sp.permissions.gate_off">Off: WebBrain acts on every site without asking.</p>+ <button type="button" id="btn-permission-gate-settings" class="permission-gate-settings" data-i18n="sp.permissions.manage">Manage site permissions</button>+ </div>+ </div><button id="btn-mic" data-i18n-title="sp.btn.mic"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/>diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.jsindex ce2e824c9..f293ca545 100644--- a/src/chrome/src/ui/sidepanel.js+++ b/src/chrome/src/ui/sidepanel.js@@ -1787,14 +1787,14 @@ chrome.storage.onChanged.addListener((changes) => {});-// Header switch for the same storage-backed gate as Settings β Permissions and+// Composer switch for the same storage-backed gate as Settings β Permissions and// /dangerously-skip-permissions. Turning prompts off posts the command's// persistent notice. A permission card already waiting is left for the user to// answer: a display switch must never approve a pending action on its own.const permissionGateMenu = document.getElementById('permission-gate-menu');const permissionGateBtn = document.getElementById('btn-permission-gate');const permissionGatePopover = document.getElementById('permission-gate-popover');-const permissionGateToggle = document.getElementById('toggle-permission-gate-header');+const permissionGateToggle = document.getElementById('toggle-permission-gate-panel');const permissionGateOffNote = document.getElementById('permission-gate-off-note');const permissionGateSettingsBtn = document.getElementById('btn-permission-gate-settings');let permissionGateWriteQueue = Promise.resolve();@@ -1813,7 +1813,7 @@ function renderPermissionGateControl() {permissionGateBtn.setAttribute('aria-label', t(key));}-function setPermissionGateFromHeader(askBefore) {+function setPermissionGateFromPanel(askBefore) {const write = permissionGateWriteQueue.then(async () => {const changed = askBeforeConsequential !== askBefore;await chrome.storage.local.set({ [PERMISSION_GATE_KEY]: askBefore });@@ -1854,7 +1854,7 @@ permissionGateBtn?.addEventListener('click', () => {if (willOpen) permissionGateToggle?.focus({ preventScroll: true });});permissionGateToggle?.addEventListener('change', () => {- setPermissionGateFromHeader(permissionGateToggle.checked).catch(() => {});+ setPermissionGateFromPanel(permissionGateToggle.checked).catch(() => {});});permissionGateSettingsBtn?.addEventListener('click', () => {closePermissionGatePopover();diff --git a/src/chrome/styles/sidepanel.css b/src/chrome/styles/sidepanel.cssindex 302fec163..7e1d3efa1 100644--- a/src/chrome/styles/sidepanel.css+++ b/src/chrome/styles/sidepanel.css@@ -891,33 +891,56 @@ html[data-ui-scale-ready="false"] body { visibility: hidden; }.ui-scale-popover output { min-width: 40px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }/* Permission prompts: the same switch as Settings β Permissions β Ask before- consequential actions. It opens below the header tools like the scale menu.- When prompts are off the trigger keeps a warning color and dot, so the state- stays visible while the popover is closed. The popover anchors to the tools- cluster (not its trigger) so it always fits a narrow or zoomed panel. */-.header-tools { position: relative; }+ consequential actions, as an icon in the composer toolbar next to the+ microphone. Its popover opens upward like the model picker's menu. When+ prompts are off the trigger keeps a warning color and dot, so the state stays+ visible while the popover is closed. The popover anchors to the toolbar (not+ its trigger) so it always fits a narrow or zoomed panel. */+.composer-toolbar { position: relative; }++#btn-permission-gate {+ position: relative;+ background: transparent;+ border: none;+ color: var(--text-secondary);+ width: 28px;+ height: 28px;+ padding: 0;+ border-radius: 50%;+ cursor: pointer;+ display: flex;+ align-items: center;+ justify-content: center;+ transition: background 0.2s, color 0.2s, transform 0.1s;+ flex-shrink: 0;+}++#btn-permission-gate:hover {+ background: var(--bg-secondary);+ color: var(--text-primary);+}-#header .header-tools #btn-permission-gate { position: relative; }+#btn-permission-gate:active { transform: scale(0.95); }-#header .header-tools #btn-permission-gate[aria-expanded="true"] {+#btn-permission-gate[aria-expanded="true"] {color: var(--text-primary);background: var(--accent-dim);}-#header .header-tools #btn-permission-gate.is-gate-off {+#btn-permission-gate.is-gate-off {color: var(--warning);}-#header .header-tools #btn-permission-gate.is-gate-off::after {+#btn-permission-gate.is-gate-off::after {content: '';position: absolute;- top: 2px;- inset-inline-end: 1px;+ top: 3px;+ inset-inline-end: 3px;width: 6px;height: 6px;border-radius: 50%;background: var(--warning);- box-shadow: 0 0 0 1.5px var(--bg-secondary);+ box-shadow: 0 0 0 1.5px var(--bg-input);}#btn-permission-gate:focus-visible {@@ -927,9 +950,9 @@ html[data-ui-scale-ready="false"] body { visibility: hidden; }.permission-gate-popover {position: absolute;- z-index: 30;- top: calc(100% + 7px);- inset-inline-start: 0;+ z-index: 40;+ bottom: calc(100% + 10px);+ inset-inline-end: 0;display: grid;gap: 8px;width: min(272px, calc(100vw / var(--ui-scale-zoom, 1) - 28px));@@ -1036,9 +1059,7 @@ html[dir="rtl"] .permission-gate-input:checked + .permission-gate-switch::before.permission-gate-off-note.hidden { display: none; }-/* Two ids: the generic `#header .header-tools button:not(...)` rule below- would otherwise turn this text link into an icon button. */-#header #permission-gate-popover .permission-gate-settings {+.permission-gate-settings {justify-self: start;padding: 0;border: 0;@@ -1051,7 +1072,7 @@ html[dir="rtl"] .permission-gate-input:checked + .permission-gate-switch::beforecursor: pointer;}-#header #permission-gate-popover .permission-gate-settings:hover {+.permission-gate-settings:hover {color: var(--accent-hover);background: none;}diff --git a/src/firefox/src/ui/sidepanel.html b/src/firefox/src/ui/sidepanel.htmlindex 67c12a80f..d08f8608d 100644--- a/src/firefox/src/ui/sidepanel.html+++ b/src/firefox/src/ui/sidepanel.html@@ -176,27 +176,6 @@<button type="button" class="ui-scale-reset" data-ui-scale-action="reset" data-i18n="sp.ui_scale.reset"></button></div></div>- <div id="permission-gate-menu" class="permission-gate-menu">- <button type="button" id="btn-permission-gate" aria-haspopup="true" aria-expanded="false" aria-controls="permission-gate-popover" data-i18n-title="sp.permissions.button" data-i18n-aria-label="sp.permissions.button">- <svg data-icon="triangle-alert" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">- <path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/>- <path d="M12 9v4"/>- <path d="M12 17h.01"/>- </svg>- </button>- <div id="permission-gate-popover" class="permission-gate-popover hidden" role="group" aria-labelledby="permission-gate-label">- <label class="permission-gate-row" for="toggle-permission-gate-header">- <span class="permission-gate-copy">- <span id="permission-gate-label" class="permission-gate-title" data-i18n="st.perms.gate.label">Ask before consequential actions</span>- <span id="permission-gate-desc" class="permission-gate-desc" data-i18n="sp.permissions.gate_desc">WebBrain asks the first time it clicks, types, downloads or runs code on a site.</span>- </span>- <input type="checkbox" id="toggle-permission-gate-header" class="permission-gate-input" role="switch" aria-describedby="permission-gate-desc permission-gate-off-note" checked>- <span class="permission-gate-switch" aria-hidden="true"></span>- </label>- <p id="permission-gate-off-note" class="permission-gate-off-note hidden" data-i18n="sp.permissions.gate_off">Off: WebBrain acts on every site without asking.</p>- <button type="button" id="btn-permission-gate-settings" class="permission-gate-settings" data-i18n="sp.permissions.manage">Manage site permissions</button>- </div>- </div><button id="btn-settings" data-i18n-title="sp.btn.settings"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/>@@ -388,6 +367,27 @@</div><span id="status-dot" class="status-dot offline" data-i18n-title="sp.status.disconnected"></span><span class="composer-toolbar-spacer" aria-hidden="true"></span>+ <div id="permission-gate-menu" class="permission-gate-menu">+ <button type="button" id="btn-permission-gate" aria-haspopup="true" aria-expanded="false" aria-controls="permission-gate-popover" data-i18n-title="sp.permissions.button" data-i18n-aria-label="sp.permissions.button">+ <svg data-icon="triangle-alert" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">+ <path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/>+ <path d="M12 9v4"/>+ <path d="M12 17h.01"/>+ </svg>+ </button>+ <div id="permission-gate-popover" class="permission-gate-popover hidden" role="group" aria-labelledby="permission-gate-label">+ <label class="permission-gate-row" for="toggle-permission-gate-panel">+ <span class="permission-gate-copy">+ <span id="permission-gate-label" class="permission-gate-title" data-i18n="st.perms.gate.label">Ask before consequential actions</span>+ <span id="permission-gate-desc" class="permission-gate-desc" data-i18n="sp.permissions.gate_desc">WebBrain asks the first time it clicks, types, downloads or runs code on a site.</span>+ </span>+ <input type="checkbox" id="toggle-permission-gate-panel" class="permission-gate-input" role="switch" aria-describedby="permission-gate-desc permission-gate-off-note" checked>+ <span class="permission-gate-switch" aria-hidden="true"></span>+ </label>+ <p id="permission-gate-off-note" class="permission-gate-off-note hidden" data-i18n="sp.permissions.gate_off">Off: WebBrain acts on every site without asking.</p>+ <button type="button" id="btn-permission-gate-settings" class="permission-gate-settings" data-i18n="sp.permissions.manage">Manage site permissions</button>+ </div>+ </div><button id="btn-mic" data-i18n-title="sp.btn.mic"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/>diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.jsindex 5f9fa09b5..42c40b3b1 100644--- a/src/firefox/src/ui/sidepanel.js+++ b/src/firefox/src/ui/sidepanel.js@@ -1962,14 +1962,14 @@ browser.storage.onChanged.addListener((changes) => {});-// Header switch for the same storage-backed gate as Settings β Permissions and+// Composer switch for the same storage-backed gate as Settings β Permissions and// /dangerously-skip-permissions. Turning prompts off posts the command's// persistent notice. A permission card already waiting is left for the user to// answer: a display switch must never approve a pending action on its own.const permissionGateMenu = document.getElementById('permission-gate-menu');const permissionGateBtn = document.getElementById('btn-permission-gate');const permissionGatePopover = document.getElementById('permission-gate-popover');-const permissionGateToggle = document.getElementById('toggle-permission-gate-header');+const permissionGateToggle = document.getElementById('toggle-permission-gate-panel');const permissionGateOffNote = document.getElementById('permission-gate-off-note');const permissionGateSettingsBtn = document.getElementById('btn-permission-gate-settings');let permissionGateWriteQueue = Promise.resolve();@@ -1988,7 +1988,7 @@ function renderPermissionGateControl() {permissionGateBtn.setAttribute('aria-label', t(key));}-function setPermissionGateFromHeader(askBefore) {+function setPermissionGateFromPanel(askBefore) {const write = permissionGateWriteQueue.then(async () => {const changed = askBeforeConsequential !== askBefore;await browser.storage.local.set({ [PERMISSION_GATE_KEY]: askBefore });@@ -2029,7 +2029,7 @@ permissionGateBtn?.addEventListener('click', () => {if (willOpen) permissionGateToggle?.focus({ preventScroll: true });});permissionGateToggle?.addEventListener('change', () => {- setPermissionGateFromHeader(permissionGateToggle.checked).catch(() => {});+ setPermissionGateFromPanel(permissionGateToggle.checked).catch(() => {});});permissionGateSettingsBtn?.addEventListener('click', () => {closePermissionGatePopover();diff --git a/src/firefox/styles/sidepanel.css b/src/firefox/styles/sidepanel.cssindex e7497c85a..4a52709da 100644--- a/src/firefox/styles/sidepanel.css+++ b/src/firefox/styles/sidepanel.css@@ -764,33 +764,56 @@ html[data-ui-scale-ready="false"] body { visibility: hidden; }.ui-scale-popover output { min-width: 40px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }/* Permission prompts: the same switch as Settings β Permissions β Ask before- consequential actions. It opens below the header tools like the scale menu.- When prompts are off the trigger keeps a warning color and dot, so the state- stays visible while the popover is closed. The popover anchors to the tools- cluster (not its trigger) so it always fits a narrow or zoomed panel. */-.header-tools { position: relative; }+ consequential actions, as an icon in the composer toolbar next to the+ microphone. Its popover opens upward like the model picker's menu. When+ prompts are off the trigger keeps a warning color and dot, so the state stays+ visible while the popover is closed. The popover anchors to the toolbar (not+ its trigger) so it always fits a narrow or zoomed panel. */+.composer-toolbar { position: relative; }++#btn-permission-gate {+ position: relative;+ background: transparent;+ border: none;+ color: var(--text-secondary);+ width: 28px;+ height: 28px;+ padding: 0;+ border-radius: 50%;+ cursor: pointer;+ display: flex;+ align-items: center;+ justify-content: center;+ transition: background 0.2s, color 0.2s, transform 0.1s;+ flex-shrink: 0;+}++#btn-permission-gate:hover {+ background: var(--bg-secondary);+ color: var(--text-primary);+}-#header .header-tools #btn-permission-gate { position: relative; }+#btn-permission-gate:active { transform: scale(0.95); }-#header .header-tools #btn-permission-gate[aria-expanded="true"] {+#btn-permission-gate[aria-expanded="true"] {color: var(--text-primary);background: var(--accent-dim);}-#header .header-tools #btn-permission-gate.is-gate-off {+#btn-permission-gate.is-gate-off {color: var(--warning);}-#header .header-tools #btn-permission-gate.is-gate-off::after {+#btn-permission-gate.is-gate-off::after {content: '';position: absolute;- top: 2px;- inset-inline-end: 1px;+ top: 3px;+ inset-inline-end: 3px;width: 6px;height: 6px;border-radius: 50%;background: var(--warning);- box-shadow: 0 0 0 1.5px var(--bg-secondary);+ box-shadow: 0 0 0 1.5px var(--bg-input);}#btn-permission-gate:focus-visible {@@ -800,9 +823,9 @@ html[data-ui-scale-ready="false"] body { visibility: hidden; }.permission-gate-popover {position: absolute;- z-index: 30;- top: calc(100% + 7px);- inset-inline-start: 0;+ z-index: 40;+ bottom: calc(100% + 10px);+ inset-inline-end: 0;display: grid;gap: 8px;width: min(272px, calc(100vw / var(--ui-scale-zoom, 1) - 28px));@@ -909,9 +932,7 @@ html[dir="rtl"] .permission-gate-input:checked + .permission-gate-switch::before.permission-gate-off-note.hidden { display: none; }-/* Two ids: the generic `#header .header-tools button:not(...)` rule below- would otherwise turn this text link into an icon button. */-#header #permission-gate-popover .permission-gate-settings {+.permission-gate-settings {justify-self: start;padding: 0;border: 0;@@ -924,7 +945,7 @@ html[dir="rtl"] .permission-gate-input:checked + .permission-gate-switch::beforecursor: pointer;}-#header #permission-gate-popover .permission-gate-settings:hover {+.permission-gate-settings:hover {color: var(--accent-hover);background: none;}diff --git a/test/run.js b/test/run.jsindex 253a9ce19..4478eb193 100644--- a/test/run.js+++ b/test/run.js@@ -43953,10 +43953,11 @@ test('sidepanel keeps display tools and conversation actions in the header and tconst tools = header.match(/<div class="header-tools">[\s\S]*?\n <\/div>\n/)?.[0] || '';const conversation = header.slice(header.indexOf('class="conversation-action-group header-conversation"'));- for (const id of ['btn-expand', 'btn-ui-scale', 'btn-permission-gate', 'btn-settings']) {+ for (const id of ['btn-expand', 'btn-ui-scale', 'btn-settings']) {assert.match(tools, new RegExp(`id="${id}"`), `${label}: ${id} should stay with the header display tools`);}- assert.match(tools, /id="language-picker"[\s\S]*?id="btn-ui-scale"[\s\S]*?id="btn-permission-gate"[\s\S]*?id="btn-settings"[\s\S]*?id="btn-expand"/, `${label}: the display tools should run the display preferences, the permission switch, then Settings, then pop-out`);+ assert.match(tools, /id="language-picker"[\s\S]*?id="btn-ui-scale"[\s\S]*?id="btn-settings"[\s\S]*?id="btn-expand"/, `${label}: the display tools should run the display preferences, then Settings, then pop-out`);+ assert.doesNotMatch(header, /id="btn-permission-gate"/, `${label}: the permission switch lives in the composer toolbar, not the header`);assert.ok(header.indexOf('class="header-tools"') < header.indexOf('header-conversation'), `${label}: the display tools should lead the header and the conversation actions close it`);assert.match(conversation, /id="btn-history"[\s\S]*?id="history-popover"[\s\S]*?id="btn-clear"/, `${label}: History and New chat should close the header, with the creation action at its edge`);assert.doesNotMatch(header, /id="provider-picker"|id="mode-toggle"/, `${label}: the model picker and the modes should leave the header`);@@ -47968,7 +47969,7 @@ test('sidepanel UI scale exposes mirrored levels, layout, and focused shortcuts'}});-test('sidepanel header permission switch drives the Settings gate in both builds', async () => {+test('sidepanel composer permission switch drives the Settings gate in both builds', async () => {const keys = ['sp.permissions.button', 'sp.permissions.button_off', 'sp.permissions.gate_desc', 'sp.permissions.gate_off', 'sp.permissions.manage', 'sp.permissions.enabled'];const sources = {};for (const [label, prefix, api] of [['chrome', 'src/chrome', 'chrome'], ['firefox', 'src/firefox', 'browser']]) {@@ -47977,9 +47978,11 @@ test('sidepanel header permission switch drives the Settings gate in both buildsconst css = fs.readFileSync(path.join(ROOT, prefix, 'styles/sidepanel.css'), 'utf8');const trigger = html.match(/<button[^>]*id="btn-permission-gate"[\s\S]*?<\/button>/)?.[0] || '';assert.match(trigger, /aria-haspopup="true"[^>]*aria-expanded="false"[^>]*aria-controls="permission-gate-popover"[^>]*data-i18n-title="sp\.permissions\.button"[^>]*data-i18n-aria-label="sp\.permissions\.button"/, `${label}: the trigger should be a labelled menu button like the scale control`);- assert.match(trigger, /data-icon="triangle-alert"[\s\S]*?stroke-width="2"[\s\S]*?stroke-linecap="round"[\s\S]*?stroke-linejoin="round"/, `${label}: the trigger should use the native Lucide-style warning icon`);+ assert.match(trigger, /data-icon="triangle-alert"[^>]*width="18"[^>]*height="18"[\s\S]*?stroke-width="2\.25"[\s\S]*?stroke-linecap="round"[\s\S]*?stroke-linejoin="round"/, `${label}: the trigger should use the Lucide-style warning icon at the composer icons' size and stroke`);+ const toolbar = html.match(/<div class="composer-toolbar">[\s\S]*?id="btn-send"/)?.[0] || '';+ assert.match(toolbar, /id="btn-attach"[\s\S]*?class="composer-toolbar-spacer"[\s\S]*?id="permission-gate-menu"[\s\S]*?id="btn-mic"/, `${label}: the switch should sit in the composer toolbar, next to the microphone`);assert.doesNotMatch(trigger, /β /, `${label}: the trigger should not use an emoji glyph as an icon`);- assert.match(html, /id="permission-gate-popover"[^>]*class="permission-gate-popover hidden"[\s\S]*?data-i18n="st\.perms\.gate\.label"[\s\S]*?data-i18n="sp\.permissions\.gate_desc"[\s\S]*?id="toggle-permission-gate-header"[^>]*role="switch"[\s\S]*?id="permission-gate-off-note"[^>]*data-i18n="sp\.permissions\.gate_off"[\s\S]*?id="btn-permission-gate-settings"/, `${label}: the popover should hold the Settings switch label, its explanation, the off note and the site list link`);+ assert.match(html, /id="permission-gate-popover"[^>]*class="permission-gate-popover hidden"[\s\S]*?data-i18n="st\.perms\.gate\.label"[\s\S]*?data-i18n="sp\.permissions\.gate_desc"[\s\S]*?id="toggle-permission-gate-panel"[^>]*role="switch"[\s\S]*?id="permission-gate-off-note"[^>]*data-i18n="sp\.permissions\.gate_off"[\s\S]*?id="btn-permission-gate-settings"/, `${label}: the popover should hold the Settings switch label, its explanation, the off note and the site list link`);const start = panel.indexOf("const permissionGateMenu = document.getElementById('permission-gate-menu');");const end = panel.indexOf('\nrenderPermissionGateControl();\n', start);@@ -47988,19 +47991,17 @@ test('sidepanel header permission switch drives the Settings gate in both buildsconst block = panel.slice(start, end);assert.match(block, new RegExp(`${api}\\.storage\\.local\\.set\\(\\{ \\[PERMISSION_GATE_KEY\\]: askBefore \\}\\)`), `${label}: the switch should write the same storage key as Settings`);assert.match(block, /else addPersistentSlashMessage\(systemHtml\(t\('sp\.permissions\.disabled_html'\)\)\)/, `${label}: turning prompts off should post the command's persistent notice`);- assert.doesNotMatch(block, /resolvePendingPermissionPrompt/, `${label}: the header switch must never approve a pending permission card`);+ assert.doesNotMatch(block, /resolvePendingPermissionPrompt/, `${label}: the composer switch must never approve a pending permission card`);assert.match(block, /permissionGateWriteQueue = write\.catch\(\(\) => renderPermissionGateControl\(\)\)/, `${label}: a failed write should restore the stored state`);assert.match(block, /settings\.html#permissions/, `${label}: the popover should open Settings at the site permission list`);assert.match(panel, /if \(changes\[PERMISSION_GATE_KEY\]\) \{[\s\S]*?renderPermissionGateControl\(\);/, `${label}: changes made in Settings or by the command should update the switch`);assert.match(panel, /storage\.local\.get\(\[PERMISSION_GATE_KEY, ACT_WARNING_DISMISSED_KEY\]\)\.then\([\s\S]*?renderPermissionGateControl\(\);/, `${label}: the stored gate should hydrate the switch`);assert.match(panel, /if \(closeUiScalePopover\(\)\) \{[\s\S]*?\}\n\s*if \(closePermissionGatePopover\(\)\) \{[\s\S]*?permissionGateBtn\?\.focus\(\);\s*return;/, `${label}: Escape should close the switch instead of aborting the active run`);- assert.match(css, /#header \.header-tools #btn-permission-gate\.is-gate-off \{\s*color: var\(--warning\);/, `${label}: prompts off should keep the trigger in the warning color`);- assert.match(css, /#header #permission-gate-popover \.permission-gate-settings \{/, `${label}: the link should outrank the generic header icon button rule`);- assert.match(css, /\.permission-gate-popover \{[\s\S]*?position: absolute;[\s\S]*?inset-inline-start: 0;[\s\S]*?width: min\(272px, calc\(100vw \/ var\(--ui-scale-zoom, 1\) - 28px\)\);/, `${label}: the popover should open inward and fit a narrow or zoomed panel`);- assert.ok(- css.indexOf('@media (max-width: 380px)') > css.lastIndexOf('#header #permission-gate-popover'),- `${label}: the narrow-panel header overrides must still follow the header rules`,- );+ assert.match(css, /#btn-permission-gate\.is-gate-off \{\s*color: var\(--warning\);/, `${label}: prompts off should keep the trigger in the warning color`);+ assert.match(css, /#btn-attach,\n#btn-mic \{[\s\S]*?width: 28px;\n height: 28px;/, `${label}: the composer icon buttons keep their size`);+ assert.match(css, /#btn-permission-gate \{[\s\S]*?width: 28px;\n height: 28px;[\s\S]*?border-radius: 50%;/, `${label}: the switch should match the composer icon buttons`);+ assert.doesNotMatch(css, /#header[^{]*#btn-permission-gate|#header #permission-gate-popover/, `${label}: no header-only rules should remain for the switch`);+ assert.match(css, /\.permission-gate-popover \{[\s\S]*?position: absolute;[\s\S]*?bottom: calc\(100% \+ 10px\);[\s\S]*?inset-inline-end: 0;[\s\S]*?width: min\(272px, calc\(100vw \/ var\(--ui-scale-zoom, 1\) - 28px\)\);/, `${label}: the popover should open upward from the composer and fit a narrow or zoomed panel`);const localeDir = path.join(ROOT, prefix, 'src/ui/locales');for (const file of fs.readdirSync(localeDir).filter((name) => name.endsWith('.js'))) {diff --git a/test/sidepanel-permission-gate-ui.mjs b/test/sidepanel-permission-gate-ui.mjsindex 9efa575d9..a1ece1d1b 100644--- a/test/sidepanel-permission-gate-ui.mjs+++ b/test/sidepanel-permission-gate-ui.mjs@@ -5,7 +5,7 @@ import { chromium, firefox } from 'playwright';const read = async (build, file) => (await fs.readFile(new URL(`../src/${build}/${file}`, import.meta.url), 'utf8')).replace(/\r\n/g, '\n');-// Runs the production header switch (its whole block in sidepanel.js) against+// Runs the production composer switch (its whole block in sidepanel.js) against// the real panel markup, styles and English strings. Only storage, tabs and the// chat helpers it calls are fixtures, so the test sees every write and notice.for (const [build, engine, api] of [['chrome', chromium, 'chrome'], ['firefox', firefox, 'browser']]) {@@ -84,7 +84,7 @@ for (const [build, engine, api] of [['chrome', chromium, 'chrome'], ['firefox',off: btn.classList.contains('is-gate-off'),dot: getComputedStyle(btn, '::after').content,open: !popover.classList.contains('hidden'),- checked: document.getElementById('toggle-permission-gate-header').checked,+ checked: document.getElementById('toggle-permission-gate-panel').checked,noteShown: !document.getElementById('permission-gate-off-note').classList.contains('hidden'),focus: document.activeElement?.id || '',log: structuredClone(window.__log),@@ -110,7 +110,7 @@ for (const [build, engine, api] of [['chrome', chromium, 'chrome'], ['firefox',s = await state();assert.equal(s.open, true);assert.equal(s.expanded, 'true');- assert.equal(s.focus, 'toggle-permission-gate-header', 'focus moves to the switch');+ assert.equal(s.focus, 'toggle-permission-gate-panel', 'focus moves to the switch');assert.equal(s.log.scaleClosed, 1, 'opening it closes the scale menu');assert.match(await page.textContent('#permission-gate-popover'), /Ask before consequential actions[\s\S]*WebBrain asks the first time/);@@ -162,7 +162,7 @@ for (const [build, engine, api] of [['chrome', chromium, 'chrome'], ['firefox',await page.click('#btn-permission-gate');await page.evaluate(() => window.__failNextWrite());await page.click('.permission-gate-row');- await page.waitForFunction(() => document.getElementById('toggle-permission-gate-header').checked === true);+ await page.waitForFunction(() => document.getElementById('toggle-permission-gate-panel').checked === true);const s = await state();assert.deepEqual(s.log.writes, []);assert.deepEqual(s.log.notices, []);@@ -175,9 +175,10 @@ for (const [build, engine, api] of [['chrome', chromium, 'chrome'], ['firefox',await page.click('#btn-permission-gate');const box = await page.locator('#permission-gate-popover').boundingBox();assert.ok(box.x >= 0 && box.x + box.width <= 360, `popover stays inside a 360px panel (${box.x}+${box.width})`);+ const toolbar = await page.locator('.composer-toolbar').boundingBox();+ assert.ok(box.y >= 0 && box.y + box.height <= toolbar.y, `popover opens upward above the composer toolbar (${box.y}+${box.height} vs ${toolbar.y})`);+ assert.ok(toolbar.height <= 36, 'the composer toolbar stays on one row');const header = await page.locator('#header').boundingBox();- const tools = await page.locator('.header-tools').boundingBox();- assert.ok(tools.height <= 32, 'header tools stay on one row');assert.ok(header.height <= 56, 'the header does not wrap');await page.click('#btn-permission-gate-settings');await page.waitForFunction(() => window.__log.opened.length === 1);