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/attach-names-live-conversation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@schlessera/brain-ui-kit": minor
"@schlessera/brain-ui-react": patch
---
The composer's paperclip now says what its menu offers. The kit `Composer` gains an optional `attachLabel` prop for the attach trigger's accessible name, which defaults to "Attach — photo, camera, files". A pointer sees the same name as a tooltip after 400ms of hover, or at once on keyboard focus. Escape or opening the menu dismisses it, and touch screens never show it. When live conversation is available, the app names it in the trigger ("Attach — live conversation, photo, camera, files") and in the phone attach sheet's subtitle.
1 change: 1 addition & 0 deletions api-report/ui-kit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ signatures (every public export and the types it is made of)
onSend?: (value: string) => void;
onStop?: () => void;
onAttach?: () => void;
attachLabel?: string;
onMic?: () => void;
mic?: boolean;
micLabel?: string;
Expand Down
16 changes: 16 additions & 0 deletions docs/decisions/design-kit/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ The fifth drop answered the eleven questions the maintainer forwarded
its reason rather than omitted. The query is a real input.
4. **The composer is kit-owned.** The app's `ComposerView` retires; the app
keeps only the attach sheet, the provider list and the handlers.

> **2026-11-02 — Clarified by #3045 (maintainer ruling of 2026-10-29).**
> The attach trigger's name and pointer tooltip list the menu's current
> actions; live conversation is reached through it. The name always starts
> with "Attach" and, when live conversation is available, reads
> "Attach — live conversation, photo, camera, files"; otherwise
> "Attach — photo, camera, files". The kit `Composer` takes that name as
> its additive `attachLabel` prop and paints it as a tooltip after 400ms
> of hover and at once on keyboard focus, dismissed by Escape or by opening
> the menu, and never under `(hover: none)`. On touch the attach sheet's
> subtitle names the same actions, and instructions say "Tap the paperclip
> (Attach), then Live conversation." A dictating composer's trigger stays
> inert, with no name and no tooltip. This clarifies §4 and the reviewed
> composer detail (capture is a menu behind attach); it adds no separate
> entry, no persistent desktop label and no touch long-press, and the kit
> and the menu keep their ownership.
5. **No snooze on a blocking approval**; "Always allow" has no key.
6. **Focus after the last decision in a list goes to the `EmptyState` heading
that replaces the section, with the `InlineToast` receipt above it**; the
Expand Down
12 changes: 12 additions & 0 deletions docs/integration-contract/package-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4237,3 +4237,15 @@ packet audio. Unsupported codec/container forms, including audio/mp4, retain
conservative elapsed-wall timestamps for the rest of that recording. Old stored
wall timestamps remain readable without migration. No field, stop reason or
state is added. This semantic change ships in a minor before 1.0.

<a id="composer-attach-label-additive-0450-3045"></a>

## Composer attach label (additive, 0.45.0, #3045)

`ComposerProps` in `@schlessera/brain-ui-kit` gains optional
`attachLabel?: string`, the attach trigger's accessible name. Omitted or empty,
it is "Attach — photo, camera, files" (previously the fixed
"Attach — photo, camera, file"). An actionable trigger also paints that name as
an `aria-hidden` pointer tooltip; an inert trigger, including a dictating
composer's, has neither. Existing props and defaults are otherwise unchanged,
and no wire schema changes. `api-report/` records the added prop.
87 changes: 81 additions & 6 deletions packages/ui-kit/src/chrome/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,15 @@ export interface ComposerProps {
onSend?: (value: string) => void;
/** The stop disc while `streaming`, and `esc` inside the field. */
onStop?: () => void;
/** Opens the app's own capture menu (photo, camera, file). */
/** Opens the app's own capture menu (photo, camera, files). */
onAttach?: () => void;
/**
* The attach trigger's accessible name, and the pointer tooltip that shows
* it: the actions the app's menu currently offers, in menu order. Starts
* with "Attach" so an instruction naming the control still matches it.
* Defaults to "Attach — photo, camera, files".
*/
attachLabel?: string;
/** Opens capture, or stops it while `dictating`. */
onMic?: () => void;
/**
Expand All @@ -141,6 +148,9 @@ export interface ComposerProps {
maxRows?: number;
}

/** The attach trigger's default name: the capture menu with no live conversation in it. */
const ATTACH_LABEL = "Attach — photo, camera, files";

export type ComposerState = "ready" | "streaming" | "reconnecting" | "offline" | "dictating";

export interface ComposerRecall {
Expand Down Expand Up @@ -218,6 +228,8 @@ export function Composer(p: ComposerProps) {
}

const field: CSSProperties = {
// The attach tooltip anchors to the field, so it clears a grown field.
position: "relative",
flex: 1,
minWidth: 0,
display: "flex",
Expand Down Expand Up @@ -302,7 +314,7 @@ export function Composer(p: ComposerProps) {
<div style={{ display: "flex", alignItems: "flex-end", gap: 10 }}>
<div style={field} className="bk-field">
{showAttach ? (
<IconButton icon="attach" label="Attach — photo, camera, file" haspopup="menu" onClick={dictating ? undefined : p.onAttach} />
<IconButton icon="attach" label={p.attachLabel || ATTACH_LABEL} haspopup="menu" tip onClick={dictating ? undefined : p.onAttach} />
) : null}
<textarea
data-composer=""
Expand Down Expand Up @@ -415,16 +427,71 @@ function pressable(act: () => void) {
};
}

/**
* The attach tooltip's dismissal (#3045), on the trigger's own attribute. While
* the pointer is over it, Escape anywhere hides it — WCAG 1.4.13 asks for that
* without moving the pointer, even while focus is in the field — and Escape
* keeps every other meaning it has there (stopping a run); nothing is
* prevented. Leaving or blurring clears the dismissal for the next visit.
*/
const tipListeners = new WeakMap<HTMLElement, AbortController>();

function dismissTip(trigger: HTMLElement) {
trigger.setAttribute("data-tip-dismissed", "");
}

function armTip(trigger: HTMLElement) {
tipListeners.get(trigger)?.abort();
const controller = new AbortController();
tipListeners.set(trigger, controller);
trigger.ownerDocument.addEventListener("keydown", (event) => {
if (!trigger.isConnected) { controller.abort(); return; }
if (event.key === "Escape") dismissTip(trigger);
}, { signal: controller.signal });
}

function resetTip(trigger: HTMLElement, left: boolean) {
if (left) {
tipListeners.get(trigger)?.abort();
tipListeners.delete(trigger);
} else if (trigger.matches(":hover")) {
// Focus moving into the menu this trigger just opened is not a new visit:
// under a still-hovering pointer the tooltip would paint over the menu.
return;
}
trigger.removeAttribute("data-tip-dismissed");
}

/**
* The paperclip and the microphone inside the field: a 28px round target
* with a hover veil. During dictation the mic expands to a 44px stop target.
*
* Each gains an optional callback and D20's gating rule does the rest: with no
* handler this renders exactly the icon the source renders, with no role, no
* ring and no tab stop. The paperclip is a menu trigger, so it also says so.
*
* ## The paperclip's tooltip is its name, shown (#3045)
*
* A glyph with no text is only discoverable if its name can be seen, so an
* actionable `tip` trigger also paints its `label` above the field — the same
* string, so the visible label is the accessible name (WCAG 2.5.3) and a
* screen reader hears it once; the painted copy is `aria-hidden`. `theme.css`'s
* `.bk-tip` owns the timing: shown after 400ms of hover, at once on keyboard
* focus, and never under `(hover: none)`, where the app's sheet names the
* actions instead. It is a descendant of the trigger, so the pointer can move
* onto it without losing it (WCAG 1.4.13). Dismissal is the only state, and it
* is kept on the trigger itself (`data-tip-dismissed`, which React never
* renders) rather than in a hook, so the composer still costs one render per
* keystroke: Escape, or opening the menu, hides it until the pointer leaves or
* focus moves away. An inert trigger — a dictating composer — has no tooltip.
*/
function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: "menu"; targetSize?: number; onClick?: () => void }) {
function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: "menu"; tip?: boolean; targetSize?: number; onClick?: () => void }) {
const act = Boolean(props.onClick);
const tip = act && props.tip === true;
const activate = (target: HTMLElement) => {
if (tip) dismissTip(target);
props.onClick?.();
};
return (
<span
style={
Expand All @@ -440,15 +507,23 @@ function IconButton(props: { icon: "attach" | "mic"; label: string; haspopup?: "
"--hv-bg": token("hover-veil-strong"),
} as CSSProperties
}
className={act ? "bk-control" : undefined}
className={act ? (tip ? "bk-control bk-tip-host" : "bk-control") : undefined}
role={act ? "button" : undefined}
aria-label={act ? props.label : undefined}
aria-haspopup={act ? props.haspopup : undefined}
tabIndex={act ? 0 : undefined}
onClick={props.onClick}
onKeyDown={act ? pressable(() => props.onClick?.()) : undefined}
onClick={act ? (event) => activate(event.currentTarget) : undefined}
onKeyDown={act ? (event) => {
if (tip && event.key === "Escape") { dismissTip(event.currentTarget); return; }
const target = event.currentTarget;
pressable(() => activate(target))(event);
} : undefined}
onPointerEnter={tip ? (event) => armTip(event.currentTarget) : undefined}
onPointerLeave={tip ? (event) => resetTip(event.currentTarget, true) : undefined}
onBlur={tip ? (event) => resetTip(event.currentTarget, false) : undefined}
>
<Icon icon={props.icon} size={17} color={color.inkMute} />
{tip ? <span className="bk-tip" data-composer-tip="" aria-hidden="true">{props.label}</span> : null}
</span>
);
}
Expand Down
62 changes: 62 additions & 0 deletions packages/ui-kit/src/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,68 @@
outline-offset: -2px;
}

/* The composer's attach tooltip (#3045): the trigger's accessible name,
* painted above the field so a paperclip with no text can still be read.
*
* Anchored to the field (`position: relative` on its inline style), not the
* 28px glyph, so it clears a field that has grown to five rows. It is a DOM
* child of the trigger, so moving the pointer onto it keeps the trigger's
* `:hover` (WCAG 1.4.13, hoverable); the field's top padding sits between the
* two, so hiding waits 150ms — long enough to cross it — and showing again
* mid-hide is no transition at all, because both ends are visible.
*
* Hover shows it after 400ms; keyboard focus shows it at once. Touch never
* does: under `(hover: none)` it is not displayed, and the app's attach sheet
* names the actions instead. `data-tip-dismissed` is Escape or an opened menu,
* and `:active` hides it so a press never drags it with the 1px nudge.
* Visibility is the only thing that changes, so nothing moves under reduced
* motion either. */
.bk-tip {
position: absolute;
bottom: calc(100% + 6px);
left: 0;
z-index: var(--bk-z-popover);
box-sizing: border-box;
width: max-content;
/* The field starts ~28px in on a phone; keep the same margin on the right. */
max-width: min(22rem, calc(100vw - 56px));
padding: 5px 9px;
border: 1px solid var(--bk-color-edge);
border-radius: 8px;
background: var(--bk-color-raised);
color: var(--bk-color-ink);
box-shadow: 0 4px 14px var(--bk-palette-shadow);
font: 500 12px/1.4 "Plus Jakarta Sans", sans-serif;
white-space: normal;
overflow-wrap: anywhere;
text-align: left;
cursor: default;
visibility: hidden;
pointer-events: none;
transition: visibility 0s linear 150ms;
}
@media (hover: hover) {
.bk-tip-host:hover > .bk-tip {
visibility: visible;
pointer-events: auto;
transition-delay: 400ms;
}
}
.bk-tip-host:focus-visible > .bk-tip {
visibility: visible;
pointer-events: auto;
transition: none;
}
.bk-tip-host[data-tip-dismissed] > .bk-tip,
.bk-tip-host:active > .bk-tip {
visibility: hidden;
pointer-events: none;
transition: none;
}
@media (hover: none) {
.bk-tip { display: none; }
}

/* The real inputs inside a `.bk-field`: the composer's textarea, the
* palette's query and AskUserCard's "Other" answer. Each suppresses its own
* ring, because the field shows it, and paints its placeholder in mute ink at
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-kit/stories/chrome/Composer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ export const RecallStatic = meta.story({
export const AttachIsAMenu = meta.story({
args: { onAttach: fn(), onMic: fn(), onSend: fn() },
play: async ({ canvas, userEvent, args }) => {
const attach = await canvas.findByRole("button", { name: "Attach — photo, camera, file" });
const attach = await canvas.findByRole("button", { name: "Attach — photo, camera, files" });
await expect(attach).toHaveAttribute("aria-haspopup", "menu");
const names = (await canvas.findAllByRole("button")).map((b) => b.getAttribute("aria-label"));
await expect(names).toEqual(["Attach — photo, camera, file", "Dictate", "Send"]);
await expect(names).toEqual(["Attach — photo, camera, files", "Dictate", "Send"]);
await userEvent.click(attach);
await expect(args.onAttach).toHaveBeenCalled();
},
Expand Down
45 changes: 45 additions & 0 deletions packages/ui-kit/tests/composer-attach-tip.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* The composer's attach trigger names its menu (#3045): `attachLabel` is the
* accessible name and the tooltip paints the same string, `aria-hidden`, so a
* screen reader hears it once. An inert trigger — no handler, or a dictating
* composer — has neither. The tooltip's timing and touch gating are CSS, and
* are proven in the browser (`conversation-controls.offline.tsx`).
*/
import { describe, expect, test } from "bun:test";
import { renderToStaticMarkup } from "react-dom/server";

import { Composer } from "../src/chrome/Composer.js";

const onAttach = () => {};
const tip = (html: string) => html.match(/<span class="bk-tip" data-composer-tip="" aria-hidden="true">([^<]*)<\/span>/)?.[1];

describe("Composer attach tooltip", () => {
test("the default names the capture menu, and the tooltip paints that name", () => {
const html = renderToStaticMarkup(<Composer onAttach={onAttach} />);
expect(html).toContain('aria-label="Attach — photo, camera, files"');
expect(tip(html)).toBe("Attach — photo, camera, files");
expect(html).toContain("bk-tip-host");
});

test("attachLabel renames the trigger and its tooltip together", () => {
const label = "Attach — live conversation, photo, camera, files";
const html = renderToStaticMarkup(<Composer onAttach={onAttach} attachLabel={label} />);
expect(html).toContain(`aria-label="${label}"`);
expect(tip(html)).toBe(label);
});

test("an inert trigger has no name and no tooltip", () => {
for (const html of [
renderToStaticMarkup(<Composer />),
renderToStaticMarkup(<Composer state="dictating" onAttach={onAttach} attachLabel="Attach — live conversation, photo, camera, files" />),
]) {
expect(html).not.toContain("Attach —");
expect(html).not.toContain("bk-tip");
}
});

test("the microphone has no tooltip", () => {
const html = renderToStaticMarkup(<Composer onMic={() => {}} />);
expect(html).not.toContain("bk-tip");
});
});
2 changes: 1 addition & 1 deletion packages/ui-kit/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const railProject = (mode: "fine" | "coarse" | "mixed") => ({
// pointer; they need the consumer stylesheet. Button's hover text
// contrast (#974) and the palette's reason rows (#1106) are measured
// under all three pointers as well.
include: ["tests/visual/native-buttons.visual.tsx", "tests/visual/side-rail-targets.visual.tsx", "tests/visual/button-hover-contrast.visual.tsx", "tests/visual/overlay-targets.visual.tsx", "tests/visual/session-strip.visual.tsx", "tests/visual/pending-follow-ups.visual.tsx", "tests/visual/palette-reasons.visual.tsx", "../ui-react/tests/browser/desktop-navigation.pointer.tsx", "../ui-react/tests/browser/keyboard-hints.pointer.tsx", "../ui-react/tests/browser/phone-navigation.pointer.tsx", "../ui-react/tests/browser/destination-press.pointer.tsx", "../ui-react/tests/browser/working-sessions.pointer.tsx", "../ui-react/tests/browser/session-drafts.pointer.tsx", "../ui-react/tests/browser/navigation-reach.*.pointer.tsx", "../ui-react/tests/browser/hit-reach.*.pointer.tsx", "../ui-react/tests/browser/recordings-tray.offline.tsx", "../ui-react/tests/browser/dictation-notice.pointer.tsx", "../ui-react/tests/browser/overlay-stacking.pointer.tsx", "../ui-react/tests/browser/session-profile.pointer.tsx", "../ui-react/tests/browser/turn-budget.pointer.tsx"],
include: ["tests/visual/native-buttons.visual.tsx", "tests/visual/side-rail-targets.visual.tsx", "tests/visual/button-hover-contrast.visual.tsx", "tests/visual/overlay-targets.visual.tsx", "tests/visual/session-strip.visual.tsx", "tests/visual/pending-follow-ups.visual.tsx", "tests/visual/palette-reasons.visual.tsx", "../ui-react/tests/browser/desktop-navigation.pointer.tsx", "../ui-react/tests/browser/keyboard-hints.pointer.tsx", "../ui-react/tests/browser/phone-navigation.pointer.tsx", "../ui-react/tests/browser/destination-press.pointer.tsx", "../ui-react/tests/browser/working-sessions.pointer.tsx", "../ui-react/tests/browser/session-drafts.pointer.tsx", "../ui-react/tests/browser/navigation-reach.*.pointer.tsx", "../ui-react/tests/browser/hit-reach.*.pointer.tsx", "../ui-react/tests/browser/recordings-tray.offline.tsx", "../ui-react/tests/browser/dictation-notice.pointer.tsx", "../ui-react/tests/browser/attach-tooltip.pointer.tsx", "../ui-react/tests/browser/overlay-stacking.pointer.tsx", "../ui-react/tests/browser/session-profile.pointer.tsx", "../ui-react/tests/browser/turn-budget.pointer.tsx"],
provide: { railPointer: mode, keyboardHintsLive: false },
browser: {
enabled: true,
Expand Down
9 changes: 8 additions & 1 deletion packages/ui-react/src/components/chat/composer-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export function ComposerView(p: ComposerViewProps) {
}

const pointer = useMediaQuery("(min-width: 900px)");
// The trigger's name lists what its menu offers, in menu order (#3045):
// live conversation is reached through the paperclip, so the paperclip says
// so whenever the row is there. The kit paints the same string as the
// pointer tooltip; a phone's sheet names the actions in its subtitle.
const attachLabel = p.onConversation ? "Attach — live conversation, photo, camera, files" : undefined;
const attachSubtitle = `${p.onConversation ? "Live conversation, photo" : "Photo"}, camera, ${p.onPickTracks ? "track files, " : ""}or paste.`;
const attachMenu = (
<div className={pointer ? "bk-focus-clip flex flex-col rounded-[inherit]" : "flex flex-col"}>
{p.onConversation && <ListRow variant="group" icon="mic" iconTone="teal" title="Live conversation" subtitle="Talk while your agent works" onClick={p.onConversation} />}
Expand Down Expand Up @@ -203,7 +209,7 @@ export function ComposerView(p: ComposerViewProps) {
</div>
)}
<Overlay open={p.attachMenuOpen && !pointer} variant="sheet" title="Attach" data-overlay-site="attach"
subtitle={p.onPickTracks ? "Photo, camera, track files, or paste." : "Photo, camera, or paste."}
subtitle={attachSubtitle}
onClose={p.onAttachToggle}>
{attachMenu}
</Overlay>
Expand All @@ -225,6 +231,7 @@ export function ComposerView(p: ComposerViewProps) {
onSend={p.onSend}
onStop={p.onStop}
onAttach={p.onAttachToggle}
attachLabel={attachLabel}
onMic={p.onMic}
mic={p.mic}
micLabel={p.micLabel}
Expand Down
Loading
Loading