@devries-cameron20 / t3code-1 / commits / 9b3b1c79a7
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(client): a thread search that fails says so instead of "No results" (#38155)

Co-authored-by: Rajvardhan Patil <243567420+RajvardhanPatil07@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Rajvardhan Patil committed Nov 17, 2026 at 21:57 UTC 9b3b1c79a71ee564ed59b9937fbaefffb458473d
10 files changed +61 -9
apps/mobile/src/features/home/HomeScreen.tsx
+6
@@ -707,6 +707,12 @@ export function HomeScreen(props: HomeScreenProps) {
707 detail={`Looking for "${props.searchQuery}" in messages.`}
708 variant={Platform.OS === "android" ? "plain" : undefined}
709 />
710 + ) : hasSearchQuery && threadSearch.failed ? (
711 + <EmptyState
712 + title="Search failed"
713 + detail={`Couldn't search messages for "${props.searchQuery}". Change the search to try again.`}
714 + variant={Platform.OS === "android" ? "plain" : undefined}
715 + />
716 ) : hasSearchQuery ? (
717 <EmptyState
718 title="No results"
apps/mobile/src/features/keyboard/CommandPalette.tsx
+5 -1
@@ -694,7 +694,11 @@ export function CommandPalette(props: {
694 contentContainerStyle={{ paddingBottom: 8 }}
695 ListEmptyComponent={
696 <Text className="p-5 text-center text-foreground-muted">
697 - {search.isPending ? "Searching…" : "No results"}
697 + {search.isPending
698 + ? "Searching…"
699 + : search.failed
700 + ? "Couldn't search messages"
701 + : "No results"}
702 </Text>
703 }
704 // Message results from slower environments may still arrive below.
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+3 -1
@@ -577,7 +577,9 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
577 : props.searchQuery.trim().length > 0
578 ? threadSearch.isPending
579 ? "Searching thread messages…"
580 - : "No matching threads"
580 + : threadSearch.failed
581 + ? "Couldn't search thread messages"
582 + : "No matching threads"
583 : selectedProjectScope !== null
584 ? `No threads in ${selectedProjectScope.title}`
585 : "No threads yet"}
apps/mobile/src/state/queries.ts
+5
@@ -60,6 +60,7 @@ const EMPTY_THREAD_SEARCH_MATCHES: ReadonlyArray<EnvironmentThreadSearchMatch> =
60 const EMPTY_THREAD_SEARCH_ATOM = Atom.make<ThreadSearchResultsState>({
61 matches: EMPTY_THREAD_SEARCH_MATCHES,
62 isLoading: false,
63 + failed: false,
64 rows: [],
65 }).pipe(Atom.withLabel("mobile:thread-search:empty"));
66
@@ -223,6 +224,8 @@ export function useThreadSearch(
224 /** The query `matches` are for, which lags the typed one while a search runs. */
225 readonly query: string;
226 readonly isPending: boolean;
227 + /** No environment could run the search for the current query, so an empty result is not "no matches". */
228 + readonly failed: boolean;
229 } {
230 // A pasted wall of text searches by its start rather than failing the request.
231 const normalizedQuery = query.trim().slice(0, THREAD_SEARCH_QUERY_MAX_LENGTH).trim();
@@ -241,6 +244,7 @@ export function useThreadSearch(
244 searchKey === null ? EMPTY_THREAD_SEARCH_ATOM : threadSearch.results(searchKey),
245 );
246 const isPending = canSearch && (normalizedQuery !== debouncedQuery || result.isLoading);
247 + const failed = settledQuery !== null && !result.isLoading && result.failed;
248 // What fast environments returned shows without waiting for a slow one;
249 // callers keep shown rows in place with `nextShownOrder`.
250 const ready =
@@ -276,6 +280,7 @@ export function useThreadSearch(
280 matches: visible.matches,
281 query: visible.query,
282 isPending,
283 + failed,
284 };
285 }
286
apps/web/src/components/CommandPalette.tsx
+4 -1
@@ -933,6 +933,7 @@ function OpenCommandPaletteDialog(props: {
933 threadMessageItems,
934 now: searchNow,
935 isSearchPending: isThreadSearchPending,
936 + isSearchFailed: isThreadSearchFailed,
937 } = useCommandPaletteThreadItems({ activeThread: activeThread ?? null, threadSearchQuery });
938 // Recent means used recently: written in or opened, whichever is later. The
939 // open thread would always lead that list, so it is left out.
@@ -3103,7 +3104,9 @@ function OpenCommandPaletteDialog(props: {
3104 }
3105 : isThreadSearchPending
3106 ? { emptyStateMessage: "Searching thread messages…" }
3106 - : {})}
3107 + : isThreadSearchFailed
3108 + ? { emptyStateMessage: "Couldn't search thread messages." }
3109 + : {})}
3110 />
3111 </CommandPaletteContent>
3112 );
apps/web/src/components/CommandPaletteThreadItems.tsx
+1
@@ -249,5 +249,6 @@ export function useCommandPaletteThreadItems(input: {
249 threadMessageItems,
250 now,
251 isSearchPending: messageSearch.isPending,
252 + isSearchFailed: messageSearch.failed,
253 };
254 }
apps/web/src/components/Sidebar.tsx
+5 -1
@@ -3274,7 +3274,11 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
3274 role="status"
3275 className="px-2 py-6 text-center text-xs text-sidebar-muted-foreground"
3276 >
3277 - {threadSearch.isPending ? "Searching thread messages…" : "No threads found"}
3277 + {threadSearch.isPending
3278 + ? "Searching thread messages…"
3279 + : threadSearch.failed
3280 + ? "Couldn't search thread messages"
3281 + : "No threads found"}
3282 </p>
3283 )
3284 ) : null}
apps/web/src/state/queries.ts
+5
@@ -60,6 +60,7 @@ const EMPTY_THREAD_SEARCH_MATCHES: ReadonlyArray<EnvironmentThreadSearchMatch> =
60 const EMPTY_THREAD_SEARCH_ATOM = Atom.make<ThreadSearchResultsState>({
61 matches: EMPTY_THREAD_SEARCH_MATCHES,
62 isLoading: false,
63 + failed: false,
64 rows: [],
65 }).pipe(Atom.withLabel("web:thread-search:empty"));
66
@@ -114,6 +115,8 @@ export function useThreadSearch(
115 readonly matches: ReadonlyArray<EnvironmentThreadSearchMatch>;
116 readonly query: string;
117 readonly isPending: boolean;
118 + /** No environment could run the search for the current query, so an empty result is not "no matches". */
119 + readonly failed: boolean;
120 } {
121 // A pasted wall of text searches by its start rather than failing the request.
122 const normalizedQuery = query.trim().slice(0, THREAD_SEARCH_QUERY_MAX_LENGTH).trim();
@@ -132,6 +135,7 @@ export function useThreadSearch(
135 searchKey === null ? EMPTY_THREAD_SEARCH_ATOM : threadSearch.results(searchKey),
136 );
137 const isPending = canSearch && (normalizedQuery !== debouncedQuery || result.isLoading);
138 + const failed = settledQuery !== null && !result.isLoading && result.failed;
139 // What fast environments returned shows without waiting for a slow one;
140 // callers keep shown rows in place with `nextShownOrder`.
141 const ready =
@@ -167,6 +171,7 @@ export function useThreadSearch(
171 matches: visible.matches,
172 query: visible.query,
173 isPending,
174 + failed,
175 };
176 }
177
packages/client-runtime/src/state/threadSearch.test.ts
+11 -3
@@ -64,15 +64,15 @@ it("ignores invalid search keys", () => {
64 const state = registry.get(searchAtom(makeThreadSearchKey([envA], "a".repeat(201))));
65 const malformedState = registry.get(searchAtom("not json{{"));
66
67 - expect(state).toEqual({ matches: [], isLoading: false, rows: [] });
68 - expect(malformedState).toEqual({ matches: [], isLoading: false, rows: [] });
67 + expect(state).toEqual({ matches: [], isLoading: false, failed: false, rows: [] });
68 + expect(malformedState).toEqual({ matches: [], isLoading: false, failed: false, rows: [] });
69 expect(searchCount).toBe(0);
70 } finally {
71 registry.dispose();
72 }
73 });
74
75 -it("merges successful environments and silently ignores failures", () => {
75 +it("merges successful environments, and reports a failure only when none answered", () => {
76 const result: OrchestrationSearchThreadsResult = {
77 matches: [
78 {
@@ -101,9 +101,17 @@ it("merges successful environments and silently ignores failures", () => {
101 expect(state).toEqual({
102 matches: [{ ...result.matches[0], environmentId: envA }],
103 isLoading: false,
104 + failed: false,
105 rows: [],
106 });
107 expect(threadSearchMatchKey(state.matches[0]!)).toBe('["env-a","thread-a"]');
108 + // With no environment answering, an empty result must not read as "no matches".
109 + expect(registry.get(searchAtom(makeThreadSearchKey([envB], "needle")))).toEqual({
110 + matches: [],
111 + isLoading: false,
112 + failed: true,
113 + rows: [],
114 + });
115
116 registry.dispose();
117 });
packages/client-runtime/src/state/threadSearch.ts
+16 -2
@@ -52,6 +52,11 @@ export interface EnvironmentThreadSearchMatch extends OrchestrationThreadSearchM
52 export interface ThreadSearchResultsState {
53 readonly matches: ReadonlyArray<EnvironmentThreadSearchMatch>;
54 readonly isLoading: boolean;
55 + /**
56 + * Every environment asked failed to answer, so an empty result says nothing about matches. One
57 + * environment failing beside another that answered still counts as an answer.
58 + */
59 + readonly failed: boolean;
60 /** Rows of matching older settled threads, which shells that omit them do not hold. */
61 readonly rows: ReadonlyArray<{
62 readonly environmentId: EnvironmentId;
@@ -121,7 +126,7 @@ export function createThreadSearchResultsAtomFamily<E>(options: {
126 Atom.make((get): ThreadSearchResultsState => {
127 const parsedKey = parseThreadSearchKey(key);
128 if (Option.isNone(parsedKey)) {
124 - return { matches: [], isLoading: false, rows: EMPTY_SEARCH_ROWS };
129 + return { matches: [], isLoading: false, failed: false, rows: EMPTY_SEARCH_ROWS };
130 }
131
132 const [environmentIds, query, scope = {}] = parsedKey.value;
@@ -131,6 +136,8 @@ export function createThreadSearchResultsAtomFamily<E>(options: {
136 const matches: EnvironmentThreadSearchMatch[] = [];
137 const rows: Array<ThreadSearchResultsState["rows"][number]> = [];
138 let isLoading = false;
139 + let asked = 0;
140 + let failures = 0;
141
142 for (const environmentId of environmentIds) {
143 const before = options.olderSettledBefore
@@ -152,6 +159,8 @@ export function createThreadSearchResultsAtomFamily<E>(options: {
159 }),
160 );
161 isLoading ||= result.waiting;
162 + asked += 1;
163 + if (AsyncResult.isFailure(result)) failures += 1;
164 const value = AsyncResult.getOrElse(result, () => null);
165 if (value !== null) {
166 matches.push(...value.matches.map((match) => ({ ...match, environmentId })));
@@ -164,7 +173,12 @@ export function createThreadSearchResultsAtomFamily<E>(options: {
173 }
174 }
175
167 - return { matches, isLoading, rows: rows.length === 0 ? EMPTY_SEARCH_ROWS : rows };
176 + return {
177 + matches,
178 + isLoading,
179 + failed: asked > 0 && failures === asked,
180 + rows: rows.length === 0 ? EMPTY_SEARCH_ROWS : rows,
181 + };
182 }).pipe(Atom.withLabel(`${options.labelPrefix}:${key}`)),
183 );
184 const rowsAtom = Atom.family((rowsKey: string) => {