Cover the real provider switch and share chat Settings and stop checks

- Host test switches AI Provider from chat Settings through the real
  provider commands and checks the new mount keeps chat's context, frame,
  Back to chat and focus on the provider choice.
- Drop the open and minimized branches of the carried presentation: the
  provider choice lives only in Settings, so chat is never open then.
- One showChatSettings helper for the gear and the restore, and one
  isStoppable helper for the live-or-error check in chat and the panel close.
This commit is contained in:
manjunath22466 committed 2026-11-05 00:17:08 +05:30
1 parent 46dde909cc
commit 3577d19513
9 files changed
+99 -58

No files matched your search

+23 -33
View File
@@ -1,6 +1,7 @@
import { bindChatAttachments } from './chatAttachments.js';
import { bindChatPreferences } from './chatPreferences.js';
import { readStoredCloudVoiceAuthMode } from './cloudVoiceAuth.js';
import { isStoppable } from './session.js';
import { t } from '../i18n/index.js';
/**
@@ -96,8 +97,7 @@ export function bindChatControl({ ui, session, onOpen, dataManager }) {
leaveChatSettings();
// Chat replaces voice, a stale voice error included, so the dock stops
// showing it.
if (!isTyped() && (session.isActive() || session.state === 'error'))
session.stop();
if (!isTyped() && isStoppable(session)) session.stop();
onOpen?.();
ui.update('chat', { open: true, minimized: false, rows: 2, authNote });
sync();
@@ -392,15 +392,7 @@ export function bindChatControl({ ui, session, onOpen, dataManager }) {
}
const frame = ui.element('chatPanel')?.getBoundingClientRect?.();
close();
ui.update('voicePanel', {
context: 'chat',
...(frame?.width && {
frameWidth: frame.width,
frameHeight: frame.height,
}),
});
ui.update('chat', { backVisible: true });
sync();
showChatSettings(frame);
void ui.focus(['chatBack']);
}),
// The panel clears its context as it closes, so chat tracks its own.
@@ -416,32 +408,30 @@ export function bindChatControl({ ui, session, onOpen, dataManager }) {
}),
];
sync();
// What a provider switch carries to the next mount: chat's Settings or
// chat itself, never the conversation.
// Settings shown from chat, in chat's frame when it has one.
function showChatSettings(frame) {
ui.update('voicePanel', {
context: 'chat',
...(frame?.width && {
frameWidth: frame.width,
frameHeight: frame.height,
}),
});
ui.update('chat', { backVisible: true });
sync();
}
// What a provider switch carries to the next mount: chat's Settings, never
// the conversation. The provider choice lives only in Settings, so chat
// itself is never open during a switch.
function presentation() {
if (inChatSettings()) {
const { frameWidth, frameHeight } = ui.state.voicePanel;
return { view: 'settings', frameWidth, frameHeight };
}
if (chat().open) return { view: chat().minimized ? 'minimized' : 'open' };
return null;
if (!inChatSettings()) return null;
const { frameWidth: width, frameHeight: height } = ui.state.voicePanel;
return { view: 'settings', frame: width ? { width, height } : null };
}
// Restored without moving focus: the switch keeps it on the provider choice.
function restorePresentation(state) {
if (disposed || !state) return;
if (state.view === 'settings') {
ui.update('voicePanel', {
context: 'chat',
...(state.frameWidth && {
frameWidth: state.frameWidth,
frameHeight: state.frameHeight,
}),
});
ui.update('chat', { backVisible: true });
return sync();
}
open({ focus: false });
if (state.view === 'minimized') minimize({ focus: false });
if (disposed || state?.view !== 'settings') return;
showChatSettings(state.frame);
}
return {
close,