Merge remote-tracking branch 'origin/main' into ci/simplify-test-suite

# Conflicts:
#	packages/app/e2e/browser/agent-stream-ui.spec.ts
This commit is contained in:
Mohamed Boudra
2026-09-15 03:16:45 +02:00
59 changed files with 3086 additions and 857 deletions
+33 -4
View File
@@ -22,7 +22,7 @@ Every provider delivers incremental text, so there is no provider that needs spe
Arrival is lumpy and there is no fixing that at the source. A 60ms coalescing window carries however many characters the model produced in those 60ms, which swings by an order of magnitude within a single turn. Painting each delta as it lands makes the size of those lumps visible, and that is what reads as jagged.
So arrival sets a _target_ and the reveal rate is derived from the backlog instead. A burst makes the text catch up faster; it does not make the text jump. Shrinking the coalescing window does not fix this — it makes the lumps smaller and more frequent, at the cost of message rate on a daemon loop that already contends with terminal frames and per-message relay encryption.
So arrival sets a _target_ and the reveal rate is derived from the backlog instead. A burst shortens the interval within the word cadence. A late frame releases one word, without spending missed frames as credit to show a group at once. Shrinking the coalescing window does not fix this — it makes the lumps smaller and more frequent, at the cost of message rate on a daemon loop that already contends with terminal frames and per-message relay encryption.
## Invariants
@@ -33,7 +33,7 @@ So arrival sets a _target_ and the reveal rate is derived from the backlog inste
blocks and parses only the growing last block during append. Splitting in the reducer discards
paragraph separators and exposes fragments to plugin callbacks, which need the whole source text.
- **First sight of a text is revealed whole.** Only growth is paced. This is what makes history hydration, timeline replay, a virtualized row remounting on scroll, and an already-finished message all render complete on first paint without a special case for each.
- **Leaving `phase: "streaming"` snaps the reveal.** A completed turn must never be left holding characters. `layoutStream` sets the phase, so anything outside the live head with an active turn is already complete.
- **Completion releases an unfinished word.** Every platform drains queued words through the same pacing when the provider finishes; the last word also finishes fading.
- **The reducer queue commits on a frame, with a timer as the ceiling.** A frame callback never fires in a hidden tab, so a timer races it and wins when nothing is painting — the store has to keep advancing either way.
- **A history row re-renders only when its item or layout item identity changes.** The inverted
FlatList hands every mounted cell a new `index` and `ref` whenever a row is prepended, so without a
@@ -47,11 +47,40 @@ So arrival sets a _target_ and the reveal rate is derived from the backlog inste
## Measuring
Word reveal lives in `packages/app/src/word-stream`. Native attribution and pinned
upstream revisions are in `packages/app/modules/paseo-word-stream/UPSTREAM.md`.
Judge the visible front across word boundaries at the recording's native frame
rate. No character should become more opaque than text before it in reading
order, and the front should not visibly change speed at word boundaries.
Sampling at 100 ms hid the previous defect: later letters appeared before earlier
letters, leaving holes that read as flashing words during playback.
Exercise provisional Markdown and recycled views when checking fade-once behavior.
A table forming or inline formatting closing can change the rendered structure
without making previously visible text new again.
On native, text and its fade metadata must become visible together. An earlier
implementation sent metadata asynchronously and flashed new text fully opaque
for one frame before dimming it. Preserve native layout, selection, and inline
styles, and keep animation ticks off the JS thread. Do not remove the animation
host's layout box with `display: contents`: RN forcibly flattens it and removes
the native animation owner. iOS table cells receive pacing without opacity
animation; include that limit in platform QA reports.
Compare release APKs on the same Android device with the mock `bursty-stream`
provider, identical prompts, fresh conversations, and equal sampling windows.
Collect `agent-device perf frames` and `perf memory sample`; keep screen recording
out of the timed runs. Software-rendered emulator results are comparative
evidence, not physical-device frame-rate guarantees. Native instrumentation
tests in the module check pixels, append/replacement behavior, and cleanup.
- **Smoothness (user-perceived):** `packages/app/e2e/browser/agent-stream-smoothness.spec.ts`, gated behind `PASEO_AGENT_STREAM_PERF_E2E=1`. Drives the mock provider's `bursty-stream` model and reports coefficient of variation of characters painted per frame (smoothness) plus p95 gap between visible updates (stalls). Both numbers are needed: a stalled stream is perfectly smooth.
- **Reproducing bursty arrival:** the `bursty-stream` model in `mock-load-test-agent.ts` emits uneven runs of tokens separated by idle gaps. Burst sizes come from a seeded generator, so a run repeats exactly.
- **Rate policy in isolation:** `computeRevealStep` in `packages/app/src/agent-stream/text-reveal.ts` is pure; `text-reveal.test.ts` covers convergence and burst flattening without a renderer.
- **Rate policy in isolation:** `packages/app/src/word-stream/internal/model.test.ts` checks the shared word scheduler without a renderer.
- **Fade behavior:** `word-stream-fade.spec.ts` checks web direction, layout stability, selection, and tail cleanup. Native tests in `modules/paseo-word-stream` drive the host view React mounts with the same range props the bridge sends, advance frame time through the host's injected frame clock, and check rendered pixels and animation completion on Android and iOS.
Healthy numbers (2026-08, Expo web against a local dev daemon, real Claude Haiku agent, ~8.5s samples during active streaming). Setting `TEXT_REVEAL_HORIZON_MS` to 0 makes the reveal paint on arrival, which is how the baseline column was taken:
Historical character-reveal baseline (2026-08, Expo web against a local dev daemon, real Claude Haiku agent, ~8.5s samples during active streaming). The paint-on-arrival column disabled the former reveal horizon:
| | paint on arrival | paced |
| -------------------------------- | ---------------- | ----- |