@devries-cameron20 / t3code-1 / commits / 983654b3b2
Fork 0

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

fix(web): an invalid host filter in an Issues link no longer crashes the page (#38190)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 17, 2026 at 16:54 UTC 983654b3b2f7267a69e3d5d049d781aadbbc3166
8 files changed +38 -36
apps/web/src/components/issue/IssuesPage.tsx
+6 -6
@@ -93,13 +93,13 @@ import { useDebouncedValue } from "~/state/queries";
93 import { primaryServerKeybindingsAtom } from "~/state/server";
94
95 export interface IssuesSearch extends IssueListPreferences {
96 - readonly selectedEnvironmentId?: EnvironmentId;
97 - readonly selectedProjectId?: ProjectId;
96 + readonly selectedEnvironmentId?: EnvironmentId | undefined;
97 + readonly selectedProjectId?: ProjectId | undefined;
98 /** Part of the panel tab's identity, so a link reopens the tab a row press opened. */
99 - readonly selectedHost?: string;
100 - readonly tracker?: string;
101 - readonly scope?: string;
102 - readonly key?: string;
99 + readonly selectedHost?: string | undefined;
100 + readonly tracker?: string | undefined;
101 + readonly scope?: string | undefined;
102 + readonly key?: string | undefined;
103 }
104
105 const STATE_TABS = [
apps/web/src/components/issue/issueListPreferences.ts
+1 -1
@@ -11,7 +11,7 @@ import { IssueInvolvement, IssueListState } from "@t3tools/contracts";
11 export interface IssueListPreferences {
12 readonly who: IssueInvolvement;
13 readonly status: IssueListState;
14 - readonly host?: string;
14 + readonly host?: string | undefined;
15 readonly q?: string | undefined;
16 /** `label`, `assignee` and `order` for the same reason: the pull-request page has `labels` and `sort`. */
17 readonly label?: ReadonlyArray<string> | undefined;
apps/web/src/components/issue/issuesSearch.logic.test.ts
+3 -2
@@ -3,10 +3,11 @@ import { describe, expect, it } from "vite-plus/test";
3 import { issuesSearchFromUrl } from "./issuesSearch.logic";
4
5 describe("issuesSearchFromUrl", () => {
6 - it("replaces a malformed label or order instead of letting the raw value through", () => {
6 + it("replaces a malformed filter instead of letting the raw value through", () => {
7 // The router lays the validated keys over the raw search, so a key left out keeps its raw value.
8 - const raw = { label: true, order: "oldest", assignee: " " };
8 + const raw = { label: true, order: "oldest", assignee: " ", host: true };
9 const search = { ...raw, ...issuesSearchFromUrl(raw) };
10 + expect(search.host).toBeUndefined();
11 expect(search.label).toBeUndefined();
12 expect(search.assignee).toBeUndefined();
13 expect(search.order).toBeUndefined();
apps/web/src/components/issue/issuesSearch.logic.ts
+9 -19
@@ -7,37 +7,27 @@ const bounded = (value: unknown): string | undefined => {
7 const text = typeof value === "number" ? String(value) : value;
8 return typeof text === "string" && text.trim() ? text.trim().slice(0, 200) : undefined;
9 };
10 -/** A search key that is either present as a string or absent, never present as undefined. */
11 -function present<K extends string, V extends string>(
12 - key: K,
13 - value: string | undefined,
14 -): { [P in K]?: V } {
15 - return value === undefined ? {} : ({ [key]: value } as { [P in K]: V });
16 -}
10
11 const labels = (raw: unknown): ReadonlyArray<string> | undefined => {
12 const names = (Array.isArray(raw) ? raw : [raw]).flatMap((name) => bounded(name) ?? []);
13 return names.length === 0 ? undefined : names.slice(0, 20);
14 };
15
16 +// Every optional key is an own key, even when undefined: the router lays these over the parent
17 +// route's unvalidated search, where a key left out would keep its raw value.
18 export const issuesSearchFromUrl = (raw: Record<string, unknown>): IssuesSearch => ({
19 who:
20 raw.who === "assigned" || raw.who === "authored" || raw.who === "mentioned" ? raw.who : "all",
21 status: raw.status === "closed" || raw.status === "all" ? raw.status : "open",
27 - ...present("host", bounded(raw.host)),
28 - // `q`, `label`, `assignee` and `order` are always own keys: the router lays these over the parent route's
29 - // unvalidated search, where a key left out would keep its raw value.
22 + host: bounded(raw.host),
23 q: bounded(raw.q),
24 label: labels(raw.label),
25 assignee: bounded(raw.assignee),
26 order: raw.order === "created" ? "created" : undefined,
34 - ...present<"selectedEnvironmentId", EnvironmentId>(
35 - "selectedEnvironmentId",
36 - bounded(raw.selectedEnvironmentId),
37 - ),
38 - ...present<"selectedProjectId", ProjectId>("selectedProjectId", bounded(raw.selectedProjectId)),
39 - ...present("selectedHost", bounded(raw.selectedHost)),
40 - ...present("tracker", bounded(raw.tracker)),
41 - ...present("scope", bounded(raw.scope)),
42 - ...present("key", bounded(raw.key)),
27 + selectedEnvironmentId: bounded(raw.selectedEnvironmentId) as EnvironmentId | undefined,
28 + selectedProjectId: bounded(raw.selectedProjectId) as ProjectId | undefined,
29 + selectedHost: bounded(raw.selectedHost),
30 + tracker: bounded(raw.tracker),
31 + scope: bounded(raw.scope),
32 + key: bounded(raw.key),
33 });
apps/web/src/components/pullRequest/pullRequestListPreferences.ts
+1 -1
@@ -24,7 +24,7 @@ export interface PullRequestListPreferences {
24 readonly state: PullRequestListState;
25 readonly environmentId?: EnvironmentId;
26 readonly projectId?: ProjectId;
27 - readonly host?: string;
27 + readonly host?: string | undefined;
28 readonly q?: string | undefined;
29 readonly draft?: "only" | "hide";
30 readonly review?: NonNullable<PullRequestListFilters["review"]>;
apps/web/src/components/pullRequest/usePullRequestListView.ts
+4 -4
@@ -47,12 +47,12 @@ export interface PullRequestsSearch extends PullRequestListPreferences {
47 readonly selectedUrl?: string;
48 readonly environmentId?: EnvironmentId;
49 readonly projectId?: ProjectId;
50 - readonly host?: string;
50 + readonly host?: string | undefined;
51 readonly repository?: string;
52 readonly number?: number;
53 - readonly selectedProjectId?: ProjectId;
54 - readonly selectedHost?: string;
55 - readonly selectedEnvironmentId?: EnvironmentId;
53 + readonly selectedProjectId?: ProjectId | undefined;
54 + readonly selectedHost?: string | undefined;
55 + readonly selectedEnvironmentId?: EnvironmentId | undefined;
56 }
57
58 const SEARCH_DEBOUNCE_MS = 250;
apps/web/src/reopenClosedView.ts
+3 -3
@@ -56,9 +56,9 @@ export function planNextReopen(
56 type PullRequestsSearchLike = Partial<PullRequestListPreferences> & {
57 repository?: string;
58 number?: number;
59 - selectedProjectId?: ProjectId;
60 - selectedHost?: string;
61 - selectedEnvironmentId?: EnvironmentId;
59 + selectedProjectId?: ProjectId | undefined;
60 + selectedHost?: string | undefined;
61 + selectedEnvironmentId?: EnvironmentId | undefined;
62 };
63
64 export function pullRequestsSearchForRestore<S extends PullRequestsSearchLike>(
scripts/scenarios/issues-invalid-host-keeps-page.e2e.ts new
+11
@@ -0,0 +1,11 @@
1 +import { expect } from "e2e";
2 +
3 +import { test, WEB } from "./t3.ts";
4 +
5 +test("An invalid host filter keeps the Issues page open", WEB, async ({ t3, app, browser }) => {
6 + await t3.project("demo");
7 + await t3.open("/issues?host=true");
8 +
9 + await app.screenshot("issues-invalid-host");
10 + await expect(browser.locator("h1")).toHaveText("Issues");
11 +});