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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/design/webshell-voice-button-visibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# WebShell Voice Button Visibility

## Summary

The WebShell voice button is visible only when the workspace explicitly enables voice, the embedding host allows the voice toolbar action, and the daemon advertises the `voice_transcribe` capability.

## Decision

The host toolbar filter remains the outer gate. When the host allows voice, `VoiceButton` reads the existing `/workspace/voice` status and accepts only `enabled: true`. A missing capability avoids the status request entirely.

The status is fail-closed: the button stays hidden while the request is pending or after it fails. Each settings event invalidates the previous result and starts a fresh request. Results are tied to the workspace client and settings version so a late response cannot re-enable a stale configuration.

If a previously enabled gate becomes invalid during an active capture, the capture is aborted before the control remains hidden so the microphone and voice connection are released.

## Boundaries

Voice model selection, available model discovery, and voice mode do not affect button visibility. Invalid model configuration continues to use the existing capture error path after the user clicks the button.

This change does not add a WebShell prop, daemon endpoint, SDK type, or configuration field.
22 changes: 22 additions & 0 deletions packages/web-shell/client/components/ChatEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ vi.mock('../hooks/useComposerCore', async (importOriginal) => {
};
});

vi.mock('../voice/VoiceButton', () => ({
VoiceButton: () => <span data-testid="voice-button" />,
}));

const mounted: Array<{
root: Root;
container: HTMLDivElement;
Expand Down Expand Up @@ -199,6 +203,24 @@ function renderChatEditor(props: {
return container;
}

describe('ChatEditor voice toolbar integration', () => {
it('mounts voice only when the host toolbar allows it', () => {
expect(
renderChatEditor({}).querySelector('[data-testid="voice-button"]'),
).not.toBeNull();
expect(
renderChatEditor({
visibleToolbarActions: ['voice'],
}).querySelector('[data-testid="voice-button"]'),
).not.toBeNull();
expect(
renderChatEditor({
visibleToolbarActions: [],
}).querySelector('[data-testid="voice-button"]'),
).toBeNull();
});
});

describe('ChatEditor composer tag icons', () => {
it('renders built-in icons for top composer tags', () => {
const kinds = ['extension', 'file', 'mcp', 'skill'] as const;
Expand Down
25 changes: 16 additions & 9 deletions packages/web-shell/client/e2e/utils/mockDaemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface WebShellDaemonScenario {
providers: DaemonWorkspaceProvidersStatus;
skills: DaemonWorkspaceSkillsStatus;
settings: DaemonWorkspaceSettingsStatus;
voice: DaemonWorkspaceVoiceStatus;
extensions: DaemonWorkspaceExtensionsStatus;
extensionOperations: ExtensionActiveOperations;
extensionUpdateCheck: ExtensionUpdateCheckResponse;
Expand Down Expand Up @@ -71,6 +72,7 @@ type ScenarioOverrides = Partial<
| 'providers'
| 'skills'
| 'settings'
| 'voice'
| 'extensions'
| 'extensionOperations'
| 'extensionUpdateCheck'
Expand All @@ -83,6 +85,7 @@ type ScenarioOverrides = Partial<
providers?: Partial<DaemonWorkspaceProvidersStatus>;
skills?: Partial<DaemonWorkspaceSkillsStatus>;
settings?: Partial<DaemonWorkspaceSettingsStatus>;
voice?: Partial<DaemonWorkspaceVoiceStatus>;
extensions?: Partial<DaemonWorkspaceExtensionsStatus>;
extensionOperations?: Partial<ExtensionActiveOperations>;
extensionUpdateCheck?: Partial<ExtensionUpdateCheckResponse>;
Expand Down Expand Up @@ -230,6 +233,17 @@ export function createWebShellDaemonScenario(
...(overrides.settings ?? {}),
};

const voice: DaemonWorkspaceVoiceStatus = {
v: 1,
workspaceCwd,
enabled: false,
mode: 'hold',
language: 'en',
voiceModel: null,
availableVoiceModels: [],
...(overrides.voice ?? {}),
};

const extensions: DaemonWorkspaceExtensionsStatus = {
v: 1,
workspaceCwd,
Expand Down Expand Up @@ -282,6 +296,7 @@ export function createWebShellDaemonScenario(
providers,
skills,
settings,
voice,
extensions,
extensionOperations,
extensionUpdateCheck,
Expand Down Expand Up @@ -934,15 +949,7 @@ function workspaceTools(
function workspaceVoice(
scenario: WebShellDaemonScenario,
): DaemonWorkspaceVoiceStatus {
return {
v: 1,
workspaceCwd: scenario.workspaceCwd,
enabled: false,
mode: 'hold',
language: 'en',
voiceModel: null,
availableVoiceModels: [],
};
return scenario.voice;
}

async function json(route: Route, body: unknown, status = 200): Promise<void> {
Expand Down
26 changes: 26 additions & 0 deletions packages/web-shell/client/e2e/web-shell.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,32 @@ test('opens slash menu, resume dialog, model dialog, and theme dialog @smoke', a
await expect(page.locator('[data-web-shell-theme-dialog]')).toHaveCount(0);
});

test('gates voice dictation on the workspace voice setting @smoke', async ({
page,
}, testInfo) => {
const scenario = createWebShellDaemonScenario({
voice: {
enabled: false,
},
});
scenario.capabilities.features = [
...scenario.capabilities.features,
'voice_transcribe',
];
const daemon = await installScenario(page, scenario, testInfo);
const voiceButton = page.getByRole('button', {
name: 'Start voice dictation',
});

await gotoSession(page, scenario, daemon);
await expect(voiceButton).toHaveCount(0);

scenario.voice.enabled = true;
await page.reload();
await completeReplay(page, daemon);
await expect(voiceButton).toBeVisible();
});

for (const viewportHeight of COMPOSER_VIEWPORT_HEIGHTS) {
test(`grows long text to the responsive composer cap at ${viewportHeight}px @smoke`, async ({
page,
Expand Down
Loading
Loading