Files
substrata/test/ask-thinking.test.ts
CatoandClaude 366d3edb30 feat(ask): the Ask panel scrolls, expands to /chat, and answers draw charts (#213)
The owner's phone (2026-10-23, /atlas, Ask Substrata over a bottleneck): the
answer could not be scrolled, there was no way to expand it, "Quick replies"
was a heading over nothing, "3 records read" a stray line, and the composer
carried "Model: Auto" and a paperclip.

- The panel is chatkit's ChatScreen in a sheet (AskPanel): on a phone a
  bottom sheet to 92% of the visual viewport with a grip; from 768px a
  right-hand panel. One title row: Ask Substrata · Expand · Close.
- Expand hands the whole thread to /chat (lib/ask-thread.ts); the URL
  carries only an id and the conversation id continues.
- Suggested replies are chatkit's reply row (nothing drawn when empty);
  records read are the thought row above the answer ("Read 3 records").
- Composer: microphone and send; the key chip only with a BYOK key.
- Charts in answers (chatkit 0.15): chart blocks drawn by chartkit
  (LineChart, BarChart, ShareBars, Timeline, StatTiles) on every chat
  surface; chartable tools return page links and plain numbers.
- --ck-page mapped to the surface token: unmapped, the dark theme drew
  light text on chatkit's near-white page.
- check:ask-layout (scripts/ux/ask-layout.mjs): 320/390/1440, light and
  dark — the thread scrolls, no sideways overflow, 44px targets, no cut
  words, Expand lands on /chat with the same turns.


Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 13:00:25 +02:00

51 lines
1.7 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* "Thought for 4s › Read 3 records" above an answer: what the assistant did,
* as chatkit's thought row, in place of a stray "3 records read" line under
* it. The trail comes first, the records read are one step, and an answer
* that did nothing draws no row at all.
*/
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { thinkingFor } from '../components/portal/chat/thinking';
import type { Turn } from '../components/portal/chat/types';
const source = (id: string, title: string): NonNullable<Turn['sources']>[number] => ({
number: 1,
id,
title,
href: `/markets/${id}`,
evidence: 'Sourced',
primary: [],
kind: 'company',
});
test('the trail, then "Read N records", with the time it took', () => {
const t = thinkingFor({
id: 'a',
role: 'assistant',
content: '…',
trail: ['Looking up ASML', 'Reading listings and exposure for ASML'],
sources: [source('asml', 'ASML'), source('zeiss', 'Zeiss'), source('cymer', 'Cymer')],
durationMs: 4200,
});
assert.ok(t);
assert.equal(t.durationMs, 4200);
assert.deepEqual(
t.steps?.map((s) => s.label),
['Looking up ASML', 'Reading listings and exposure for ASML', 'Read 3 records'],
);
assert.equal(t.steps?.at(-1)?.detail, 'ASML · Zeiss · Cymer');
});
test('one record is singular; nothing done is no row', () => {
const one = thinkingFor({
id: 'a',
role: 'assistant',
content: '…',
sources: [source('asml', 'ASML')],
});
assert.equal(one?.steps?.[0]?.label, 'Read 1 record');
assert.equal(thinkingFor({ id: 'a', role: 'assistant', content: '…' }), undefined);
assert.equal(thinkingFor({ id: 'u', role: 'user', content: 'hi', trail: ['x'] }), undefined);
});