feat: 添加测试框架及功能测试用例
test: 实现BDD测试框架及功能测试 docs: 添加测试配置文件及文档 refactor: 重构命令处理逻辑以支持测试
This commit is contained in:
@@ -161,6 +161,28 @@ async def _cmd_status(user_id: str) -> str:
|
||||
|
||||
async def _cmd_close(user_id: str, args: str) -> str:
|
||||
"""Close a session."""
|
||||
# If a specific conv_id is given by name (not a number), resolve it directly.
|
||||
if args:
|
||||
try:
|
||||
int(args)
|
||||
by_number = True
|
||||
except ValueError:
|
||||
by_number = False
|
||||
|
||||
if not by_number:
|
||||
# Explicit conv_id given — look it up directly (may belong to another user).
|
||||
conv_id = args.strip()
|
||||
try:
|
||||
success = await manager.close(conv_id, user_id=user_id)
|
||||
if success:
|
||||
if agent.get_active_conv(user_id) == conv_id:
|
||||
agent._active_conv[user_id] = None
|
||||
return f"✓ Closed session `{conv_id}`"
|
||||
else:
|
||||
return f"Session `{conv_id}` not found."
|
||||
except PermissionError as e:
|
||||
return str(e)
|
||||
|
||||
sessions = manager.list_sessions(user_id=user_id)
|
||||
if not sessions:
|
||||
return "No sessions to close."
|
||||
|
||||
Reference in New Issue
Block a user