feat(session): 从首个用户消息提取 Session 标题并在 Dashboard 展示#245
Merged
ThreeFish-AI merged 2 commits intoMay 25, 2026
Conversation
- 新增 session_meta 表持久化 session 级标题元数据 - 检测新 session 时从首个 user 消息提取文本截取前 30 字作为标题 - get_or_create_record() 返回 is_new 标志标识首次会话 - Dashboard Sessions 列表新增 Title 列,展开详情同步展示 - 更新相关测试适配返回值变更 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
Dashboard 的 Sessions 页面原本仅通过机器生成的 session_key 标识会话,用户难以直观识别每个会话对应的任务内容。本 PR 从 Claude Code 首次请求的首个
user消息中提取文本(截取前 30 字)作为会话标题,并在 Dashboard 中展示。核心变更
logging/db.py):新增session_meta表存储 session 级标题元数据,提供set_session_title()(幂等写入)和get_session_titles()(批量查询),query_recent_sessions()自动关联标题返回routing/executor.py):新增_extract_session_title()从规范化请求中提取首个 user 文本;session_manager.py的get_or_create_record()返回(record, is_new)元组标识首次会话;usage_recorder.py增加代理方法透传标题设置server/dashboard.py):Sessions 列表新增 Title 列(15% 宽度),展开详情行同步展示,标题为空时显示–占位tests/test_router_executor.py):更新get_or_create_record()返回值解构,全部 1464 测试通过设计决策
session_meta表(非compat_sessionTTL 表、非usage_log冗余列):兼顾持久性与职责正交,避免标题随 session 过期丢失或每行请求记录冗余存储INSERT OR IGNORE幂等写入:标题仅在首次请求时设置,后续请求不覆盖Test Plan