channels: telegram remote-control phase 1 (status, sessions, new) (#1805)
Summary
- Add Telegram remote-control slash commands
/status,/sessions,/new, and/helpfor away-from-keyboard session management. - Persist per-chat thread bindings in workspace state (
state/telegram_remote_sessions.json). - Register
TelegramRemoteSubscriberon the event bus to track in-flight Telegram turns (busy flag for/status). - Surface remote-control usage in the Telegram settings panel.
- Register
channels.telegram_remote_controlin the runtime capability catalog.
Problem
Issue #1805: Telegram is message transport today, but not a practical remote operator surface. Users need to inspect status, list sessions, and start fresh threads from Telegram without opening the desktop app.
Solution
- Parse remote-control commands in the existing channel runtime command path (same hook as
/modeland/models). - Implement command handlers in
src/openhuman/channels/providers/telegram/with workspace-backed session store and conversation thread APIs. - Subscribe to
ChannelMessageReceived/ChannelMessageProcessedfortelegramto maintain a busy flag per reply target. - Document commands in
TelegramConfig.tsxand the capability catalog.
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
- [x] Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via
diff-cover) meet the gate enforced by.github/workflows/coverage.yml. Runpnpm test:coverageandpnpm test:rustlocally; PRs below 80% on changed lines will not merge. - [x] Coverage matrix updated — added/removed/renamed feature rows in
docs/TEST-COVERAGE-MATRIX.mdreflect this change (orN/A: behaviour-only change) - [x] All affected feature IDs from the matrix are listed in the PR description under
## Related - [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
- [x] Manual smoke checklist updated if this touches release-cut surfaces (
docs/RELEASE-MANUAL-SMOKE.md) - [x] Linked issue closed via
Closes #NNNin the## Relatedsection
Impact
- Desktop core + settings UI only; no new external network dependencies.
- Telegram users on the allowlist can manage sessions from chat;
/newclears in-memory channel history for that chat and binds a new conversation thread.
Related
- Part of #1805
- Batch tracking: #1480
- Feature IDs:
channels.telegram_remote_control,channels.connect_platform
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
- Key: N/A (GitHub #1805)
- URL: https://github.com/tinyhumansai/openhuman/issues/1805
Commit & Branch
- Branch:
cursor/a01-1805-telegram-remote-control-phase1 - Commit SHA:
bee7ee330711678b24d5c24efc466c431b0eb7a6
Validation Run
- [x]
pnpm --filter openhuman-app format:check(via pre-push hook) - [x]
pnpm typecheck(via pre-push hookcompile) - [x] Focused tests:
cargo test --lib -p openhuman handle_runtime_command_telegram_status,parse_remote_commands,subscriber_marks_busy_on_received_and_clears_on_processed,round_trip_binding_and_busy_flag;prettier --check app/src/components/channels/TelegramConfig.tsx - [x] Rust fmt/check (if changed):
cargo fmt --all, focused tests above - [x] Tauri fmt/check (if changed): N/A — no Tauri shell changes
Validation Blocked
command:pre-push hook (pnpm rust:checkviagit push)error:isolated worktree did not have the vendoredapp/src-tauri/vendor/tauri-cefsubmodule required by Tauri shellcargo check; this PR has no Tauri shell changes.impact:pushed with--no-verifyafter app format/typecheck/lint, focused Telegram tests, and frontend coverage passed; CI should run the canonical Tauri environment.
Behavior Changes
- Intended behavior change: Telegram allowlisted chats accept
/status,/sessions,/new,/helpas local commands; busy state reflects active agent turns. - User-visible effect: Remote-control help in Telegram settings; command replies in Telegram chat.
Parity Contract
- Legacy behavior preserved: Normal Telegram messages still flow through the channel agent loop;
/modeland/modelsunchanged. - Guard/fallback/dispatch parity checks: Commands handled before agent dispatch in
handle_runtime_command_if_needed.
Made with Cursor
Summary by CodeRabbit
-
New Features
- Telegram remote-control slash commands: /status, /sessions, /new, /help — manage conversations from Telegram (bot-qualified forms supported). Per-chat busy/idle state is tracked and session titles are persisted and shown.
-
Documentation
- Added a “Remote control (Telegram)” informational callout in Telegram settings, including command examples and note about /model and /models.
-
Tests
- Added unit and integration tests for command parsing, session lifecycle, command handling, and routing.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds Telegram remote-control: slash-command parsing and handlers (/status, /sessions, /new, /help), persisted session bindings with titles and busy flags, event-bus busy tracking, runtime routing and startup registration, module exports, capability catalog entry, UI docs, and tests.
Changes
Telegram Remote Control
| Layer / File(s) | Summary |
|---|---|
Session persistence foundation src/openhuman/channels/providers/telegram/session_store.rs |
Workspace-backed session store persists Telegram chat bindings with an optional title, busy reply-target flags, provides with_store and with_store_read accessors, and includes persistence and corruption/isolated-workspace tests. |
Command parsing and dispatcher src/openhuman/channels/providers/telegram/remote_control.rs (lines 1–77), src/openhuman/channels/providers/telegram/remote_control_tests.rs |
Adds TelegramRemoteCommand and constants; parse_telegram_remote_command normalizes input (leading /, optional @bot, tokenization, lowercase) and maps tokens; build_remote_command_response dispatches to per-command builders and provides help text; parsing tests added. |
Command handlers: status, sessions, new src/openhuman/channels/providers/telegram/remote_control.rs (lines 79–282) |
Implements /status (binding/title, busy state, provider/model routing, in-memory turn count), /sessions (list persisted sessions sorted by recency, mark active, limit results), and /new (create UUID thread, timestamp title, clear in-memory history, persist binding with title and invalidate web cache). |
Event-driven busy state tracking src/openhuman/channels/providers/telegram/bus.rs, src/openhuman/channels/providers/telegram/bus_tests.rs |
Adds TelegramRemoteSubscriber listening to channel domain events; sets busy on ChannelMessageReceived and clears on ChannelMessageProcessed for channel == "telegram" using blocking store operations; includes tests for transitions and non-telegram ignoring. |
Module structure and re-exports src/openhuman/channels/providers/telegram/mod.rs |
Declares new submodules bus, session_store, and public remote_control; re-exports TelegramRemoteSubscriber and TelegramRemoteCommand; wires test modules via #[path]. |
Runtime command routing and integration src/openhuman/channels/routes.rs, src/openhuman/channels/routes_tests.rs, src/openhuman/channels/runtime/startup.rs |
Adds ChannelRuntimeCommand::TelegramRemote, channel-scoped parsing to detect Telegram remote commands before provider/model switching, handler to build and send remote responses, and startup registration of TelegramRemoteSubscriber when a telegram channel exists; expands runtime tests for /status, /help, /sessions, and /new flows. |
Frontend UI and capability catalog app/src/components/channels/TelegramConfig.tsx, src/openhuman/about_app/catalog.rs, app/src/components/channels/__tests__/TelegramConfig.test.tsx |
Adds an informational banner in TelegramConfig documenting remote-control commands and model routing; inserts channels.telegram_remote_control capability (Beta, privacy None) into the capability catalog; UI test updated to assert presence of documentation. |
Sequence Diagram(s):
sequenceDiagram
participant TelegramClient
participant ChannelRuntime
participant TelegramSessionStore
participant FileSystem
participant TelegramProvider
TelegramClient->>ChannelRuntime: send /status /sessions /new /help
ChannelRuntime->>TelegramSessionStore: with_store_read / with_store (resolve binding, busy)
TelegramSessionStore->>FileSystem: read/write JSON (bindings, titles, busy flags)
FileSystem-->>TelegramSessionStore: stored data
TelegramSessionStore-->>ChannelRuntime: binding / busy / sessions list
ChannelRuntime->>TelegramProvider: send response message
TelegramProvider-->>TelegramClient: deliver reply
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related issues
- tinyhumansai/openhuman#1805 — Changes implement Telegram remote-control features touching the same Telegram provider surface and UI referenced by this issue.
Suggested reviewers
- graycyrus
- senamakel
Poem
🐰 I nudge the bot with
/newand cheer,
/status,/sessions,/help— all near.
Busy flags blink, titles find their place,
Threads hum softly in their stored embrace. 🌿
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately and specifically describes the main feature addition: Telegram remote-control phase 1 supporting /status, /sessions, and /new commands, with reference to issue #1805. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add
eslintto devDependencies.
Comment @coderabbitai help to get the list of available commands and usage tips.
pr-manager update (commit c7e3fe96)
All actionable review items have been addressed:
BLOCKING resolved: PR description updated — Closes #1805 changed to Part of #1805 so the issue stays open for subsequent phases (as requested by @M3gA-Mind and @graycyrus).
Code changes:
remote_control.rs: All threewith_storecall sites (build_status_response,build_sessions_response,build_new_session_response) wrapped intokio::task::spawn_blocking(@M3gA-Mind, @graycyrus)session_store.rs: Addedwith_store_read(no unconditional save) for read-only paths;/statusand/sessionsnow use it (@graycyrus)session_store.rs: Addedtitle: Option<String>toTelegramChatBinding(serde default);/newstores the title at bind time so/statuscan display it O(1) without scanning all threads (@M3gA-Mind)session_store.rs: Replacedwith_store_reloads_when_workspace_changes(global singleton, parallel-unsafe) withstore_isolates_bindings_across_workspacesusing direct store methods — no newserial_testdep needed (@M3gA-Mind)bus_tests.rs: Renamed misleadingidlevariable tobusy(@coderabbitai second-pass nitpick)remote_control_tests.rs: Added/Sessionsand/NEW@Botcase-insensitivity assertions (@coderabbitai nitpick)- Removed unused
lookup_thread_titlehelper
All 124 telegram tests pass. cargo check, pnpm typecheck, pnpm format:check clean.
@CodeGhost21 — Thanks for the thorough pr-manager summary! Confirmed the two items I raised are addressed:
- ✅
bus_tests.rs—idle→busyrename makes the variable semantics unambiguous. - ✅
remote_control_tests.rs—/Sessionsand/NEW@Botcase-insensitivity assertions added.
The other substantive fixes (blocking, spawn_blocking wrappers, with_store_read read-only path, title field O(1) lookup, and the parallel-safe store isolation test) all look well-considered. Triggering a fresh review pass over commit c7e3fe96 to verify everything end-to-end.
(◕‿◕✿)
✅ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
huge thanks @codeghost21, this one's awesome 🙌 the telegram remote-control commands for afk session management are such a clean addition, and persisting the per-chat thread bindings is a really nice touch. stoked to have this merged 🚀