Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/server/src/environment/ServerEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export const make = Effect.gen(function* () {
fileAttachments: { maxUploadBytes: PROVIDER_SEND_TURN_MAX_FILE_BYTES },
pullRequests: true,
pullRequestChecks: true,
issues: true,
linkedThreadRefreshes: true,
sideChats: true,
vcsBranchStatus: true,
Expand Down
10 changes: 10 additions & 0 deletions apps/web/src/closedViewStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ const isClosedViewEntry = (entry: unknown): entry is ClosedViewEntry => {
(surface.host === undefined || typeof surface.host === "string") &&
(surface.url === undefined || typeof surface.url === "string")
);
case "issue":
return (
typeof surface.projectId === "string" &&
typeof surface.tracker === "string" &&
typeof surface.scope === "string" &&
typeof surface.key === "string" &&
(surface.environmentId === undefined || typeof surface.environmentId === "string") &&
(surface.host === undefined || typeof surface.host === "string") &&
(surface.url === undefined || typeof surface.url === "string")
);
default:
return false;
}
Expand Down
19 changes: 19 additions & 0 deletions apps/web/src/components/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ import { pickableProjectGroups } from "@t3tools/client-runtime/state/project-gro
import { buildSidebarProjectPickerEntries } from "../sidebarProjectGrouping";
import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
import { readPullRequestListPreferences } from "~/components/pullRequest/pullRequestListPreferences";
import { readIssueListPreferences } from "~/components/issue/issueListPreferences";
import { IssueGlyph } from "~/components/issue/issuePresentation";
import { useThreadRouteTarget } from "../hooks/useThreadRouteTarget";
import { threadRecentUse } from "@t3tools/shared/paletteSearch";

Expand Down Expand Up @@ -1654,6 +1656,23 @@ function OpenCommandPaletteDialog(props: {
});
}

if (
environments.some(
(environment) => environment.serverConfig?.environment.capabilities.issues === true,
)
) {
actionItems.push({
kind: "action",
value: "action:issues",
searchTerms: ["issues", "issue", "bugs", "tracker", "github", "triage"],
title: "Open issues",
icon: <IssueGlyph.issue className={ITEM_ICON_CLASS} />,
run: async () => {
await navigate({ to: "/issues", search: readIssueListPreferences() });
},
});
}

actionItems.push({
kind: "action",
value: "action:use-in-another-app",
Expand Down
11 changes: 9 additions & 2 deletions apps/web/src/components/ReopenClosedViewShortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
reopenClosedView,
} from "../reopenClosedView";
import {
ISSUES_PANEL_REF,
PULL_REQUESTS_PANEL_REF,
selectActiveRightPanel,
selectSelectedRightPanelSurface,
Expand All @@ -42,6 +43,7 @@ import {
resolveThreadRouteTarget,
} from "../threadRoutes";
import { toastManager } from "./ui/toast";
import { readIssueListPreferences } from "./issue/issueListPreferences";

const PREVIEW_FORWARDED_COMMANDS = [
"workspace.focusNext",
Expand All @@ -58,6 +60,8 @@ const PREVIEW_FORWARDED_COMMANDS = [

const isGlobalPullRequests = (ref: ScopedThreadRef) =>
scopedThreadKey(ref) === scopedThreadKey(PULL_REQUESTS_PANEL_REF);
const isGlobalIssues = (ref: ScopedThreadRef) =>
scopedThreadKey(ref) === scopedThreadKey(ISSUES_PANEL_REF);

export function ReopenClosedViewShortcut() {
const navigate = useNavigate();
Expand Down Expand Up @@ -91,7 +95,7 @@ export function ReopenClosedViewShortcut() {
const { drop, restore } = planNextReopen(useClosedViewStore.getState().entries, (entry) => {
const ref = entry.threadRef;
const panel = selectThreadRightPanelState(panelsByThread, ref);
if (isGlobalPullRequests(ref)) {
if (isGlobalPullRequests(ref) || isGlobalIssues(ref)) {
return {
environmentKnown: true,
catalogReady: true,
Expand Down Expand Up @@ -119,7 +123,8 @@ export function ReopenClosedViewShortcut() {

const ref = restore.threadRef;
const globalPullRequests = isGlobalPullRequests(ref);
const thread = globalPullRequests ? null : readThreadShell(ref);
const globalIssues = isGlobalIssues(ref);
const thread = globalPullRequests || globalIssues ? null : readThreadShell(ref);
const owner = thread ?? drafts.getDraftThreadByRef(ref);
const project = owner ? readProject(scopeProjectRef(ref.environmentId, owner.projectId)) : null;
if (!(await reopenClosedView(restore, { openPreview, workspaceAvailable: project !== null }))) {
Expand All @@ -136,6 +141,8 @@ export function ReopenClosedViewShortcut() {
to: "/pull-requests",
search: (previous) => pullRequestsSearchForRestore(previous, selected),
});
} else if (globalIssues) {
await navigate({ to: "/issues", search: readIssueListPreferences() });
} else {
const draftId = thread === null ? drafts.getDraftIdByRef(ref) : null;
if (draftId !== null)
Expand Down
44 changes: 44 additions & 0 deletions apps/web/src/components/RightPanelTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import type {
ContextMenuItem,
EnvironmentId,
IssueTrackerKind,
PreviewSessionSnapshot,
ProjectId,
PullRequestState,
Expand All @@ -36,6 +37,7 @@ import { restrictToFirstScrollableAncestor, restrictToHorizontalAxis } from "@dn
import { horizontalListSortingStrategy, SortableContext, useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import {
CircleDotIcon,
Smartphone,
ChevronDown,
ChevronLeft,
Expand Down Expand Up @@ -64,6 +66,8 @@ import { isElectron } from "~/env";
import type { DesktopPreviewOverlay } from "~/previewStateStore";
import type { RightPanelSurface } from "~/rightPanelStore";
import { cn } from "~/lib/utils";
import { issueStatePresentation } from "~/components/issue/issuePresentation";
import { issueEnvironment } from "~/state/issues";
import { resolveShortcutCommand, type ShortcutMatchContext } from "~/keybindings";
import { readLocalApi } from "~/localApi";
import { useStableCallback } from "~/hooks/useStableCallback";
Expand Down Expand Up @@ -592,6 +596,9 @@ function surfaceTitle(
return `#${surface.number}`;
case "pull-requests":
return "Pull requests";
case "issue":
// A git host numbers its issues; a tracker with keys of its own, such as Linear, names them.
return /^\d+$/.test(surface.key) ? `#${surface.key}` : surface.key;
case "device":
return surface.title ?? surface.target?.name ?? "Device";
case "side-chat":
Expand Down Expand Up @@ -684,6 +691,8 @@ function SurfaceIcon({
);
case "pull-requests":
return <PullRequestGlyph.link className="size-3 shrink-0" />;
case "issue":
return <IssueSurfaceIcon surface={surface} environmentId={environmentId} />;
case "side-chat":
return <SideChatTabIcon environmentId={environmentId} threadId={surface.threadId} />;
case "device":
Expand Down Expand Up @@ -756,6 +765,41 @@ export function resolvePullRequestTabLink(
return newest;
}

/** The issue's own state mark, from the detail its panel already reads; a plain dot until then. */
function IssueSurfaceIcon({
surface,
environmentId,
}: {
surface: Extract<RightPanelSurface, { kind: "issue" }>;
environmentId: EnvironmentId | null;
}) {
const resolvedEnvironmentId =
(surface.environmentId as EnvironmentId | undefined) ?? environmentId;
const detail = useEnvironmentQuery(
resolvedEnvironmentId === null
? null
: issueEnvironment.detail({
environmentId: resolvedEnvironmentId,
input: {
projectId: surface.projectId as ProjectId,
tracker: surface.tracker as IssueTrackerKind,
...(surface.host ? { host: surface.host } : {}),
scope: surface.scope,
key: surface.key,
},
}),
).data;
if (detail === null) return <CircleDotIcon className="size-3 shrink-0" />;
const presentation = issueStatePresentation(detail.state);
return (
<presentation.Icon
role="img"
aria-label={presentation.label}
className={cn("size-3 shrink-0", presentation.toneClassName)}
/>
);
}

function PullRequestSurfaceIcon({
surface,
environmentId,
Expand Down
110 changes: 110 additions & 0 deletions apps/web/src/components/issue/IssueCommentComposer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import type { EnvironmentId, IssueRef } from "@t3tools/contracts";
import { ArrowUpIcon } from "lucide-react";
import { useRef, useState } from "react";

import { TextFieldSpeechControls, useTextFieldSpeech } from "~/speech/useTextFieldSpeech";
import { issueEnvironment } from "~/state/issues";
import { useAtomCommand } from "~/state/use-atom-command";

import { ComposerSurface } from "../chat/ComposerSurface";
import { readableFailure } from "../pullRequest/pullRequestDetail.logic";
import { Spinner } from "../ui/spinner";
import { toastManager } from "../ui/toast";

/** The thread composer's card, floating over the issue's timeline, with a comment as its message. */
export function IssueCommentComposer({
environmentId,
reference,
blocked,
}: {
environmentId: EnvironmentId;
reference: IssueRef;
/** Why the viewer cannot comment here; null when they can. */
blocked: string | null;
}) {
const [body, setBody] = useState("");
const [submitting, setSubmitting] = useState(false);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const comment = useAtomCommand(issueEnvironment.comment, { reportFailure: false });
const locked = blocked !== null || submitting;
const speech = useTextFieldSpeech({
environmentId,
projectId: reference.projectId,
ownerKey: JSON.stringify(["issue-comment", environmentId, reference]),
text: body,
textareaRef,
onTextChange: setBody,
disabled: locked,
});

const submit = async (text: string) => {
if (text.trim().length === 0 || locked) return;
setSubmitting(true);
const result = await comment({ environmentId, input: { ...reference, body: text } });
setSubmitting(false);
if (result._tag === "Failure") {
toastManager.add({
type: "error",
title: "The comment could not be posted",
description: readableFailure(squashAtomCommandFailure(result), "The tracker refused it."),
});
return;
}
setBody("");
};
const submitAfterDictation = () => speech.submitAfterDictation((text) => void submit(text));
const submitDisabled =
speech.preparing || (body.trim().length === 0 && !speech.blocksSubmission) || locked;

return (
<div className="pointer-events-none absolute inset-x-0 bottom-0 z-10 px-3 pb-3">
<ComposerSurface.Shell className="pointer-events-auto">
<ComposerSurface.Host>
<form
className="relative z-10 flex flex-col"
onSubmit={(event) => {
event.preventDefault();
submitAfterDictation();
}}
>
<textarea
ref={textareaRef}
rows={2}
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"
aria-label="Add a comment"
placeholder={blocked ?? "Leave a comment"}
value={body}
// Lock while posting because success clears the draft.
disabled={locked}
readOnly={speech.freezesEditor}
onChange={(event) => setBody(event.target.value)}
onKeyDown={(event) => {
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
if (event.key === "Enter" && (event.metaKey || event.ctrlKey) && !event.shiftKey) {
event.preventDefault();
if (!event.repeat) submitAfterDictation();
}
}}
/>
<div className="flex flex-wrap items-center justify-end gap-2 px-2.5 pb-2.5">
<TextFieldSpeechControls speech={speech} disabled={locked} />
<button
type="submit"
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"
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved
disabled={submitDisabled}
aria-label={submitting ? "Posting comment" : "Comment"}
>
{submitting ? (
<Spinner size="sm" aria-hidden />
) : (
<ArrowUpIcon aria-hidden className="size-4" />
)}
</button>
</div>
</form>
</ComposerSurface.Host>
</ComposerSurface.Shell>
</div>
);
}
Loading
Loading