Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(live-voice): give the docked widget its own state, not a store it lacks

vastsafe095d9ee018
diff --git a/apps/desktop/electron/main/ipc/live-voice-ipc.ts b/apps/desktop/electron/main/ipc/live-voice-ipc.ts
index 7505e0f95..6a8fd77f8 100644
--- a/apps/desktop/electron/main/ipc/live-voice-ipc.ts
+++ b/apps/desktop/electron/main/ipc/live-voice-ipc.ts
@@ -17,7 +17,7 @@ export function registerLiveVoiceIpc(input: {
service: LiveCallServiceImpl;
getMainWindow: () => BrowserWindow | null;
/** The docked widget window: not a call owner, but allowed to drive its chrome. */
- widget: Pick<LiveVoiceWidget, "owns" | "setPresentation" | "requestAction" | "setIssue">;
+ widget: Pick<LiveVoiceWidget, "owns" | "setPresentation" | "requestAction" | "setOwnerState">;
}): void {
const { registrar, service, getMainWindow, widget } = input;
const owner = (event: IpcMainInvokeEvent): LiveOwner => {
@@ -92,12 +92,13 @@ export function registerLiveVoiceIpc(input: {
widget.requestAction(parseWidgetAction(raw));
return { ok: true };
});
- // The owner frame's own failure code: a refused action is local to the frame
- // that ran it and never appears in the call view, so the widget can only name
- // it if the owner reports it here.
- registrar.handleWithEvent(IPC.invoke.liveVoiceWidgetIssue, async (event, raw: unknown) => {
+ // What only the owner frame knows about this call: its own failure code (a
+ // refused action is local to the frame that ran it) and whether the bound work
+ // session is waiting on a decision the user has to make elsewhere. Neither is
+ // in the call view, so the widget can only show them if the owner reports them.
+ registrar.handleWithEvent(IPC.invoke.liveVoiceWidgetOwnerState, async (event, raw: unknown) => {
registrar.assertMainWindowSender(event);
- widget.setIssue(parseWidgetIssue(raw));
+ widget.setOwnerState(parseWidgetOwnerState(raw));
return { ok: true };
});
}
@@ -268,10 +269,11 @@ export function parseWidgetPresentation(raw: unknown): { visible: boolean } & Li
return { visible: input.visible, width: input.width as number, height: input.height as number };
}
-/** The owner frame's own failure code for the call it is running. */
-export function parseWidgetIssue(raw: unknown): { callId: string; code: string | null } {
+/** The owner frame's own view of the call: its failure code and pending decision. */
+export function parseWidgetOwnerState(raw: unknown): { callId: string; errorCode: string | null; decisionWaiting: boolean } {
const input = record(raw);
- exactKeys(input, ["callId", "code"]);
- if (input.code !== null && (typeof input.code !== "string" || !input.code || input.code.length > 80)) return invalid();
- return { callId: callId(input.callId), code: input.code as string | null };
+ exactKeys(input, ["callId", "errorCode", "decisionWaiting"]);
+ if (input.errorCode !== null && (typeof input.errorCode !== "string" || !input.errorCode || input.errorCode.length > 80)) return invalid();
+ if (typeof input.decisionWaiting !== "boolean") return invalid();
+ return { callId: callId(input.callId), errorCode: input.errorCode as string | null, decisionWaiting: input.decisionWaiting };
}
diff --git a/apps/desktop/electron/main/live-voice/widget-window.ts b/apps/desktop/electron/main/live-voice/widget-window.ts
index 2c3d15393..c860333fb 100644
--- a/apps/desktop/electron/main/live-voice/widget-window.ts
+++ b/apps/desktop/electron/main/live-voice/widget-window.ts
@@ -39,12 +39,12 @@ export type LiveVoiceWidget = {
/** Push the authoritative call view; the window appears on the first call. */
publish: (view: LiveCallView | null) => void;
/**
- * The owner frame's own failure code for this call (`LIVE_PLAYBACK_FAILED`, a
- * refused action). It never appears in the call view — it is local to the
- * frame that ran the action — so the widget can only name it if the owner
- * reports it, and it is dropped as soon as the call it belongs to changes.
+ * What only the owner frame knows about this call: its own failure code (a
+ * refused action) and whether the bound work session is waiting on a decision.
+ * Neither is in the call view, so the widget can only show them because the
+ * owner reports them, and both are dropped when the call they belong to changes.
*/
- setIssue: (issue: { callId: string; code: string | null }) => void;
+ setOwnerState: (state: { callId: string; errorCode: string | null; decisionWaiting: boolean }) => void;
/** True when these contents are the widget window's own renderer. */
owns: (webContentsId: number) => boolean;
/** Follow the widget's own presentation decision and measured content box. */
@@ -65,6 +65,7 @@ export function createLiveVoiceWidget(input: {
let loaded = false;
let lastView: LiveCallView | null = null;
let lastErrorCode: string | undefined;
+ let lastDecisionWaiting = false;
let visible = false;
let size: LiveVoiceWidgetSize = { ...LIVE_VOICE_WIDGET_SIZE };
let saveTimer: ReturnType<typeof setTimeout> | null = null;
@@ -126,6 +127,7 @@ export function createLiveVoiceWidget(input: {
current.webContents.send(IPC.event.liveVoiceWidgetState, {
call: lastView,
...(lastErrorCode ? { errorCode: lastErrorCode } : {}),
+ ...(lastDecisionWaiting ? { decisionWaiting: true } : {}),
});
}
@@ -229,15 +231,19 @@ export function createLiveVoiceWidget(input: {
return {
publish(view) {
- // A new call starts blank: the previous call's failure must not be named
- // over the next one.
- if (view?.callId !== lastView?.callId) lastErrorCode = undefined;
+ // A new call starts blank: the previous call's failure and its pending
+ // decision must not be reported over the next one.
+ if (view?.callId !== lastView?.callId) {
+ lastErrorCode = undefined;
+ lastDecisionWaiting = false;
+ }
lastView = view;
if (view || window) void ensureWindow().then(sendView);
},
- setIssue(issue) {
- if (lastView?.callId !== issue.callId) return;
- lastErrorCode = issue.code ?? undefined;
+ setOwnerState(state) {
+ if (lastView?.callId !== state.callId) return;
+ lastErrorCode = state.errorCode ?? undefined;
+ lastDecisionWaiting = state.decisionWaiting;
sendView();
},
owns(webContentsId) {
diff --git a/apps/desktop/src/features/voice/live/LiveVoiceCallBar.tsx b/apps/desktop/src/features/voice/live/LiveVoiceCallBar.tsx
index 1205769dd..a0c84d784 100644
--- a/apps/desktop/src/features/voice/live/LiveVoiceCallBar.tsx
+++ b/apps/desktop/src/features/voice/live/LiveVoiceCallBar.tsx
@@ -1,16 +1,20 @@
-import { useEffect, useMemo, useRef, type RefObject } from "react";
+import { type RefObject } from "react";
import type { TFunction } from "i18next";
import { IconClose, IconInfo, IconMic, IconMicOff, IconPhoneOff, IconSettings, IconVolume, IconWaveform } from "../../../components/icons";
import { TooltipButton } from "../../../components/ui";
import type { LiveVoiceSnapshot } from "./live-call-controller";
-import { useAppStore } from "../../../stores/app-store";
import { liveVoiceMode, type liveVoiceIssue } from "./live-voice-presentation";
-import { liveWorkDecision, operationAwaitsDecision } from "./live-work-decision";
type CallBarProps = {
t: TFunction;
snapshot: LiveVoiceSnapshot;
issue: ReturnType<typeof liveVoiceIssue>;
+ /**
+ * True while the bound work session waits on a decision the user has to make
+ * elsewhere. The widget window has no session store, so the owner frame
+ * reports this instead of the bar deriving it (live-work-decision).
+ */
+ decisionWaiting: boolean;
detailsOpen: boolean;
detailsRef: RefObject<HTMLButtonElement | null>;
actionPending: "mute" | "playback" | null;
@@ -32,31 +36,9 @@ type CallBarProps = {
* code, because nothing else on screen could name it.
*/
export function LiveVoiceCallBar({
- t, snapshot, issue, detailsOpen, detailsRef, actionPending,
+ t, snapshot, issue, decisionWaiting, detailsOpen, detailsRef, actionPending,
onCancel, onMute, onEnd, onDetails, onResume, onSettings, onDismiss,
}: CallBarProps) {
- // Live Voice failures are one-shot results of the call actions, so they are
- // reported through the global toast together with their allow-listed code.
- // Only call states that outlive a toast stay in the bar: the playback hint and
- // the quarantine that still has to confirm the microphone was released.
- const issueStaysInline = !issue || issue.warning || issue.code === "LIVE_MEDIA_RELEASE_UNCONFIRMED";
- const showToast = useAppStore((state) => state.showToast);
- const reportedIssue = useRef<string | null>(null);
- const previousActionPending = useRef(actionPending);
- useEffect(() => {
- const startedAttempt =
- actionPending !== null && previousActionPending.current === null;
- previousActionPending.current = actionPending;
- if (startedAttempt) reportedIssue.current = null;
- if (issueStaysInline || !issue) {
- reportedIssue.current = null;
- return;
- }
- if (reportedIssue.current === issue.key) return;
- reportedIssue.current = issue.key;
- showToast(`${t(issue.message)} (${issue.code})`, { variant: "error" });
- }, [actionPending, issue, issueStaysInline, showToast, t]);
-
const mode = liveVoiceMode(snapshot);
const call = snapshot.call;
const status = mode === "stopping" ? "liveVoice.phase.closing"
@@ -69,24 +51,6 @@ export function LiveVoiceCallBar({
: "liveVoice.phase.connected";
const unmute = call?.muted !== false;
const speaking = mode === "connected" && (call?.assistantSpeaking || (call?.userSpeaking && !call.muted));
- // A waiting work session outlives a spoken announcement: the user may be
- // reading another session when the decision appears, and the card that
- // answers it lives in the bound session, not in this bar.
- const boundSessionId = call?.workBinding?.workSessionId;
- const planCheckpoints = useAppStore((state) => state.planCheckpoints);
- const pendingPermissions = useAppStore((state) => state.pendingPermissions);
- const pendingAsks = useAppStore((state) => state.pendingAsks);
- const decisionWaiting = useMemo(
- () => Boolean(liveWorkDecision({
- sessionId: boundSessionId,
- awaiting: operationAwaitsDecision(call?.workOperations, boundSessionId),
- asks: pendingAsks,
- permissions: pendingPermissions,
- planCheckpoints,
- })),
- [boundSessionId, call?.workOperations, pendingAsks, pendingPermissions, planCheckpoints],
- );
-
return (
<div className="live-voice-call-bar" data-state={mode}>
<div className="live-voice-call-row">
@@ -145,7 +109,7 @@ export function LiveVoiceCallBar({
) : null}
</div>
</div>
- {issue && issueStaysInline ? (
+ {issue ? (
<p className={issue.warning ? "live-voice-feedback live-voice-hint" : "live-voice-feedback live-voice-error"} role={issue.warning ? "status" : "alert"}>
{t(issue.message)}
{/* The localized sentence alone cannot say whether authentication,
diff --git a/apps/desktop/src/features/voice/live/LiveVoiceStatusHost.tsx b/apps/desktop/src/features/voice/live/LiveVoiceStatusHost.tsx
index 2f4136e6b..d0082bd12 100644
--- a/apps/desktop/src/features/voice/live/LiveVoiceStatusHost.tsx
+++ b/apps/desktop/src/features/voice/live/LiveVoiceStatusHost.tsx
@@ -1,12 +1,15 @@
-import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
import { useTranslation } from "react-i18next";
import type { LiveVoiceWidgetAction } from "@pi-desktop/shared";
+import { useAppStore } from "../../../stores/app-store";
import { getLiveCallController } from "./live-call-controller";
import { liveVoiceApi } from "./live-voice-api";
import { openLiveVoiceSettings } from "./live-voice-navigation";
+import { liveWorkDecision, operationAwaitsDecision } from "./live-work-decision";
import { liveVoiceIssue, liveVoiceMode } from "./live-voice-presentation";
import { LiveVoiceDetails } from "./LiveVoiceDetails";
import "../../../styles/voice.css";
+import "../../../styles/voice.css";
/**
* The main window's half of the call chrome.
@@ -45,12 +48,33 @@ export function LiveVoiceStatusHost() {
if (mode === "stopping" || mode === "idle") setDetailsOpen(false);
}, [mode]);
- // The widget window is the only call chrome, so the failure this frame owns —
- // a refused mute, a playback retry that failed — has to reach it.
+ // The bound work session can wait on a decision the user has to make in that
+ // session's own card, while the user is looking at the widget instead. Those
+ // queues live in this window's store and the widget window has none, so the
+ // waiting flag is reported with the failure code below.
+ const boundSessionId = snapshot.call?.workBinding?.workSessionId;
+ const planCheckpoints = useAppStore((state) => state.planCheckpoints);
+ const pendingPermissions = useAppStore((state) => state.pendingPermissions);
+ const pendingAsks = useAppStore((state) => state.pendingAsks);
+ const decisionWaiting = useMemo(
+ () => Boolean(liveWorkDecision({
+ sessionId: boundSessionId,
+ awaiting: operationAwaitsDecision(snapshot.call?.workOperations, boundSessionId),
+ asks: pendingAsks,
+ permissions: pendingPermissions,
+ planCheckpoints,
+ })),
+ [boundSessionId, snapshot.call?.workOperations, pendingAsks, pendingPermissions, planCheckpoints],
+ );
+
+ // The widget window is the only call chrome and has neither this store nor a
+ // toast surface, so everything only this frame knows — the failure it owns and
+ // the waiting decision — has to be reported to it.
useEffect(() => {
if (!callId) return;
- void liveVoiceApi.reportWidgetIssue({ callId, code: issue?.code ?? null }).catch(() => undefined);
- }, [callId, issue?.code]);
+ void liveVoiceApi.reportWidgetOwnerState({ callId, errorCode: issue?.code ?? null, decisionWaiting })
+ .catch(() => undefined);
+ }, [callId, decisionWaiting, issue?.code]);
const runAction = useCallback((action: () => Promise<void>, pending?: "mute" | "playback") => {
setActionFailure(null);
diff --git a/apps/desktop/src/features/voice/live/LiveVoiceWidget.tsx b/apps/desktop/src/features/voice/live/LiveVoiceWidget.tsx
index 5a2cbfb2a..8da8332f5 100644
--- a/apps/desktop/src/features/voice/live/LiveVoiceWidget.tsx
+++ b/apps/desktop/src/features/voice/live/LiveVoiceWidget.tsx
@@ -8,7 +8,7 @@ import { liveVoiceIssue, liveVoiceWidgetSnapshot, liveVoiceWidgetVisible } from
import "../../../styles/voice.css";
import "../../../styles/live-voice-widget.css";
-type WidgetState = { call: LiveCallView | null; errorCode?: string };
+type WidgetState = { call: LiveCallView | null; errorCode?: string; decisionWaiting?: boolean };
/**
* The docked call widget: the call chrome as its own always-on-top window, so a
@@ -98,6 +98,7 @@ export function LiveVoiceWidget() {
t={t}
snapshot={snapshot}
issue={issue}
+ decisionWaiting={state.decisionWaiting === true}
detailsOpen={false}
detailsRef={detailsRef}
actionPending={null}
diff --git a/apps/desktop/src/features/voice/live/live-voice-api.ts b/apps/desktop/src/features/voice/live/live-voice-api.ts
index e59d96ecf..7ab93f76b 100644
--- a/apps/desktop/src/features/voice/live/live-voice-api.ts
+++ b/apps/desktop/src/features/voice/live/live-voice-api.ts
@@ -50,12 +50,12 @@ export const liveVoiceApi = {
invoke<{ ok: true }>(IPC.invoke.liveVoiceWidgetVisibility, input),
requestWidgetAction: (action: LiveVoiceWidgetAction) =>
invoke<{ ok: true }>(IPC.invoke.liveVoiceWidgetAction, { action }),
- reportWidgetIssue: (input: { callId: string; code: string | null }) =>
- invoke<{ ok: true }>(IPC.invoke.liveVoiceWidgetIssue, input),
+ reportWidgetOwnerState: (input: { callId: string; errorCode: string | null; decisionWaiting: boolean }) =>
+ invoke<{ ok: true }>(IPC.invoke.liveVoiceWidgetOwnerState, input),
onView: (listener: (view: LiveCallView) => void) => subscribe(IPC.event.liveVoiceChanged, listener),
onControl: (listener: (event: LiveControlEvent) => void) => subscribe(IPC.event.liveVoiceControl, listener),
onTranscript: (listener: (event: LiveTranscriptEvent) => void) => subscribe(IPC.event.liveVoiceTranscript, listener),
- onWidgetState: (listener: (state: { call: LiveCallView | null; errorCode?: string }) => void) =>
+ onWidgetState: (listener: (state: { call: LiveCallView | null; errorCode?: string; decisionWaiting?: boolean }) => void) =>
subscribe(IPC.event.liveVoiceWidgetState, listener),
onWidgetAction: (listener: (event: { action: LiveVoiceWidgetAction }) => void) =>
subscribe(IPC.event.liveVoiceWidgetAction, listener),
diff --git a/apps/desktop/test/fixtures/live-voice-interaction-runner.cjs b/apps/desktop/test/fixtures/live-voice-interaction-runner.cjs
index 9ce64a6ed..a85df0471 100644
--- a/apps/desktop/test/fixtures/live-voice-interaction-runner.cjs
+++ b/apps/desktop/test/fixtures/live-voice-interaction-runner.cjs
@@ -223,6 +223,15 @@ async function connectedScenario() {
})()`);
await evaluate("window.liveVoiceFixture.setWidgetWindowWidth(420)");
await frame();
+ // The pending decision lives in the owner window's store, which the widget
+ // window does not have: the owner frame reports it, main forwards it, and the
+ // bar names it. Seeding the owner store is therefore the whole test.
+ await evaluate("window.liveVoiceFixture.pendingAsk('fixture-session-1', 'Ship beta.1?')");
+ await check("a decision the bound session waits on reaches the widget bar",
+ `document.querySelector('.live-voice-call-bar')?.textContent.includes('waiting for your answer or approval') === true`);
+ await evaluate("window.liveVoiceFixture.clearPendingAsks()");
+ await check("the waiting hint clears with the decision",
+ `document.querySelector('.live-voice-call-bar')?.textContent.includes('waiting for your answer or approval') === false`);
await capture("call-connected");
await evaluate("window.liveVoiceFixture.setPhase('reconnecting')");
await check("reconnecting keeps an explicit End action", `ui.state('reconnecting') && ${button("End call", bar)} && !${button("Cancel", bar)} && !${button("Unmute microphone", bar)}`);
diff --git a/apps/desktop/test/fixtures/live-voice-interaction.jsx b/apps/desktop/test/fixtures/live-voice-interaction.jsx
index 3234e0e89..559bd3cce 100644
--- a/apps/desktop/test/fixtures/live-voice-interaction.jsx
+++ b/apps/desktop/test/fixtures/live-voice-interaction.jsx
@@ -51,7 +51,7 @@ const ending = new Map();
// The widget window is a view of the call: main pushes the owner's view into it
// and forwards its presses back to the owner frame. Both directions are faked
// here so the mounted production widget runs its real code path.
-const widgetReports = { presentation: null, actions: [], errorCode: undefined };
+const widgetReports = { presentation: null, actions: [], errorCode: undefined, decisionWaiting: false };
const emit = (channel, value) => {
for (const listener of listeners.get(channel) ?? []) listener(structuredClone(value));
};
@@ -60,6 +60,7 @@ function pushWidgetState() {
emit(IPC.event.liveVoiceWidgetState, {
call,
...(widgetReports.errorCode ? { errorCode: widgetReports.errorCode } : {}),
+ ...(widgetReports.decisionWaiting ? { decisionWaiting: true } : {}),
});
}
function updateCall(patch) {
@@ -92,8 +93,10 @@ async function handleInvoke(channel, request) {
contextEnabled: request.shareSelectedSessionContext === true,
} } : {}),
};
- // A new call starts blank: main drops the previous call's failure code.
+ // A new call starts blank: main drops the previous call's failure code and
+ // its waiting-decision flag.
widgetReports.errorCode = undefined;
+ widgetReports.decisionWaiting = false;
updateCall({});
const prepared = {
callId: call.callId, requestId: request.requestId, bindingId: call.bindingId,
@@ -147,10 +150,15 @@ async function handleInvoke(channel, request) {
widgetReports.actions.push(request.action);
emit(IPC.event.liveVoiceWidgetAction, { action: request.action });
return { ok: true };
- case IPC.invoke.liveVoiceWidgetIssue:
- // The owner frame's own failure code, cached for the call it belongs to
- // and pushed into the widget exactly as main does.
+ case IPC.invoke.liveVoiceWidgetOwnerState:
+ // What only the owner frame knows — its failure code and whether the bound
+ // session waits on a decision — cached for that call and pushed into the
+ // widget exactly as main does.
if (request.callId !== call?.callId) return { ok: true };
+ widgetReports.errorCode = request.errorCode ?? undefined;
+ widgetReports.decisionWaiting = request.decisionWaiting === true;
+ pushWidgetState();
+ return { ok: true };
widgetReports.errorCode = request.code ?? undefined;
pushWidgetState();
return { ok: true };
@@ -335,6 +343,25 @@ window.liveVoiceFixture = {
},
// Narrow the window main gives the widget, so a status line no longer fits: a
// bar that folds or under-reports its width fails the assertion after it.
+ // The pending queues live in the owner window's store; the widget window has
+ // none. Seeding one here exercises the "owner reports it, main forwards it"
+ // path end to end instead of the bar reading a store it does not have.
+ pendingAsk(sessionId, question) {
+ useAppStore.setState((state) => ({
+ pendingAsks: {
+ ...state.pendingAsks,
+ [sessionId]: [{
+ requestId: "ask-fixture",
+ sessionId,
+ toolCallId: "call_ask",
+ questions: [{ question, options: [{ label: "yes" }] }],
+ }],
+ },
+ }));
+ },
+ clearPendingAsks() {
+ useAppStore.setState({ pendingAsks: {} });
+ },
setWidgetWindowWidth(width) { setFixtureWidgetWidth(width); },
inspect() {
return {
@@ -346,6 +373,7 @@ window.liveVoiceFixture = {
presentation: widgetReports.presentation,
actions: [...widgetReports.actions],
visible: widgetReports.presentation?.visible === true,
+ ownerState: { errorCode: widgetReports.errorCode ?? null, decisionWaiting: widgetReports.decisionWaiting },
},
};
},
diff --git a/apps/desktop/test/live-voice-controls.test.mjs b/apps/desktop/test/live-voice-controls.test.mjs
index fe5ba67d7..747fb97db 100644
--- a/apps/desktop/test/live-voice-controls.test.mjs
+++ b/apps/desktop/test/live-voice-controls.test.mjs
@@ -149,7 +149,7 @@ test("Live Voice separates idle entry and compact call presentation", async (t)
assert.match(html, /LIVE_NETWORK_ERROR/);
// A failure only the owner frame can see — a refused action — reaches the
// widget as a reported code, because the call view never carries it.
- assert.match(hostSource, /liveVoiceApi\.reportWidgetIssue\(\{ callId, code: issue\?\.code \?\? null \}\)/);
+ assert.match(hostSource, /liveVoiceApi\.reportWidgetOwnerState\(\{ callId, errorCode: issue\?\.code \?\? null, decisionWaiting \}\)/);
// account failures read as account failures, not as generic configuration advice
const auth = liveVoiceIssue({ ...snapshot, call: { ...call, phase: "failed", error: { code: "LIVE_AUTH_REQUIRED", retriable: false } } });
assert.equal(auth.message, "liveVoice.authRequired");
diff --git a/apps/desktop/test/live-voice-widget.test.mjs b/apps/desktop/test/live-voice-widget.test.mjs
index a36d5b8e8..c9b0e105e 100644
--- a/apps/desktop/test/live-voice-widget.test.mjs
+++ b/apps/desktop/test/live-voice-widget.test.mjs
@@ -121,11 +121,11 @@ test("widget IPC handlers enforce renderer ownership", async (t) => {
},
};
const actions = [];
+ const ownerStates = [];
const widget = {
owns: (id) => id === widgetId,
- setPresentation() {},
requestAction: (action) => actions.push(action),
- setIssue() {},
+ setOwnerState: (state) => ownerStates.push(state),
};
const service = new Proxy({}, { get: () => async () => ({}) });
registerLiveVoiceIpc({ registrar, service, getMainWindow: () => ({ webContents: { id: mainId } }), widget });
@@ -135,6 +135,35 @@ test("widget IPC handlers enforce renderer ownership", async (t) => {
await assert.rejects(() => invoke("pi-desktop/voice/live/widget/action", mainId, { action: "mute" }), { errorCode: "PERMISSION_DENIED" });
await assert.rejects(() => invoke("pi-desktop/voice/live/widget/visibility", mainId, { visible: true, width: 380, height: 60 }), { errorCode: "PERMISSION_DENIED" });
await assert.rejects(() => invoke("pi-desktop/voice/live/widget/action", 33, { action: "end" }), { errorCode: "PERMISSION_DENIED" });
- await invoke("pi-desktop/voice/live/widget/issue", mainId, { callId: "call-a", code: null });
- await assert.rejects(() => invoke("pi-desktop/voice/live/widget/issue", widgetId, { callId: "call-a", code: null }), { errorCode: "PERMISSION_DENIED" });
+ // The owner frame reports its own view; the widget window may not forge it.
+ await invoke("pi-desktop/voice/live/widget/ownerState", mainId, { callId: "call-a", errorCode: null, decisionWaiting: true });
+ assert.deepEqual(ownerStates, [{ callId: "call-a", errorCode: null, decisionWaiting: true }]);
+ await assert.rejects(
+ () => invoke("pi-desktop/voice/live/widget/ownerState", widgetId, { callId: "call-a", errorCode: null, decisionWaiting: true }),
+ { errorCode: "PERMISSION_DENIED" },
+ );
+});
+
+test("the owner frame's own view of the call is validated before the widget sees it", async (t) => {
+ const { ipc } = await desktopModules(t);
+
+ assert.deepEqual(
+ ipc.parseWidgetOwnerState({ callId: "call-a", errorCode: "LIVE_PLAYBACK_FAILED", decisionWaiting: true }),
+ { callId: "call-a", errorCode: "LIVE_PLAYBACK_FAILED", decisionWaiting: true },
+ "the owner's failure code and a waiting decision travel together",
+ );
+ assert.deepEqual(
+ ipc.parseWidgetOwnerState({ callId: "call-a", errorCode: null, decisionWaiting: false }),
+ { callId: "call-a", errorCode: null, decisionWaiting: false },
+ "clearing both is a normal report, not a silent no-op",
+ );
+ assert.throws(() => ipc.parseWidgetOwnerState({ callId: "call-a", errorCode: null }), { errorCode: "LIVE_PROTOCOL_ERROR" },
+ "a report missing the decision flag is rejected instead of guessed");
+ assert.throws(() => ipc.parseWidgetOwnerState({ callId: "call-a", errorCode: null, decisionWaiting: "yes" }), { errorCode: "LIVE_PROTOCOL_ERROR" });
+ assert.throws(() => ipc.parseWidgetOwnerState({ callId: "call-a", errorCode: "", decisionWaiting: false }), { errorCode: "LIVE_PROTOCOL_ERROR" });
+ assert.throws(
+ () => ipc.parseWidgetOwnerState({ callId: "call-a", errorCode: null, decisionWaiting: false, text: "raw" }),
+ { errorCode: "LIVE_PROTOCOL_ERROR" },
+ "no free-form text can ride along into the widget",
+ );
});
diff --git a/apps/desktop/test/live-work-decision.test.mjs b/apps/desktop/test/live-work-decision.test.mjs
index 4a72e041e..ce3ce5260 100644
--- a/apps/desktop/test/live-work-decision.test.mjs
+++ b/apps/desktop/test/live-work-decision.test.mjs
@@ -100,12 +100,27 @@ test("a bound work session's pending decision reaches the voice surfaces", async
if (!options) return key;
return [key, ...Object.entries(options).map(([name, value]) => `${name}=${value}`)].join("|");
};
+ // The bar is presentational: the owner frame derives the waiting flag from its
+ // own store and reports it to the widget window, which has no store of its own.
+ // This harness derives it the same way, so the assertions still run against the
+ // real component fed by the real helper.
+ const deriveDecisionWaiting = (nextCall) => {
+ const state = useAppStore.getState();
+ return Boolean(liveWorkDecision({
+ sessionId: nextCall?.workBinding?.workSessionId,
+ awaiting: operationAwaitsDecision(nextCall?.workOperations, nextCall?.workBinding?.workSessionId),
+ asks: state.pendingAsks,
+ permissions: state.pendingPermissions,
+ planCheckpoints: state.planCheckpoints,
+ }));
+ };
const renderBar = (nextCall) => {
const snapshot = { status, call: nextCall, transcripts: [], starting: false, stopping: false };
return renderToStaticMarkup(React.createElement(LiveVoiceCallBar, {
t: translate,
snapshot,
issue: liveVoiceIssue(snapshot),
+ decisionWaiting: deriveDecisionWaiting(nextCall),
detailsOpen: false,
detailsRef: { current: null },
actionPending: null,
diff --git a/docs/adr/0314-live-voice-docked-widget.md b/docs/adr/0315-live-voice-docked-widget.md
similarity index 98%
rename from docs/adr/0314-live-voice-docked-widget.md
rename to docs/adr/0315-live-voice-docked-widget.md
index 2150ff164..414e4cd65 100644
--- a/docs/adr/0314-live-voice-docked-widget.md
+++ b/docs/adr/0315-live-voice-docked-widget.md
@@ -1,4 +1,4 @@
-# ADR 0314: The Live Voice call bar is a docked desktop widget window
+# ADR 0315: The Live Voice call bar is a docked desktop widget window
- Status: Accepted
- Date: 2026-10-01
diff --git a/docs/adr/README.md b/docs/adr/README.md
index e062c8563..2c4934311 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -346,10 +346,10 @@ Each ADR includes:
| 0312 | [Session-scoped Todo checklist](0312-session-scoped-todo-checklist.md) | Accepted for implementation |
| 0313 | [Default Live Work to the Current Composer Session](0313-live-voice-default-session-target.md) | Accepted |
| 0314 | [A spoken answer selects among an open asktool question's own options](0314-live-voice-spoken-asktool-answers.md) | Accepted for implementation (amends the Live Voice Work Session decision path for AskTool only) |
+| 0315 | [The Live Voice call bar is a docked desktop widget window](0315-live-voice-docked-widget.md) | Accepted |
| turn-process-and-thinking-display | [Turn process and thinking presentation](turn-process-and-thinking-display.md) | Accepted |
| provider-display-order | [Provider display order](provider-display-order.md) | Accepted |
| registry-header-variable-spelling | [Remote header variables accept the registry's `{name}` spelling](registry-header-variable-spelling.md) | Proposed |
| provider-system-certificates | [Desktop sidecar uses OS-trusted certificates](provider-system-certificates.md) | Accepted |
| image-generation-capability | [Image generation as a configured Agent capability](image-generation-capability.md) | Accepted |
| retained-browser-pages-per-tab | [Retain a host-owned browser page per resource tab](retained-browser-pages-per-tab.md) | Accepted |
-| 0314 | [The Live Voice call bar is a docked desktop widget window](0314-live-voice-docked-widget.md) | Accepted |
diff --git a/docs/spec/03-runtime/01-ipc-protocol.md b/docs/spec/03-runtime/01-ipc-protocol.md
index 93d13148c..2b3c6f576 100644
--- a/docs/spec/03-runtime/01-ipc-protocol.md
+++ b/docs/spec/03-runtime/01-ipc-protocol.md
@@ -2413,8 +2413,8 @@ owner derivation.
| `pi-desktop/voice/live/event/transcript` | Main → Renderer | transient bounded transcript event for the current call |
| `pi-desktop/voice/live/widget/visibility` | Widget → Main | the docked widget's own presentation decision and the content box it needs; Main shows or hides that window accordingly |
| `pi-desktop/voice/live/widget/action` | Widget → Main | a call action pressed in the docked widget; Main validates the sender and forwards it to the owner frame, which runs it |
-| `pi-desktop/voice/live/widget/issue` | Main window → Main | the owner frame's own failure code for its call (for example a refused mute), which the call view never carries |
-| `pi-desktop/voice/live/event/widgetState` | Main → Widget | the authoritative call view plus the owner's failure code, pushed to the docked widget window |
+| `pi-desktop/voice/live/widget/ownerState` | Main window → Main | what only the owner frame knows: its own failure code (for example a refused mute) and whether the bound work session waits on a decision; neither is in the call view |
+| `pi-desktop/voice/live/event/widgetState` | Main → Widget | the authoritative call view plus the owner's own failure code and waiting-decision flag, pushed to the docked widget window |
| `pi-desktop/voice/live/event/widgetAction` | Main → Main window | the forwarded widget action the owner frame has to run |
The `MessagePort` is provisioned only after successful owner validation, then
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 73450f3aa..7d88bb65e 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -3199,7 +3199,9 @@ has four presentation states:
work, and the resulting state returns through the same authoritative view the
owner receives. A failure only the owner frame can observe — a refused mute, a
playback retry that failed — is reported so the bar names it in place next to
- its verbatim `LIVE_*` code; the bar is the only call chrome the user sees.
+ its verbatim `LIVE_*` code; the bar is the only call chrome the user sees. The
+ same report carries whether the bound work session waits on a decision the user
+ has to make in that session's own card, which the widget window cannot see.
- The main window draws no call bar. It keeps the details surface, which the
widget's Details action opens after bringing that window forward, and it stays
the frame that runs the actions. Feature disable hides the idle icon; the
diff --git a/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md b/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md
index d6bb8a073..ce9976727 100644
--- a/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md
+++ b/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md
@@ -1887,8 +1887,8 @@ unchanged. See [provider configuration](12-provider-config-schema.md).
| `pi-desktop/voice/live/event/transcript` | Main → Renderer | 当前通话的临时、有界字幕事件 |
| `pi-desktop/voice/live/widget/visibility` | 挂件 → Main | 挂件自身的展示决定与所需内容盒尺寸;Main 据此显示或隐藏该窗口 |
| `pi-desktop/voice/live/widget/action` | 挂件 → Main | 在挂件中按下的通话操作;Main 校验发送方后转发给 owner frame 执行 |
-| `pi-desktop/voice/live/widget/issue` | 主窗口 → Main | owner frame 自身为该通话记录的错误码(例如被拒绝的静音),通话视图不会携带它 |
-| `pi-desktop/voice/live/event/widgetState` | Main → 挂件 | 权威通话视图加上 owner 的错误码,推送给停靠挂件窗口 |
+| `pi-desktop/voice/live/widget/ownerState` | 主窗口 → Main | 只有 owner frame 才知道的信息:它自身的错误码(例如被拒绝的静音)以及绑定工作会话是否在等待决策;两者都不在通话视图中 |
+| `pi-desktop/voice/live/event/widgetState` | Main → 挂件 | 权威通话视图加上 owner 自身的错误码与等待决策标记,推送给停靠挂件窗口 |
| `pi-desktop/voice/live/event/widgetAction` | Main → 主窗口 | 需要 owner frame 执行的挂件操作 |
只有 owner 验证成功后才会创建 `MessagePort`,之后由 preload 中继到 renderer 窗口。owner 在首个 `hello` 中回送每通电话独有的 nonce;Main 仅在 call ID 和 nonce 均匹配时接受该端口一次。二进制帧包含有界 PCM 音频、采集 epoch、释放确认、播放游标和协议就绪信号。它不是通用 IPC 隧道:不会传输 Provider 凭证、任意命令、工作区路径、Agent 消息或持久化字幕。通话结束或 owner 丢失时会关闭端口。
diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.md
index 08734ea76..0cbae32c1 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -2201,7 +2201,8 @@ Live Voice 受现有开发者模式和开发构建门控约束,包含四种展
- 挂件只是通话的视图,绝不是 owner。每次按键都转发给主窗口——麦克风、媒体和按通话隔离的
工作都由主窗口持有——结果状态再通过 owner 收到的同一份权威视图回到挂件。只有 owner frame
才能观察到的失败(被拒绝的静音、恢复播放失败)会被上报,于是通话栏就地在旁边标出该失败
- 及其原样的 `LIVE_*` 错误码;通话栏是用户能看到的唯一通话控件。
+ 及其原样的 `LIVE_*` 错误码;通话栏是用户能看到的唯一通话控件。同一份上报还会携带绑定工作
+ 会话是否在等待某个决策——该决策必须在其会话卡片里做出,而挂件窗口自己看不到。
- 主窗口不再绘制通话栏。它保留详情界面——挂件的“详情”操作会把主窗口带到前台并打开它——
并继续是执行这些操作的 frame。禁用该功能会隐藏空闲图标;通话与其 Renderer 清理结束后
挂件消失。延迟到达的 Main 终态事件和 Renderer 媒体释放不能短暂开放第二个开始入口。
diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.ts
index 1e604bdea..51bfd9540 100644
--- a/packages/shared/src/protocol.ts
+++ b/packages/shared/src/protocol.ts
@@ -105,7 +105,7 @@ export const IPC = {
liveVoiceStopWorkOperation: "pi-desktop/voice/live/work/stopOperation",
liveVoiceCancelQueuedOperation: "pi-desktop/voice/live/work/cancelQueuedOperation",
liveVoiceWidgetAction: "pi-desktop/voice/live/widget/action",
- liveVoiceWidgetIssue: "pi-desktop/voice/live/widget/issue",
+ liveVoiceWidgetOwnerState: "pi-desktop/voice/live/widget/ownerState",
liveVoiceWidgetVisibility: "pi-desktop/voice/live/widget/visibility",
agentCompact: "pi-desktop/agent/compact",
agentAbort: "pi-desktop/agent/abort",