Repository navigation
refactor(channels): centralize progress draft events - #117269
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 3:06 AM ET / 07:06 UTC. ClawSweeper reviewWhat this changesCentralizes progress-draft event translation, receipt tracking, and finalizable draft-stream controls used by Discord, Slack, Matrix, and shared channel code. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 5 items remain The refactor follows the existing shared queued-followup admission contract and centralizes repeated channel lifecycle logic, so this PR remains useful. It needs explicit maintainer handling plus real after-fix channel behavior evidence before merge. Priority: P2 Review scores
Verification
How this fits togetherChannel plugins convert agent progress callbacks into editable draft messages before a final reply replaces them. The shared compositor owns event translation and draft lifecycle behavior, while the follow-up admission path establishes when a queued turn begins. flowchart LR
A[Agent progress events] --> B[Reply and follow-up admission]
B --> C[Channel reply callbacks]
C --> D[Shared draft compositor]
D --> E[Discord Slack and Matrix drafts]
E --> F[Final channel reply]
Decision needed
Why: The Before merge
Agent review detailsSecurityNone. PR surfaceSource -143, Tests +149, Generated 0. Total +6 across 21 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Refresh the branch against current Do we have a high-confidence way to reproduce the issue? Not applicable: this is an internal lifecycle refactor rather than a user-reported bug. Current-main source and tests confirm that the queued-followup callback already has a concrete admission path. Is this the best way to solve the issue? Yes, provisionally: the shared compositor and draft controls are the common owner for this duplicated channel lifecycle policy, and the Discord change consumes an existing authoritative queued-turn callback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 78486e27511c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Summary
{ text, blocks }atomically and Matrix/Slack share one finalizable lifecycleRoot cause and owner
Progress lifecycle policy had spread into Slack, Discord, and Matrix. Slack additionally stored blocks in a sidecar separate from the queued text, and Discord depended on
onAssistantMessageStarteven though queued execution strips that callback. The architectural owner is the shared channel progress compositor plus draft loop/controls.The canonical fix moves event-phase gating and receipt tracking to focused shared channel modules, carries each channel's formatter policy as an injected callback, and uses the queued-followup admission callback as the authoritative turn boundary. Removed paths include Slack's
pendingUpdate/manual lifecycle, Discord's local receipt state, and repeated channel event mappings.Telegram and Mattermost were inspected but intentionally left unchanged: their summary/generation contracts are different from these incremental draft transports.
Compatibility
Existing string draft-loop behavior remains the default through additive generic defaults and optional payload hooks. Existing plugin SDK export names/subpaths are unchanged; the generated API manifest was refreshed for the additive generic/optional return surface. No new public barrel was added.
Production delta
Handwritten production code is net -144 LOC (tests net +150 LOC; generated SDK manifest counted separately).
Proof
onQueuedFollowupAdmitteddirectlytbx_01kyy0vxe781m188gq3zfnadtgpassed formatting, SDK contract, dependency/plugin guards, dead exports, and all core/extension production/test typechecks; it found only unbound callback-method linttbx_01kyy1neehpejq4qn36kjde5yqwas shut down by the backend before checkoutRedacted channel-runtime evidence
This no-source-change proof ran the nearest real process/inbound channel harnesses at exact head
a5851003ec6a2f513181d5fcff20fbdebd6bfba1. It uses mocked external channel APIs/providers while executing the production Discord process callbacks, Slack dispatch/draft stream, and Matrix handler/draft controller.Command:
node scripts/run-vitest.mjs \ extensions/discord/src/monitor/message-handler.process.draft-progress.test.ts \ extensions/slack/src/draft-stream.test.ts \ extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts \ extensions/matrix/src/matrix/monitor/handler.test.ts \ --reporter verbose \ -t 're-arms progress collapse for a queued assistant turn|does not collapse a text-only queued assistant turn|cleans up an unfinished queued progress turn|edits changed blocks even when fallback text is unchanged|suppresses terminal progress callbacks without their terminal phase'Redacted terminal excerpt:
Verdict JSON:
{ "schema": "openclaw.real-behavior.v1", "head": "a5851003ec6a2f513181d5fcff20fbdebd6bfba1", "mode": "nearest-process-inbound", "externalChannelApis": "mocked", "provider": "mocked", "redacted": true, "commandExit": 0, "checks": [ { "channel": "discord", "surface": "processDiscordMessage", "cases": 3, "result": "pass", "observed": [ "queued progress re-armed at authoritative admission", "text-only queued turn remained uncollapsed", "unfinished queued progress was cleaned" ] }, { "channel": "slack", "surface": "dispatch plus draft stream", "cases": 2, "result": "pass", "observed": [ "same fallback text with changed blocks emitted the new atomic payload", "non-terminal command and patch callbacks stayed hidden" ] }, { "channel": "matrix", "surface": "monitor handler plus draft controller", "cases": 1, "result": "pass", "observed": [ "non-terminal approval, command, and patch callbacks emitted no draft" ] } ], "overall": "pass" }