Repository navigation
fix: preserve code and attachments in streamed replies - #146361
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 20, 2026, 3:49 AM ET / 07:49 UTC (Revision 33). ClawSweeper reviewWhat this changesPreserves code formatting, attachment associations, reply targets, and speech intent across streaming, Telegram delivery, and conversation history. Merge readiness⛔ Blocked before merge - 2 items remain Keep open as a useful, well-supported fix. No actionable introduced defect was established, and the previous third-party compile-sweep caveat does not demonstrate a compatibility blocker. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw turns model output into prepared replies, applies delivery policy, and sends them to channels or WebChat. The same reply content also feeds persisted conversation history and final-answer recovery. flowchart LR
A[Model output] --> B[Directive parsing]
B --> C[Prepared reply facts]
C --> D[Hooks and delivery policy]
D --> E[Telegram or WebChat]
C --> F[Conversation history]
F --> G[Final answer recovery]
G --> D
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep raw parsing at its owning boundary and carry prepared content through shared delivery and history owners while preserving documented legacy SDK callbacks. Do we have a high-confidence way to reproduce the issue? Yes: the registered chat.send fixture and current-main directive cleanup establish a concrete indentation-loss path. This read-only review inspected source and supplied before/after evidence without executing the application. Is this the best way to solve the issue? Yes: prepared operations prevent repeated interpretation while sharing delivery policy and settlement with existing raw paths; the retained optional callbacks avoid requiring a plugin migration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7a6de767af09. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (32 earlier review cycles; latest 8 shown)
|
Preserve attachment associations through media normalization and shared prepared delivery. Remove static import cycles and keep Gateway and Telegram fixtures aligned with the shared operation contract.
Merge pinned main efcde55 and preserve prepared text, reply targets, attachment metadata, and delivery settlement through current dispatch owners. Remove obsolete Telegram-only dispatch additions and retain compatible SDK and raw callback contracts. Validated with 1702 focused cases across 20 files, full build, scoped mapped checks, and independent review through P2. Inherited UI and CLI check failures are documented; Telegram Test Server proof remains required before landing.
Prune the removed max-lines suppression and reuse the shared first-text extractor at Gateway test call sites. Extend registered Telegram recovery coverage to preserve an attachment alias associated with the second media item while deduplicating its singular URL. Validated owner guards, formatting, targeted lint, extension test types, 245 Gateway/shared cases and 11 Telegram recovery cases. Fresh independent review is clean through P2.
Use the existing message-unwrapping helper at shared text-extractor call sites and remove two redundant missing-message throws. The retained empty-string assertions still reject absent messages. Verified the exact CI merge composition against main parent 7f73161 with the maintained line-cap guard, scoped lint, formatting, all 223 Gateway cases, and fresh independent review through P2.
Integrate current main while retaining prepared stream boundaries and literal reply content. Share the latest-assistant transcript projection between SQLite and retained JSONL readers so recovered replies retain authored text and validated delivery facts. Preserve opaque host metadata through Telegram payload transformations. This keeps preceding-input answers from recovering a later final after media dedup and retains delivery ownership through transcript correlation and durable send. Keep existing reply intent ahead of recovered targets and preserve attachment associations through the shared planner. Canonical Markdown block ownership keeps indented MEDIA examples literal during recovery. Apply Gateway control-token suppression only to raw projections; admitted prepared fragments remain intact in display and transcripts. Join contiguous display fragments once so intermediate trimming cannot add code-block lines. Consolidate duplicate delivery tests at registered entry points and add real persistence-to-dispatch regressions with causal failure proof. No configuration keys, stored schemas, or migration behavior change.
Preserve main's session-aware media roots and remote-placement handling while retaining prepared delivery, attachment associations, and opaque payload metadata. Keep the legacy channel-message facade at its maintained 136 exports; prepared operations and metadata copying remain on their narrow SDK entrypoints. The composed change passes 617 focused cases, selected static checks, the exact SDK inventory, and an independent review of the complete PR candidate.
…152736) * refactor: move outbound claim and renewal SQLite to worker * test: route outbound queue consumers through database workers * test: expect worker routing for durable Discord delivery * test(ci): retain one owner for Twitch delivery coverage * test(outbound): clean up ACK fixtures with their owner * test: join Doctor database cleanup before snapshots * test(claws): adopt canonical Doctor reader cleanup Carry the exact Doctor fixture from 8416d71 (#146361). Preserve ordered async drain, native reset, and temporary-directory cleanup while closing both metadata readers in finally. Supersedes the local helper-based fixture repair without changing Claims production. * refactor(outbound): centralize delivery queue worker dispatch Route the existing eight queue operations through one typed domain adapter while retaining each executor and transaction owner. Remove the obsolete lease-only selector and preserve current-main worker operations and canonical fixtures. Reuse the exact duplicate test-route deletion from 57a0a198ebdec2530afd17b656183f060fb4c4b3. * test(outbound): control recovery snapshot timing Capture the queue row and await real worker renewal before fixing the host recovery clock. Model an expired detached scan without shortening the authoritative lease or sleeping. Fix the clock before startup captures its recovery deadline. Preserve exact owner, renewed expiry, and retry assertions; both modes reject a stale-snapshot guard mutation. Production remains unchanged.
* fix(reply): preserve code and attachments in streamed replies * fix: retain prepared reply metadata through delivery Preserve attachment associations through media normalization and shared prepared delivery. Remove static import cycles and keep Gateway and Telegram fixtures aligned with the shared operation contract. * test: fix streamed reply integration guards and recovery coverage Prune the removed max-lines suppression and reuse the shared first-text extractor at Gateway test call sites. Extend registered Telegram recovery coverage to preserve an attachment alias associated with the second media item while deduplicating its singular URL. Validated owner guards, formatting, targeted lint, extension test types, 245 Gateway/shared cases and 11 Telegram recovery cases. Fresh independent review is clean through P2. * test: reuse Gateway message inspection without line growth Use the existing message-unwrapping helper at shared text-extractor call sites and remove two redundant missing-message throws. The retained empty-string assertions still reject absent messages. Verified the exact CI merge composition against main parent 04ca996 with the maintained line-cap guard, scoped lint, formatting, all 223 Gateway cases, and fresh independent review through P2. * test: repair streaming media coverage and CI checks * fix(telegram): keep recovered finals from resending block media * test(telegram): exercise prepared replies through native transport * fix(reply): clear stale metadata after media staging failures Always replace attachment metadata with the surviving aligned entries. A failed first file must not lend its name or MIME type to a later URL that has no metadata. Clear the metadata when no media survives. Add a regression using the existing normalizer fixture; it fails before this change on the stale filename. * test(telegram): use shared SDK fixtures in recovery suites Keep recovery suites on existing unpublished test facades and reuse public runtime entrypoints where available. Preserve all delivery assertions and fixture behavior while removing direct core imports from plugin tests. Name the existing mock type through Vitest's public Mock contract so test fixture declarations remain portable without changing runtime behavior. * fix(tasks): respect live publication invalidation Recheck recovery-witness invalidation before notifications and after observer callbacks. Intervening committed writes remain authoritative even when task records return to equal values, without dropping valid receipt readiness or weakening publication assertions. * fix(tests): import prepared replacement from lifecycle
…#153579) ## What Problem This Solves Fixes literal `[embed]` examples disappearing from indented and inline code in Control UI chat and becoming unintended canvas previews. ## User Impact Code examples remain visible as code. Ordinary supported embeds still render, fenced examples remain literal, and surrounding prose is preserved. No configuration, schema, permission, dependency, or iframe-policy change is introduced. ## Why This Change Was Made The existing extractor now uses the canonical Markdown code-region scanner instead of a separate fence-only walk. The contributor's production repair is preserved. Regression coverage is consolidated into two distinct cases for indented blocks and inline code; production code is seven lines smaller. ## Evidence [Inspected actual Control UI before/after screenshots and ordinary-embed controls](openclaw#153579 (comment)). - Drove the real Control UI app/router through the maintained mocked Gateway handshake and session history, then the production normalizer, chat bubble and widget iframe. This is not a handcrafted page displaying normalizer output. - Four browser cases per phase: indented and inline examples were stripped and generated previews on pinned main; the candidate preserves both with no preview. Fenced examples and ordinary supported embeds pass unchanged. - Used synthetic model/session labels and inert same-origin canvas assets. External HTTP was blocked. Both tabs and owned Vite servers were settled after capture. This is UI boundary proof, not a claim about a real Gateway or external embed provider. - The two regression cases failed on the original extractor. The candidate passed 10 extractor tests and 90 UI normalizer tests, scoped lint/formatting, and both structural line checks. - Both final changed files match the tested current-main replay. The six published PNGs were inspected, attached in the originating task, and verified decoded and visible in the actual GitHub comment. The linked comment records the exact before/after source revisions. ## AI Assistance Original contributor note, retained for attribution: > AI-assisted. Discovered the `parseFenceSpans` gap by scanning its callers (the same anchor that openclaw#146361 migrated in `parse-output.ts`). The fix applies the existing `findCodeRegions`/`isInsideCode` pattern. Proof exercises the Control UI `normalizeMessage` normalization path that the chat renderer calls, with before/after Playwright screenshots. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #146330
What Problem This Solves
Fixes code examples, attachment details, and reply targets being lost when streamed answers cross delivery and transcript boundaries.
User Impact
Replies retain code indentation, literal control-token examples, attachment associations, reply intent, and explicit speech facts. Telegram preserves eligible preview quotes during finalization, respects hook-selected media during recovery, and avoids resending delivered attachments. Successful text-and-audio replies no longer trigger a false missing-response warning.
A failed text-only queue insertion now reports a definitive non-send only after an observed transaction rollback. Prepared replies also use the existing missing-runtime classification, while errors after runtime invocation retain their original uncertainty.
Configuration keys, defaults, SQL schemas, and historical transcript records are unchanged. Existing raw SDK callbacks remain supported; no migration is required.
Why This Change Was Made
The raw-directive parser owns interpretation. Planning, dispatch, and transcript projection carry prepared text and delivery facts. The shared media preparer stages bytes once; final selection retains each surviving file's metadata and source aliases without reopening its source. Persisted facts do not confer runtime authority.
Test cleanup removes redundant mocks, unused fixtures, test-only exports, and overlapping helper coverage. Telegram integration suites consume existing unpublished SDK test owners. Recovery and media cases extend existing tables. The task-publication integration adopts main's complete production fix from #153371 and retains complementary terminal-read and overlapping-write regressions with one request helper.
Evidence
Landed: 8416d710. Validated PR head:
1956cf95c19678d65ce487812de2a14bb4c229f1, tree0c2464d542fedac4b494a42694d4bba6aefc7693. Current-head CI passed with 161 jobs terminal and zero failures, including both previously failing lanes. Current-head Telegram Package Acceptance passed all three cases. Native merge, completion comment, and cleanup are verified.b01acd24e999b0e7b0305231a6de5d8458a1ad71e70bf7dc44e9e1cec924eab7. Canonical cleanup completed, though separate per-lease/process receipts were not retained. This uses Telegram's Test Server, an independent user, scripted model responses, andno-push-artifact; it is not a live-model or Telegram-client visual test.A broad third-party plugin compile sweep was not performed. All selected checks and requested live proof are complete. Native landing and cleanup are verified, and #146330 is closed.