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:
parent
3296874408
commit
2a86d3903a
1 changed files with 54 additions and 11 deletions
|
|
@ -3,14 +3,18 @@
|
|||
from telegram import Update
|
||||
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.services.discussion import get_active_discussion
|
||||
|
||||
|
||||
async def status_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
"""Handle /status command - show current project/discussion state.
|
||||
|
||||
For now, shows a placeholder since project management isn't implemented yet.
|
||||
Will be expanded in Phase 3 to show actual project state.
|
||||
Shows:
|
||||
- Bot and AI router status
|
||||
- Selected project (if any)
|
||||
- Active discussion state (if any)
|
||||
"""
|
||||
# Check AI client status
|
||||
try:
|
||||
|
|
@ -19,12 +23,51 @@ async def status_command(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
|
|||
except RuntimeError:
|
||||
ai_status = "AI Router: not configured"
|
||||
|
||||
# TODO: Phase 3 - Query actual project/discussion state from database
|
||||
status_text = (
|
||||
"*MoAI Status*\n\n"
|
||||
"Bot: Online\n"
|
||||
"Database: Connected\n"
|
||||
f"{ai_status}\n\n"
|
||||
'_No project selected. Use /project new "Name" to create one._'
|
||||
)
|
||||
await update.message.reply_text(status_text, parse_mode="Markdown")
|
||||
# Build status lines
|
||||
status_lines = [
|
||||
"*MoAI Status*\n",
|
||||
"Bot: Online",
|
||||
"Database: Connected",
|
||||
ai_status,
|
||||
"",
|
||||
]
|
||||
|
||||
# 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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue