Skip to content

fix: show typing while a queued follow-up turn runs - #201920

Merged
obviyus merged 4 commits into
openclaw:mainfrom
chessing234:fix/queued-followup-typing-201885
Nov 27, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
chessing234:fix/queued-followup-typing-201885

Conversation

@chessing234

@chessing234 chessing234 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: src/auto-reply/dispatch.ts:358-359 seals the source message's typing controller and src/auto-reply/reply/reply-dispatcher.ts:706-709 stops its channel typing callbacks (src/channels/typing.ts closed) when the enqueuing dispatch returns, and the queued follow-up turn reused both (agent-runner-run.ts createFollowupRunner typing, followup-turn-execution.ts defaults.typing), so its typing starts were no-ops.

Fixes #201885

What Problem This Solves

Fixes: a message that waits behind a running turn (queue mode followup, or a busy session) never shows "typing…" while the agent works on it, even though the docs promise typing once the model loop starts.

User Impact

User impact: a queued message now shows typing from the moment its own turn starts until its reply arrives, the same as a message sent to an idle session. typingMode: "never" and /stop behave as before.

Why This Change Was Made

Each queued turn now owns its typing: the follow-up runner builds a fresh typing controller per turn and stops it in the existing finally. An explicit typing start on the channel callbacks opens a new cycle instead of being ignored after an earlier stop; stops still win over in-flight keepalive ticks.

This replaces the earlier version of this PR, which kept the source controller open with hold/release flags. That skipped channel idle work (Feishu preview finalization), removed the typing pulse at enqueue, and could leave holds open in collect mode or on retries. Thanks @chessing234 for the PR and @Davidnovarro for the precise report.

Evidence

  • Live Telegram Test Server, real model (anthropic/claude-haiku-5-5), messages.queue.mode: "followup"; M1 runs a ~12 s exec, M2 is sent 3 s later; the QA userbot records the bot's typing updates. Details: fix: show typing while a queued follow-up turn runs #201920 (comment)
    • main (6d2cb03), twice: no typing between M1's reply and M2's reply (11.4 s and 10.8 s without typing).
    • this PR, twice: typing within 2 s of M2's turn start and every ≤6 s until its reply, none afterwards.
    • Controls: idle message shows typing on both builds; /stop during M2's turn ends typing; /stop while M2 waits shows no typing afterwards; typingMode: "never" shows none.
  • Regression in followup-runner.test.ts with real createTypingCallbacks: fails on main, still fails with only the runner change (the stopped callbacks ignore the start), passes with both.

Merge danger: two-way door. No stored state, config or contract change; a revert restores the old behavior. Blast radius: typing indicators for queued turns on all channels; channel plugins that call onReplyStart directly now restart typing after an earlier stop (checked: Discord, Matrix, Feishu, MS Teams and ACP call it only at turn or block start, before their own stop).

Source dispatch sealed the shared typing controller before the queued turn could start it.
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR retains the inbound typing lifecycle until a queued follow-up finishes.

Example: A Telegram follow-up queues at 14:02:53, starts at 14:03:38, and replies at 14:04:36.

  • Before: The source dispatch closes typing before the queued turn starts.
  • After: The retained controller can show typing during the queued turn and stop when it finishes.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful repair direction, but channel lifecycle regressions block correctness and supplied tests do not satisfy the real-behavior proof gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Telegram shows no working indicator during a queued follow-up's execution even though its final reply arrives.
Reason: Restoring the existing typing contract has clear user value and belongs in shared lifecycle ownership.

Merge readiness

⛔ Blocked before merge - 5 items remain

This PR addresses a current typing lifecycle bug and merits continued work, but it removes documented enqueue feedback and suppresses channel idle work beyond typing cleanup.

Priority: P2
Reviewed head: cc0a2162dae6c2f89a5750d929971b3e58115640

Before merge

  • Add real behavior proof - The added test exercises real controller, dispatcher, and channel-callback code with mocked start and stop functions and a manually applied hold; the supplied evidence does not exercise the patched queued runner through Telegram. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve custom channel idle finalization while holding typing (P1) - The hold skips resolvedOnIdle entirely, including explicitly supplied channel callbacks. Feishu supplies queueIdleSideEffects here, which closes streaming previews and settles deferred delivery receipts; its onCleanup only stops typing. When a queued follow-up opens that retained preview, the source idle callback has been skipped, and follow-up cleanup calls the controller directly without replaying channel idle work. The preview can remain open and deferred deliveries can remain unsettled. Preserve channel finalization independently of the typing hold.
  • Retain the documented enqueue-time typing signal (P2) - For an instant-mode message queued behind a live run, this replaces signalToolStart with a hold that sends no typing action. The user now receives no enqueue-time typing feedback while waiting. That signal was deliberately added in a3c9c09 and remains promised by https://docs.openclaw.ai/concepts/queue. Preserve the existing start signal while repairing its lifetime; the changed test currently asserts its removal.
  • Explain or restore the original intent of Enqueue-time typing - a3c9c09: Keep chat surfaces visibly busy when a follow-up waits behind a live run; the behavior remains documented.
  • Explain or restore the original intent of Dispatcher idle callbacks - 84c8209: Clear channel status after replies; subsequent delivery settlement work awaits channel idle before publishing settlement.

Findings

  • [P1] Preserve custom channel idle finalization while holding typing — src/auto-reply/reply/reply-dispatcher.ts:688-690
  • [P2] Retain the documented enqueue-time typing signal — src/auto-reply/reply/agent-runner-run.ts:376-379

Provenance

  • Enqueue-time typing changes intended behavior without addressing why it exists (a3c9c09: Keep chat surfaces visibly busy when a follow-up waits behind a live run; the behavior remains documented.)
  • Dispatcher idle callbacks changes intended behavior without addressing why it exists (84c8209: Clear channel status after replies; subsequent delivery settlement work awaits channel idle before publishing settlement.)

Tests

  • Missing end-to-end proof: Provide redacted post-fix Telegram evidence showing a queued follow-up start typing after source dispatch returns and stop after its reply, covering background-run and rejected-steering admission; redact IPs, API keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

Shared auto-reply dispatch creates a typing controller for each inbound message, passes it into queued execution, and connects its start and cleanup signals to channel callbacks.

flowchart TD
  A[Inbound channel message] --> B[Reply dispatcher]
  B --> C[Typing controller]
  B --> D[Follow-up queue]
  D --> E[Follow-up runner]
  E --> C
  C --> F[Channel typing callbacks]
Loading

Technical review

Best possible solution:

Transfer typing ownership through the existing queue lifecycle while preserving enqueue feedback, channel finalization, and terminal controller sealing.

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

The linked report and current source establish that dispatch completion disables both typing layers before queued execution reuses them; no live reproduction was run during this read-only review.

Is this the best way to solve the issue?

Keeping the existing lifecycle usable addresses the central cause, but the handoff must preserve channel idle side effects and the documented enqueue signal.

Full review comments:

  • [P1] Preserve custom channel idle finalization while holding typing — src/auto-reply/reply/reply-dispatcher.ts:688-690
    The hold skips resolvedOnIdle entirely, including explicitly supplied channel callbacks. Feishu supplies queueIdleSideEffects here, which closes streaming previews and settles deferred delivery receipts; its onCleanup only stops typing. When a queued follow-up opens that retained preview, the source idle callback has been skipped, and follow-up cleanup calls the controller directly without replaying channel idle work. The preview can remain open and deferred deliveries can remain unsettled. Preserve channel finalization independently of the typing hold.
    Confidence: 0.95
  • [P2] Retain the documented enqueue-time typing signal — src/auto-reply/reply/agent-runner-run.ts:376-379
    For an instant-mode message queued behind a live run, this replaces signalToolStart with a hold that sends no typing action. The user now receives no enqueue-time typing feedback while waiting. That signal was deliberately added in a3c9c09 and remains promised by https://docs.openclaw.ai/concepts/queue. Preserve the existing start signal while repairing its lifetime; the changed test currently asserts its removal.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0eb6488cd3ce.

Provenance checked

  • Controller completion and sealing changes intended behavior with a stated reason (d5f0889: Stop typing after both execution and dispatch finish; later history preserves sealing against late callbacks.)
  • Follow-up terminal cleanup keeps the original intent (bc3092f: Release source admission and complete operation and typing cleanup through the existing finally boundary.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/auto-reply/reply/queued-followup-typing.test.ts src/auto-reply/reply/followup-runner.test.ts src/auto-reply/reply/reply-utils.test.ts src/auto-reply/reply/typing-persistence.test.ts src/channels/typing.test.ts --maxWorkers=1
  • pnpm test src/auto-reply/dispatch.test.ts extensions/feishu/src/reply-dispatcher.test.ts --maxWorkers=1
  • Verify the focused lifecycle regressions fail on the pinned base and pass with the repair.
  • Run the affected runReplyAgent integration suite and targeted typecheck, lint, and formatting checks.

What I checked:

Likely related people:

  • Josh Avant: Raw commit bc3092f adds src/auto-reply/reply/followup-runner.ts:512 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bc3092fceb5d; files: src/auto-reply/reply/followup-runner.ts)
  • Vincent Koc: Raw commit 9fe59d5 adds src/auto-reply/reply/reply-dispatcher.ts:213 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 9fe59d5e7ef0; files: src/auto-reply/reply/reply-dispatcher.ts)

PR surface

Source +26, Tests +46. Total +72 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 33 7 +26
Tests 3 49 3 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 82 10 +72

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The reported queued replies arrive, but missing typing makes working turns appear idle.
  • merge-risk: 🚨 compatibility: The shared dispatcher changes existing channel onIdle behavior, including Feishu streaming finalization.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 11:25 AM ET / 16:25 UTC.

@clawsweeper

clawsweeper Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: applying reviewed decision.

I am applying the reviewed decision for this pull request: fix: show typing for a queued Telegram follow-up This is item 1/1 in the current shard. Shard 1/1.

This transient lease prevents a newer review from overlapping label, comment, or close mutations.

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

@chessing234

Copy link
Copy Markdown
Contributor Author

@steipete shows typing for a queued Telegram follow-up.

1 similar comment
@chessing234

Copy link
Copy Markdown
Contributor Author

@steipete shows typing for a queued Telegram follow-up.

The source dispatch seals its typing controller and stops the channel
typing callbacks when it returns on enqueue, so the queued turn reused a
closed lifecycle and never showed typing. Each queued turn now builds its
own controller, and an explicit channel typing start opens a new cycle.

Replaces the hold/release controller flags, which skipped channel idle
work (Feishu) and removed the enqueue typing pulse.
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Legend: base-* = main 6d2cb03, cand-* = this PR.

Live Telegram proof (Telegram Test Server, real user account, real model anthropic/claude-haiku-5-5, messages.queue.mode: "followup").

M1 runs sleep 12 && echo M1DONE with the exec tool; M2 (sleep 8 && echo M2DONE) is sent 3 s later and waits behind it. Times are seconds from the start of recording. bot sendChatAction is every typing refresh the bot sent (Bot API proxy log); userbot typing-on is when the user's Telegram client saw typing switch on.

base-queue-r1
  userbot typing-on (s): 4.2, 10.4, 16.8
  bot sendChatAction (s): 4.0, 8.2, 10.2, 16.0, 20.3
  M1 reply 21.4s  M2 reply 32.9s  /stop -
  M2 turn (M1 reply -> M2 reply): 0 sendChatAction, max gap 11.4s; userbot typing-on 0
  later than 6 s after M2 reply: sendChatAction 0, userbot typing-on 0
base-queue-r2
  userbot typing-on (s): 4.4, 9.3
  bot sendChatAction (s): 4.3, 9.2, 12.4, 16.4, 20.9
  M1 reply 22.2s  M2 reply 33.0s  /stop -
  M2 turn (M1 reply -> M2 reply): 0 sendChatAction, max gap 10.8s; userbot typing-on 0
  later than 6 s after M2 reply: sendChatAction 0, userbot typing-on 0
base-idle-r1
  userbot typing-on (s): 4.2, 9.0
  bot sendChatAction (s): 4.0, 8.8, 12.2, 16.5
  M1 reply 17.7s  M2 reply -  /stop -
  later than 6 s after M1 reply: sendChatAction 0, userbot typing-on 0
cand-queue-r1
  userbot typing-on (s): 4.4, 9.3, 22.3, 26.4
  bot sendChatAction (s): 4.2, 9.1, 12.4, 16.4, 22.1, 26.3, 30.3
  M1 reply 20.3s  M2 reply 32.5s  /stop -
  M2 turn (M1 reply -> M2 reply): 3 sendChatAction, max gap 4.2s; userbot typing-on 2
  later than 6 s after M2 reply: sendChatAction 0, userbot typing-on 0
cand-queue-r2
  userbot typing-on (s): 5.0, 13.5, 27.2, 31.4
  bot sendChatAction (s): 4.8, 9.0, 13.3, 17.0, 21.0, 27.1, 31.2, 35.2
  M1 reply 25.3s  M2 reply 38.1s  /stop -
  M2 turn (M1 reply -> M2 reply): 3 sendChatAction, max gap 4.2s; userbot typing-on 2
  later than 6 s after M2 reply: sendChatAction 0, userbot typing-on 0
cand-idle-r1
  userbot typing-on (s): 4.8, 9.9, 17.1
  bot sendChatAction (s): 4.7, 9.7, 10.7, 16.7
  M1 reply 18.8s  M2 reply -  /stop -
  later than 6 s after M1 reply: sendChatAction 0, userbot typing-on 0
cand-stop-turn-r1
  userbot typing-on (s): 4.7, 10.9, 17.0, 23.9, 28.1
  bot sendChatAction (s): 4.5, 8.7, 10.7, 16.5, 20.7, 23.7, 27.9, 31.9, 35.9, 39.9, 43.9
  M1 reply 21.9s  M2 reply -  /stop 45.2s
  later than 6 s after /stop: sendChatAction 0, userbot typing-on 0
  after M1 reply: sendChatAction 6
cand-stop-wait-r1
  userbot typing-on (s): 6.0, 10.3
  bot sendChatAction (s): 4.5, 10.2
  M1 reply -  M2 reply -  /stop 12.3s
  later than 6 s after /stop: sendChatAction 0, userbot typing-on 0
cand-never-r1
  userbot typing-on (s): none
  bot sendChatAction (s): none
  M1 reply 21.1s  M2 reply 32.6s  /stop -
  M2 turn (M1 reply -> M2 reply): 0 sendChatAction, max gap 11.5s; userbot typing-on 0
  later than 6 s after M2 reply: sendChatAction 0, userbot typing-on 0
  • main (6d2cb03), twice: nothing between M1's reply and M2's reply (11.4 s and 10.8 s without typing).
  • this PR, twice: typing about 2 s after M2's turn starts, refreshed at most 4.2 s apart until its reply, none afterwards.
  • Controls: an idle message shows typing on both builds; /stop during M2's turn ends typing (last refresh 1.3 s before /stop); /stop while M2 waits aborts M1 and drops M2 with no typing afterwards; typingMode: "never" sends no typing.

Regression test followup-runner.test.ts (real createTypingCallbacks): fails on main, still fails with only the per-turn controller (the stopped callbacks ignore the start), passes with both changes.

@obviyus obviyus changed the title fix: show typing for a queued Telegram follow-up fix: show typing while a queued follow-up turn runs Nov 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Nov 27, 2026
@obviyus
obviyus merged commit f3a62f7 into openclaw:main Nov 27, 2026
131 of 133 checks passed
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Landed in f3a62f7. A Telegram message that waits behind a running turn now shows typing while its own turn runs, until its reply arrives. Each queued turn starts and stops its own typing, so nothing stays stuck after a cancel or a reply. Thanks @chessing234 for the PR and @Davidnovarro for the report in #201885. We replaced the approach in commits on top of yours: a fresh typing controller per queued turn instead of holding the first one open.

github-actions Bot pushed a commit to SharonZ92901/openclaw that referenced this pull request Nov 27, 2026
Root cause: src/auto-reply/dispatch.ts:358-359 seals the source message's typing controller and src/auto-reply/reply/reply-dispatcher.ts:706-709 stops its channel typing callbacks (src/channels/typing.ts `closed`) when the enqueuing dispatch returns, and the queued follow-up turn reused both (agent-runner-run.ts createFollowupRunner `typing`, followup-turn-execution.ts `defaults.typing`), so its typing starts were no-ops.

Fixes #201885

## What Problem This Solves

Fixes: a message that waits behind a running turn (queue mode `followup`, or a busy session) never shows "typing…" while the agent works on it, even though the docs promise typing once the model loop starts.

## User Impact

User impact: a queued message now shows typing from the moment its own turn starts until its reply arrives, the same as a message sent to an idle session. `typingMode: "never"` and `/stop` behave as before.

## Why This Change Was Made

Each queued turn now owns its typing: the follow-up runner builds a fresh typing controller per turn and stops it in the existing `finally`. An explicit typing start on the channel callbacks opens a new cycle instead of being ignored after an earlier stop; stops still win over in-flight keepalive ticks.

This replaces the earlier version of this PR, which kept the source controller open with hold/release flags. That skipped channel idle work (Feishu preview finalization), removed the typing pulse at enqueue, and could leave holds open in collect mode or on retries. Thanks @chessing234 for the PR and @Davidnovarro for the precise report.

## Evidence

- Live Telegram Test Server, real model (anthropic/claude-haiku-5-5), `messages.queue.mode: "followup"`; M1 runs a ~12 s exec, M2 is sent 3 s later; the QA userbot records the bot's typing updates. Details: openclaw/openclaw#201920 (comment)
  - main (6d2cb0379cb6), twice: no typing between M1's reply and M2's reply (11.4 s and 10.8 s without typing).
  - this PR, twice: typing within 2 s of M2's turn start and every ≤6 s until its reply, none afterwards.
  - Controls: idle message shows typing on both builds; `/stop` during M2's turn ends typing; `/stop` while M2 waits shows no typing afterwards; `typingMode: "never"` shows none.
- Regression in `followup-runner.test.ts` with real `createTypingCallbacks`: fails on main, still fails with only the runner change (the stopped callbacks ignore the start), passes with both.

Merge danger: two-way door. No stored state, config or contract change; a revert restores the old behavior. Blast radius: typing indicators for queued turns on all channels; channel plugins that call `onReplyStart` directly now restart typing after an earlier stop (checked: Discord, Matrix, Feishu, MS Teams and ACP call it only at turn or block start, before their own stop).

Co-authored-by: Ayaan Zaidi <[email protected]>
vincentkoc added a commit that referenced this pull request Nov 27, 2026
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (2115 commits)
  fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485)
  fix(ci): update iOS screenshot reducer gate (#206497)
  fix: keep chat photo previews sharp within their byte limits (#206461)
  fix: let agents use short Workboard card IDs
  fix(tui): run provider sign-in in the local TUI (#200605)
  improve(config): reduce repeated directory checks for larger agent rosters (#206494)
  perf(test): reuse the Periphery producer workflow snapshot (#189681)
  fix(ci): keep locale assets within the installed package budget (#206492)
  fix: preserve failed Apple chat messages across partial history pages (#205404)
  improve: avoid merging unrelated settings for agent directory lookups (#206489)
  fix: show typing while a queued follow-up turn runs (#201920)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  ...
vincentkoc added a commit that referenced this pull request Nov 27, 2026
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (923 commits)
  fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485)
  fix(ci): update iOS screenshot reducer gate (#206497)
  fix: keep chat photo previews sharp within their byte limits (#206461)
  fix: let agents use short Workboard card IDs
  fix(tui): run provider sign-in in the local TUI (#200605)
  improve(config): reduce repeated directory checks for larger agent rosters (#206494)
  perf(test): reuse the Periphery producer workflow snapshot (#189681)
  fix(ci): keep locale assets within the installed package budget (#206492)
  fix: preserve failed Apple chat messages across partial history pages (#205404)
  improve: avoid merging unrelated settings for agent directory lookups (#206489)
  fix: show typing while a queued follow-up turn runs (#201920)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
Root cause: src/auto-reply/dispatch.ts:358-359 seals the source message's typing controller and src/auto-reply/reply/reply-dispatcher.ts:706-709 stops its channel typing callbacks (src/channels/typing.ts `closed`) when the enqueuing dispatch returns, and the queued follow-up turn reused both (agent-runner-run.ts createFollowupRunner `typing`, followup-turn-execution.ts `defaults.typing`), so its typing starts were no-ops.

Fixes openclaw#201885

## What Problem This Solves

Fixes: a message that waits behind a running turn (queue mode `followup`, or a busy session) never shows "typing…" while the agent works on it, even though the docs promise typing once the model loop starts.

## User Impact

User impact: a queued message now shows typing from the moment its own turn starts until its reply arrives, the same as a message sent to an idle session. `typingMode: "never"` and `/stop` behave as before.

## Why This Change Was Made

Each queued turn now owns its typing: the follow-up runner builds a fresh typing controller per turn and stops it in the existing `finally`. An explicit typing start on the channel callbacks opens a new cycle instead of being ignored after an earlier stop; stops still win over in-flight keepalive ticks.

This replaces the earlier version of this PR, which kept the source controller open with hold/release flags. That skipped channel idle work (Feishu preview finalization), removed the typing pulse at enqueue, and could leave holds open in collect mode or on retries. Thanks @chessing234 for the PR and @Davidnovarro for the precise report.

## Evidence

- Live Telegram Test Server, real model (anthropic/claude-haiku-5-5), `messages.queue.mode: "followup"`; M1 runs a ~12 s exec, M2 is sent 3 s later; the QA userbot records the bot's typing updates. Details: openclaw#201920 (comment)
  - main (7e9dc4d), twice: no typing between M1's reply and M2's reply (11.4 s and 10.8 s without typing).
  - this PR, twice: typing within 2 s of M2's turn start and every ≤6 s until its reply, none afterwards.
  - Controls: idle message shows typing on both builds; `/stop` during M2's turn ends typing; `/stop` while M2 waits shows no typing afterwards; `typingMode: "never"` shows none.
- Regression in `followup-runner.test.ts` with real `createTypingCallbacks`: fails on main, still fails with only the runner change (the stopped callbacks ignore the start), passes with both.

Merge danger: two-way door. No stored state, config or contract change; a revert restores the old behavior. Blast radius: typing indicators for queued turns on all channels; channel plugins that call `onReplyStart` directly now restart typing after an earlier stop (checked: Discord, Matrix, Feishu, MS Teams and ACP call it only at turn or block start, before their own stop).

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 29, 2026
…162684)

Root cause: src/auto-reply/reply/agent-runner-run.ts:376 starts typing for an input queued behind an active turn on the enqueuing dispatch's own typing controller, and src/auto-reply/dispatch.ts:358-359 seals that controller (and the channel typing callbacks) when the dispatch returns a few hundred ms later, so nothing types for the rest of the wait.

Fixes #162547

Thanks @AXEG0 for the detailed report and logs, and @jayzhou2309 for the original fix and its analysis of the sealed controller.

## What Problem This Solves

A Telegram DM that queues behind a turn already running in the same session (an announce-started run, an operator turn, `messages.queue.mode: "followup"`) shows "typing…" for at most one pulse, then nothing until its own turn starts. `docs/concepts/queue.md` says typing fires on enqueue and stays on while the run waits its turn.

## Why This Change Was Made

The queued input now owns its typing for the wait, the same way it already owns typing for its own turn since #201920:

- `createFollowupTyping` (`followup-runner.ts`) builds a typing controller from the channel's existing typing callbacks (`onReplyStart` / `onTypingCleanup`). The follow-up runner already did this per turn; it now calls the same function.
- On enqueue behind an active turn, `runReplyAgent` starts that controller (respecting the typing mode, as before) and stops it when the active owner clears (`runAfterReplyOperationClear`, the same point that schedules the queue drain, so the queued turn's own typing takes over) or when the queued input settles first (`controllerInput.settlement`: `/stop`, queue clear, queue-cap drop). The enqueuing dispatch's own controller is cleaned up as before.

This replaces the earlier dispatcher handoff (an `onTypingHandoff` callback returned from `createReplyDispatcherWithTyping`, a per-run typing field on `FollowupRun` and dispatcher idle deferral). `createReplyDispatcherWithTyping` is a public Plugin SDK export, so that callback escaped Core. Nothing changes in the dispatcher, the SDK or plugin-facing types now; channels without typing callbacks get a no-op controller.

## User Impact

A message waiting behind a busy session shows typing from enqueue until its turn starts, then its own turn's typing takes over until the reply is sent. Messages that do not queue, `typingMode: "never"`, and channels without typing are unchanged. Typing stops on `/stop` or when the queued input is dropped.

## Evidence

Live Telegram Test Server (telegram-e2e-userbot, real QA user, mock provider that holds every model call until a release at 90 s). An operator CLI turn runs in `agent:main:main` from 0 s (no Telegram typing), `messages.queue.mode: "followup"`, the DM is sent at 30 s and queues behind it. Full timelines: #162684 (comment)

| run | DM queued at | sendChatAction during the wait | max gap in the wait | after the reply |
|---|---|---|---|---|
| main #1 | 30.2 s | 1 (at enqueue) | 59.2 s | none |
| main #2 | 30.3 s | 1 (at enqueue) | 58.5 s | none |
| this PR #1 | 30.2 s | 15 | 6.0 s | none |
| this PR #2 | 30.3 s | 14 | 8.0 s | none |
| this PR, slow queued turn | 30.3 s | 14, then the queued turn's own typing at 94.9/99.0/103.0 s | 7.3 s | none after the 106.1 s reply |
| main, slow queued turn | 30.2 s | 1 | 59.2 s | none |

Controls on this PR: a DM with no active turn behaves as on main (one typing, reply, nothing after); `/stop` while the DM waits ends typing (last 49.3 s, stop reply 50.6 s, nothing after); `typingMode: "never"` sends no typing; queue cap 1 with `drop: "old"` keeps a single typing stream when the second DM drops the first, and nothing after the reply.

Regression: `agent-runner.runreplyagent.followup-drain.cases.ts` "types for a queued input past its dispatch until the active owner clears / the queued input is cleared": fails on main (channel `onReplyStart` called 0 times), passes here.

Merge danger: two-way door. No stored state, config, schema or contract change; a revert restores the old single pulse. Blast radius: typing indicators for inputs queued behind an active turn, on channels with typing callbacks.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…162684)

Root cause: src/auto-reply/reply/agent-runner-run.ts:376 starts typing for an input queued behind an active turn on the enqueuing dispatch's own typing controller, and src/auto-reply/dispatch.ts:358-359 seals that controller (and the channel typing callbacks) when the dispatch returns a few hundred ms later, so nothing types for the rest of the wait.

Fixes #162547

Thanks @AXEG0 for the detailed report and logs, and @jayzhou2309 for the original fix and its analysis of the sealed controller.

A Telegram DM that queues behind a turn already running in the same session (an announce-started run, an operator turn, `messages.queue.mode: "followup"`) shows "typing…" for at most one pulse, then nothing until its own turn starts. `docs/concepts/queue.md` says typing fires on enqueue and stays on while the run waits its turn.

The queued input now owns its typing for the wait, the same way it already owns typing for its own turn since #201920:

- `createFollowupTyping` (`followup-runner.ts`) builds a typing controller from the channel's existing typing callbacks (`onReplyStart` / `onTypingCleanup`). The follow-up runner already did this per turn; it now calls the same function.
- On enqueue behind an active turn, `runReplyAgent` starts that controller (respecting the typing mode, as before) and stops it when the active owner clears (`runAfterReplyOperationClear`, the same point that schedules the queue drain, so the queued turn's own typing takes over) or when the queued input settles first (`controllerInput.settlement`: `/stop`, queue clear, queue-cap drop). The enqueuing dispatch's own controller is cleaned up as before.

This replaces the earlier dispatcher handoff (an `onTypingHandoff` callback returned from `createReplyDispatcherWithTyping`, a per-run typing field on `FollowupRun` and dispatcher idle deferral). `createReplyDispatcherWithTyping` is a public Plugin SDK export, so that callback escaped Core. Nothing changes in the dispatcher, the SDK or plugin-facing types now; channels without typing callbacks get a no-op controller.

A message waiting behind a busy session shows typing from enqueue until its turn starts, then its own turn's typing takes over until the reply is sent. Messages that do not queue, `typingMode: "never"`, and channels without typing are unchanged. Typing stops on `/stop` or when the queued input is dropped.

Live Telegram Test Server (telegram-e2e-userbot, real QA user, mock provider that holds every model call until a release at 90 s). An operator CLI turn runs in `agent:main:main` from 0 s (no Telegram typing), `messages.queue.mode: "followup"`, the DM is sent at 30 s and queues behind it. Full timelines: #162684 (comment)

| run | DM queued at | sendChatAction during the wait | max gap in the wait | after the reply |
|---|---|---|---|---|
| main #1 | 30.2 s | 1 (at enqueue) | 59.2 s | none |
| main #2 | 30.3 s | 1 (at enqueue) | 58.5 s | none |
| this PR #1 | 30.2 s | 15 | 6.0 s | none |
| this PR #2 | 30.3 s | 14 | 8.0 s | none |
| this PR, slow queued turn | 30.3 s | 14, then the queued turn's own typing at 94.9/99.0/103.0 s | 7.3 s | none after the 106.1 s reply |
| main, slow queued turn | 30.2 s | 1 | 59.2 s | none |

Controls on this PR: a DM with no active turn behaves as on main (one typing, reply, nothing after); `/stop` while the DM waits ends typing (last 49.3 s, stop reply 50.6 s, nothing after); `typingMode: "never"` sends no typing; queue cap 1 with `drop: "old"` keeps a single typing stream when the second DM drops the first, and nothing after the reply.

Regression: `agent-runner.runreplyagent.followup-drain.cases.ts` "types for a queued input past its dispatch until the active owner clears / the queued input is cleared": fails on main (channel `onReplyStart` called 0 times), passes here.

Merge danger: two-way door. No stored state, config, schema or contract change; a revert restores the old single pulse. Blast radius: typing indicators for inputs queued behind an active turn, on channels with typing callbacks.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 6e0f49f)

Release adaptation: the stable runner supplies its turn defaults inside executeFollowup; create fresh typing for the queued dispatch route while preserving injected controllers on other callers. PR-number mention hits are unrelated and no later same-path commits were found.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 30, 2026
…penclaw#162684)

Root cause: src/auto-reply/reply/agent-runner-run.ts:376 starts typing for an input queued behind an active turn on the enqueuing dispatch's own typing controller, and src/auto-reply/dispatch.ts:358-359 seals that controller (and the channel typing callbacks) when the dispatch returns a few hundred ms later, so nothing types for the rest of the wait.

Fixes openclaw#162547

Thanks @AXEG0 for the detailed report and logs, and @jayzhou2309 for the original fix and its analysis of the sealed controller.

## What Problem This Solves

A Telegram DM that queues behind a turn already running in the same session (an announce-started run, an operator turn, `messages.queue.mode: "followup"`) shows "typing…" for at most one pulse, then nothing until its own turn starts. `docs/concepts/queue.md` says typing fires on enqueue and stays on while the run waits its turn.

## Why This Change Was Made

The queued input now owns its typing for the wait, the same way it already owns typing for its own turn since openclaw#201920:

- `createFollowupTyping` (`followup-runner.ts`) builds a typing controller from the channel's existing typing callbacks (`onReplyStart` / `onTypingCleanup`). The follow-up runner already did this per turn; it now calls the same function.
- On enqueue behind an active turn, `runReplyAgent` starts that controller (respecting the typing mode, as before) and stops it when the active owner clears (`runAfterReplyOperationClear`, the same point that schedules the queue drain, so the queued turn's own typing takes over) or when the queued input settles first (`controllerInput.settlement`: `/stop`, queue clear, queue-cap drop). The enqueuing dispatch's own controller is cleaned up as before.

This replaces the earlier dispatcher handoff (an `onTypingHandoff` callback returned from `createReplyDispatcherWithTyping`, a per-run typing field on `FollowupRun` and dispatcher idle deferral). `createReplyDispatcherWithTyping` is a public Plugin SDK export, so that callback escaped Core. Nothing changes in the dispatcher, the SDK or plugin-facing types now; channels without typing callbacks get a no-op controller.

## User Impact

A message waiting behind a busy session shows typing from enqueue until its turn starts, then its own turn's typing takes over until the reply is sent. Messages that do not queue, `typingMode: "never"`, and channels without typing are unchanged. Typing stops on `/stop` or when the queued input is dropped.

## Evidence

Live Telegram Test Server (telegram-e2e-userbot, real QA user, mock provider that holds every model call until a release at 90 s). An operator CLI turn runs in `agent:main:main` from 0 s (no Telegram typing), `messages.queue.mode: "followup"`, the DM is sent at 30 s and queues behind it. Full timelines: openclaw#162684 (comment)

| run | DM queued at | sendChatAction during the wait | max gap in the wait | after the reply |
|---|---|---|---|---|
| main #1 | 30.2 s | 1 (at enqueue) | 59.2 s | none |
| main #2 | 30.3 s | 1 (at enqueue) | 58.5 s | none |
| this PR #1 | 30.2 s | 15 | 6.0 s | none |
| this PR #2 | 30.3 s | 14 | 8.0 s | none |
| this PR, slow queued turn | 30.3 s | 14, then the queued turn's own typing at 94.9/99.0/103.0 s | 7.3 s | none after the 106.1 s reply |
| main, slow queued turn | 30.2 s | 1 | 59.2 s | none |

Controls on this PR: a DM with no active turn behaves as on main (one typing, reply, nothing after); `/stop` while the DM waits ends typing (last 49.3 s, stop reply 50.6 s, nothing after); `typingMode: "never"` sends no typing; queue cap 1 with `drop: "old"` keeps a single typing stream when the second DM drops the first, and nothing after the reply.

Regression: `agent-runner.runreplyagent.followup-drain.cases.ts` "types for a queued input past its dispatch until the active owner clears / the queued input is cleared": fails on main (channel `onReplyStart` called 0 times), passes here.

Merge danger: two-way door. No stored state, config, schema or contract change; a revert restores the old single pulse. Blast radius: typing indicators for inputs queued behind an active turn, on channels with typing callbacks.

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

Labels

gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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]: Telegram queued follow-up turn never shows typing (source dispatch seals the shared typing controller)

2 participants