mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-05 07:07:36 +01:00
* fix(chat): the assistant stops answering a question it was never asked
A reader on /bottlenecks/euv-lithography-scanners asked who owns the
company that makes them, whether it is public or private, and what its
history is. The answer was "Not in your data", followed by a report that
"the web passage provided" discussed the difference between public and
private limited companies. Four separate faults produced that.
1. The web passage was never shown. `answerQuestion` returns `web`, and
the component has a block that renders it under its own heading — but
the stream handler destructured only `answer` and `sources`, so the
block was dead code and had been since it was written. The reader saw
an answer citing evidence the screen was hiding. Its classes had never
been exercised either: `border-strong` resolves to nothing, since the
token is `--color-border-strong`. It is a `companion-web` class now,
where this repo keeps visual decisions.
2. The lookup searched the question verbatim. "who owns this company is
it a public company..." has no subject in it. `lib/chat-query.ts` puts
the subject back: the page the reader is standing on, or the first
company among the retrieved rows when the question is about a company
and the page is a material. A question that already names something on
screen is left alone.
3. The refusal detector was `/not in your data/i` against one exact
phrase, so a model that wrote "the records do not cover" — which the
prompt invites — never triggered the lookup that exists for it.
4. There was no third register. "Is it listed?" is not a research
question, and a corpus is not supposed to hold it. The ladder now ends
in BACKGROUND: fenced to stable public facts, never a figure, a
capacity, a price or a supplier relationship, never cited, opened with
"Outside the corpus —", and marked on screen. Grounding verification
is skipped on that path, because its repair would reinstate the wall;
the fact-check route opts out of the whole ladder, since defending an
article with material the records do not hold is the one thing it can
never do.
Follow-ups were "Open the evidence for X" — not questions, and never
sent to the browser either. They are now questions this assistant can
answer, and they are buttons.
And the composer was five controls in a wrapping row: a native select at
full width, two square bordered boxes, a rounded filled button and a
borderless one — four visual weights, two ragged lines on a phone, with
the model picker the loudest thing in it and the contribution form (a
different action entirely) sitting inline with Ask. The textarea and the
tool bar now share one border and read as one surface; every quiet
control is the same height and weight; Ask is the only filled thing;
sending evidence sits below on its own. Checked at 320px, in both themes,
and with a long model id — the picker truncates rather than clipping the
labels beside it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkjZ1jJPhHzxAPvbSSG3wH
* fix(portal): the header is a menu again, at every width
The README has said "three menu groups and one action, because seven flat
items was more than a reader could hold" since components/portal/Megamenu.tsx
existed. That file was deleted in 7f59e09 and nothing noticed. What shipped
in its place was a flat list of nine uppercase links, and it was broken in a
different way at every width:
- 1440px: `.public-nav` had `flex-wrap: wrap`, so the nine links wrapped onto
two rows inside the header and made it twice as tall as the wordmark.
- 768–1099px: `.public-nav` was `display: none` until 1100px, so an iPad got
a lone letter-spaced "MENU" adrift beside the wordmark and an otherwise
empty bar.
- 390px: the panel was `position: absolute; right: 0` on a <details> sitting
mid-header, so a 22rem panel began 22rem to the LEFT of a button nowhere
near the right edge. The search field and every link label rendered off the
left side of the screen. That is the whole mobile menu, unusable.
The grouping is back, and this time it lives in `config/site-nav.ts` rather
than in a component that can be deleted quietly: every link is declared once
in `LINK`, and the header groups, the research list, the desk sidebar and the
footer are all built from those objects. Each destination carries one line
taken from that page's own description, so the menu says what is behind a
noun without adding a second sentence to keep true.
Wide (≥820px): three group dropdowns plus Join, one row, never wrapping, the
group you are inside marked under its own label. Narrow: one panel the full
width of the shell, anchored to the header's container — groups stacked,
search at the top, current page ruled down its left edge. Both are <details>,
so neither needs JavaScript to open.
Two things moved to make 820px fit: the inline search form now appears at lg
rather than md (below that it was competing with the nav for the same row,
which is why the nav was hidden to 1100px in the first place), and the menu
button moved from beside the wordmark to the end of the right-hand cluster,
where a thumb reaches. The header also moves to z-[60] so the open panel is
not painted over by the floating Ask dock, which sits at 50.
`test/nav.test.ts` reads the README's own table and fails if it stops
matching NAV_GROUPS. A README cannot notice its own component being deleted;
this can.
Also: chat starters are one column below 30rem instead of six ragged widths.
Verified in the running app at 320/390/834/1024/1440 — no horizontal overflow
at any width and the header is 65px tall at all five, with every nav route
returning 200.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkjZ1jJPhHzxAPvbSSG3wH
---------
Co-authored-by: Claude <noreply@anthropic.com>
93 lines
3.7 KiB
TypeScript
93 lines
3.7 KiB
TypeScript
/**
|
|
* The question, as a query.
|
|
*
|
|
* On 2026-09-20 a reader standing on the EUV lithography scanner page asked who
|
|
* owns the company that makes them. The corpus does not hold ownership, so the
|
|
* assistant looked the question up on the open web — verbatim, subject and all
|
|
* missing — and was handed an explainer on public versus private limited
|
|
* companies. The answer that came back was correct and useless.
|
|
*
|
|
* These tests hold the fix: the subject the reader can see on screen is the
|
|
* head of the query, "this company" on a material page resolves to a company,
|
|
* and a question that already names its subject is left alone.
|
|
*/
|
|
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
condense,
|
|
followUpsFor,
|
|
lookupQuery,
|
|
lookupSubject,
|
|
saysNotInCorpus,
|
|
} from '../lib/chat-query';
|
|
|
|
const SCANNERS = { name: 'EUV lithography scanners', kind: 'bottleneck' as const };
|
|
const ROWS = [
|
|
{ title: 'EUV lithography scanners', kind: 'bottleneck' as const },
|
|
{ title: 'ASML', kind: 'company' as const },
|
|
{ title: 'Netherlands', kind: 'country' as const },
|
|
];
|
|
|
|
test('"this company" on a material page resolves to the company that makes it', () => {
|
|
const asked =
|
|
"who owns this company is it a public company is a private company what's the history";
|
|
assert.equal(lookupSubject(asked, SCANNERS, ROWS), 'ASML');
|
|
assert.match(lookupQuery(asked, SCANNERS, ROWS), /^ASML /);
|
|
});
|
|
|
|
test('a question with no company in it still gets the page as its subject', () => {
|
|
const asked = 'what would relieve this';
|
|
assert.equal(lookupSubject(asked, SCANNERS, ROWS), 'EUV lithography scanners');
|
|
assert.match(lookupQuery(asked, SCANNERS, ROWS), /^EUV lithography scanners /);
|
|
});
|
|
|
|
test('a question that already names its subject is not prefixed', () => {
|
|
const asked = 'when did ASML buy Cymer';
|
|
assert.equal(lookupQuery(asked, SCANNERS, ROWS), asked);
|
|
// Case is not a different company.
|
|
assert.equal(lookupQuery('who owns asml', SCANNERS, ROWS), 'who owns asml');
|
|
});
|
|
|
|
test('with nothing retrieved and no page, the question is the query', () => {
|
|
assert.equal(lookupQuery('who makes gallium', undefined, []), 'who makes gallium');
|
|
});
|
|
|
|
test('politeness is dropped and long questions are cut on a word', () => {
|
|
assert.equal(condense(' Could you please tell me who owns it '), 'who owns it');
|
|
const long = condense(`who owns it ${'lithography '.repeat(40)}`);
|
|
assert.ok(long.length <= 180, 'query is bounded');
|
|
assert.doesNotMatch(long, /lithograp$/, 'cut on a word boundary, not mid-word');
|
|
});
|
|
|
|
test('a refusal is recognised however the model phrases it', () => {
|
|
for (const said of [
|
|
'Not in your data.',
|
|
'The records do not identify the owner of the scanner maker.',
|
|
'The corpus does not contain ownership information.',
|
|
'There is nothing in the records about this.',
|
|
'That is not covered in the corpus.',
|
|
]) {
|
|
assert.equal(saysNotInCorpus(said), true, `should count as a refusal: ${said}`);
|
|
}
|
|
});
|
|
|
|
test('an answer that used the corpus is not mistaken for a refusal', () => {
|
|
for (const said of [
|
|
'ASML is recorded as producing EUV lithography scanners [F2].',
|
|
'The records identify one producer, and the join is a directory join [F1].',
|
|
'Three suppliers are recorded, and the data covers all three [F1] [F2] [F3].',
|
|
]) {
|
|
assert.equal(saysNotInCorpus(said), false, `should not count as a refusal: ${said}`);
|
|
}
|
|
});
|
|
|
|
test('follow-ups are questions this assistant can answer, not instructions', () => {
|
|
const next = followUpsFor(ROWS);
|
|
assert.equal(next.length, 3);
|
|
for (const question of next) assert.match(question, /\?$/);
|
|
assert.ok(next.some((q) => q.includes('ASML')));
|
|
assert.equal(new Set(next).size, next.length, 'no repeats');
|
|
});
|