Skip to content

Start and continue threads from Telegram, with approvals as chat buttons - #1728

Merged
currentbits merged 4 commits into
mainfrom
coder/1718-telegram-channel-start-continue-thr-7a0216
Oct 29, 2026
Merged

currentbits merged 4 commits into
mainfrom
coder/1718-telegram-channel-start-continue-thr-7a0216

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Part of #1718 (Telegram first; Slack and Discord follow on the same electron/channels/ layer).

What changes for users

  • Settings › Integrations › Telegram:
    • Bot token (encrypted at rest, never sent to the renderer).
    • Allowed sender IDs (required: nothing runs without them).
    • Default project and optional agent profile.
    • Connect / Disconnect with status ("connected as @botName").
  • Long polling, no public URL or webhook. Backs off on errors; a rejected token (401) stops polling instead of retrying. Polling stops cleanly on disconnect or quit; enabled state survives a relaunch.
  • Chat ↔ thread:
    • First message starts a thread in the default project; later messages continue it, or queue while a turn runs.
    • /new starts fresh; /status shows the current thread.
    • The final assistant message is posted back as plain text, chunked at 4096 chars.
    • Permission prompts arrive as Allow / Deny buttons that call the same respondPermission path as the desktop approvals inbox. Single-choice ask_user questions arrive as buttons; anything richer says "answer in Solenta".
    • Chat-started threads report back even when muted or snoozed.

Security

  • Senders off the allowlist get no reply; their ID is logged once so the owner can copy it.
  • Private chats only. Group/supergroup messages and button presses are ignored, so agent output (code, diffs, maybe secrets) never reaches other group members, even when an allowed sender writes in a group.
  • Buttons re-check the sender and must come from the chat they were sent to. Button keys map to request IDs held in main, so a press can't name an arbitrary request.
  • Chat text only ever becomes a prompt, never a shell argument. Threads use the project's / profile's normal permission mode; chat never escalates.
  • The token never appears in error text (the request URL carries it).
  • Known, accepted: a paired web client with thread-create scope could tag a thread with a Telegram channel. It can only reach chats that have already messaged the bot, and that client can already read thread output.

⚠️ Before merging

Tested only against a fake Telegram Bot API. Smoke-test with a real bot:

  1. Create a bot with @Botfather.
  2. Connect it in Settings.
  3. DM it a prompt.
  4. Approve a permission prompt from the chat.
  5. Check the reply comes back.
  6. Message it from a group and check it's ignored.

Testing

  • electron/test/channels-telegram.test.js (fake Bot API), 14/14:
    • allowlist enforced and logged once
    • group chats ignored
    • new chat → tagged thread + prompt
    • follow-ups continue / queue, /new
    • result posted back and chunked
    • approval buttons, and strangers' presses ignored
    • question buttons
    • disconnect aborts the long poll with no timers left, including during error backoff
    • token sealed on disk and redacted
    • non-numeric IDs rejected
    • connect refuses without an allowlist
  • test/channelsSection.test.tsx 3/3; typecheck clean. The worker reports the full electron and renderer suites and vite build passed before the private-chat fix (be903ef6), which touched only electron/channels/*, its test and one line of settings copy.

🤖 Generated with Claude Code

Willem and others added 4 commits October 28, 2026 12:36
)

Long-polls getUpdates from main, allowlisted senders only. Results,
approvals (inline Allow/Deny) and ask_user questions go back to the chat.
Bot token sealed at rest and redacted from the renderer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…include telegram (#1718)

Save leaves enabled to Connect/Disconnect, since the section's props can be stale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bers (#1718)

An allowed sender messaging the bot in a group would have had the agent's
replies (code, diffs, maybe secrets) posted to every member. Messages and
button presses from non-private chats are now ignored and logged once.

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

chatgpt-codex-connector Bot commented Oct 28, 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-28T11:58:01.306310Z be903ef 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: be903ef695

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

// ponytail: grows by one per unanswered prompt; prune if that ever matters.
/** @type {Map<string, { chatId: string, threadId: string, requestId?: string, questionId?: string }>} */
const buttons = new Map();
let nextKey = 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make button keys unique across application restarts

After an application restart, nextKey resets to 1 while previously sent Telegram keyboards remain usable. Once a new approval receives the same key in the same chat, pressing Allow on the old message approves the new request instead of reporting that the button expired. I reproduced an old ok:1 button approving a different request after recreating the channel manager. Use restart-unique identifiers (for example, random UUIDs) so stale buttons cannot authorize unrelated actions.

Useful? React with 👍 / 👎.

Comment thread electron/main.js
Comment on lines +901 to +902
if (channels && isNotifyTransition(prev, next)) {
channels.onThreadUpdate(payload.thread, next);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Deliver approvals added while a thread is already waiting

When a provider adds a second permission request while the first remains pending, this gate suppresses delivery because the notification state stays waiting. In electron/runner-permissions.js, the Codex permission handler appends each request and pushes thread detail, but only clears awaitingInput after all pending permissions are resolved. Consequently, an additional request arriving after the first Telegram delivery receives no buttons, and approving the visible request leaves the run blocked with no way to approve the remaining request from Telegram. Invoke the channel's deduplicated approval delivery on updates while waiting rather than only on notification-state transitions.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit 34b6d38 into main Oct 29, 2026
11 of 12 checks passed
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.

1 participant