Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
},
"dependencies": {
"convex": "^1.39.1",
"geist": "^1.7.0",
"next": "16.2.12",
"react": "19.2.4",
"react-dom": "19.2.4",
"geist": "^1.7.2",
"next": "16.3.4",
"react": "19.2.8",
"react-dom": "19.2.8",
"react-markdown": "^10.1.0",
"remark-gfm": "^4.0.1"
},
"devDependencies": {
"@types/node": "^24.13.3",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react": "^19.2.18",
"@types/react-dom": "^19.2.7",
"eslint": "^9.39.5",
"eslint-config-next": "16.2.12",
"prettier": "^3.8.1",
"eslint-config-next": "16.3.4",
"prettier": "^3.9.6",
"typescript": "^6.0.3",
"vitest": "^4.1.11"
}
Expand Down
126 changes: 95 additions & 31 deletions apps/web/src/components/SearchPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function normalizeQuery(value: string): string {
}

function matchesNav(query: string, item: NavItem): boolean {
const haystack = [item.label, item.href, ...(item.keywords ?? [])].join(' ').toLowerCase();
const haystack = [item.label, item.href, ...(item.keywords ?? [])]
.join(' ')
.toLowerCase();
return query.split(' ').every((token) => !token || haystack.includes(token));
}

Expand All @@ -78,26 +80,27 @@ export function SearchPalette() {
const q = normalizeQuery(query);

useEffect(() => {
if (!open || q.length < 2) {
setEntries([]);
setSearching(false);
return;
}
if (!open || q.length < 2) return;

const controller = new AbortController();
setSearching(true);
const handle = window.setTimeout(async () => {
try {
const response = await fetch(`/api/v1/search?q=${encodeURIComponent(q)}`, {
signal: controller.signal,
});
const response = await fetch(
`/api/v1/search?q=${encodeURIComponent(q)}`,
{
signal: controller.signal,
},
);
if (!response.ok) throw new Error(`search ${response.status}`);
const body = (await response.json()) as { results?: EntryResult[] };
setEntries((body.results ?? []).slice(0, 8));
setActiveIndex(0);
setSearching(false);
} catch (error) {
if ((error as Error).name !== 'AbortError') {
setEntries([]);
setActiveIndex(0);
setSearching(false);
}
}
Expand All @@ -111,7 +114,12 @@ export function SearchPalette() {

const items = useMemo<PaletteItem[]>(() => {
if (!q) {
return NAV_ITEMS.map((item) => ({ kind: 'nav', id: item.id, label: item.label, href: item.href }));
return NAV_ITEMS.map((item) => ({
kind: 'nav',
id: item.id,
label: item.label,
href: item.href,
}));
}

const list: PaletteItem[] = [
Expand All @@ -121,11 +129,19 @@ export function SearchPalette() {
label: `Search for “${q}”`,
href: `/search?q=${encodeURIComponent(q)}`,
},
...entries.map(
(entry): PaletteItem => ({ kind: 'entry', id: `entry-${entry.id}`, href: entryHref(entry), entry }),
),
...entries.map((entry): PaletteItem => ({
kind: 'entry',
id: `entry-${entry.id}`,
href: entryHref(entry),
entry,
})),
...NAV_ITEMS.filter((item) => matchesNav(q, item)).map(
(item): PaletteItem => ({ kind: 'nav', id: item.id, label: item.label, href: item.href }),
(item): PaletteItem => ({
kind: 'nav',
id: item.id,
label: item.label,
href: item.href,
}),
),
];
return list;
Expand All @@ -134,28 +150,34 @@ export function SearchPalette() {
function close() {
setOpen(false);
setQuery('');
setEntries([]);
setSearching(false);
setActiveIndex(0);
triggerRef.current?.focus();
}

function openPalette() {
setQuery('');
setEntries([]);
setSearching(false);
setActiveIndex(0);
setOpen(true);
}

function updateQuery(value: string) {
const nextQuery = normalizeQuery(value);
setQuery(value);
if (nextQuery === q) return;
setEntries([]);
setSearching(nextQuery.length >= 2);
setActiveIndex(0);
}

function navigate(href: string) {
close();
router.push(href);
}

// Reset the selection whenever the option list changes — including when
// debounced results arrive — so Enter never fires on a shifted item.
useEffect(() => {
setActiveIndex(0);
}, [items]);

useEffect(() => {
function onKeyDown(e: KeyboardEvent) {
const key = e.key.toLowerCase();
Expand Down Expand Up @@ -243,9 +265,25 @@ export function SearchPalette() {
aria-expanded={open}
aria-label="Search"
>
<svg className={styles.triggerIcon} viewBox="0 0 24 24" fill="none" aria-hidden="true">
<circle cx="11" cy="11" r="6.5" stroke="currentColor" strokeWidth="1.6" />
<path d="m16 16 4.5 4.5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
<svg
className={styles.triggerIcon}
viewBox="0 0 24 24"
fill="none"
aria-hidden="true"
>
<circle
cx="11"
cy="11"
r="6.5"
stroke="currentColor"
strokeWidth="1.6"
/>
<path
d="m16 16 4.5 4.5"
stroke="currentColor"
strokeWidth="1.6"
strokeLinecap="round"
/>
</svg>
<span className={styles.triggerLabel}>Search…</span>
<kbd className={styles.triggerKbd} aria-hidden="true">
Expand All @@ -264,21 +302,39 @@ export function SearchPalette() {
onMouseDown={(e) => e.stopPropagation()}
>
<div className={styles.top}>
<svg className={styles.inputIcon} viewBox="0 0 24 24" fill="none" aria-hidden="true">
<circle cx="11" cy="11" r="6.5" stroke="currentColor" strokeWidth="1.6" />
<path d="m16 16 4.5 4.5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
<svg
className={styles.inputIcon}
viewBox="0 0 24 24"
fill="none"
aria-hidden="true"
>
<circle
cx="11"
cy="11"
r="6.5"
stroke="currentColor"
strokeWidth="1.6"
/>
<path
d="m16 16 4.5 4.5"
stroke="currentColor"
strokeWidth="1.6"
strokeLinecap="round"
/>
</svg>
<input
ref={inputRef}
className={styles.input}
value={query}
onChange={(e) => setQuery(e.target.value)}
onChange={(e) => updateQuery(e.target.value)}
placeholder="Search terms and acronyms…"
aria-label="Search terms and acronyms"
role="combobox"
aria-expanded="true"
aria-controls={listboxId}
aria-activedescendant={activeItem ? `${listboxId}-${activeItem.id}` : undefined}
aria-activedescendant={
activeItem ? `${listboxId}-${activeItem.id}` : undefined
}
autoCapitalize="none"
autoCorrect="off"
spellCheck={false}
Expand All @@ -292,7 +348,12 @@ export function SearchPalette() {
)}
</div>

<ul className={styles.list} id={listboxId} role="listbox" aria-label="Results">
<ul
className={styles.list}
id={listboxId}
role="listbox"
aria-label="Results"
>
{!q ? <li className={styles.groupLabel}>Go to</li> : null}
{items.map((item, idx) => (
<li
Expand All @@ -307,7 +368,9 @@ export function SearchPalette() {
{item.kind === 'entry' ? (
<span className={styles.entryItem}>
<span className={styles.entryTitleRow}>
<span className={styles.entryTitle}>{item.entry.displayTitle}</span>
<span className={styles.entryTitle}>
{item.entry.displayTitle}
</span>
<TypeMarker type={item.entry.entryType} />
</span>
{item.entry.snippet || item.entry.summaryText ? (
Expand All @@ -330,7 +393,8 @@ export function SearchPalette() {

{q && !searching && entries.length === 0 ? (
<div className={styles.empty}>
No entries match “{q}” yet. Press Enter for full-text search.
No entries match “{q}” yet. Press Enter for full-text
search.
</div>
) : null}
</div>
Expand Down
17 changes: 7 additions & 10 deletions experiments/tagging/production-backfill/local-review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ const rubric: Rubric = {
globalRules: ['Apply only when central.'],
contracts: [
contract,
...Array.from(
{ length: 10 },
(_value, index): Contract => ({
slug: `tag-${index}`,
name: `Tag ${index}`,
definition: `Definition ${index}`,
inclusionRules: [`Include ${index}`],
exclusionRules: [`Exclude ${index}`],
}),
),
...Array.from({ length: 10 }, (_value, index): Contract => ({
slug: `tag-${index}`,
name: `Tag ${index}`,
definition: `Definition ${index}`,
inclusionRules: [`Include ${index}`],
exclusionRules: [`Exclude ${index}`],
})),
],
};

Expand Down
11 changes: 1 addition & 10 deletions experiments/tagging/synthetic-reference/target-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,7 @@ import {
} from './validators.ts';

export type TargetLane =
| 'P1'
| 'P2'
| 'P3'
| 'P4'
| 'C+'
| 'C-'
| 'A1'
| 'A2'
| 'V1'
| 'V2';
'P1' | 'P2' | 'P3' | 'P4' | 'C+' | 'C-' | 'A1' | 'A2' | 'V1' | 'V2';
export type TargetPhase = 'primary' | 'critic' | 'arbiter' | 'verify';
export type TargetMirror = 'M1' | 'M2' | 'S1';
export type TargetVerdict = 'yes' | 'no' | 'abstain';
Expand Down
5 changes: 1 addition & 4 deletions experiments/tagging/synthetic-reference/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ export const TAG_IDS = [
export type TagId = (typeof TAG_IDS)[number];
export type Polarity = 'positive' | 'negative';
export type ReferenceSplit =
| 'development'
| 'calibration'
| 'validation'
| 'audit';
'development' | 'calibration' | 'validation' | 'audit';
export type SealedRole = 'primary' | 'critic' | 'arbiter' | 'auditor';

export type RubricRule = Readonly<{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"pnpm": {
"overrides": {
"@humanfs/node@<0.16.8": "^0.16.8",
"brace-expansion@<1.1.18": "^1.1.18",
"brace-expansion@>=2.0.0 <2.1.4": "^2.1.4",
"brace-expansion@>=5.0.0 <5.0.9": "^5.0.9",
Expand All @@ -53,7 +54,7 @@
"@types/node": "^24.13.3",
"convex-test": "^0.0.54",
"eslint": "^9.39.5",
"globals": "^17.3.0",
"globals": "^17.12.0",
"typescript": "^6.0.3",
"typescript-eslint": "^8.67.0",
"vitest": "^4.1.11"
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"devDependencies": {
"@types/node": "^24.13.3",
"eslint": "^9.39.5",
"prettier": "^3.8.1",
"prettier": "^3.9.6",
"typescript": "^6.0.3",
"vitest": "^4.1.11"
}
Expand Down
Loading
Loading