Skip to content

Add interactive bot prompts and refactor telegram controller#15

Merged
valuecodes merged 7 commits intomainfrom
use-browser-tooling
May 3, 2026
Merged

Add interactive bot prompts and refactor telegram controller#15
valuecodes merged 7 commits intomainfrom
use-browser-tooling

Conversation

@valuecodes
Copy link
Copy Markdown
Owner

What

  • Adds an ask_user_question tool so the LLM can pause mid-conversation and ask the user a clarifying question; pending state lives in a new pending_conversations table.
  • Splits the monolithic telegram/controller.ts into ui, callback-data, and conversation-runner modules so the entry points are easier to follow.
  • Tightens schedule UX: delete_schedule now requires a human-readable summary that surfaces in the confirmation prompt, and list_schedules returns numbered positions so the bot can render a stable list.
  • Always asks about use_browser before 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.

Copilot AI review requested due to automatic review settings May 3, 2026 05:56
Copy link
Copy Markdown

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

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: 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".

Comment thread apps/operator/src/modules/telegram/conversation-runner.ts
Comment thread apps/operator/src/modules/telegram/controller.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_question tool-loop pausing with persisted pending conversations and callback handling to resume the OpenAI tool loop.
  • Refactors Telegram controller logic into ui, callback-data, and conversation-runner modules and updates routes/tests accordingly.
  • Extends schedules with useBrowser support 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.

Comment thread apps/operator/src/services/openai.ts
Comment thread apps/operator/src/modules/telegram/conversation-runner.ts
Comment thread apps/operator/src/services/pending-conversation.ts Outdated
Comment thread apps/operator/src/modules/telegram/controller.ts Outdated
@valuecodes valuecodes merged commit ef4c935 into main May 3, 2026
7 checks passed
@valuecodes valuecodes deleted the use-browser-tooling branch May 3, 2026 06:23
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.

2 participants