Skip to content

fix: retry Discord draft preview cleanup after transient delete failure - #104895

Closed
LZY3538 wants to merge 1 commit into
openclaw:mainfrom
LZY3538:codex/fix-104865-discord-draft-cleanup
Closed

LZY3538 wants to merge 1 commit into
openclaw:mainfrom
LZY3538:codex/fix-104865-discord-draft-cleanup

Conversation

@LZY3538

@LZY3538 LZY3538 commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #104865

What Problem This Solves

Fixes a Discord partial-streaming cleanup regression where a fresh final reply can land while the old preview remains visible after a transient preview DELETE failure. The old implementation also cleared preview ownership too early, so a later cleanup could not retry the same message.

Why This Change Was Made

The shared finalizable draft cleanup now keeps ownership until DELETE succeeds, then clears the stored id only if that same id is still current. That preserves retryability and avoids erasing a replacement preview that was created while the old DELETE was in flight.

Discord teardown now performs the missing bounded cleanup retry for an unfinalized preview even after a fresh final reply was delivered. It still protects previews finalized in place, and it does not add timers, retry loops, configuration, or extra final-message delivery.

User Impact

Discord users with partial/progress preview streaming should no longer get stuck with an unrecoverable stale preview beside the final answer after a transient DELETE failure. Shared cleanup users such as Mattermost inherit the safer delete-then-compare-clear ownership behavior.

Evidence

  • node scripts/run-vitest.mjs src/channels/draft-stream-controls.test.ts -t "keeps failed deletes available for retry" (passed)
  • node scripts/run-vitest.mjs src/channels/draft-stream-controls.test.ts -t "preserves a replacement id while delete is in flight" (passed)
  • node scripts/run-vitest.mjs extensions/discord/src/monitor/message-handler.process.test.ts -t "retries stale preview cleanup at teardown after fresh final delivery" (passed)
  • pnpm exec oxfmt --check --threads=1 src/channels/draft-stream-controls.ts src/channels/draft-stream-controls.test.ts extensions/discord/src/monitor/message-handler.draft-preview.ts extensions/discord/src/monitor/message-handler.process.test.ts (passed)
  • git diff --check (passed)
  • python .agents/skills/autoreview/scripts/autoreview --mode local --engine codex --model gpt-5.5 (clean: no accepted/actionable findings)

Remote proof note: this local machine does not have a usable Crabbox binary or sibling Crabbox checkout, so Testbox-backed check:changed could not be started here. A direct local pnpm check:test-types also did not complete in this Windows worktree after several minutes with no stage output; the pushed head e6ebf380a61418017148273fa51853d71e96b609 is now relying on GitHub CI for the broad type/check matrix.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 12, 2026
@clawsweeper

clawsweeper Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 11:18 PM ET / July 12, 2026, 03:18 UTC.

Summary
The PR retains draft-preview ownership after failed deletion, compare-clears the deleted ID after success, and retries a retained unfinalized Discord preview during teardown.

PR surface: Source +3, Tests +78. Total +81 across 4 files.

Reproducibility: yes. The current-main source path, linked issue, and focused tests provide a high-confidence deterministic reproduction of ownership loss after a transient preview DELETE failure.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #104865
Summary: This PR is the direct candidate fix for the linked current-main Discord draft-cleanup bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Post a redacted live Discord transcript, logs, or recording showing one preview DELETE failure followed by successful teardown cleanup.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Focused regression tests and green CI are supplemental only; before merge, add a redacted live Discord transcript, runtime logs, or recording showing the first preview DELETE fail and the retained preview disappear on teardown retry. Updating the PR body should trigger a fresh review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Next step before merge

  • [P1] No code repair remains identified; contributor-supplied real Discord proof is required before normal maintainer merge review can complete.

Security
Cleared: The focused runtime and test patch changes no dependencies, permissions, credentials, downloads, publishing metadata, or other security-sensitive execution surfaces.

Review details

Best possible solution:

Merge the focused shared ownership fix and bounded Discord teardown retry after a redacted real Discord run demonstrates that a transient preview DELETE failure is followed by successful cleanup.

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

Yes. The current-main source path, linked issue, and focused tests provide a high-confidence deterministic reproduction of ownership loss after a transient preview DELETE failure.

Is this the best way to solve the issue?

Yes. The current head repairs ownership at the shared lifecycle boundary and adds exactly one Discord teardown retry without introducing duplicate final delivery, timers, configuration, or a parallel cleanup mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d0764f356603.

Label changes

Label justifications:

  • P2: The PR fixes a reproducible but limited Discord stale-preview regression that can leave conflicting visible content beside the final reply.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused regression tests and green CI are supplemental only; before merge, add a redacted live Discord transcript, runtime logs, or recording showing the first preview DELETE fail and the retained preview disappear on teardown retry. Updating the PR body should trigger a fresh review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +3, Tests +78. Total +81 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 9 6 +3
Tests 2 78 0 +78
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 87 6 +81

What I checked:

Likely related people:

  • vincentkoc: Current blame attributes the shared finalizable draft cleanup helper and surrounding lifecycle implementation to this contributor. (role: introduced shared lifecycle; confidence: high; commits: bbdb24a27851; files: src/channels/draft-stream-controls.ts)
  • davelutztx: Authored the merged fresh-final Discord change whose cleanup ordering exposed this regression. (role: introduced Discord behavior; confidence: high; commits: 8aaf9fc6bc5c; files: extensions/discord/src/monitor/message-handler.process.ts, extensions/discord/src/send.outbound.ts)
  • steipete: Major channel and plugin SDK refactors connect this contributor to the surrounding shared lifecycle and Discord ownership boundaries. (role: recent adjacent contributor; confidence: medium; commits: 62ddc9d9e0d9, 9ebe38b6e36b, 75c1bfbae8f8; files: src/plugin-sdk/channel-outbound.ts, extensions/discord/src/monitor/message-handler.process.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-12T02:40:49.369Z sha 179c301e5e6bf13b74cb5e69e10534e9ea00489e :: needs real behavior proof before merge. :: [P1] Retry retained previews during Discord teardown | [P1] Clear only the preview ID that was deleted

@LZY3538
LZY3538 force-pushed the codex/fix-104865-discord-draft-cleanup branch from 179c301 to e6ebf38 Compare July 12, 2026 02:59
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S and removed size: XS labels Jul 12, 2026
@LZY3538
LZY3538 force-pushed the codex/fix-104865-discord-draft-cleanup branch from e6ebf38 to 907fdea Compare July 12, 2026 03:06
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 12, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing as a duplicate of #104893 for #104865. Both branches implement the same delete-then-compare-clear ownership rule and the same single Discord teardown retry, but #104893 was opened first, is assigned for maintainer follow-through, uses the repository’s shared deferred-test helper, and includes focused cross-channel coverage plus live Discord fault-injection proof. This branch has no distinct runtime behavior to preserve. The underlying issue remains open on the canonical PR. Thanks for the careful concurrency coverage.

@steipete steipete added duplicate This issue or pull request already exists close:duplicate Closed as duplicate dedupe:child Duplicate issue/PR child in dedupe cluster labels Jul 13, 2026
@steipete steipete closed this Jul 13, 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 close:duplicate Closed as duplicate dedupe:child Duplicate issue/PR child in dedupe cluster duplicate This issue or pull request already exists P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Discord partial streaming forgets preview after cleanup failure

2 participants