Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
62 changes: 54 additions & 8 deletions apps/mobile/src/features/threads/thread-list-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import type {
import type { MenuAction } from "@react-native-menu/menu";
import { SymbolView } from "expo-symbols";
import { memo, useCallback, useMemo, type ComponentProps } from "react";
import { Pressable, useWindowDimensions, View } from "react-native";
import { Pressable, useColorScheme, useWindowDimensions, View } from "react-native";
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
import Svg, { Circle, Path } from "react-native-svg";

import { AppText as Text } from "../../components/AppText";
import { ControlPillMenu } from "../../components/ControlPill";
Expand All @@ -16,7 +17,7 @@ import { cn } from "../../lib/cn";
import { relativeTime } from "../../lib/time";
import { useThemeColor } from "../../lib/useThemeColor";
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
import { useThreadPr } from "../../state/use-thread-pr";
import { useThreadPr, type ThreadPr } from "../../state/use-thread-pr";
import type { HomeGroupDisplayAction } from "../home/homeListItems";
import { ThreadSwipeable } from "../home/thread-swipe-actions";
import { resolveThreadStatus } from "./threadPresentation";
Expand All @@ -33,6 +34,41 @@ export type ThreadListVariant = "compact" | "sidebar";
export const THREAD_LIST_COMPACT_INSET = 20;
const SIDEBAR_ROW_RADIUS = 12;

function pullRequestTintColor(
state: ThreadPr["state"],
colorScheme: ReturnType<typeof useColorScheme>,
) {
const dark = colorScheme === "dark";
switch (state) {
case "open":
return dark ? "#34d399" : "#059669";
case "merged":
return dark ? "#a78bfa" : "#7c3aed";
case "closed":
return dark ? "#a1a1aa" : "#71717a";
}
}

function PullRequestIcon(props: { readonly size: number; readonly color: string }) {
return (
<Svg
width={props.size}
height={props.size}
viewBox="0 0 24 24"
fill="none"
stroke={props.color}
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
>
<Circle cx={18} cy={18} r={3} />
<Circle cx={6} cy={6} r={3} />
<Path d="M13 6h3a2 2 0 0 1 2 2v7" />
<Path d="M6 9v12" />
</Svg>
);
}

/* ─── Project group header ───────────────────────────────────────────── */

export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props: {
Expand Down Expand Up @@ -394,6 +430,7 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
>["simultaneousWithExternalGesture"];
}) {
const { width: windowWidth } = useWindowDimensions();
const colorScheme = useColorScheme();
const compact = props.variant === "compact";
const selected = props.selected === true;
// Recycling-safe: resets when the list container is reused for another
Expand Down Expand Up @@ -479,13 +516,22 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
</>
) : null}
{pr !== null ? (
<Text
className={`${compact ? "text-sm" : "text-xs"} font-t3-medium ${
selected ? "text-white" : pr.textClassName
}`}
<View

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium threads/thread-list-items.tsx:519

The PR badge View at line 520 sets accessibilityLabel but is not an accessibility element — in React Native a View without accessible={true} is not exposed to VoiceOver/TalkBack, and its accessibilityLabel is ignored. Since the parent Pressable already announces the thread title, the PR status is never read to screen-reader users. Consider adding accessible and accessibilityRole="text" to the View so the PR information is exposed as a separate element, or fold the PR label into the parent's accessibilityLabel.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/mobile/src/features/threads/thread-list-items.tsx around line 519:

The PR badge `View` at line 520 sets `accessibilityLabel` but is not an accessibility element — in React Native a `View` without `accessible={true}` is not exposed to VoiceOver/TalkBack, and its `accessibilityLabel` is ignored. Since the parent `Pressable` already announces the thread title, the PR status is never read to screen-reader users. Consider adding `accessible` and `accessibilityRole="text"` to the `View` so the PR information is exposed as a separate element, or fold the PR label into the parent's `accessibilityLabel`.

accessibilityLabel={`${pr.label} pull request ${pr.state}`}
className="flex-row items-center gap-0.5"
>
{pr.label}
</Text>
<PullRequestIcon
size={compact ? 13 : 11}
color={selected ? "#ffffff" : pullRequestTintColor(pr.state, colorScheme)}
/>
<Text
className={`${compact ? "text-sm" : "text-xs"} font-t3-medium ${
selected ? "text-white" : pr.textClassName
}`}
>
{pr.label}
</Text>
</View>
) : null}
</View>
) : null;
Expand Down
28 changes: 28 additions & 0 deletions apps/mobile/src/state/thread-pr-presentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { VcsStatusResult } from "@t3tools/contracts";

export type ThreadPr = NonNullable<VcsStatusResult["pr"]>;

export interface ThreadPrPresentation {
readonly number: number;
readonly state: ThreadPr["state"];
readonly url: string;
/** Compact desktop-style label, e.g. "#3774". */
readonly label: string;
readonly textClassName: string;
}

const PR_STATE_TEXT_CLASS: Record<ThreadPr["state"], string> = {
open: "text-emerald-600 dark:text-emerald-400",
merged: "text-violet-600 dark:text-violet-400",
closed: "text-zinc-500 dark:text-zinc-400",
};

export function presentThreadPr(pr: ThreadPr): ThreadPrPresentation {
return {
number: pr.number,
state: pr.state,
url: pr.url,
label: `#${pr.number}`,
textClassName: PR_STATE_TEXT_CLASS[pr.state],
};
}
22 changes: 22 additions & 0 deletions apps/mobile/src/state/use-thread-pr.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { VcsStatusResult } from "@t3tools/contracts";
import { describe, expect, it } from "vite-plus/test";

import { presentThreadPr } from "./thread-pr-presentation";

const pullRequest: NonNullable<VcsStatusResult["pr"]> = {
number: 3774,
title: "Desktop-style pull request indicator",
url: "https://github.com/t3tools/t3code/pull/3774",
baseRef: "main",
headRef: "codex/desktop-style-pr-indicator",
state: "merged",
};

describe("presentThreadPr", () => {
it("uses the compact desktop-style pull request number label", () => {
expect(presentThreadPr(pullRequest)).toMatchObject({
label: "#3774",
textClassName: "text-violet-600 dark:text-violet-400",
});
});
});
40 changes: 7 additions & 33 deletions apps/mobile/src/state/use-thread-pr.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,14 @@
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
import type { VcsStatusResult } from "@t3tools/contracts";
import { resolveChangeRequestPresentation } from "@t3tools/shared/sourceControl";

import { useEnvironmentQuery } from "./query";
import { presentThreadPr, type ThreadPrPresentation } from "./thread-pr-presentation";
import { vcsEnvironment } from "./vcs";

export type ThreadPr = NonNullable<VcsStatusResult["pr"]>;

export interface ThreadPrPresentation {
readonly number: number;
readonly state: ThreadPr["state"];
readonly url: string;
/** Compact chip label, e.g. "PR open" / "MR merged". */
readonly label: string;
readonly textClassName: string;
}

const PR_STATE_TEXT_CLASS: Record<ThreadPr["state"], string> = {
open: "text-emerald-600 dark:text-emerald-400",
merged: "text-violet-600 dark:text-violet-400",
closed: "text-zinc-500 dark:text-zinc-400",
};

export function presentThreadPr(
pr: ThreadPr,
provider: VcsStatusResult["sourceControlProvider"] | null | undefined,
): ThreadPrPresentation {
const shortName = resolveChangeRequestPresentation(provider).shortName;
return {
number: pr.number,
state: pr.state,
url: pr.url,
label: `${shortName} ${pr.state}`,
textClassName: PR_STATE_TEXT_CLASS[pr.state],
};
}
export {
presentThreadPr,
type ThreadPr,
type ThreadPrPresentation,
} from "./thread-pr-presentation";

/**
* Live PR status for a thread's branch. Subscriptions are deduplicated per
Expand Down Expand Up @@ -63,5 +37,5 @@ export function useThreadPr(
if (!status.pr) {
return null;
}
return presentThreadPr(status.pr, status.sourceControlProvider);
return presentThreadPr(status.pr);
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Outdated
}
Loading