mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-04 05:47:59 +01:00
The Ask panel and /chat were Substrata's own assembly of chatkit's pieces (ChatScreen, Composer, ChatThread) with no chat list, no New chat and no reload. They are now chatkit 0.18's ChatApp, the same app Heidi, Loki and OrangeCat move onto: Chats drawer (a rail on a wide screen) with search, rename and delete, New chat, temporary chat, titles, the queue, Stop and the open chat reopened on reload. Chats are kept on the reader's device (localConversationStore); no server conversations, no migration. Substrata keeps only its own parts: the transport (askTransport: /api/chat with pictures, the stream into turn.update, the evidence on the message, the server's own words on a failed turn), chartkit renderers, AnswerFooter, the key and "Send evidence" under the composer, one composer configuration shared with the home box. Panel and /chat share the store and the open chat, so Expand is only a bigger frame (lib/ask-thread.ts goes). A message from elsewhere (Check this, ?q=, the home box's ?send= with its pictures) opens a new chat and is sent through the composer, since ChatApp has no send handle yet (lib/chat/drive-composer.ts says so). Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com>
85 lines
3.4 KiB
TypeScript
85 lines
3.4 KiB
TypeScript
/**
|
||
* /chat layout contract: the page is the fleet's whole-screen chat
|
||
* (chatkit ChatScreen, as on Loki and Solon). ChatScreen owns the heights —
|
||
* the visual viewport under a phone keyboard, the measured header and
|
||
* composer insets — so the page computes none, and on a phone the site's
|
||
* own bars step aside so the conversation has the whole display.
|
||
*/
|
||
|
||
import { test } from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import { readFileSync } from 'node:fs';
|
||
import { join } from 'node:path';
|
||
|
||
import { viewport } from '../app/chat/page';
|
||
|
||
const ROOT = new URL('..', import.meta.url).pathname;
|
||
const css = () => readFileSync(join(ROOT, 'app/styles/ask.css'), 'utf8');
|
||
const chat = () => readFileSync(join(ROOT, 'components/portal/ResearchChat.tsx'), 'utf8');
|
||
|
||
test('/chat exports viewport with interactiveWidget: resizes-content', () => {
|
||
assert.equal(
|
||
viewport?.interactiveWidget,
|
||
'resizes-content',
|
||
'/chat must tell mobile browsers to resize content when the virtual keyboard appears',
|
||
);
|
||
});
|
||
|
||
test('/chat renders through ChatApp filling the visual viewport', () => {
|
||
const code = chat();
|
||
assert.match(code, /<ChatApp\s[\s\S]*?fill=\{compact \? 'parent' : 'viewport'\}/);
|
||
assert.match(code, /headerStart=\{[\s\S]*?className="ck-glass"/, 'a ck-glass way back home');
|
||
assert.match(code, /'companion is-compact'/, 'the dock keeps the compact column');
|
||
});
|
||
|
||
test('ask.css computes no chat height of its own', () => {
|
||
const s = css();
|
||
assert.doesNotMatch(
|
||
s,
|
||
/\.companion(?:\.is-compact)?\s*\{[^}]*height:\s*calc\(/,
|
||
'ChatScreen owns the height',
|
||
);
|
||
assert.doesNotMatch(s, /\.companion\s+\.ck-composer-wrap/, 'no sticky composer on /chat');
|
||
assert.doesNotMatch(s, /\.companion-page\s+\.companion/, 'the old column rule is gone');
|
||
});
|
||
|
||
test('ask.css gives the conversation the whole phone display and keeps the window still', () => {
|
||
const s = css();
|
||
assert.match(
|
||
s,
|
||
/\.shell\.is-chat \.shell-column \{[\s\S]*?overflow:\s*hidden/,
|
||
'the shell column never scrolls on /chat; the thread is the scroller',
|
||
);
|
||
assert.match(
|
||
s,
|
||
/@media \(max-width: 767\.98px\) \{[\s\S]*?\.shell\.is-chat \.shell-topbar,\s*\.shell\.is-chat \.shell-tabbar \{\s*display:\s*none/,
|
||
'below 768px the top bar and tab bar step aside',
|
||
);
|
||
assert.match(
|
||
s,
|
||
/@media \(min-width: 768px\) \{[\s\S]*?\.companion-page \.ck-app-viewport \{\s*height:\s*calc\(var\(--ck-viewport-height, 100dvh\) - var\(--spacing-topbar\)\)/,
|
||
'from 768px the screen takes the height under the top bar',
|
||
);
|
||
const chatPage = readFileSync(join(ROOT, 'app/chat/page.tsx'), 'utf8');
|
||
assert.match(chatPage, /<Shell\s+footer=\{false\}>/, '/chat must suppress footer in Shell');
|
||
});
|
||
|
||
test('ask.css pads the empty state with the measured insets, like the thread', () => {
|
||
const s = css();
|
||
assert.match(
|
||
s,
|
||
/\.companion \.ck-screen-body > \.ask-empty \{[\s\S]*?--ck-top-inset[\s\S]*?--ck-bottom-inset[\s\S]*?overflow-y:\s*auto/,
|
||
'the empty state scrolls under the floating header and composer',
|
||
);
|
||
});
|
||
|
||
test('the panel is chatkit’s screen filling the sheet: its thread is the scroller', () => {
|
||
const s = css();
|
||
assert.match(
|
||
s,
|
||
/\.companion \{[\s\S]*?flex:\s*1;[\s\S]*?min-height:\s*0[\s\S]*?\.ask-sheet-body > \.companion/,
|
||
'the screen takes the sheet’s height, so chatkit’s thread scrolls inside it',
|
||
);
|
||
assert.doesNotMatch(s, /\.companion\.is-compact \.ck-thread/, 'no hand-made scroller');
|
||
});
|