diff --git a/apps/web/src/components/pullRequest/PullRequestListEmptyState.tsx b/apps/web/src/components/pullRequest/PullRequestListEmptyState.tsx index 7edf26efc3acc..c5e26dfd6e67e 100644 --- a/apps/web/src/components/pullRequest/PullRequestListEmptyState.tsx +++ b/apps/web/src/components/pullRequest/PullRequestListEmptyState.tsx @@ -1,4 +1,5 @@ import { RefreshIcon } from "~/components/ui/refresh-icon"; +import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations"; import { T, useGT, Var } from "gt-react"; import { PlusIcon, SearchIcon } from "lucide-react"; @@ -70,7 +71,8 @@ export function PullRequestListEmptyState({ onRefresh: () => void; }) { const gt = useGT(); - const shownQuery = query.length > 48 ? `${query.slice(0, 48)}…` : query; + const shownQuery = + query.length > 48 ? `${query.slice(0, splitsSurrogatePair(query, 48) ? 47 : 48)}…` : query; if (!hasProjects) { return ( diff --git a/scripts/scenarios/pull-request-search-keeps-whole-characters.e2e.ts b/scripts/scenarios/pull-request-search-keeps-whole-characters.e2e.ts new file mode 100644 index 0000000000000..f28695fa19bfd --- /dev/null +++ b/scripts/scenarios/pull-request-search-keeps-whole-characters.e2e.ts @@ -0,0 +1,21 @@ +import { expect } from "e2e"; + +import { test, WEB } from "./t3.ts"; + +const KEPT = "a".repeat(47); +// The emoji's two UTF-16 units straddle unit 48, where the shown search is cut. +const QUERY = `${KEPT}😀 and the rest of the search`; + +test( + "A long pull request search that matches nothing ends without a broken character", + WEB, + async ({ t3, app, screen }) => { + await t3.project("demo"); + await t3.open(`/pull-requests?${new URLSearchParams({ q: QUERY })}`); + + const title = screen.getByText(/^Nothing matches/); + await title.waitFor({ timeout: 60_000 }); + await app.screenshot("no-matches"); + await expect(title).toHaveText(`Nothing matches “${KEPT}…”`); + }, +);