Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(chat): wrap long slash command chips in the transcript (#1019)

Yuxinod9f6e024a7a0
diff --git a/apps/desktop/src/components/settings/RemoteHostsPage.tsx b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
index c91ad1ab7..4e4660390 100644
--- a/apps/desktop/src/components/settings/RemoteHostsPage.tsx
+++ b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
@@ -245,8 +245,8 @@ export function RemoteHostsPage() {
value={addMode}
onChange={(mode) => setAddMode(mode)}
options={[
- { value: "ssh", label: t("settings.remoteHosts.addSsh") },
- { value: "pair", label: t("settings.remoteHosts.addPair") },
+ { value: "ssh", label: t("settings.remoteHosts.addSsh"), id: "remote-host-add-ssh", controls: "remote-host-add-panel-ssh" },
+ { value: "pair", label: t("settings.remoteHosts.addPair"), id: "remote-host-add-pair", controls: "remote-host-add-panel-pair" },
]}
label={t("settings.remoteHosts.addTitle")}
role="tablist"
diff --git a/apps/desktop/src/components/ui.tsx b/apps/desktop/src/components/ui.tsx
index 260d8059c..08ff6e781 100644
--- a/apps/desktop/src/components/ui.tsx
+++ b/apps/desktop/src/components/ui.tsx
@@ -695,7 +695,12 @@ export function SegmentedControl<T extends string>({
}: {
value: T;
onChange: (value: T) => void;
- options: readonly { readonly value: T; readonly label: ReactNode }[];
+ options: readonly {
+ readonly value: T;
+ readonly label: ReactNode;
+ readonly id?: string;
+ readonly controls?: string;
+ }[];
label: string;
role?: "group" | "radiogroup" | "tablist";
className?: string;
@@ -714,7 +719,7 @@ export function SegmentedControl<T extends string>({
key={option.value}
type="button"
{...(itemRole === "tab"
- ? { role: "tab", id: `${label}-tab-${option.value}`, "aria-selected": value === option.value }
+ ? { role: "tab", id: option.id ?? `${label}-tab-${option.value}`, "aria-controls": option.controls, "aria-selected": value === option.value }
: itemRole === "radio"
? { role: "radio", "aria-checked": value === option.value }
: { "aria-pressed": value === option.value })}
diff --git a/apps/desktop/src/features/settings/import-page.tsx b/apps/desktop/src/features/settings/import-page.tsx
index aecf4cdcb..7fce10716 100644
--- a/apps/desktop/src/features/settings/import-page.tsx
+++ b/apps/desktop/src/features/settings/import-page.tsx
@@ -62,6 +62,8 @@ export function ImportSection() {
options={IMPORT_KINDS.map((entry) => ({
value: entry.id,
label: t(entry.labelKey),
+ id: `import-tab-${entry.id}`,
+ controls: `import-panel-${entry.id}`,
}))}
label={t("settings.import")}
role="tablist"
diff --git a/apps/desktop/src/styles/composer-autocomplete.css b/apps/desktop/src/styles/composer-autocomplete.css
index 07c1fcd8f..ee1cda534 100644
--- a/apps/desktop/src/styles/composer-autocomplete.css
+++ b/apps/desktop/src/styles/composer-autocomplete.css
@@ -111,13 +111,15 @@
flex: 0 0 auto;
}
-/* Typed slash invocation rendered as a chip in the transcript (D123). */
+/* Typed slash invocation rendered as a chip in the transcript (D123).
+ Skill invocations carry the user's whole typed body, so the chip wraps
+ like .message-user-text instead of truncating. */
.chat-command-chip {
display: inline-block;
max-width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+ vertical-align: top;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
padding: 2px 8px;
border-radius: var(--radius-md);
background: var(--ds-tile-deep);
diff --git a/apps/desktop/src/styles/composer-menus.css b/apps/desktop/src/styles/composer-menus.css
index 75e5b5952..203ed2a8d 100644
--- a/apps/desktop/src/styles/composer-menus.css
+++ b/apps/desktop/src/styles/composer-menus.css
@@ -255,8 +255,6 @@
max-height: 280px;
flex-direction: column;
overflow-y: auto;
- scrollbar-width: thin;
- scrollbar-color: var(--ds-border-default) transparent;
}
/* Reasoning slider (issue #417): the menu root carries the slider directly
@@ -514,8 +512,6 @@
.composer-model-list {
max-height: 280px;
overflow-y: auto;
- scrollbar-width: thin;
- scrollbar-color: var(--ds-border-default) transparent;
}
.composer-model-group-label {
@@ -538,9 +534,8 @@
text-transform: none;
}
-/* Model rows sit at one tab stop below their provider heading, so groups keep
- a clear parent → child hierarchy without changing the option's label. The
- smaller normal-weight text keeps the provider heading as the visual anchor. */
+/* Model rows share the provider heading's compact inset. Normal-weight option
+ text stays distinct from the stronger provider heading. */
.composer-model-group .composer-model-option {
padding-left: 8px;
font-size: var(--text-sm);
diff --git a/apps/desktop/test/agent-capability-settings.test.mjs b/apps/desktop/test/agent-capability-settings.test.mjs
index 7db21f9fd..d4b01d97f 100644
--- a/apps/desktop/test/agent-capability-settings.test.mjs
+++ b/apps/desktop/test/agent-capability-settings.test.mjs
@@ -55,7 +55,7 @@ test("skills and MCP filter one list by level instead of stacking two sections",
}
assert.doesNotMatch(layout, /AgentCapabilitySection|AgentCapabilityColumn/);
assert.match(layout, /agent-capability-list/);
- assert.match(layout, /role="radiogroup"/);
+ assert.match(layout, /<SegmentedControl[\s\S]*?value=\{filter\}/);
assert.match(layout, /settings\.capabilityFilterAll/);
// Subagents are global-only, so they get no level filter and no project.
assert.doesNotMatch(subagents, /AgentProjectPicker|projectPath|CapabilityFilter/);
@@ -116,8 +116,9 @@ test("capability surfaces use the shared settings hierarchy", () => {
});
test("the workbench reuses the shared segmented control instead of a third copy", () => {
- assert.match(layout, /"settings-segment", "agent-capability-segment"|settings-segment agent-capability-segment/);
- assert.match(layout, /"settings-segment-item"/);
+ assert.match(layout, /<SegmentedControl/);
+ assert.match(layout, /className="agent-capability-segment"/);
+ assert.match(layout, /itemClassName="agent-capability-segment-btn"/);
// providers.css defines the shared segment and imports after settings.css, so
// a bare local class would silently lose. Every local override must compound.
for (const decl of [
diff --git a/apps/desktop/test/composer-model-thinking-menu.test.mjs b/apps/desktop/test/composer-model-thinking-menu.test.mjs
index dafabf5dc..9137d46d4 100644
--- a/apps/desktop/test/composer-model-thinking-menu.test.mjs
+++ b/apps/desktop/test/composer-model-thinking-menu.test.mjs
@@ -102,17 +102,17 @@ test("the combined chip and menu meet the compact accessible visual contract", (
assert.match(composerSource, /event\.key === "Escape"/);
assert.match(stylesSource, /\.composer-model-thinking-menu\s*\{[\s\S]*?position:\s*fixed;/);
assert.match(stylesSource, /\.composer-model-thinking-menu\s*\{[\s\S]*?top:\s*0;/);
- assert.match(stylesSource, /\.composer-model-thinking-menu\s*\{[\s\S]*?width:\s*min\(300px,\s*calc\(100vw - 24px\)\)/);
+ assert.match(stylesSource, /\.composer-model-thinking-menu\s*\{[\s\S]*?width:\s*min\(280px,\s*calc\(100vw - 24px\)\)/);
assert.match(composerSource, /className="composer-model-thinking-icon"[\s\S]*?<IconBot size=\{14\} \/>/);
assert.doesNotMatch(stylesSource, /\.composer-model-thinking-icon\.is-off/);
assert.match(stylesSource, /@media \(prefers-reduced-motion: reduce\)/);
});
-test("model options are visually nested under their provider heading", () => {
+test("model options share the compact provider heading inset", () => {
assert.match(composerSource, /composer-plus-item composer-model-option/);
assert.match(
stylesSource,
- /\.composer-model-group \.composer-model-option\s*\{[\s\S]*?padding-left:\s*22px/,
+ /\.composer-model-group \.composer-model-option\s*\{[\s\S]*?padding-left:\s*8px/,
);
});
@@ -126,11 +126,11 @@ test("model groups use the account-aware display name", () => {
test("provider headings establish a stronger type level than model rows", () => {
assert.match(
stylesSource,
- /\.composer-model-group-label\s*\{[\s\S]*?font-size:\s*var\(--text-md\)/,
+ /\.composer-model-group-label\s*\{[^}]*font-size:\s*var\(--text-xs-plus\)[^}]*font-weight:\s*var\(--font-weight-strong\)/,
);
assert.match(
stylesSource,
- /\.composer-model-group \.composer-model-option\s*\{[\s\S]*?font-size:\s*var\(--text-sm\)[\s\S]*?font-weight:\s*var\(--font-weight-normal\)/,
+ /\.composer-model-group \.composer-model-option\s*\{[^}]*font-size:\s*var\(--text-sm\)[^}]*font-weight:\s*var\(--font-weight-normal\)/,
);
assert.match(
stylesSource,
diff --git a/apps/desktop/test/plan-mode-source-contract.test.mjs b/apps/desktop/test/plan-mode-source-contract.test.mjs
index c23b3af9e..40113e860 100644
--- a/apps/desktop/test/plan-mode-source-contract.test.mjs
+++ b/apps/desktop/test/plan-mode-source-contract.test.mjs
@@ -44,8 +44,8 @@ test("renderer exposes Agent, Plan, and Goal as the only operating modes", () =>
assert.match(composerSource, /settings\.modeGoal/);
assert.match(composerSource, /IconListChecks/);
assert.match(composerSource, /IconTarget/);
- assert.match(settingsSource, /\["plan", "settings\.modePlan"\]/);
- assert.match(settingsSource, /\["goal", "settings\.modeGoal"\]/);
+ assert.match(settingsSource, /value: "plan", label: t\("settings\.modePlan"\)/);
+ assert.match(settingsSource, /value: "goal", label: t\("settings\.modeGoal"\)/);
assert.match(commandsSource, /case "builtin\.mode\.plan"/);
assert.match(commandsSource, /case "builtin\.mode\.goal"/);
for (const source of [composerSource, settingsSource, commandsSource]) {
diff --git a/apps/desktop/test/segmented-control.test.mjs b/apps/desktop/test/segmented-control.test.mjs
new file mode 100644
index 000000000..624d82a41
--- /dev/null
+++ b/apps/desktop/test/segmented-control.test.mjs
@@ -0,0 +1,43 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+import { renderToStaticMarkup } from "react-dom/server";
+import { createServer } from "vite";
+
+test("segmented controls preserve selection semantics and stable tab-panel links", async () => {
+ const server = await createServer({
+ root: fileURLToPath(new URL("..", import.meta.url)),
+ configFile: false,
+ server: { middlewareMode: true, hmr: false, ws: false },
+ esbuild: { jsx: "automatic" },
+ appType: "custom",
+ optimizeDeps: { noDiscovery: true, include: [] },
+ });
+ try {
+ const { SegmentedControl } = await server.ssrLoadModule("/src/components/ui.tsx");
+ const options = [
+ { value: "ssh", label: "SSH", id: "host-ssh", controls: "panel-ssh" },
+ { value: "pair", label: "Pair", id: "host-pair", controls: "panel-pair" },
+ ];
+ let value = "ssh";
+ const render = (props = {}) => SegmentedControl({
+ value, options, label: "Add host", role: "tablist",
+ onChange: (next) => { value = next; }, ...props,
+ });
+ for (const label of ["Add host", "添加主机"]) {
+ const html = renderToStaticMarkup(render({ label }));
+ assert.match(html, /role="tab" id="host-ssh" aria-controls="panel-ssh" aria-selected="true"/);
+ assert.match(html, /role="tab" id="host-pair" aria-controls="panel-pair" aria-selected="false"/);
+ }
+ render().props.children.find((tab) => tab.props.id === "host-pair").props.onClick();
+ assert.equal(value, "pair");
+ const selected = renderToStaticMarkup(render());
+ assert.match(selected, /id="host-pair" aria-controls="panel-pair" aria-selected="true"/);
+ assert.match(selected, /id="host-ssh" aria-controls="panel-ssh" aria-selected="false"/);
+ assert.match(renderToStaticMarkup(render({ role: undefined })), /role="radio" aria-checked="true"/);
+ assert.match(renderToStaticMarkup(render({ role: "group" })), /aria-pressed="true"/);
+ assert.equal((renderToStaticMarkup(render({ disabled: true })).match(/disabled=""/g) ?? []).length, 2);
+ } finally {
+ await server.close();
+ }
+});
diff --git a/apps/desktop/test/settings-general.test.mjs b/apps/desktop/test/settings-general.test.mjs
index dc784da57..9a9d1906e 100644
--- a/apps/desktop/test/settings-general.test.mjs
+++ b/apps/desktop/test/settings-general.test.mjs
@@ -101,11 +101,11 @@ const networkProxySource = await readFile(
test("Basics and AI tabs expose their respective app and AI controls", () => {
const generalStart = settingsPageSource.indexOf('{tab === "general" && settings && (');
const aiStart = settingsPageSource.indexOf('{tab === "ai" && settings && (');
- const shortcutsStart = settingsPageSource.indexOf(
- '{tab === "shortcuts" && settings && (',
+ const voiceStart = settingsPageSource.indexOf(
+ '{tab === "voice" && settings && (',
);
const generalSource = settingsPageSource.slice(generalStart, aiStart);
- const aiSource = settingsPageSource.slice(aiStart, shortcutsStart);
+ const aiSource = settingsPageSource.slice(aiStart, voiceStart);
assert.match(generalSource, /<ThemeRow /);
assert.match(generalSource, /<LanguageRow /);
@@ -157,10 +157,9 @@ test("Basics and AI tabs expose their respective app and AI controls", () => {
// The AI tab keeps the Settings picker control: a native <select> popup is
// platform-drawn and cannot carry the shared menu surface or its check mark.
assert.doesNotMatch(aiSource, /<select/);
- // Speech is not a Settings surface: the AI tab renders no voice card, search
- // indexes no speech keys, its styles are gone, and the host capability keeps
- // its IPC contract (ADR 0291).
- assert.doesNotMatch(settingsPageSource, /VoiceSettingsCard|voice-settings/);
+ // Voice owns a separate destination; the AI tab does not duplicate it.
+ assert.doesNotMatch(aiSource, /VoiceSettingsCard|VoiceSettingsSection|voice-settings/);
+ assert.match(settingsPageSource, /tab === "voice" && settings && [\s\S]*?<VoiceSettingsSection/);
assert.doesNotMatch(settingsSearchSource, /settings\.speech/);
assert.doesNotMatch(stylesSource, /\.settings-speech/);
assert.doesNotMatch(enLocaleSource, /speechTitle:|speechVoicePlaceholder:/);
@@ -205,7 +204,7 @@ test("General Network card persists a custom HTTP or SOCKS5 proxy and the relaxe
test("basics gates developer tools behind a persisted developer mode", () => {
assert.match(sharedTypesSource, /developerMode\?: boolean/);
assert.match(settingsPageSource, /function DeveloperSection/);
- assert.match(settingsPageSource, /role="switch"/);
+ assert.match(settingsPageSource, /<SettingsToggle\s+checked=\{enabled\}/);
assert.match(settingsPageSource, /saveSettings\(\{ developerMode: !enabled \}\)/);
assert.match(settingsPageSource, /api\.toggleDevTools\(true\)/);
assert.match(settingsPageSource, /disabled=\{!enabled\}/);
diff --git a/apps/desktop/test/settings-import-page.test.mjs b/apps/desktop/test/settings-import-page.test.mjs
index cc81e03e4..c0a30d518 100644
--- a/apps/desktop/test/settings-import-page.test.mjs
+++ b/apps/desktop/test/settings-import-page.test.mjs
@@ -30,7 +30,8 @@ function cssRule(selector) {
test("import is one workbench per kind instead of four stacked scan cards", () => {
// One tab strip owns the four kinds; each kind gets one panel behind it.
assert.match(page, /role="tablist"/);
- assert.match(page, /aria-controls={`import-panel-\$\{entry\.id\}`}/);
+ assert.match(page, /id: `import-tab-\$\{entry\.id\}`/);
+ assert.match(page, /controls: `import-panel-\$\{entry\.id\}`/);
assert.match(page, /aria-labelledby={`import-tab-\$\{entry\.id\}`}/);
// One toolbar and one idle state per kind — not per section or per step.
diff --git a/apps/desktop/test/settings-project-archive.test.mjs b/apps/desktop/test/settings-project-archive.test.mjs
index fc1848938..1d2b870b4 100644
--- a/apps/desktop/test/settings-project-archive.test.mjs
+++ b/apps/desktop/test/settings-project-archive.test.mjs
@@ -104,8 +104,10 @@ test("project archive is a toolbar over a list, with no page-level prose", () =>
assert.match(projectsPageSource, /project\.clearSearch/);
assert.match(projectsPageSource, /projects-result-count[^]*aria-live="polite"/);
assert.match(projectsPageSource, /project\.resultCount/);
- assert.match(projectsPageSource, /"settings-segment projects-sort"/);
- assert.match(projectsPageSource, /aria-pressed=\{sort === mode\}/);
+ assert.match(projectsPageSource, /<SegmentedControl\s+value=\{sort\}/);
+ assert.match(projectsPageSource, /className="projects-sort"/);
+ assert.match(projectsPageSource, /itemClassName="projects-sort-btn"/);
+ assert.match(projectsPageSource, /role="group"/);
assert.match(projectsPageSource, /project\.sortRecent/);
assert.match(projectsPageSource, /project\.sortName/);
diff --git a/apps/desktop/test/settings-remote-hosts.test.mjs b/apps/desktop/test/settings-remote-hosts.test.mjs
index c014c084f..1701bd227 100644
--- a/apps/desktop/test/settings-remote-hosts.test.mjs
+++ b/apps/desktop/test/settings-remote-hosts.test.mjs
@@ -30,7 +30,10 @@ function cssRule(selector) {
test("remote hosts is an inventory plus one SSH/Pair add form", () => {
assert.match(page, /role="tablist"/);
- assert.match(page, /aria-controls={`remote-host-add-panel-\$\{mode\}`}/);
+ for (const mode of ["ssh", "pair"]) {
+ assert.ok(page.includes(`id: "remote-host-add-${mode}"`));
+ assert.ok(page.includes(`controls: "remote-host-add-panel-${mode}"`));
+ }
assert.match(page, /id={`remote-host-add-panel-\$\{mode\}`}|id="remote-host-add-panel-ssh"/);
assert.match(page, /hidden=\{addMode !== "ssh"\}/);
assert.match(page, /hidden=\{addMode !== "pair"\}/);
diff --git a/apps/desktop/test/thinking-ui.test.mjs b/apps/desktop/test/thinking-ui.test.mjs
index e1556a4bb..911ccc290 100644
--- a/apps/desktop/test/thinking-ui.test.mjs
+++ b/apps/desktop/test/thinking-ui.test.mjs
@@ -73,7 +73,7 @@ test("composer exposes the runtime thinking level order and provider filtering",
assert.doesNotMatch(stylesSource, /\.composer-thinking-level\b/);
assert.match(
stylesSource,
- /\.composer-model-thinking-menu\s*\{[\s\S]*?width:\s*min\(300px,\s*calc\(100vw - 24px\)\);/,
+ /\.composer-model-thinking-menu\s*\{[\s\S]*?width:\s*min\(280px,\s*calc\(100vw - 24px\)\);/,
);
assert.match(composerSource, /availableThinkingLevels/);
assert.match(composerSource, /thinkingMenuLevels/);
diff --git a/apps/desktop/test/traffic-light-reserve.test.mjs b/apps/desktop/test/traffic-light-reserve.test.mjs
index ce91bbc94..01851eb09 100644
--- a/apps/desktop/test/traffic-light-reserve.test.mjs
+++ b/apps/desktop/test/traffic-light-reserve.test.mjs
@@ -65,7 +65,7 @@ test("every shell surface reserves the shared lead inset", () => {
]) {
assert.doesNotMatch(
declarationsOnly(source),
- /76px/,
+ /(?:padding-left|margin-left|left|--[\w-]+):[^;]*\b76px\b/,
`${name} must not restate the traffic-light footprint`,
);
}
diff --git a/docs/spec/04-ux/07-ui-design-system.md b/docs/spec/04-ux/07-ui-design-system.md
index f7e046002..32e69e91b 100644
--- a/docs/spec/04-ux/07-ui-design-system.md
+++ b/docs/spec/04-ux/07-ui-design-system.md
@@ -1233,7 +1233,12 @@ Implementation: `components/ui.tsx → SegmentedControl<T>`.
| Roles | `radiogroup` (default), `group`, or `tablist` |
| Item roles | `radio` / none / `tab` — derived from container role |
| Generic | `<T extends string>` for type-safe value/onChange |
-| Options | `readonly { value: T; label: ReactNode }[]` — label accepts JSX (e.g. count badge) |
+| Options | `readonly { value: T; label: ReactNode; id?: string; controls?: string }[]` — label accepts JSX (e.g. count badge) |
+
+Tablist callers supply stable option `id` and `controls` values to connect
+each tab to its panel through `aria-controls` and the panel's
+`aria-labelledby`. These identifiers must not depend on translated labels.
+Import and Remote Hosts preserve these links when switching tabs or language.
Every multi-option selector rendered as a row of equal buttons **must** use
`SegmentedControl`. Inline `<div className="settings-segment">` with manual
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 0069e9baa..d686a2e46 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -2292,6 +2292,13 @@ identify the platform validation still needed.
#### E2E-036: Localized import grouping starts collapsed
+- **Tab accessibility**: Switch between the four import kinds in English and
+ Chinese. Each selected tab keeps its stable `import-tab-*` id and points to
+ the matching `import-panel-*` through `aria-controls`; that panel points
+ back through `aria-labelledby`. Inactive panels remain hidden and preserve
+ their existing state. The shared selection/link contract is covered by
+ `apps/desktop/test/segmented-control.test.mjs`, with page wiring checked in
+ `apps/desktop/test/settings-import-page.test.mjs`.
- **Preconditions**: Supported local agent stores contain importable sessions across at least two project paths and two sources, including one session without a project path; the app can be launched once with an English system locale and once with a Simplified Chinese system locale.
- **Steps**: 1) Launch in English and open Settings → Import. 2) Scan for sessions. 3) Inspect the initial source groups. 4) Expand one group and select a session. 5) Change Group by to Project path. 6) Switch back to Source. 7) Repeat the flow after launching with a Simplified Chinese system locale.
- **Expected**: Source/来源 is the initial grouping; all groups are collapsed after the scan and after either grouping change; project-path mode shows exact project paths and a final No project/未关联项目 group; expanding one group leaves the others collapsed; the selected session remains selected across grouping changes; counts, dates, selection labels, accessible names, and the import result use the active locale without raw keys or unresolved double-brace placeholders. A Codex archive above the scan threshold may show an em dash for its unknown message count during review, but it remains selectable and the later import converts the complete transcript. A Codex archive with more than 250 session files shows only the newest 250 by folder date plus a localized cap note; older Codex sessions are absent from that scan.
@@ -13060,7 +13067,9 @@ browser milestones are scheduled.
Projects and Info with an Experimental badge. 3) Open it and confirm the page
title carries the same badge, with a host inventory and one Add form
(SSH / Pair) and no instructional copy. 4) Switch Add to Pair and back to
- SSH; confirm both forms stay filled. 5) Disable developer mode while the
+ SSH; confirm both forms stay filled and each tab's `aria-controls` points
+ to its panel, whose `aria-labelledby` points back to that tab. Repeat the
+ association check after changing the interface language. 5) Disable developer mode while the
destination is open and confirm the page returns to General and the rail row
is gone.
- **Expected**: The whole destination is marked Experimental and is reachable
diff --git a/scripts/e2e-theme-surfaces.mjs b/scripts/e2e-theme-surfaces.mjs
index c9f4bc558..99bda36c6 100644
--- a/scripts/e2e-theme-surfaces.mjs
+++ b/scripts/e2e-theme-surfaces.mjs
@@ -50,6 +50,15 @@ app.whenReady().then(async () => {
await window.webContents.debugger.sendCommand("Emulation.setFocusEmulationEnabled", { enabled: true });
window.webContents.sendInputEvent({ type: "keyDown", keyCode: "Tab" });
window.webContents.sendInputEvent({ type: "keyUp", keyCode: "Tab" });
+ // Input delivery is asynchronous. Wait for the keyboard focus seed before
+ // the probe blurs it; otherwise Tab can land during the first paint sample.
+ await window.webContents.executeJavaScript(
+ "new Promise((resolve) => {" +
+ "const target = document.querySelector('.settings-search');" +
+ "if (document.activeElement === target) resolve();" +
+ "else target.addEventListener('focus', () => resolve(), { once: true });" +
+ "})"
+ );
const checks = [];
for (const theme of ["light", "dark"]) {
for (const custom of [false, true, false]) {