Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spoken-turn-details-chat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@schlessera/brain-ui-react": patch
---

A spoken turn's transcript details now open from the turn itself (#3700). The glyph button under each recognized or voice-reply turn is gone. Each turn has one hidden "Details" control that shows as a pill when you Tab to it, or after you hover the turn. A right-click, Shift+F10, the ContextMenu key or a touch long-press opens the same dialog. A right-click while you have text selected in the turn keeps the browser's own menu, so Copy still works. The details themselves and their wording are unchanged.
43 changes: 24 additions & 19 deletions packages/ui-react/src/components/voice/conversation-outputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ export function ConversationPermissionOutcomes({ sessionId }: { sessionId: strin
* It reads as brain's spoken turn: the teal speaker mark, never a heard claim.
* No text is dimmed as unplayed: the client knows which chunks drained, not
* which words they carried (`playedSamples` does not align text to audio).
* `cutOff` comes only from a retained interruption naming this output.
* `cutOff` comes only from a retained interruption naming this output. The
* turn's evidence opens from its own Details stop (#3728), never a glyph.
*/
export function ConversationOutput({ output, restored = false, arrivalKey, cutOff = false }: { output: ConversationClientOutput; restored?: boolean; arrivalKey?: string; cutOff?: boolean }) {
return <div className="py-4" data-arrival-key={arrivalKey} tabIndex={-1} data-conversation-output="" data-output-id={output.outputId}>
<SpokenTurn speaker="brain" cutOff={cutOff}><span className="whitespace-pre-wrap">{output.generated}</span></SpokenTurn>
<div className="flex"><TranscriptQualifiers kind="generated" source={output.providerId ? conversationService(output.providerId) : undefined}
playback={output.playback === "discarded" ? "not-spoken" : output.playback} restored={restored} unsaved={output.unsaved} orderUnknown={output.orderUnknown ?? restored} evidenceLabel="Technical evidence (generated reply)">
<p>Conversation {output.conversationId} · epoch {output.epoch} · output {output.outputId}</p>
{output.playedSamples && <p>Reported local samples: {output.playedSamples.start}–{output.playedSamples.end}. This does not align text to audio.</p>}
</TranscriptQualifiers></div>
<SpokenTurn speaker="brain" cutOff={cutOff} details={{
kind: "generated", source: output.providerId ? conversationService(output.providerId) : undefined,
playback: output.playback === "discarded" ? "not-spoken" : output.playback, restored, unsaved: output.unsaved, orderUnknown: output.orderUnknown ?? restored, evidenceLabel: "Technical evidence (generated reply)",
children: <>
<p>Conversation {output.conversationId} · epoch {output.epoch} · output {output.outputId}</p>
{output.playedSamples && <p>Reported local samples: {output.playedSamples.start}–{output.playedSamples.end}. This does not align text to audio.</p>}
</>,
}}><span className="whitespace-pre-wrap">{output.generated}</span></SpokenTurn>
</div>;
}

Expand Down Expand Up @@ -80,7 +83,8 @@ export function ConversationTaskContext({ message, sessionId, result, entries =
* bubble with a cursor while live recognition is still updating, and a dotted
* underline only where a calibrated score is low. Restored text never shows as
* still being recognized. Provider, timing and speaker evidence stay in the
* details, outside user-message and live-announcement regions.
* details the turn opens (#3728), outside user-message and live-announcement
* regions.
*/
export function ConversationRecognitionRow({ fragments, introduction = false }: { fragments: ConversationRecognition[]; introduction?: boolean }) {
const first = fragments[0]!;
Expand All @@ -91,17 +95,18 @@ export function ConversationRecognitionRow({ fragments, introduction = false }:
const moved = fragments.every(f => f.moved);
return <section className="py-4 text-foreground" data-conversation-recognition="" style={{ overflowWrap: "anywhere" }}>
{introduction && <div className="mb-3 text-xs text-muted-foreground">Voice · {service} <TranscriptSymbols /></div>}
<SpokenTurn speaker="you" inProgress={!restored && !moved && updating > 0}><span className="whitespace-pre-wrap" data-recognized-text="">{moved ? "Moved to voice review" : fragments.map(f => <RecognizedWords key={JSON.stringify([f.kind, f.sequence])} fragment={f} />)}</span></SpokenTurn>
<div className="flex justify-end"><TranscriptQualifiers
kind="recognized" source={service} finish={finish} unsaved={first.unsaved} restored={restored} orderUnknown={fragments.some(f=>f.orderUnknown)} evidenceLabel={`Technical evidence (${fragments.length} fragment${fragments.length === 1 ? "" : "s"})`}>
<p>Recognized text evidence. Display order does not establish an exact response pairing.</p>
<ol>{fragments.map(f => <li key={JSON.stringify([f.kind, f.sequence])} className="py-1">
Epoch {f.epoch} · fragment {f.sequence} · {f.kind === "input_fragment" ? `Captured input ${f.utteranceId}; speaker unverified` : "Unassigned input; speaker unverified"}.
{f.kind === "input_fragment" ? f.certainty === "known" && f.confidence !== undefined ? ` Service confidence ${Math.round(f.confidence * 100)}%.` : " No calibrated confidence." : ""}
{f.kind === "unassigned_input_fragment" && f.sessionInterval ? ` Provider session timing; approximate: ${f.sessionInterval.startMs}–${f.sessionInterval.endMs} ms.` : f.kind === "input_fragment" && f.interval ? ` Provider input timing: ${f.interval.startMs}–${f.interval.endMs} ms.` : " Timing unavailable; speaker unverified."}
{f.finalization === "final" ? " Service finish marker received." : f.finalization === "interim" ? " Updating recognition." : " No finish evidence."}
</li>)}</ol>
</TranscriptQualifiers></div>
<SpokenTurn speaker="you" inProgress={!restored && !moved && updating > 0} details={{
kind: "recognized", source: service, finish, unsaved: first.unsaved, restored, orderUnknown: fragments.some(f => f.orderUnknown), evidenceLabel: `Technical evidence (${fragments.length} fragment${fragments.length === 1 ? "" : "s"})`,
children: <>
<p>Recognized text evidence. Display order does not establish an exact response pairing.</p>
<ol>{fragments.map(f => <li key={JSON.stringify([f.kind, f.sequence])} className="py-1">
Epoch {f.epoch} · fragment {f.sequence} · {f.kind === "input_fragment" ? `Captured input ${f.utteranceId}; speaker unverified` : "Unassigned input; speaker unverified"}.
{f.kind === "input_fragment" ? f.certainty === "known" && f.confidence !== undefined ? ` Service confidence ${Math.round(f.confidence * 100)}%.` : " No calibrated confidence." : ""}
{f.kind === "unassigned_input_fragment" && f.sessionInterval ? ` Provider session timing; approximate: ${f.sessionInterval.startMs}–${f.sessionInterval.endMs} ms.` : f.kind === "input_fragment" && f.interval ? ` Provider input timing: ${f.interval.startMs}–${f.interval.endMs} ms.` : " Timing unavailable; speaker unverified."}
{f.finalization === "final" ? " Service finish marker received." : f.finalization === "interim" ? " Updating recognition." : " No finish evidence."}
</li>)}</ol>
</>,
}}><span className="whitespace-pre-wrap" data-recognized-text="">{moved ? "Moved to voice review" : fragments.map(f => <RecognizedWords key={JSON.stringify([f.kind, f.sequence])} fragment={f} />)}</span></SpokenTurn>
</section>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { BrainUiProvider } from "../../src/root-context.js";
import { AppShell } from "../../src/components/layout/app-shell.js";
import { ChatPage } from "../../src/components/chat/chat-page.js";
import { installFaultNetwork } from "./offline/fault-network.js";
import { pointDetails } from "./spoken-details.js";

const SESSION = "odysseus-ithaca";
const CAPS: ConversationCapabilities = { nonblockingWork: "supported", manualEndpoint: "supported", finalTranscript: "unproven", remoteOutputCancelAck: "unproven", exactPermissionSpeech: "unproven", echoIsolatedInput: "unproven", outputWordAlignment: "unproven" };
Expand Down Expand Up @@ -593,7 +594,7 @@ test("cold restored speech explicitly has unknown original discussion position",
await expect.poll(() => s.host.querySelector("[data-conversation-output]")?.textContent).toContain("An earlier voyage reply.");
// #3700: the unknown position is evidence in the details, not a diagnostic line in the chat.
expect(s.host.querySelector("[data-conversation-output]")!.textContent).not.toContain("Original discussion position unknown");
await userEvent.click(s.host.querySelector<HTMLButtonElement>('[data-conversation-output] [data-transcript-qualifiers="generated"]')!);
await pointDetails(s.host.querySelector<HTMLButtonElement>('[data-conversation-output] [data-transcript-qualifiers="generated"]')!);
await expect.poll(() => document.querySelector("dialog[open]")?.textContent).toContain("Original discussion position unknown");
await userEvent.keyboard("{Escape}");
expect(s.client.state.getState().micOn).toBe(false);
Expand Down Expand Up @@ -1027,7 +1028,7 @@ test("recognition namespaces, finish evidence, duplicates, transfer and epoch fe
expect(s.client.state.getState().recognition[1]).toMatchObject({ kind: "input_fragment", utteranceId: s.socket.frames("conversation_audio").at(-1)!.utteranceId, sequence: 0 });
s.event({ kind: "unassigned_input_fragment", sequence: 1, text: "", timing: { kind: "unavailable" }, finalization: "final" });
const finishTrigger = s.host.querySelector<HTMLButtonElement>("[data-transcript-qualifiers=recognized]")!;
await userEvent.click(finishTrigger);
await pointDetails(finishTrigger);
await expect.poll(() => document.querySelector("dialog[open]")?.textContent).toContain("Service finish marker received");
await userEvent.keyboard("{Escape}");
expect(s.host.querySelectorAll("[data-conversation-recognition]")).toHaveLength(2);
Expand Down
13 changes: 7 additions & 6 deletions packages/ui-react/tests/browser/dialogue-qualifiers.offline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ChatPage } from "../../src/components/chat/chat-page.js";
import { CONVERSATION_LIMITS, type ServerConversationOpened } from "@schlessera/brain-ui-sdk/protocol";
import type { ConversationRecognition } from "../../src/voice/conversation-client.js";
import { installFaultNetwork } from "./offline/fault-network.js";
import { pointDetails } from "./spoken-details.js";

const SESSION = "odysseus-raft";
let styles: HTMLStyleElement;
Expand Down Expand Up @@ -62,32 +63,32 @@ for(const theme of ["light","dark"] as const)for(const width of [320,1280])for(c
await page.screenshot({element:s.host,path:`../../.vitest-attachments/durable-dialogue/rows-${theme}-${width}-${zoom}.png`});
scroll.scrollTop=scroll.scrollHeight;
await page.screenshot({element:s.host,path:`../../.vitest-attachments/durable-dialogue/tail-${theme}-${width}-${zoom}.png`});
const trigger=unsaved.find(q=>q.dataset.transcriptQualifiers==="recognized")!;trigger.scrollIntoView({block:"center"});await userEvent.hover(trigger);
await expect.poll(()=>document.querySelector('[role="tooltip"]')?.textContent).toContain("Unsaved text evidence");
const trigger=unsaved.find(q=>q.dataset.transcriptQualifiers==="recognized")!;trigger.scrollIntoView({block:"center"});
expect(trigger.closest(".bk-spoken-turn")!.querySelector(".bk-transcript-glyphs"),"no glyph on a spoken turn (#3700)").toBeNull();
trigger.focus();await userEvent.keyboard("{Enter}");
const dialog=document.querySelector<HTMLDialogElement>("dialog[open]")!;
expect(dialog.textContent).toContain("These words are not saved and are unavailable after reload.");
expect(dialog.textContent).toContain("Unsaved text evidence. These words are not saved and are unavailable after reload.");
expect(dialog.textContent).toContain("Words may be uncertain; speaker unverified.");
expect(dialog.querySelector("details")!.open).toBe(false);expect(dialog.scrollWidth).toBeLessThanOrEqual(dialog.clientWidth+1);
[...dialog.querySelectorAll("p")].find(p=>p.textContent?.startsWith("Unsaved text evidence"))!.scrollIntoView({block:"center"});
await page.screenshot({element:dialog,path:`../../.vitest-attachments/durable-dialogue/unsaved-details-${theme}-${width}-${zoom}.png`});
await closeDetails();expect(document.activeElement).toBe(trigger);
await userEvent.click(unsaved.find(q=>q.dataset.transcriptQualifiers==="generated")!);expect(document.querySelector("dialog[open]")!.textContent).toContain("Playback unknown");await closeDetails();
await pointDetails(unsaved.find(q=>q.dataset.transcriptQualifiers==="generated")!);expect(document.querySelector("dialog[open]")!.textContent).toContain("Playback unknown");await closeDetails();
});
for(const unsaved of [true,false])for(const kind of ["recognition","speech"] as const)test(`paging and live-tail windowing preserve the ${kind} unsaved=${unsaved} reader until real source removal`,async ctx=>{
const s=await scene(ctx);evidence(s);
const voice=s.ui.connection.conversation.state;
const trigger=[...s.host.querySelectorAll<HTMLButtonElement>(`[data-transcript-qualifiers="${kind==="recognition"?"recognized":"generated"}"]`)].find(q=>q.getAttribute("aria-label")!.includes("unsaved")===unsaved)!;
const key=trigger.closest<HTMLElement>("[data-arrival-key]")!.dataset.arrivalKey;
await userEvent.click(trigger);expect(document.querySelector("dialog[open]")).not.toBeNull();
await pointDetails(trigger);expect(document.querySelector("dialog[open]")).not.toBeNull();
flushSync(()=>voice.setState(current=>({dialogue:{[SESSION]:{...current.dialogue[SESSION]!,records:[retained(0,"Earlier mast note. "),...current.dialogue[SESSION]!.records]}},recognition:[...current.recognition,{...fragments("gemini-live",1)[0]!,sequence:4,text:" Keep the sail within reach.",unsaved:true}],outputs:[...current.outputs.map(o=>o.unsavedGenerated ? {...o,unsavedGenerated:o.unsavedGenerated+" Keep the rigging clear."} : o),...Array.from({length:41},(_,i)=>({conversationId:"tail",epoch:1,sessionId:SESSION,providerId:"gpt-live",outputId:`tail-${i}`,generated:`Later report ${i}.`,playback:"unknown" as const}))]})));
expect(trigger.isConnected).toBe(true);expect(trigger.closest<HTMLElement>("[data-arrival-key]")!.dataset.arrivalKey).toBe(key);
expect(s.host.querySelectorAll("[data-arrival-key]").length).toBeLessThanOrEqual(41);expect(document.querySelector("dialog[open]")).not.toBeNull();await closeDetails();expect(document.activeElement).toBe(trigger);
const elsewhere=document.createElement("button");elsewhere.textContent="Continue reading";document.body.append(elsewhere);ctx.onTestFinished(()=>elsewhere.remove());elsewhere.focus();await expect.poll(()=>trigger.isConnected).toBe(false);expect(s.host.querySelectorAll("[data-arrival-key]")).toHaveLength(40);
// Reveal earlier history with the actual existing window control.
const earlier=[...s.host.querySelectorAll<HTMLElement>('button,[role="button"]')].find(b=>b.textContent?.includes("earlier message"))!;await userEvent.click(earlier);
const restored=[...s.host.querySelectorAll<HTMLButtonElement>(`[data-transcript-qualifiers="${kind==="recognition"?"recognized":"generated"}"]`)].find(q=>q.getAttribute("aria-label")!.includes("unsaved")===unsaved)!;
await userEvent.click(restored);const anchor=s.host.querySelector("[data-reading-column]");
await pointDetails(restored);const anchor=s.host.querySelector("[data-reading-column]");
flushSync(()=>voice.setState(current=>unsaved ? kind==="recognition"?{recognition:[]}:{outputs:current.outputs.filter(o=>!o.unsavedGenerated)} : {dialogue:{[SESSION]:{...current.dialogue[SESSION]!,records:current.dialogue[SESSION]!.records.filter(r=>r.evidence.kind!=="voice" || (kind==="recognition" ? r.evidence.event.kind==="output_transcript" : r.evidence.event.kind!=="output_transcript"))}}}));
await expect.poll(()=>document.querySelector("dialog[open]")).toBeNull();expect(document.activeElement).toBe(anchor);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,8 @@ for (const provider of ["gemini", "gpt"] as const) for (const failure of ["quota
expect(qualifiers).toHaveLength(2);
expect(qualifiers[0]!.getAttribute("aria-label")).not.toContain("unsaved");
expect(qualifiers[1]!.getAttribute("aria-label"),"UNSAVED_ROW_QUALIFIER").toContain("unsaved");
expect(qualifiers[1]!.querySelectorAll("svg").length).toBeGreaterThan(qualifiers[0]!.querySelectorAll("svg").length);
// #3700: the unsaved state is named on the Details stop and in its dialog, never drawn as a glyph.
expect(qualifiers.map(q=>q.querySelectorAll("svg").length),"no glyph on a spoken turn").toEqual([0,0]);

expect(rows.flatMap(e=>e.fragments.map(f=>f.text))).toEqual(events.map(f=>"text" in f.event ? f.event.text : ""));
expect(result.rows).toHaveLength(events.filter(f=>f.retention!=="unsaved").length);
Expand Down
15 changes: 15 additions & 0 deletions packages/ui-react/tests/browser/spoken-details.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="@vitest/browser-playwright" />
// A spoken turn's details are reached through its hidden Details stop
// (#3728, #3700): there is no glyph to click at rest. These open it the
// ways a reader does.
import { expect } from "vitest";
import { userEvent } from "vitest/browser";

/** Hover the turn until the pill shows, then click the pill. */
export async function pointDetails(trigger: HTMLButtonElement) {
const turn = trigger.closest<HTMLElement>(".bk-spoken-turn");
expect(turn, "the Details stop belongs to a spoken turn").not.toBeNull();
await userEvent.hover(turn!.firstElementChild!);
await expect.poll(() => turn!.dataset.reveal, { message: "hovering the turn shows the pill" }).toBe("true");
await userEvent.click(trigger);
}
Loading
Loading