Repository navigation
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
你好——我发现了 2 个问题
AI Agent 提示词
请处理本次代码审查中的评论:
## 单独评论
### 评论 1
<location path="src/App.tsx" line_range="1677-1689" />
<code_context>
- registeringKey = stopKey;
- // 避免重复注册相同的键
- if (stopKey !== startKey) {
+ if (startAllowed) {
+ registeringKey = startKey;
+ await register(toTauriKey(startKey), () => {
+ const now = Date.now();
+ if (now - lastStartTime < GLOBAL_HOTKEY_THROTTLE_MS) return;
+ lastStartTime = now;
+ document.dispatchEvent(
+ new CustomEvent('mxu-start-tasks', {
+ detail: { source: 'global-hotkey', combo: startKey },
+ }),
+ );
+ });
+ }
+ if (stopAllowed) {
+ registeringKey = stopKey;
</code_context>
<issue_to_address>
**过期的快捷键仍在运行**
当全局快捷键在 `registerKeys` 正等待快捷键加载或注册期间被更改或禁用时,effect 清理会异步调用 `unregisterAll()`,但待处理的 `registerKeys` 调用可能会在之后注册旧的快捷键。当两个快捷键都变为不允许使用时,`bj` 处的分支不会开始任何替代注册,因此过期的回调仍处于活动状态,并可能为设置中已不再显示的快捷键分发任务。
请取消待处理的注册,或以其他方式保护它们,确保清理操作之后不会发生过期注册,包括两个快捷键都不允许使用的情况。
另请查看 `src/App.tsx:1665-1668`。
</issue_to_address>
### 评论 2
<location path="src/components/FormControls.tsx" line_range="314" />
<code_context>
+/** 设置里的开始/结束快捷键:单独按键仅 F1–F24,其余必须带修饰键。 */
+export function isAllowedSettingsHotkey(combo: string): boolean {
+ const parts = combo.split('+').filter(Boolean);
+ if (parts.length === 0) return false;
+
+ const key = parts[parts.length - 1];
</code_context>
<issue_to_address>
**带加号的快捷键会被拒绝**
当用户在捕获任务快捷键时按下带修饰键的加号键,`buildHotkeyCombo` 会使用相邻的 `+` 字符对快捷键进行编码,但 `isAllowedSettingsHotkey` 在拆分时会过滤掉空部分,从而丢失该按键。验证器会拒绝该快捷键,捕获界面则显示需要修饰键的警告。
解析带加号的快捷键时,不要丢弃由拆分结果中的空部分所表示的按键。
</issue_to_address>Original comment in English
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/App.tsx" line_range="1677-1689" />
<code_context>
- registeringKey = stopKey;
- // 避免重复注册相同的键
- if (stopKey !== startKey) {
+ if (startAllowed) {
+ registeringKey = startKey;
+ await register(toTauriKey(startKey), () => {
+ const now = Date.now();
+ if (now - lastStartTime < GLOBAL_HOTKEY_THROTTLE_MS) return;
+ lastStartTime = now;
+ document.dispatchEvent(
+ new CustomEvent('mxu-start-tasks', {
+ detail: { source: 'global-hotkey', combo: startKey },
+ }),
+ );
+ });
+ }
+ if (stopAllowed) {
+ registeringKey = stopKey;
</code_context>
<issue_to_address>
**Stale shortcuts keep running**
When global hotkeys are changed or disabled while `registerKeys` is awaiting shortcut loading or registration, the effect cleanup calls `unregisterAll()` asynchronously, but a pending `registerKeys` call can register its old key afterward. When both keys become disallowed, the branch at `bj` starts no replacement registration, so the stale callback remains active and can dispatch tasks for a shortcut no longer shown in settings.
Cancel or otherwise guard pending registrations so cleanup cannot be followed by a stale registration, including when both keys are disallowed.
Also at `src/App.tsx:1665-1668`.
</issue_to_address>
### Comment 2
<location path="src/components/FormControls.tsx" line_range="314" />
<code_context>
+/** 设置里的开始/结束快捷键:单独按键仅 F1–F24,其余必须带修饰键。 */
+export function isAllowedSettingsHotkey(combo: string): boolean {
+ const parts = combo.split('+').filter(Boolean);
+ if (parts.length === 0) return false;
+
+ const key = parts[parts.length - 1];
</code_context>
<issue_to_address>
**Plus-key shortcuts are rejected**
When the user presses a modified plus key while capturing a task shortcut, `buildHotkeyCombo` encodes the shortcut with adjacent `+` characters, but `isAllowedSettingsHotkey` filters out empty parts when splitting it, losing the key. The validator rejects the shortcut and capture shows the modifier-required warning.
Parse plus-key shortcuts without discarding the key represented by the empty split part.
</issue_to_address>| if (startAllowed) { | ||
| registeringKey = startKey; | ||
| await register(toTauriKey(startKey), () => { | ||
| const now = Date.now(); | ||
| if (now - lastStartTime < GLOBAL_HOTKEY_THROTTLE_MS) return; | ||
| lastStartTime = now; | ||
| document.dispatchEvent( | ||
| new CustomEvent('mxu-start-tasks', { | ||
| detail: { source: 'global-hotkey', combo: startKey }, | ||
| }), | ||
| ); | ||
| }); | ||
| } |
There was a problem hiding this comment.
🟡 中等 · 过期的快捷键仍在运行
当全局快捷键在 registerKeys 正等待快捷键加载或注册期间被更改或禁用时,effect 清理会异步调用 unregisterAll(),但待处理的 registerKeys 调用可能会在之后注册旧的快捷键。当两个快捷键都变为不允许使用时,bj 处的分支不会开始任何替代注册,因此过期的回调仍处于活动状态,并可能为设置中已不再显示的快捷键分发任务。
请取消待处理的注册,或以其他方式保护它们,确保清理操作之后不会发生过期注册,包括两个快捷键都不允许使用的情况。
另请查看 src/App.tsx:1665-1668。
AI Agent 提示词
在 `src/App.tsx` 第 1677–1689 行:
**过期的快捷键仍在运行**
当全局快捷键在 `registerKeys` 正等待快捷键加载或注册期间被更改或禁用时,effect 清理会异步调用 `unregisterAll()`,但待处理的 `registerKeys` 调用可能会在之后注册旧的快捷键。当两个快捷键都变为不允许使用时,`bj` 处的分支不会开始任何替代注册,因此过期的回调仍处于活动状态,并可能为设置中已不再显示的快捷键分发任务。
请取消待处理的注册,或以其他方式保护它们,确保清理操作之后不会发生过期注册,包括两个快捷键都不允许使用的情况。
另请查看 `src/App.tsx:1665-1668`。Original comment in English
🟡 Medium · Stale shortcuts keep running
When global hotkeys are changed or disabled while registerKeys is awaiting shortcut loading or registration, the effect cleanup calls unregisterAll() asynchronously, but a pending registerKeys call can register its old key afterward. When both keys become disallowed, the branch at bj starts no replacement registration, so the stale callback remains active and can dispatch tasks for a shortcut no longer shown in settings.
Cancel or otherwise guard pending registrations so cleanup cannot be followed by a stale registration, including when both keys are disallowed.
Also at src/App.tsx:1665-1668.
Prompt for AI agents
In `src/App.tsx` at lines 1677-1689:
**Stale shortcuts keep running**
When global hotkeys are changed or disabled while `registerKeys` is awaiting shortcut loading or registration, the effect cleanup calls `unregisterAll()` asynchronously, but a pending `registerKeys` call can register its old key afterward. When both keys become disallowed, the branch at `bj` starts no replacement registration, so the stale callback remains active and can dispatch tasks for a shortcut no longer shown in settings.
Cancel or otherwise guard pending registrations so cleanup cannot be followed by a stale registration, including when both keys are disallowed.
Also at `src/App.tsx:1665-1668`.| /** 设置里的开始/结束快捷键:单独按键仅 F1–F24,其余必须带修饰键。 */ | ||
| export function isAllowedSettingsHotkey(combo: string): boolean { | ||
| const parts = combo.split('+').filter(Boolean); | ||
| if (parts.length === 0) return false; |
There was a problem hiding this comment.
🟡 中等 · 带加号的快捷键会被拒绝
当用户在捕获任务快捷键时按下带修饰键的加号键,buildHotkeyCombo 会使用相邻的 + 字符对快捷键进行编码,但 isAllowedSettingsHotkey 在拆分时会过滤掉空部分,从而丢失该按键。验证器会拒绝该快捷键,捕获界面则显示需要修饰键的警告。
解析带加号的快捷键时,不要丢弃由拆分结果中的空部分所表示的按键。
AI Agent 提示词
在 `src/components/FormControls.tsx` 第 314 行:
**带加号的快捷键会被拒绝**
当用户在捕获任务快捷键时按下带修饰键的加号键,`buildHotkeyCombo` 会使用相邻的 `+` 字符对快捷键进行编码,但 `isAllowedSettingsHotkey` 在拆分时会过滤掉空部分,从而丢失该按键。验证器会拒绝该快捷键,捕获界面则显示需要修饰键的警告。
解析带加号的快捷键时,不要丢弃由拆分结果中的空部分所表示的按键。Original comment in English
🟡 Medium · Plus-key shortcuts are rejected
When the user presses a modified plus key while capturing a task shortcut, buildHotkeyCombo encodes the shortcut with adjacent + characters, but isAllowedSettingsHotkey filters out empty parts when splitting it, losing the key. The validator rejects the shortcut and capture shows the modifier-required warning.
Parse plus-key shortcuts without discarding the key represented by the empty split part.
Prompt for AI agents
In `src/components/FormControls.tsx` at line 314:
**Plus-key shortcuts are rejected**
When the user presses a modified plus key while capturing a task shortcut, `buildHotkeyCombo` encodes the shortcut with adjacent `+` characters, but `isAllowedSettingsHotkey` filters out empty parts when splitting it, losing the key. The validator rejects the shortcut and capture shows the modifier-required warning.
Parse plus-key shortcuts without discarding the key represented by the empty split part.
逻辑参考腾讯QQ

close MaaEnd/MaaEnd#6313
Summary
Test plan
Made with Cursor
Sourcery 总结
在保持管道热键配置灵活性的同时,确保任务开始和停止操作使用安全的热键。
新功能:
错误修复:
增强功能:
Original summary in English
Summary by Sourcery
Enforce safe hotkey requirements for task start and stop actions while keeping pipeline hotkey configuration flexible.
New Features:
Bug Fixes:
Enhancements: