Fix session title falling back to "New session" in Pi Web bridge
Session from pi-web on Hugging Face by woxQAQ · MIT · condensed by Coders Talk
Click a segment to jump to that moment
1h 05msession
0interventions
GOAL
Investigate why the frontend session title logic in a Vue/bridge codebase defaults to "New session" for real sessions, then fix the underlying bugs in title priority and session summary extraction.
- +0Prompt · +0我们是如何给新会话赋名的 (How do we name new sessions?)
- +0mAgent did · +0mTraced session naming logic across bridge and web: default 'New session' constant, first-user-message extraction, set_session_name RPC, and two inconsistent naming priority orders between sessionDisplayName() and the session list summary.
- +1mPrompt · +1m我们bridge协议中应该有 sessionName 的 (The bridge protocol should have sessionName)
- +2mAgent did · +2mConfirmed sessionName exists in RpcSessionState and multiple RPC responses, and traced how bridge populates it via sessionDisplayName() and getSessionName().
- +4mPrompt · +4m我们应该在前端展示这个sessionName吧 (We should display sessionName in the frontend)
- +5mAgent did · +5mRecommended prioritizing sessionState.sessionName over list-derived name in App.vue, then implemented the change to activeSessionLabel and verified with pnpm run build:web.
- +10mPrompt · +10m检查一下为什么 cbb636aa-4d3f-4404-811b-46ec2285d8a5 这个会话前端显示的session name 是 New session
- +10mAgent did · +10mInvestigated multiple real sessions via jsonl files and live WebSocket queries, found the ID was a request ID not a session ID, then found another session's title truncated because a large embedded image pushed the first user message past the 64KB prefix read limit, breaking JSON parsing.
- +39mPrompt · +39m我们有办法略去 image block 吗 (Can we skip the image block when reading the summary?)
- +43mPrompt · +43m2 (chose option 2: lightweight raw-string text extraction instead of full JSON parse)
- +43mAgent did · +43mImplemented parseJsonStringLiteral() and extractUserMessageTextFromRawLine() as a fallback in findFirstUserMessageText() so truncated JSON lines with large image payloads still yield the first user text; added a regression test and verified with vitest and pnpm run check.
- +1h 5mOutcome · +1h 5mCommitted f568c08 'fix: improve session title handling': 3 files changed, 115 insertions, 8 deletions; targeted vitest test passed and type check passed.
VERDICT
Next time I'd start by asking directly for the two known root causes at once: the frontend title priority order and the 64KB session-summary read truncation on large image messages, since both turned out to matter. The correction that actually did the work was picking option 2 (raw-string text extraction) over fully reading the whole first line, which let us fix the truncation bug without changing the read strategy everywhere.