Skip to content

Commit 61d20f8

Browse files
committed
fix: search result error pages
1 parent 4805dcd commit 61d20f8

3 files changed

Lines changed: 99 additions & 7 deletions

File tree

components/publication-projects-body.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ export default function PublicationProjectsBody({ pmid }: { pmid: string }) {
166166
<NextLink href="/">Search by title or keywords</NextLink>
167167
</Button>
168168
</Flex>
169+
<Text size="2" style={{ color: "var(--gray-11)" }}>
170+
Prefer plain English?{" "}
171+
<Link asChild underline="always">
172+
<NextLink href="/mcp">Use seqout with an LLM</NextLink>
173+
</Link>{" "}
174+
to ask for this paper&rsquo;s datasets in your own words.
175+
</Text>
169176
</>
170177
) : (
171178
<>

components/search-page-body.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
import {
2727
Button,
2828
Flex,
29+
Link,
2930
Select,
3031
Separator,
3132
Skeleton,
@@ -40,6 +41,7 @@ import {
4041
useQuery,
4142
useQueryClient,
4243
} from "@tanstack/react-query";
44+
import NextLink from "next/link";
4345
import { usePathname, useRouter, useSearchParams } from "next/navigation";
4446
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4547

@@ -2357,6 +2359,20 @@ export default function SearchPageBody() {
23572359
<span className="seqout-accession">GSE196830</span>).
23582360
</Text>
23592361
)}
2362+
{/* Shown alongside a "did you mean" too: a misspelling and a query
2363+
keyword search can't express are both cases where describing
2364+
the data in plain English gets further. */}
2365+
<Text
2366+
size="2"
2367+
align="center"
2368+
style={{ color: "var(--gray-11)", maxWidth: "32rem" }}
2369+
>
2370+
Prefer plain English?{" "}
2371+
<Link asChild underline="always">
2372+
<NextLink href="/mcp">Use seqout with an LLM</NextLink>
2373+
</Link>{" "}
2374+
to describe the data you&rsquo;re after in your own words.
2375+
</Text>
23602376
</Flex>
23612377
)}
23622378
</Flex>

components/submission-studies-body.tsx

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import ResultCard from "@/components/result-card";
44
import SearchBar from "@/components/search-bar";
5-
import { getJson } from "@/utils/api";
5+
import { ApiError, getJson } from "@/utils/api";
66
import { getProjectShortUrl } from "@/utils/shortUrl";
7-
import { Button, Flex, Heading, Text } from "@radix-ui/themes";
7+
import { Button, Flex, Heading, Link, Text } from "@radix-ui/themes";
88
import { useQuery } from "@tanstack/react-query";
9+
import NextLink from "next/link";
910
import { useRouter } from "next/navigation";
1011
import { useEffect, useState } from "react";
1112

@@ -35,14 +36,18 @@ export default function SubmissionStudiesBody({
3536
const [showAll, setShowAll] = useState(false);
3637
const acc = accession.toUpperCase();
3738

38-
const { data, isLoading, isError, error } = useQuery({
39+
const { data, isLoading, isError, error, refetch } = useQuery({
3940
queryKey: ["submission-studies", acc],
4041
queryFn: () => getJson<SubmissionResponse>(`/submission/${acc}`),
4142
enabled: isSubmission(acc),
4243
retry: false,
4344
staleTime: Infinity,
4445
});
4546

47+
// The API 404s when nothing is filed under the submission; anything else is a
48+
// failure on our side and shouldn't read as "not found".
49+
const noStudies = error instanceof ApiError && error.status === 404;
50+
4651
const studies = data?.studies ?? [];
4752
const visible = showAll ? studies : studies.slice(0, INITIAL_ROWS);
4853
const soleStudy = studies.length === 1 ? studies[0].accession : null;
@@ -66,10 +71,18 @@ export default function SubmissionStudiesBody({
6671
px={{ initial: "4", md: "3" }}
6772
direction="column"
6873
>
69-
<Heading size="6">Studies for submission {acc}</Heading>
74+
{/* Suppressed for a non-submission accession: the message below is its
75+
own heading, and "Studies for submission FOO" above "FOO isn't a
76+
submission accession" just contradicts itself. */}
77+
{isSubmission(acc) && (
78+
<Heading size="6">Studies for submission {acc}</Heading>
79+
)}
7080

7181
{isLoading && <Text color="gray">Searching…</Text>}
72-
{isError && (
82+
83+
{/* Not a submission accession at all, so the query never ran — without
84+
this the page is just a heading over blank space. */}
85+
{!isSubmission(acc) && (
7386
<Flex
7487
align="center"
7588
justify="center"
@@ -78,18 +91,74 @@ export default function SubmissionStudiesBody({
7891
gap="3"
7992
>
8093
<Text size={{ initial: "5", md: "6" }} weight="bold">
81-
No studies found for submission {acc}
94+
{acc} isn&rsquo;t a submission accession
8295
</Text>
8396
<Text
8497
size="2"
8598
align="center"
8699
style={{ color: "var(--gray-11)", maxWidth: "32rem" }}
87100
>
88-
{String(error)}
101+
Submission accessions look like SRA123456, ERA123456 or DRA123456.
102+
For a study, sample or run, paste it into the search bar above.
89103
</Text>
90104
</Flex>
91105
)}
92106

107+
{isError && (
108+
<Flex
109+
align="center"
110+
justify="center"
111+
direction="column"
112+
height="20rem"
113+
gap="3"
114+
>
115+
{noStudies ? (
116+
<>
117+
<Text size={{ initial: "5", md: "6" }} weight="bold">
118+
No studies found for submission {acc}
119+
</Text>
120+
<Text
121+
size="2"
122+
align="center"
123+
style={{ color: "var(--gray-11)", maxWidth: "32rem" }}
124+
>
125+
No SRP/ERP/DRP study in seqout is filed under this submission.
126+
The accession may belong to an archive we don&rsquo;t mirror,
127+
or its studies may not be public yet.
128+
</Text>
129+
<Button variant="soft" asChild>
130+
<NextLink href="/">Search by title or keywords</NextLink>
131+
</Button>
132+
<Text size="2" style={{ color: "var(--gray-11)" }}>
133+
Prefer plain English?{" "}
134+
<Link asChild underline="always">
135+
<NextLink href="/mcp">Use seqout with an LLM</NextLink>
136+
</Link>{" "}
137+
to describe the data you&rsquo;re after in your own words.
138+
</Text>
139+
</>
140+
) : (
141+
<>
142+
<Text size={{ initial: "5", md: "6" }} weight="bold">
143+
Couldn&rsquo;t load submission {acc}
144+
</Text>
145+
<Text
146+
size="2"
147+
align="center"
148+
style={{ color: "var(--gray-11)", maxWidth: "32rem" }}
149+
>
150+
The request failed before we could look this submission up, so
151+
we don&rsquo;t know whether it has studies. This one is on us,
152+
not your accession.
153+
</Text>
154+
<Button variant="soft" onClick={() => refetch()}>
155+
Try again
156+
</Button>
157+
</>
158+
)}
159+
</Flex>
160+
)}
161+
93162
{data && studies.length > 1 && (
94163
<Text color="gray" weight="light">
95164
{studies.length.toLocaleString()} studies

0 commit comments

Comments
 (0)