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:
Sameh Khamis committed 2026-10-31 19:22:03 -07:00
1 parent 2ffd7a4afd
commit 1de4f635ca
47 files changed
+1691 -1645

No files matched your search

+36 -40
View File
@@ -46,27 +46,25 @@ export class RealtimeCost {
*/
syncCostUi() {
const state = this.costTracker.state();
const syncWarning = () => {
const warning = this.ui?.costWarning;
const value = this.ui?.costValue;
if (!warning || !value) return;
warning.hidden = !['warn', 'cap', 'unknown'].includes(
value.dataset.level,
);
warning.textContent = warning.hidden ? '' : value.textContent;
warning.title = value.title;
warning.dataset.level = value.dataset.level;
// The panel's warning outside the closed panel mirrors the readout.
const showCost = (cost) => {
this.ui.update('cost', { hidden: false, ...cost });
const hidden = !['warn', 'cap', 'unknown'].includes(cost.level);
this.ui.update('costWarning', {
hidden,
text: hidden ? '' : cost.text,
title: cost.title,
level: cost.level,
});
};
const pendingTier = resolveVoiceModel(this.voiceTier).tier;
const isMini = pendingTier === 'mini';
if (this.ui?.tierButton) {
this.ui.tierButton.textContent = isMini ? t('MINI') : t('STD');
this.ui.tierButton.setAttribute(
'aria-pressed',
isMini ? 'true' : 'false',
);
const pendingId = resolveVoiceModel(pendingTier).id;
this.ui.tierButton.title =
if (!this.ui) return;
const pendingId = resolveVoiceModel(pendingTier).id;
this.ui.update('tier', {
text: isMini ? t('MINI') : t('STD'),
pressed: isMini,
title:
this.isActive() && state.modelId !== pendingId
? t('Next session: {pendingId} — this session stays on {modelId}', {
pendingId,
@@ -78,16 +76,15 @@ export class RealtimeCost {
pendingId,
target: isMini ? t('standard') : t('mini'),
},
);
}
if (this.ui?.costValue) {
const liveAuth = this.sessionCloudVoiceAuth || this.cloudVoiceAuth;
if (liveAuth === 'oauth') {
const { responses, input, output, captions } = this.oauthUsage;
this.ui.costValue.hidden = false;
this.ui.costValue.textContent = t('COST UNKNOWN');
this.ui.costValue.dataset.level = 'unknown';
this.ui.costValue.title =
),
});
const liveAuth = this.sessionCloudVoiceAuth || this.cloudVoiceAuth;
if (liveAuth === 'oauth') {
const { responses, input, output, captions } = this.oauthUsage;
showCost({
text: t('COST UNKNOWN'),
level: 'unknown',
title:
t(
'ChatGPT OAuth session: {responses} response(s), {input} input and {output} output tokens, {captions} caption transcription(s) reported.',
{ responses, input, output, captions },
@@ -101,14 +98,14 @@ export class RealtimeCost {
t(
'Usage is incomplete because a response was still in flight when the session ended.',
)
: '');
syncWarning();
return;
}
this.ui.costValue.hidden = false;
this.ui.costValue.textContent = state.display;
this.ui.costValue.dataset.level = state.level;
this.ui.costValue.title =
: ''),
});
return;
}
showCost({
text: state.display,
level: state.level,
title:
t(
'Estimated session cost on {modelId} — {responses} response(s). Warns at {warn}, ends the session at {cap}.',
{
@@ -125,9 +122,8 @@ export class RealtimeCost {
t(
'Estimate is incomplete — a response was still in flight when the session ended, so its usage was never reported.',
)
: '');
syncWarning();
}
: ''),
});
}
/**
@@ -166,7 +162,7 @@ export class RealtimeCost {
});
}
this.syncCostUi();
if (this.isActive() && this.ui?.detail) {
if (this.isActive() && this.ui) {
// The tier as the interface names it; the stored value stays English.
const tier =
resolveVoiceModel(this.voiceTier).tier === 'mini'