Skip to content
TypeScript

fix(web): new-thread shortcuts work while the command palette lists them (#19055)

Roger V6fe97fed8d9d
diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx
index db89bdb0812..14078841086 100644
--- a/apps/web/src/components/CommandPalette.tsx
+++ b/apps/web/src/components/CommandPalette.tsx
@@ -2875,14 +2875,26 @@ function OpenCommandPaletteDialog(props: {
function handleKeyDown(event: KeyboardEvent<HTMLInputElement>): void {
const command = resolveShortcutCommand(event, keybindings, {
platform: navigator.platform,
- context: { modelPickerOpen: false },
+ context: { modelPickerOpen: false, editableFocus: true },
});
- if (threadJumpIndexFromCommand(command ?? "") !== null) {
+ // Global new-thread handlers ignore shortcuts while the palette is open.
+ const isJump = threadJumpIndexFromCommand(command ?? "") !== null;
+ const isNewThread =
+ !event.nativeEvent.isComposing &&
+ event.keyCode !== 229 &&
+ (command === "chat.new" ||
+ command === "chat.newLocal" ||
+ command === "chat.newWithoutProject");
+ const matchingItem =
+ isJump || isNewThread
+ ? displayedGroups
+ .flatMap((group) => group.items)
+ .find((item) => item.shortcutCommand === command)
+ : undefined;
+ if (isJump || matchingItem) {
+ (event as typeof event & { preventBaseUIHandler?: () => void }).preventBaseUIHandler?.();
event.preventDefault();
event.stopPropagation();
- const matchingItem = displayedGroups
- .flatMap((group) => group.items)
- .find((item) => item.shortcutCommand === command);
if (matchingItem) {
executeItem(matchingItem);
}