Commit Graph

7 Commits

Author SHA1 Message Date
Alem Tuzlak d85abb781d fix(bot-slack): native setStatus thinking indicator instead of hourglass (#5698)
## What

Replaces the homemade animated `⏳` "thinking"
placeholder (a posted message whose dots cycled via `setInterval`) with
Slack's **native** `assistant.threads.setStatus` "is thinking…"
indicator — and generalizes it from assistant-pane-only to **every
thread-anchored reply**: channel @-mentions, channel threads, DMs, and
the pane.

## Why

The hourglass was an extra post-then-delete message that looked nothing
like the native loading state other Slack agents show. Slack has since
relaxed `assistant.threads.setStatus` to accept the ordinary
**`chat:write`** scope (not just `assistant:write`), specifically so
channel-based apps can show AI loading states in channels and DMs
([docs](https://docs.slack.dev/reference/methods/assistant.threads.setStatus/)).
The adapter already used `setStatus` for the pane — this just extends it
everywhere and deletes the placeholder.

## How

- **`event-renderer.ts`** — delete the hourglass machinery
(`startThinking`/`claimThinking`/`clearThinking`/`setInterval`);
generalize `setPaneStatus`/`clearPaneStatus` →
`setStatus`/`clearStatus`. New `status?: { threadTs, isPane, config }`
arg: `statusMode` drives the thinking indicator; `isPane` only selects
tool-progress surface (pane composer status vs `task_update` timeline /
`🔧` rows — both unchanged).
- **`adapter.ts`** — `createRunRenderer` builds `status` for any target
with a thread anchor (`threadTs ?? statusTs`); `assistant: false` opts
out everywhere.
- **`types.ts` / `slack-listener.ts`** — flat DMs (no `thread_ts`) carry
the inbound message `ts` as the status anchor; replies still post flat.
- **README** — document the broadened status + the `chat:write`
relaxation.

## Testing

- `nx run-many -t test build` for `bot-slack` — **248 tests pass**,
build clean, oxlint 0 errors, oxfmt clean.
- New tests cover non-pane channel-thread status, the `🔧` tool
path staying on non-pane, and the DM `statusTs` anchor.
- Net **−149 lines**.

> Note: the DM path anchors `setStatus` to a non-assistant DM message ts
— the one piece only verifiable against the live Slack API. Channel
@-mentions already carry a real `thread_ts`.
2026-06-25 16:09:13 +02:00
Alem Tuzlak b3680616f4 fix(bot-slack): use native setStatus thinking indicator instead of hourglass
Replace the homemade animated ⏳ placeholder (a posted
message with setInterval-cycled dots) with Slack's native
assistant.threads.setStatus "is thinking..." indicator on every thread-anchored
reply -- channel @-mentions, channel threads, DMs, and the assistant pane -- not
just the pane. Slack now accepts setStatus under chat:write (not only
assistant:write), so it works for channel-based apps. Flat DMs carry the inbound
message ts as the status anchor. assistant:false opts out everywhere.
2026-06-25 15:34:05 +02:00
Tyler Slaton 3afb050ebe feat(bot-slack): configure response routing 2026-06-24 11:53:55 -07:00
Alem Tuzlak 268b39e3e0 feat(bot): cross-platform surface parity — reactions, ephemeral, modals
Add capability-gated surface methods across the bot packages so one handler
degrades gracefully per platform:
- thread.react / thread.unreact — emoji reactions (Slack, Discord, Telegram)
- thread.postEphemeral — only-you messages with a required DM fallback
- openModal (interaction/command-scoped) — structured forms (Slack rich,
  Discord text-only), omitted on surfaces with no live interaction trigger

Spans @copilotkit/bot-ui, bot, bot-slack, bot-discord, bot-telegram with
per-adapter capability flags. Discord: open modals from slash-command
interactions, and never clear registered commands on an empty publish.
2026-06-23 20:49:07 +02:00
Alem Tuzlak f6444f5d35 feat(bot-slack): modernize native streaming (task chunks, feedback, single-message)
Bring the Slack adapter up to the current native streaming API surface
(chat.startStream/appendStream/stopStream, GA Oct 2025) and remove the
type-erasure workarounds.

- Remove `as unknown as Parameters<...>` casts in favor of the SDK's typed
  args (ChatStartStream/AppendStream/StopStream/PostMessage/UpdateArguments).
- Stream a whole turn into ONE message: drop the per-message continuation
  splitting (no documented cumulative cap; matches vercel/chat), keeping the
  12k per-append chunking.
- Surface tool progress as native in-message `task_update` chunks
  (task_display_mode "timeline"), degrading to `🔧` rows where
  structured chunks are unavailable.
- Add opt-in AI feedback buttons via `slack({ feedback })` — a typed
  context_actions/feedback_buttons row attached at stopStream, with clicks
  routed adapter-locally (bypassing the engine's interaction dispatch).
- Scope recipient_user_id/recipient_team_id to channel targets only.
- Lower the native flush floor to ~600ms (appendStream Tier-4), legacy stays
  800ms.

Engine: add an optional, backward-compatible RunRenderer.finish() hook called
after runAgentLoop so a turn-scoped renderer can finalize its stream.
2026-06-18 12:39:05 +02:00
Alem Tuzlak a925e33be9 docs(bot-slack): document assistant pane + native streaming; enable in slack example
Update package READMEs + ARCHITECTURE for the assistant pane, native streaming,
and the new onThreadStarted / setSuggestedPrompts / setTitle surface. Reverse
the slack.mdx callout that told users to delete the assistant scopes (now
required), and enable the pane in the examples/slack manifest (assistant_view +
assistant:write + assistant_thread_* events) with a dev-ex onThreadStarted
greeting and the assistant config.
2026-06-15 15:47:46 +02:00
Alem Tuzlak 545fbdcda1 feat(bot-slack): Slack platform adapter
JSX -> Block Kit rendering with per-element budgets and degradation,
Socket Mode ingress, opaque-id interactions (ack within 3s, run async),
chat.update message streaming with chunking, accent attachments, and
sender-profile resolution. Preserves the PoC's streaming, chunking,
and mrkdwn mechanics behind the PlatformAdapter boundary.
2026-06-10 10:46:08 -07:00