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
4 changes: 2 additions & 2 deletions apps/mobile/src/features/issues/IssueListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
THREAD_LIST_V2_SIDEBAR_ROW_CONTAINER_STYLE,
THREAD_LIST_V2_SIDEBAR_ROW_STYLE,
} from "../threads/thread-list-v2-row-appearance";
import { issueStatus } from "./issuePresentation";
import { IssueStatusIcon, issueStatus } from "./issuePresentation";

export const IssueListRow = memo(function IssueListRow(props: {
readonly item: EnvironmentIssueEntry;
Expand Down Expand Up @@ -58,7 +58,7 @@ export const IssueListRow = memo(function IssueListRow(props: {
className={cn("self-start", props.sidebar ? "pt-0.5" : "pt-2.5")}
style={props.depth ? { marginLeft: props.depth * 20 } : undefined}
>
<SymbolView name={status.icon} size={20} tintColorClassName={status.tint} />
<IssueStatusIcon state={item.state} size={20} />
</View>
<View
className={cn(
Expand Down
21 changes: 18 additions & 3 deletions apps/mobile/src/features/issues/IssueRelations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AppText as Text } from "../../components/ui/AppText";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
import { PullRequestSectionHeading } from "../pull-requests/PullRequestSectionHeading";
import type { IssueParams } from "./issueParams";
import { issueStatus } from "./issuePresentation";
import { IssueStatusIcon, issueStatus } from "./issuePresentation";

function RelatedIssueRow(props: {
readonly issue: IssueRelatedRef;
Expand All @@ -28,7 +28,7 @@ function RelatedIssueRow(props: {
onPress={() => props.onOpen(issue)}
className="min-h-10 flex-row items-center gap-2 active:opacity-70"
>
<SymbolView name={status.icon} size={14} tintColorClassName={status.tint} />
<IssueStatusIcon state={issue.state} size={14} />
<Text className="shrink-0 font-mono text-2xs text-foreground-muted">{issue.displayKey}</Text>
<Text className="min-w-0 flex-1 text-sm" numberOfLines={1}>
{issue.title}
Expand All @@ -55,7 +55,7 @@ export function IssueRelations(props: {
["Blocking", detail.blocks ?? []],
];
const related = groups.filter(([, issues]) => issues.length > 0);
if (!project && !detail.branchName && related.length === 0) return null;
if (!project && !detail.branchName && !detail.priorityLabel && related.length === 0) return null;

const openRelated = (issue: IssueRelatedRef) =>
navigation.dispatch(
Expand Down Expand Up @@ -120,6 +120,21 @@ export function IssueRelations(props: {
<SymbolView name="doc.on.doc" size={12} tintColorClassName="accent-icon-muted" />
</Pressable>
) : null}
{detail.priorityLabel ? (
<View
accessible
accessibilityLabel={`Priority ${detail.priorityLabel}`}
className="flex-row items-center gap-2"
>
<SymbolView name="chart.bar.xaxis" size={14} tintColorClassName="accent-icon-muted" />
<Text className="min-w-0 flex-1 text-sm" numberOfLines={1}>
{/* Mobile rows have no label column, so the value names itself. */}
{/^no priority$/i.test(detail.priorityLabel)
? detail.priorityLabel
: `${detail.priorityLabel} priority`}
</Text>
</View>
) : null}
{related.map(([label, issues]) => (
<View key={label} className="gap-0.5">
<PullRequestSectionHeading>{label}</PullRequestSectionHeading>
Expand Down
10 changes: 8 additions & 2 deletions apps/mobile/src/features/issues/IssueRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { issueIdentity, issueParamsKey, issueTarget, type IssueParams } from "./
import {
IssueLabelPill,
issueCommandError,
IssueStatusIcon,
issueStatus,
useIssueAccess,
} from "./issuePresentation";
Expand Down Expand Up @@ -111,8 +112,13 @@ function IssueStateControl(props: {
disabled={!moves.length || props.busy}
className="min-h-8 flex-row items-center gap-1.5 active:opacity-70"
>
<SymbolView name={status.icon} size={14} tintColorClassName={status.tint} />
<Text className={`text-xs font-t3-medium ${status.text}`}>{status.label}</Text>
<IssueStatusIcon state={props.state} size={14} />
{/* A Linear state's colour is its glyph's; the name stays neutral beside it. */}
<Text
className={`text-xs font-t3-medium ${props.state.type ? "text-foreground" : status.text}`}
>
{status.label}
</Text>
{moves.length ? (
<SymbolView name="chevron.down" size={9} tintColorClassName="accent-icon-muted" />
) : null}
Expand Down
47 changes: 45 additions & 2 deletions apps/mobile/src/features/issues/issuePresentation.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { useAtomValue } from "@effect/atom-react";
import { issueWriteAccess } from "@t3tools/client-runtime/issue-presentation";
import { issueStateGlyph } from "@t3tools/client-runtime/issue-state-glyph";
import {
isAtomCommandInterrupted,
squashAtomCommandFailure,
} from "@t3tools/client-runtime/state/runtime";
import type { IssueDetail, IssueLabel, IssueState } from "@t3tools/contracts";
import { AsyncResult } from "effect/reactivity";
import { View } from "react-native";
import { useColorScheme, View } from "react-native";
import Svg, { Circle, Path } from "react-native-svg";

import type { AppSymbolName } from "../../components/ui/AppSymbol";
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { issueEnvironment } from "../../state/issues";
import { ENVIRONMENT_REQUEST_INTERRUPTED } from "../../state/query";
Expand Down Expand Up @@ -47,6 +49,47 @@ export function issueStatus(state: IssueState): {
};
}

/**
* The state's mark: Linear's per-type glyph in the state's colour where the tracker has workflow
* types, otherwise the open or closed symbol. The same shapes the web draws.
*/
export function IssueStatusIcon(props: { readonly state: IssueState; readonly size: number }) {
const scheme = useColorScheme() === "dark" ? "dark" : "light";
const glyph = issueStateGlyph(props.state, scheme);
if (glyph === null) {
const status = issueStatus(props.state);
return <SymbolView name={status.icon} size={props.size} tintColorClassName={status.tint} />;
}
return (
<Svg width={props.size} height={props.size} viewBox={`0 0 ${glyph.viewBox} ${glyph.viewBox}`}>
{glyph.primitives.map((primitive) =>
primitive.tag === "circle" ? (
<Circle
key={primitive.key}
cx={primitive.cx}
cy={primitive.cy}
r={primitive.r}
fill={primitive.fill ?? "none"}
stroke={primitive.stroke ?? "none"}
strokeWidth={primitive.strokeWidth}
strokeDasharray={primitive.dash ?? undefined}
/>
) : (
<Path
key={primitive.key}
d={primitive.d}
fill={primitive.fill ?? "none"}
stroke={primitive.stroke ?? "none"}
strokeWidth={primitive.strokeWidth}
strokeLinecap="round"
strokeLinejoin="round"
/>
),
)}
</Svg>
);
}

/** What this device may do to the issue, and the first thing in the way when it may not. */
export function useIssueAccess(params: IssueParams, detail: IssueDetail | null | undefined) {
const connected = usePullRequestConnected(params.environmentId);
Expand Down
30 changes: 22 additions & 8 deletions apps/web/src/components/LinearIssueContextChip.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
import type { LinearIssueContextRecord } from "@t3tools/contracts";
import { CircleCheckIcon, CircleIcon, CircleXIcon } from "lucide-react";
import { IssueStateType, type LinearIssueContextRecord } from "@t3tools/contracts";
import { CircleIcon } from "lucide-react";
import * as Schema from "effect/Schema";
import { linearIssueExtrasSummary } from "@t3tools/shared/linearLaunch";

import { ContextChip, ContextChipLabel } from "./ContextChip";
import ChatMarkdown from "./ChatMarkdown";
import { LinearIcon } from "./Icons";
import { cn } from "~/lib/utils";
import { IssueStateIcon as LinearStateIcon } from "./issue/issuePresentation";
import { PreviewCard, PreviewCardPopup, PreviewCardTrigger } from "./ui/preview-card";

/** Records name Linear's own state types; newer ones carry `open`, `completed` or `canceled`. */
const isStateType = Schema.is(IssueStateType);
const CLOSED_TYPES: ReadonlyArray<string> = ["completed", "canceled", "duplicate"];

/** Records carry Linear's state type; some older ones only `open`, which has no glyph. */
function IssueStateIcon({
type,
name,
className,
}: {
readonly type: string;
readonly name: string;
readonly className?: string;
}) {
const Icon =
type === "completed" ? CircleCheckIcon : type === "canceled" ? CircleXIcon : CircleIcon;
return <Icon aria-hidden className={cn("size-3.5 shrink-0 text-muted-foreground", className)} />;
if (!isStateType(type)) {
return (
<CircleIcon
aria-hidden
className={cn("size-3.5 shrink-0 text-muted-foreground", className)}
/>
);
}
const category = CLOSED_TYPES.includes(type) ? "closed" : "open";
return <LinearStateIcon state={{ category, name, type }} className={cn("size-3.5", className)} />;
}

function LinearIssuePreview({ record }: { readonly record: LinearIssueContextRecord }) {
Expand All @@ -33,7 +47,7 @@ function LinearIssuePreview({ record }: { readonly record: LinearIssueContextRec
<div className="w-96 max-w-full space-y-2 p-3 text-xs">
<div className="truncate text-2xs text-muted-foreground">{crumbs.join(" › ")}</div>
<div className="flex items-start gap-1.5">
<IssueStateIcon type={record.stateType} className="mt-0.5" />
<IssueStateIcon type={record.stateType} name={record.stateName} className="mt-0.5" />
<div className="min-w-0">
<div className="font-medium text-foreground">
<span className="font-mono text-muted-foreground">{record.identifier}</span>{" "}
Expand Down Expand Up @@ -66,7 +80,7 @@ function LinearIssuePreview({ record }: { readonly record: LinearIssueContextRec
</div>
{record.subIssues.slice(0, 5).map((sub) => (
<div key={sub.identifier} className="flex items-center gap-1.5">
<IssueStateIcon type={sub.stateType} />
<IssueStateIcon type={sub.stateType} name={sub.stateType} />
<span className="font-mono text-muted-foreground">{sub.identifier}</span>
<span className="truncate">{sub.title}</span>
</div>
Expand Down
11 changes: 2 additions & 9 deletions apps/web/src/components/RightPanelTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ 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 { IssueStateIcon } from "~/components/issue/issuePresentation";
import { issueEnvironment } from "~/state/issues";
import { resolveShortcutCommand, type ShortcutMatchContext } from "~/keybindings";
import { readLocalApi } from "~/localApi";
Expand Down Expand Up @@ -795,14 +795,7 @@ function IssueSurfaceIcon({
}),
).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)}
/>
);
return <IssueStateIcon labelled state={detail.state} className="size-3" />;
}

function PullRequestSurfaceIcon({
Expand Down
16 changes: 14 additions & 2 deletions apps/web/src/components/WorkspaceBreadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@ interface WorkspaceBreadcrumbProps {
readonly ariaLabel: string;
readonly children: ReactNode;
readonly className?: string;
/** Wraps onto more lines instead of squeezing the current level out of a narrow pane. */
readonly wrap?: boolean;
}

export function WorkspaceBreadcrumb({ ariaLabel, children, className }: WorkspaceBreadcrumbProps) {
export function WorkspaceBreadcrumb({
ariaLabel,
children,
className,
wrap = false,
}: WorkspaceBreadcrumbProps) {
return (
<nav aria-label={ariaLabel} className={cn("min-w-0", className)}>
<ol className="m-0 flex min-w-0 list-none items-center gap-2 p-0 text-sm sm:gap-3">
<ol
className={cn(
"m-0 flex min-w-0 list-none items-center gap-2 p-0 text-sm sm:gap-3",
wrap && "flex-wrap gap-y-0 sm:gap-y-0",
)}
>
{children}
</ol>
</nav>
Expand Down
13 changes: 10 additions & 3 deletions apps/web/src/components/issue/IssueBrowseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { issueEnvironment } from "~/state/issues";
import { useEnvironmentQuery } from "~/state/query";
import { useAtomCommand } from "~/state/use-atom-command";

import { IssueGlyph } from "./issuePresentation";
import { IssueRow, type IssueRowTarget } from "./IssueRow";
import {
appendIssueBrowseEntries,
Expand Down Expand Up @@ -126,24 +127,26 @@ export function IssueBrowseView({
}

const breadcrumb = (
<WorkspaceBreadcrumb ariaLabel="Browse breadcrumb">
<WorkspaceBreadcrumb ariaLabel="Browse breadcrumb" wrap>
{crumbs.map((crumb, index) => (
<Fragment key={crumb.level}>
{index > 0 ? (
<WorkspaceBreadcrumbSeparator>
<ChevronRightIcon className="size-3.5" />
</WorkspaceBreadcrumbSeparator>
) : null}
<WorkspaceBreadcrumbItem current={crumb.target === null}>
{/* An ancestor may shrink too: a long project name truncates on its own line. */}
<WorkspaceBreadcrumbItem current={crumb.target === null} className="max-w-full shrink">
{crumb.target === null ? (
<WorkspaceBreadcrumbText>{crumb.label}</WorkspaceBreadcrumbText>
) : (
<Button
size="xs"
variant="ghost-muted"
className="max-w-full min-w-0 shrink"
onClick={() => onNavigate(crumb.target ?? {})}
>
{crumb.label}
<span className="truncate">{crumb.label}</span>
</Button>
)}
</WorkspaceBreadcrumbItem>
Expand Down Expand Up @@ -175,6 +178,8 @@ export function IssueBrowseView({
<PullRequestListGhost />
) : teams.length === 0 && teamsError ? (
<PullRequestsUnavailableState
title="Could not load teams"
icon={<IssueGlyph.issue />}
error={teamsError}
onRetry={onRetryTeams}
refreshing={teamsPending}
Expand Down Expand Up @@ -302,6 +307,8 @@ function BrowseLevel({
{toolbar}
{query.error !== null && !query.isPending ? (
<PullRequestsUnavailableState
title="Could not load this view"
icon={<IssueGlyph.issue />}
error={query.error}
onRetry={query.refresh}
refreshing={query.isPending}
Expand Down
27 changes: 14 additions & 13 deletions apps/web/src/components/issue/IssueDetailPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ import { IssueCommentComposer } from "./IssueCommentComposer";
import { IssueDetailGhost } from "./IssueDetailGhost";
import { ReactionBar } from "../pullRequest/PullRequestReactions";
import { PullRequestsUnavailableState } from "../pullRequest/PullRequestsUnavailableState";
import { issueTrackerPresentation, issueStatePresentation } from "./issuePresentation";
import {
IssueGlyph,
IssueStateIcon,
issueTrackerPresentation,
issueStatePresentation,
} from "./issuePresentation";
import { LinearIssueLaunchBar, LinearIssueRelations } from "../linear/LinearIssueDetailExtras";

/**
Expand Down Expand Up @@ -481,6 +486,7 @@ export function IssueDetailPanel({
return (
<PullRequestsUnavailableState
title="Could not load this issue"
icon={<IssueGlyph.issue />}
error={detailQuery.error}
onRetry={detailQuery.refresh}
/>
Expand Down Expand Up @@ -563,12 +569,7 @@ export function IssueDetailPanel({
refreshIssueLists(environmentId);
};

const currentStateIcon = (
<currentState.Icon
aria-hidden
className={cn("size-3.5 shrink-0", currentState.toneClassName)}
/>
);
const currentStateIcon = <IssueStateIcon state={detail.state} className="size-3.5" />;
const stateControl: ReactNode =
otherStates.length > 0 ? (
<Menu>
Expand All @@ -588,13 +589,9 @@ export function IssueDetailPanel({
</MenuTrigger>
<MenuPopup align="end">
{otherStates.map((state) => {
const presentation = issueStatePresentation(state);
return (
<MenuItem key={state.name} onClick={() => void moveTo(state.name)}>
<presentation.Icon
aria-hidden
className={cn("size-3.5 shrink-0", presentation.toneClassName)}
/>
<IssueStateIcon state={state} className="size-3.5" />
{state.name}
</MenuItem>
);
Expand Down Expand Up @@ -624,7 +621,11 @@ export function IssueDetailPanel({
{detail.scope}
</span>
<InlineButton
className={cn("shrink-0 font-medium", currentState.toneClassName)}
// A Linear state's colour is its glyph's; the key stays neutral beside it.
className={cn(
"shrink-0 font-medium",
detail.state.type === undefined && currentState.toneClassName,
)}
aria-label={`Open ${detail.displayKey} on ${tracker.providerName}`}
render={<a href={detail.url} target="_blank" rel="noopener noreferrer" />}
>
Expand Down
Loading
Loading