Open
Conversation
- 编辑器选中代码右键菜单新增「发送到会话」功能,支持发送带行号引用的代码片段 - Tab 标签右键菜单新增「发送到会话」功能,支持发送文件路径引用 - 发送格式与文件树右键功能保持一致,使用 @文件路径 或 @文件路径#L行号 格式 - 自动转换为相对路径,聚焦到会话输入框,显示成功提示
This comment has been minimized.
This comment has been minimized.
Remove the unused rootPath parameter from EditorTabs component. The path normalization logic is already handled in EditorArea's handleSendToSession function, making this parameter redundant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 统一使用 normalizePath 处理路径归一化 - 修复选区结束在行首时的行号偏移问题 - 清理 i18n 中重复的翻译键 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
- 统一路径处理逻辑:新增 getRelativePath 辅助函数 - 修复 normalizePath 调用错误(该函数只接受一个参数) - 修复翻译键重复问题('Send to session' 在两处定义) - 优化 useEffect 依赖数组,使用 getRelativePath 替代 rootPath Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
- 修复 FileTree.tsx 中的翻译键不一致
- t('Send to Session') → t('Send to session')
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
- 新增 formatLineRef 辅助函数统一处理行号引用格式化 - 消除两处重复的 endLine + lineRef 计算逻辑 - 更新相关 Hook 依赖数组 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
- 添加 sessionIdRef 来存储当前的 sessionId - 在发送内容到终端时使用 sessionIdRef.current - 添加检查确保 sessionId 存在
This comment has been minimized.
This comment has been minimized.
使用 activeTabPathRef.current 替代闭包捕获的 activeTabPath,确保始终获取最新的活动标签路径。 修复位置: - addAction 回调中的路径获取 - showCommentForm 函数中的路径获取 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
- 移除 addAction 外层的 sessionId 判断,改为仅在 run 回调内检查 - 从 handleEditorMount 依赖数组中移除 sessionId,减少不必要的回调重建 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Claude finished @lwt-sadais's task in 3m 2s —— View job 🔍 代码审查报告
📊 审查概览 · 一目了然
🏆 代码质量评分📋 问题分布🎯 关键发现
🎯 问题详细分析 · 📊 点击展开查看📊 **👆 点击此处展开详细统计和图表分析**📈 问题趋势分析
🐛 问题清单与修复指南 · 📋 点击展开查看📋 **👆 点击此处展开详细问题列表 (共 4 个问题) · 一键复制追踪 📌**
|
| 🎯 优先级 | 🚨 严重 | ⚡ 轻微 | 📈 总计 | |
|---|---|---|---|---|
| 🔴 P0 | 0 个 | - | - | 0 个 |
| 🟡 P1 | - | 2 个 | - | 2 个 |
| 🔵 P2 | - | - | 2 个 | 2 个 |
| 📊 合计 | 0 | 2 | 2 | 4 个 |
✅ 亮点与优秀实践
本次 PR 有几个值得肯定的设计决策:
- 使用 ref 解决闭包问题 —
sessionIdRef和activeTabPathRef确保 MonacoaddAction回调中始终访问到最新状态,这是处理 Monaco 事件回调的正确模式 - 提取
formatLineRef辅助函数 — 行号引用逻辑被独立为可复用函数,且正确处理了光标在行首时endLine的边界情况(endColumn === 1时减 1) - 路径处理与 FileTree 保持一致 — 使用
normalizePath进行大小写不敏感路径比较,与项目其他模块风格统一 - 向后兼容设计 — 通过
sessionId条件控制菜单项显示,不影响无 session 场景 - i18n 翻译键统一 — 从多次提交可见修复了翻译键格式问题,最终统一使用
'Send to session'风格
🎯 合并决策建议
📋 合并评估结果
| 📊 评估维度 | ⭐ 得分 | 🎯 状态 | 💭 说明 |
|---|---|---|---|
| 🔐 安全性 | 10/10 | ✅ 通过 | 无安全风险,仅涉及 UI 交互 |
| 📊 代码质量 | 8/10 | ✅ 良好 | 结构清晰,闭包问题处理得当 |
| ⚡ 性能影响 | 9/10 | ✅ 无影响 | 使用 useCallback 和 ref 避免不必要渲染 |
| 🛠️ 功能完整性 | 8/10 | ✅ 完整 | 编辑器和 Tab 两个入口均已实现 |
| 🧪 测试覆盖 | 5/10 | 无自动化测试,依赖手动验证 |
📈 综合评分: 40/50 分 · 等级: 良好
🚦 最终建议
✅ 建议合并
📝 详细理由:
- 🟢 功能实现完整,编辑器选中代码和 Tab 标签两个入口均可正常使用
- 🟢 闭包问题通过 ref +
getState()模式正确解决- 🟢 路径处理逻辑与 FileTree 保持一致
- 🟢 无安全风险,无性能退化
- 🟡 i18n 动态切换存在已知限制,但影响极小
🎯 具体行动建议:
-
可选改进(非阻断):
- 在
addAction的run回调中添加注释,说明为什么使用getState()而非闭包变量(修复 Windows 平台兼容性问题 #2) - 给 EditorTabs 的「发送到会话」菜单项添加
MessageSquarePlus图标,与 FileTree 保持一致(feat(source-control): 新增类 VSCode 风格的源代码管理面板 #4)
- 在
-
后续版本改进:
- 如果需要支持运行时语言切换,考虑在 locale 变更时重新注册 Monaco action(fix: 彻底修复终端渲染问题(花屏和字体设置闪烁) #1)
- 统一组件内的相对路径计算逻辑,减少重复代码(fix(terminal): 修复终端标签快捷键无法使用的问题 #3)
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.
功能描述
支持在编辑器中通过右键菜单将选中内容或文件发送到会话,提升代码讨论效率。
新增功能
1. 编辑器选中代码发送到会话
@相对路径#L起始行-L结束行(单行时为#L行号)@src/main.ts#L10-L202. Tab 标签发送到会话
@相对路径@src/main.ts技术实现
addActionAPI 注册右键菜单项useTerminalWriteStore进行会话通信normalizePath)sessionId时显示菜单项,向后兼容修改文件
src/renderer/components/files/EditorArea.tsx:新增编辑器右键菜单和 Tab 发送逻辑src/renderer/components/files/EditorTabs.tsx:新增 Tab 右键菜单项测试建议
相关 Issue
Closes #(issue number)