mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(voice): add typed AI chat beside voice
Chat sits next to the mic in the command dock. Replies are silent and never request the microphone; the first message connects with the selected provider and runs the same map actions as voice through each provider's text API (OpenAI OPENAI_CHAT_MODEL, Gemini GEMINI_CHAT_MODEL via generateContent, which never starts Live). Only one mode runs at a time. - Chat panel rendered by the voice control presenter: conversation, recent and quick-command suggestions, Up/Down history, attachments (map-layer references or small UTF-8 text files, sent only with the message) - Chat and voice panels sit above the dock or dock into the right rail's column; minimized bars sit centred above the dock, and height animates on swaps - A centred panel steps down to its bar for the Location and Visual Presets trays without moving focus, rests above an open tray, and docks right while expanded over one; it returns to the centre once the trays close - Minimized voice previews the last sentence from each side; the empty Voice Preview suggests things to say - Settings opened from chat keep chat's frame and show the shared AI provider and quick commands; voice Settings show Back to voice - Closing chat ends a typed session; the voice panel's close turns voice off - The dock widens its voice control for the chat button and restyles its wings, which show icons only at 900px and below; assistant panels share the left panels' glass, and Cyber keeps its own surfaces - Server text-chat handlers with body, time and per-IP limits (GEV_RATELIMIT_*_CHAT_PER_MIN), documented in SECURITY.md; tests and all eleven locales Co-authored-by: Darren Dignam <[email protected]>
This commit is contained in:
1 parent
720260af58
commit
af461febae
57 files changed
+6500
-63
No files matched your search
@@ -1,3 +1,7 @@
|
||||
import { nextTick } from 'vue';
|
||||
import { bindAssistantPanelLayout, bindLayoutDock } from './panelLayout.js';
|
||||
import { bindChatControl } from './chatControl.js';
|
||||
import { bindVoiceMiniPreview } from './voiceMiniPreview.js';
|
||||
import { createVoiceControl, voiceStatusLabel } from './control.js';
|
||||
import { createVoiceSession } from './session.js';
|
||||
import { VoiceCardControls } from './voiceCard.js';
|
||||
@@ -114,7 +118,10 @@ export function createVoiceCommands({
|
||||
ui.update('detail', {
|
||||
text: () => detail || (idle ? t('Voice off') : t('Voice active')),
|
||||
});
|
||||
ui.update('button', { pressed: session.isActive() });
|
||||
// A typed chat session is not the microphone.
|
||||
ui.update('button', {
|
||||
pressed: session.isActive() && !adapter.getStartOptions?.().textOnly,
|
||||
});
|
||||
ui.update('error', {
|
||||
text: () =>
|
||||
event.state === 'error'
|
||||
@@ -135,10 +142,17 @@ export function createVoiceCommands({
|
||||
observer: actionObserver,
|
||||
nativeProvider: nativePanelProvider,
|
||||
});
|
||||
const updatePanel = panelMount ? session.subscribe(panelMount.handle) : null;
|
||||
// Typed chat turns belong to the chat panel, not the voice card or panel.
|
||||
const voicePresentation = (handle) => (event) => {
|
||||
if (event.type !== 'state' && adapter.getStartOptions?.().textOnly) return;
|
||||
handle(event);
|
||||
};
|
||||
const updatePanel = panelMount
|
||||
? session.subscribe(voicePresentation(panelMount.handle))
|
||||
: null;
|
||||
const updateCard =
|
||||
card && !panelMount
|
||||
? session.subscribe((event) => card.handle(event))
|
||||
? session.subscribe(voicePresentation((event) => card.handle(event)))
|
||||
: null;
|
||||
controls.voiceCard = card;
|
||||
if (panelMount) {
|
||||
@@ -170,21 +184,88 @@ export function createVoiceCommands({
|
||||
card?.outline(event);
|
||||
session.sendMapEvent({ type: 'map_annotation_outline', ...event });
|
||||
});
|
||||
const chat = panelMount
|
||||
? bindChatControl({
|
||||
ui,
|
||||
session,
|
||||
dataManager,
|
||||
onOpen: () => panelMount?.panel.close(),
|
||||
})
|
||||
: null;
|
||||
function minimizeVoicePanel() {
|
||||
const panel = ui.element('voicePanel');
|
||||
const holdsFocus = panel?.contains?.(globalThis.document?.activeElement);
|
||||
ui.update('voicePanel', { minimized: true });
|
||||
// Keep focus on the bar's expand button, not the mic (Space there would
|
||||
// end voice), without a keyboard ring.
|
||||
if (holdsFocus)
|
||||
void nextTick(() =>
|
||||
panel
|
||||
?.querySelector?.('[data-layout-minimize]')
|
||||
?.focus?.({ focusVisible: false }),
|
||||
);
|
||||
}
|
||||
const layouts = panelMount
|
||||
? [
|
||||
bindLayoutDock(ui),
|
||||
bindAssistantPanelLayout({
|
||||
ui,
|
||||
name: 'chatPanel',
|
||||
minimize: () => chat?.minimize({ focus: false }),
|
||||
restore: () => chat?.restore({ focus: false }),
|
||||
}),
|
||||
bindAssistantPanelLayout({
|
||||
ui,
|
||||
name: 'voicePanel',
|
||||
minimize: minimizeVoicePanel,
|
||||
restore: () => ui.update('voicePanel', { minimized: false }),
|
||||
}),
|
||||
ui.on('voice-minimize', () => {
|
||||
if (ui.state.voicePanel.minimized)
|
||||
ui.update('voicePanel', { minimized: false });
|
||||
else minimizeVoicePanel();
|
||||
}),
|
||||
]
|
||||
: [];
|
||||
const unbindMiniPreview = panelMount
|
||||
? bindVoiceMiniPreview({ ui, session })
|
||||
: null;
|
||||
const startVoice = () => {
|
||||
if (panelMount?.panel.snapshot().previewEnabled)
|
||||
panelMount.panel.select('preview');
|
||||
void session.start({ pushToTalk: false });
|
||||
};
|
||||
const buttonHandler = () => {
|
||||
if (adapter.ignoreButtonClick?.()) return;
|
||||
if (session.isActive()) {
|
||||
chat?.close();
|
||||
if (session.isActive() && adapter.getStartOptions?.().textOnly) {
|
||||
session.stop();
|
||||
startVoice();
|
||||
} else if (session.isActive()) {
|
||||
const ticket = panelMount?.stopTicket();
|
||||
session.stop();
|
||||
panelMount?.closeAfterStop(ticket);
|
||||
} else void session.start({ pushToTalk: false });
|
||||
} else startVoice();
|
||||
};
|
||||
const offButton = ui.on('button', buttonHandler);
|
||||
// The panel's close turns voice off, as chat's close ends the chat. A typed
|
||||
// session belongs to chat, which handles its own close.
|
||||
const offClose = ui.on('settings-close', () => {
|
||||
if (!session.isActive() || adapter.getStartOptions?.().textOnly) return;
|
||||
const ticket = panelMount?.stopTicket();
|
||||
session.stop();
|
||||
panelMount?.closeAfterStop(ticket);
|
||||
});
|
||||
let cleaned = false;
|
||||
const cleanup = () => {
|
||||
if (cleaned) return;
|
||||
cleaned = true;
|
||||
offButton();
|
||||
offClose();
|
||||
offProvider?.();
|
||||
for (const off of layouts) off();
|
||||
unbindMiniPreview?.();
|
||||
chat?.destroy();
|
||||
annotationUnsubscribe?.();
|
||||
updateStatus();
|
||||
updateCard?.();
|
||||
|
||||
Reference in new issue
Block a user