@devries-cameron20 / t3code Mirror · read-only / commits / 85dcfa61ca
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, 08:30 UTC

feat(web): add the Issues page and issue detail panel (#19260)

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>

Julius Marminge committed Nov 16, 2026 at 22:00 UTC 85dcfa61cab4bfe70b73f94c09f0dfa135a4302d
34 files changed +3059 -74
apps/server/src/environment/ServerEnvironment.ts
+1
@@ -227,6 +227,7 @@ export const make = Effect.gen(function* () {
227 fileAttachments: { maxUploadBytes: PROVIDER_SEND_TURN_MAX_FILE_BYTES },
228 pullRequests: true,
229 pullRequestChecks: true,
230 + issues: true,
231 linkedThreadRefreshes: true,
232 sideChats: true,
233 vcsBranchStatus: true,
apps/web/src/closedViewStore.ts
+10
@@ -95,6 +95,16 @@ const isClosedViewEntry = (entry: unknown): entry is ClosedViewEntry => {
95 (surface.host === undefined || typeof surface.host === "string") &&
96 (surface.url === undefined || typeof surface.url === "string")
97 );
98 + case "issue":
99 + return (
100 + typeof surface.projectId === "string" &&
101 + typeof surface.tracker === "string" &&
102 + typeof surface.scope === "string" &&
103 + typeof surface.key === "string" &&
104 + (surface.environmentId === undefined || typeof surface.environmentId === "string") &&
105 + (surface.host === undefined || typeof surface.host === "string") &&
106 + (surface.url === undefined || typeof surface.url === "string")
107 + );
108 default:
109 return false;
110 }
apps/web/src/components/CommandPalette.tsx
+19
@@ -278,6 +278,8 @@ import { pickableProjectGroups } from "@t3tools/client-runtime/state/project-gro
278 import { buildSidebarProjectPickerEntries } from "../sidebarProjectGrouping";
279 import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
280 import { readPullRequestListPreferences } from "~/components/pullRequest/pullRequestListPreferences";
281 +import { readIssueListPreferences } from "~/components/issue/issueListPreferences";
282 +import { IssueGlyph } from "~/components/issue/issuePresentation";
283 import { useThreadRouteTarget } from "../hooks/useThreadRouteTarget";
284 import { threadRecentUse } from "@t3tools/shared/paletteSearch";
285
@@ -1654,6 +1656,23 @@ function OpenCommandPaletteDialog(props: {
1656 });
1657 }
1658
1659 + if (
1660 + environments.some(
1661 + (environment) => environment.serverConfig?.environment.capabilities.issues === true,
1662 + )
1663 + ) {
1664 + actionItems.push({
1665 + kind: "action",
1666 + value: "action:issues",
1667 + searchTerms: ["issues", "issue", "bugs", "tracker", "github", "triage"],
1668 + title: "Open issues",
1669 + icon: <IssueGlyph.issue className={ITEM_ICON_CLASS} />,
1670 + run: async () => {
1671 + await navigate({ to: "/issues", search: readIssueListPreferences() });
1672 + },
1673 + });
1674 + }
1675 +
1676 actionItems.push({
1677 kind: "action",
1678 value: "action:use-in-another-app",
apps/web/src/components/ReopenClosedViewShortcut.tsx
+9 -2
@@ -23,6 +23,7 @@ import {
23 reopenClosedView,
24 } from "../reopenClosedView";
25 import {
26 + ISSUES_PANEL_REF,
27 PULL_REQUESTS_PANEL_REF,
28 selectActiveRightPanel,
29 selectSelectedRightPanelSurface,
@@ -42,6 +43,7 @@ import {
43 resolveThreadRouteTarget,
44 } from "../threadRoutes";
45 import { toastManager } from "./ui/toast";
46 +import { readIssueListPreferences } from "./issue/issueListPreferences";
47
48 const PREVIEW_FORWARDED_COMMANDS = [
49 "workspace.focusNext",
@@ -58,6 +60,8 @@ const PREVIEW_FORWARDED_COMMANDS = [
60
61 const isGlobalPullRequests = (ref: ScopedThreadRef) =>
62 scopedThreadKey(ref) === scopedThreadKey(PULL_REQUESTS_PANEL_REF);
63 +const isGlobalIssues = (ref: ScopedThreadRef) =>
64 + scopedThreadKey(ref) === scopedThreadKey(ISSUES_PANEL_REF);
65
66 export function ReopenClosedViewShortcut() {
67 const navigate = useNavigate();
@@ -91,7 +95,7 @@ export function ReopenClosedViewShortcut() {
95 const { drop, restore } = planNextReopen(useClosedViewStore.getState().entries, (entry) => {
96 const ref = entry.threadRef;
97 const panel = selectThreadRightPanelState(panelsByThread, ref);
94 - if (isGlobalPullRequests(ref)) {
98 + if (isGlobalPullRequests(ref) || isGlobalIssues(ref)) {
99 return {
100 environmentKnown: true,
101 catalogReady: true,
@@ -119,7 +123,8 @@ export function ReopenClosedViewShortcut() {
123
124 const ref = restore.threadRef;
125 const globalPullRequests = isGlobalPullRequests(ref);
122 - const thread = globalPullRequests ? null : readThreadShell(ref);
126 + const globalIssues = isGlobalIssues(ref);
127 + const thread = globalPullRequests || globalIssues ? null : readThreadShell(ref);
128 const owner = thread ?? drafts.getDraftThreadByRef(ref);
129 const project = owner ? readProject(scopeProjectRef(ref.environmentId, owner.projectId)) : null;
130 if (!(await reopenClosedView(restore, { openPreview, workspaceAvailable: project !== null }))) {
@@ -136,6 +141,8 @@ export function ReopenClosedViewShortcut() {
141 to: "/pull-requests",
142 search: (previous) => pullRequestsSearchForRestore(previous, selected),
143 });
144 + } else if (globalIssues) {
145 + await navigate({ to: "/issues", search: readIssueListPreferences() });
146 } else {
147 const draftId = thread === null ? drafts.getDraftIdByRef(ref) : null;
148 if (draftId !== null)
apps/web/src/components/RightPanelTabs.tsx
+44
@@ -17,6 +17,7 @@ import {
17 import type {
18 ContextMenuItem,
19 EnvironmentId,
20 + IssueTrackerKind,
21 PreviewSessionSnapshot,
22 ProjectId,
23 PullRequestState,
@@ -36,6 +37,7 @@ import { restrictToFirstScrollableAncestor, restrictToHorizontalAxis } from "@dn
37 import { horizontalListSortingStrategy, SortableContext, useSortable } from "@dnd-kit/sortable";
38 import { CSS } from "@dnd-kit/utilities";
39 import {
40 + CircleDotIcon,
41 Smartphone,
42 ChevronDown,
43 ChevronLeft,
@@ -64,6 +66,8 @@ import { isElectron } from "~/env";
66 import type { DesktopPreviewOverlay } from "~/previewStateStore";
67 import type { RightPanelSurface } from "~/rightPanelStore";
68 import { cn } from "~/lib/utils";
69 +import { issueStatePresentation } from "~/components/issue/issuePresentation";
70 +import { issueEnvironment } from "~/state/issues";
71 import { resolveShortcutCommand, type ShortcutMatchContext } from "~/keybindings";
72 import { readLocalApi } from "~/localApi";
73 import { useStableCallback } from "~/hooks/useStableCallback";
@@ -592,6 +596,9 @@ function surfaceTitle(
596 return `#${surface.number}`;
597 case "pull-requests":
598 return "Pull requests";
599 + case "issue":
600 + // A git host numbers its issues; a tracker with keys of its own, such as Linear, names them.
601 + return /^\d+$/.test(surface.key) ? `#${surface.key}` : surface.key;
602 case "device":
603 return surface.title ?? surface.target?.name ?? "Device";
604 case "side-chat":
@@ -684,6 +691,8 @@ function SurfaceIcon({
691 );
692 case "pull-requests":
693 return <PullRequestGlyph.link className="size-3 shrink-0" />;
694 + case "issue":
695 + return <IssueSurfaceIcon surface={surface} environmentId={environmentId} />;
696 case "side-chat":
697 return <SideChatTabIcon environmentId={environmentId} threadId={surface.threadId} />;
698 case "device":
@@ -756,6 +765,41 @@ export function resolvePullRequestTabLink(
765 return newest;
766 }
767
768 +/** The issue's own state mark, from the detail its panel already reads; a plain dot until then. */
769 +function IssueSurfaceIcon({
770 + surface,
771 + environmentId,
772 +}: {
773 + surface: Extract<RightPanelSurface, { kind: "issue" }>;
774 + environmentId: EnvironmentId | null;
775 +}) {
776 + const resolvedEnvironmentId =
777 + (surface.environmentId as EnvironmentId | undefined) ?? environmentId;
778 + const detail = useEnvironmentQuery(
779 + resolvedEnvironmentId === null
780 + ? null
781 + : issueEnvironment.detail({
782 + environmentId: resolvedEnvironmentId,
783 + input: {
784 + projectId: surface.projectId as ProjectId,
785 + tracker: surface.tracker as IssueTrackerKind,
786 + ...(surface.host ? { host: surface.host } : {}),
787 + scope: surface.scope,
788 + key: surface.key,
789 + },
790 + }),
791 + ).data;
792 + if (detail === null) return <CircleDotIcon className="size-3 shrink-0" />;
793 + const presentation = issueStatePresentation(detail.state);
794 + return (
795 + <presentation.Icon
796 + role="img"
797 + aria-label={presentation.label}
798 + className={cn("size-3 shrink-0", presentation.toneClassName)}
799 + />
800 + );
801 +}
802 +
803 function PullRequestSurfaceIcon({
804 surface,
805 environmentId,
apps/web/src/components/issue/IssueCommentComposer.tsx new
+110
@@ -0,0 +1,110 @@
1 +import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
2 +import type { EnvironmentId, IssueRef } from "@t3tools/contracts";
3 +import { ArrowUpIcon } from "lucide-react";
4 +import { useRef, useState } from "react";
5 +
6 +import { TextFieldSpeechControls, useTextFieldSpeech } from "~/speech/useTextFieldSpeech";
7 +import { issueEnvironment } from "~/state/issues";
8 +import { useAtomCommand } from "~/state/use-atom-command";
9 +
10 +import { ComposerSurface } from "../chat/ComposerSurface";
11 +import { readableFailure } from "../pullRequest/pullRequestDetail.logic";
12 +import { Spinner } from "../ui/spinner";
13 +import { toastManager } from "../ui/toast";
14 +
15 +/** The thread composer's card, floating over the issue's timeline, with a comment as its message. */
16 +export function IssueCommentComposer({
17 + environmentId,
18 + reference,
19 + blocked,
20 +}: {
21 + environmentId: EnvironmentId;
22 + reference: IssueRef;
23 + /** Why the viewer cannot comment here; null when they can. */
24 + blocked: string | null;
25 +}) {
26 + const [body, setBody] = useState("");
27 + const [submitting, setSubmitting] = useState(false);
28 + const textareaRef = useRef<HTMLTextAreaElement>(null);
29 + const comment = useAtomCommand(issueEnvironment.comment, { reportFailure: false });
30 + const locked = blocked !== null || submitting;
31 + const speech = useTextFieldSpeech({
32 + environmentId,
33 + projectId: reference.projectId,
34 + ownerKey: JSON.stringify(["issue-comment", environmentId, reference]),
35 + text: body,
36 + textareaRef,
37 + onTextChange: setBody,
38 + disabled: locked,
39 + });
40 +
41 + const submit = async (text: string) => {
42 + if (text.trim().length === 0 || locked) return;
43 + setSubmitting(true);
44 + const result = await comment({ environmentId, input: { ...reference, body: text } });
45 + setSubmitting(false);
46 + if (result._tag === "Failure") {
47 + toastManager.add({
48 + type: "error",
49 + title: "The comment could not be posted",
50 + description: readableFailure(squashAtomCommandFailure(result), "The tracker refused it."),
51 + });
52 + return;
53 + }
54 + setBody("");
55 + };
56 + const submitAfterDictation = () => speech.submitAfterDictation((text) => void submit(text));
57 + const submitDisabled =
58 + speech.preparing || (body.trim().length === 0 && !speech.blocksSubmission) || locked;
59 +
60 + return (
61 + <div className="pointer-events-none absolute inset-x-0 bottom-0 z-10 px-3 pb-3">
62 + <ComposerSurface.Shell className="pointer-events-auto">
63 + <ComposerSurface.Host>
64 + <form
65 + className="relative z-10 flex flex-col"
66 + onSubmit={(event) => {
67 + event.preventDefault();
68 + submitAfterDictation();
69 + }}
70 + >
71 + <textarea
72 + ref={textareaRef}
73 + rows={2}
74 + className="field-sizing-content max-h-64 min-h-[2lh] w-full resize-none bg-transparent px-3.5 pt-3 pb-1 text-base text-foreground outline-none wrap-anywhere placeholder:text-muted-foreground/70 disabled:opacity-64 sm:text-sm"
75 + aria-label="Add a comment"
76 + placeholder={blocked ?? "Leave a comment"}
77 + value={body}
78 + // Lock while posting because success clears the draft.
79 + disabled={locked}
80 + readOnly={speech.freezesEditor}
81 + onChange={(event) => setBody(event.target.value)}
82 + onKeyDown={(event) => {
83 + if (event.nativeEvent.isComposing || event.keyCode === 229) return;
84 + if (event.key === "Enter" && (event.metaKey || event.ctrlKey) && !event.shiftKey) {
85 + event.preventDefault();
86 + if (!event.repeat) submitAfterDictation();
87 + }
88 + }}
89 + />
90 + <div className="flex flex-wrap items-center justify-end gap-2 px-2.5 pb-2.5">
91 + <TextFieldSpeechControls speech={speech} disabled={locked} />
92 + <button
93 + type="submit"
94 + className="flex size-8 items-center justify-center rounded-full bg-message-action text-message-action-foreground shadow-xs transition-all duration-150 enabled:cursor-pointer enabled:shadow-message-action/24 enabled:inset-shadow-control-highlight hover:scale-105 hover:bg-message-action-hover active:shadow-none active:inset-shadow-control-pressed disabled:pointer-events-none disabled:bg-foreground/12 disabled:text-muted-foreground disabled:shadow-none"
95 + disabled={submitDisabled}
96 + aria-label={submitting ? "Posting comment" : "Comment"}
97 + >
98 + {submitting ? (
99 + <Spinner size="sm" aria-hidden />
100 + ) : (
101 + <ArrowUpIcon aria-hidden className="size-4" />
102 + )}
103 + </button>
104 + </div>
105 + </form>
106 + </ComposerSurface.Host>
107 + </ComposerSurface.Shell>
108 + </div>
109 + );
110 +}
apps/web/src/components/issue/IssueDetailGhost.tsx new
+106
@@ -0,0 +1,106 @@
1 +import type { IssueListEntry } from "@t3tools/contracts";
2 +import { ExternalLinkIcon } from "lucide-react";
3 +
4 +import { cn } from "~/lib/utils";
5 +import { formatRelativeTimeLabel } from "~/timestampFormat";
6 +
7 +import { Button } from "../ui/button";
8 +import { PullRequestDetailTitleRow } from "../pullRequest/PullRequestDetailLayout";
9 +import { GhostBar } from "../pullRequest/PullRequestGhosts";
10 +import {
11 + PullRequestActorLabel,
12 + PullRequestLabelChip,
13 + PullRequestMetaLine,
14 +} from "../pullRequest/pullRequestPresentation";
15 +import { IssueStateGlyph, issueTrackerPresentation } from "./issuePresentation";
16 +
17 +/** The issue panel while its detail loads, showing what the list row already knows. */
18 +export function IssueDetailGhost({ seed }: { seed?: IssueListEntry | null }) {
19 + const tracker = seed ? issueTrackerPresentation(seed.tracker) : null;
20 + return (
21 + <div
22 + role="status"
23 + aria-label="Loading issue"
24 + className={cn(
25 + "scrollbar-gutter-both flex h-full min-h-0 flex-col gap-4 overflow-hidden px-4 pt-3 pb-4",
26 + !seed && "motion-safe:animate-skeleton",
27 + )}
28 + >
29 + {seed && tracker ? (
30 + <>
31 + <PullRequestDetailTitleRow className="gap-2">
32 + <IssueStateGlyph state={seed.state} />
33 + <span className="shrink-0 font-mono text-xs text-muted-foreground">
34 + {seed.displayKey}
35 + </span>
36 + <span className="min-w-0 flex-1 truncate text-xs text-muted-foreground">
37 + <tracker.Icon aria-hidden className="mr-1 inline size-3 align-[-2px]" />
38 + {seed.scope}
39 + </span>
40 + <Button
41 + size="icon-xs"
42 + variant="ghost"
43 + aria-label={`Open on ${tracker.providerName}`}
44 + render={<a href={seed.url} target="_blank" rel="noopener noreferrer" />}
45 + >
46 + <ExternalLinkIcon aria-hidden className="size-3.5" />
47 + </Button>
48 + </PullRequestDetailTitleRow>
49 + {/* Leaves room for the edit button, so the title wraps the same once loaded. */}
50 + <h2 className="pr-7 text-base font-semibold leading-snug">{seed.title}</h2>
51 + <PullRequestMetaLine className="text-xs text-muted-foreground">
52 + <PullRequestActorLabel actor={seed.author} />
53 + <span>opened {formatRelativeTimeLabel(seed.createdAt)}</span>
54 + {seed.closedAt ? <span>closed {formatRelativeTimeLabel(seed.closedAt)}</span> : null}
55 + </PullRequestMetaLine>
56 + {/* Both rows hold the height of the picker button the loaded panel puts in them. */}
57 + <div className="flex min-h-6 flex-wrap items-center gap-1.5 text-xs text-muted-foreground">
58 + <span className="shrink-0">Labels</span>
59 + {seed.labels.length === 0 ? <span>none</span> : null}
60 + {seed.labels.map((label) => (
61 + <PullRequestLabelChip key={label.name} label={label} />
62 + ))}
63 + </div>
64 + <div className="flex min-h-6 flex-wrap items-center gap-1.5 text-xs text-muted-foreground">
65 + <span className="shrink-0">Assignees</span>
66 + {seed.assignees.length === 0 ? <span>none</span> : null}
67 + {seed.assignees.map((actor) => (
68 + <PullRequestActorLabel key={actor.login} actor={actor} />
69 + ))}
70 + </div>
71 + </>
72 + ) : (
73 + <>
74 + <div className="flex h-7 items-center gap-2">
75 + <GhostBar className="size-4 rounded-full" />
76 + <GhostBar className="w-12" />
77 + <GhostBar className="w-32" />
78 + </div>
79 + <GhostBar className="h-5 w-3/4" />
80 + <GhostBar className="w-48" />
81 + <GhostBar className="w-32" />
82 + </>
83 + )}
84 + <div className={cn("flex flex-col gap-4", seed && "motion-safe:animate-skeleton")}>
85 + <div className="flex flex-col gap-2.5 rounded-lg border border-border/60 p-3">
86 + <GhostBar className="w-20" />
87 + <GhostBar className="h-3.5 w-full" />
88 + <GhostBar className="h-3.5 w-5/6" />
89 + <GhostBar className="h-3.5 w-2/3" />
90 + <GhostBar className="h-3.5 w-3/4" />
91 + </div>
92 + <GhostBar className="w-16" />
93 + {[0, 1].map((row) => (
94 + <div key={row} className="flex items-start gap-2">
95 + <GhostBar className="size-5 shrink-0 rounded-full" />
96 + <div className="flex-1 space-y-1.5">
97 + <GhostBar className="w-1/3" />
98 + <GhostBar className="w-full" />
99 + <GhostBar className="w-3/4" />
100 + </div>
101 + </div>
102 + ))}
103 + </div>
104 + </div>
105 + );
106 +}
apps/web/src/components/issue/IssueDetailPanel.tsx new
+877
@@ -0,0 +1,877 @@
1 +import { useAtomValue } from "@effect/atom-react";
2 +import { prependIssueComments } from "@t3tools/client-runtime/state/issues";
3 +import {
4 + issueAssigneeHeld,
5 + issueAssigneesAfterPicks,
6 + issueLabelsAfterPicks,
7 + issuePicksFor,
8 + issueWriteAfterPicks,
9 + noIssuePicks,
10 +} from "@t3tools/client-runtime/issue-selection";
11 +import { isSelected, toggleSelection } from "@t3tools/client-runtime/pull-request-selection";
12 +import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
13 +import type {
14 + EnvironmentId,
15 + IssueAssigneeCandidate,
16 + IssueComment,
17 + IssueDetail,
18 + IssueEvent,
19 + IssueLabelCandidate,
20 + IssueLinkedPullRequest,
21 + IssueListEntry,
22 + IssueReaction,
23 + IssueRef,
24 + PullRequestRef,
25 + ScopedThreadRef,
26 +} from "@t3tools/contracts";
27 +import {
28 + CheckIcon,
29 + ChevronDownIcon,
30 + ExternalLinkIcon,
31 + TagIcon,
32 + UserPlusIcon,
33 + UsersIcon,
34 +} from "lucide-react";
35 +import { useState, type ReactNode } from "react";
36 +
37 +import { RefreshIcon } from "~/components/ui/refresh-icon";
38 +import { issueEnvironment } from "~/state/issues";
39 +import { useProjects } from "~/state/entities";
40 +import { useEnvironmentQuery } from "~/state/query";
41 +import { useAtomCommand } from "~/state/use-atom-command";
42 +import { formatRelativeTimeLabel } from "~/timestampFormat";
43 +
44 +import { Button, InlineButton } from "../ui/button";
45 +import { Input } from "../ui/input";
46 +import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
47 +import { cn } from "~/lib/utils";
48 +import { PullRequestMetaRow, PullRequestSection } from "../pullRequest/PullRequestSummaryTab";
49 +import { toastManager } from "../ui/toast";
50 +import { PullRequestCandidatePicker } from "../pullRequest/PullRequestCandidatePicker";
51 +import { PullRequestCommentBody } from "../pullRequest/PullRequestCommentBody";
52 +import { PullRequestDetailTitleRow } from "../pullRequest/PullRequestDetailLayout";
53 +import { PullRequestEditButton } from "../pullRequest/PullRequestEditButton";
54 +import { PullRequestMarkdown } from "../pullRequest/PullRequestMarkdown";
55 +import { PullRequestMarkdownEditor } from "../pullRequest/PullRequestMarkdownEditor";
56 +import { readableFailure } from "../pullRequest/pullRequestDetail.logic";
57 +import { pullRequestLabelColor } from "../pullRequest/pullRequestList.logic";
58 +import {
59 + PullRequestActorLabel,
60 + PullRequestLabelChip,
61 + PullRequestMetaLine,
62 + PullRequestStateGlyph,
63 +} from "../pullRequest/pullRequestPresentation";
64 +import { IssueCommentComposer } from "./IssueCommentComposer";
65 +import { IssueDetailGhost } from "./IssueDetailGhost";
66 +import { ReactionBar } from "../pullRequest/PullRequestReactions";
67 +import { PullRequestsUnavailableState } from "../pullRequest/PullRequestsUnavailableState";
68 +import {
69 + issueCloseReasonLabel,
70 + issueStatePresentation,
71 + issueTrackerPresentation,
72 +} from "./issuePresentation";
73 +
74 +/** Why a control is off, said once so each disabled affordance can point at it. */
75 +function writeBlockReason(detail: IssueDetail, canWrite: boolean): string | null {
76 + if (!canWrite) return "Writing to this tracker needs the source-control write scope.";
77 + if (!detail.writable)
78 + return "This issue is outside every project's own scope, so it is read-only here.";
79 + return null;
80 +}
81 +
82 +function IssueReactionBar({
83 + reactions,
84 + canReact,
85 + subjectId,
86 + environmentId,
87 + reference,
88 +}: {
89 + reactions: ReadonlyArray<IssueReaction>;
90 + canReact: boolean;
91 + subjectId?: string | undefined;
92 + environmentId: EnvironmentId;
93 + reference: IssueRef;
94 +}) {
95 + const react = useAtomCommand(issueEnvironment.react, { reportFailure: false });
96 + return (
97 + <ReactionBar
98 + reactions={reactions}
99 + canReact={canReact}
100 + onReact={async (content, reacted) => {
101 + const result = await react({
102 + environmentId,
103 + input: {
104 + ...reference,
105 + ...(subjectId === undefined ? {} : { subjectId }),
106 + content,
107 + reacted,
108 + },
109 + });
110 + return result._tag !== "Failure";
111 + }}
112 + />
113 + );
114 +}
115 +
116 +function IssueLabelPicker({
117 + environmentId,
118 + reference,
119 + detail,
120 + allowed,
121 + disabledReason,
122 +}: {
123 + environmentId: EnvironmentId;
124 + reference: IssueRef;
125 + detail: IssueDetail;
126 + allowed: boolean;
127 + disabledReason: string;
128 +}) {
129 + const [open, setOpen] = useState(false);
130 + const [query, setQuery] = useState("");
131 + const [picks, setPicks] = useState(noIssuePicks<IssueLabelCandidate>);
132 + const current = issuePicksFor(picks, detail, open);
133 + const draft = current.draft;
134 + const candidatesQuery = useEnvironmentQuery(
135 + open ? issueEnvironment.candidates({ environmentId, input: reference }) : null,
136 + );
137 + const update = useAtomCommand(issueEnvironment.update, { reportFailure: false });
138 + const applied = new Set(detail.labels.map((label) => label.name));
139 + const needle = query.toLowerCase();
140 + const candidates = (candidatesQuery.data?.labels ?? []).filter(
141 + (label) =>
142 + needle.length === 0 ||
143 + label.name.toLowerCase().includes(needle) ||
144 + (label.description ?? "").toLowerCase().includes(needle),
145 + );
146 + const onOpenChange = (nextOpen: boolean) => {
147 + setOpen(nextOpen);
148 + if (nextOpen) {
149 + // Picks made against an older read are not this picker's any more.
150 + setPicks(issuePicksFor(picks, detail, false));
151 + return;
152 + }
153 + const labels = issueWriteAfterPicks(
154 + issueLabelsAfterPicks(detail, draft),
155 + detail.labels.map((label) => label.name),
156 + current.written,
157 + );
158 + if (labels === null) return;
159 + setPicks({ ...current, written: labels });
160 + void update({ environmentId, input: { ...reference, labels } }).then((result) => {
161 + if (result._tag !== "Failure") return;
162 + setPicks((latest) => (latest.written === labels ? noIssuePicks() : latest));
163 + toastManager.add({
164 + type: "error",
165 + title: "Could not change labels",
166 + description: readableFailure(squashAtomCommandFailure(result), "The tracker refused it."),
167 + });
168 + });
169 + };
170 + return (
171 + <PullRequestCandidatePicker
172 + icon={<TagIcon className="size-3.5" />}
173 + label="Change labels"
174 + allowed={allowed}
175 + disabledReason={disabledReason}
176 + open={open}
177 + onOpenChange={onOpenChange}
178 + query={query}
179 + onQueryChange={setQuery}
180 + searchLabel="Search labels"
181 + isPending={candidatesQuery.isPending && candidatesQuery.data === null}
182 + error={candidatesQuery.data === null ? candidatesQuery.error : null}
183 + candidates={candidates}
184 + emptyLabel="This tracker has no labels."
185 + noMatchLabel="No label matches that."
186 + errorLabel="The labels could not be read."
187 + truncated={candidatesQuery.data?.truncated === true}
188 + truncatedLabel="More labels exist than are listed here."
189 + candidateKey={(candidate) => candidate.name}
190 + onSelect={(candidate) =>
191 + setPicks({
192 + ...current,
193 + draft: toggleSelection(draft, candidate.name, candidate, applied.has(candidate.name)),
194 + })
195 + }
196 + >
197 + {(candidate) => {
198 + const dot = pullRequestLabelColor(candidate.color);
199 + return (
200 + <>
201 + <span
202 + aria-hidden
203 + className="size-2 shrink-0 rounded-full bg-muted-foreground"
204 + {...(dot ? { style: { backgroundColor: dot } } : {})}
205 + />
206 + <span className="min-w-0 flex-1 truncate">
207 + {candidate.name}
208 + {candidate.description ? (
209 + <span className="text-muted-foreground"> · {candidate.description}</span>
210 + ) : null}
211 + </span>
212 + {isSelected(draft, candidate.name, applied.has(candidate.name)) ? (
213 + <CheckIcon aria-label="Applied" className="size-3.5 shrink-0" />
214 + ) : null}
215 + </>
216 + );
217 + }}
218 + </PullRequestCandidatePicker>
219 + );
220 +}
221 +
222 +function IssueAssigneePicker({
223 + environmentId,
224 + reference,
225 + detail,
226 + allowed,
227 + disabledReason,
228 +}: {
229 + environmentId: EnvironmentId;
230 + reference: IssueRef;
231 + detail: IssueDetail;
232 + allowed: boolean;
233 + disabledReason: string;
234 +}) {
235 + const [open, setOpen] = useState(false);
236 + const [query, setQuery] = useState("");
237 + const [picks, setPicks] = useState(noIssuePicks<IssueAssigneeCandidate>);
238 + const current = issuePicksFor(picks, detail, open);
239 + const draft = current.draft;
240 + const candidatesQuery = useEnvironmentQuery(
241 + open ? issueEnvironment.candidates({ environmentId, input: reference }) : null,
242 + );
243 + const update = useAtomCommand(issueEnvironment.update, { reportFailure: false });
244 + const needle = query.toLowerCase();
245 + const candidates = (candidatesQuery.data?.assignees ?? []).filter(
246 + (candidate) =>
247 + needle.length === 0 ||
248 + candidate.login.toLowerCase().includes(needle) ||
249 + (candidate.name ?? "").toLowerCase().includes(needle),
250 + );
251 + const onOpenChange = (nextOpen: boolean) => {
252 + setOpen(nextOpen);
253 + if (nextOpen) {
254 + // Picks made against an older read are not this picker's any more.
255 + setPicks(issuePicksFor(picks, detail, false));
256 + return;
257 + }
258 + const assignees = issueWriteAfterPicks(
259 + issueAssigneesAfterPicks(detail, draft),
260 + detail.assignees.map((actor) => actor.login),
261 + current.written,
262 + );
263 + if (assignees === null) return;
264 + setPicks({ ...current, written: assignees });
265 + void update({ environmentId, input: { ...reference, assignees } }).then((result) => {
266 + if (result._tag !== "Failure") return;
267 + setPicks((latest) => (latest.written === assignees ? noIssuePicks() : latest));
268 + toastManager.add({
269 + type: "error",
270 + title: "Could not change assignees",
271 + description: readableFailure(squashAtomCommandFailure(result), "The tracker refused it."),
272 + });
273 + });
274 + };
275 + return (
276 + <PullRequestCandidatePicker
277 + icon={<UserPlusIcon className="size-3.5" />}
278 + label="Change assignees"
279 + allowed={allowed}
280 + disabledReason={disabledReason}
281 + open={open}
282 + onOpenChange={onOpenChange}
283 + query={query}
284 + onQueryChange={setQuery}
285 + searchLabel="Search people"
286 + isPending={candidatesQuery.isPending && candidatesQuery.data === null}
287 + error={candidatesQuery.data === null ? candidatesQuery.error : null}
288 + candidates={candidates}
289 + emptyLabel="Nobody can be assigned here."
290 + noMatchLabel="Nobody matches that."
291 + errorLabel="The people could not be read."
292 + truncated={candidatesQuery.data?.truncated === true}
293 + truncatedLabel="More people exist than are listed here."
294 + candidateKey={(candidate) => candidate.id}
295 + onSelect={(candidate) =>
296 + setPicks({
297 + ...current,
298 + draft: toggleSelection(
299 + draft,
300 + candidate.id,
301 + candidate,
302 + issueAssigneeHeld(detail, candidate),
303 + ),
304 + })
305 + }
306 + >
307 + {(candidate) => (
308 + <>
309 + <PullRequestActorLabel actor={candidate} tooltip={false} className="min-w-0 flex-1" />
310 + {isSelected(draft, candidate.id, issueAssigneeHeld(detail, candidate)) ? (
311 + <CheckIcon aria-label="Assigned" className="size-3.5 shrink-0" />
312 + ) : null}
313 + </>
314 + )}
315 + </PullRequestCandidatePicker>
316 + );
317 +}
318 +
319 +function eventSentence(event: IssueEvent): string {
320 + switch (event.kind) {
321 + case "closed":
322 + return event.detail
323 + ? `closed this as ${issueCloseReasonLabel(event.detail).toLowerCase()}`
324 + : "closed this";
325 + case "reopened":
326 + return "reopened this";
327 + case "labeled":
328 + return event.detail ? `added the ${event.detail} label` : "added a label";
329 + case "unlabeled":
330 + return event.detail ? `removed the ${event.detail} label` : "removed a label";
331 + case "assigned":
332 + return event.detail ? `assigned ${event.detail}` : "assigned someone";
333 + case "unassigned":
334 + return event.detail ? `unassigned ${event.detail}` : "unassigned someone";
335 + case "renamed":
336 + return event.detail ? `renamed this to “${event.detail}”` : "renamed this";
337 + case "referenced":
338 + return event.detail ? `referenced this from ${event.detail}` : "referenced this";
339 + case "state-changed":
340 + return event.detail ? `moved this to ${event.detail}` : "changed the state";
341 + }
342 +}
343 +
344 +type TimelineItem =
345 + | { kind: "comment"; at: string; comment: IssueComment }
346 + | { kind: "event"; at: string; event: IssueEvent };
347 +
348 +function LinkedPullRequestRow({
349 + link,
350 + scope,
351 + onSelect,
352 +}: {
353 + link: IssueLinkedPullRequest;
354 + /** The issue's own repository, left off a pull request that lives in it. */
355 + scope: string;
356 + onSelect: (() => void) | null;
357 +}) {
358 + const body = (
359 + <>
360 + <PullRequestStateGlyph state={link.state} isDraft={link.isDraft} />
361 + <span className="min-w-0 flex-1 truncate text-sm">{link.title}</span>
362 + <PullRequestMetaLine className="shrink-0 text-xs text-muted-foreground">
363 + {link.closesIssue ? <span>Closes this issue</span> : null}
364 + <span className="tabular-nums">
365 + {link.repository.toLowerCase() === scope.toLowerCase() ? "" : link.repository}#
366 + {link.number}
367 + </span>
368 + </PullRequestMetaLine>
369 + </>
370 + );
371 + const className =
372 + "flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-accent";
373 + return onSelect ? (
374 + <button type="button" className={className} onClick={onSelect}>
375 + {body}
376 + </button>
377 + ) : (
378 + <a href={link.url} target="_blank" rel="noopener noreferrer" className={className}>
379 + {body}
380 + </a>
381 + );
382 +}
383 +
384 +export function IssueDetailPanel({
385 + environmentId,
386 + reference,
387 + threadRef = null,
388 + listEntry = null,
389 + onSelectPullRequest,
390 +}: {
391 + environmentId: EnvironmentId;
392 + reference: IssueRef;
393 + /** The list row this issue was opened from, shown until the detail arrives. */
394 + listEntry?: IssueListEntry | null;
395 + threadRef?: ScopedThreadRef | null;
396 + /** Opens a linked change request beside this one; absent, the link goes to the host. */
397 + onSelectPullRequest?: ((reference: PullRequestRef) => void) | undefined;
398 +}) {
399 + const detailQuery = useEnvironmentQuery(
400 + issueEnvironment.detail({ environmentId, input: reference }),
401 + );
402 + const detail = detailQuery.data;
403 + const canWrite = useAtomValue(issueEnvironment.comment.permissionAtom(environmentId));
404 + const projects = useProjects();
405 + const cwd =
406 + projects.find((p) => p.environmentId === environmentId && p.id === reference.projectId)
407 + ?.workspaceRoot ?? "";
408 +
409 + const [older, setOlder] = useState<{
410 + readonly seed: string | null;
411 + readonly comments: ReadonlyArray<IssueComment>;
412 + readonly cursor: string | null;
413 + } | null>(null);
414 + const loadComments = useAtomCommand(issueEnvironment.comments, { reportFailure: false });
415 + const [loadingOlder, setLoadingOlder] = useState(false);
416 + const update = useAtomCommand(issueEnvironment.update, { reportFailure: false });
417 + const setState = useAtomCommand(issueEnvironment.setState, { reportFailure: false });
418 + const [editing, setEditing] = useState<"title" | "body" | null>(null);
419 + const [titleDraft, setTitleDraft] = useState("");
420 + const [saving, setSaving] = useState(false);
421 + const [changingState, setChangingState] = useState(false);
422 +
423 + if (detail === null) {
424 + if (detailQuery.error !== null && !detailQuery.isPending) {
425 + return (
426 + <PullRequestsUnavailableState
427 + title="Could not load this issue"
428 + error={detailQuery.error}
429 + onRetry={detailQuery.refresh}
430 + />
431 + );
432 + }
433 + return <IssueDetailGhost seed={listEntry} />;
434 + }
435 +
436 + // Older pages are tied to the cursor the detail was read with; a refreshed detail starts over.
437 + const olderComments = older?.seed === detail.commentsCursor ? older.comments : [];
438 + const nextCursor = older?.seed === detail.commentsCursor ? older.cursor : detail.commentsCursor;
439 + const comments = prependIssueComments(detail.comments, olderComments);
440 + const timeline: ReadonlyArray<TimelineItem> = [
441 + ...comments.map((c): TimelineItem => ({ kind: "comment", at: c.createdAt, comment: c })),
442 + ...detail.events.map((e): TimelineItem => ({ kind: "event", at: e.createdAt, event: e })),
443 + ].sort((a, b) => Date.parse(a.at) - Date.parse(b.at));
444 +
445 + const blocked = writeBlockReason(detail, canWrite);
446 + const may = (capability: boolean, permission: boolean) =>
447 + blocked === null && capability && permission;
448 + const canComment = may(detail.capabilities.comment, detail.viewerPermissions.comment);
449 + const canEdit = may(detail.capabilities.edit, detail.viewerPermissions.edit);
450 + const canLabel = may(detail.capabilities.labels, detail.viewerPermissions.labels);
451 + const canAssign = may(detail.capabilities.assignees, detail.viewerPermissions.assignees);
452 + const canReact = blocked === null && detail.capabilities.reactions;
453 + const canSetState = may(detail.capabilities.states.length > 0, detail.viewerPermissions.setState);
454 + const tracker = issueTrackerPresentation(detail.tracker);
455 + const otherStates = detail.capabilities.states.filter(
456 + (state) => state.category !== detail.state.category || state.name !== detail.state.name,
457 + );
458 + const closingStates = otherStates.filter((state) => state.category === "closed");
459 + const openingStates = otherStates.filter((state) => state.category === "open");
460 +
461 + const loadOlder = async () => {
462 + if (nextCursor === null || loadingOlder) return;
463 + setLoadingOlder(true);
464 + const result = await loadComments({
465 + environmentId,
466 + input: { ...reference, cursor: nextCursor },
467 + });
468 + setLoadingOlder(false);
469 + if (result._tag === "Failure") {
470 + toastManager.add({ type: "error", title: "Older comments could not be read" });
471 + return;
472 + }
473 + setOlder({
474 + seed: detail.commentsCursor,
475 + comments: prependIssueComments(olderComments, result.value.comments),
476 + cursor: result.value.nextCursor,
477 + });
478 + };
479 +
480 + const save = async (patch: { title?: string; body?: string }) => {
481 + setSaving(true);
482 + const result = await update({ environmentId, input: { ...reference, ...patch } });
483 + setSaving(false);
484 + if (result._tag === "Failure") {
485 + toastManager.add({
486 + type: "error",
487 + title: "The issue could not be updated",
488 + description: readableFailure(squashAtomCommandFailure(result), "The tracker refused it."),
489 + });
490 + return;
491 + }
492 + setEditing(null);
493 + };
494 +
495 + const moveTo = async (state: string, closeReason?: string) => {
496 + if (changingState) return;
497 + setChangingState(true);
498 + const result = await setState({
499 + environmentId,
500 + input: { ...reference, state, ...(closeReason === undefined ? {} : { closeReason }) },
501 + });
502 + setChangingState(false);
503 + if (result._tag === "Failure") {
504 + toastManager.add({
505 + type: "error",
506 + title: "The state could not be changed",
507 + description: readableFailure(squashAtomCommandFailure(result), "The tracker refused it."),
508 + });
509 + }
510 + };
511 +
512 + const stateControl: ReactNode = canSetState ? (
513 + <span className="flex shrink-0 items-center gap-1">
514 + {openingStates.length === 1 && closingStates.length === 0 ? (
515 + <Button
516 + size="xs"
517 + variant="outline"
518 + disabled={changingState}
519 + onClick={() => void moveTo(openingStates[0]!.name)}
520 + >
521 + Reopen
522 + </Button>
523 + ) : null}
524 + {closingStates.length === 1 &&
525 + detail.capabilities.closeReasons.length === 0 &&
526 + openingStates.length === 0 ? (
527 + <Button
528 + size="xs"
529 + variant="outline"
530 + disabled={changingState}
531 + onClick={() => void moveTo(closingStates[0]!.name)}
532 + >
533 + Close
534 + </Button>
535 + ) : null}
536 + {(closingStates.length > 0 && detail.capabilities.closeReasons.length > 0) ||
537 + otherStates.length > 1 ? (
538 + <Menu>
539 + <MenuTrigger render={<Button size="xs" variant="outline" disabled={changingState} />}>
540 + {detail.state.category === "open" ? "Close" : "Change state"}
541 + <ChevronDownIcon aria-hidden className="size-3" />
542 + </MenuTrigger>
543 + <MenuPopup align="end">
544 + {otherStates.flatMap((state) =>
545 + state.category === "closed" && detail.capabilities.closeReasons.length > 0
546 + ? detail.capabilities.closeReasons.map((reason) => (
547 + <MenuItem
548 + key={`${state.name}:${reason}`}
549 + onClick={() => void moveTo(state.name, reason)}
550 + >
551 + {state.name === "closed" ? "Close" : state.name} as{" "}
552 + {issueCloseReasonLabel(reason).toLowerCase()}
553 + </MenuItem>
554 + ))
555 + : [
556 + <MenuItem key={state.name} onClick={() => void moveTo(state.name)}>
557 + {state.category === "open" && state.name === "open"
558 + ? "Reopen"
559 + : state.name === "closed"
560 + ? "Close"
561 + : `Move to ${state.name}`}
562 + </MenuItem>,
563 + ],
564 + )}
565 + </MenuPopup>
566 + </Menu>
567 + ) : null}
568 + </span>
569 + ) : null;
570 +
571 + return (
572 + <div className="relative flex h-full min-h-0 flex-col">
573 + <div
574 + className={cn(
575 + "min-h-0 flex-1 overflow-y-auto",
576 + // Room for the floating composer, so the last comment can scroll clear of it.
577 + detail.capabilities.comment && "pb-32",
578 + )}
579 + data-pull-request-summary-scroll
580 + >
581 + <div className="px-4 pb-1">
582 + <PullRequestDetailTitleRow className="h-7 gap-1 text-sm sm:text-xs">
583 + <span className="min-w-0 truncate font-medium text-muted-foreground">
584 + {detail.scope}
585 + </span>
586 + <InlineButton
587 + className={cn(
588 + "shrink-0 font-medium",
589 + issueStatePresentation(detail.state).toneClassName,
590 + )}
591 + aria-label={`Open ${detail.displayKey} on ${tracker.providerName}`}
592 + render={<a href={detail.url} target="_blank" rel="noopener noreferrer" />}
593 + >
594 + {detail.displayKey}
595 + <ExternalLinkIcon aria-hidden className="size-2.5" />
596 + </InlineButton>
597 + <span className="flex-1" />
598 + {stateControl}
599 + <Button
600 + size="icon-xs"
601 + variant="ghost"
602 + aria-label="Refresh issue"
603 + disabled={detailQuery.isPending}
604 + onClick={() => {
605 + // Older pages are cached under the cursor, which a refresh can hand back unchanged.
606 + setOlder(null);
607 + detailQuery.refresh();
608 + }}
609 + >
610 + <RefreshIcon size="sm" refreshing={detailQuery.isPending} />
611 + </Button>
612 + </PullRequestDetailTitleRow>
613 +
614 + {editing === "title" ? (
615 + <form
616 + className="mt-1 flex items-center gap-2"
617 + onSubmit={(event) => {
618 + event.preventDefault();
619 + const next = titleDraft.trim();
620 + if (next.length > 0 && next !== detail.title) void save({ title: next });
621 + else setEditing(null);
622 + }}
623 + >
624 + <Input
625 + autoFocus
626 + aria-label="Issue title"
627 + value={titleDraft}
628 + disabled={saving}
629 + onChange={(event) => setTitleDraft(event.target.value)}
630 + onKeyDown={(event) => {
631 + if (event.key === "Escape") setEditing(null);
632 + }}
633 + />
634 + <Button type="submit" size="sm" disabled={saving}>
635 + Save
636 + </Button>
637 + <Button
638 + type="button"
639 + size="sm"
640 + variant="outline"
641 + disabled={saving}
642 + onClick={() => setEditing(null)}
643 + >
644 + Cancel
645 + </Button>
646 + </form>
647 + ) : (
648 + <PullRequestDetailTitleRow className="group mt-1 gap-1">
649 + <h2 className="min-w-0 flex-1 text-base font-semibold leading-snug">
650 + {detail.title}
651 + </h2>
652 + {canEdit ? (
653 + <PullRequestEditButton
654 + aria-label="Edit title"
655 + onClick={() => {
656 + setTitleDraft(detail.title);
657 + setEditing("title");
658 + }}
659 + />
660 + ) : null}
661 + </PullRequestDetailTitleRow>
662 + )}
663 +
664 + <PullRequestMetaLine className="mt-2 min-h-5 text-xs text-muted-foreground">
665 + <PullRequestActorLabel actor={detail.author} />
666 + <span>opened {formatRelativeTimeLabel(detail.createdAt)}</span>
667 + {detail.closedAt ? (
668 + <span>closed {formatRelativeTimeLabel(detail.closedAt)}</span>
669 + ) : null}
670 + {detail.writable ? null : <span>Read-only</span>}
671 + </PullRequestMetaLine>
672 +
673 + <div className="mt-4 space-y-2">
674 + <PullRequestMetaRow icon={<TagIcon className="size-3.5" />} label="Labels">
675 + <span className="flex min-w-0 flex-wrap items-center gap-1">
676 + {detail.labels.length === 0 ? (
677 + <span className="text-muted-foreground">None</span>
678 + ) : (
679 + detail.labels.map((label) => (
680 + <PullRequestLabelChip
681 + key={label.name}
682 + label={label}
683 + size="default"
684 + className="max-w-48"
685 + />
686 + ))
687 + )}
688 + {detail.capabilities.labels ? (
689 + <IssueLabelPicker
690 + environmentId={environmentId}
691 + reference={reference}
692 + detail={detail}
693 + allowed={canLabel}
694 + disabledReason={
695 + blocked ?? "Changing labels needs triage access on this tracker."
696 + }
697 + />
698 + ) : null}
699 + </span>
700 + </PullRequestMetaRow>
701 + <PullRequestMetaRow icon={<UsersIcon className="size-3.5" />} label="Assignees">
702 + <span className="flex min-w-0 flex-wrap items-center gap-1.5">
703 + {detail.assignees.length === 0 ? (
704 + <span className="text-muted-foreground">None</span>
705 + ) : (
706 + detail.assignees.map((actor) => (
707 + <PullRequestActorLabel key={actor.login} actor={actor} />
708 + ))
709 + )}
710 + {detail.capabilities.assignees ? (
711 + <IssueAssigneePicker
712 + environmentId={environmentId}
713 + reference={reference}
714 + detail={detail}
715 + allowed={canAssign}
716 + disabledReason={
717 + blocked ?? "Changing assignees needs triage access on this tracker."
718 + }
719 + />
720 + ) : null}
721 + </span>
722 + </PullRequestMetaRow>
723 + </div>
724 + </div>
725 +
726 + <PullRequestSection
727 + key={`description:${detail.url}`}
728 + title="Description"
729 + keepMounted
730 + actions={
731 + canEdit && editing !== "body" ? (
732 + <PullRequestEditButton
733 + aria-label="Edit description"
734 + onClick={() => setEditing("body")}
735 + />
736 + ) : null
737 + }
738 + >
739 + <div className="flex flex-col gap-2">
740 + {editing === "body" ? (
741 + <PullRequestMarkdownEditor
742 + value={detail.body}
743 + cwd={cwd}
744 + environmentId={environmentId}
745 + threadRef={threadRef}
746 + label="Description"
747 + completionScope={null}
748 + saving={saving}
749 + allowEmpty
750 + onSave={(next) => void save({ body: next })}
751 + onCancel={() => setEditing(null)}
752 + />
753 + ) : (
754 + <PullRequestMarkdown
755 + text={detail.body.trim().length > 0 ? detail.body : "_No description provided._"}
756 + cwd={cwd}
757 + environmentId={environmentId}
758 + threadRef={threadRef}
759 + />
760 + )}
761 + {detail.reactions !== undefined ? (
762 + <IssueReactionBar
763 + reactions={detail.reactions}
764 + canReact={canReact}
765 + environmentId={environmentId}
766 + reference={reference}
767 + />
768 + ) : null}
769 + </div>
770 + </PullRequestSection>
771 +
772 + {detail.linkedPullRequests.length > 0 ? (
773 + <PullRequestSection key={`linked:${detail.url}`} title="Linked pull requests">
774 + <div className="flex flex-col gap-1">
775 + {detail.linkedPullRequests.map((link) => (
776 + <LinkedPullRequestRow
777 + key={`${link.repository}#${link.number}`}
778 + link={link}
779 + scope={detail.scope}
780 + onSelect={
781 + onSelectPullRequest
782 + ? () =>
783 + onSelectPullRequest({
784 + projectId: reference.projectId,
785 + ...(reference.host === undefined ? {} : { host: reference.host }),
786 + repository: link.repository,
787 + number: link.number,
788 + })
789 + : null
790 + }
791 + />
792 + ))}
793 + </div>
794 + </PullRequestSection>
795 + ) : null}
796 +
797 + <PullRequestSection
798 + key={`activity:${detail.url}`}
799 + title={detail.commentCount > 0 ? `Activity (${detail.commentCount})` : "Activity"}
800 + >
801 + <div className="flex flex-col gap-3">
802 + {nextCursor !== null ? (
803 + <Button
804 + size="sm"
805 + variant="outline"
806 + className="self-start"
807 + disabled={loadingOlder}
808 + onClick={() => void loadOlder()}
809 + >
810 + {loadingOlder ? "Loading…" : "Load older comments"}
811 + </Button>
812 + ) : null}
813 + {timeline.length === 0 ? (
814 + <p className="text-sm text-muted-foreground">Nothing has happened here yet.</p>
815 + ) : null}
816 + {timeline.map((item) =>
817 + item.kind === "comment" ? (
818 + <article
819 + key={`c:${item.comment.id}`}
820 + className="flex flex-col gap-2 rounded-lg border border-border/60 p-3"
821 + >
822 + <PullRequestMetaLine className="text-xs text-muted-foreground">
823 + <PullRequestActorLabel actor={item.comment.author} />
824 + {item.comment.url ? (
825 + <InlineButton
826 + tone="muted"
827 + render={
828 + <a href={item.comment.url} target="_blank" rel="noopener noreferrer" />
829 + }
830 + >
831 + {formatRelativeTimeLabel(item.comment.createdAt)}
832 + </InlineButton>
833 + ) : (
834 + <span>{formatRelativeTimeLabel(item.comment.createdAt)}</span>
835 + )}
836 + </PullRequestMetaLine>
837 + <PullRequestCommentBody
838 + text={item.comment.body}
839 + cwd={cwd}
840 + environmentId={environmentId}
841 + threadRef={threadRef}
842 + />
843 + {item.comment.reactions !== undefined ? (
844 + <IssueReactionBar
845 + reactions={item.comment.reactions}
846 + canReact={canReact}
847 + subjectId={item.comment.id}
848 + environmentId={environmentId}
849 + reference={reference}
850 + />
851 + ) : null}
852 + </article>
853 + ) : (
854 + <PullRequestMetaLine
855 + key={`e:${item.event.id}`}
856 + className="px-1 text-xs text-muted-foreground"
857 + >
858 + <PullRequestActorLabel actor={item.event.actor} />
859 + <span>{eventSentence(item.event)}</span>
860 + <span>{formatRelativeTimeLabel(item.event.createdAt)}</span>
861 + </PullRequestMetaLine>
862 + ),
863 + )}
864 + </div>
865 + </PullRequestSection>
866 + </div>
867 +
868 + {detail.capabilities.comment ? (
869 + <IssueCommentComposer
870 + environmentId={environmentId}
871 + reference={reference}
872 + blocked={canComment ? null : (blocked ?? "You cannot comment here.")}
873 + />
874 + ) : null}
875 + </div>
876 + );
877 +}
apps/web/src/components/issue/IssueRow.tsx new
+117
@@ -0,0 +1,117 @@
1 +import type { EnvironmentId, IssueListEntry } from "@t3tools/contracts";
2 +import { MessageSquareIcon } from "lucide-react";
3 +import { memo } from "react";
4 +
5 +import { cn } from "~/lib/utils";
6 +
7 +import {
8 + PULL_REQUEST_ROW_CLASS,
9 + PULL_REQUEST_ROW_NUMBER_CLASS,
10 + PullRequestRowAuthor,
11 + PullRequestRowLines,
12 +} from "../pullRequest/PullRequestListRow";
13 +import {
14 + PullRequestLabelChip,
15 + PullRequestActorAvatar,
16 +} from "../pullRequest/pullRequestPresentation";
17 +import { IssueStateGlyph, issueTrackerPresentation } from "./issuePresentation";
18 +
19 +export interface EnvironmentIssueEntry extends IssueListEntry {
20 + readonly environmentId: EnvironmentId;
21 +}
22 +
23 +export type IssueRowTarget = Pick<
24 + EnvironmentIssueEntry,
25 + "environmentId" | "projectId" | "tracker" | "host" | "scope" | "key" | "url"
26 +>;
27 +
28 +/** The page row in the pull-request list's shape: state glyph, then key and title over meta. */
29 +function IssueRowImpl({
30 + entry,
31 + selected,
32 + showScope,
33 + showTracker,
34 + environmentLabel,
35 + onSelect,
36 +}: {
37 + entry: EnvironmentIssueEntry;
38 + selected: boolean;
39 + /** Only when the list spans more than one scope, where the key alone is ambiguous. */
40 + showScope: boolean;
41 + /** Only when the list spans more than one tracker or host. */
42 + showTracker: boolean;
43 + /** Names the server this row was read from, where the list spans more than one. */
44 + environmentLabel?: string | undefined;
45 + onSelect: (entry: IssueRowTarget) => void;
46 +}) {
47 + const tracker = issueTrackerPresentation(entry.tracker);
48 + return (
49 + <div
50 + className={cn(
51 + "flex items-center rounded-md [content-visibility:auto] [contain-intrinsic-block-size:56.5px]",
52 + selected ? "bg-accent" : "hover:bg-accent/60",
53 + )}
54 + >
55 + <button
56 + type="button"
57 + aria-current={selected ? "true" : undefined}
58 + onClick={() => onSelect(entry)}
59 + className={cn(PULL_REQUEST_ROW_CLASS, "@container/issue-row-meta px-3 py-2.5")}
60 + >
61 + <IssueStateGlyph state={entry.state} />
62 + <PullRequestRowLines
63 + number={<span className={PULL_REQUEST_ROW_NUMBER_CLASS}>{entry.displayKey}</span>}
64 + title={entry.title}
65 + status={
66 + <>
67 + {entry.assignees.length > 0 ? (
68 + <span className="flex items-center -space-x-1">
69 + {entry.assignees.slice(0, 3).map((assignee) => (
70 + <PullRequestActorAvatar
71 + key={assignee.login}
72 + actor={assignee}
73 + className="ring-1 ring-background"
74 + />
75 + ))}
76 + </span>
77 + ) : null}
78 + {entry.commentCount > 0 ? (
79 + <span className="inline-flex items-center gap-0.5 tabular-nums">
80 + <MessageSquareIcon aria-hidden className="size-3" />
81 + {entry.commentCount}
82 + </span>
83 + ) : null}
84 + </>
85 + }
86 + meta={
87 + <>
88 + <PullRequestRowAuthor actor={entry.author} />
89 + {showTracker ? (
90 + <span className="inline-flex shrink-0 items-center gap-1">
91 + <tracker.Icon aria-hidden className="size-3" />
92 + <span className="sr-only">{tracker.providerName}</span>
93 + </span>
94 + ) : null}
95 + {showScope ? <span className="truncate">{entry.scope}</span> : null}
96 + {environmentLabel ? <span className="truncate">{environmentLabel}</span> : null}
97 + {entry.labels.length > 0 ? (
98 + <span className="hidden min-w-0 items-center gap-1 @xl/issue-row-meta:flex">
99 + {entry.labels.slice(0, 3).map((label, index) => (
100 + <PullRequestLabelChip key={label.name} label={label}>
101 + {index === 2 && entry.labels.length > 3 ? (
102 + <span className="shrink-0">+{entry.labels.length - 3}</span>
103 + ) : null}
104 + </PullRequestLabelChip>
105 + ))}
106 + </span>
107 + ) : null}
108 + </>
109 + }
110 + updatedAt={entry.updatedAt}
111 + />
112 + </button>
113 + </div>
114 + );
115 +}
116 +
117 +export const IssueRow = memo(IssueRowImpl);
apps/web/src/components/issue/IssuesPage.tsx new
+825
@@ -0,0 +1,825 @@
1 +import { useAtomValue } from "@effect/atom-react";
2 +import {
3 + issueEntryKey,
4 + mergeIssueListErrors,
5 + mergeIssueListPage,
6 +} from "@t3tools/client-runtime/state/issues";
7 +import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
8 +import type {
9 + EnvironmentId,
10 + IssueInvolvement,
11 + IssueListCursors,
12 + IssueListEntry,
13 + IssueListInput,
14 + IssueListProjectError,
15 + IssueListResult,
16 + IssueListState,
17 + IssueTrackerKind,
18 + IssueTrackerSummary,
19 + ProjectId,
20 + SourceControlProviderKind,
21 +} from "@t3tools/contracts";
22 +import { useNavigate, useSearch } from "@tanstack/react-router";
23 +import {
24 + AtSignIcon,
25 + CircleCheckIcon,
26 + LayersIcon,
27 + PenLineIcon,
28 + Plug2Icon,
29 + UserCheckIcon,
30 + UsersIcon,
31 +} from "lucide-react";
32 +import { Fragment, useEffect, useState, type ReactNode } from "react";
33 +
34 +import { RefreshIcon } from "~/components/ui/refresh-icon";
35 +import { IssueDetailPanel } from "~/components/issue/IssueDetailPanel";
36 +import {
37 + IssueRow,
38 + type EnvironmentIssueEntry,
39 + type IssueRowTarget,
40 +} from "~/components/issue/IssueRow";
41 +import {
42 + issueListPreferences,
43 + writeIssueListPreferences,
44 + type IssueListPreferences,
45 +} from "~/components/issue/issueListPreferences";
46 +import { IssueGlyph, issueTrackerPresentation } from "~/components/issue/issuePresentation";
47 +import { PullRequestDetailPanel } from "~/components/pullRequest/PullRequestDetailPanel";
48 +import { PullRequestListGhost } from "~/components/pullRequest/PullRequestGhosts";
49 +import {
50 + PullRequestFilterOptionIcon,
51 + PullRequestSearchInput,
52 + type PullRequestFilterOption,
53 +} from "~/components/pullRequest/PullRequestListFilters";
54 +import { PullRequestsUnavailableState } from "~/components/pullRequest/PullRequestsUnavailableState";
55 +import { RightPanelTabs } from "~/components/RightPanelTabs";
56 +import { WorkspaceBreadcrumb, WorkspaceBreadcrumbItem } from "~/components/WorkspaceBreadcrumb";
57 +import { WorkspacePageContainer } from "~/components/WorkspacePageContainer";
58 +import { WorkspacePageHeader } from "~/components/WorkspacePageHeader";
59 +import { PanelLayoutControls } from "~/components/chat/PanelLayoutControls";
60 +import { Button } from "~/components/ui/button";
61 +import {
62 + Empty,
63 + EmptyDescription,
64 + EmptyHeader,
65 + EmptyMedia,
66 + EmptyTitle,
67 +} from "~/components/ui/empty";
68 +import { Menu, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "~/components/ui/menu";
69 +import { SidebarInset } from "~/components/ui/sidebar";
70 +import { Toggle, ToggleGroup } from "~/components/ui/toggle-group";
71 +import { isElectron } from "~/env";
72 +import { useLiveRefresh } from "~/hooks/useLiveRefresh";
73 +import { shortcutLabelForCommand } from "~/keybindings";
74 +import { isTerminalFocused } from "~/lib/terminalFocus";
75 +import { usePanelAnimationSettings, usePanelPresence } from "~/panelAnimations";
76 +import {
77 + ISSUES_PANEL_REF,
78 + selectActiveRightPanelSurface,
79 + selectSelectedRightPanelSurface,
80 + selectThreadRightPanelState,
81 + useRightPanelStore,
82 + type PullRequestSurface,
83 + type RightPanelSurface,
84 +} from "~/rightPanelStore";
85 +import { useAtomCommand } from "~/state/use-atom-command";
86 +import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
87 +import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
88 +import { useProjects } from "~/state/entities";
89 +import { useEnvironments, useIssuesSupported } from "~/state/environments";
90 +import { issueEnvironment, useIssueList, type IssueListTarget } from "~/state/issues";
91 +import { useDebouncedValue } from "~/state/queries";
92 +import { primaryServerKeybindingsAtom } from "~/state/server";
93 +
94 +export interface IssuesSearch extends IssueListPreferences {
95 + readonly selectedEnvironmentId?: EnvironmentId;
96 + readonly selectedProjectId?: ProjectId;
97 + /** Part of the panel tab's identity, so a link reopens the tab a row press opened. */
98 + readonly selectedHost?: string;
99 + readonly tracker?: string;
100 + readonly scope?: string;
101 + readonly key?: string;
102 +}
103 +
104 +const STATE_TABS = [
105 + { value: "open", label: "Open", Icon: IssueGlyph.issue },
106 + { value: "closed", label: "Closed", Icon: CircleCheckIcon },
107 + { value: "all", label: "All", Icon: LayersIcon },
108 +] as const satisfies ReadonlyArray<PullRequestFilterOption<IssueListState>>;
109 +
110 +const INVOLVEMENT_TABS = [
111 + { value: "all", label: "Everyone", Icon: UsersIcon },
112 + { value: "assigned", label: "Assigned to me", Icon: UserCheckIcon },
113 + { value: "authored", label: "Opened by me", Icon: PenLineIcon },
114 + { value: "mentioned", label: "Mentioning me", Icon: AtSignIcon },
115 +] as const satisfies ReadonlyArray<PullRequestFilterOption<IssueInvolvement>>;
116 +
117 +const PAGE_SIZE = 50;
118 +const EMPTY_SET: ReadonlySet<string> = new Set();
119 +const EMPTY_RECORD = {} as const;
120 +const EMPTY_MAP = new Map<string, string>();
121 +
122 +function getShortcutContext() {
123 + return {
124 + terminalFocus: isTerminalFocused(),
125 + terminalOpen: false,
126 + previewFocus: false,
127 + previewOpen: false,
128 + modelPickerOpen: false,
129 + isWeb: !isElectron,
130 + isDesktop: isElectron,
131 + };
132 +}
133 +
134 +/** Rows from every environment that answered, with any continuation pages laid over them. */
135 +interface HeldPage {
136 + readonly answer: IssueListResult;
137 + readonly entries: ReadonlyArray<IssueListEntry>;
138 + readonly errors: ReadonlyArray<IssueListProjectError>;
139 + readonly nextCursors: IssueListCursors;
140 + /** Why the last "Load more" failed, until a retry succeeds or a new first page arrives. */
141 + readonly moreFailure: string | null;
142 +}
143 +
144 +function trackerKey(tracker: Pick<IssueTrackerSummary, "tracker" | "host">): string {
145 + return `${tracker.tracker} ${tracker.host.toLowerCase()}`;
146 +}
147 +
148 +/** Continuations are laid over the first page they continue; a new first page forgets them. */
149 +function holdPages(
150 + answers: ReadonlyArray<readonly [EnvironmentId, IssueListResult]>,
151 + pages: ReadonlyMap<EnvironmentId, HeldPage>,
152 +): ReadonlyMap<EnvironmentId, HeldPage> {
153 + const next = new Map<EnvironmentId, HeldPage>();
154 + for (const [environmentId, answer] of answers) {
155 + const previous = pages.get(environmentId);
156 + next.set(
157 + environmentId,
158 + previous?.answer === answer
159 + ? previous
160 + : {
161 + answer,
162 + entries: answer.entries,
163 + errors: answer.errors,
164 + nextCursors: answer.nextCursors,
165 + moreFailure: null,
166 + },
167 + );
168 + }
169 + return next;
170 +}
171 +
172 +function groupIssues(
173 + held: ReadonlyMap<EnvironmentId, HeldPage>,
174 + query: string,
175 + projects: ReadonlyArray<EnvironmentProject>,
176 +) {
177 + const byTracker = new Map<
178 + string,
179 + {
180 + tracker: IssueTrackerSummary;
181 + rows: EnvironmentIssueEntry[];
182 + errors: Array<{ projectTitle: string; message: string; environmentId: EnvironmentId }>;
183 + more: EnvironmentId[];
184 + }
185 + >();
186 + const needle = query.toLowerCase();
187 + for (const [environmentId, page] of held) {
188 + for (const tracker of page.answer.trackers) {
189 + const key = trackerKey(tracker);
190 + if (!byTracker.has(key)) byTracker.set(key, { tracker, rows: [], errors: [], more: [] });
191 + const group = byTracker.get(key)!;
192 + if (!group.tracker.configured && tracker.configured) group.tracker = tracker;
193 + if (Object.keys(page.nextCursors).some((c) => c.startsWith(`${tracker.host} `)))
194 + group.more.push(environmentId);
195 + }
196 + for (const entry of page.entries) {
197 + const key = trackerKey(entry);
198 + const group = byTracker.get(key);
199 + if (!group) continue;
200 + // A tracker that cannot search is narrowed here instead.
201 + if (
202 + needle.length > 0 &&
203 + group.tracker.capabilities?.search !== true &&
204 + !entry.title.toLowerCase().includes(needle) &&
205 + !entry.displayKey.toLowerCase().includes(needle)
206 + )
207 + continue;
208 + group.rows.push({ ...entry, environmentId });
209 + }
210 + for (const error of page.errors) {
211 + const project = projects.find(
212 + (p) => p.environmentId === environmentId && p.id === error.projectId,
213 + );
214 + const kind = project?.repositoryIdentity?.provider as SourceControlProviderKind | undefined;
215 + const host = kind
216 + ? sourceControlClients.changeRequestHost(project?.repositoryIdentity, kind)
217 + : null;
218 + const group =
219 + (host ? byTracker.get(`${kind} ${host.toLowerCase()}`) : undefined) ??
220 + [...byTracker.values()][0];
221 + group?.errors.push({ ...error, environmentId });
222 + }
223 + }
224 + for (const group of byTracker.values()) {
225 + group.rows.sort((a, b) => Date.parse(b.updatedAt) - Date.parse(a.updatedAt));
226 + }
227 + return [...byTracker.values()].sort((a, b) =>
228 + trackerKey(a.tracker).localeCompare(trackerKey(b.tracker)),
229 + );
230 +}
231 +
232 +function hostOptionsFor(groups: ReturnType<typeof groupIssues>) {
233 + const hosts = new Map<string, IssueTrackerSummary>();
234 + for (const group of groups) hosts.set(group.tracker.host, group.tracker);
235 + return [
236 + { value: "", label: "All", Icon: Plug2Icon },
237 + ...[...hosts.values()].map((tracker) => ({
238 + value: tracker.host,
239 + label:
240 + hosts.size > 1 && issueTrackerPresentation(tracker.tracker).providerName === tracker.host
241 + ? tracker.host
242 + : `${issueTrackerPresentation(tracker.tracker).providerName} (${tracker.host})`,
243 + Icon: issueTrackerPresentation(tracker.tracker).Icon,
244 + ...(tracker.configured ? {} : { unavailable: tracker.detail ?? "Unavailable" }),
245 + })),
246 + ];
247 +}
248 +
249 +export function IssuesPage() {
250 + const navigate = useNavigate({ from: "/issues" });
251 + const search = useSearch({ from: "/_chat/issues" });
252 + const { environments } = useEnvironments();
253 + const projects = useProjects();
254 + const issuesSupported = useIssuesSupported();
255 + const keybindings = useAtomValue(primaryServerKeybindingsAtom);
256 +
257 + const capableEnvironments = environments.filter(
258 + (environment) => environment.serverConfig?.environment.capabilities.issues === true,
259 + );
260 + const environmentLabels = new Map(environments.map((e) => [e.environmentId, e.label] as const));
261 +
262 + const debouncedQuery = useDebouncedValue(search.q ?? "", 300);
263 + const listInput: IssueListInput = {
264 + state: search.status,
265 + involvement: search.who,
266 + limit: PAGE_SIZE,
267 + ...(search.host ? { host: search.host } : {}),
268 + ...(debouncedQuery ? { query: debouncedQuery } : {}),
269 + };
270 + const targets: ReadonlyArray<IssueListTarget> = capableEnvironments.map((e) => ({
271 + environmentId: e.environmentId,
272 + input: listInput,
273 + }));
274 + const list = useIssueList(targets);
275 + useLiveRefresh(list.refresh, { key: JSON.stringify(targets) });
276 +
277 + const [pages, setPages] = useState<ReadonlyMap<EnvironmentId, HeldPage>>(new Map());
278 + const held = holdPages(list.answers, pages);
279 + const loadPage = useAtomCommand(issueEnvironment.listPage, { reportFailure: false });
280 + const [loadingMore, setLoadingMore] = useState<EnvironmentId | null>(null);
281 + const loadMore = async (environmentId: EnvironmentId) => {
282 + const page = held.get(environmentId);
283 + if (!page || Object.keys(page.nextCursors).length === 0 || loadingMore !== null) return;
284 + setLoadingMore(environmentId);
285 + const result = await loadPage({
286 + environmentId,
287 + input: { ...listInput, cursors: page.nextCursors },
288 + });
289 + setLoadingMore(null);
290 + const failure = result._tag === "Failure" ? squashAtomCommandFailure(result) : null;
291 + setPages((current) => {
292 + const next = new Map(current);
293 + next.set(
294 + environmentId,
295 + result._tag === "Failure"
296 + ? {
297 + ...page,
298 + moreFailure: failure instanceof Error ? failure.message : "The next page failed.",
299 + }
300 + : {
301 + answer: page.answer,
302 + entries: mergeIssueListPage(page.entries, result.value.entries),
303 + errors: mergeIssueListErrors(page.errors, result.value.errors),
304 + nextCursors: result.value.nextCursors,
305 + moreFailure: null,
306 + },
307 + );
308 + return next;
309 + });
310 + };
311 +
312 + // Rows grouped per tracker account, so a tracker that cannot be read says so where its rows
313 + // would be, and each tracker's rows carry on from their own cursors.
314 + const groups = groupIssues(held, debouncedQuery, projects);
315 +
316 + const hostOptions = hostOptionsFor(groups);
317 +
318 + const updateSearch = (patch: { [Key in keyof IssuesSearch]?: IssuesSearch[Key] | undefined }) => {
319 + const merged = { ...search, ...patch };
320 + const next: IssuesSearch = {
321 + who: merged.who ?? search.who,
322 + status: merged.status ?? search.status,
323 + ...(merged.host ? { host: merged.host } : {}),
324 + q: merged.q || undefined,
325 + ...(merged.selectedEnvironmentId
326 + ? { selectedEnvironmentId: merged.selectedEnvironmentId }
327 + : {}),
328 + ...(merged.selectedProjectId ? { selectedProjectId: merged.selectedProjectId } : {}),
329 + ...(merged.selectedHost ? { selectedHost: merged.selectedHost } : {}),
330 + ...(merged.tracker ? { tracker: merged.tracker } : {}),
331 + ...(merged.scope ? { scope: merged.scope } : {}),
332 + ...(merged.key ? { key: merged.key } : {}),
333 + };
334 + writeIssueListPreferences(issueListPreferences(next));
335 + void navigate({ search: next });
336 + };
337 + const clearedSelection = {
338 + selectedEnvironmentId: undefined,
339 + selectedProjectId: undefined,
340 + selectedHost: undefined,
341 + tracker: undefined,
342 + scope: undefined,
343 + key: undefined,
344 + } as const;
345 +
346 + // One shared panel for the page, with a fixed sentinel ref, as the pull-request page does.
347 + const rightPanelRef = capableEnvironments.length === 0 ? null : ISSUES_PANEL_REF;
348 + const rightPanelState = useRightPanelStore((state) =>
349 + selectThreadRightPanelState(state.byThreadKey, rightPanelRef),
350 + );
351 + const selectedSurface = useRightPanelStore((state) =>
352 + selectSelectedRightPanelSurface(state.byThreadKey, rightPanelRef),
353 + );
354 + const panelSurface =
355 + selectedSurface?.kind === "issue" || selectedSurface?.kind === "pull-request"
356 + ? selectedSurface
357 + : null;
358 + const { active: panelAnimationsActive, durationMs } = usePanelAnimationSettings();
359 + const presenceValue = { activeSurface: panelSurface, surfaces: rightPanelState.surfaces };
360 + const presence = usePanelPresence(
361 + rightPanelState.isOpen && panelSurface !== null,
362 + presenceValue,
363 + panelAnimationsActive,
364 + rightPanelRef?.threadId ?? null,
365 + durationMs,
366 + );
367 + const renderedSurface = presence.value?.activeSurface ?? null;
368 + const panelEnvironmentId =
369 + (renderedSurface?.environmentId as EnvironmentId | undefined) ??
370 + capableEnvironments[0]?.environmentId ??
371 + null;
372 +
373 + const panelListEntry =
374 + renderedSurface?.kind === "issue"
375 + ? (groups
376 + .flatMap((group) => group.rows)
377 + .find(
378 + (row) =>
379 + row.environmentId === panelEnvironmentId &&
380 + issueEntryKey(row) ===
381 + issueEntryKey({
382 + ...renderedSurface,
383 + host: renderedSurface.host ?? row.host,
384 + projectId: renderedSurface.projectId as ProjectId,
385 + }),
386 + ) ?? null)
387 + : null;
388 +
389 + const selectSurfaceInUrl = (surface: RightPanelSurface | null) =>
390 + updateSearch(
391 + surface?.kind === "issue"
392 + ? {
393 + selectedEnvironmentId: surface.environmentId as EnvironmentId | undefined,
394 + selectedProjectId: surface.projectId as ProjectId,
395 + selectedHost: surface.host,
396 + tracker: surface.tracker,
397 + scope: surface.scope,
398 + key: surface.key,
399 + }
400 + : clearedSelection,
401 + );
402 +
403 + const selectEntry = (entry: IssueRowTarget) => {
404 + if (rightPanelRef === null) return;
405 + useRightPanelStore.getState().openIssue(rightPanelRef, entry);
406 + updateSearch({
407 + selectedEnvironmentId: entry.environmentId,
408 + selectedProjectId: entry.projectId,
409 + selectedHost: entry.host,
410 + tracker: entry.tracker,
411 + scope: entry.scope,
412 + key: entry.key,
413 + });
414 + };
415 +
416 + // A link into the page names an issue before any row was pressed.
417 + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- opens the URL-linked issue in the right panel store
418 + useEffect(() => {
419 + if (
420 + rightPanelRef === null ||
421 + !search.tracker ||
422 + !search.scope ||
423 + !search.key ||
424 + !search.selectedProjectId
425 + )
426 + return;
427 + useRightPanelStore.getState().openIssue(rightPanelRef, {
428 + ...(search.selectedEnvironmentId === undefined
429 + ? {}
430 + : { environmentId: search.selectedEnvironmentId }),
431 + projectId: search.selectedProjectId,
432 + ...(search.selectedHost === undefined ? {} : { host: search.selectedHost }),
433 + tracker: search.tracker,
434 + scope: search.scope,
435 + key: search.key,
436 + });
437 + }, [
438 + rightPanelRef,
439 + search.tracker,
440 + search.scope,
441 + search.key,
442 + search.selectedProjectId,
443 + search.selectedHost,
444 + search.selectedEnvironmentId,
445 + ]);
446 +
447 + const closeSurface = (surface: RightPanelSurface) => {
448 + if (rightPanelRef === null) return;
449 + useRightPanelStore.getState().closeSurface(rightPanelRef, surface.id);
450 + selectSurfaceInUrl(
451 + selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, rightPanelRef),
452 + );
453 + };
454 + const toggleRightPanel = () => {
455 + if (rightPanelRef === null) return;
456 + if (rightPanelState.isOpen) {
457 + useRightPanelStore.getState().close(rightPanelRef);
458 + updateSearch(clearedSelection);
459 + return;
460 + }
461 + if (panelSurface === null) return;
462 + useRightPanelStore.getState().show(rightPanelRef);
463 + selectSurfaceInUrl(panelSurface);
464 + };
465 +
466 + // Every writable scope the workspace has, for the composer.
467 +
468 + const showTracker = groups.length > 1;
469 + const noneAnswered = list.answers.length === 0;
470 +
471 + const listBody: ReactNode = !issuesSupported ? (
472 + <PullRequestsUnavailableState
473 + title="Issues unavailable"
474 + error="Update this environment's T3 Code server to browse issues."
475 + />
476 + ) : noneAnswered && list.isPending ? (
477 + <PullRequestListGhost />
478 + ) : noneAnswered && list.error ? (
479 + <PullRequestsUnavailableState
480 + error={list.error}
481 + onRetry={list.refresh}
482 + refreshing={list.isPending}
483 + />
484 + ) : groups.length === 0 ? (
485 + <Empty>
486 + <EmptyMedia variant="icon">
487 + <IssueGlyph.issue />
488 + </EmptyMedia>
489 + <EmptyHeader>
490 + <EmptyTitle>No trackers to read</EmptyTitle>
491 + <EmptyDescription>Add a project whose remote is on a supported tracker.</EmptyDescription>
492 + </EmptyHeader>
493 + </Empty>
494 + ) : (
495 + <div className="flex flex-col gap-6">
496 + {groups.map((group) => {
497 + const presentation = issueTrackerPresentation(group.tracker.tracker);
498 + const showScope = new Set(group.rows.map((row) => row.scope.toLowerCase())).size > 1;
499 + return (
500 + <section key={trackerKey(group.tracker)} className="flex flex-col gap-1">
501 + <h2 className="flex items-center gap-1.5 px-3 text-xs font-medium text-muted-foreground">
502 + <presentation.Icon aria-hidden className="size-3.5" />
503 + {presentation.providerName}
504 + {presentation.providerName.toLowerCase() !== group.tracker.host ? (
505 + <span className="font-normal">· {group.tracker.host}</span>
506 + ) : null}
507 + <span className="font-normal">
508 + · {group.tracker.projectCount}{" "}
509 + {group.tracker.projectCount === 1 ? "project" : "projects"}
510 + </span>
511 + </h2>
512 + {!group.tracker.configured ? (
513 + <p className="px-3 text-sm text-muted-foreground">
514 + {group.tracker.detail ?? "This tracker cannot be read right now."}
515 + </p>
516 + ) : null}
517 + {group.errors.map((error) => (
518 + <p
519 + key={`${error.environmentId}:${error.projectTitle}`}
520 + className="px-3 text-xs text-destructive"
521 + >
522 + {error.projectTitle}: {error.message}
523 + </p>
524 + ))}
525 + {group.tracker.configured && group.rows.length === 0 && group.errors.length === 0 ? (
526 + <p className="px-3 text-sm text-muted-foreground">
527 + {debouncedQuery ? "Nothing matches that." : "No issues under these filters."}
528 + </p>
529 + ) : null}
530 + {group.rows.map((row) => {
531 + const key = issueEntryKey(row);
532 + const selected =
533 + renderedSurface?.kind === "issue" &&
534 + renderedSurface.environmentId === row.environmentId &&
535 + issueEntryKey({
536 + ...renderedSurface,
537 + host: renderedSurface.host ?? "",
538 + projectId: renderedSurface.projectId as ProjectId,
539 + }) === key;
540 + return (
541 + <IssueRow
542 + key={`${row.environmentId}:${key}`}
543 + entry={row}
544 + selected={selected}
545 + showScope={showScope}
546 + showTracker={showTracker}
547 + {...(capableEnvironments.length > 1 && environmentLabels.has(row.environmentId)
548 + ? { environmentLabel: environmentLabels.get(row.environmentId) }
549 + : {})}
550 + onSelect={selectEntry}
551 + />
552 + );
553 + })}
554 + {group.more.map((environmentId) => {
555 + const moreFailure = held.get(environmentId)?.moreFailure ?? null;
556 + return (
557 + <Fragment key={environmentId}>
558 + {moreFailure === null ? null : (
559 + <p className="px-3 text-xs text-destructive">{moreFailure}</p>
560 + )}
561 + <Button
562 + size="sm"
563 + variant="ghost-muted"
564 + className="self-start"
565 + disabled={loadingMore !== null}
566 + onClick={() => void loadMore(environmentId)}
567 + >
568 + {loadingMore === environmentId
569 + ? "Loading…"
570 + : moreFailure === null
571 + ? "Load more"
572 + : "Retry"}
573 + </Button>
574 + </Fragment>
575 + );
576 + })}
577 + </section>
578 + );
579 + })}
580 + </div>
581 + );
582 +
583 + return (
584 + <SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none">
585 + <div className="relative flex min-h-0 flex-1">
586 + <div className="@container/issue-list flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-background">
587 + <WorkspacePageHeader
588 + electron={isElectron}
589 + reserveNativeControls={!rightPanelState.isOpen}
590 + className="relative bg-background"
591 + >
592 + <WorkspaceBreadcrumb ariaLabel="Issues breadcrumb">
593 + <WorkspaceBreadcrumbItem current>
594 + <h1 className="truncate">Issues</h1>
595 + </WorkspaceBreadcrumbItem>
596 + </WorkspaceBreadcrumb>
597 + <div className="min-w-0 flex-1" />
598 + <div
599 + className="flex items-center gap-1 [-webkit-app-region:no-drag]"
600 + data-workspace-titlebar-controls
601 + >
602 + <PanelLayoutControls
603 + showTerminalControl={false}
604 + showThreadPanelControl={false}
605 + terminalAvailable={false}
606 + terminalOpen={false}
607 + terminalShortcutLabel={null}
608 + threadPanelOpen={false}
609 + threadPanelPresentation="inline"
610 + threadPanelShortcutLabel={null}
611 + onToggleThreadPanel={() => undefined}
612 + rightPanelAvailable={panelSurface !== null}
613 + rightPanelOpen={rightPanelState.isOpen}
614 + rightPanelShortcutLabel={shortcutLabelForCommand(keybindings, "rightPanel.toggle")}
615 + rightPanelUnavailableLabel="Select an issue first"
616 + onToggleTerminal={() => undefined}
617 + onToggleRightPanel={toggleRightPanel}
618 + />
619 + </div>
620 + </WorkspacePageHeader>
621 +
622 + <div className="topbar-scroll-fade scrollbar-gutter-both min-h-0 flex-1 overflow-y-auto">
623 + <WorkspacePageContainer width="expanded" className="min-h-full gap-4">
624 + <div className="flex flex-wrap items-center gap-2">
625 + <div className="min-w-0 basis-full @lg/issue-list:basis-0 @lg/issue-list:flex-1">
626 + <PullRequestSearchInput
627 + value={search.q ?? ""}
628 + label="Search issues"
629 + placeholder="Search issues"
630 + busy={
631 + (search.q ?? "") !== debouncedQuery ||
632 + (debouncedQuery.length > 0 && list.isPending)
633 + }
634 + onChange={(q) => updateSearch({ q: q || undefined })}
635 + onSubmit={(q) => updateSearch({ q: q || undefined })}
636 + />
637 + </div>
638 + <ToggleGroup
639 + size="segmented"
640 + variant="segmented"
641 + aria-label="Filter by state"
642 + value={[search.status]}
643 + onValueChange={(next) => {
644 + const status = STATE_TABS.find((tab) => tab.value === next[0])?.value;
645 + if (status) updateSearch({ status });
646 + }}
647 + >
648 + {STATE_TABS.map((tab) => (
649 + <Toggle key={tab.value} value={tab.value}>
650 + {tab.label}
651 + </Toggle>
652 + ))}
653 + </ToggleGroup>
654 + <FilterMenu
655 + label="Filter by involvement"
656 + value={search.who}
657 + options={INVOLVEMENT_TABS}
658 + onChange={(who) => updateSearch({ who })}
659 + />
660 + {hostOptions.length > 1 ? (
661 + <FilterMenu
662 + label="Filter by tracker"
663 + value={search.host ?? ""}
664 + options={hostOptions}
665 + onChange={(host) => updateSearch({ host: host || undefined })}
666 + />
667 + ) : null}
668 + <Button
669 + size="icon"
670 + variant="outline"
671 + aria-label="Refresh issues"
672 + onClick={list.refresh}
673 + disabled={list.isPending}
674 + >
675 + <RefreshIcon size="md" refreshing={list.isPending} />
676 + </Button>
677 + </div>
678 + {listBody}
679 + </WorkspacePageContainer>
680 + </div>
681 + </div>
682 +
683 + {presence.present &&
684 + renderedSurface &&
685 + panelEnvironmentId !== null &&
686 + rightPanelRef !== null ? (
687 + <RightPanelTabs
688 + mode="inline"
689 + open={rightPanelState.isOpen}
690 + keybindings={keybindings}
691 + getShortcutContext={getShortcutContext}
692 + widthStorageKey="t3code:issue-panel-width"
693 + defaultWidth={typeof window === "undefined" ? 640 : Math.floor(window.innerWidth / 2)}
694 + surfaces={presence.value?.surfaces ?? []}
695 + environmentId={panelEnvironmentId}
696 + activeSurfaceId={renderedSurface.id}
697 + pendingSurfaceIds={EMPTY_SET}
698 + previewSessions={EMPTY_RECORD}
699 + desktopByTabId={EMPTY_RECORD}
700 + terminalLabelsById={EMPTY_MAP}
701 + onActivate={(surface) => {
702 + useRightPanelStore.getState().activateSurface(rightPanelRef, surface.id);
703 + selectSurfaceInUrl(surface);
704 + }}
705 + onCloseSurface={closeSurface}
706 + onCloseOtherSurfaces={(surface) => {
707 + useRightPanelStore.getState().closeOtherSurfaces(rightPanelRef, surface.id);
708 + selectSurfaceInUrl(surface);
709 + }}
710 + onCloseSurfacesToRight={(surface) => {
711 + useRightPanelStore.getState().closeSurfacesToRight(rightPanelRef, surface.id);
712 + selectSurfaceInUrl(
713 + selectActiveRightPanelSurface(
714 + useRightPanelStore.getState().byThreadKey,
715 + rightPanelRef,
716 + ),
717 + );
718 + }}
719 + onCloseAllSurfaces={() => {
720 + useRightPanelStore.getState().closeAllSurfaces(rightPanelRef);
721 + selectSurfaceInUrl(null);
722 + }}
723 + onMoveSurface={(surfaceId, toIndex) =>
724 + useRightPanelStore.getState().moveSurface(rightPanelRef, surfaceId, toIndex)
725 + }
726 + onCopyFilePath={() => undefined}
727 + onAddBrowser={() => undefined}
728 + onAddBrowserInProfile={() => undefined}
729 + onAddTerminal={() => undefined}
730 + onAddDiff={() => undefined}
731 + onAddFiles={() => undefined}
732 + onAddPullRequest={() => undefined}
733 + onAddPullRequests={() => undefined}
734 + onAddDevice={() => undefined}
735 + browserAvailable={false}
736 + terminalAvailable={false}
737 + diffAvailable={false}
738 + filesAvailable={false}
739 + pullRequestAvailable={false}
740 + pullRequestsAvailable={false}
741 + deviceAvailable={false}
742 + >
743 + {renderedSurface.kind === "issue" ? (
744 + <IssueDetailPanel
745 + key={renderedSurface.id}
746 + environmentId={panelEnvironmentId}
747 + listEntry={panelListEntry}
748 + reference={{
749 + projectId: renderedSurface.projectId as ProjectId,
750 + tracker: renderedSurface.tracker as IssueTrackerKind,
751 + ...(renderedSurface.host ? { host: renderedSurface.host } : {}),
752 + scope: renderedSurface.scope,
753 + key: renderedSurface.key,
754 + }}
755 + onSelectPullRequest={(reference) => {
756 + useRightPanelStore.getState().openPullRequest(rightPanelRef, {
757 + projectId: reference.projectId,
758 + repository: reference.repository,
759 + number: reference.number,
760 + ...(reference.host === undefined ? {} : { host: reference.host }),
761 + environmentId: panelEnvironmentId,
762 + });
763 + }}
764 + />
765 + ) : (
766 + <PullRequestDetailPanel
767 + key={renderedSurface.id}
768 + getShortcutContext={getShortcutContext}
769 + shortcutsEnabled={panelSurface?.id === renderedSurface.id}
770 + environmentId={panelEnvironmentId}
771 + reference={{
772 + projectId: (renderedSurface as PullRequestSurface).projectId as ProjectId,
773 + repository: (renderedSurface as PullRequestSurface).repository,
774 + number: (renderedSurface as PullRequestSurface).number,
775 + ...((renderedSurface as PullRequestSurface).host
776 + ? { host: (renderedSurface as PullRequestSurface).host }
777 + : {}),
778 + }}
779 + />
780 + )}
781 + </RightPanelTabs>
782 + ) : null}
783 + </div>
784 + </SidebarInset>
785 + );
786 +}
787 +
788 +function FilterMenu<Value extends string>({
789 + label,
790 + value,
791 + options,
792 + onChange,
793 +}: {
794 + label: string;
795 + value: Value;
796 + options: ReadonlyArray<PullRequestFilterOption<Value>>;
797 + onChange: (value: Value) => void;
798 +}) {
799 + const current = options.find((option) => option.value === value) ?? options[0];
800 + if (!current) return null;
801 + return (
802 + <Menu>
803 + <MenuTrigger aria-label={`${label}: ${current.label}`} render={<Button variant="outline" />}>
804 + <PullRequestFilterOptionIcon option={current} />
805 + <span className="truncate">{current.label}</span>
806 + </MenuTrigger>
807 + <MenuPopup align="start">
808 + <MenuRadioGroup value={value} onValueChange={(next) => onChange(next as Value)}>
809 + {options.map((option) => (
810 + <MenuRadioItem
811 + key={option.value}
812 + value={option.value}
813 + disabled={option.unavailable !== undefined}
814 + >
815 + <span className="flex min-w-0 items-center gap-2">
816 + <PullRequestFilterOptionIcon option={option} />
817 + <span className="min-w-0 flex-1 truncate">{option.label}</span>
818 + </span>
819 + </MenuRadioItem>
820 + ))}
821 + </MenuRadioGroup>
822 + </MenuPopup>
823 + </Menu>
824 + );
825 +}
apps/web/src/components/issue/issueListPreferences.ts new
+74
@@ -0,0 +1,74 @@
1 +import * as Schema from "effect/Schema";
2 +
3 +import { IssueInvolvement, IssueListState } from "@t3tools/contracts";
4 +
5 +/**
6 + * What the issues page remembers between visits; the selection in the URL is not part of it.
7 + * `who` and `status` rather than `involvement` and `state`: the router merges every route's
8 + * search into one type for `navigate`, and sharing the pull-request page's key names would widen
9 + * its own literal unions with this page's values.
10 + */
11 +export interface IssueListPreferences {
12 + readonly who: IssueInvolvement;
13 + readonly status: IssueListState;
14 + readonly host?: string;
15 + readonly q?: string | undefined;
16 +}
17 +
18 +const DEFAULT_ISSUE_LIST_PREFERENCES = {
19 + who: "all",
20 + status: "open",
21 +} as const satisfies IssueListPreferences;
22 +
23 +const STORAGE_KEY = "t3.issues.preferences";
24 +
25 +const BoundedPreference = Schema.String.check(Schema.isMaxLength(200));
26 +const IssueListPreferencesSchema = Schema.Struct({
27 + who: IssueInvolvement,
28 + status: IssueListState,
29 + host: Schema.optional(BoundedPreference),
30 + q: Schema.optional(BoundedPreference),
31 +});
32 +const decodePreferences = Schema.decodeUnknownOption(IssueListPreferencesSchema);
33 +
34 +type PreferenceStorage = Pick<Storage, "getItem" | "setItem">;
35 +
36 +function storage(): PreferenceStorage | undefined {
37 + return typeof window === "undefined" ? undefined : window.localStorage;
38 +}
39 +
40 +/** Only list controls are remembered. The selected issue remains a URL and right-panel concern. */
41 +export function issueListPreferences(search: {
42 + readonly who: IssueInvolvement;
43 + readonly status: IssueListState;
44 + readonly host?: string | undefined;
45 + readonly q?: string | undefined;
46 +}): IssueListPreferences {
47 + return {
48 + who: search.who,
49 + status: search.status,
50 + ...(search.host ? { host: search.host } : {}),
51 + ...(search.q ? { q: search.q } : {}),
52 + };
53 +}
54 +
55 +export function readIssueListPreferences(): IssueListPreferences {
56 + try {
57 + const raw = storage()?.getItem(STORAGE_KEY);
58 + if (!raw) return DEFAULT_ISSUE_LIST_PREFERENCES;
59 + const decoded = decodePreferences(JSON.parse(raw));
60 + return decoded._tag === "Some"
61 + ? issueListPreferences(decoded.value)
62 + : DEFAULT_ISSUE_LIST_PREFERENCES;
63 + } catch {
64 + return DEFAULT_ISSUE_LIST_PREFERENCES;
65 + }
66 +}
67 +
68 +export function writeIssueListPreferences(preferences: IssueListPreferences): void {
69 + try {
70 + storage()?.setItem(STORAGE_KEY, JSON.stringify(issueListPreferences(preferences)));
71 + } catch {
72 + // Storage can be full or forbidden; the page still works with defaults.
73 + }
74 +}
apps/web/src/components/issue/issuePresentation.tsx new
+75
@@ -0,0 +1,75 @@
1 +import type { IssueState, IssueTrackerKind } from "@t3tools/contracts";
2 +import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
3 +import { CircleCheckIcon, CircleDotIcon, CircleSlashIcon, TicketIcon } from "lucide-react";
4 +
5 +import { cn } from "~/lib/utils";
6 +import { getSourceControlPresentationForKind } from "~/sourceControlPresentation";
7 +
8 +import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
9 +import { PULL_REQUEST_STATE_PRESENTATION } from "../pullRequest/pullRequestIcons";
10 +
11 +export const IssueGlyph = { issue: CircleDotIcon } as const;
12 +
13 +/** A git host's tracker wears the host's own icon and name; a standalone tracker wears its kind. */
14 +export function issueTrackerPresentation(tracker: IssueTrackerKind | string) {
15 + if (sourceControlClients.find(tracker) !== undefined) {
16 + return getSourceControlPresentationForKind(tracker);
17 + }
18 + return { providerName: tracker, Icon: TicketIcon };
19 +}
20 +
21 +/**
22 + * Open and completed borrow the ink the pull-request states use for open and merged, so green
23 + * and violet mean the same thing on both pages; not planned wears a draft's grey, because work
24 + * that stopped must not look like work that finished. The tracker's own state name is the label,
25 + * so a workflow tracker's "In Review" reads as itself.
26 + */
27 +export function issueStatePresentation(state: IssueState) {
28 + if (state.category === "open") {
29 + return {
30 + ...PULL_REQUEST_STATE_PRESENTATION.open,
31 + label: state.name === "open" ? "Open" : state.name,
32 + Icon: CircleDotIcon,
33 + };
34 + }
35 + if (state.closeReason === "not-planned") {
36 + return {
37 + ...PULL_REQUEST_STATE_PRESENTATION.draft,
38 + label: "Closed as not planned",
39 + Icon: CircleSlashIcon,
40 + };
41 + }
42 + return {
43 + ...PULL_REQUEST_STATE_PRESENTATION.merged,
44 + label:
45 + state.name === "closed"
46 + ? state.closeReason === "completed"
47 + ? "Closed as completed"
48 + : "Closed"
49 + : state.name,
50 + Icon: CircleCheckIcon,
51 + };
52 +}
53 +
54 +export function IssueStateGlyph({ state, className }: { state: IssueState; className?: string }) {
55 + const presentation = issueStatePresentation(state);
56 + return (
57 + <Tooltip>
58 + {/* The list row is itself a button, so the trigger stays a span. */}
59 + <TooltipTrigger render={<span className="inline-flex shrink-0" />}>
60 + <presentation.Icon
61 + role="img"
62 + aria-label={presentation.label}
63 + className={cn("size-4 shrink-0", presentation.toneClassName, className)}
64 + />
65 + </TooltipTrigger>
66 + <TooltipPopup>{presentation.label}</TooltipPopup>
67 + </Tooltip>
68 + );
69 +}
70 +
71 +/** "completed" → "Completed"; a reason the tracker spells with a dash reads as words. */
72 +export function issueCloseReasonLabel(reason: string): string {
73 + const words = reason.replace(/[-_]+/g, " ").trim();
74 + return words.charAt(0).toUpperCase() + words.slice(1);
75 +}
apps/web/src/components/pullRequest/PullRequestGhosts.tsx
+1 -1
@@ -37,7 +37,7 @@ import {
37 resolvePullRequestState,
38 } from "./pullRequestPresentation";
39
40 -function GhostBar({ className }: { className?: string | undefined }) {
40 +export function GhostBar({ className }: { className?: string | undefined }) {
41 return <span aria-hidden className={cn("block h-3 rounded bg-muted-foreground/15", className)} />;
42 }
43
apps/web/src/components/pullRequest/PullRequestListFilters.tsx
+6 -2
@@ -96,11 +96,15 @@ export function pullRequestHostLabel(
96 export function PullRequestSearchInput({
97 value,
98 busy,
99 + label,
100 + placeholder,
101 onChange,
102 onSubmit,
103 }: {
104 value: string;
105 busy?: boolean;
106 + label: string;
107 + placeholder: string;
108 onChange: (value: string) => void;
109 onSubmit: (value: string) => void;
110 }) {
@@ -127,8 +131,8 @@ export function PullRequestSearchInput({
131 onSubmit(event.currentTarget.value);
132 }
133 }}
130 - placeholder="Search pull requests, or label:bug"
131 - aria-label="Search pull requests"
134 + placeholder={placeholder}
135 + aria-label={label}
136 />
137 </InputGroup>
138 );
apps/web/src/components/pullRequest/PullRequestReactions.tsx
+55 -32
@@ -30,22 +30,16 @@ const PILL_CLASS =
30 const EMPTY_PENDING: ReadonlyMap<PullRequestReactionContent, PendingPullRequestReaction> =
31 new Map();
32
33 -export function PullRequestReactionBar({
33 +/** Reaction pills with a picker. `onReact` resolves to whether the host saved the change. */
34 +export function ReactionBar({
35 reactions,
36 canReact,
36 - subjectId,
37 - environmentId,
38 - reference,
39 - onRefresh,
37 + onReact,
38 className,
39 }: {
40 readonly reactions: ReadonlyArray<PullRequestReaction>;
41 readonly canReact: boolean;
44 - /** Omit to react to the pull request description. */
45 - readonly subjectId?: string | undefined;
46 - readonly environmentId: EnvironmentId;
47 - readonly reference: PullRequestRef;
48 - readonly onRefresh: () => void;
42 + readonly onReact: (content: PullRequestReactionContent, reacted: boolean) => Promise<boolean>;
43 readonly className?: string | undefined;
44 }) {
45 const [pickerOpen, setPickerOpen] = useState(false);
@@ -53,9 +47,6 @@ export function PullRequestReactionBar({
47 readonly signature: string;
48 readonly values: ReadonlyMap<PullRequestReactionContent, PendingPullRequestReaction>;
49 }>({ signature: "", values: EMPTY_PENDING });
56 - const setReaction = useAtomCommand(pullRequestEnvironment.setReaction, {
57 - reportFailure: false,
58 - });
50
51 const signature = pullRequestReactionsSignature(reactions);
52 const values = pending.signature === signature ? pending.values : EMPTY_PENDING;
@@ -64,26 +55,14 @@ export function PullRequestReactionBar({
55 const toggle = async (content: PullRequestReactionContent, reacted: boolean) => {
56 const entry: PendingPullRequestReaction = { reacted };
57 setPending({ signature, values: new Map([...values, [content, entry]]) });
67 - const result = await setReaction({
68 - environmentId,
69 - input: {
70 - ...reference,
71 - ...(subjectId === undefined ? {} : { subjectId }),
72 - content,
73 - reacted,
74 - },
58 + if (await onReact(content, reacted)) return;
59 + setPending((current) => {
60 + if (current.values.get(content) !== entry) return current;
61 + const next = new Map(current.values);
62 + next.delete(content);
63 + return { signature: current.signature, values: next };
64 });
76 - if (result._tag === "Failure") {
77 - setPending((current) => {
78 - if (current.values.get(content) !== entry) return current;
79 - const next = new Map(current.values);
80 - next.delete(content);
81 - return { signature: current.signature, values: next };
82 - });
83 - toastManager.add({ type: "error", title: "The reaction could not be saved" });
84 - return;
85 - }
86 - onRefresh();
65 + toastManager.add({ type: "error", title: "The reaction could not be saved" });
66 };
67
68 if (shown.length === 0 && !canReact) return null;
@@ -164,3 +143,47 @@ export function PullRequestReactionBar({
143 </div>
144 );
145 }
146 +
147 +export function PullRequestReactionBar({
148 + reactions,
149 + canReact,
150 + subjectId,
151 + environmentId,
152 + reference,
153 + onRefresh,
154 + className,
155 +}: {
156 + readonly reactions: ReadonlyArray<PullRequestReaction>;
157 + readonly canReact: boolean;
158 + /** Omit to react to the pull request description. */
159 + readonly subjectId?: string | undefined;
160 + readonly environmentId: EnvironmentId;
161 + readonly reference: PullRequestRef;
162 + readonly onRefresh: () => void;
163 + readonly className?: string | undefined;
164 +}) {
165 + const setReaction = useAtomCommand(pullRequestEnvironment.setReaction, {
166 + reportFailure: false,
167 + });
168 + return (
169 + <ReactionBar
170 + reactions={reactions}
171 + canReact={canReact}
172 + className={className}
173 + onReact={async (content, reacted) => {
174 + const result = await setReaction({
175 + environmentId,
176 + input: {
177 + ...reference,
178 + ...(subjectId === undefined ? {} : { subjectId }),
179 + content,
180 + reacted,
181 + },
182 + });
183 + if (result._tag === "Failure") return false;
184 + onRefresh();
185 + return true;
186 + }}
187 + />
188 + );
189 +}
apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx
+12 -12
@@ -339,7 +339,7 @@ function CollapsedComment({
339 );
340 }
341
342 -function MetaRow({
342 +export function PullRequestMetaRow({
343 icon,
344 label,
345 children,
@@ -359,7 +359,7 @@ function MetaRow({
359 );
360 }
361
362 -function Section({
362 +export function PullRequestSection({
363 title,
364 defaultOpen = true,
365 keepMounted = false,
@@ -836,7 +836,7 @@ export function PullRequestSummaryTab({
836 >
837 <section className="px-4 pt-2.5 pb-1">
838 <div className="space-y-2">
839 - <MetaRow icon={<UsersIcon className="size-3.5" />} label="Reviewers">
839 + <PullRequestMetaRow icon={<UsersIcon className="size-3.5" />} label="Reviewers">
840 <span className="flex min-w-0 flex-wrap items-center gap-1.5">
841 {reviewerEntries.length === 0 ? (
842 <span className="text-muted-foreground">None</span>
@@ -909,9 +909,9 @@ export function PullRequestSummaryTab({
909 />
910 ) : null}
911 </span>
912 - </MetaRow>
912 + </PullRequestMetaRow>
913 {detail.labels.length > 0 || detail.capabilities.labels === true ? (
914 - <MetaRow icon={<TagIcon className="size-3.5" />} label="Labels">
914 + <PullRequestMetaRow icon={<TagIcon className="size-3.5" />} label="Labels">
915 <span className="flex min-w-0 flex-wrap items-center gap-1">
916 {detail.labels.length === 0 ? (
917 <span className="text-muted-foreground">None</span>
@@ -934,12 +934,12 @@ export function PullRequestSummaryTab({
934 />
935 ) : null}
936 </span>
937 - </MetaRow>
937 + </PullRequestMetaRow>
938 ) : null}
939 </div>
940 </section>
941
942 - <Section
942 + <PullRequestSection
943 key={`description:${detail.url}`}
944 title="Description"
945 keepMounted
@@ -979,9 +979,9 @@ export function PullRequestSummaryTab({
979 </div>
980 )}
981 </div>
982 - </Section>
982 + </PullRequestSection>
983
984 - <Section
984 + <PullRequestSection
985 key={`checks:${detail.url}`}
986 title="Checks"
987 defaultOpen={false}
@@ -1043,9 +1043,9 @@ export function PullRequestSummaryTab({
1043 } /* oxlint-enable react/no-array-index-key */,
1044 )
1045 )}
1046 - </Section>
1046 + </PullRequestSection>
1047
1048 - <Section
1048 + <PullRequestSection
1049 title={`Comments (${detail.commentCount})`}
1050 actions={
1051 <div className="flex shrink-0 items-center gap-1">
@@ -1139,7 +1139,7 @@ export function PullRequestSummaryTab({
1139 )}
1140 </>
1141 )}
1142 - </Section>
1142 + </PullRequestSection>
1143 </div>
1144 );
1145 }
apps/web/src/components/pullRequest/PullRequestsPage.tsx
+2
@@ -1189,6 +1189,8 @@ export function PullRequestsPage() {
1189 const searchInput = (
1190 <PullRequestSearchInput
1191 value={search.q ?? ""}
1192 + label="Search pull requests"
1193 + placeholder="Search pull requests, or label:bug"
1194 busy={typedQuery.length > 0 && (!querySettled || showingCarried)}
1195 onChange={(query) => updateListScope({ q: query || undefined })}
1196 onSubmit={submitQuery}
apps/web/src/components/sidebar/SidebarChrome.tsx
+15 -1
@@ -13,7 +13,7 @@ import {
13 } from "../../navigationHistory";
14 import { primaryServerKeybindingsAtom } from "../../state/server";
15 import { cn } from "../../lib/utils";
16 -import { usePullRequestsSupported } from "../../state/environments";
16 +import { useIssuesSupported, usePullRequestsSupported } from "../../state/environments";
17 import { T3Wordmark } from "../T3Wordmark";
18 import {
19 resolveEnvironmentIdentificationPillLabel,
@@ -33,6 +33,8 @@ import {
33 } from "../ui/sidebar";
34 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
35 import { readPullRequestListPreferences } from "../pullRequest/pullRequestListPreferences";
36 +import { readIssueListPreferences } from "../issue/issueListPreferences";
37 +import { IssueGlyph } from "../issue/issuePresentation";
38 import { isSidebarUtilityPage, useNavigateToMainApp } from "./mainAppLocation";
39 import { SidebarThreadUndoNotice } from "./SidebarThreadUndoNotice";
40 import { SidebarProviderUpdatePill } from "./SidebarProviderUpdatePill";
@@ -226,6 +228,7 @@ const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {
228 select: (location) => isSidebarUtilityPage(location.pathname),
229 });
230 const pullRequestsSupported = usePullRequestsSupported();
231 + const issuesSupported = useIssuesSupported();
232 const closeMobileSidebar = () => {
233 if (isMobile) {
234 setOpenMobile(false);
@@ -238,6 +241,10 @@ const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {
241 search: readPullRequestListPreferences(),
242 });
243 };
244 + const handleIssuesClick = () => {
245 + closeMobileSidebar();
246 + void navigate({ to: "/issues", search: readIssueListPreferences() });
247 + };
248 const handleSettingsClick = () => {
249 closeMobileSidebar();
250 void navigate({ to: "/settings" });
@@ -278,6 +285,13 @@ const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {
285 onClick={handlePullRequestsClick}
286 />
287 ) : null}
288 + {issuesSupported ? (
289 + <SidebarUtilityItem
290 + icon={<IssueGlyph.issue />}
291 + label="Issues"
292 + onClick={handleIssuesClick}
293 + />
294 + ) : null}
295 <SidebarUtilityItem
296 icon={<ChartNoAxesColumnIcon />}
297 label="Usage"
apps/web/src/components/sidebar/mainAppLocation.ts
+3 -1
@@ -10,7 +10,9 @@ export function isAppModalPage(pathname: string) {
10 }
11
12 export function isSidebarUtilityPage(pathname: string) {
13 - return pathname.startsWith("/projects/") || pathname === "/pull-requests";
13 + return (
14 + pathname.startsWith("/projects/") || pathname === "/pull-requests" || pathname === "/issues"
15 + );
16 }
17
18 // Pages the root route always renders without the app shell, so they are never
apps/web/src/reopenClosedView.ts
+3
@@ -158,6 +158,9 @@ export async function reopenClosedView(
158 case "pull-request":
159 panels.openPullRequest(ref, surface);
160 break;
161 + case "issue":
162 + panels.openIssue(ref, surface);
163 + break;
164 case "side-chat":
165 panels.openSideChat(ref, surface.threadId);
166 break;
apps/web/src/rightPanelStore.ts
+101 -5
@@ -21,6 +21,7 @@ const RIGHT_PANEL_KINDS = [
21 "terminal",
22 "pull-request",
23 "pull-requests",
24 + "issue",
25 "side-chat",
26 ] as const;
27 export type RightPanelKind = (typeof RIGHT_PANEL_KINDS)[number];
@@ -78,17 +79,43 @@ export type RightPanelSurface =
79 detailTab?: PullRequestDetailTab;
80 }
81 | { id: "pull-requests"; kind: "pull-requests" }
82 + /**
83 + * An issue opened in the issues list's shared panel, or beside a thread. Like `pull-request`,
84 + * the reference lives in the id so several issues can stay open as peer tabs.
85 + */
86 + | {
87 + id: `issue:${string}`;
88 + kind: "issue";
89 + environmentId?: string;
90 + projectId: string;
91 + tracker: string;
92 + host?: string;
93 + scope: string;
94 + key: string;
95 + url?: string;
96 + }
97 | { id: `side-chat:${string}`; kind: "side-chat"; threadId: ThreadId };
98
99 const RIGHT_PANEL_STORAGE_KEY = "t3code:right-panel-state:v2";
84 -const RIGHT_PANEL_STORAGE_VERSION = 14;
100 +const RIGHT_PANEL_STORAGE_VERSION = 15;
101
102 export const PULL_REQUESTS_PANEL_REF = scopeThreadRef(
103 EnvironmentId.make("pull-requests-panel"),
104 ThreadId.make("pull-requests-panel"),
105 );
106
91 -const isPullRequestsPanelKey = (threadKey: string) => threadKey.endsWith(":pull-requests-panel");
107 +/** The issues page's shared panel, with the same fixed sentinel ref as the pull-request list. */
108 +export const ISSUES_PANEL_REF = scopeThreadRef(
109 + EnvironmentId.make("issues-panel"),
110 + ThreadId.make("issues-panel"),
111 +);
112 +
113 +/**
114 + * The pull-request and issues lists' shared panels are session
115 + * state: reopening the app should show the list, not last session's tabs and detail fetches.
116 + */
117 +const isPullRequestsPanelKey = (threadKey: string) =>
118 + threadKey.endsWith(":pull-requests-panel") || threadKey.endsWith(":issues-panel");
119
120 export interface ThreadRightPanelState {
121 isOpen: boolean;
@@ -125,7 +152,7 @@ interface RightPanelStoreState {
152 ) => boolean;
153 open: (
154 ref: ScopedThreadRef,
128 - kind: Exclude<RightPanelKind, "file" | "terminal" | "pull-request" | "side-chat">,
155 + kind: Exclude<RightPanelKind, "file" | "terminal" | "pull-request" | "issue" | "side-chat">,
156 ) => void;
157 openSideChat: (ref: ScopedThreadRef, threadId: ThreadId) => void;
158 openDevice: (ref: ScopedThreadRef, target: DeviceTabTarget, automatic?: boolean) => void;
@@ -155,6 +182,7 @@ interface RightPanelStoreState {
182 detailTab?: PullRequestDetailTab;
183 },
184 ) => void;
185 + openIssue: (ref: ScopedThreadRef, target: IssueSurfaceTarget) => void;
186 setPullRequestDetailTab: (
187 ref: ScopedThreadRef,
188 surfaceId: string,
@@ -191,7 +219,7 @@ interface RightPanelStoreState {
219 toggleVisibility: (ref: ScopedThreadRef) => void;
220 toggle: (
221 ref: ScopedThreadRef,
194 - kind: Exclude<RightPanelKind, "file" | "terminal" | "pull-request" | "side-chat">,
222 + kind: Exclude<RightPanelKind, "file" | "terminal" | "pull-request" | "issue" | "side-chat">,
223 ) => void;
224 setThreadPanelOpen: (
225 ref: ScopedThreadRef,
@@ -214,7 +242,10 @@ const DEFAULT_THREAD_PANEL_VISIBILITY: ThreadPanelVisibility = {
242 };
243
244 const singletonSurface = (
217 - kind: Exclude<RightPanelKind, "file" | "preview" | "terminal" | "pull-request" | "side-chat">,
245 + kind: Exclude<
246 + RightPanelKind,
247 + "file" | "preview" | "terminal" | "pull-request" | "issue" | "side-chat"
248 + >,
249 ): RightPanelSurface => {
250 switch (kind) {
251 case "diff":
@@ -277,6 +308,39 @@ export function pullRequestSurfaceId(target: {
308 return `pull-request:${scope}${encodeURIComponent(target.projectId)}:${host}${encodeURIComponent(target.repository)}:${target.number}`;
309 }
310
311 +export type IssueSurface = Extract<RightPanelSurface, { kind: "issue" }>;
312 +
313 +export interface IssueSurfaceTarget {
314 + environmentId?: string;
315 + projectId: string;
316 + tracker: string;
317 + host?: string;
318 + scope: string;
319 + key: string;
320 + url?: string;
321 +}
322 +
323 +function issueSurfaceId(target: Omit<IssueSurfaceTarget, "url">): IssueSurface["id"] {
324 + const environment =
325 + target.environmentId === undefined ? "" : `${encodeURIComponent(target.environmentId)}:`;
326 + const host = target.host === undefined ? "" : `${encodeURIComponent(target.host.toLowerCase())}:`;
327 + return `issue:${environment}${encodeURIComponent(target.projectId)}:${target.tracker}:${host}${encodeURIComponent(target.scope.toLowerCase())}:${encodeURIComponent(target.key)}`;
328 +}
329 +
330 +function issueSurface(target: IssueSurfaceTarget): IssueSurface {
331 + return {
332 + id: issueSurfaceId(target),
333 + kind: "issue",
334 + ...(target.environmentId === undefined ? {} : { environmentId: target.environmentId }),
335 + projectId: target.projectId,
336 + tracker: target.tracker,
337 + ...(typeof target.host === "string" ? { host: target.host.toLowerCase() } : {}),
338 + scope: target.scope,
339 + key: target.key,
340 + ...(typeof target.url === "string" ? { url: target.url } : {}),
341 + };
342 +}
343 +
344 export function pullRequestSurface(target: {
345 environmentId?: string;
346 projectId: string;
@@ -543,6 +607,23 @@ export function migratePersistedRightPanelState(persistedState: unknown): {
607 }),
608 ];
609 }
610 + if (surface.kind === "issue") {
611 + if (
612 + typeof surface.projectId !== "string" ||
613 + typeof surface.tracker !== "string" ||
614 + typeof surface.scope !== "string" ||
615 + typeof surface.key !== "string"
616 + ) {
617 + return [];
618 + }
619 + const { environmentId, ...rest } = surface;
620 + return [
621 + issueSurface({
622 + ...rest,
623 + ...(typeof environmentId === "string" ? { environmentId } : {}),
624 + }),
625 + ];
626 + }
627 if (surface.kind !== "terminal") return [surface];
628 if (
629 !("resourceId" in surface) ||
@@ -778,6 +859,21 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
859 };
860 }),
861 ),
862 + openIssue: (ref, target) =>
863 + set((state) =>
864 + userAction(state, scopedThreadKey(ref), (current) => {
865 + const surface = issueSurface(target);
866 + const next = upsertSurface(current, surface);
867 + return target.url
868 + ? {
869 + ...next,
870 + surfaces: next.surfaces.map((entry) =>
871 + entry.id === surface.id ? surface : entry,
872 + ),
873 + }
874 + : next;
875 + }),
876 + ),
877 setPullRequestDetailTab: (ref, surfaceId, detailTab) =>
878 set((state) => {
879 const threadKey = scopedThreadKey(ref);
apps/web/src/routeTree.gen.ts
+21
@@ -22,6 +22,7 @@ import { Route as ChatUsageRouteImport } from './routes/_chat.usage'
22 import { Route as ChatSettingsRouteImport } from './routes/_chat.settings'
23 import { Route as ChatPullRequestsRouteImport } from './routes/_chat.pull-requests'
24 import { Route as ChatNewRouteImport } from './routes/_chat.new'
25 +import { Route as ChatIssuesRouteImport } from './routes/_chat.issues'
26 import { Route as ThreadsEnvironmentIdThreadIdRouteImport } from './routes/threads.$environmentId.$threadId'
27 import { Route as ChatSettingsWorktreesRouteImport } from './routes/_chat.settings.worktrees'
28 import { Route as ChatSettingsVoiceRouteImport } from './routes/_chat.settings.voice'
@@ -117,6 +118,11 @@ const ChatNewRoute = ChatNewRouteImport.update({
118 path: '/new',
119 getParentRoute: () => ChatRoute,
120 } as any)
121 +const ChatIssuesRoute = ChatIssuesRouteImport.update({
122 + id: '/issues',
123 + path: '/issues',
124 + getParentRoute: () => ChatRoute,
125 +} as any)
126 const ThreadsEnvironmentIdThreadIdRoute =
127 ThreadsEnvironmentIdThreadIdRouteImport.update({
128 id: '/threads/$environmentId/$threadId',
@@ -282,6 +288,7 @@ export interface FileRoutesByFullPath {
288 '/guest': typeof GuestRoute
289 '/pair': typeof PairRoute
290 '/welcome': typeof WelcomeRoute
291 + '/issues': typeof ChatIssuesRoute
292 '/new': typeof ChatNewRoute
293 '/pull-requests': typeof ChatPullRequestsRoute
294 '/settings': typeof ChatSettingsRouteWithChildren
@@ -325,6 +332,7 @@ export interface FileRoutesByTo {
332 '/guest': typeof GuestRoute
333 '/pair': typeof PairRoute
334 '/welcome': typeof WelcomeRoute
335 + '/issues': typeof ChatIssuesRoute
336 '/new': typeof ChatNewRoute
337 '/pull-requests': typeof ChatPullRequestsRoute
338 '/settings': typeof ChatSettingsRouteWithChildren
@@ -371,6 +379,7 @@ export interface FileRoutesById {
379 '/guest': typeof GuestRoute
380 '/pair': typeof PairRoute
381 '/welcome': typeof WelcomeRoute
382 + '/_chat/issues': typeof ChatIssuesRoute
383 '/_chat/new': typeof ChatNewRoute
384 '/_chat/pull-requests': typeof ChatPullRequestsRoute
385 '/_chat/settings': typeof ChatSettingsRouteWithChildren
@@ -418,6 +427,7 @@ export interface FileRouteTypes {
427 | '/guest'
428 | '/pair'
429 | '/welcome'
430 + | '/issues'
431 | '/new'
432 | '/pull-requests'
433 | '/settings'
@@ -461,6 +471,7 @@ export interface FileRouteTypes {
471 | '/guest'
472 | '/pair'
473 | '/welcome'
474 + | '/issues'
475 | '/new'
476 | '/pull-requests'
477 | '/settings'
@@ -506,6 +517,7 @@ export interface FileRouteTypes {
517 | '/guest'
518 | '/pair'
519 | '/welcome'
520 + | '/_chat/issues'
521 | '/_chat/new'
522 | '/_chat/pull-requests'
523 | '/_chat/settings'
@@ -649,6 +661,13 @@ declare module '@tanstack/react-router' {
661 preLoaderRoute: typeof ChatNewRouteImport
662 parentRoute: typeof ChatRoute
663 }
664 + '/_chat/issues': {
665 + id: '/_chat/issues'
666 + path: '/issues'
667 + fullPath: '/issues'
668 + preLoaderRoute: typeof ChatIssuesRouteImport
669 + parentRoute: typeof ChatRoute
670 + }
671 '/threads/$environmentId/$threadId': {
672 id: '/threads/$environmentId/$threadId'
673 path: '/threads/$environmentId/$threadId'
@@ -927,6 +946,7 @@ const ChatSettingsRouteWithChildren = ChatSettingsRoute._addFileChildren(
946 )
947
948 interface ChatRouteChildren {
949 + ChatIssuesRoute: typeof ChatIssuesRoute
950 ChatNewRoute: typeof ChatNewRoute
951 ChatPullRequestsRoute: typeof ChatPullRequestsRoute
952 ChatSettingsRoute: typeof ChatSettingsRouteWithChildren
@@ -937,6 +957,7 @@ interface ChatRouteChildren {
957 }
958
959 const ChatRouteChildren: ChatRouteChildren = {
960 + ChatIssuesRoute: ChatIssuesRoute,
961 ChatNewRoute: ChatNewRoute,
962 ChatPullRequestsRoute: ChatPullRequestsRoute,
963 ChatSettingsRoute: ChatSettingsRouteWithChildren,
apps/web/src/routes/_chat.issues.tsx new
+38
@@ -0,0 +1,38 @@
1 +import type { EnvironmentId, ProjectId } from "@t3tools/contracts";
2 +import { createFileRoute } from "@tanstack/react-router";
3 +
4 +import { IssuesPage, type IssuesSearch } from "../components/issue/IssuesPage";
5 +
6 +// The router reads a bare `key=42` as a number.
7 +const bounded = (value: unknown): string | undefined => {
8 + const text = typeof value === "number" ? String(value) : value;
9 + return typeof text === "string" && text.trim() ? text.trim().slice(0, 200) : undefined;
10 +};
11 +/** A search key that is either present as a string or absent, never present as undefined. */
12 +function present<K extends string, V extends string>(
13 + key: K,
14 + value: string | undefined,
15 +): { [P in K]?: V } {
16 + return value === undefined ? {} : ({ [key]: value } as { [P in K]: V });
17 +}
18 +
19 +export const Route = createFileRoute("/_chat/issues")({
20 + validateSearch: (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 + ...present("host", bounded(raw.host)),
25 + // Always an own key: the router lays this over the parent route's unvalidated search.
26 + q: bounded(raw.q),
27 + ...present<"selectedEnvironmentId", EnvironmentId>(
28 + "selectedEnvironmentId",
29 + bounded(raw.selectedEnvironmentId),
30 + ),
31 + ...present<"selectedProjectId", ProjectId>("selectedProjectId", bounded(raw.selectedProjectId)),
32 + ...present("selectedHost", bounded(raw.selectedHost)),
33 + ...present("tracker", bounded(raw.tracker)),
34 + ...present("scope", bounded(raw.scope)),
35 + ...present("key", bounded(raw.key)),
36 + }),
37 + component: IssuesPage,
38 +});
apps/web/src/state/environments.ts
+4
@@ -113,6 +113,10 @@ export function usePullRequestsSupported() {
113 return useAtomValue(environmentSummaries.pullRequestsSupportedAtom);
114 }
115
116 +export function useIssuesSupported() {
117 + return useAtomValue(environmentSummaries.issuesSupportedAtom);
118 +}
119 +
120 export function useEnvironmentMachines() {
121 return useAtomValue(environmentSummaries.machineByIdAtom);
122 }
apps/web/src/state/issues.ts new
+67
@@ -0,0 +1,67 @@
1 +import { createIssueEnvironmentAtoms } from "@t3tools/client-runtime/state/issues";
2 +import type { EnvironmentId, IssueListInput, IssueListResult } from "@t3tools/contracts";
3 +import { useAtomValue } from "@effect/atom-react";
4 +import * as Option from "effect/Option";
5 +import { AsyncResult, Atom } from "effect/reactivity";
6 +
7 +import { connectionAtomRuntime } from "../connection/runtime";
8 +import { appAtomRegistry } from "../rpc/atomRegistry";
9 +import { formatEnvironmentQueryError } from "./query";
10 +
11 +export const issueEnvironment = createIssueEnvironmentAtoms(connectionAtomRuntime);
12 +
13 +export interface IssueListTarget {
14 + readonly environmentId: EnvironmentId;
15 + readonly input: IssueListInput;
16 +}
17 +
18 +export interface MergedIssueListView {
19 + /** One answer per environment that has one, in target order. */
20 + readonly answers: ReadonlyArray<readonly [EnvironmentId, IssueListResult]>;
21 + /** The first environment that failed outright; the others may still have answered. */
22 + readonly error: string | null;
23 + readonly isPending: boolean;
24 + readonly refresh: () => void;
25 +}
26 +
27 +/**
28 + * The same listing read across every connected environment at once, as the pull-request page
29 + * does: React cannot subscribe to a list of atoms whose length changes, so the fan-out lives in
30 + * one derived atom keyed by the targets. An environment that fails contributes nothing rather
31 + * than blanking the page.
32 + */
33 +const mergedIssueListFamily = Atom.family((key: string) =>
34 + Atom.make((get) => {
35 + const targets = JSON.parse(key) as ReadonlyArray<IssueListTarget>;
36 + const answers: Array<readonly [EnvironmentId, IssueListResult]> = [];
37 + let error: string | null = null;
38 + let isPending = false;
39 + for (const target of targets) {
40 + const result = get(issueEnvironment.list(target));
41 + isPending ||= result.waiting;
42 + if (result._tag === "Failure" && error === null) {
43 + error = formatEnvironmentQueryError(result.cause);
44 + }
45 + const value = Option.getOrNull(AsyncResult.value(result));
46 + if (value !== null) answers.push([target.environmentId, value]);
47 + }
48 + return { answers, error, isPending };
49 + }).pipe(Atom.withLabel(`web-issues:list:${key}`)),
50 +);
51 +
52 +const EMPTY_ISSUE_LIST = Atom.make({
53 + answers: [] as ReadonlyArray<readonly [EnvironmentId, IssueListResult]>,
54 + error: null as string | null,
55 + isPending: false,
56 +}).pipe(Atom.withLabel("web-issues:list:empty"));
57 +
58 +export function useIssueList(targets: ReadonlyArray<IssueListTarget>): MergedIssueListView {
59 + const key = JSON.stringify(targets);
60 + const view = useAtomValue(targets.length === 0 ? EMPTY_ISSUE_LIST : mergedIssueListFamily(key));
61 + const refresh = () => {
62 + for (const target of JSON.parse(key) as ReadonlyArray<IssueListTarget>) {
63 + appAtomRegistry.refresh(issueEnvironment.list(target));
64 + }
65 + };
66 + return { ...view, refresh };
67 +}
docs/user/source-control.md
+16
@@ -350,6 +350,22 @@ conflicts, and a watched thread never auto-settles.
350 Cross-repository links use a project on the same host. Azure DevOps reviews require a project checked
351 out from the matching organization and repository.
352
353 +## Issues
354 +
355 +The Issues page lists the issues of every project whose remote is on a supported tracker
356 +(GitHub today), grouped per tracker account. Open it from the sidebar's utility row or with
357 +**Open issues** in the command palette. Filter by open or closed, by your involvement
358 +(assigned, opened by you, mentioning you), and by tracker; the search box asks the tracker
359 +itself where it can search. Press **Load more** at the end of a group to read further back.
360 +
361 +Select an issue to open it beside the list: description, comments, state changes, linked pull
362 +requests, labels, assignees, and reactions. Linked pull requests open in the same panel. You can
363 +comment, edit the title and description, change labels and assignees, react, and close or
364 +reopen (with a close reason where the tracker records one) when the tracker and your account
365 +allow it. An issue read through a project that does not own its repository is shown read-only.
366 +
367 +Writing to a tracker over a remote connection requires the `source-control:write` scope.
368 +
369 ## GitHub stacks
370
371 The Pull requests page shows each PR's position in its GitHub stack. Open the stack badge in a
packages/client-runtime/package.json
+8
@@ -279,6 +279,10 @@
279 "types": "./src/state/providerInstanceDisplay.ts",
280 "default": "./src/state/providerInstanceDisplay.ts"
281 },
282 + "./state/issues": {
283 + "types": "./src/state/issues.ts",
284 + "default": "./src/state/issues.ts"
285 + },
286 "./state/pull-requests": {
287 "types": "./src/state/pullRequests.ts",
288 "default": "./src/state/pullRequests.ts"
@@ -567,6 +571,10 @@
571 "types": "./src/pullRequestReviewers.ts",
572 "default": "./src/pullRequestReviewers.ts"
573 },
574 + "./issue-selection": {
575 + "types": "./src/issueSelection.ts",
576 + "default": "./src/issueSelection.ts"
577 + },
578 "./pull-request-selection": {
579 "types": "./src/pullRequestSelection.ts",
580 "default": "./src/pullRequestSelection.ts"
packages/client-runtime/src/issueSelection.test.ts new
+75
@@ -0,0 +1,75 @@
1 +import { describe, expect, it } from "@effect/vitest";
2 +
3 +import {
4 + issueAssigneesAfterPicks,
5 + issueLabelsAfterPicks,
6 + issuePicksFor,
7 + issueWriteAfterPicks,
8 + noIssuePicks,
9 + type IssuePicks,
10 +} from "./issueSelection.ts";
11 +import { emptySelection, toggleSelection } from "./pullRequestSelection.ts";
12 +
13 +const label = (name: string) => ({ name, color: null, description: null });
14 +const person = (login: string, id: string) => ({ login, id, name: null, avatarUrl: null });
15 +
16 +describe("issue picker picks", () => {
17 + it("writes the whole label set once, and nothing when the picks cancel out", () => {
18 + const detail = { labels: [label("bug"), label("ui")] };
19 + let draft = emptySelection<ReturnType<typeof label>>();
20 + draft = toggleSelection(draft, "docs", label("docs"), false);
21 + draft = toggleSelection(draft, "bug", label("bug"), true);
22 + expect(issueLabelsAfterPicks(detail, draft)).toEqual(["ui", "docs"]);
23 + draft = toggleSelection(draft, "docs", label("docs"), false);
24 + draft = toggleSelection(draft, "bug", label("bug"), true);
25 + expect(issueLabelsAfterPicks(detail, draft)).toBeNull();
26 + });
27 +
28 + it("keeps assignees by login and adds new ones by the tracker's id", () => {
29 + const detail = { assignees: [person("Julius", "u1"), person("theo", "u2")] };
30 + let draft = emptySelection<ReturnType<typeof person>>();
31 + draft = toggleSelection(draft, "u1", person("julius", "u1"), true);
32 + draft = toggleSelection(draft, "u3", person("mark", "u3"), false);
33 + expect(issueAssigneesAfterPicks(detail, draft)).toEqual(["theo", "u3"]);
34 + });
35 +
36 + it("builds a second write on the first while the detail has not caught up", () => {
37 + type Label = ReturnType<typeof label>;
38 + const stale = { labels: [label("bug")] };
39 + const names = (detail: typeof stale) => detail.labels.map((entry) => entry.name);
40 + const pick = (picks: IssuePicks<Label>, detail: typeof stale, name: string) => {
41 + const current = issuePicksFor(picks, detail, true);
42 + const held = names(detail).includes(name);
43 + return { ...current, draft: toggleSelection(current.draft, name, label(name), held) };
44 + };
45 + const close = (picks: IssuePicks<Label>, detail: typeof stale) => {
46 + const current = issuePicksFor(picks, detail, true);
47 + const write = issueWriteAfterPicks(
48 + issueLabelsAfterPicks(detail, current.draft),
49 + names(detail),
50 + current.written,
51 + );
52 + return { write, picks: write === null ? current : { ...current, written: write } };
53 + };
54 +
55 + const first = close(pick(noIssuePicks<Label>(), stale, "docs"), stale);
56 + expect(first.write).toEqual(["bug", "docs"]);
57 + // Reopened before the refreshed detail arrives: the second pick keeps the first.
58 + const second = close(pick(first.picks, stale, "ui"), stale);
59 + expect(second.write).toEqual(["bug", "docs", "ui"]);
60 + expect(close(second.picks, stale).write).toBeNull();
61 + // Taking both back writes the set the stale detail still shows.
62 + const undone = close(pick(pick(second.picks, stale, "docs"), stale, "ui"), stale);
63 + expect(undone.write).toEqual(["bug"]);
64 +
65 + const fresh = { labels: [label("bug"), label("docs"), label("ui")] };
66 + expect(issuePicksFor(second.picks, fresh, false).draft.size).toBe(0);
67 + // A picker still open over the refresh keeps its picks, which the fresh detail now confirms.
68 + expect(close(pick(second.picks, fresh, "p1"), fresh).write).toEqual([
69 + "bug",
70 + "docs",
71 + "ui",
72 + "p1",
73 + ]);
74 + });
75 +});
packages/client-runtime/src/issueSelection.ts new
+80
@@ -0,0 +1,80 @@
1 +import type { IssueAssigneeCandidate, IssueDetail, IssueLabelCandidate } from "@t3tools/contracts";
2 +
3 +import { selectionChanges, type SelectionDraft } from "./pullRequestSelection.ts";
4 +
5 +type Labelled = Pick<IssueDetail, "labels">;
6 +type Assigned = Pick<IssueDetail, "assignees">;
7 +
8 +/**
9 + * An issue write replaces the whole set, so a picker's picks become one write when it closes.
10 + * Both return null when the picks leave the issue as the tracker already has it.
11 + */
12 +export function issueLabelsAfterPicks(
13 + detail: Labelled,
14 + draft: SelectionDraft<IssueLabelCandidate>,
15 +): ReadonlyArray<string> | null {
16 + const names = detail.labels.map((label) => label.name);
17 + const { add, remove } = selectionChanges(draft, (name) => names.includes(name));
18 + if (add.length + remove.length === 0) return null;
19 + const removed = new Set(remove.map((label) => label.name));
20 + return [...names.filter((name) => !removed.has(name)), ...add.map((label) => label.name)];
21 +}
22 +
23 +export const issueAssigneeHeld = (detail: Assigned, candidate: IssueAssigneeCandidate) =>
24 + detail.assignees.some((actor) => actor.login.toLowerCase() === candidate.login.toLowerCase());
25 +
26 +/** People already assigned are written by login, the newly picked by the tracker's own id. */
27 +export function issueAssigneesAfterPicks(
28 + detail: Assigned,
29 + draft: SelectionDraft<IssueAssigneeCandidate>,
30 +): ReadonlyArray<string> | null {
31 + const { add, remove } = selectionChanges(draft, (_, candidate) =>
32 + issueAssigneeHeld(detail, candidate),
33 + );
34 + if (add.length + remove.length === 0) return null;
35 + const removed = new Set(remove.map((candidate) => candidate.login.toLowerCase()));
36 + return [
37 + ...detail.assignees
38 + .map((actor) => actor.login)
39 + .filter((login) => !removed.has(login.toLowerCase())),
40 + ...add.map((candidate) => candidate.id),
41 + ];
42 +}
43 +
44 +/** A picker's picks, the read of the issue they were made against, and the set they last wrote. */
45 +export interface IssuePicks<T> {
46 + readonly basis: object | null;
47 + readonly draft: SelectionDraft<T>;
48 + readonly written: ReadonlyArray<string> | null;
49 +}
50 +
51 +export function noIssuePicks<T>(): IssuePicks<T> {
52 + return { basis: null, draft: new Map(), written: null };
53 +}
54 +
55 +/**
56 + * The picks that count against `detail`. A write replaces the whole set and the detail only
57 + * catches up once it is re-read, so picks outlive their write until then: a picker reopened in
58 + * between builds on them instead of on the stale set. A newer read forgets them, except in an
59 + * open picker, whose picks are diffed against that read when it closes.
60 + */
61 +export function issuePicksFor<T>(
62 + picks: IssuePicks<T>,
63 + detail: object,
64 + open: boolean,
65 +): IssuePicks<T> {
66 + if (picks.basis === detail) return picks;
67 + return { basis: detail, draft: open ? picks.draft : new Map(), written: null };
68 +}
69 +
70 +/** The set a closing picker writes: null when the tracker has it or was already sent it. */
71 +export function issueWriteAfterPicks(
72 + after: ReadonlyArray<string> | null,
73 + held: ReadonlyArray<string>,
74 + written: ReadonlyArray<string> | null,
75 +): ReadonlyArray<string> | null {
76 + const target = after ?? held;
77 + const sent = written ?? held;
78 + const same = target.length === sent.length && target.every((value) => sent.includes(value));
79 + return same ? null : target;
80 +}
packages/client-runtime/src/state/issues.test.ts new
+92
@@ -0,0 +1,92 @@
1 +import type { IssueComment, IssueListEntry, IssueTrackerKind, ProjectId } from "@t3tools/contracts";
2 +import { describe, expect, it } from "vite-plus/test";
3 +
4 +import {
5 + issueEntryKey,
6 + mergeIssueListErrors,
7 + mergeIssueListPage,
8 + prependIssueComments,
9 +} from "./issues.ts";
10 +
11 +function entry(overrides: Partial<IssueListEntry> & { key: string }): IssueListEntry {
12 + return {
13 + tracker: "github" as IssueTrackerKind,
14 + host: "github.com",
15 + scope: "acme/app",
16 + displayKey: `#${overrides.key}`,
17 + title: `Issue ${overrides.key}`,
18 + url: `https://github.com/acme/app/issues/${overrides.key}`,
19 + author: null,
20 + state: { category: "open", name: "open" },
21 + createdAt: "2026-10-01T00:00:00.000Z",
22 + updatedAt: "2026-10-01T00:00:00.000Z",
23 + closedAt: null,
24 + assignees: [],
25 + labels: [],
26 + commentCount: 0,
27 + projectId: "project-1" as ProjectId,
28 + projectTitle: "App",
29 + ...overrides,
30 + };
31 +}
32 +
33 +describe("mergeIssueListErrors", () => {
34 + it("keeps earlier failures and lets a continuation's replace its project's", () => {
35 + const api = "api" as ProjectId;
36 + const web = "web" as ProjectId;
37 + const held = [
38 + { projectId: api, projectTitle: "api", message: "boom" },
39 + { projectId: web, projectTitle: "web", message: "first" },
40 + ];
41 + const page = [{ projectId: web, projectTitle: "web", message: "rate limited" }];
42 + expect(mergeIssueListErrors(held, page).map((error) => error.message)).toEqual([
43 + "boom",
44 + "rate limited",
45 + ]);
46 + });
47 +});
48 +
49 +describe("mergeIssueListPage", () => {
50 + it("keeps rows from scopes the page did not continue and orders by update", () => {
51 + const held = [
52 + entry({ key: "1", updatedAt: "2026-10-03T00:00:00.000Z" }),
53 + entry({ key: "9", scope: "acme/other", updatedAt: "2026-10-02T00:00:00.000Z" }),
54 + ];
55 + const page = [entry({ key: "2", updatedAt: "2026-10-04T00:00:00.000Z" })];
56 + expect(mergeIssueListPage(held, page).map((row) => row.key)).toEqual(["2", "1", "9"]);
57 + });
58 +
59 + it("replaces a repeated row with the page's newer words", () => {
60 + const held = [entry({ key: "1", title: "Old title" })];
61 + const page = [
62 + entry({ key: "1", title: "New title", state: { category: "closed", name: "closed" } }),
63 + ];
64 + const merged = mergeIssueListPage(held, page);
65 + expect(merged).toHaveLength(1);
66 + expect(merged[0]?.title).toBe("New title");
67 + expect(merged[0]?.state.category).toBe("closed");
68 + });
69 +
70 + it("keys rows case-insensitively by host and scope, exactly by key", () => {
71 + expect(issueEntryKey(entry({ key: "1", host: "GitHub.com", scope: "Acme/App" }))).toBe(
72 + issueEntryKey(entry({ key: "1" })),
73 + );
74 + expect(issueEntryKey(entry({ key: "ENG-1" }))).not.toBe(issueEntryKey(entry({ key: "eng-1" })));
75 + });
76 +});
77 +
78 +describe("prependIssueComments", () => {
79 + const comment = (id: string): IssueComment => ({
80 + id,
81 + author: null,
82 + body: id,
83 + createdAt: "2026-10-01T00:00:00.000Z",
84 + url: null,
85 + });
86 +
87 + it("puts older comments first and drops ones already shown", () => {
88 + const current = [comment("c3"), comment("c4")];
89 + const older = [comment("c1"), comment("c2"), comment("c3")];
90 + expect(prependIssueComments(current, older).map((c) => c.id)).toEqual(["c1", "c2", "c3", "c4"]);
91 + });
92 +});
packages/client-runtime/src/state/issues.ts new
+175
@@ -0,0 +1,175 @@
1 +import {
2 + WS_METHODS,
3 + type EnvironmentId,
4 + type IssueComment,
5 + type IssueListEntry,
6 + type IssueListProjectError,
7 + type IssueListResult,
8 + type IssueRef,
9 +} from "@t3tools/contracts";
10 +import * as Effect from "effect/Effect";
11 +import { Atom, type AtomRegistry } from "effect/reactivity";
12 +
13 +import {
14 + createAtomCommandScheduler,
15 + createEnvironmentRpcCommand,
16 + createEnvironmentRpcQueryAtomFamily,
17 +} from "./runtime.ts";
18 +import type { EnvironmentRegistry } from "../connection/registry.ts";
19 +
20 +/** One row's identity across list pages and detail reads; hosts compare case-insensitively. */
21 +export function issueEntryKey(
22 + entry: Pick<IssueListEntry, "projectId" | "host" | "scope" | "key">,
23 +): string {
24 + return `${entry.projectId}\u0000${entry.host.toLowerCase()}\u0000${entry.scope.toLowerCase()}\u0000${entry.key}`;
25 +}
26 +
27 +/**
28 + * Lay a continuation page over the rows already held. A page only covers the scopes it was asked
29 + * to continue, so rows from other scopes stay; a row the page repeats replaces the held one, so a
30 + * title or state that moved between reads shows the newer words. Order stays newest-updated first,
31 + * which is how every tracker hands them over.
32 + */
33 +export function mergeIssueListPage(
34 + held: ReadonlyArray<IssueListEntry>,
35 + page: ReadonlyArray<IssueListEntry>,
36 +): ReadonlyArray<IssueListEntry> {
37 + if (held.length === 0) return page;
38 + if (page.length === 0) return held;
39 + const byKey = new Map<string, IssueListEntry>();
40 + for (const entry of held) byKey.set(issueEntryKey(entry), entry);
41 + for (const entry of page) byKey.set(issueEntryKey(entry), entry);
42 + return [...byKey.values()].sort((a, b) => Date.parse(b.updatedAt) - Date.parse(a.updatedAt));
43 +}
44 +
45 +/** A continuation's failures for a project replace the ones it reported before. */
46 +export function mergeIssueListErrors(
47 + held: ReadonlyArray<IssueListProjectError>,
48 + page: ReadonlyArray<IssueListProjectError>,
49 +): ReadonlyArray<IssueListProjectError> {
50 + if (page.length === 0) return held;
51 + const replaced = new Set(page.map((error) => error.projectId));
52 + return [...held.filter((error) => !replaced.has(error.projectId)), ...page];
53 +}
54 +
55 +/** Older comments go in front: the detail carries the newest page and pages walk backwards. */
56 +export function prependIssueComments(
57 + current: ReadonlyArray<IssueComment>,
58 + older: ReadonlyArray<IssueComment>,
59 +): ReadonlyArray<IssueComment> {
60 + if (older.length === 0) return current;
61 + const seen = new Set(current.map((comment) => comment.id));
62 + return [...older.filter((comment) => !seen.has(comment.id)), ...current];
63 +}
64 +
65 +/**
66 + * Every read goes to a tracker API over the environment, so results are reused for a short while
67 + * and refreshed explicitly. Mutations run serially per environment: changes to one issue are
68 + * order-sensitive. Each confirmed write refreshes the detail it touched; the list is refreshed by
69 + * the page, which knows which listings it is showing.
70 + */
71 +export function createIssueEnvironmentAtoms<R, E>(
72 + runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>,
73 +) {
74 + const commandScheduler = createAtomCommandScheduler();
75 + const serialPerEnvironment = {
76 + mode: "serial",
77 + key: ({ environmentId }: { readonly environmentId: string }) => environmentId,
78 + } as const;
79 + const detail = createEnvironmentRpcQueryAtomFamily(runtime, {
80 + label: "environment-data:issues:detail",
81 + tag: WS_METHODS.issuesDetail,
82 + staleTimeMs: 30_000,
83 + });
84 + const detailRef = ({ projectId, tracker, host, scope, key }: IssueRef): IssueRef => ({
85 + projectId,
86 + tracker,
87 + ...(host === undefined ? {} : { host }),
88 + scope,
89 + key,
90 + });
91 + const refreshDetail = (
92 + { environmentId, input }: { readonly environmentId: EnvironmentId; readonly input: IssueRef },
93 + registry: AtomRegistry.AtomRegistry,
94 + ) => Effect.sync(() => registry.refresh(detail({ environmentId, input: detailRef(input) })));
95 + return {
96 + list: createEnvironmentRpcQueryAtomFamily(runtime, {
97 + label: "environment-data:issues:list",
98 + tag: WS_METHODS.issuesList,
99 + staleTimeMs: 30_000,
100 + }),
101 + /**
102 + * A continuation of the listing, run as a command rather than read as a query: a page is
103 + * asked for once and laid over the rows held, and a refresh of the first page forgets it.
104 + */
105 + listPage: createEnvironmentRpcCommand(runtime, {
106 + label: "environment-data:issues:list-page",
107 + tag: WS_METHODS.issuesList,
108 + scheduler: commandScheduler,
109 + concurrency: {
110 + mode: "singleFlight",
111 + key: ({ environmentId, input }) => JSON.stringify([environmentId, input]),
112 + },
113 + }),
114 + detail,
115 + /** Older comments past the cursor the detail handed over; the panel prepends what arrives. */
116 + comments: createEnvironmentRpcCommand(runtime, {
117 + label: "environment-data:issues:comments",
118 + tag: WS_METHODS.issuesComments,
119 + scheduler: commandScheduler,
120 + concurrency: {
121 + mode: "singleFlight",
122 + key: ({ environmentId, input }) =>
123 + JSON.stringify([environmentId, input.projectId, input.scope, input.key, input.cursor]),
124 + },
125 + }),
126 + /** Read when the composer opens: what a scope offers a new issue changes with a commit. */
127 + templates: createEnvironmentRpcQueryAtomFamily(runtime, {
128 + label: "environment-data:issues:templates",
129 + tag: WS_METHODS.issuesTemplates,
130 + staleTimeMs: 5 * 60_000,
131 + }),
132 + /** Read when a label or assignee picker opens, not with every issue. */
133 + candidates: createEnvironmentRpcQueryAtomFamily(runtime, {
134 + label: "environment-data:issues:candidates",
135 + tag: WS_METHODS.issuesCandidates,
136 + staleTimeMs: 60_000,
137 + }),
138 + create: createEnvironmentRpcCommand(runtime, {
139 + label: "environment-data:issues:create",
140 + tag: WS_METHODS.issuesCreate,
141 + scheduler: commandScheduler,
142 + concurrency: serialPerEnvironment,
143 + }),
144 + comment: createEnvironmentRpcCommand(runtime, {
145 + label: "environment-data:issues:comment",
146 + tag: WS_METHODS.issuesComment,
147 + scheduler: commandScheduler,
148 + concurrency: serialPerEnvironment,
149 + onSuccess: refreshDetail,
150 + }),
151 + update: createEnvironmentRpcCommand(runtime, {
152 + label: "environment-data:issues:update",
153 + tag: WS_METHODS.issuesUpdate,
154 + scheduler: commandScheduler,
155 + concurrency: serialPerEnvironment,
156 + onSuccess: refreshDetail,
157 + }),
158 + setState: createEnvironmentRpcCommand(runtime, {
159 + label: "environment-data:issues:set-state",
160 + tag: WS_METHODS.issuesSetState,
161 + scheduler: commandScheduler,
162 + concurrency: serialPerEnvironment,
163 + onSuccess: refreshDetail,
164 + }),
165 + react: createEnvironmentRpcCommand(runtime, {
166 + label: "environment-data:issues:react",
167 + tag: WS_METHODS.issuesReact,
168 + scheduler: commandScheduler,
169 + concurrency: serialPerEnvironment,
170 + onSuccess: refreshDetail,
171 + }),
172 + };
173 +}
174 +
175 +export type IssueListAnswer = IssueListResult;
packages/client-runtime/src/state/presentation.ts
+8
@@ -328,6 +328,13 @@ export function createEnvironmentSummaryAtoms(input: {
328 (get(input.presentationAtom(environmentId))?.serverConfig ?? null) !== null,
329 ),
330 );
331 + const issuesSupportedAtom = Atom.make((get) =>
332 + get(environmentIdsAtom).some(
333 + (environmentId) =>
334 + get(input.presentationAtom(environmentId))?.serverConfig?.environment.capabilities
335 + .issues === true,
336 + ),
337 + );
338 return {
339 environmentIdsAtom,
340 connectedEnvironmentIdsAtom,
@@ -335,5 +342,6 @@ export function createEnvironmentSummaryAtoms(input: {
342 environmentsAtom,
343 machineByIdAtom,
344 pullRequestsSupportedAtom,
345 + issuesSupportedAtom,
346 };
347 }
packages/contracts/src/environment.ts
+1
@@ -95,6 +95,7 @@ export const ExecutionEnvironmentCapabilities = Schema.Struct({
95 ),
96 pullRequests: Schema.optionalKey(Schema.Boolean),
97 pullRequestChecks: Schema.optionalKey(Schema.Boolean),
98 + issues: Schema.optionalKey(Schema.Boolean),
99 /** Side chats: hidden `lineage.sideChat` forks. Older servers ignore the fork flag. */
100 sideChats: Schema.optionalKey(Schema.Boolean),
101 vcsBranchStatus: Schema.optionalKey(Schema.Boolean),
packages/contracts/src/issue.ts
+9 -18
@@ -9,7 +9,13 @@ import {
9 ProjectId,
10 TrimmedNonEmptyString,
11 } from "./baseSchemas.ts";
12 -import { PullRequestActor, PullRequestLabel, PullRequestState } from "./pullRequest.ts";
12 +import {
13 + PullRequestActor,
14 + PullRequestLabel,
15 + PullRequestReaction,
16 + PullRequestReactionContent,
17 + PullRequestState,
18 +} from "./pullRequest.ts";
19
20 /**
21 * Which tracker an issue lives in. Git hosts reuse their `SourceControlProviderKind` spelling
@@ -53,25 +59,10 @@ export type IssueListState = typeof IssueListState.Type;
59 export const IssueInvolvement = Schema.Literals(["all", "assigned", "authored", "mentioned"]);
60 export type IssueInvolvement = typeof IssueInvolvement.Type;
61
56 -export const IssueReactionContent = Schema.Literals([
57 - "thumbs-up",
58 - "thumbs-down",
59 - "laugh",
60 - "hooray",
61 - "confused",
62 - "heart",
63 - "rocket",
64 - "eyes",
65 -]);
62 +export const IssueReactionContent = PullRequestReactionContent;
63 export type IssueReactionContent = typeof IssueReactionContent.Type;
64
68 -export const IssueReaction = Schema.Struct({
69 - content: IssueReactionContent,
70 - count: PositiveInt,
71 - /** Who reacted, as far as the tracker named them; the viewer is left out and shown as "You". */
72 - actors: Schema.Array(TrimmedNonEmptyString),
73 - viewerHasReacted: Schema.Boolean,
74 -});
65 +export const IssueReaction = PullRequestReaction;
66 export type IssueReaction = typeof IssueReaction.Type;
67
68 /**