Add interactive bot prompts and refactor telegram controller#15
Add interactive bot prompts and refactor telegram controller#15valuecodes merged 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59f332a8b7
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
This PR adds a pause/resume interaction pattern to the Operator Telegram bot (via an ask_user_question tool backed by a new pending_conversations table) and refactors the Telegram controller into smaller modules, while tightening schedule UX (stable list positions, delete confirmations with human-readable summaries, and explicit use_browser selection for monitors).
Changes:
- Introduces
ask_user_questiontool-loop pausing with persisted pending conversations and callback handling to resume the OpenAI tool loop. - Refactors Telegram controller logic into
ui,callback-data, andconversation-runnermodules and updates routes/tests accordingly. - Extends schedules with
useBrowsersupport and updates tool/schema/test coverage; pins browser-scraper dev ports to avoid collisions.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/operator/src/services/schedule.ts | Adds useBrowser to schedule creation schema and persists it on insert. |
| apps/operator/src/services/schedule.test.ts | Adds schema tests covering useBrowser parsing/typing. |
| apps/operator/src/services/pending-conversation.ts | New service for persisting paused tool-loop conversations with TTL and token consumption. |
| apps/operator/src/services/openai.ts | Adds ask_user_question tool + tool-loop pausing outcomes; exports helpers for pause/resume. |
| apps/operator/src/services/openai.test.ts | Adds tests for paused outcomes, quotas, malformed args, and back-compat behavior. |
| apps/operator/src/modules/telegram/ui.ts | New UI helpers for mapping tool args, formatting schedule descriptions, and building keyboards. |
| apps/operator/src/modules/telegram/routes.test.ts | Adds integration-style tests for use_browser guard + question callbacks and resume flow. |
| apps/operator/src/modules/telegram/conversation-runner.ts | New runner that executes OpenAI tool loop, persists questions, and dispatches Telegram messages/buttons. |
| apps/operator/src/modules/telegram/controller.ts | Refactors webhook handling to use runner, adds question-answer callback path, and shared ack/cleanup. |
| apps/operator/src/modules/telegram/callback-data.ts | New parser for confirm/cancel and question-answer callback_data formats. |
| apps/operator/src/db/schema.ts | Adds pending_conversations table to Drizzle schema exports. |
| apps/operator/migrations/meta/_journal.json | Records new migration entry. |
| apps/operator/migrations/meta/0006_snapshot.json | Captures schema snapshot including pending_conversations. |
| apps/operator/migrations/0006_unknown_the_santerians.sql | Creates pending_conversations table. |
| apps/browser-scraper/package.json | Pins dev server ports/inspector ports to avoid local collisions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What
ask_user_questiontool so the LLM can pause mid-conversation and ask the user a clarifying question; pending state lives in a newpending_conversationstable.telegram/controller.tsintoui,callback-data, andconversation-runnermodules so the entry points are easier to follow.delete_schedulenow requires a human-readable summary that surfaces in the confirmation prompt, andlist_schedulesreturns numbered positions so the bot can render a stable list.use_browserbefore creating a monitor, and pins browser-scraper dev to ports 8788/9230 so it doesn't collide with the operator dev server.How to test
pnpm typecheck
pnpm lint
pnpm test
pnpm format:check
Security review
No security-impacting changes.