feat(session-title): 多层级回退标题提取,消除 Dashboard 空标题显示#258
Merged
ThreeFish-AI merged 1 commit intoJun 3, 2026
Conversation
- 重构 _extract_session_title 为 4 级逐级回退策略: Level 1: user TEXT 噪声剥离(原有逻辑不变) Level 2: TOOL_RESULT 文本截取 → '[Tool output] <snippet>' Level 3: IMAGE 计数 → '[1 Image]' / '[N Images]' Level 4: 元数据兜底 → '[Tool call] Bash, Read' / '[Session] model' - 噪声标签白名单新增 artifactMetadata、thinking - 新增 update_empty_session_title 延迟补写机制, 非首次请求也可为空标题 session 回填 - 补充 30 个测试用例覆盖全部回退级别与新噪声标签 🤖 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 Session 列表中,部分来自 Claude Code 的 Session 其 title 显示为 en-dash
–(前端对空标题的兜底展示)。空标题源于_extract_session_title()仅从role=user + type=TEXT的消息中提取文本,经噪声标签剥离后若为空便无果而终,且标题为INSERT OR IGNORE写入一次、永不更新。改动
多层级回退标题提取:重构
_extract_session_title()为 4 级逐级回退策略,任一级别命中即返回:"[Tool output] <snippet>""[1 Image]"/"[N Images]""[Tool call] Bash, Read"/"[Session] claude-opus-4-8"噪声标签白名单增补:
_NOISE_TAG_PATTERN新增artifactMetadata(CC 产物上下文)和thinking(CC 内联推理标签)。延迟标题补写:新增
update_empty_session_title()方法(WHERE title =条件保证仅覆盖空标题),非首次请求也会尝试为空标题 session 回填,保持幂等性。测试覆盖:新增 30 个测试用例,覆盖全部回退级别、新噪声标签、各辅助函数及集成级联场景。全量 1575 个测试通过,无回归。
涉及文件
src/coding/proxy/routing/executor.py— 核心回退逻辑 + 噪声标签扩展 + 延迟补写调用src/coding/proxy/logging/db.py— 新增update_empty_session_title()src/coding/proxy/routing/usage_recorder.py— 委托层新增对应方法tests/test_router_executor.py— 30 个新测试用例