Files
CatoandClaude Opus 5.5 c1d7379919 feat: chatkit v0.1 — one chat for every product
The fleet had 13 chats in 10 repos, each written fresh, each missing what
another had fixed. This extracts loki /loki (composer, thread, messages,
markdown, attachments) and adds heidi's microphone and orangecat's keyboard fix:

- Composer: auto-growing 16px textarea, Enter/Shift+Enter/IME, Send and Stop
  in one slot, attachments with paste, mic always present, every label
  translatable, app-specific controls in slots.
- useDictation: browser recogniser first; missing or SILENT (4 s watchdog,
  bounded permission wait) -> record and transcribe on the server; a dead
  recogniser remembered 30 days; every failure shown in words.
- ChatThread/ChatMessage: stick-to-bottom + jump button, speaker names once two
  agents speak, Copy on answers, Retry on the last one, failed turns visible.
- Markdown with no HTML path; javascript: links stay text.
- styles.css: --ck-* variables defaulting to @bitbaum/design-tokens.
- verify = format, lint, types, build, 18 unit/render tests and 21 browser
  checks (390px + desktop, light + dark, a sentence through a fake mic past a
  silent recogniser). Browser checks mutation-tested (14px input, 60 s
  watchdog) — both fail as they should.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 08:06:26 +02:00

90 lines
3.4 KiB
TypeScript

import type { ReactNode } from "react";
import { type CitationMap, type RenderLink } from "./Markdown.js";
export type ChatSpeaker = {
/** Shown above the message when more than one agent can answer. */
name: string;
/** Stable id for styling (`ck-from-<id>`), e.g. "cat" or "loki". */
id?: string;
};
export type ChatMessageData = {
id: string;
role: "user" | "assistant";
content: string;
speaker?: ChatSpeaker;
citations?: CitationMap;
/** The turn failed: shown as a failure with Retry, never as silence. */
failed?: boolean;
};
export type ThreadLabels = {
copy: string;
copied: string;
retry: string;
stop: string;
working: string;
stopped: string;
jump: string;
failed: string;
loading: string;
};
export declare const DEFAULT_THREAD_LABELS: ThreadLabels;
/**
* One turn. The asymmetry is deliberate: the person's own words get a pill —
* a short aside they already know — and the answer gets the full column with
* no box, because it is the thing being READ. Copy is on every answer; Retry
* only on the last one (retrying an older turn would fork the thread).
*/
export declare function ChatMessage({ message, onRetry, renderLink, showSpeaker, footer, last, labels, }: {
message: ChatMessageData;
/** The latest answer: its actions stay visible (they are what you want next). */
last?: boolean;
onRetry?: () => void;
renderLink?: RenderLink;
/** Hide the name when only one agent ever speaks. */
showSpeaker?: boolean;
/** Under the answer: provenance, sources, an action card. */
footer?: ReactNode;
labels?: ThreadLabels;
}): import("react").JSX.Element;
export type LiveTurn = {
/** What has streamed in so far. */
text?: string;
/** What it is doing before the first word ("Reading the fleet map"). */
status?: string;
speaker?: ChatSpeaker;
};
/**
* The conversation. Follows new tokens only while the reader is at the
* bottom, with a button back down once they are not; a turn in flight can be
* stopped from where it is being written.
*/
export declare function ChatThread({ messages, live, loading, stopped, onStop, onRetry, renderLink, renderFooter, showSpeakers, empty, children, labels: labelOverrides, }: {
messages: ChatMessageData[];
live?: LiveTurn | null;
loading?: boolean;
/** The person stopped the last turn themselves. */
stopped?: boolean;
onStop?: () => void;
/** Retry the last answer (offered on it, and on a failed one). */
onRetry?: () => void;
renderLink?: RenderLink;
/** App-specific content under an answer (sources, an action card). */
renderFooter?: (m: ChatMessageData) => ReactNode;
/** Default: shown when more than one speaker appears in the thread. */
showSpeakers?: boolean;
/** Shown instead of the thread before the first message (starters). */
empty?: ReactNode;
/** After the last turn (a note, a picker). */
children?: ReactNode;
labels?: Partial<ThreadLabels>;
}): import("react").JSX.Element;
export type Starter = string | {
label: string;
prompt?: string;
};
/** The empty state that starts a conversation. It disappears once one has. */
export declare function ChatStarters({ starters, onPick, title, }: {
starters: readonly Starter[];
onPick: (prompt: string) => void;
title?: ReactNode;
}): import("react").JSX.Element;
//# sourceMappingURL=Thread.d.ts.map