@devries-cameron20 / t3code Mirror · read-only / commits / c350ee7e15
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

feat(web): filter the issues list by project (#38256)

Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>

Bilal Bakr committed Nov 19, 2026 at 02:54 UTC c350ee7e15d0f993b406d243d2b4685b10a437e0
10 files changed +199 -12
apps/server/src/issue/IssueService.test.ts
+15 -2
@@ -548,15 +548,20 @@ describe("IssueService with a standalone tracker", () => {
548 const projects = [project({ id: "web", repository: "acme/web" }), project({ id: "notes" })];
549 const trackers = [fakeTracker(record(GITHUB)), fakeStandaloneTracker(record(LINEAR))];
550 const bound = yield* makeService({
551 - projects,
551 + projects: [...projects, project({ id: "api", repository: "acme/api" })],
552 trackers,
553 bindings: { ["web" as ProjectId]: { tracker: LINEAR, scope: "ENG" } },
554 });
555
556 const result = yield* bound.list({ state: "open" });
557 - expect(listed.sort()).toEqual(["github github.com acme/web", "linear linear.app ENG"]);
557 + expect(listed.sort()).toEqual([
558 + "github github.com acme/api",
559 + "github github.com acme/web",
560 + "linear linear.app ENG",
561 + ]);
562 expect(result.entries.map((entry) => [entry.tracker, entry.scope, entry.key]).sort()).toEqual(
563 [
564 + ["github", "acme/api", "1"],
565 ["github", "acme/web", "1"],
566 ["linear", "ENG", "ENG-1"],
567 ],
@@ -571,6 +576,14 @@ describe("IssueService with a standalone tracker", () => {
576 host: "linear.app",
577 scope: "ENG",
578 });
579 + // Narrowed to one project, both of its trackers are still read.
580 + listed.length = 0;
581 + const selected = yield* bound.list({ state: "open", projectId: "web" as ProjectId });
582 + expect(listed.sort()).toEqual(["github github.com acme/web", "linear linear.app ENG"]);
583 + expect(selected.entries.map((entry) => [entry.projectId, entry.scope]).sort()).toEqual([
584 + ["web", "ENG"],
585 + ["web", "acme/web"],
586 + ]);
587 // A reference picks the project's tracker by kind; both are the project's own, so writable.
588 const linearRef = {
589 projectId: "web" as ProjectId,
apps/web/src/components/issue/IssueListFilterPickers.tsx
+50 -2
@@ -1,6 +1,11 @@
1 import type { IssueCandidatesTarget } from "@t3tools/client-runtime/state/issues";
2 -import type { IssueInvolvement, IssueListState } from "@t3tools/contracts";
3 -import { LayersIcon, ListFilterIcon, TagIcon, UserIcon } from "lucide-react";
2 +import type {
3 + EnvironmentId,
4 + IssueInvolvement,
5 + IssueListState,
6 + ProjectId,
7 +} from "@t3tools/contracts";
8 +import { FolderGit2Icon, LayersIcon, ListFilterIcon, TagIcon, UserIcon } from "lucide-react";
9 import { T, useGT } from "gt-react";
10 import { useState } from "react";
11
@@ -21,13 +26,17 @@ import {
26 } from "~/components/ui/menu";
27 import { useIssueFilterCandidates } from "~/state/issues";
28
29 +import type { ProjectFaviconProject } from "../ProjectFavicon";
30 +
31 import {
32 PullRequestFilterRadioSubmenu,
33 + pullRequestProjectKey,
34 type PullRequestFilterOption,
35 } from "../pullRequest/PullRequestListFilters";
36 import { pullRequestLabelColor } from "../pullRequest/pullRequestList.logic";
37
38 const VISIBLE_CHOICES = 30;
39 +const ALL_PROJECTS = "all";
40 const matches = (needle: string, ...fields: ReadonlyArray<string | null | undefined>) =>
41 needle.length === 0 || fields.some((field) => field?.toLowerCase().includes(needle));
42
@@ -44,15 +53,39 @@ export function IssueFiltersMenu(props: {
53 onLabels: (labels: ReadonlyArray<string>) => void;
54 assignee: string | undefined;
55 onAssignee: (assignee: string | undefined) => void;
56 + projects: ReadonlyArray<ProjectFaviconProject & { readonly id: ProjectId }>;
57 + project: { environmentId: EnvironmentId; projectId: ProjectId } | undefined;
58 + onProject: (project: { environmentId: EnvironmentId; projectId: ProjectId } | undefined) => void;
59 }) {
60 const gt = useGT();
61 const [open, setOpen] = useState(false);
62 const count = [
63 props.state !== "open",
64 props.involvement !== "all",
65 + props.project,
66 props.assignee,
67 ...props.labels,
68 ].filter(Boolean).length;
69 + const projectValue = props.project
70 + ? pullRequestProjectKey({
71 + id: props.project.projectId,
72 + environmentId: props.project.environmentId,
73 + })
74 + : ALL_PROJECTS;
75 + const projectOptions: ReadonlyArray<PullRequestFilterOption<string>> = [
76 + { value: ALL_PROJECTS, label: gt("All projects"), Icon: LayersIcon },
77 + // A remembered project this client does not list stays shown, so the filter can be taken off.
78 + ...(projectValue !== ALL_PROJECTS &&
79 + !props.projects.some((project) => pullRequestProjectKey(project) === projectValue)
80 + ? [{ value: projectValue, label: gt("Unavailable project"), Icon: FolderGit2Icon }]
81 + : []),
82 + ...props.projects.map((project) => ({
83 + value: pullRequestProjectKey(project),
84 + label: project.title,
85 + Icon: FolderGit2Icon,
86 + project,
87 + })),
88 + ];
89 // Read when the menu opens, not with every listing: one request per scope.
90 const scopes = open ? props.scopes : [];
91 return (
@@ -81,6 +114,21 @@ export function IssueFiltersMenu(props: {
114 options={props.involvementOptions}
115 onChange={props.onInvolvement}
116 />
117 + {props.projects.length > 1 || props.project ? (
118 + <PullRequestFilterRadioSubmenu
119 + label={gt("Project")}
120 + value={projectValue}
121 + options={projectOptions}
122 + onChange={(next) => {
123 + const project = props.projects.find((p) => pullRequestProjectKey(p) === next);
124 + props.onProject(
125 + project
126 + ? { environmentId: project.environmentId, projectId: project.id }
127 + : undefined,
128 + );
129 + }}
130 + />
131 + ) : null}
132 <MenuSeparator />
133 <MenuSub>
134 <MenuSubTrigger>
apps/web/src/components/issue/IssuesPage.tsx
+29 -5
@@ -55,6 +55,7 @@ import {
55 import { m, type MessageResolver } from "~/i18n/messages";
56 import { resolveFilterOptions } from "../pullRequest/pullRequestListOptions";
57 import { IssueFiltersMenu } from "./IssueListFilterPickers";
58 +import { issueFilterProjects } from "./issuesSearch.logic";
59 import { ISSUE_SAVED_VIEWS } from "./issueSavedViews";
60 import { SavedViewsMenu } from "~/components/SavedViewsMenu";
61 import { PullRequestCompactFilterMenu } from "../pullRequest/PullRequestCompactFilterMenu";
@@ -199,22 +200,32 @@ export function IssuesPage() {
200 (environment) => environment.serverConfig?.environment.capabilities.issues === true,
201 );
202 const environmentLabels = new Map(environments.map((e) => [e.environmentId, e.label] as const));
203 + const filterProjects = issueFilterProjects(
204 + projects.filter((project) =>
205 + capableEnvironments.some((e) => e.environmentId === project.environmentId),
206 + ),
207 + environmentLabels,
208 + );
209 + const scopedProject =
210 + search.issueServer && search.issueProject
211 + ? { environmentId: search.issueServer, projectId: search.issueProject }
212 + : undefined;
213
214 const debouncedQuery = useDebouncedValue(search.q ?? "", 300);
215 const listInput: IssueListInput = {
216 state: search.status,
217 involvement: search.who,
218 limit: PAGE_SIZE,
219 + ...(scopedProject ? { projectId: scopedProject.projectId } : {}),
220 ...(search.host ? { host: search.host } : {}),
221 ...(debouncedQuery ? { query: debouncedQuery } : {}),
222 ...(search.label?.length ? { labels: search.label } : {}),
223 ...(search.assignee ? { assignee: search.assignee } : {}),
224 ...(search.order ? { sort: search.order } : {}),
225 };
214 - const targets: ReadonlyArray<IssueListTarget> = capableEnvironments.map((e) => ({
215 - environmentId: e.environmentId,
216 - input: listInput,
217 - }));
226 + const targets: ReadonlyArray<IssueListTarget> = capableEnvironments
227 + .filter((e) => scopedProject === undefined || e.environmentId === scopedProject.environmentId)
228 + .map((e) => ({ environmentId: e.environmentId, input: listInput }));
229 const list = useIssueList(targets);
230 // Refreshing a list still loading would cancel it and start over, losing the scopes already read.
231 useLiveRefresh(
@@ -277,7 +288,7 @@ export function IssuesPage() {
288 )
289 : held;
290 const groups = groupIssues(shown, debouncedQuery, projects, search.order ?? "updated");
280 - const filterScopes = issueFilterScopes(shown, projects);
291 + const filterScopes = issueFilterScopes(shown, projects, scopedProject);
292
293 const hostOptions = hostOptionsFor(
294 [...held.values()].flatMap((page) => page.answer.trackers),
@@ -290,6 +301,9 @@ export function IssuesPage() {
301 const next: IssuesSearch = {
302 who: merged.who ?? search.who,
303 status: merged.status ?? search.status,
304 + ...(merged.issueServer && merged.issueProject
305 + ? { issueServer: merged.issueServer, issueProject: merged.issueProject }
306 + : {}),
307 ...(merged.host ? { host: merged.host } : {}),
308 q: merged.q || undefined,
309 ...(merged.label?.length ? { label: merged.label } : {}),
@@ -676,6 +690,14 @@ export function IssuesPage() {
690 onLabels={(label) => updateSearch({ label })}
691 assignee={search.assignee}
692 onAssignee={(assignee) => updateSearch({ assignee })}
693 + projects={filterProjects}
694 + project={scopedProject}
695 + onProject={(project) =>
696 + updateSearch({
697 + issueServer: project?.environmentId,
698 + issueProject: project?.projectId,
699 + })
700 + }
701 />
702 <SavedViewsMenu
703 kind={ISSUE_SAVED_VIEWS}
@@ -685,6 +707,8 @@ export function IssuesPage() {
707 updateSearch({
708 who: view.who,
709 status: view.status,
710 + issueServer: view.issueServer,
711 + issueProject: view.issueProject,
712 host: view.host,
713 q: view.q,
714 label: view.label,
apps/web/src/components/issue/issueListPreferences.ts
+10 -1
@@ -1,6 +1,6 @@
1 import * as Schema from "effect/Schema";
2
3 -import { IssueInvolvement, IssueListState } from "@t3tools/contracts";
3 +import { EnvironmentId, IssueInvolvement, IssueListState, ProjectId } from "@t3tools/contracts";
4
5 /**
6 * What the issues page remembers between visits; the selection in the URL is not part of it.
@@ -11,6 +11,8 @@ import { IssueInvolvement, IssueListState } from "@t3tools/contracts";
11 export interface IssueListPreferences {
12 readonly who: IssueInvolvement;
13 readonly status: IssueListState;
14 + readonly issueServer?: EnvironmentId | undefined;
15 + readonly issueProject?: ProjectId | undefined;
16 readonly host?: string | undefined;
17 readonly q?: string | undefined;
18 /** `label`, `assignee` and `order` for the same reason: the pull-request page has `labels` and `sort`. */
@@ -30,6 +32,8 @@ const BoundedPreference = Schema.String.check(Schema.isMaxLength(200));
32 export const IssueListPreferencesSchema = Schema.Struct({
33 who: IssueInvolvement,
34 status: IssueListState,
35 + issueServer: Schema.optional(EnvironmentId),
36 + issueProject: Schema.optional(ProjectId),
37 host: Schema.optional(BoundedPreference),
38 q: Schema.optional(BoundedPreference),
39 label: Schema.optional(Schema.Array(BoundedPreference).check(Schema.isMaxLength(20))),
@@ -48,6 +52,8 @@ function storage(): PreferenceStorage | undefined {
52 export function issueListPreferences(search: {
53 readonly who: IssueInvolvement;
54 readonly status: IssueListState;
55 + readonly issueServer?: EnvironmentId | undefined;
56 + readonly issueProject?: ProjectId | undefined;
57 readonly host?: string | undefined;
58 readonly q?: string | undefined;
59 readonly label?: ReadonlyArray<string> | undefined;
@@ -57,6 +63,9 @@ export function issueListPreferences(search: {
63 return {
64 who: search.who,
65 status: search.status,
66 + ...(search.issueServer && search.issueProject
67 + ? { issueServer: search.issueServer, issueProject: search.issueProject }
68 + : {}),
69 ...(search.host ? { host: search.host } : {}),
70 ...(search.q ? { q: search.q } : {}),
71 ...(search.label?.length ? { label: search.label } : {}),
apps/web/src/components/issue/issueSavedViews.test.ts
+5
@@ -1,10 +1,14 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 +import { EnvironmentId, ProjectId } from "@t3tools/contracts";
4 +
5 import { issueViewMatches } from "./issueSavedViews";
6
7 const preferences = {
8 who: "assigned",
9 status: "open",
10 + issueServer: EnvironmentId.make("env-1"),
11 + issueProject: ProjectId.make("project-1"),
12 host: "github.com",
13 q: "crash",
14 label: ["bug", "priority"],
@@ -20,5 +24,6 @@ describe("saved issue views", () => {
24 );
25 expect(issueViewMatches(view, { ...preferences, assignee: undefined })).toBe(false);
26 expect(issueViewMatches(view, { ...preferences, label: ["bug"] })).toBe(false);
27 + expect(issueViewMatches(view, { ...preferences, issueProject: undefined })).toBe(false);
28 });
29 });
apps/web/src/components/issue/issuesSearch.logic.test.ts
+27 -1
@@ -1,6 +1,9 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 -import { issuesSearchFromUrl } from "./issuesSearch.logic";
3 +import type { EnvironmentProject } from "@t3tools/client-runtime/state/models";
4 +import { EnvironmentId, ProjectId } from "@t3tools/contracts";
5 +
6 +import { issueFilterProjects, issuesSearchFromUrl } from "./issuesSearch.logic";
7
8 describe("issuesSearchFromUrl", () => {
9 it("replaces a malformed filter instead of letting the raw value through", () => {
@@ -18,3 +21,26 @@ describe("issuesSearchFromUrl", () => {
21 });
22 });
23 });
24 +
25 +describe("issueFilterProjects", () => {
26 + it("keeps every project on one repository as its own choice", () => {
27 + const environmentId = EnvironmentId.make("env");
28 + const project = (id: string, isScratch = false) =>
29 + ({
30 + id: ProjectId.make(id),
31 + environmentId,
32 + title: "t3code",
33 + workspaceRoot: `/work/${id}`,
34 + repositoryIdentity: { canonicalKey: "github.com/pingdotgg/t3code" },
35 + isScratch,
36 + }) as unknown as EnvironmentProject;
37 + const choices = issueFilterProjects(
38 + [project("main"), project("worktree"), project("scratch", true)],
39 + new Map([[environmentId, "laptop"]]),
40 + );
41 + expect(choices.map((choice) => [choice.id, choice.title])).toEqual([
42 + ["main", "t3code · laptop · /work/main"],
43 + ["worktree", "t3code · laptop · /work/worktree"],
44 + ]);
45 + });
46 +});
apps/web/src/components/issue/issuesSearch.logic.ts
+16
@@ -1,3 +1,5 @@
1 +import { pullRequestFilterProjects } from "@t3tools/client-runtime/pull-request-project-filter";
2 +import type { EnvironmentProject } from "@t3tools/client-runtime/state/models";
3 import type { EnvironmentId, ProjectId } from "@t3tools/contracts";
4
5 import type { IssuesSearch } from "./IssuesPage";
@@ -19,6 +21,8 @@ export const issuesSearchFromUrl = (raw: Record<string, unknown>): IssuesSearch
21 who:
22 raw.who === "assigned" || raw.who === "authored" || raw.who === "mentioned" ? raw.who : "all",
23 status: raw.status === "closed" || raw.status === "all" ? raw.status : "open",
24 + issueServer: bounded(raw.issueServer) as EnvironmentId | undefined,
25 + issueProject: bounded(raw.issueProject) as ProjectId | undefined,
26 host: bounded(raw.host),
27 q: bounded(raw.q),
28 label: labels(raw.label),
@@ -31,3 +35,15 @@ export const issuesSearchFromUrl = (raw: Record<string, unknown>): IssuesSearch
35 scope: bounded(raw.scope),
36 key: bounded(raw.key),
37 });
38 +
39 +/** One choice per project: projects on one repository can read different Linear teams. */
40 +export const issueFilterProjects = (
41 + projects: ReadonlyArray<EnvironmentProject>,
42 + environmentLabels: ReadonlyMap<EnvironmentId, string>,
43 +) =>
44 + pullRequestFilterProjects(
45 + projects
46 + .filter((project) => !project.isScratch)
47 + .map((project) => ({ ...project, repositoryIdentity: null })),
48 + environmentLabels,
49 + );
docs/user/source-control.md
+1 -1
@@ -361,7 +361,7 @@ out from the matching organization and repository.
361 The Issues page lists the issues of every project whose remote is on GitHub, GitLab, Azure
362 DevOps or Forgejo, grouped per tracker account. Open it from the sidebar's utility row or with
363 **Open issues** in the command palette. Filter by open or closed, by your involvement
364 -(assigned, opened by you, mentioning you), and by tracker; the search box asks the tracker
364 +(assigned, opened by you, mentioning you), by project, and by tracker; the search box asks the tracker
365 itself where it can search. Press **Load more** at the end of a group to read further back.
366 The **Views** menu saves and restores a search, filter, and sort setup, as it does for pull
367 requests.
packages/client-runtime/src/issueList.test.ts
+41
@@ -6,6 +6,7 @@ import type {
6 IssueTrackerSummary,
7 ProjectId,
8 } from "@t3tools/contracts";
9 +import type { EnvironmentProject } from "./state/models.ts";
10 import { describe, expect, it } from "vite-plus/test";
11
12 import {
@@ -142,6 +143,46 @@ describe("issueFilterScopes", () => {
143 [environmentId, hold(answer({ trackers: [tracker({})], entries: [], scopes: [scope] }))],
144 ]);
145 expect(issueFilterScopes(held, [])).toEqual([{ environmentId, input: scope }]);
146 + const otherProjectId = "web" as ProjectId;
147 + const projects = [api, otherProjectId].map((id) => ({
148 + id,
149 + environmentId,
150 + repositoryIdentity: {
151 + provider: "github",
152 + canonicalKey: `github.com/acme/${id}`,
153 + owner: "acme",
154 + name: id,
155 + },
156 + })) as unknown as ReadonlyArray<EnvironmentProject>;
157 + const withRepositories = new Map([
158 + [
159 + environmentId,
160 + hold(
161 + answer({
162 + trackers: [
163 + tracker({}),
164 + tracker({ tracker: "github" as IssueTrackerKind, host: "github.com" }),
165 + ],
166 + scopes: [scope, { ...scope, projectId: otherProjectId, scope: "WEB" }],
167 + }),
168 + ),
169 + ],
170 + ]);
171 + expect(
172 + issueFilterScopes(withRepositories, projects, { environmentId, projectId: api }),
173 + ).toEqual([
174 + {
175 + environmentId,
176 + input: { projectId: api, tracker: "github", host: "github.com", scope: "acme/api" },
177 + },
178 + { environmentId, input: scope },
179 + ]);
180 + expect(
181 + issueFilterScopes(withRepositories, projects, {
182 + environmentId: "other" as EnvironmentId,
183 + projectId: api,
184 + }),
185 + ).toEqual([]);
186 });
187
188 it("skips a tracker that cannot be read", () => {
packages/client-runtime/src/issueList.ts
+5
@@ -8,6 +8,7 @@ import type {
8 IssueScopeRef,
9 IssueTrackerSummary,
10 SourceControlProviderKind,
11 + ProjectId,
12 } from "@t3tools/contracts";
13
14 import { mergeIssueListPage } from "./state/issues.ts";
@@ -167,11 +168,14 @@ export function groupIssues(
168 export function issueFilterScopes(
169 held: ReadonlyMap<EnvironmentId, HeldIssuePage>,
170 projects: ReadonlyArray<EnvironmentProject>,
171 + selectedProject?: { readonly environmentId: EnvironmentId; readonly projectId: ProjectId },
172 ) {
173 const scopes: Array<{ readonly environmentId: EnvironmentId; readonly input: IssueScopeRef }> =
174 [];
175 for (const [environmentId, page] of held) {
176 + if (selectedProject && selectedProject.environmentId !== environmentId) continue;
177 for (const project of projects) {
178 + if (selectedProject && selectedProject.projectId !== project.id) continue;
179 if (project.environmentId !== environmentId) continue;
180 const identity = project.repositoryIdentity;
181 const kind = identity?.provider as SourceControlProviderKind | undefined;
@@ -204,6 +208,7 @@ export function issueFilterScopes(
208 scope,
209 }));
210 for (const input of covered) {
211 + if (selectedProject && selectedProject.projectId !== input.projectId) continue;
212 const host = input.host?.toLowerCase();
213 const tracker = page.answer.trackers.find(
214 (t) => t.tracker === input.tracker && t.host.toLowerCase() === host,