mirror of
https://github.com/bitbaum/chatkit.git
synced 2026-12-04 10:48:27 +01:00
The owner's finding, 2026-11-06: every product installs the shared packages
and the text boxes people type in are still made by hand, with no microphone;
two comment systems were written in one week. This gives the two remaining
shapes of "a person types words" a component, so there is nothing to build
locally.
- DictationField: a labelled text area (or one line) with the composer's
microphone — Web Speech, the recording fallback, the take with its timer,
kept for a retry — appending to what is there; 16px, 44px targets.
Optional improve={{ run, suggestions }}: one tap or say/type what to change;
working, failure and Undo in words, the text untouched on failure. No model
call or prompt here; run is the app's.
- CommentThread: oldest first, the box is Composer, a transport the app
implements (post, optional remove), optimistic removal rolled back with a
message, a refused post keeps the draft, text not markup, a sign-in link
for a signed-out reader, times in a stated timeZone.
- VoiceBar/VoiceProblem are one implementation shared by Composer and the
field; Composer behaves as before.
- Styles after the ChatApp boundary: the embedded sheet keeps its budget.
- test/browser-field.mjs + fixture page; render tests; README; 0.23.0.
verify: format, lint, typecheck, build, 142 unit tests, and all five browser
suites (the four existing ones unchanged) pass.
Claude-Session: https://claude.ai/code/session_019MDtmvpWNTLxXNfwUHS7MD
Co-authored-by: Claude <noreply@anthropic.com>
49 lines
1.8 KiB
JavaScript
49 lines
1.8 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { gzipSync } from "node:zlib";
|
|
import { test } from "node:test";
|
|
|
|
const source = readFileSync(new URL("../styles.css", import.meta.url), "utf8");
|
|
const embedded = readFileSync(new URL("../styles/chat.css", import.meta.url), "utf8");
|
|
const appMarker = "/* ── ChatApp: the whole app";
|
|
const appBoundary = source.indexOf(appMarker);
|
|
|
|
test("embedded stylesheet is generated from the shared chat styles", () => {
|
|
assert.notEqual(appBoundary, -1, "the full stylesheet marks ChatApp-only styles");
|
|
assert.equal(embedded, source.slice(0, appBoundary).trimEnd() + "\n");
|
|
});
|
|
|
|
test("embedded stylesheet includes shared chat surfaces and excludes ChatApp chrome", () => {
|
|
for (const selector of [".ck-composer", ".ck-thread", ".ck-rich", ".ck-choice"]) {
|
|
assert.ok(embedded.includes(selector), `${selector} remains styled`);
|
|
}
|
|
assert.ok(!embedded.includes(".ck-app-rail"), "the full app's history rail is not embedded");
|
|
assert.ok(
|
|
!embedded.includes(".ck-field-wrap"),
|
|
"DictationField is not a chat surface: not embedded",
|
|
);
|
|
assert.ok(
|
|
!embedded.includes(".ck-comments"),
|
|
"CommentThread is not a chat surface: not embedded",
|
|
);
|
|
for (const selector of [
|
|
".ck-field-wrap",
|
|
".ck-field-input",
|
|
".ck-comments",
|
|
".ck-comment-body",
|
|
]) {
|
|
assert.ok(
|
|
source.slice(appBoundary).includes(selector),
|
|
`${selector} is styled in the full sheet`,
|
|
);
|
|
}
|
|
assert.ok(source.slice(appBoundary).includes(".ck-app-rail"), "full ChatApp styling remains");
|
|
});
|
|
|
|
test("embedded stylesheet stays within its compressed transfer budget", () => {
|
|
assert.ok(
|
|
gzipSync(embedded).byteLength <= 11_000,
|
|
`embedded stylesheet is ${gzipSync(embedded).byteLength} bytes gzipped (budget 11,000)`,
|
|
);
|
|
});
|