Skip to content

fix(channels): recover failed progress draft starts#88749

Merged
steipete merged 1 commit into
mainfrom
fix/progress-draft-start-state
May 31, 2026
Merged

fix(channels): recover failed progress draft starts#88749
steipete merged 1 commit into
mainfrom
fix/progress-draft-start-state

Conversation

@steipete
Copy link
Copy Markdown
Contributor

Summary

Fixes #83115.

This keeps channel progress draft startup state honest when onStart is async:

  • failed delayed startup no longer leaves the gate permanently active
  • in-flight startup remains visible to finalization via hasStarted
  • noteWork() joins active startup before reporting active/inactive state
  • cancellation clears active state so callers do not refresh a draft that never started
  • Discord, Telegram, Slack, Matrix, and Teams refresh just-started progress drafts instead of waiting for a later event

Verification

Behavior addressed: Channel progress draft gates no longer report a failed startup as active, and progress updates arriving during startup/cancel races do not get dropped or leave stale drafts behind.

Real environment tested: Local OpenClaw checkout on branch fix/progress-draft-start-state, rebased onto origin/main at commit 52b86b8493.

Exact steps or command run after this patch:

  • node scripts/run-vitest.mjs src/plugin-sdk/channel-streaming.test.ts extensions/telegram/src/bot-message-dispatch.test.ts extensions/discord/src/monitor/message-handler.process.test.ts extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts extensions/matrix/src/matrix/monitor/handler.test.ts extensions/msteams/src/reply-stream-controller.test.ts
  • ./node_modules/.bin/oxfmt --check src/channels/streaming.ts src/plugin-sdk/channel-streaming.test.ts extensions/discord/src/monitor/message-handler.draft-preview.ts extensions/telegram/src/bot-message-dispatch.ts extensions/slack/src/monitor/message-handler/dispatch.ts extensions/matrix/src/matrix/monitor/handler.ts extensions/msteams/src/reply-stream-controller.ts
  • git diff --check origin/main...HEAD
  • autoreview --mode local after rebase

Evidence after fix:

  • Focused Vitest passed: 6 shards, 422 tests.
  • oxfmt check passed on all touched files.
  • git diff --check origin/main...HEAD passed.
  • Autoreview clean: no accepted/actionable findings.

Observed result after fix: Rejected startup clears gate state and can retry; in-flight startup stays visible to finalization; cancel races resolve inactive; touched channel callers refresh active or just-started progress drafts.

What was not tested: Live Discord/Telegram/Slack/Matrix/Teams network delivery was not exercised; the proof is focused unit coverage of the shared gate and channel progress-draft callers.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels May 31, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 31, 2026

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(channels): recover failed progress draft starts This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 52b86b8493

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/channels/streaming.ts
Comment on lines +590 to +592
if (startPromise) {
await startPromise;
return started;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle failed in-flight progress starts in noteWork

When a delayed or explicit draft start is already in flight and onStart rejects (for example a Telegram/Discord draft flush() or send/update failure while another progress event arrives), this await startPromise now rejects out of noteWork(). Before this change, concurrent noteWork() calls saw started and returned without throwing, while the timer path still swallowed the failed start and allowed retry; the new join path can abort the channel progress handler instead of reporting inactive and recovering. Please catch the joined startup failure here and return the post-failure active state so failed starts clear and subsequent work can retry consistently.

Useful? React with 👍 / 👎.

@steipete
Copy link
Copy Markdown
Contributor Author

Land-ready verification for head 52b86b8493d8e66406e59b02058264451d5cea16.

Local/Testbox proof:

  • node scripts/run-vitest.mjs src/plugin-sdk/channel-streaming.test.ts extensions/telegram/src/bot-message-dispatch.test.ts extensions/discord/src/monitor/message-handler.process.test.ts extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts extensions/matrix/src/matrix/monitor/handler.test.ts extensions/msteams/src/reply-stream-controller.test.ts passed: 6 shards, 422 tests.
  • ./node_modules/.bin/oxfmt --check src/channels/streaming.ts src/plugin-sdk/channel-streaming.test.ts extensions/discord/src/monitor/message-handler.draft-preview.ts extensions/telegram/src/bot-message-dispatch.ts extensions/slack/src/monitor/message-handler/dispatch.ts extensions/matrix/src/matrix/monitor/handler.ts extensions/msteams/src/reply-stream-controller.ts passed.
  • git diff --check origin/main...HEAD passed.
  • node scripts/check-changed.mjs --base origin/main passed in Testbox tbx_01kszpd6wnnbcwmwn8nxc11p2d; Actions run: https://github.com/openclaw/openclaw/actions/runs/26721545639.
  • Post-rebase autoreview clean: no accepted/actionable findings.

GitHub CI: all required PR checks green on the same head.

Known proof gap: no live Discord/Telegram/Slack/Matrix/Teams network delivery run; the proof is focused shared-gate and channel caller coverage.

@steipete steipete merged commit fa2b2ff into main May 31, 2026
197 of 201 checks passed
@steipete steipete deleted the fix/progress-draft-start-state branch May 31, 2026 19:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 1, 2026
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Channel streaming started flag set before async onStart completes

1 participant