feat(05-04): update /status to show active discussion info

Enhance status command to display:
- Selected project name and configured models
- Active discussion state (round progress, message count)
- Short discussion ID for reference
- Contextual hints for next actions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikkel Georgsen 2026-01-16 19:49:06 +00:00
parent 3296874408
commit 2a86d3903a

View file

@ -3,14 +3,18 @@
from telegram import Update from telegram import Update
from telegram.ext import ContextTypes from telegram.ext import ContextTypes
from moai.bot.handlers.projects import get_selected_project
from moai.core.ai_client import get_ai_client from moai.core.ai_client import get_ai_client
from moai.core.services.discussion import get_active_discussion
async def status_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: async def status_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""Handle /status command - show current project/discussion state. """Handle /status command - show current project/discussion state.
For now, shows a placeholder since project management isn't implemented yet. Shows:
Will be expanded in Phase 3 to show actual project state. - Bot and AI router status
- Selected project (if any)
- Active discussion state (if any)
""" """
# Check AI client status # Check AI client status
try: try:
@ -19,12 +23,51 @@ async def status_command(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
except RuntimeError: except RuntimeError:
ai_status = "AI Router: not configured" ai_status = "AI Router: not configured"
# TODO: Phase 3 - Query actual project/discussion state from database # Build status lines
status_text = ( status_lines = [
"*MoAI Status*\n\n" "*MoAI Status*\n",
"Bot: Online\n" "Bot: Online",
"Database: Connected\n" "Database: Connected",
f"{ai_status}\n\n" ai_status,
'_No project selected. Use /project new "Name" to create one._' "",
) ]
await update.message.reply_text(status_text, parse_mode="Markdown")
# Check for selected project
project = await get_selected_project(context)
if project is None:
status_lines.append('_No project selected. Use /project new "Name" to create one._')
else:
status_lines.append(f"*Project:* {project.name}")
if project.models:
models_str = ", ".join(project.models)
status_lines.append(f"Models: {models_str}")
else:
status_lines.append("Models: none configured")
# Check for active discussion
discussion = await get_active_discussion(project.id)
if discussion is not None:
# Count messages across all rounds
message_count = sum(len(r.messages) for r in discussion.rounds)
round_count = len(discussion.rounds)
# Check for in-progress discussion state
disc_state = context.user_data.get("discussion_state")
if disc_state and disc_state.get("discussion_id") == discussion.id:
current_round = disc_state["current_round"]
round_limit = disc_state["round_limit"]
status_lines.append("")
status_lines.append(f"*Active Discussion:* Round {current_round}/{round_limit}")
status_lines.append(f"Discussion ID: {discussion.id[:8]}...")
status_lines.append(f"Messages: {message_count}")
else:
status_lines.append("")
status_lines.append(f"*Active Discussion:* {round_count} rounds completed")
status_lines.append(f"Discussion ID: {discussion.id[:8]}...")
status_lines.append(f"Messages: {message_count}")
status_lines.append("_Use /discuss to continue or /stop to end._")
else:
status_lines.append("")
status_lines.append("_No active discussion. Use /open <question> to start._")
await update.message.reply_text("\n".join(status_lines), parse_mode="Markdown")