mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat(voice): render the voice control from a presenter
createVoiceControl now returns a presenter instead of building the control with innerHTML: the session, cost, input, card and panel owners write its state by part and listen for interactions, and VoiceControl.vue renders it in the command dock, between the location bar and the visual presets as before. Focus moves wait for the render; the waveform's bars publish apart from the control and only when they change; the minutes field keeps a draft until its owner writes it. Owner tests use a real presenter on their own store, and view tests render the control.
This commit is contained in:
1 parent
2ffd7a4afd
commit
1de4f635ca
47 files changed
+1691
-1645
No files matched your search
+17
-34
@@ -10,6 +10,7 @@ import { createRealtimeSession } from './realtimeSession.js';
|
||||
import { realtimeSessionEvent } from './realtimeEvents.js';
|
||||
import { createVoiceCommands } from './sessionCommands.js';
|
||||
import { describeUnsavedWork } from '../i18n/index.js';
|
||||
import { createTestVoiceUi } from '../testSupport/voiceUi.mjs';
|
||||
|
||||
function deferred() {
|
||||
let resolve;
|
||||
@@ -242,26 +243,17 @@ test('common button and annotation bindings work with an alternate adapter and c
|
||||
const previous = globalThis.window;
|
||||
globalThis.window = {};
|
||||
try {
|
||||
const button = new EventTarget();
|
||||
button.setAttribute = () => {};
|
||||
let removed = 0;
|
||||
let subscribed = null;
|
||||
let calls = 0;
|
||||
const events = [];
|
||||
const ui = {
|
||||
button,
|
||||
root: {
|
||||
dataset: {},
|
||||
remove() {
|
||||
removed++;
|
||||
},
|
||||
},
|
||||
status: {},
|
||||
detail: {},
|
||||
tierButton: {},
|
||||
costValue: {},
|
||||
helpDetail: {},
|
||||
const ui = createTestVoiceUi();
|
||||
// Count removals but keep the control, so a click after cleanup still
|
||||
// reaches any listener the binder failed to release.
|
||||
ui.remove = () => {
|
||||
removed++;
|
||||
};
|
||||
const click = () => ui.emit('button');
|
||||
const lifetime = new AbortController();
|
||||
const controls = createVoiceCommands({
|
||||
runner: async () => {
|
||||
@@ -294,31 +286,31 @@ test('common button and annotation bindings work with an alternate adapter and c
|
||||
};
|
||||
},
|
||||
});
|
||||
button.dispatchEvent(new Event('click'));
|
||||
click();
|
||||
await new Promise((done) => setTimeout(done, 0));
|
||||
assert.equal(calls, 1);
|
||||
assert.equal(ui.tierButton.hidden, true);
|
||||
assert.equal(ui.costValue.hidden, true);
|
||||
assert.equal(ui.helpDetail.textContent, 'Activate to toggle voice');
|
||||
assert.equal(ui.status.textContent, 'LISTENING');
|
||||
assert.equal(ui.detail.textContent, 'Ready');
|
||||
assert.equal(ui.state.tier.hidden, true);
|
||||
assert.equal(ui.state.cost.hidden, true);
|
||||
assert.equal(ui.state.help.text, 'Activate to toggle voice');
|
||||
assert.equal(ui.state.status.text, 'LISTENING');
|
||||
assert.equal(ui.state.detail.text, 'Ready');
|
||||
// Switching language (a reload) asks first during a session.
|
||||
assert.deepEqual(describeUnsavedWork(), ['the active voice session']);
|
||||
subscribed({ status: 'resolved' });
|
||||
assert.deepEqual(events, [
|
||||
{ type: 'map_annotation_outline', status: 'resolved' },
|
||||
]);
|
||||
button.dispatchEvent(new Event('click'));
|
||||
click();
|
||||
assert.equal(controls.state, 'idle');
|
||||
assert.deepEqual(describeUnsavedWork(), []);
|
||||
button.dispatchEvent(new Event('click'));
|
||||
click();
|
||||
await new Promise((done) => setTimeout(done, 0));
|
||||
assert.deepEqual(describeUnsavedWork(), ['the active voice session']);
|
||||
lifetime.abort();
|
||||
assert.deepEqual(describeUnsavedWork(), [], 'disposal unregisters');
|
||||
assert.equal(subscribed, null);
|
||||
assert.equal(removed, 1);
|
||||
button.dispatchEvent(new Event('click'));
|
||||
click();
|
||||
assert.equal(calls, 2);
|
||||
} finally {
|
||||
globalThis.window = previous;
|
||||
@@ -598,16 +590,7 @@ for (const emitsIdle of [false, true]) {
|
||||
|
||||
test('actual default OpenAI adapter stop publishes one common idle', (t) => {
|
||||
const events = [];
|
||||
const ui = {
|
||||
root: {
|
||||
dataset: {},
|
||||
querySelectorAll: () => [],
|
||||
classList: { remove() {} },
|
||||
remove() {},
|
||||
},
|
||||
status: {},
|
||||
detail: {},
|
||||
};
|
||||
const ui = createTestVoiceUi();
|
||||
const runner = async () => ({});
|
||||
const session = createVoiceSession({
|
||||
runner,
|
||||
|
||||
Reference in new issue
Block a user