Files
pipelines/app/notes/X1-wire.md
T

112 lines
5.9 KiB
Markdown

# X1-wire — register Search in the shell and `/search`
## Scope
Wired the landed `SearchScreen` into the normal `PipelinesApp` composition. No
search internals, `features/pipelines`, `features/chat`, `features/graph`,
`features/artifacts`, server, web, Android or iOS files were changed.
## Behaviour
- The existing shell gains a native search action without a fifth tab:
Material `AppBar` `IconButton` (`tooltip: Search`) and Cupertino
`CupertinoNavigationBar` trailing button (`semanticLabel: Search`). The tab
set stays `Pipelines / Runs / Chat / Settings`.
- `AppRouteKind.search` with the total path `/search`. `/search/` normalises,
`/search/1` and other unknown paths still parse to `/pipelines`.
- Search is a transient full-screen dialog page above the shell (standard
Material close icon, Cupertino `Cancel`), so closing is a normal native
action and the shell below is never remounted. `openSearch` records the
previous route; Close, system Back (`popRoute`) and `onDidRemovePage` return
to it. Browser Back/Forward go through the ordinary Router history.
- Escape closes the page (the browser's search-panel shortcut) through
`CallbackShortcuts`.
- The field is focused on open. Material mounts the screen immediately;
the Cupertino page waits for its entrance to complete, because a focus
request during that transition is dropped (the landing screen was visibly
unfocused without this). A post-frame then mounts `SearchScreen`, whose
existing `autofocus` takes effect.
- Requests use the one shared `AppSession` gateway (`session.gateway`); the
screen and page open no socket. Before the first connection the destination
shows the existing native `ConnectionGate` in the same title bar.
- Results keep the screen's `onOpen` contract: the server hit map is passed
through unchanged. Only a run-family hit (`run.id`, or `step/field/artifact
.run_id`) is opened, through the existing `/runs/:id` route. No route is
invented for pipeline/version hits; those rows still call `onOpen` but this
app has no pipeline-detail route to open yet.
## Files
- `lib/application/app_route.dart` — search kind, path, parser branch.
- `lib/application/app_router.dart` — search page, open/close return route,
native dialog chrome, system Back, page-removal callback.
- `lib/application/pipelines_app.dart` — registration, Escape shortcut,
run-target passthrough, `onSearch` on the shell.
- `lib/application/search_destination.dart` (new) — connection gate, shared
gateway, Cupertino focus mount, `searchHitRunId`.
- `lib/shell/adaptive_shell.dart` — optional native search action.
- `test/application/app_route_test.dart` — `/search` parse/serialise/fallback.
- `test/application/search_wiring_test.dart` (new) — focus, close/state,
result routing, one socket, Cupertino close, hit helper, system Back.
- `tool/runs_probe_server.mjs` — additive `search` branch and
`searchRequests` fixture state (the Runs probe behaviour is unchanged).
- `tool/search_wiring_probe.mjs` (new) — real-browser acceptance driver.
## Checks
Run from `app/` with `/Users/alan/development/flutter/bin/flutter`:
- `flutter analyze` — **No issues found**.
- `flutter test` — **837 passed** (whole app suite).
- `flutter test test/application test/features/search test/widget_test.dart` —
**87 passed**.
- `flutter build web` (default `lib/main.dart`) — **succeeded**.
- `flutter build web -o build/search_wiring_web` — **succeeded** for the probe.
- `node --check tool/search_wiring_probe.mjs` and
`node --check tool/runs_probe_server.mjs` — passed.
- Probe exit 0. Evidence: both hosts opened `/search` with the field as the
focused browser `INPUT`; the exact request was
`{"query":"fixture","kind":"","limit":0}`; the run row opened `/runs/1`;
Escape returned to the same retained run detail with `getRun` unchanged (1);
browser Back returned to `/runs` with `listRuns` unchanged and the transient
page gone; the fixture saw `connections: 1` for the whole Material run; both
boots subscribed on the existing socket (`subscribed: 2`).
- Real Chrome (headless, CDP) against an isolated websocket fixture on an
OS-assigned loopback port; no production or operator data.
Captures (shared artifacts, both hosts, phone and desktop):
- `x1-wire/x1-wire-material-search-phone.png`
- `x1-wire/x1-wire-material-search-desktop.png`
- `x1-wire/x1-wire-material-run-from-search-phone.png`
- `x1-wire/x1-wire-material-escape-restored-phone.png`
- `x1-wire/x1-wire-cupertino-search-phone.png`
- `x1-wire/x1-wire-cupertino-search-desktop.png`
- `x1-wire/x1-wire-cupertino-back-restored-phone.png`
under `/Users/alan/.local/share/pipelines/data/artifacts/88/public/`.
## Not verified / remaining
- Pipeline and version hits do not navigate: no pipeline-detail route exists
in the app yet (PARITY target routing remains open). Step/field/artifact hits
open their run but not the recorded visit/sequence or field tab.
- Mobile targets were not built, installed or exercised; only Web was rendered.
The Cupertino focus handling is covered by widget tests and the macOS-UA web
probe, not an iOS device.
- Live authenticated production search was not exercised.
- No commit, push, deployment or canonical URL change was made.
## Manager completion after an infrastructure failure
This run ended with the server reporting `constraint failed: UNIQUE constraint
failed: step_file_changes.run_id, step_file_changes.sequence (1555)` — a server
persistence bug in file-change capture, not a fault in this slice. The same
failure hit the parallel run-graph slice. The retained edits were complete: the
manager ran the application suite (45 tests pass), inspected the route/shell
changes, and merged them. The server defect is recorded in WORK.md and is being
fixed with a regression on the server side; no retry of this app slice was needed.
Evidence for the wiring is the focused suite plus the real-app probe run after
landing; the server failure means this run's own stage evidence is incomplete.