setComposing(true)}
+ onCompositionEnd={() => setComposing(false)}
+ />
+ {!commandMode && (
+
+ {(["all", "thread", "message"] as const).map((type) => (
+
+ ))}
+
+
+ )}
+
+ {!commandMode && (
+ <>
+ {!search.supported && (
+
+ {t.workspaceSearch.unsupported}
+
+ )}
+ {search.supported && search.isError && (
+
+
{t.workspaceSearch.error}
+
+
+ )}
+ {search.supported &&
+ !search.isError &&
+ busy &&
+ search.items.length === 0 && (
+
+
+ {t.workspaceSearch.searching}
+
+ )}
+ {search.data?.pages.some((page) => page.indexing) && (
+
+ {t.workspaceSearch.indexing}
+
+ )}
+ {input.trim() &&
+ search.data?.pages[0]?.messages_available === false && (
+
+ {t.workspaceSearch.unavailable}
+
+ )}
+ {(["thread", "message"] as const).map((type) => {
+ const hits = search.items.filter(
+ (hit) => hit.type === type,
+ );
+ if (!hits.length) return null;
+ return (
+
+ {hits.map((hit) => (
+ {
+ router.push(pathOfSearchHit(hit));
+ setOpen(false);
+ }}
+ >
+ {type === "thread" ? (
+
+ ) : (
+
+ )}
+
+
+
+ {hit.title.trim()
+ ? hit.title
+ : t.workspaceSearch.untitled}
+
+ {hit.archived && (
+
+
+ {t.workspaceSearch.archived}
+
+ )}
+
+ {type === "message" && (
+
+ {hit.snippet.map((segment, index) =>
+ segment.matched ? (
+
+ {segment.text}
+
+ ) : (
+ {segment.text}
+ ),
+ )}
+
+ )}
+
+ {type === "message" && (
+
+ {hit.role === "user"
+ ? t.workspaceSearch.user
+ : t.workspaceSearch.assistant}
+
+ )}
+
+ {hit.updated_at
+ ? new Date(
+ hit.updated_at,
+ ).toLocaleDateString()
+ : ""}
+
+
+
+
+ ))}
+
+ );
+ })}
+ {!busy &&
+ !search.isError &&
+ search.supported &&
+ search.items.length === 0 &&
+ !search.data?.pages.some((page) => page.indexing) && (
+
+ {t.workspaceSearch.empty}
+
+ )}
+ {search.hasNextPage && (
+ void search.fetchNextPage()}
+ >
+ {t.workspaceSearch.more}
+
+ )}
+ >
+ )}
+ {commandMode &&
+ ![
+ t.sidebar.newChat,
+ t.common.settings,
+ t.shortcuts.keyboardShortcuts,
+ ].some((label) =>
+ label
+ .toLocaleLowerCase()
+ .includes(
+ input.trimStart().slice(1).trim().toLocaleLowerCase(),
+ ),
+ ) && (
+
+ {t.workspaceSearch.empty}
+
+ )}
+ {(commandMode || !input.trim()) && (
+
+ {[
+ {
+ label: t.sidebar.newChat,
+ icon: MessageSquarePlusIcon,
+ action: handleNewChat,
+ shortcut: `${metaKey}${shiftKey}N`,
+ },
+ {
+ label: t.common.settings,
+ icon: SettingsIcon,
+ action: handleOpenSettings,
+ shortcut: `${metaKey},`,
+ },
+ {
+ label: t.shortcuts.keyboardShortcuts,
+ icon: KeyboardIcon,
+ action: handleShowShortcuts,
+ shortcut: `${metaKey}/`,
+ },
+ ]
+ .filter(
+ (action) =>
+ !commandMode ||
+ action.label
+ .toLocaleLowerCase()
+ .includes(
+ input
+ .trimStart()
+ .slice(1)
+ .trim()
+ .toLocaleLowerCase(),
+ ),
+ )
+ .map((action) => (
+
+
+ {action.label}
+ {action.shortcut}
+
+ ))}
+
+ )}
+
+
+ {t.workspaceSearch.hint}
+
+