Skip to content

fix(chat): preserve scrollback as collaborator replies persist - #167402

Closed
steipete wants to merge 1 commit into
mainfrom
ci-fix/uir1-collaborator-reading-anchor
Closed

steipete wants to merge 1 commit into
mainfrom
ci-fix/uir1-collaborator-reading-anchor

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes shared chats jumping out of scrollback when a collaborator's reply moves from streaming output into saved history.

User Impact

Readers keep their place through queued input, streaming, and persistence. Following the conversation tail and resuming it with a local message continue to work.

Why This Change Was Made

The regression in #167054 retired committed assistant text before asynchronous transcript publication supplied its saved row. The reply briefly collapsed and the browser clamped scrollTop.

The existing run-buffer owner now distinguishes committed history ownership from published live-text ownership. It retains the live occurrence until publication and holds only the prepared terminal chat frame while publication attempts settle. Failed reads retain available fallback text. Resets and successor executions discard the predecessor's waiting frame.

Backend cleanup does not wait for transcript publication. Error-grace timers, retry admission and the existing transcript notification queue keep their baseline behavior. No protocol fields or persisted formats change.

This replaces the initial 17-file draft (+1008/-345) with 10 existing files (+661/-202), with no new modules. Production net growth is +231 lines versus +202 in the initial draft: the reduction is in responsibilities and total scope, not production LOC. The separate grace/publication modules, admission changes, asynchronous lifecycle finalizer, extra notification queue and protocol documentation changes are gone.

Evidence

The original real-Gateway E2E file and every-frame <=1 px anchor/scrollTop assertions are unchanged. Authentication, WebSockets, persistence and rendering are real; inference and conversation data use the credential-free synthetic fixture.

Revision Reading drift Reading while typing drift
Producer parent 4bf68b9 0 px 0 px
Producer af210e1 559 px 656 px
Baseline c48e883 584 px 656 px
Initial draft 0 px 0 px
Narrowed replacement 0 px 0 px

Final exact-source proof: the headless real-Gateway test passes in 81.76 seconds with reading top=584 and reading-typed top=4882, both retaining anchor=35. All 205 selected Gateway tests and both database-backed fixtures (37 tests) pass. The 179 unchanged UI dedup tests also pass.

A full check-changed run passes, including core types and all 27 test type graphs. The last two-file ingress delta separately passes the browser replay, affected tests, core and all selected test type graphs, typed/boundary lint, formatting and line-count gates. Full source-contracts, architecture (zero cycles), and deadcode:full pass; their unchanged graph proof is retained. All ten final file hashes match the reviewed and tested sources.

The final browser replay uses the ordinary repo UI E2E configuration: the prebuilt-only configuration correctly refused the intentionally dirty two-file overlay before running any test.

Codex P2 review is scoped-clean. Each accepted ownership finding has a failing-before/passing-after regression. The commentary file passes 23 cases locally in 24.51 seconds, predominantly worker compilation; the added cases take a few milliseconds and use no real waits.

The simpler publication-before-retirement attempt failed five existing dedup cases. Holding retirement alone lost the remaining live text when an earlier saved row arrived after final delivery. The retained mechanisms correspond to these failures:

Retained mechanism Required regression
Committed/published occurrence facts and publication acknowledgement Unchanged scroll E2E; five existing plain/native/before-first-byte dedup cases
Pending count and one prepared terminal frame Saved A publication must not erase Live B
Captured terminal buffer shared with late receipts A late same-run receipt must not cancel the final frame
Existing registration/context/claim fences and shared stale-batch cleanup Reset, remapped IDs, same-context replacement, early successor receipts, successor terminal and hidden predecessor cases
Existing ingress cleanup also checks pending publication ownership A hidden successor must not revive the predecessor's terminal after releasing its context

The prior broader Gateway-server run passed 502 files / 5,069 tests and failed six sessions-send cases. The unchanged baseline reproduced those same failures. That attribution and the original shard proof are reused; they are not represented as fresh full-suite passes for this rewrite.

The rendered result is unchanged from the inspected synthetic evidence below, so the original screenshots are retained.

Before: persistence displaces the reader by 656 px

After: persistence keeps the original reading anchor

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The branch keeps streamed replies visible until their saved history rows publish and delays terminal chat delivery until pending publication attempts settle.

Example: A reader types while a collaborator's reply becomes saved history.

  • Before: The supplied baseline browser run shifts the reading position by 656 px.
  • After: The supplied after-fix replay preserves the reading position with 0 px drift.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A worthwhile owner-level repair with real browser/Gateway proof, focused lifecycle regressions, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The updated exact-source real-Gateway/browser replay exercises the changed buffer and transcript-publication owners through authenticated collaboration, persistence, and rendering, reporting 0 px drift while reading and typing; inspected before/after screenshots support the visible result. Inference is synthetic. Protocol fields, stored formats, schemas, and settings remain unchanged, so no migration is required.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Readers lose their place when a collaborator's streamed reply becomes saved conversation history.
Reason: The measured regression warrants an owner-level repair. Prior merged area ownership supports the direction, and the narrowed change preserves complete replies and commentary deduplication without new product surface.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still has the publication gap, and the narrowed repair has convincing browser evidence with no actionable findings.

Priority: P2
Reviewed head: b73851c4448761544ce0ca4c56883e5939d19bc3

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway turns agent output and saved conversation rows into updates for chat clients. Its live reply buffer bridges streaming output to published history so readers see a continuous conversation.

flowchart TD
  A[Agent streams reply] --> B[Gateway reply buffer]
  C[Transcript commits row] --> B
  C --> D[History publication attempt]
  B --> E[Visible streaming reply]
  D --> F{Saved row published?}
  F -->|Yes| G[Retire matching live text]
  F -->|No| E
  G --> B
  D --> H[Settle prepared terminal frame]
Loading

Technical review

Best possible solution:

Keep the handoff in the existing Gateway reply buffer, preserving complete replies, fallback visibility, and successor-run isolation.

Do we have a high-confidence way to reproduce the issue?

Yes: current source exposes premature live-text retirement, and the supplied real-Gateway/browser scenario records baseline scroll displacement. This review did not independently run the scenario.

Is this the best way to solve the issue?

Yes: correcting the Gateway publication handoff addresses the transient conversation collapse at its producer while retaining existing deduplication and client scroll behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 409cef15bea2.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit af210e1 adds src/gateway/server-chat-buffer.ts:88 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: af210e1f3fbf; files: src/gateway/server-chat-buffer.ts)

PR surface

Source +231, Tests +228. Total +459 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 409 178 +231
Tests 4 252 24 +228
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 661 202 +459

Labels

Label changes:

  • remove proof: 📸 screenshot: Current real behavior proof evidence kind is live_output.

Label justifications:

  • P2: Losing the reading position during shared-chat persistence is a concrete usability regression with bounded impact.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-08T18:46:35.404Z sha 8f18b42 :: needs maintainer review before merge. :: none

Reviewed October 8, 2026, 5:40 PM ET / 21:40 UTC (Revision 2).

Keep committed assistant text visible until its saved row publishes.
Hold only the terminal chat frame in the existing run buffer; backend
cleanup, error grace, retry admission and notification queues keep their
existing owners. Cancel stale handoffs when an execution is replaced.

Fixes the handoff regression introduced by af210e1 (#167054).
The unchanged real-Gateway test retains both reading anchors at 0 px.
Dedup, lifecycle ownership, fixture, type, lint and P2 proof pass.
@steipete
steipete force-pushed the ci-fix/uir1-collaborator-reading-anchor branch from 8f18b42 to b73851c Compare October 8, 2026 21:34
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed docs Improvements or additions to documentation size: XL labels Oct 8, 2026
@clawsweeper clawsweeper Bot removed the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Oct 8, 2026
@roboclaw-bot roboclaw-bot self-assigned this Oct 16, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Closing after verifying the remaining repair is merged on main.

The primary delayed-publication scrollback fix was already covered by commit 1f9022d. The remaining failure cases—retaining visible replies when transcript publication fails, carrying handled reader failures through terminal delivery, and avoiding duplication when a repeated receipt later succeeds—are now fixed by #174087, merged as 3d52679.

The replacement uses the current occurrence/publication owner rather than applying this older buffering implementation wholesale. Exact-head CI passed, the landed composition was verified against the reviewed source, and @steipete credit is preserved in the PR and squash commit.

@RomneyDa
RomneyDa deleted the ci-fix/uir1-collaborator-reading-anchor branch October 22, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants