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:
manjunath22466andDarren Dignam committed 2026-11-02 20:56:39 +05:30
1 parent 720260af58
commit af461febae
57 files changed
+6500 -63

No files matched your search

+28 -4
View File
@@ -1,3 +1,4 @@
import { createGeminiTextChat } from './geminiTextChat.js';
import { t, translateKnown } from '../i18n/index.js';
import { msg } from '../i18n/marker.js';
import { createGeminiAudio } from './geminiAudio.js';
@@ -2535,6 +2536,20 @@ export class GeminiSessionController {
export function createGeminiSession(options) {
const controller = new GeminiSessionController(options);
const chat = createGeminiTextChat({
...options,
emit: (event) => {
if (event.type === 'state') controller.status = event.state;
options.emit(event);
},
});
let textOnly = false;
const startVoice = (settings) => {
textOnly = false;
return controller.start(settings);
};
controller.input.start = startVoice;
controller.radio.isActive = () => !textOnly && controller.isActive();
return {
controller,
capabilities: {
@@ -2544,13 +2559,22 @@ export function createGeminiSession(options) {
'Gemini voice sessions have a time limit. When a session expires, start voice again for a new conversation.',
),
},
start: (settings) => controller.start(settings),
start: (settings) => {
textOnly = Boolean(settings?.textOnly);
return textOnly ? chat.start() : startVoice(settings);
},
getStartOptions: () => ({
pushToTalk: Boolean(controller.input.pushToTalkMode),
...(textOnly ? { textOnly: true } : {}),
}),
stop: (settings) => controller.stop(settings),
sendText: (text) => controller.sendTextCommand(text),
sendMapEvent: (event) => controller.notifyMapEvent(event),
stop: (settings) => {
chat.stop({ ...settings, preserveStatus: true });
controller.stop(settings);
},
sendText: (text) =>
textOnly ? chat.sendText(text) : controller.sendTextCommand(text),
sendMapEvent: (event) =>
textOnly ? chat.sendMapEvent(event) : controller.notifyMapEvent(event),
ignoreButtonClick: () => Boolean(controller.spaceKeyHeld),
bindControls: () => controller.input.bindPushToTalkShortcut(),
};