Skip to content

Start and continue threads from Slack and Discord DMs, next to Telegram - #1740

Merged
currentbits merged 2 commits into
mainfrom
coder/1718-slack-discord-channels-on-a-general-4e7720
Oct 29, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/1718-slack-discord-channels-on-a-general-4e7720

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #1718 (Telegram shipped in #1728).

What changes for users

Settings › Integrations gets Slack and Discord cards next to Telegram, with setup steps. As with Telegram:

  • DM the bot to start a thread; later messages continue it, or queue while a turn runs.
  • /new and /status work.
  • The final answer is posted back.
  • Approvals and single-choice questions arrive as buttons.

Slack (Socket Mode, no public URL)

  • App-level token (connections:write) + bot token (chat:write, im:history).
  • Acks every envelope before handling it.
  • Reconnects on a fresh URL after a drop or a disconnect message, with capped backoff on errors.
  • DMs only (channel_type === "im"); channels, groups and multi-person DMs are ignored.
  • Bot posts and edits are ignored, so its own replies never loop back.
  • Plain escaped text in 3,500-char chunks; Block Kit buttons via block_actions.

Discord (Gateway, no public URL)

  • IDENTIFY with the DIRECT_MESSAGES intent only: a bot's own DMs carry content without the privileged MESSAGE_CONTENT intent.
  • Heartbeat with the last sequence; RESUME on resume_gateway_url after a drop, op 7 or a missed ACK; op 9 handled.
  • A rejected token (4004 and friends) stops for good instead of retrying.
  • DMs only (no guild_id). Bots are ignored.
  • 2,000-char chunks that never ping anyone. Components buttons via INTERACTION_CREATE.

Channel layer

electron/channels/index.js now runs one transport per kind. Replies route by thread.channel.kind. Settings, state and status are per kind. Telegram is unchanged: its test file is untouched from main and passes 14/14 against the new layer. Slack and Discord share fakes in electron/test/support/fakeChat.js.

Security (same rules for all three)

  • Unknown senders get no reply. DMs only.
  • Button presses re-check the sender, the chat and the channel kind; button keys map to request IDs held in main.
  • Chat text only ever becomes a prompt. The thread uses the profile's / project's permission mode, never a more permissive one.
  • All tokens are sealed at rest (secretGroups), never sent to the renderer (hasToken-style flags only), and stripped from the diagnostics bundle.
  • Errors never echo a token.
  • Sockets close on disconnect and quit without waiting on a close event, and timers are cleared.

The worker's 5 commits are squashed into one: Solenta's push secret scan flagged token-shaped fake fixtures. The new fixtures are built from parts, and the Telegram test is left untouched so its existing fixture isn't pulled into the diff.

⚠️ Before relying on it

Tested only against fake Slack / Discord servers. Worth one real smoke test per platform:

  1. Connect.
  2. DM a prompt.
  3. Approve a permission from the chat.
  4. Check the reply.
  5. Message from a channel or server and check it's ignored.

Testing

  • channels-slack, channels-discord (27) + channels-telegram (14, unchanged file): 41/41. They cover:
    • allowlist enforcement, and non-DMs ignored
    • DM → thread; follow-ups and queueing
    • results posted back, chunked
    • approval buttons, with strangers' and channel presses ignored
    • heartbeat / resume / reconnect, and fatal close codes
    • tokens sealed and redacted, bad tokens never echoed
    • no timers left on disconnect
    • Telegram and Slack running at once, each thread routed to its own chat
  • channelsSection UI tests 6/6; typecheck clean.
  • The worker reports the full electron (5277) and renderer (3275) suites and vite build green.
  • Merges cleanly onto current main.

🤖 Generated with Claude Code

…am (#1718)

- Chat channels: one transport per kind, routed by thread.channel.kind
- Slack over Socket Mode (DMs only, Block Kit buttons, reconnect on a fresh URL)
- Discord over the Gateway (DIRECT_MESSAGES intent, heartbeat + RESUME, DMs only)
- Settings: Slack and Discord cards next to Telegram
- stop() never waits on a WebSocket close event
- Test fixture tokens are built from parts so secret scanners never see a
  token-shaped literal

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T13:25:35.194607Z 03fbe74 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 03fbe74166

ℹ️ 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".

Comment on lines +89 to +92
if (!res.ok) {
const err = new Error(`Discord ${label} failed (HTTP ${res.status})${json && json.message ? `: ${json.message}` : ""}`);
/** @type {any} */ (err).status = res.status;
throw err;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry rate-limited posts before abandoning message delivery

When a long answer or approval prompt exhausts the API's posting limit, HTTP 429 is treated as a terminal error, aborting the chunk loop and dropping all remaining chunks. The new Slack transport has the same behavior. Neither transport honors the retry delay documented by Discord or Slack. This can also leave an approval without its buttons when an earlier text chunk is rate-limited. The channel layer only logs the failure and has already marked the answer or prompt as delivered, so it will not retry. Queue posts and honor the server's retry delay before advancing to the next chunk.

Useful? React with 👍 / 👎.

Comment on lines +207 to +209
handlers = handlers
.then(() => (stopped ? undefined : dispatch(msg.t, msg.d || {})))
.catch((err) => log(`discord: handler failed: ${err && err.message ? err.message : err}`));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Acknowledge Discord interactions before queued message processing

If a preceding DM is still awaiting runner.startRun, every subsequent button interaction—even from another user's DM—waits behind it in this shared promise chain. Startup can await project setup in electron/runner.js, so this delay can easily exceed Discord's three-second initial-response deadline, after which the interaction token is invalidated. The approval may eventually execute, but Discord reports that the interaction failed and the confirmation cannot be delivered. Acknowledge or defer interactions promptly, independently of the message-processing queue, and deliver the result afterward.

Useful? React with 👍 / 👎.

currentbits added a commit that referenced this pull request Oct 29, 2026
…1741)

ubuntu-latest started rolling to an image whose apparmor-profiles (5.0.2)
no longer ships /usr/share/apparmor/extra-profiles/bwrap-userns-restrict,
so the Codex sandbox-proof setup failed before any test ran (PR #1740).
Use whichever bwrap profile the image has; if none, relax
apparmor_restrict_unprivileged_userns for this job only (the codex probe
still fails the job if the real sandbox cannot start).

Co-authored-by: Willem <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@currentbits
currentbits merged commit 1cf6b54 into main Oct 29, 2026
6 checks passed
currentbits added a commit that referenced this pull request Oct 29, 2026
…HTTP reply (#1742)

Acks go over the socket and the reply over HTTP, so the fake server can see
the reply first; main's ubuntu job after #1740 read acks too early.

Co-authored-by: Willem <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
currentbits added a commit that referenced this pull request Oct 30, 2026
…in (#1751)

* Package every electron/ .js including subdirectories (electron/channels/)

package-app.sh and package-cross.sh copied electron/*.js only, so the
electron/channels/ folder from #1728/#1740 never reached the bundle and
every packaged build hung at boot on Electron's uncaught-error dialog
(require ./channels/index.js). Found by verify-package's boot probe while
cutting a nightly from e2f2fb3. Copy recursively, tests still excluded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Test: packaging copies every electron/ .js recursively in both scripts

The old assertion pinned the top-level electron/*.js glob that dropped
electron/channels/. Assert the recursive rsync (tests excluded) in
package-app.sh and package-cross.sh instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two-way chat channels: start/continue threads from Slack, Discord, Telegram

1 participant