Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
cdc9873
CONTRACT: feat(ui-kit): open a spoken turn's transcript details from …
schlessera Nov 8, 2026
df6253f
test(ui-kit): baselines for spoken-turn details at 320 and desktop in…
schlessera Nov 8, 2026
d5eed3d
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
dafee21
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
ff544b8
Merge origin/main into feat/3728-spoken-turn-details
schlessera Nov 9, 2026
74f6087
Merge origin/main into feat/3728-spoken-turn-details
schlessera Nov 9, 2026
0eb9c75
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
291990e
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
d834335
Merge origin/main into feat/3728-spoken-turn-details
schlessera Nov 9, 2026
d1254f1
Merge origin/main into feat/3728-spoken-turn-details
schlessera Nov 9, 2026
6e6203e
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
3b40279
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
8087b05
Merge origin/main into feat/3728-spoken-turn-details
schlessera Nov 9, 2026
e496176
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
3c56117
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
3288876
Merge origin/main into feat/3728-spoken-turn-details (refresh only)
schlessera Nov 9, 2026
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.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@schlessera/brain-ui-kit": minor
---

`SpokenTurn` gains an optional `details` prop (#3728). A spoken turn with details renders one visually hidden "Details" stop that shows as a pill on keyboard focus or a 300ms hover, and opens the existing transcript details dialog from Enter, Space, Shift+F10, the ContextMenu key, a right-click or a 500ms touch long-press, with focus returning on close. A right-click with text selected inside the turn keeps the native menu, and no evidence glyph renders. `TranscriptQualifiers` gains `trigger?: "glyphs" | "reveal"`; the default `"glyphs"` is unchanged. The new `SpokenTurnDetails` type is exported.
17 changes: 17 additions & 0 deletions api-report/ui-kit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export "." (./src/index.ts)
SpokenMark
type SpokenMarkProps
SpokenTurn
type SpokenTurnDetails
type SpokenTurnProps
StartCard
type StartCardNotice
Expand Down Expand Up @@ -2178,11 +2179,14 @@ signatures (every public export and the types it is made of)
}
SpokenTurn (packages/ui-kit/src/voice/SpokenTurn.tsx)
export function SpokenTurn(p: SpokenTurnProps): import("react").JSX.Element;
SpokenTurnDetails (packages/ui-kit/src/voice/SpokenTurn.tsx)
export type SpokenTurnDetails = Omit<TranscriptQualifiersProps, "trigger">;
SpokenTurnProps (packages/ui-kit/src/voice/SpokenTurn.tsx)
export interface SpokenTurnProps {
speaker: Speaker;
inProgress?: boolean;
cutOff?: boolean;
details?: SpokenTurnDetails;
children?: ReactNode;
}
StartCard (packages/ui-kit/src/voice/StartCard.tsx)
Expand Down Expand Up @@ -2500,6 +2504,19 @@ signatures (every public export and the types it is made of)
onExpandedChange?: (expanded: boolean) => void;
isStatic?: boolean;
}
TranscriptQualifiersProps (packages/ui-kit/src/conversation/TranscriptQualifiers.tsx)
export interface TranscriptQualifiersProps {
kind: "recognized" | "generated" | "task-request" | "task-result";
source?: string;
playback?: "played" | "unknown" | "not-spoken";
restored?: boolean;
unsaved?: boolean;
orderUnknown?: boolean;
finish?: "updating" | "some-updating" | "finished" | "unknown";
evidenceLabel: string;
children: ReactNode;
trigger?: "glyphs" | "reveal";
}
Tray (packages/ui-kit/src/blocks/Tray.tsx)
const Tray: import("react").ForwardRefExoticComponent<TrayProps & import("react").RefAttributes<HTMLButtonElement>>;
TrayProps (packages/ui-kit/src/blocks/Tray.tsx)
Expand Down
17 changes: 17 additions & 0 deletions docs/integration-contract/package-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4971,6 +4971,23 @@ the composer renders exactly as before. No wire schema changes.
`api-report/` records the added prop.


<a id="spoken-turn-details-additive-0450-3728"></a>

## Spoken-turn details (additive, 0.45.0, #3728)

`SpokenTurnProps` in `@schlessera/brain-ui-kit` gains optional
`details?: SpokenTurnDetails`, and the package exports the new type
`SpokenTurnDetails` (`Omit<TranscriptQualifiersProps, "trigger">`). With it, a
spoken turn renders one visually hidden "Details" stop, named by the existing
transcript-qualifier string and marked `aria-haspopup="dialog"`, that shows as a
pill on keyboard focus or after a 300ms pointer hover. Enter, Space, Shift+F10,
the ContextMenu key, a right-click (unless text inside the turn is selected) and
a 500ms touch long-press open the existing transcript details dialog, and focus
returns to the stop on close. No glyph renders. `TranscriptQualifiersProps`,
now reachable through that type, gains optional `trigger?: "glyphs" | "reveal"`;
omitted or `"glyphs"`, the trigger renders exactly as before. A turn without
`details` is unchanged. `api-report/` records the added props and type.

## Prospective trust policy data (additive, #3607)

The governance policy types reachable through ui-server's public signatures
Expand Down
27 changes: 23 additions & 4 deletions packages/ui-kit/src/conversation/TranscriptQualifiers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export interface TranscriptQualifiersProps {
finish?: "updating" | "some-updating" | "finished" | "unknown";
evidenceLabel: string;
children: ReactNode;
/**
* How the details are reached. `glyphs` (the default) is the evidence glyph
* button with its hover and focus tooltip. `reveal` is a visually hidden
* "Details" stop that shows as a pill on focus, or when its host sets
* `data-reveal` on an ancestor (hover); it carries no glyph and no tooltip,
* and opens the same dialog (#3728).
*/
trigger?: "glyphs" | "reveal";
}

const finishCopy = {
Expand Down Expand Up @@ -112,17 +120,28 @@ export function TranscriptQualifiers(p: TranscriptQualifiersProps) {
}, [shown]);
const returnFocus = () => trigger.current?.isConnected ? trigger.current : anchor.current?.isConnected ? anchor.current : owner?.returnFocus() ?? null;
const portal = trigger.current?.ownerDocument.body;
return <>
<button
const opened = () => { hide(); suppressed.current = true; anchor.current = trigger.current?.closest<HTMLElement>("[data-arrival-key],[data-transcript-anchor]") ?? null; if (trigger.current) owner?.onRead(trigger.current); setOpen(true); };
const control = p.trigger === "reveal"
? <button
// raw-button: kit — The reveal stop is clipped at rest, not hidden, so browse mode still finds it.
type="button" ref={trigger} className="bk-transcript-reveal" data-transcript-qualifiers={p.kind} data-transcript-trigger="reveal"
aria-label={name} aria-haspopup="dialog" aria-expanded={open} aria-controls={`${id}-details`}
onFocus={() => { if (trigger.current) owner?.onRead(trigger.current); skipFocus.current = false; }}
onClick={opened}>
<span className="bk-transcript-pill" aria-hidden="true">Details</span>
</button>
: <button
// raw-button: kit — Multi-glyph evidence needs focus/hover descriptions without a native title tooltip.
type="button" ref={trigger} className="bk-control bk-transcript-qualifiers" data-transcript-qualifiers={p.kind}
aria-label={name} aria-haspopup="dialog" aria-expanded={open} aria-controls={`${id}-details`} aria-describedby={shown ? `${id}-tooltip` : undefined}
onPointerEnter={event => { if (event.pointerType !== "touch") { hovered.current = true; enter(); } }}
onPointerLeave={() => { hovered.current = false; leave(); }}
onFocus={() => { if (trigger.current) owner?.onRead(trigger.current); if (skipFocus.current) { skipFocus.current = false; return; } enter(); }} onBlur={leave}
onClick={() => { hide(); suppressed.current = true; anchor.current = trigger.current?.closest<HTMLElement>("[data-arrival-key],[data-transcript-anchor]") ?? null; if (trigger.current) owner?.onRead(trigger.current); setOpen(true); }}>
onClick={opened}>
<span className="bk-transcript-glyphs" aria-hidden="true">{keys.map(key => <Icon key={key} icon={vocabulary[key].icon} size={14} />)}</span>
</button>
</button>;
return <>
{control}
{portal && shown && createPortal(<div id={`${id}-tooltip`} ref={tooltip} role="tooltip" className="bk-transcript-tooltip" style={{ ...position, colorScheme: getComputedStyle(trigger.current!).colorScheme }}
onPointerEnter={() => { hovered.current = true; clear(); }} onPointerLeave={() => { hovered.current = false; leave(); }}>
{sentences.join(" ")} Source: {p.source || "unknown"}. Open transcript details for evidence.
Expand Down
1 change: 1 addition & 0 deletions packages/ui-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export {
VoiceToolChip,
type Speaker,
type SpokenMarkProps,
type SpokenTurnDetails,
type SpokenTurnProps,
type UncertainWordProps,
type VoiceToolChipProps,
Expand Down
27 changes: 27 additions & 0 deletions packages/ui-kit/src/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,9 @@
.bk-voice-meter[data-mode="sweep"] { background: var(--bk-voice-tint); }
.bk-voice-ring .bk-voice-ring-fill { transition: none; }
span.bk-voice-cursor, span.bk-voice-ctl-spin, span.bk-voice-spin { animation: none; }
/* A spoken turn's Details pill appears without fading (#3728). Its shown
* rules carry two classes or a class and a pseudo-class, so this carries three. */
.bk-spoken-turn[data-details] .bk-transcript-reveal { transition: none; }
}

/* ── Interaction states ────────────────────────────────────────────────────
Expand Down Expand Up @@ -2904,6 +2907,29 @@ html:has(dialog.bk-overlay[open]:modal) { overflow: hidden; }
.bk-spoken-bubble { max-width: 82%; box-sizing: border-box; padding: 10px 13px; border: 1px solid var(--bk-color-edge); border-radius: 16px 16px 5px 16px; background: var(--bk-color-raised); font: 400 13.5px/1.55 "Plus Jakarta Sans", sans-serif; color: var(--bk-color-ink); overflow-wrap: anywhere; }
.bk-spoken-bubble[data-in-progress="true"] { border-color: var(--bk-amber-ink); background: transparent; }
.bk-spoken-prose { font: 400 13.5px/1.7 "Plus Jakarta Sans", sans-serif; color: var(--bk-color-ink); overflow-wrap: anywhere; }
/* A spoken turn's Details stop (#3728). One per turn, in place of the evidence
* glyph: clipped at rest (not `display: none`, so browse mode finds it), shown
* on keyboard focus, while its dialog is open, or when the turn sets
* `data-reveal` after a 300ms hover. The 24px pill sits on a 44px hit area
* absolutely placed on the turn's outer bottom corner, right for yours and
* left for brain's, so showing it never moves the chat. A long-press shows the
* pressed veil and edge (`data-pressed`): no ring, no scale. On `(hover: none)`
* the turn's words are not selectable, so a long-press never selects text;
* they stay selectable in the dialog's evidence. */
.bk-spoken-turn[data-details] > .bk-spoken-bubble, .bk-spoken-turn[data-details] > .bk-spoken-prose { position: relative; }
.bk-transcript-reveal { position: absolute; z-index: 1; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 44px; min-height: 44px; margin: 0; padding: 0 2px; border: 0; background: transparent; color: var(--bk-color-ink-dim); font: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; clip-path: inset(50%); opacity: 0; }
.bk-spoken-bubble > .bk-transcript-reveal { right: 8px; top: calc(100% - 22px); }
.bk-spoken-prose > .bk-transcript-reveal { left: 0; top: calc(100% - 14px); }
.bk-transcript-pill { display: inline-flex; align-items: center; box-sizing: border-box; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--bk-color-raised); box-shadow: inset 0 0 0 1px var(--bk-color-edge); font: 600 11px/1 "Plus Jakarta Sans", sans-serif; color: var(--bk-color-ink-dim); white-space: nowrap; }
.bk-transcript-reveal:focus-visible, .bk-transcript-reveal[aria-expanded="true"], [data-reveal="true"] .bk-transcript-reveal { clip-path: none; opacity: 1; transition: opacity 120ms linear; }
.bk-transcript-reveal:focus-visible { outline: none; }
.bk-transcript-reveal:focus-visible > .bk-transcript-pill { outline: 2px solid var(--bk-focus-ring); outline-offset: 2px; }
.bk-transcript-reveal:hover > .bk-transcript-pill { box-shadow: inset 0 0 0 1px var(--bk-hover-border); color: var(--bk-color-ink); }
.bk-spoken-turn[data-pressed="true"] > .bk-spoken-bubble { border-color: var(--bk-hover-border); background-image: linear-gradient(var(--bk-hover-veil-strong), var(--bk-hover-veil-strong)); }
.bk-spoken-turn[data-pressed="true"] > .bk-spoken-prose { border-radius: 8px; background: var(--bk-hover-veil-strong); box-shadow: 0 0 0 4px var(--bk-hover-veil-strong), 0 0 0 5px var(--bk-hover-border); }
@media (hover: none) {
.bk-spoken-turn[data-details] { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
}
.bk-voice-cursor { display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -2px; background: var(--bk-amber-fill); animation: bk-voice-blink 1s steps(1, end) infinite; }
@keyframes bk-voice-blink { 50% { opacity: 0; } }
.bk-uncertain { text-decoration-line: underline; text-decoration-style: dotted; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: currentColor; }
Expand All @@ -2924,3 +2950,4 @@ html:has(dialog.bk-overlay[open]:modal) { overflow: hidden; }
[data-motion="reduce"] .bk-voice-meter[data-mode="sweep"] { background: var(--bk-voice-tint); }
[data-motion="reduce"] .bk-voice-ring-fill { transition: none; }
[data-motion="reduce"] .bk-voice-cursor, [data-motion="reduce"] .bk-voice-ctl-spin, [data-motion="reduce"] .bk-voice-spin { animation: none; }
[data-motion="reduce"] .bk-spoken-turn[data-details] .bk-transcript-reveal { transition: none; }
88 changes: 86 additions & 2 deletions packages/ui-kit/src/voice/SpokenTurn.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ReactNode } from "react";
import { useEffect, useRef, useState, type KeyboardEvent, type MouseEvent, type PointerEvent, type ReactNode } from "react";

import { TranscriptQualifiers, type TranscriptQualifiersProps } from "../conversation/TranscriptQualifiers.js";
import { Icon } from "../primitives/Icon.js";

export type Speaker = "you" | "brain";
Expand All @@ -20,30 +21,113 @@ export function SpokenMark(p: SpokenMarkProps) {
);
}

/** A spoken turn's transcript details: the existing qualifier evidence. */
export type SpokenTurnDetails = Omit<TranscriptQualifiersProps, "trigger">;

export interface SpokenTurnProps {
speaker: Speaker;
/** Still being recognized: an outlined bubble with a cursor. You only. */
inProgress?: boolean;
/** Brain was talked over: a quiet "cut off" tag after the played words. */
cutOff?: boolean;
/**
* The turn's transcript details (#3728). Renders one visually hidden
* "Details" stop that shows on focus or hover, and opens the same dialog on
* a long-press, a right-click or Shift+F10 / the ContextMenu key. No glyph.
*/
details?: SpokenTurnDetails;
children?: ReactNode;
}

/** The hover delay before the pill shows, as the glyph tooltip's. */
const HOVER_MS = 300;
/** A long-press shows the pressed veil, then opens the details. */
const VEIL_MS = 150;
const HOLD_MS = 500;
/** Movement past this aborts a long-press, so scrolling is unaffected. */
const SLOP_PX = 10;

/**
* A spoken turn in the chat. It reads like any other message, with a small
* inline mark. Yours is a bubble; brain's is prose, as a typed answer is.
*/
export function SpokenTurn(p: SpokenTurnProps) {
const turn = useRef<HTMLDivElement>(null);
const [reveal, setReveal] = useState(false);
const [pressed, setPressed] = useState(false);
const hover = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
const hold = useRef<{ x: number; y: number; id: number; timers: Array<ReturnType<typeof setTimeout>> } | null>(null);
const held = useRef(false);
const details = p.details;
useEffect(() => () => { clearTimeout(hover.current); for (const t of hold.current?.timers ?? []) clearTimeout(t); }, []);

const open = () => turn.current?.querySelector<HTMLButtonElement>('[data-transcript-trigger="reveal"]')?.click();
const release = () => { for (const t of hold.current?.timers ?? []) clearTimeout(t); hold.current = null; setPressed(false); };
/** T2: a selection inside the turn keeps the native menu, so Copy works. */
const selecting = () => {
const selection = turn.current?.ownerDocument.getSelection();
return !!selection && !selection.isCollapsed && selection.rangeCount > 0 && !!turn.current && selection.containsNode(turn.current, true);
};

const handlers = details ? {
"data-details": "",
"data-reveal": reveal ? "true" : undefined,
"data-pressed": pressed ? "true" : undefined,
onPointerEnter: (event: PointerEvent<HTMLDivElement>) => {
if (event.pointerType === "touch") return;
clearTimeout(hover.current);
hover.current = setTimeout(() => setReveal(true), HOVER_MS);
},
onPointerLeave: () => { clearTimeout(hover.current); setReveal(false); },
onPointerDown: (event: PointerEvent<HTMLDivElement>) => {
if (event.pointerType !== "touch" || !event.isPrimary) return;
release();
held.current = false;
hold.current = {
x: event.clientX, y: event.clientY, id: event.pointerId,
timers: [
setTimeout(() => setPressed(true), VEIL_MS),
setTimeout(() => { release(); open(); held.current = true; }, HOLD_MS),
],
};
},
onPointerMove: (event: PointerEvent<HTMLDivElement>) => {
const start = hold.current;
if (start && event.pointerId === start.id && Math.hypot(event.clientX - start.x, event.clientY - start.y) > SLOP_PX) release();
},
onPointerUp: release,
onPointerCancel: release,
// The finger lifting after a long-press must not also tap the uncertain word.
onClickCapture: (event: MouseEvent<HTMLDivElement>) => {
if (!held.current) return;
held.current = false;
event.preventDefault();
event.stopPropagation();
},
onContextMenu: (event: MouseEvent<HTMLDivElement>) => {
if (selecting()) return;
event.preventDefault();
release();
open();
},
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => {
if (!(event.key === "ContextMenu" || (event.key === "F10" && event.shiftKey))) return;
event.preventDefault();
open();
},
} : {};

const body = (
<>
<SpokenMark speaker={p.speaker} />
{p.children}
{p.inProgress && p.speaker === "you" ? <span className="bk-voice-cursor" aria-hidden="true" /> : null}
{p.cutOff ? <CutOffTag /> : null}
{details ? <TranscriptQualifiers {...details} trigger="reveal" /> : null}
</>
);
return (
<div className="bk-spoken-turn" data-speaker={p.speaker}>
<div ref={turn} className="bk-spoken-turn" data-speaker={p.speaker} {...handlers}>
{p.speaker === "you" ? (
<div className="bk-spoken-bubble" data-in-progress={p.inProgress ? "true" : undefined} aria-busy={p.inProgress || undefined}>{body}</div>
) : (
Expand Down
Loading
Loading