Skip to content

Fix markdown rendering, add inline button menus, and fix duplicate cancel message on /followup redirect#2

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/fix-rendering-issues
Draft

Fix markdown rendering, add inline button menus, and fix duplicate cancel message on /followup redirect#2
Copilot wants to merge 1 commit intomainfrom
copilot/fix-rendering-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

Three independent issues: markdown was never rendered in AI responses (missing parse_mode everywhere), no interactive menus existed for model selection or navigation, and /followup redirecting an active stream caused both the original handler and /followup to each send a cancellation message.

Markdown rendering

  • Added _is_parse_error(exc: BadRequest) -> bool helper — single source of truth for detecting Telegram entity-parse failures, used consistently across all three fallback sites.
  • _safe_edit_text and _send_chunks now accept parse_mode; on a parse error they retry with plain text so the message is always delivered.
  • All AI-response send-sites now pass ParseMode.MARKDOWN: _stream_to_message final edit, _send() closures in company_command/build_command/autorun_command, and about_command, weather_command, company_roles_command, _do_build_followup, _weather_reminder_job.

Inline button menus

  • /start: New welcome command with an 8-button inline keyboard covering all major commands (replaces about_command mapping).
  • /settings (no args): Shows a model-selection inline keyboard instead of plain text — vision indicator (✅/📝), ★ on current selection, "Clear preference" button.
  • model_select_callback handles set_model:<name> / set_model:clear presses.
  • cmd_shortcut_callback handles cmd:<name> presses from /start — shows a usage hint or the settings keyboard inline.

Interrupt fix + streaming responsiveness

  • Added _silenced_cancels: set[int]; /followup adds the user ID before calling task.cancel() so the original handler's CancelledError catch suppresses the duplicate "⛔ cancelled" message:
_silenced_cancels.add(user.id)
existing_task.cancel()
# ...
except asyncio.CancelledError:
    if user.id not in _silenced_cancels:
        await context.bot.send_message(..., text="⛔ Your in-progress request has been cancelled.")
    _silenced_cancels.discard(user.id)
  • STREAM_EDIT_INTERVAL reduced 2.0 s → 1.0 s for faster live streaming updates.

…mprovements

Co-authored-by: HugoWong528 <267603037+HugoWong528@users.noreply.github.com>
Agent-Logs-Url: https://github.com/HugoWong528/Telegram-bot/sessions/076ab1bd-869d-4c65-ada5-a9819f317a95
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