Skip to content

fix(slack): keep thread typing across queued follow-up turns - #168544

Open
synthalorian wants to merge 4 commits into
openclaw:mainfrom
synthalorian:fix/issue-158350
Open

synthalorian wants to merge 4 commits into
openclaw:mainfrom
synthalorian:fix/issue-158350

Conversation

@synthalorian

@synthalorian synthalorian commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Slack thread status is per thread, but each inbound dispatch owned its own typing lifecycle. A mid-turn mention that cannot be steered (claude-cli) is parked and later runs as a queued follow-up. That follow-up reused the predecessor dispatch's typing controller. Core cleanup seals that controller, and the channel callbacks close with it, so the queued turn never publishes processing. A stop from the parked or finished dispatch can also publish active while another turn on the same thread is still the one that should look busy.

Why This Change Was Made

Admitted follow-ups now get a successor typing controller. The predecessor stays sealed. The successor reopens channel typing as a new generation, so a late stop from the sealed lifecycle cannot clear the new indicator. Slack session status uses the same generation: a parked pipeline that never published processing does not publish active, and a queued turn can publish processing again before its own visible output, then return to active when it finishes. Status writes are serialized, so a predecessor active request cannot take effect after the successor's processing request. A finished successor is not started again when that older request resolves. The existing visible-output gate still suppresses status once this turn itself has output.

User Impact

In a Slack thread, a message sent while the agent is already working no longer drops the native working indicator just because that message was parked. When that message later runs as its own turn, Slack shows the working status again until the turn finishes.

Evidence

Head: d4ba62ab06df9b544c5eacf7bd8d1d5a2cac75c1

Previous CI on 0573de80c75bfb19616c2d8ddc1c7bb13333262c failed in two jobs:

  • check-lint-core-3: src/channels/typing.ts:103:7: error: Function 'stopIfCurrent' expected no return value. (typescript(consistent-return))
  • checks-fast-baseline-ratchets: First-party mock factories must preserve real exports or explain isolation for the new follow-up lifecycle test. The same job also warned 1073 -> 1074 counted lines (cap 700) on src/auto-reply/reply/get-reply.ts.

Those are fixed without new suppressions. stopIfCurrent now always returns a promise. The lifecycle test spreads importOriginal. get-reply.ts no longer passes the silent-token default explicitly, so its counted lines move 1076 -> 1075 against current main. Local check:test-mock-exports and check:line-cap-ratchet against upstream/main passed. oxlint on the touched files is clean, including the extension tsconfig rule that rejected unbound test helpers.

Local publisher stub, no Slack Socket Mode and no user token. node --import ./scripts/tsx.mjs scripts/run-vitest.mjs src/auto-reply/reply/followup-runner.typing-lifecycle.test.ts extensions/slack/src/monitor/message-handler/thread-status.test.ts --maxWorkers=1 passed. The follow-up runner drove the stub and printed:

FOLLOWUP_EVENTS ["processing#0","active#0","processing#1","followup-started","active#1"]

A later stop and start on that sealed predecessor did not append another event. With the predecessor active write held until after the successor had started, settlement was ["processing","active","processing"]. When the successor also finished before that write resolved, settlement was ["processing","active","processing","active"], and a further stop published nothing.

The ordering regression fails on the previous cycle: while the delayed active write is still pending, the successor processing write is already in flight (expected 2 to be 1).

Maintainer decision still open: whether beginNextLifecycle should become a supported optional TypingCallbacks contract. Issue #158350 does not pin that public-API choice.

Fixes #158350

@clawsweeper

clawsweeper Bot commented Oct 10, 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.

@synthalorian

Copy link
Copy Markdown
Contributor Author

Proof for head 0573de80c75bfb19616c2d8ddc1c7bb13333262c.

Without the successor handoff, src/auto-reply/reply/followup-runner.typing-lifecycle.test.ts failed. The sealed controller produced start, stop, followup-started and never started or stopped typing for the admitted turn.

With the fix, node --import ./scripts/tsx.mjs scripts/test-projects.mts --maxWorkers=1 passed:

  • src/auto-reply/reply/followup-runner.typing-lifecycle.test.ts
  • src/auto-reply/reply/followup-runner.test.ts
  • src/auto-reply/reply/followup-turn-execution.test.ts
  • src/auto-reply/reply/typing-persistence.test.ts
  • src/auto-reply/reply/reply-dispatcher.typing-revive.test.ts
  • src/channels/typing.test.ts
  • extensions/slack/src/monitor/message-handler/thread-status.test.ts
  • extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts

git diff --check was clean. oxlint reported no issues on the touched files. No live Slack Socket Mode run was performed.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: L labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR gives admitted queued follow-ups fresh typing lifecycles and serializes their Slack session-status updates.

Example: A second Slack thread mention queues behind a running claude-cli turn.

  • Before: The queued turn inherits a sealed controller and never shows native working status.
  • After: The queued turn opens a successor lifecycle, publishes processing, and restores active when it finishes.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has useful lifecycle coverage and no open correctness finding, but publisher-stub output does not satisfy the external PR behavior-proof gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: An admitted queued Slack turn appears idle because its inherited typing lifecycle has already closed.
Reason: The remaining source-confirmed defect merits repair, but the chosen exported lifecycle extension needs an owner decision.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR repairs a source-confirmed queued-turn typing defect still present on current main, and the earlier status-ordering findings are resolved.

Priority: P2
Reviewed head: d4ba62ab06df9b544c5eacf7bd8d1d5a2cac75c1
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should beginNextLifecycle and the associated reply callback become supported public typing lifecycle contracts?
  • Recommendation: Approve and document the existing callback extension: Accept the optional generation opener on the existing typing owner and document successor opening, generation-specific cleanup, and behavior when the callback is absent.
  • Why: The exported callback shape expands the plugin contract, and neither the linked issue nor the available discussion contains an owner approval of that interface.

Before merge

  • Add real behavior proof - The supplied run exercises real follow-up and typing components with mocked admission, execution, delivery, and status publishers. Provide a recording or redacted logs through the shipped Slack Gateway showing a mid-turn claude-cli mention becoming a queued turn, successor processing before visible output, terminal active after completion or cancellation, and delayed-response ordering; also show successor typing on Telegram's Test Server. Redact IPs, API keys, phone numbers, and non-public endpoints. 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.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Tests

  • Low-value test src/auto-reply/reply/reply-dispatcher.typing-revive.test.ts: Remove the callback-identity assertion: it pins an internal forwarding detail without exercising successor start or cleanup behavior.
  • Missing end-to-end proof: Missing shipped Slack queued-successor proof covering processing before visible output, terminal cleanup and delayed status responses, plus Telegram Test Server proof of successor typing.
Agent review details

How this fits together

The shared reply pipeline converts admitted queued turns into channel typing callbacks; Slack translates those callbacks into thread session-status requests and activity reactions.

flowchart LR
  A[Slack inbound mention] --> B[Follow-up queue]
  B --> C[Turn admission]
  C --> D[Successor typing controller]
  D --> E[Channel typing lifecycle]
  E --> F[Slack status publisher]
  F --> G[Slack thread status]
Loading

Technical review

Best possible solution:

Keep successor typing with the existing lifecycle owners and preserve Slack's visible-output suppression and terminal sealing.

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

Current main demonstrably reuses a permanently sealed typing controller during queued execution; the contributor also reports a baseline lifecycle failure, while the historical immediate-clearing symptom is not established on current main.

Is this the best way to solve the issue?

A fresh controller for each admitted turn addresses the shared lifecycle cause, and serialized Slack writes resolve the earlier ordering defects without periodic status reconciliation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1c272f2ae919.

Provenance checked

  • Shared typing terminal cleanup keeps the original intent (4d4bdde: Finish admitted provider starts before terminal stop and prevent completed controllers from acquiring new timers.)
  • Canonical queued execution keeps the original intent (f8cc39c: Keep queued turns as adapters into canonical execution while retaining admission, presentation, delivery, and cleanup ownership.)
  • Slack session-status lifecycle keeps the original intent (b8e7b7b: Use native processing and active session states with synchronized titles and native Stop support.)
  • Slack terminal failure diagnostics keeps the original intent (5a36317: Report rejected terminal active writes after accepted processing without exposing private identifiers or preventing reaction cleanup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +181, Tests +405. Total +586 across 13 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 9 246 65 +181
Tests 4 405 0 +405
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 651 65 +586

Review metrics

Metric Value Why it matters
Production versus test LOC Production +246/-65; tests +405/-0 Production growth adds the Slack status owner and successor handoff; tests cover distinct ordering and lifecycle contracts, apart from one callback-identity assertion.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #158350
Summary: This PR targets the canonical report's source-confirmed queued-successor defect; neighboring work covers queued waiting feedback or completed-turn diagnostics.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Queued requests still execute, but missing working feedback makes an active conversation appear idle.
  • merge-risk: 🚨 compatibility: The PR extends an exported plugin typing callback contract whose supported lifecycle semantics still require an owner decision.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Shared successor lifecycle restoration reaches Telegram's sendTyping callback and changes the typing indicator during queued execution.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-10T17:06:11.896Z sha 0573de80c75bfb19616c2d8ddc1c7bb13333262c :: needs real behavior proof before merge. :: [P2] Order predecessor active writes before successor processing | [P2] Avoid restarting processing after the successor has finished
  • reviewed 2026-10-13T03:27:02.662Z sha 72fef3ca18dc3b943d0bb37061added9ba825ef2 :: needs real behavior proof before merge. :: none

Reviewed October 12, 2026, 11:39 PM ET / October 13, 2026, 03:39 UTC (Revision 3).

@synthalorian

Copy link
Copy Markdown
Contributor Author

Proof for head 72fef3ca18dc3b943d0bb37061added9ba825ef2.

No live Slack Socket Mode and no user token. The follow-up runner was driven with a local typing publisher stub:

node --import ./scripts/tsx.mjs scripts/run-vitest.mjs src/auto-reply/reply/followup-runner.typing-lifecycle.test.ts extensions/slack/src/monitor/message-handler/thread-status.test.ts --maxWorkers=1

That run passed. The runner printed:

FOLLOWUP_EVENTS ["processing#0","active#0","processing#1","followup-started","active#1"]

Generation 0 is the predecessor. After it was sealed, generation 1 published processing before followup-started, then active when that turn finished. A later stop and start on the sealed predecessor did not append an event.

Slack status settlement, with the predecessor active write held open:

  • Successor still running when that write resolved: ["processing","active","processing"]
  • Successor already finished, then a further stop: ["processing","active","processing","active"]

The second case does not republish processing. On the previous cycle, the same delayed-active test failed because the successor processing write was already in flight (expected 2 to be 1).

Previous CI on 0573de80c75bfb19616c2d8ddc1c7bb13333262c:

  • check-lint-core-3: src/channels/typing.ts:103:7: error: Function 'stopIfCurrent' expected no return value. (typescript(consistent-return))
  • checks-fast-baseline-ratchets: First-party mock factories must preserve real exports or explain isolation

Both are fixed without new suppressions. get-reply.ts counted lines are 1076 -> 1075 against current main, so the old 1073 -> 1074 line-cap warning is not repeated. Local mock-export and line-cap ratchets passed.

The maintainer decision is still open: whether beginNextLifecycle should be a supported optional TypingCallbacks contract. Issue #158350 does not pin that choice.

@synthalorian

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@synthalorian

Copy link
Copy Markdown
Contributor Author

Follow-up for head d4ba62ab06df9b544c5eacf7bd8d1d5a2cac75c1.

check-lint on 72fef3ca18dc3b943d0bb37061added9ba825ef2 failed:

extensions/slack/src/monitor/message-handler/thread-status.test.ts:62:43: error: Avoid referencing unbound methods which may cause unintentional scoping of this. (typescript(unbound-method))

The same rule failed at line 84. The status helpers are arrow functions now. node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/slack/src/monitor/message-handler/thread-status.test.ts reported 0 errors, and the status tests passed. The publisher-stub event order is unchanged from the proof above. check-lint-core-3 and checks-fast-baseline-ratchets had already passed on the previous head.

@synthalorian

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Admitted follow-ups reused a sealed typing controller, so Slack never showed
processing for the queued turn and a late stop could clear the thread.

Give each admitted turn its own typing lifecycle and status generation.
Serialize Slack session-status publishes so a predecessor active request
cannot land after the successor's processing, and do not republish
processing once that successor has finished.
Main replaced follow-up admission, so the successor typing test has to mock prepareReplyAgentTurn instead of the removed admitFollowupTurn path.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

[Bug]: Slack: mid-turn message clears the thread's 'is working' status, and follow-up turns never show typing (claude-cli)

1 participant