fix(coding-agent): preserve copy-prompt retry collision

This commit is contained in:
KamijoToma
2026-06-18 02:54:22 +08:00
parent 3dd95e081e
commit b526132b5d
2 changed files with 22 additions and 7 deletions
@@ -586,9 +586,16 @@ export class CustomEditor extends Editor {
return;
}
// Intercept configured copy-prompt shortcut
if (this.#matchesAction(canonical, "app.clipboard.copyPrompt") && this.onCopyPrompt) {
this.onCopyPrompt();
return;
}
// Intercept configured retry shortcut. Later user/custom handlers keep
// precedence so adding the default Alt+R binding does not steal existing
// shortcuts such as app.plan.toggle or extension commands.
// shortcuts such as app.plan.toggle or extension commands; copy-prompt is
// checked above for the same reason.
if (this.#matchesAction(canonical, "app.retry") && this.onRetry) {
const customHandler = this.#customMatchKeys.get(canonical);
if (customHandler) {
@@ -599,12 +606,6 @@ export class CustomEditor extends Editor {
return;
}
// Intercept configured copy-prompt shortcut
if (this.#matchesAction(canonical, "app.clipboard.copyPrompt") && this.onCopyPrompt) {
this.onCopyPrompt();
return;
}
// Check custom key handlers (extensions)
const handler = this.#customMatchKeys.get(canonical);
if (handler) {
@@ -30,4 +30,18 @@ describe("CustomEditor keybindings", () => {
expect(customHandler).toHaveBeenCalledTimes(1);
expect(onRetry).not.toHaveBeenCalled();
});
it("lets copy-prompt remaps keep precedence over the default retry chord", () => {
const editor = new CustomEditor(getEditorTheme());
const onRetry = vi.fn();
const onCopyPrompt = vi.fn();
editor.onRetry = onRetry;
editor.onCopyPrompt = onCopyPrompt;
editor.setActionKeys("app.clipboard.copyPrompt", ["alt+r"]);
editor.handleInput("\x1br");
expect(onCopyPrompt).toHaveBeenCalledTimes(1);
expect(onRetry).not.toHaveBeenCalled();
});
});