From 14b20c183058b4bde08c666d3fab67797a2c155a Mon Sep 17 00:00:00 2001 From: "Nick T." <73005126+tiliakoos@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:50:35 -0500 Subject: [PATCH] fix(web): a long pull request search no longer ends in a broken character The search shown in the empty pull request list is cut at 48 units, which could leave half of an emoji. The cut now stops one unit earlier then. --- .../pullRequest/PullRequestListEmptyState.tsx | 4 +++- ...quest-search-keeps-whole-characters.e2e.ts | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 scripts/scenarios/pull-request-search-keeps-whole-characters.e2e.ts 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}…”`); + }, +);