Skip to content

fix(threads): keep reports in order and deliver them once - #354

Merged
nixuuu merged 1 commit into
devfrom
fix/timeline-order-duplicates
Nov 8, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/timeline-order-duplicates

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Report inputs could appear after newer answers, leave empty cancelled work, and repeat for the same child result. Desktop and phone could retain different projections after consumption or reconnect. This keeps report delivery unique per recipient and child turn and preserves the loaded timeline window across recovery.

Causes and evidence

  1. In the supplied recording, repeated purple reports with 4-hop and 2-hop badges sit beside empty cancelled work while newer 03:33 and 03:35 turns appear below during scrolling. Web appended turns without transcript elements after all event-backed rows. Those turns now keep their canonical ordinal position; transcript/background events retain event sequence order.
  2. A spawn and subsequent admitted steers can share a target turn. Completion previously notified once per call: the gateway/worker reproduction produced three reports for one result. Delivery now claims the result once per recipient under its existing thread lock. Different hop counts are consistent with distinct calls; the original call IDs are unavailable, so the recording alone cannot establish the precise relay path.
  3. Consuming pending bus inputs cancelled them without withdrawing their timeline rows or broadcasting the changed projections. Consumption now withdraws them and publishes turn/steer updates. Migration 0096 repairs historical consumed inputs while preserving started/dispatched work and genuine cancellations. Explicit-message consumption was introduced by fix(agent-bus): deliver subagent messages while they're current #338; per-call completion notifications and the empty-turn layout predate it.
  4. Real-browser paging exposed another jump: report-bearing threads conservatively fall back to a full snapshot on reconnect, replacing an expanded window with its last 24 turns. Additive UI field from_turn_id preserves the inclusive oldest loaded turn on both clients, with authoritative reset for invalid history. Late old turn updates stay outside a loaded tail. Fork ancestry keeps chain order.

nightly.100 includes #350 and was published at 00:21:46 Warsaw on November 8, before the reported 03:33 observation. Installation on the reporting Mac is unconfirmed. These paths reproduce on a base containing #350 and explain persistence either way. No linked-computer topology is needed.

Validation

  • Gateway↔scripted-worker/Postgres regressions cover admitted steers, fallback/consumption, wait_threads progress, idle report delivery, distinct results with identical text, repeated sweeps, late old projections, disk-cache restore, expanded history, and gateway restart. A paired mobile client uses Connect over pinned Network access with the same device credential after restart; its projection matches the BFF-coalesced desktop path. Before the fix, duplicate delivery was 3 instead of 1 and consumed inputs never updated live.
  • Migration upgrade regression preserves genuine, started and dispatched cancellations. History integration covers full-snapshot resume and invalid window/version resets.
  • Gates passed: bun install, bun run gen:check, bun run typecheck (including mobile), bun run lint, bun run format:check, and the web build. The complete bun run check:tmp ran in four sequential native shards (--shard=1/4 through 4/4, --timeout 30000): 1780 pass, 161 skip, 0 fail across all 320 files, with a clean test temp directory after each shard. Two monolithic attempts were interrupted by SIGTERM, so sharding completed the full gate. The existing steering regression now expects one shared-result report instead of two.
  • Real browser: light/dark at 1280×800 and 390×844, long labels, older-page loading/reconnect, genuine cancellation placement, consumed-report removal, jump to latest, and composer reply also observed by the paired mobile client. Test servers and tabs were closed. Packaged macOS/iPhone apps and the optional Android emulator were not run. The isolated fixture lacks linked-computer runtime, producing an unrelated /api/computers 409.
  • Copy audit (§8): no UI strings added or changed; consumed inputs no longer render misleading empty cancelled work. Existing cancellation copy remains for real cancellations.

CI: static checks, all four CI test shards, and Web/Linux builds passed on this head. Windows packaging reached the prepared runtime and electron-builder, then failed with HTTP 504; its failed job was retried once. No external review yet; inline self-review found no outstanding issues.

Fixes: #338
Related: #350

@nixuuu
nixuuu force-pushed the fix/timeline-order-duplicates branch from 8f4be87 to f766fb2 Compare November 8, 2026 09:29
@nixuuu
nixuuu marked this pull request as ready for review November 8, 2026 09:46
@nixuuu
nixuuu merged commit f583c5c into dev Nov 8, 2026
12 of 17 checks passed
@nixuuu
nixuuu deleted the fix/timeline-order-duplicates branch November 8, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant