Merge branch 'main' into flutter/chat-messages
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# C2 — Chat thread controller
|
||||
|
||||
Manager integration follow-up: exposes subscribed/subscriptionError separately
|
||||
from history errors, so readable stored history cannot hide a refused live watch.
|
||||
Resync marks history loading while retaining the current transcript. A focused
|
||||
regression covers refused subscribe + successful history, then successful resync.
|
||||
The controller does not claim to fold form events; those are a separate UI slice.
|
||||
|
||||
`lib/features/chat/conversation/chat_thread_controller.dart` owns one open
|
||||
conversation without any UI. It is constructed with the shared `ApiGateway` and
|
||||
one `sessionId`, reuses `ChatRepository` for the wire and
|
||||
`domain/chat_transcript.dart` for the fold, and exposes `messages`, `running`,
|
||||
`loaded`, `loading`, `hasMore`, `cursor` and `error` through
|
||||
`ChangeNotifier`.
|
||||
|
||||
Behaviour:
|
||||
|
||||
- `load()` calls `chat_subscribe` with the exact session body, then reads the
|
||||
newest `chat_messages` page with `limit: 200` and an empty cursor. A refused
|
||||
subscribe leaves history usable.
|
||||
- `loadOlder()` is explicit only, requires `hasMore`, passes the server's opaque
|
||||
`next_cursor` back verbatim, and prepends the older page by id.
|
||||
- Only `chat_event` envelopes for this session are folded; replayed/live
|
||||
text, reasoning, tool, step and user frames use the existing domain fold, so
|
||||
unknown message and part fields survive.
|
||||
- `resync()` settles the held turn, re-subscribes, then replaces the transcript,
|
||||
cursor and `hasMore` with the newest authoritative page. Activity replayed
|
||||
while re-attaching (for example a running step) survives the replacement. A
|
||||
pushed `resync` event invokes the same path.
|
||||
- History failures set `error` and keep the held transcript; they are never
|
||||
reported as an empty success. Superseded reads and replies after disposal are
|
||||
ignored.
|
||||
- Disposal cancels only the local stream subscription. There is no
|
||||
`chat_unsubscribe` request.
|
||||
|
||||
Checks (run from `app/`):
|
||||
|
||||
- `flutter test test/features/chat/conversation` — 10 tests passed.
|
||||
- `flutter test test/features/chat` — 43 tests passed.
|
||||
- `flutter analyze lib/features/chat test/features/chat` — no issues.
|
||||
|
||||
Not done: the controller is not yet wired to a screen, so there is no rendered
|
||||
or browser change to capture; mobile builds and device verification were not
|
||||
performed. No shared domain, shell, main, pubspec or server files changed.
|
||||
@@ -0,0 +1,174 @@
|
||||
# P1 wire — Pipelines destination on the shared session
|
||||
|
||||
## Implemented
|
||||
|
||||
- `lib/application/pipelines_destination.dart` registers the landed
|
||||
`PipelinesScreen` on the existing `/pipelines` route through `AppSession`.
|
||||
It reuses the session's single socket and gateway; no second connection,
|
||||
fake rows or hidden request path was added.
|
||||
- Before the first accepted connection the destination mounts no screen and
|
||||
sends no `list_pipelines`, `list_runs` or `get_pipeline`. The full gate says
|
||||
`Connecting to Pipelines…` or `Pipelines server unavailable`, with an
|
||||
explicit native `Retry` and the existing missing-endpoint explanation.
|
||||
- After the first connection the screen stays mounted through drops. A
|
||||
status banner reports `Reconnecting to Pipelines…`; a reconnect advances
|
||||
`syncToken`, and `PipelinesScreen.didUpdateWidget` calls the existing
|
||||
`controller.load()` so the list and the selected detail refresh in place.
|
||||
Selection (pipeline id and requested version) is preserved; there is no
|
||||
remount and no return to the empty list.
|
||||
- `PipelinesScreen` gained `embedded` and `syncToken`. Embedded mode skips its
|
||||
own Material `Scaffold`/`AppBar` or Cupertino `CupertinoPageScaffold`/
|
||||
`CupertinoNavigationBar`, because the shell already owns the single bar.
|
||||
A native refresh action stays in the content (`IconButton`/`CupertinoButton`
|
||||
with the same `Refresh` wording), using the real host selection.
|
||||
- The connection gate and banner moved verbatim from `runs_destination.dart`
|
||||
to `lib/application/connection_status.dart`, so Runs and Pipelines share one
|
||||
implementation and one wording. Runs behavior is unchanged.
|
||||
- Registration is a tiny entry in the existing `destinationBodies` map in
|
||||
`lib/application/pipelines_app.dart`.
|
||||
- No graph rendering, actions, templates, schedules, route expansion, native
|
||||
control replacement, fixed component size/font/colour override, server,
|
||||
web, legacy, Android or pubspec change was made. Graph still shows
|
||||
`Graph rendering is pending (P2).`
|
||||
|
||||
## Files
|
||||
|
||||
Production:
|
||||
|
||||
- `lib/application/connection_status.dart` (new, moved shared chrome)
|
||||
- `lib/application/pipelines_destination.dart` (new)
|
||||
- `lib/application/pipelines_app.dart` (registration and import)
|
||||
- `lib/application/runs_destination.dart` (uses the shared chrome)
|
||||
- `lib/features/pipelines/screen.dart` (embedded framing, content refresh,
|
||||
reconnect sync token)
|
||||
|
||||
Tests:
|
||||
|
||||
- `test/application/pipelines_destination_test.dart` (new)
|
||||
- `test/application/pipelines_registration_test.dart` (new)
|
||||
- `test/application/pipelines_replies.dart` (new serialized reply helper)
|
||||
- `test/application/pipelines_app_test.dart` (route now renders the real list)
|
||||
- `test/application/settings_registration_test.dart` (answers the mounted
|
||||
Pipelines reads before visiting Settings)
|
||||
- `test/features/pipelines/pipelines_screen_test.dart` (embedded framing and
|
||||
content refresh)
|
||||
|
||||
Browser tooling (isolated, pure loopback fixtures):
|
||||
|
||||
- `tool/pipelines_wiring_probe_entry.dart` — exact `runPipelinesApp()`
|
||||
composition
|
||||
- `tool/pipelines_wiring_probe_server.mjs` — static bundle plus loopback
|
||||
websocket fixture with drop/refuse/accept/state endpoints
|
||||
- `tool/pipelines_wiring_probe.mjs` — real Chrome DevTools probe
|
||||
|
||||
## Checks actually run
|
||||
|
||||
| Check | Result |
|
||||
| --- | --- |
|
||||
| `flutter analyze` | `No issues found!` |
|
||||
| `flutter test` | **595 passed** |
|
||||
| `flutter test test/application` | **33 passed** |
|
||||
| `flutter test test/features/pipelines` | **49 passed** |
|
||||
| `flutter test test/features/pipelines/pipelines_screen_test.dart` | **6 passed** |
|
||||
| `dart format --output=none --set-exit-if-changed lib test tool/pipelines_wiring_probe_entry.dart` | 273 files, 0 changed |
|
||||
| `node --check` on both probe scripts | passed |
|
||||
| `flutter build web` (default `lib/main.dart`) | `✓ Built build/web` |
|
||||
| `flutter build web -t tool/pipelines_wiring_probe_entry.dart` | `✓ Built` |
|
||||
| `node tool/pipelines_wiring_probe.mjs <build> <captures>` | exit 0, 25 checks, 9 captures, `probe.json` has no error |
|
||||
|
||||
Coverage added:
|
||||
|
||||
- missing native endpoint never opens a socket;
|
||||
- connecting gate sends no list request; the screen mounts only after the
|
||||
shared socket accepts;
|
||||
- refused first connection is friendly, names no transport exception and
|
||||
offers Retry;
|
||||
- a drop retains the loaded rows and detail, then reconnect re-reads list and
|
||||
the open detail without losing the selected row;
|
||||
- the registered `/pipelines` route renders real rows, detail content hash and
|
||||
source with exactly one Material or Cupertino bar, one socket;
|
||||
- Cupertino host builds no `Material` widget;
|
||||
- embedded framing adds no second bar and keeps a working content Refresh.
|
||||
|
||||
## Browser evidence (real Chrome, normal composition)
|
||||
|
||||
Directory: `/Users/alan/.local/share/pipelines/data/artifacts/69/public/p1-wire-captures`
|
||||
|
||||
- `01-gate-refused-material.png` — first connection refused: honest gate,
|
||||
`Retry`, shell nav present, zero list requests recorded by the fixture.
|
||||
- `02-list-material.png` — Material shell below its single bar with the real
|
||||
`Release verification` / `Nightly documentation` rows.
|
||||
- `03-detail-material.png` — selected pipeline Summary with
|
||||
`sha256:fixture-3-v3`, versions and metadata.
|
||||
- `04-source-material.png` — Source tab with the real fixture source text.
|
||||
- `05-drop-detail-retained-material.png` — socket dropped: `Reconnecting to
|
||||
Pipelines…` banner while the open detail stays visible at `/pipelines`.
|
||||
- `06-reconnect-detail-refreshed-material.png` — after Retry: banner gone,
|
||||
list and open detail re-read (fixture counters advanced for `list_pipelines`
|
||||
and `get_pipeline`), same selection.
|
||||
- `07-list-cupertino-dark.png` — macOS/dark host: Cupertino global bar and tab
|
||||
bar, inset grouped rows, `Release verification` present.
|
||||
- `08-detail-cupertino-dark.png` — Cupertino dark detail with content hash,
|
||||
versions and native segmented tabs.
|
||||
- `09-source-cupertino-dark.png` — Cupertino dark Source with source text.
|
||||
- `probe.json` — fixture URL, 25 checks, captures and final counters.
|
||||
|
||||
The probe starts the fixture with websocket upgrades refused, asserts the gate
|
||||
and that `listPipelines`, `listRuns` and `getPipeline` are all 0, then accepts
|
||||
and drives the normal app. Hosts are selected through the browser platform
|
||||
user agent (Linux for Material, macOS for Cupertino), which is what the normal
|
||||
composition reads. OCR asserts the real row, content hash and source; the
|
||||
captures were inspected to confirm one bar and Cupertino dark styling.
|
||||
|
||||
Reproduce:
|
||||
|
||||
```sh
|
||||
flutter build web -t tool/pipelines_wiring_probe_entry.dart -o <build>
|
||||
node tool/pipelines_wiring_probe.mjs <build> <capture-dir>
|
||||
```
|
||||
|
||||
## Explicitly not done / unverified
|
||||
|
||||
- Graph rendering and graph nodes/edges remain P2; the existing pending notice
|
||||
is unchanged.
|
||||
- No action, template, schedule, route expansion or navigation redesign.
|
||||
- No production server, real operator chat/run or authenticated preview was
|
||||
touched; all browser data comes from the isolated loopback fixture.
|
||||
- Android and iOS were not built, installed or run; mobile remains unverified.
|
||||
- No push, deployment or preview-service change was made. The Land stage
|
||||
committed the reviewed candidate on `flutter/p1-wire` and merged `main`
|
||||
into it (see Landing below).
|
||||
- No Material/Cupertino fixed sizes, palette or font overrides were added.
|
||||
The only fixed breakpoint remains the existing `kPipelinesWideBreakpoint`.
|
||||
|
||||
## Diff
|
||||
|
||||
Tracked changes (`git diff --numstat`):
|
||||
|
||||
```
|
||||
3 0 app/lib/application/pipelines_app.dart
|
||||
4 184 app/lib/application/runs_destination.dart
|
||||
57 16 app/lib/features/pipelines/screen.dart
|
||||
26 5 app/test/application/pipelines_app_test.dart
|
||||
3 0 app/test/application/settings_registration_test.dart
|
||||
26 0 app/test/features/pipelines/pipelines_screen_test.dart
|
||||
```
|
||||
|
||||
New files: `connection_status.dart` (195), `pipelines_destination.dart` (61),
|
||||
three test files and three probe files. Net production change is ~120 added
|
||||
lines after moving the shared chrome out of `runs_destination.dart`.
|
||||
|
||||
## Landing
|
||||
|
||||
- Committed the reviewed work as `8476cfd7 feat(app): wire the native
|
||||
pipelines browser on the shared session` (15 paths, no unrelated files).
|
||||
- Merged local `main` (`7be4456f`) into `flutter/p1-wire` with no conflicts;
|
||||
the merge brought in the native run rename work only (`app/WORK.md`,
|
||||
`lib/features/runs/**`, `notes/R2-title-wire.md`, its tests and probe).
|
||||
- Post-merge checks on the merged candidate: `flutter analyze` clean,
|
||||
`flutter test` **599 passed**, `dart format` 274 files 0 changed,
|
||||
`node --check` on both probe scripts, `flutter build web` built, and the
|
||||
Chrome wiring probe again reported **25 checks, 9 captures**, no error,
|
||||
final `{subscribed:3, listPipelines:3, listRuns:3, getPipeline:3,
|
||||
dropped:1, connections:1}`. The 595 in the table above is the pre-merge
|
||||
branch count; the extra 4 tests are the merged rename coverage.
|
||||
@@ -0,0 +1,23 @@
|
||||
# Cancel from the actual run detail
|
||||
|
||||
The loaded detail's native action row reuses CancelRunAction alongside Rename.
|
||||
No new confirmation or protocol implementation: Keep sends nothing, only Confirm
|
||||
sends the exact run_id, and no canceled state appears before server acceptance.
|
||||
The accepted run detail now folds lifecycle fields into the held list row as well
|
||||
as the detail (the previous title-only update was insufficient for Cancel).
|
||||
Detail-only payloads are not duplicated into the summary list; pending old detail
|
||||
refreshes are invalidated after acceptance. Foreign run replies cannot replace
|
||||
the open detail. Native controls still own sizing and appearance.
|
||||
|
||||
## Actual checks
|
||||
|
||||
- New normal-screen Material/Cupertino tests failed before registration, then
|
||||
passed: Keep/no request, Confirm exact id, delayed accepted canceled state,
|
||||
action disappears, Back shows canceled list row.
|
||||
- 601 integrated tests pass; analyzer and normal web build pass.
|
||||
- Normal-app real Chrome fixture probe passes23 captures, including Cupertino
|
||||
confirm/Keep, Material confirm and accepted detail/list. The fixture records
|
||||
exactly one cancel_run for its own synthetic run4. No real run was canceled.
|
||||
- Fresh Cupertino-confirm and Material-accepted PNGs inspected in approved
|
||||
temp/cancel-wired-browser. Existing history/reconnect/Settings checks pass too.
|
||||
- Mobile and authenticated production mutations remain unverified.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Recorded human decisions in run detail
|
||||
|
||||
RunDecisionNotice reuses pendingDecision and HumanDecisionAction. A standard
|
||||
Material card or Cupertino section names the recorded checkpoint and offers
|
||||
Decide. The existing native prompt owns option/feedback/confirmation/refusal
|
||||
semantics; export/resource waits do not become invented human checkpoints.
|
||||
Accepted server detail flows through the same lifecycle/list update as Cancel.
|
||||
|
||||
New actual-screen tests failed before wiring and now pass on both hosts: recorded
|
||||
instructions, selection sends nothing, exact run/stage/option and trimmed feedback
|
||||
only on confirmation, accepted result removes the card. Integrated614 tests pass;
|
||||
analysis and normal web build are clean.
|
||||
|
||||
Real normal-app browser fixture passes28 captures, including actual Cupertino
|
||||
waiting card and prompt, Material card/prompt/accepted result, Cancel/Keep and
|
||||
the existing history/reconnect/Settings checks. The fixture records one exact
|
||||
decide_run for its synthetic run5; opening/Cancel send nothing. Card and prompt
|
||||
PNGs inspected in approved temp/decision-wired-browser. No production decision
|
||||
was answered; mobile and live authenticated mutations remain unverified.
|
||||
@@ -0,0 +1,140 @@
|
||||
# S1-draft — pure saved-schedule editor draft and validation
|
||||
|
||||
Manager integration guard: invalid pipeline IDs and edited records without a
|
||||
positive exact server identity/revision cannot build save payloads. This prevents
|
||||
a malformed/historical edit from becoming a create or bypassing CAS. Three new
|
||||
regressions failed against the original draft and pass after the fail-closed
|
||||
guard. The original snapshot remains unchanged; no production save was tested.
|
||||
|
||||
## What changed
|
||||
|
||||
New files only; no existing feature, shell, transport, `main` or pubspec source
|
||||
edited:
|
||||
|
||||
| File | Lines | Responsibility |
|
||||
| --- | --- | --- |
|
||||
| `lib/features/schedules/domain/editor/schedule_draft.dart` | 210 | mutable editor draft over `SavedSchedule`/`ScheduleRule`, web-mirrored validation, `save_schedule` record assembly |
|
||||
| `test/features/schedules/domain/editor/draft_fixtures.dart` | 42 | shared server-record fixture and deep-copy helper |
|
||||
| `test/features/schedules/domain/editor/schedule_draft_test.dart` | 134 | create/edit record assembly, CAS, unknown fields, workspace, source immutability |
|
||||
| `test/features/schedules/domain/editor/schedule_draft_validation_test.dart` | 130 | timer/day/timezone/core field validation and invalid-field behavior |
|
||||
|
||||
The production file is one cohesive file (below the 220-line slice budget) and
|
||||
keeps the existing domain pattern: `SavedSchedule` and `ScheduleRule` are
|
||||
read-only views, `ScheduleDraft` is the separate editable state. Tests are split
|
||||
by responsibility (record assembly vs. validation) so neither file exceeds the
|
||||
working agreement's ~250-line aim.
|
||||
|
||||
## Review fix — workspace is now written into the record
|
||||
|
||||
Review visit 1 found that `build()` validated `workspace` but never wrote it, so
|
||||
creates were refused by `save_schedule` and workspace edits were dropped. The
|
||||
fix writes `record['workspace'] = workspace;` beside `name`/`version`/`enabled`,
|
||||
untrimmed to match `workspace: draft.workspace` in `web/src/schedules.js`
|
||||
(validation also runs on the untrimmed value). Direct probe against the real
|
||||
classes:
|
||||
|
||||
```
|
||||
create keys: enabled, id, input, name, notify_mode, pipeline_id, rule, version, workspace
|
||||
create: {"id":0,...,"workspace":"/srv","rule":{"every":"24h","timezone":"UTC"},"notify_mode":"auto"}
|
||||
edit workspace: /new (source /old)
|
||||
edit revision: 13
|
||||
```
|
||||
|
||||
New assertions cover the create record, an unchanged edit, a changed edit and
|
||||
the untrimmed value.
|
||||
|
||||
## Behavior copied from `web/src/schedules.js`
|
||||
|
||||
`ScheduleDraft.build()` returns `ScheduleSaveResult(null, errors)` while any
|
||||
field is invalid, so an invalid draft cannot yield a save payload. Errors are a
|
||||
field-name → message map using the web editor's exact words:
|
||||
|
||||
- name `Enter a schedule name.` (stored trimmed, as the web record is)
|
||||
- prompt `Enter a prompt.` (stored untrimmed)
|
||||
- pinned version: digits only, safe integer, at least 1 — `Choose a positive
|
||||
pinned version, not latest (0).`
|
||||
- workspace must start with `/` and contain no NUL/CR/LF — `Enter an absolute
|
||||
workspace path on the server.`
|
||||
- interval is Go-style compound duration (`24h`, `1h30m`, `.5h`, `1.5m`) whose
|
||||
matched text covers the whole value and totals at least one minute —
|
||||
`Interval must be at least 1m (for example 24h or 1h30m).`
|
||||
- clock times are comma-separated, trimmed, distinct `HH:mm` in 00:00–23:59 —
|
||||
`Enter distinct 24-hour times, such as 09:00, 17:30.`
|
||||
- weekday keys must be distinct values from `scheduleDays` —
|
||||
`Choose valid, distinct weekdays.`
|
||||
- notification mode is `auto`, `on` or `off` — `Choose a notification mode.`
|
||||
- timezone is blank, `Local`, a known single-zone alias or a well-formed
|
||||
`Area/Location` — `Enter a valid IANA timezone.`
|
||||
|
||||
Rule assembly mirrors the web editor: the prior rule is copied, `every`,
|
||||
`times`, `days` and `timezone` are removed, then only the selected timer shape
|
||||
is written. Empty weekdays mean every day (the key stays absent). A weekday set
|
||||
that is unchanged keeps the server's original order (the web editor does this
|
||||
so editing only a prompt does not reorder days). A blank timezone is omitted.
|
||||
|
||||
## Losslessness and CAS
|
||||
|
||||
- Edits start from `SavedSchedule.toJson()` (a deep copy): unknown top-level,
|
||||
`input`, `rule` and run-option fields (`model`, `stage_models`, `write_paths`,
|
||||
`allow_tools`, `title`, `output_format`, `next_due`, timestamps, future
|
||||
fields) survive untouched.
|
||||
- `input` keeps every unknown key and replaces only `prompt`.
|
||||
- **Every build starts from a fresh copy**, so the source snapshot and the
|
||||
draft are not mutated or aliased by a returned payload.
|
||||
- The edit record keeps the exact server `revision`; it is never incremented,
|
||||
invented or defaulted. An edit never rewrites `id`.
|
||||
- A create has no source: it emits the web sentinel `id: 0`, no `revision`, no
|
||||
unknown/run-option leftovers, `pipeline_id` from the caller, `enabled`,
|
||||
`input: {prompt}`, `rule`, and `notify_mode`.
|
||||
- `notify_mode` and `enabled` default the same way as the web draft when absent
|
||||
from a malformed older record, but an existing non-default string/boolean is
|
||||
preserved and validated rather than silently replaced.
|
||||
|
||||
## Checks actually run
|
||||
|
||||
```
|
||||
flutter pub get
|
||||
dart format lib/features/schedules/domain/editor test/features/schedules/domain/editor
|
||||
flutter analyze # No issues found! (1.1s)
|
||||
flutter test test/features/schedules/domain/editor # 9 passed
|
||||
flutter test test/features/schedules # 56 passed
|
||||
```
|
||||
|
||||
Focused coverage maps to the requested acceptance:
|
||||
|
||||
- create: sentinel `id: 0`, no revision, pipeline/version/prompt/workspace/rule;
|
||||
- lossless edit: id 9/revision 13, unknown record/input/rule/run options,
|
||||
workspace from the source, original map and `SavedSchedule` snapshot
|
||||
unchanged, returned payload not aliased;
|
||||
- changed workspace is written untrimmed, matching the web serializer;
|
||||
- prompt-only edit keeps the server weekday order and clock rule;
|
||||
- clock ↔ interval switching removes the other timer key and keeps unknown
|
||||
rule fields;
|
||||
- invalid timers (`59s`, `NaN`, `-1h`, `1.1x`, `Infinityh`, mixed text) and
|
||||
valid parity cases (`.5h`, `1h30m`, `24h`);
|
||||
- invalid clock times, duplicate weekdays, bad notification mode, invalid
|
||||
timezones, bad name/prompt/version/workspace;
|
||||
- invalid draft mutates nothing and has no record.
|
||||
|
||||
## Honest limits
|
||||
|
||||
- **Scope is the core editor slice.** Name, prompt, pinned version, workspace,
|
||||
timer mode/every/times, weekdays, timezone, enabled and notification mode are
|
||||
editable. Advanced JSON run options (`otherInput`, `stage models`, write
|
||||
paths, model, title, output format) and tools are **preserved exactly but not
|
||||
editable in this slice**; no control or parser for them was invented here.
|
||||
- **Timezone is structural.** Dart ships no IANA database, so the check accepts
|
||||
blank/`Local`, known single-zone aliases and a known area plus a well-formed
|
||||
location (e.g. `Europe/London`, `Etc/GMT+5`). It rejects clearly malformed
|
||||
values such as `Nowhere/Invalid` and `Europe/`, but cannot prove that every
|
||||
location in an accepted area exists. The server remains the final validator.
|
||||
This is documented at the function.
|
||||
- **No UI, network, CRUD, run dispatch, polling or scheduling engine.** The
|
||||
draft only assembles a record; the existing repository owns `save_schedule`,
|
||||
and no server was contacted.
|
||||
- **No browser capture applies.** This is a nonvisual pure domain item; there
|
||||
is no rendered change, so no fixture or screenshot was produced.
|
||||
- **Mobile unverified.** Only web-targeted Flutter tests and analysis ran. No
|
||||
Android/iOS build, emulator, ADB or device was used; the code is pure Dart.
|
||||
- **Not committed.** This stage forbids commit, push and deploy, so the
|
||||
candidate remains in the `flutter/schedule-draft` worktree for the manager.
|
||||
Reference in New Issue
Block a user