port: search (approved mockup) #840

Closed
kayg wants to merge 0 commits from port/search into dev
Owner

Full port of the search palette (mockup apps/mockup/src/search/* on review/calendar-2)

The Composer stays the one field for search and create (C1/C3); the mockup's search surface is ported into it.

Mockup part Product now
Two-pane panel, 1120 px, results left, note preview inside the panel (S1, S3) ported (ComposerBody); the panel is 1120 px on desktop, body height min(620px, …)
Rows: icon tile, snippet, marked words, end date ported (date from the engine's updated_ms, which search.query already returns)
No empty frame between keys composer/hold.ts (160 ms), unit + e2e tests; Enter follows the rows for the words as typed, not the held ones
Preview = the note, typed words marked, ⌘G / ⇧⌘G, "n of m" stepper NotePreview.svelte (the note's own editor in preview mode) + hits.ts (CodeMirror decoration, text untouched)
⌘Enter inserts a link to the highlighted note into the open note ported (uses linkSelection)
Filter words → tokens (S7–S10) ported with packages/ui/src/search/words.ts (+ its tests, copied from the mockup branch). Tokens for what search.query answers: notes/journal, dates, #tags; "newest"/"oldest" re-order the returned hits.
Recent + Examples on an empty field ported (Recent = search(""), "used lately")
Pull to search (phone) pull.svelte.ts + PullHint.svelte, mounted on a phone only
Long-press preview popover (phone) PreviewPopover.svelte
Phone: hug content, on a spring, above the keyboard lib/hug.ts (mockup's, with a bottom anchor): the panel stands on the keyboard, the glass and words are clipped to the content
Hit marking/previews for days, tags, actions days are notes (Journal) and use the same preview; tags: a #tag row from the client's tag list opens the tag's list; actions = the Composer's command rows. No separate previews for tags/actions.

Backend

None needed. search.query already returns updated_ms and tags, and already takes tags, kinds, before, after, tz_offset_min. Only the TS types and the client call were widened. The server query path is untouched. The client asks for up to 30 hits on desktop (10 on a phone), a limit the action already takes.

Server changes still needed for what is NOT ported (nothing started):

  • photos / files as result kinds + their previews: providers for them in crates/search (no photos/files provider exists yet), then the kind tokens photos, files.
  • pinned and "in the Trash" filters: search.query has no pinned or trash filter. Today they stay plain words.
  • newest / oldest order: done on the client over the returned hits (not over the whole index); a server sort would make it exact.

Gates (exact)

  • svelte-check: 0 errors, 15 warnings (dev-01). vitest run in apps/web: 6 files pass (hold, marks, hits + existing); packages/ui src/search 34 pass.
  • Playwright CI=1 --retries=0 --workers=1: e2e/search-palette.spec.ts composer.spec.ts composer-open.spec.ts composer-tasks.spec.ts list-search.spec.ts trash-search.spec.ts
    • dev-01: chromium-1440 24 passed; chromium-390 39 passed.
    • dev-02: webkit-390 38 passed. webkit-1440: 22 passed, 2 failed once in the full run (composer.spec:51 and :185, a click timeout on a loaded host); both pass when run alone on webkit-1440. Not re-run as a full set.
  • search-corpus (every prefix, full word, one- and two-letter typos, accents): chromium-1440 earlier green; WebKit (CORPUS_PROJECT=webkit-1440): 1492 queries, 0 missed, p50 0.9 ms, p95 4.2 ms.
  • The new specs cover: snippet row + date, preview follows ↓, marks + ⌘G, ⌘Enter link, tokens (and tap back), examples, no empty frame, phone foot/hug, long-press popover, pull (Chromium only: WebKit can't build a Touch).

Bundle (gzip, vite build, base = origin/dev 55f35fcd)

  • first paint (index.html's JS+CSS): base 306 KB → 308 KB (+2 KB: the pull-hint gate in App.svelte).
  • total JS+CSS: 450 KB → 462 KB (+12 KB). Palette chunk 13 → 21 KB. The preview editor and hit marking load when the first note result is shown, not with the palette.

Screenshots

~/Developer/Worktrees/shots/port-search/ on code: {mockup,product}-{1440,390}-{1-empty,2-typing,3-results,4-token}.png. (Product at 1440 is a 3-note home; the mockup's has 35 notes.)

Not the same as the mockup, on purpose

  • Phone: the Composer's field sits at the foot on the keyboard (approved Composer design) instead of the mockup search's field at the top.
  • The kind line ("Open · …") under the field is the Composer's.
  • Desktop panel is anchored at 12vh as the Composer was, not vertically centred.

Not done / risks

  • No frame/rAF measurement (Mac VM) of the hug spring, pull gesture or preview swap. Typing path: readFilters runs per key only when the text has a space or #; not measured. Needs a perf-gate run before a train.
  • Typo-corrected words (server forgives "canl") are not marked in the preview: marks are for the words as typed.
  • Real-iOS checks needed: pull gesture, long-press, hug with the keyboard.
  • ComposerBody.svelte is now ~1090 lines; splitting it (results list, field, kind line) is the next cleanup.

Round 2 (review of the first shots)

  • Shots: the first mockup captures were blank (the mockup's public/fonts were not copied, so its app never mounted). Retaken with a check that the Search dialog and its rows exist before a shot is saved; all 16 opened and compared. ~/Developer/Worktrees/shots/port-search/ on code.
  • Result rows: the 2nd line is the body line around the match; for a title-only hit (or an engine snippet that is just the title again) it is the body's first line, read from the note's text (lib/peek.ts) a beat after the rows (composer/snippets.ts, unit-tested). No server change.
  • Preview: it is the note's own page now (.page + the editor's preview mode): the title is the H1 at the note's scale, same body type and spacing. Hit marks are the mockup's exactly: every hit --accent-soft + 1.5 px soft ring, the current one --accent with --accent-ink text.
  • Glass: the palette uses the shared <Glass dense> (same backdrop-filter as the bar, sheets and menus; asserted in search-palette.spec.ts), and no ancestor is a backdrop root (also asserted). The phone's open animation moved from the panel wrapper (a transform/opacity there made it a backdrop root) to the glass, the shadow and the words one by one, as the mockup does. One thing is NOT solved: in Chromium, the selected row of the list behind the panel stays faintly legible through it, while the other rows are blurred away; hiding the glass shows the row sharp, changing the blur to 60 px does not change it. Tried without effect: no isolation, no z-index, no translate, position absolute, panel moved to <body>, the panes' own backdrop-filter removed, scrim removed. In Playwright's WebKit on Linux nothing under the panel is blurred (glass.css notes it paints no blur there). Not fixed with an opaque override. Needs a look on a real Mac/iPhone.
  • 10 → 30 hits (server took_ms, dev-01, shared host, CORPUS_LIMIT): on the 1,492-query corpus (41 notes, so the limit rarely binds): limit 10 p95 7.6 / 6.3 / 6.0 ms, limit 30 p95 6.3 / 9.5 / 5.9 ms (p50 1.2–1.3 ms both). With a Home where every query has >30 matches (300 notes; CORPUS_MANY=1, 3 runs of 120 queries per limit, alternating): limit 10 p50 5.2 / 4.5 / 5.0, p95 14.7 / 12.7 / 12.1; limit 30 p50 6.3 / 5.4 / 6.0, p95 17.6 / 10.8 / 13.1 ms. p95 median 12.7 → 13.1 ms: flat inside the noise; p50 is ~+1 ms (+20 %). Kept 30 on a desktop, 10 on a phone. A shared dev VM, not a perf VM.
  • Filter reader per key (apps/web/scripts/bench-filters.ts, 70,200 keys over six phrases, dev-01): mean 28 µs, p50 17 µs, p95 51 µs, p99 108 µs (max 36 ms is one GC/JIT outlier). Only keys on text with a space or # pay it.
  • Split: ComposerBody.svelte 1,088 → 507 lines. New: search-state.svelte.ts (filters + results pipeline), maker.svelte.ts (make/undo), KindLine, ResultsList, FilterTokens, kinds.ts. Behaviour unchanged (same specs pass).
  • Bundle (gzip): first paint 306 → 308 KB; total 450 → 464 KB; Palette chunk 13 → 22 KB.
  • webkit-1440 composer failures: after the first full run (2 click timeouts), two further full runs on webkit-1440: one had 1 failure (composer-tasks:48, journal text within 25 s; passes alone), the last had none. Flaky under load on the shared dev-02, not reproduced as a code failure.
## Full port of the search palette (mockup `apps/mockup/src/search/*` on review/calendar-2) The Composer stays the one field for search and create (C1/C3); the mockup's search surface is ported into it. | Mockup part | Product now | |---|---| | Two-pane panel, 1120 px, results left, note preview inside the panel (S1, S3) | ported (`ComposerBody`); the panel is 1120 px on desktop, body height `min(620px, …)` | | Rows: icon tile, snippet, marked words, end date | ported (date from the engine's `updated_ms`, which `search.query` already returns) | | No empty frame between keys | `composer/hold.ts` (160 ms), unit + e2e tests; Enter follows the rows for the words as typed, not the held ones | | Preview = the note, typed words marked, ⌘G / ⇧⌘G, "n of m" stepper | `NotePreview.svelte` (the note's own editor in preview mode) + `hits.ts` (CodeMirror decoration, text untouched) | | ⌘Enter inserts a link to the highlighted note into the open note | ported (uses `linkSelection`) | | Filter words → tokens (S7–S10) | ported with `packages/ui/src/search/words.ts` (+ its tests, copied from the mockup branch). Tokens for what `search.query` answers: notes/journal, dates, #tags; "newest"/"oldest" re-order the returned hits. | | Recent + Examples on an empty field | ported (Recent = `search("")`, "used lately") | | Pull to search (phone) | `pull.svelte.ts` + `PullHint.svelte`, mounted on a phone only | | Long-press preview popover (phone) | `PreviewPopover.svelte` | | Phone: hug content, on a spring, above the keyboard | `lib/hug.ts` (mockup's, with a bottom anchor): the panel stands on the keyboard, the glass and words are clipped to the content | | Hit marking/previews for days, tags, actions | days are notes (Journal) and use the same preview; tags: a `#tag` row from the client's tag list opens the tag's list; actions = the Composer's command rows. No separate previews for tags/actions. | ## Backend None needed. `search.query` already returns `updated_ms` and `tags`, and already takes `tags`, `kinds`, `before`, `after`, `tz_offset_min`. Only the TS types and the client call were widened. The server query path is untouched. The client asks for up to 30 hits on desktop (10 on a phone), a `limit` the action already takes. Server changes still needed for what is NOT ported (nothing started): - photos / files as result kinds + their previews: providers for them in `crates/search` (no photos/files provider exists yet), then the kind tokens `photos`, `files`. - `pinned` and "in the Trash" filters: `search.query` has no `pinned` or trash filter. Today they stay plain words. - `newest` / `oldest` order: done on the client over the returned hits (not over the whole index); a server `sort` would make it exact. ## Gates (exact) - `svelte-check`: 0 errors, 15 warnings (dev-01). `vitest run` in `apps/web`: 6 files pass (hold, marks, hits + existing); `packages/ui` `src/search` 34 pass. - Playwright `CI=1 --retries=0 --workers=1`: `e2e/search-palette.spec.ts composer.spec.ts composer-open.spec.ts composer-tasks.spec.ts list-search.spec.ts trash-search.spec.ts` - dev-01: chromium-1440 24 passed; chromium-390 39 passed. - dev-02: webkit-390 38 passed. webkit-1440: 22 passed, 2 failed once in the full run (composer.spec:51 and :185, a click timeout on a loaded host); both pass when run alone on webkit-1440. Not re-run as a full set. - search-corpus (every prefix, full word, one- and two-letter typos, accents): chromium-1440 earlier green; **WebKit** (`CORPUS_PROJECT=webkit-1440`): 1492 queries, 0 missed, p50 0.9 ms, p95 4.2 ms. - The new specs cover: snippet row + date, preview follows ↓, marks + ⌘G, ⌘Enter link, tokens (and tap back), examples, no empty frame, phone foot/hug, long-press popover, pull (Chromium only: WebKit can't build a `Touch`). ## Bundle (gzip, `vite build`, base = origin/dev 55f35fcd) - first paint (index.html's JS+CSS): base 306 KB → 308 KB (+2 KB: the pull-hint gate in App.svelte). - total JS+CSS: 450 KB → 462 KB (+12 KB). Palette chunk 13 → 21 KB. The preview editor and hit marking load when the first note result is shown, not with the palette. ## Screenshots `~/Developer/Worktrees/shots/port-search/` on `code`: `{mockup,product}-{1440,390}-{1-empty,2-typing,3-results,4-token}.png`. (Product at 1440 is a 3-note home; the mockup's has 35 notes.) ## Not the same as the mockup, on purpose - Phone: the Composer's field sits at the foot on the keyboard (approved Composer design) instead of the mockup search's field at the top. - The kind line ("Open · …") under the field is the Composer's. - Desktop panel is anchored at 12vh as the Composer was, not vertically centred. ## Not done / risks - No frame/rAF measurement (Mac VM) of the hug spring, pull gesture or preview swap. Typing path: `readFilters` runs per key only when the text has a space or `#`; not measured. Needs a perf-gate run before a train. - Typo-corrected words (server forgives "canl") are not marked in the preview: marks are for the words as typed. - Real-iOS checks needed: pull gesture, long-press, hug with the keyboard. - `ComposerBody.svelte` is now ~1090 lines; splitting it (results list, field, kind line) is the next cleanup. --- ## Round 2 (review of the first shots) - **Shots**: the first mockup captures were blank (the mockup's `public/fonts` were not copied, so its app never mounted). Retaken with a check that the Search dialog and its rows exist before a shot is saved; all 16 opened and compared. `~/Developer/Worktrees/shots/port-search/` on `code`. - **Result rows**: the 2nd line is the body line around the match; for a title-only hit (or an engine snippet that is just the title again) it is the body's first line, read from the note's text (`lib/peek.ts`) a beat after the rows (`composer/snippets.ts`, unit-tested). No server change. - **Preview**: it is the note's own page now (`.page` + the editor's preview mode): the title is the H1 at the note's scale, same body type and spacing. Hit marks are the mockup's exactly: every hit `--accent-soft` + 1.5 px soft ring, the current one `--accent` with `--accent-ink` text. - **Glass**: the palette uses the shared `<Glass dense>` (same `backdrop-filter` as the bar, sheets and menus; asserted in `search-palette.spec.ts`), and no ancestor is a backdrop root (also asserted). The phone's open animation moved from the panel wrapper (a transform/opacity there made it a backdrop root) to the glass, the shadow and the words one by one, as the mockup does. One thing is NOT solved: in Chromium, the selected row of the list behind the panel stays faintly legible through it, while the other rows are blurred away; hiding the glass shows the row sharp, changing the blur to 60 px does not change it. Tried without effect: no isolation, no z-index, no translate, position absolute, panel moved to `<body>`, the panes' own backdrop-filter removed, scrim removed. In Playwright's WebKit on Linux nothing under the panel is blurred (glass.css notes it paints no blur there). Not fixed with an opaque override. Needs a look on a real Mac/iPhone. - **10 → 30 hits** (server `took_ms`, dev-01, shared host, `CORPUS_LIMIT`): on the 1,492-query corpus (41 notes, so the limit rarely binds): limit 10 p95 7.6 / 6.3 / 6.0 ms, limit 30 p95 6.3 / 9.5 / 5.9 ms (p50 1.2–1.3 ms both). With a Home where every query has >30 matches (300 notes; `CORPUS_MANY=1`, 3 runs of 120 queries per limit, alternating): limit 10 p50 5.2 / 4.5 / 5.0, p95 14.7 / 12.7 / 12.1; limit 30 p50 6.3 / 5.4 / 6.0, p95 17.6 / 10.8 / 13.1 ms. p95 median 12.7 → 13.1 ms: flat inside the noise; p50 is ~+1 ms (+20 %). Kept 30 on a desktop, 10 on a phone. A shared dev VM, not a perf VM. - **Filter reader per key** (`apps/web/scripts/bench-filters.ts`, 70,200 keys over six phrases, dev-01): mean 28 µs, p50 17 µs, p95 51 µs, p99 108 µs (max 36 ms is one GC/JIT outlier). Only keys on text with a space or `#` pay it. - **Split**: `ComposerBody.svelte` 1,088 → 507 lines. New: `search-state.svelte.ts` (filters + results pipeline), `maker.svelte.ts` (make/undo), `KindLine`, `ResultsList`, `FilterTokens`, `kinds.ts`. Behaviour unchanged (same specs pass). - **Bundle** (gzip): first paint 306 → 308 KB; total 450 → 464 KB; Palette chunk 13 → 22 KB. - **webkit-1440 composer failures**: after the first full run (2 click timeouts), two further full runs on webkit-1440: one had 1 failure (composer-tasks:48, journal text within 25 s; passes alone), the last had none. Flaky under load on the shared dev-02, not reproduced as a code failure.
search-palette spec: wait for the index
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
6752e18329
Author
Owner

Closing: head 5de79c18 is already in dev (reached via e2272a5e); nothing left to merge. Branch kept.

Closing: head 5de79c18 is already in dev (reached via e2272a5e); nothing left to merge. Branch kept.
kayg closed this pull request 2026-11-04 13:04:58 +00:00
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!840
No description provided.