Skip to content

refactor(slack): drive progress drafts through the shared compositor - #109336

Merged
steipete merged 2 commits into
mainfrom
feat/slack-compositor-port
Jul 16, 2026
Merged

steipete merged 2 commits into
mainfrom
feat/slack-compositor-port

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Slack was the last channel with a hand-rolled progress-draft pipeline: ~400 lines in dispatch.ts re-implementing the gate, tool-line merging, reasoning normalization, preamble routing, and plan snapshot state that Discord and Telegram already get from the shared compositor — with drift (preambles rendered as interleaved 💬 lines instead of the status headline; % 4 partial sampling; duplicated reasoning-merge helpers). Slack also edited the working draft into the final answer, which posts no new message (nothing re-notifies thread followers — the same reason Discord explicitly sends finals fresh), and it rotated four hardcoded "Reading the thread..." loading messages through the native status.

Why This Change Was Made

  • Compositor port: the status_final path now uses createChannelProgressDraftCompositor — preamble headline, reasoning lane, tool lines, plan checklist, and commentary arbitration behave identically to Discord/Telegram, and the duplicated Slack-local logic is deleted. Native task cards consume compositor snapshots (new read-only getSnapshot()), with a settled row-identity scheme: compositor line ids first, a fixed id for the rolling reasoning row, occurrence-suffixed content hashes last (stable across rolling-window shifts and duplicate-count transitions).
  • Fresh final + receipt collapse: successful progress-mode finals post as new messages that follow the draft's thread; the working draft is then edited into a compact receipt (🧠 2 thoughts · 🛠️ 5 tool calls · ⏱️ 42s, via a shared receipt tracker generalized from Discord's counters). Failed or error finals leave the draft untouched as the record of the turn.
  • No more rotating loading copy: the native thread status keeps the plain "is typing..." only.
  • Turn lifecycle hardening that fell out of review: queued and assistant-boundary re-arms reset delivery dedupe/tracker state; native completion status survives transient append failures so an errored turn can't be repainted as complete; a failed native rotation settles delivery bookkeeping before releasing the stream handle; a best-effort draft flush can never suppress the final send.

Partial/block modes keep their existing final behavior; the narrator, Discord/Telegram, and all config surfaces are untouched. Slack production LOC is net-negative despite the added behavior.

User Impact

In Slack progress mode the working draft reads like Discord/Telegram (agent-authored headline over the live checklist and activity), the final answer arrives as a fresh message in the same thread — so followers actually get notified — and the draft settles into a one-line activity receipt instead of being overwritten. The four fake rotating status messages are gone. Opt-ins (progress.commentary, toolProgress, nativeTaskCards, render: "rich", commandText) keep their documented behavior.

Evidence

  • Focused suites: slack dispatch.preview-fallback (120), progress-blocks (31), stream-mode + streaming + monitor.tool-result, compositor (35), channel streaming — 246 green in the final run; full tsgo 0 errors; oxlint shards clean; SDK surface gate green (budget notes in scripts/plugin-sdk-surface-report.mjs).
  • Trace fixtures regenerated for the loading-message removal only (verified line-by-line).
  • Structured autoreview (Codex gpt-5.6-sol, xhigh) across nine rounds; every accepted finding fixed with regression coverage (flush/final ordering, completion-status persistence, thread routing for fresh finals, turn-state resets, task-identity stability incl. singleton→duplicate transitions, non-work-tool gate admission, plan-explanation propagation to native titles and rich blocks, queued-rotation acknowledgements); remaining reports adjudicated against source with cited proof.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Jul 16, 2026

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 281f1c0c24

ℹ️ About Codex in GitHub

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

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

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

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

onReasoningEnd: onDraftBoundary,
onReasoningEnd: async () => {
progressReceipt.closeReasoning();
await onDraftBoundary?.();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Reset Slack reasoning state between bursts

When Slack is in progress/status-final mode, onReasoningEnd now only closes the receipt and delegates to onDraftBoundary, but that boundary calls beginNewProgressTurn() which returns false until a final reply has started or delivered. For separate reasoning items in one turn, such as onReasoningStream("<think>First</think>"), onReasoningEnd(), then onReasoningStream("<think>Second</think>"), the compositor's reasoning buffer is not reset, so the next burst is appended to the previous buffer (rendering stale/concatenated text like FirstSecond) instead of starting a fresh reasoning row as before. Reset the compositor's reasoning state on reasoning end before relying on the draft boundary.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the feat/slack-compositor-port branch from 281f1c0 to 6cd3582 Compare July 16, 2026 21:17
Slack's status_final progress path now uses the shared channel compositor
(preamble headline, reasoning, tools, plan checklist, commentary
arbitration) instead of its hand-rolled gate/merge/render pipeline, and
native task cards consume compositor snapshots with stable row identity
(line ids first, fixed reasoning id, occurrence-suffixed content hashes).
Finals in progress mode post as fresh messages that follow the draft's
thread; the working draft then collapses into a compact activity receipt,
while failed or error finals leave the draft as the turn record. The
rotating native loading messages are gone in favor of the plain typing
status. Queued and assistant-boundary turns re-arm with clean delivery
state, and native completion status survives transient append failures.
@steipete
steipete force-pushed the feat/slack-compositor-port branch from 6cd3582 to 6b371ce Compare July 16, 2026 21:19

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b371ce96e

ℹ️ About Codex in GitHub

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

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

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

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

.trim();
return {
// Reasoning snapshots replace one rolling row; text-based ids would orphan it each delta.
...(reasoning ? { id: "reasoning" } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Give native reasoning rows unique ids

When native Slack progress sees more than one reasoning burst separated by a tool call, the compositor intentionally keeps multiple 🧠 lines, but this mapper assigns every one the same reasoning id. The native task builder treats explicit ids as stable and does not occurrence-suffix them, so it emits multiple task_update chunks with the same Slack task id; because Slack task rows are keyed by id, the earlier reasoning row is overwritten/cannot be retired instead of appearing in arrival order.

Useful? React with 👍 / 👎.

renderProgressDraft();
const pushPlanProgress = async (steps?: AgentPlanStep[], explanation?: string) => {
if (streamMode === "status_final") {
await progressDraft.pushPlanProgress(steps, { explanation });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Schedule preamble expiry for plan explanations

In status-final Slack progress, a preamble followed by a plan update with an explanation before the preamble ages out now stores that explanation only through the compositor. The compositor's expiry refresh is scheduled only when narrationText exists, not when planExplanation exists, so if no later progress event arrives the draft/native title remains the stale preamble after PROGRESS_STATUS_PREAMBLE_FRESH_MS instead of switching to the plan explanation.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit bd9a996 into main Jul 16, 2026
192 of 194 checks passed
@steipete
steipete deleted the feat/slack-compositor-port branch July 16, 2026 21:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…penclaw#109336)

* test(slack): drop rotating loading-message fixture expectations

* refactor(slack): drive progress drafts through the shared compositor

Slack's status_final progress path now uses the shared channel compositor
(preamble headline, reasoning, tools, plan checklist, commentary
arbitration) instead of its hand-rolled gate/merge/render pipeline, and
native task cards consume compositor snapshots with stable row identity
(line ids first, fixed reasoning id, occurrence-suffixed content hashes).
Finals in progress mode post as fresh messages that follow the draft's
thread; the working draft then collapses into a compact activity receipt,
while failed or error finals leave the draft as the turn record. The
rotating native loading messages are gone in favor of the plain typing
status. Queued and assistant-boundary turns re-arm with clean delivery
state, and native completion status survives transient append failures.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…penclaw#109336)

* test(slack): drop rotating loading-message fixture expectations

* refactor(slack): drive progress drafts through the shared compositor

Slack's status_final progress path now uses the shared channel compositor
(preamble headline, reasoning, tools, plan checklist, commentary
arbitration) instead of its hand-rolled gate/merge/render pipeline, and
native task cards consume compositor snapshots with stable row identity
(line ids first, fixed reasoning id, occurrence-suffixed content hashes).
Finals in progress mode post as fresh messages that follow the draft's
thread; the working draft then collapses into a compact activity receipt,
while failed or error finals leave the draft as the turn record. The
rotating native loading messages are gone in favor of the plain typing
status. Queued and assistant-boundary turns re-arm with clean delivery
state, and native completion status survives transient append failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack maintainer Maintainer-authored PR scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant