feat(ui): 会话列表支持 Delete 键删除会话#114
Open
xinggitxing wants to merge 1 commit into
Open
Conversation
- Add SessionManager.deleteSession() to remove session index entry and messages file - Add Delete key to trigger session deletion confirmation in SessionList - Two-step confirmation: Enter to confirm, Esc to cancel - Separate backspace (search) and delete (delete trigger) key behavior - Clear active session if deleted session was the active one - Add comprehensive test coverage for deleteSession
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.
背景
会话管理列表缺少删除功能,用户无法清理不再需要的会话记录。之前用户只能查看会话列表,无法移除过期或测试用的会话。
变更内容
核心逻辑(
src/session.ts)新增
SessionManager.deleteSession(sessionId: string): boolean方法:sessions.json)中移除该会话条目removeSessionMessages()删除对应的.jsonl消息文件false,避免静默失败UI 交互(
src/ui/SessionList.tsx)新增可选属性
onDelete?: (sessionId: string) => void,实现二级确认机制防止误删:Delete键进入删除确认模式[Delete? Enter=yes, Esc=no]行内提示Enter→ 执行删除回调onDeleteEsc→ 取消删除,返回正常导航Del delete快捷键提示Enter to confirm · Esc to cancelBackspace仅处理搜索输入回删;Delete根据上下文分别处理搜索回删或删除触发集成(
src/ui/App.tsx)SessionList的onDelete回调处理逻辑:activeSessionId置为nullsessionManager.deleteSession(id)执行清理refreshSessionsList()立即刷新 UI测试(
src/tests/session.test.ts)新增 4 个测试用例覆盖所有场景:
deleteSession removes session entry from the indexdeleteSession removes the messages file.jsonl文件已不存在deleteSession returns false when session does not existfalse,索引不变deleteSession does not affect other sessions变更文件统计
使用方式
全量测试结果
预存失败项说明(与本 PR 无关):
debug logger appends full entriesProgram Files路径含空格导致 MCP 测试脚本启动失败Bash timeout controlSessionManager reconnect以上 7 个失败均为 当前 Windows 环境的预存问题,非本功能引入。
检查清单
npm run typecheck— 通过npm run lint— 通过npm run format:check— 通过deleteSession测试通过