mirror of
https://github.com/bitbaum/chatkit.git
synced 2026-12-04 08:38:57 +01:00
* 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> * fix(styles): --ck-* defaults at zero specificity on :root, so an app's own values win Declared on the chat's elements they overrode any app setting --ck-* at the root — the opposite of what the README promised. Found preparing loki, whose colour variables are full OKLCH colours under the design-token names and so must map them. New browser check: a :root --ck-accent reaches the chat. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
import { type DependencyList, type RefObject } from "react";
|
|
/**
|
|
* Copy + a checkmark that resets. Failures are swallowed on purpose (insecure
|
|
* origin, denied permission): the text stays selectable, so a failed copy
|
|
* blocks nothing — `copied` simply never flips.
|
|
*/
|
|
export declare function useClipboard(resetMs?: number): {
|
|
copied: boolean;
|
|
copy: (text: string) => void;
|
|
};
|
|
/**
|
|
* Follow the conversation only while the reader is at the bottom, and offer a
|
|
* way back once they are not. Pinned in a layout effect so the view settles
|
|
* before the new token paints — in a passive effect the content lands first
|
|
* and the scroll catches up, which reads as a shudder on every chunk.
|
|
*
|
|
* `grew` should change when a NEW turn is added (message count): sending is an
|
|
* unambiguous "show me the reply", so it re-arms following.
|
|
*/
|
|
export declare function useStickToBottom(changes: DependencyList, grew: number): {
|
|
scrollRef: RefObject<HTMLDivElement | null>;
|
|
endRef: RefObject<HTMLDivElement | null>;
|
|
following: boolean;
|
|
onScroll: () => void;
|
|
jumpToBottom: () => void;
|
|
};
|
|
/**
|
|
* Publishes the VISUAL viewport height as `--ck-viewport-height`.
|
|
*
|
|
* `100dvh` does not shrink when the Android soft keyboard opens; only
|
|
* `visualViewport` does. A chat column sized `100dvh` keeps its height while
|
|
* the keyboard covers the bottom of it, so the composer ends up behind the
|
|
* keyboard (orangecat `ViewportHeightSync`, #1094). Rounded down: sub-pixel
|
|
* heights leave a 1px seam under the composer on some devices.
|
|
*/
|
|
export declare function useViewportHeight(target?: RefObject<HTMLElement | null>): void;
|
|
/** Grow a textarea to its content up to `max` px, keyed on the VALUE so a
|
|
* prefill, a dictated transcript or the clear after send resize it too. */
|
|
export declare function useAutoGrow(ref: RefObject<HTMLTextAreaElement | null>, value: string, max?: number): void;
|
|
//# sourceMappingURL=hooks.d.ts.map
|