fix(voice): move focus with the voice panel that chat asks for

Asking from the chat composer to open Voice Settings or Voice Preview
closed chat around the focused input, leaving focus on a hidden control.
Focus held in chat now moves to the requested view's tab, as the panel's
own tabs move it; focus anywhere else stays put.
This commit is contained in:
Sameh Khamis committed 2026-11-03 16:04:54 -08:00
1 parent 66fb4b6aca
commit 6ce9498d18
2 files changed
+62 -3

No files matched your search

+16 -1
View File
@@ -160,13 +160,28 @@ export function createVoiceCommands({
// An explicit, successful show hands the frame from chat to the voice
// panel, which chat's open state hides. Closing chat keeps its typed
// session, running turn and messages; reopening chat restores them.
// Focus held in chat (its composer, or chat Settings' Back) would be
// left on a hidden control, so it moves to the panel's view, as the
// panel's own tabs do; focus anywhere else stays where it is.
controls.captureVoicePanelOperation = () => {
const operation = panelMount.captureOperation();
return {
...operation,
show(view, open = true) {
const focused = globalThis.document?.activeElement;
const inChat =
Boolean(focused) &&
(ui.element('chatPanel')?.contains?.(focused) ||
focused === ui.element('chatBack'));
const result = operation.show(view, open);
if (open && result.ok) chat?.close();
if (!open || !result.ok) return result;
chat?.close();
if (inChat)
void ui.focus(
result.view === 'settings'
? ['settingsTab', 'voiceBack', 'settingsClose']
: ['previewTab', 'settingsTab', 'settingsClose'],
);
return result;
},
};