fix(desktop): scope file shortcuts to active sidebar tab - #2
Conversation
Signed-off-by: yuanzhengjie <yuanzhengjie@xd.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/features/cc-agent/workdir-browse/FileBodyView.tsx | 根据 shortcutsEnabled 正确注册或清理三个全局快捷键及 find-in-page ownership。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx | 将宿主传入的 active 与 shellVisible 组合后传给 FileBodyView,当前宿主调用链已完整接线。 |
| apps/desktop/src/renderer/tests/fileBodyShortcutOwnership.test.ts | 新测试仅断言源码字符串,不能验证标签切换时的实际监听器和 ownership 生命周期。 |
| apps/desktop/src/renderer/tests/markdownTargetRendererContract.test.ts | 正则同时接受 LF 与 CRLF,修正 Windows 下的测试兼容性。 |
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/renderer/__tests__/fileBodyShortcutOwnership.test.ts:30-33
**回归测试只检查源码文本**
该测试仅通过 `toContain` 和正则计数检查源码片段,没有挂载组件或模拟标签状态切换;后续即使属性转发、effect 依赖或监听器生命周期发生回归,只要这些文本仍存在,测试就会继续通过,无法保护本次修复的快捷键所有权行为。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(desktop): scope file shortcuts to ac..." | Re-trigger Greptile
| it('enables file shortcuts only for the active visible tab', () => { | ||
| expect(fileBrowserBodySource).toContain('shortcutsEnabled={active && shellVisible}'); | ||
| expect(fileBodySource).toContain('if (!shortcutsEnabled) return;'); | ||
| expect(fileBodySource.match(/enabled: shortcutsEnabled/g)).toHaveLength(3); |
There was a problem hiding this comment.
该测试仅通过 toContain 和正则计数检查源码片段,没有挂载组件或模拟标签状态切换;后续即使属性转发、effect 依赖或监听器生命周期发生回归,只要这些文本仍存在,测试就会继续通过,无法保护本次修复的快捷键所有权行为。
Context Used: 使用和PR描述相同的语言进行评论 (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/__tests__/fileBodyShortcutOwnership.test.ts
Line: 30-33
Comment:
**回归测试只检查源码文本**
该测试仅通过 `toContain` 和正则计数检查源码片段,没有挂载组件或模拟标签状态切换;后续即使属性转发、effect 依赖或监听器生命周期发生回归,只要这些文本仍存在,测试就会继续通过,无法保护本次修复的快捷键所有权行为。
**Context Used:** 使用和PR描述相同的语言进行评论 ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
CodeQL is not triggering for this fork PR. As of August 28, 2026, the regular checks (client-ci/verify, pr-design-basis, and Greptile) are successful, but no CodeQL workflow run is attached to the PR head commit. GitHub therefore reports “Code scanning is waiting for results from CodeQL” and keeps the merge blocked. Could a maintainer please re-trigger/approve CodeQL for this PR and, if needed, update the branch-protection/code-scanning requirement for external fork PRs? This appears to be a repository workflow/branch-protection issue rather than a code failure. |
这次改了什么
摘要
修复右侧侧边栏同时打开多个文件浏览页签时,
Ctrl/Cmd+F等文件快捷键始终被第一个已挂载页签处理的问题。现在仅当前激活且可见的文件页签拥有快捷键处理权。变更类型
fix缺陷修复范围
Ctrl/Cmd+F、Ctrl/Cmd+Shift+F和Ctrl/Cmd+S只作用于当前激活且可见的文件页签。UI 变化
怎么验证的
自动验证
手工验证
不涉及:本次以快捷键所有权回归测试覆盖多页签挂载与 active/visible 状态切换。
未执行的验证
无。
风险
风险分类
影响与回滚
Ctrl/Cmd+F、Ctrl/Cmd+Shift+F、Ctrl/Cmd+S注册;另有一处既有源码契约断言改为同时接受 LF 与 CRLF。b5f3a3aaf8c4a827b29d02c0eff6211773cd487f。提交前检查
git commit -s,见 DCO)