Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(search): preserve delegation during IME Shift+Enter (#9981)

沙雕的小鱼儿 boyfeiyu8cc95bcea78e
diff --git a/packages/views/search/search-command.test.tsx b/packages/views/search/search-command.test.tsx
index eb902e0411..f02a69e234 100644
--- a/packages/views/search/search-command.test.tsx
+++ b/packages/views/search/search-command.test.tsx
@@ -1047,6 +1047,42 @@ describe("SearchCommand", () => {
expect(api("quickCreateIssue")).not.toHaveBeenCalled();
});
+ it.each([
+ { isComposing: true, keyCode: 13 },
+ { isComposing: false, keyCode: 229 },
+ ])("preserves delegation during IME Shift+Enter ($isComposing, $keyCode)", async (ime) => {
+ const user = userEvent.setup();
+ const prompt = "fix the Safari login callback 500";
+ renderSearch();
+ await user.type(input(), prompt);
+ await waitFor(() => expect(selectedValue()).toBe("delegate:submit"));
+
+ fireEvent.compositionStart(input());
+ const event = new KeyboardEvent("keydown", {
+ key: "Enter",
+ shiftKey: true,
+ ...ime,
+ bubbles: true,
+ cancelable: true,
+ });
+ fireEvent(input(), event);
+
+ expect.soft(event.defaultPrevented).toBe(false);
+ expect.soft(renderedValues()).toContain("delegate:submit");
+ expect(input()).toHaveValue(prompt);
+ expect(useSearchStore.getState().open).toBe(true);
+ expect(api("quickCreateIssue")).not.toHaveBeenCalled();
+ expect(mockOpenModal).not.toHaveBeenCalled();
+ expect(mockPush).not.toHaveBeenCalled();
+
+ fireEvent.compositionEnd(input());
+ fireEvent.keyDown(input(), { key: "Enter", shiftKey: true });
+ await waitFor(() => expect(renderedValues()).not.toContain("delegate:submit"));
+ expect(input()).toHaveValue(prompt);
+ expect(useSearchStore.getState().open).toBe(true);
+ expect(api("quickCreateIssue")).not.toHaveBeenCalled();
+ });
+
it("does not read a plain keyword as an instruction", async () => {
const user = userEvent.setup();
renderSearch();
diff --git a/packages/views/search/search-command.tsx b/packages/views/search/search-command.tsx
index 01e2d2c107..31eb59f4ed 100644
--- a/packages/views/search/search-command.tsx
+++ b/packages/views/search/search-command.tsx
@@ -5,6 +5,7 @@ import { ChevronRight, SearchIcon, Sparkles } from "@multica/ui/icons";
import { Command as CommandPrimitive } from "cmdk";
import { selectCommandBarContexts, useCommandBarContextStore } from "@multica/core/command-bar";
import { createShortcutChord } from "@multica/core/shortcuts";
+import { isImeComposing } from "@multica/core/utils";
import {
Dialog,
DialogContent,
@@ -180,7 +181,7 @@ function PaletteFrame({
return;
}
// ⇧↵ treats an input that read as an instruction as a plain search.
- if (!current && e.key === "Enter" && e.shiftKey && model.delegate) {
+ if (!current && e.key === "Enter" && e.shiftKey && model.delegate && !isImeComposing(e)) {
e.preventDefault();
setDismissedDelegateFor(rawQuery);
}