Skip to content

fix(discord): suppress typing when hooks silently handle a turn - #108449

Merged
steipete merged 4 commits into
openclaw:mainfrom
Yehonal:pr/discord-suppressed-turns-no-typing
Jul 16, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
Yehonal:pr/discord-suppressed-turns-no-typing

Conversation

@Yehonal

@Yehonal Yehonal commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discord could emit a typing indicator before shared before_dispatch hooks decided whether a turn should produce a reply. A hook returning { handled: true } could therefore leave users with a typing flash and no response.

Why This Change Was Made

Typing is an externally visible reply side effect. Shared dispatch already owns admission, so Discord feedback now starts only when that admitted lifecycle reaches onReplyStart. Silent pre-dispatch outcomes return before Discord allocates a feedback controller.

User Impact

Silently handled Discord turns no longer show a misleading typing indicator. Admitted normal replies and deliverable fast replies still show typing. typingMode: "never" and room-event suppression remain silent.

Summary

  • lazily create Discord typing feedback at the final reply target after admission;
  • preserve typing for admitted fast final replies that bypass the resolver callback;
  • delete preflight feedback preparation, queue-carried leases, retarget/restart helpers, and their dead tests;
  • add focused coverage for silent hooks, normal admission, fast replies, room events, never mode, repeated refresh, queue cleanup, and the shared dispatch boundary.

Root Cause

Discord preflight owned a second typing policy before the canonical reply-admission boundary. The previous PR revision tried to preserve that controller as an inactive queue lease, then replaced it at dispatch. That plumbing did not own a useful runtime state and duplicated policy already expressed by shared dispatch.

The rewritten implementation has one owner: shared dispatch admits the turn, then Discord creates transport feedback on demand.

Evidence

Automated validation

Current rewritten head 94d7c85c7b1a54db6256c4d0e57dc935f7de6dc8:

  • node scripts/run-vitest.mjs extensions/discord/src/monitor/message-handler.process.test.ts extensions/discord/src/monitor/message-handler.queue.test.ts extensions/discord/src/monitor/inbound-job.test.ts — 154 tests passed;
  • node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.test.ts — 269 tests passed;
  • node scripts/check-changed.mjs -- <touched paths> — format, API baseline, boundaries, core/extensions typechecks, core/extensions lint, and guards passed on Blacksmith Testbox;
  • node scripts/run-vitest.mjs extensions/discord/src/monitor/inbound-job.test.ts — 5 tests passed after removing the stale public export;
  • the focused follow-up changed gate passed on Blacksmith Testbox;
  • autoreview clean, no accepted/actionable findings on the final candidate or follow-up.

Real behavior proof

The original live Discord observer comparison used an exclusive scratch gateway and independent gateway-event observer. It demonstrated the behavioral invariant this rewrite preserves:

baseline suppressed case: typing=true, reply=false -> FAIL
patched suppressed case: typing=false, reply=false -> PASS
patched allowed control: typing=true, reply=true -> PASS

That observer run tested commit 67ff5db6b22ad91830e7fa61f3af65d0b82043a5. The rewritten current head removes the unused preflight/queue plumbing while current-head focused tests cover the same suppressed and admitted branches.

Security Impact

No authentication, authorization, permission, token-handling, or plugin-trust boundary changes. The fix removes an observable presence leak from silently handled turns.

Compatibility

  • no public API or configuration change;
  • no changelog edit on the contributor branch;
  • accepted direct messages, mentioned guild messages, and permitted commands retain typing through the admitted lifecycle;
  • room events and typingMode: "never" remain silent;
  • third-party plugins require no changes.

Risks

Typing begins after queueing and admission rather than during preflight. That later boundary is intentional: it prevents silent-turn leakage. Fast-final coverage preserves the early cue for admitted replies that bypass the normal resolver callback.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: M labels Jul 15, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 16, 2026, 5:10 AM ET / 09:10 UTC.

Summary
The PR defers Discord typing activation until shared reply suppression gates admit dispatch, while preserving typing for accepted fast replies that bypass the normal resolver lifecycle.

PR surface: Source +24, Tests +288. Total +312 across 6 files.

Reproducibility: yes. The PR provides a concrete scratch-plugin setup and real Discord baseline where a silent before_dispatch outcome produces TYPING_START without a reply.

Review metrics: none identified.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

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

Rank-up moves:

  • Update the PR body with a redacted live Discord run from 54afa50c3898f28e302022a10063f57997930855 showing the silent handled case and accepted fast-reply control.
  • [P1] Refresh against current main and let the required exact-head checks complete.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The live Discord observer output strongly proves the earlier head, but the force-pushed head adds accepted-fast-reply behavior and needs an updated redacted live run; updating the PR body should trigger review, or a maintainer can request @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.

Risk before merge

  • [P2] The live Discord evidence does not cover the current head's newly added fast-reply fallback, so the exact accepted-reply path is supported only by automated tests.
  • [P1] The branch is behind the current base and required exact-head checks are not green and complete; merge readiness must be re-evaluated after refresh without treating stale-base drift itself as a patch defect.

Maintainer options:

  1. Decide the mitigation before merge
    Land the lifecycle change after a current-head Discord run proves both that silent handled turns emit no typing and that accepted fast replies emit typing exactly once, with the refreshed head passing required checks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Wait for contributor-supplied exact-head Discord proof and refreshed required checks; there is no concrete code defect for an automated repair lane.

Security
Cleared: The diff changes Discord feedback timing and tests only; it does not broaden permissions, secrets access, dependency execution, authentication, or plugin trust boundaries.

Review details

Best possible solution:

Land the lifecycle change after a current-head Discord run proves both that silent handled turns emit no typing and that accepted fast replies emit typing exactly once, with the refreshed head passing required checks.

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

Yes. The PR provides a concrete scratch-plugin setup and real Discord baseline where a silent before_dispatch outcome produces TYPING_START without a reply.

Is this the best way to solve the issue?

Yes. Deferring the Discord-owned side effect until the shared reply-admission boundary preserves plugin-agnostic policy ownership, while the focused fast-reply fallback avoids a configuration workaround or duplicate hook policy.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The live Discord observer output strongly proves the earlier head, but the force-pushed head adds accepted-fast-reply behavior and needs an updated redacted live run; updating the PR body should trigger review, or a maintainer can request @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.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: This fixes misleading Discord typing for a bounded suppression path without evidence of message loss, outage, or broader channel failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The live Discord observer output strongly proves the earlier head, but the force-pushed head adds accepted-fast-reply behavior and needs an updated redacted live run; updating the PR body should trigger review, or a maintainer can request @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 +24, Tests +288. Total +312 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 52 28 +24
Tests 2 304 16 +288
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 356 44 +312

What I checked:

Likely related people:

  • Joseph: The PR records Joseph reviewing the isolated Discord before-and-after behavior and confirming both suppression and allowed-reply latency results. (role: behavior proof reviewer; confidence: low; files: extensions/discord/src/monitor/message-handler.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-16T04:11:51.430Z sha 67ff5db6b22ad91830e7fa61f3af65d0b82043a5 :: needs maintainer review before merge. :: none

@Yehonal
Yehonal force-pushed the pr/discord-suppressed-turns-no-typing branch from 67ff5db to 54afa50 Compare July 16, 2026 09:02
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 16, 2026
@steipete steipete self-assigned this Jul 16, 2026
@steipete
steipete force-pushed the pr/discord-suppressed-turns-no-typing branch from 54afa50 to 63204a8 Compare July 16, 2026 12:08
@openclaw-barnacle openclaw-barnacle Bot added size: L triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 16, 2026
@steipete
steipete force-pushed the pr/discord-suppressed-turns-no-typing branch from 63204a8 to 94d7c85 Compare July 16, 2026 12:22
@steipete

Copy link
Copy Markdown
Contributor

Maintainer deep review complete on 94d7c85c7b1a54db6256c4d0e57dc935f7de6dc8.

Rewritten head deletes the preflight/queue typing-feedback lease, creates Discord feedback lazily only after shared dispatch admission, preserves admitted fast-final typing, and removes the stale queue-key export.

Proof:

The PR-body Discord observer comparison remains the external behavior proof: suppressed turns emit neither typing nor reply; admitted controls emit both.

@steipete
steipete merged commit 175181f into openclaw:main Jul 16, 2026
119 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

Yehonal added a commit to Yehonal/openclaw that referenced this pull request Jul 16, 2026
…claw#108449)

* fix(discord): defer typing until reply dispatch is accepted

* fix(discord): preserve typing for accepted fast replies

* refactor(discord): create typing feedback after admission

* refactor(discord): keep queue key resolver internal

---------

Co-authored-by: Peter Steinberger <[email protected]>
Yehonal added a commit to Yehonal/openclaw that referenced this pull request Jul 16, 2026
…claw#108449)

* fix(discord): defer typing until reply dispatch is accepted

* fix(discord): preserve typing for accepted fast replies

* refactor(discord): create typing feedback after admission

* refactor(discord): keep queue key resolver internal

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…claw#108449)

* fix(discord): defer typing until reply dispatch is accepted

* fix(discord): preserve typing for accepted fast replies

* refactor(discord): create typing feedback after admission

* refactor(discord): keep queue key resolver internal

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…claw#108449)

* fix(discord): defer typing until reply dispatch is accepted

* fix(discord): preserve typing for accepted fast replies

* refactor(discord): create typing feedback after admission

* refactor(discord): keep queue key resolver internal

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

2 participants