Skip to content

Commit 168af64

Browse files
baileyclaude
authored andcommitted
test(mobile): cover the thread row's async-question marker
The row's rules for an open async question move into pure helpers beside shouldRecedeThreadRow, so a test can check them without a render harness: Input shows only while the run keeps working, the row keeps full emphasis, Working goes unsaid beside Input while Goal stays, and the accessible label reads "<title>, Input, still working" or "<title>, Input, Goal". Behavior is unchanged. Reviewed-by: gpt-6.1-sol (Codex) Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0f498c3 commit 168af64

3 files changed

Lines changed: 109 additions & 13 deletions

File tree

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ import {
7676
type ThreadListV2Status,
7777
} from "./threadListV2";
7878
import { QueuedMessageIcon } from "./queued-message-icon";
79-
import { shouldRecedeThreadRow } from "./thread-row-emphasis";
79+
import {
80+
hasThreadRowAsyncQuestion,
81+
shouldRecedeThreadRow,
82+
threadRowAccessibilityLabel,
83+
threadRowStatusText,
84+
} from "./thread-row-emphasis";
8085
import { ThreadSearchMatchExcerpt } from "./thread-search-match";
8186
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
8287
import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
@@ -688,15 +693,18 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
688693
const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, selected);
689694

690695
const status = resolveThreadListV2Status(thread);
691-
const hasAsyncQuestion = status === "working" && thread.hasPendingAsyncQuestion === true;
696+
const hasAsyncQuestion = hasThreadRowAsyncQuestion({
697+
status,
698+
hasPendingAsyncQuestion: thread.hasPendingAsyncQuestion,
699+
});
692700
const isUnread = status === "ready" && threadHasUnseenCompletion(thread);
693701
const workingLabel = STATUS_LABEL_BY_STATUS[status];
694702
const showsWoke = status === "ready" && props.wokeAt !== null;
695703
const statusLabel =
696704
(status === "working" && workingLabel !== undefined && thread.goal?.status === "active"
697705
? { ...workingLabel, label: "Goal" }
698706
: workingLabel) ?? (isUnread ? DONE_STATUS_LABEL : undefined);
699-
const recede = !hasAsyncQuestion && shouldRecedeThreadRow({ status, selected });
707+
const recede = shouldRecedeThreadRow({ status, selected, hasAsyncQuestion });
700708
const timeLabel = props.timeLabel;
701709

702710
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
@@ -1170,8 +1178,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
11701178
selected ? selectedThreadRowColors.foregroundClassName : statusLabel.className,
11711179
)}
11721180
>
1173-
{/* Beside Input the spinner and timer already say Working; Goal says more. */}
1174-
{hasAsyncQuestion && statusLabel.label === "Working" ? null : statusLabel.label}
1181+
{threadRowStatusText({ hasAsyncQuestion, label: statusLabel.label })}
11751182
{status === "working" ? (
11761183
<ThreadListV2Duration startedAt={resolveThreadWorkingStartedAt(thread)} />
11771184
) : status === "waiting" ? (
@@ -1319,13 +1326,12 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
13191326
cardContent
13201327
);
13211328

1322-
const rowAccessibilityLabel = [
1323-
thread.title,
1324-
hasAsyncQuestion ? `Input, ${statusLabel?.label === "Goal" ? "Goal" : "still working"}` : null,
1325-
props.hasQueuedMessages ? "messages queued to send" : null,
1326-
]
1327-
.filter(Boolean)
1328-
.join(", ");
1329+
const rowAccessibilityLabel = threadRowAccessibilityLabel({
1330+
title: thread.title,
1331+
hasAsyncQuestion,
1332+
statusLabel: statusLabel?.label ?? null,
1333+
hasQueuedMessages: props.hasQueuedMessages === true,
1334+
});
13291335

13301336
const rowContent = (close: () => void) =>
13311337
variant === "card" ? (
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
3+
import {
4+
hasThreadRowAsyncQuestion,
5+
shouldRecedeThreadRow,
6+
threadRowAccessibilityLabel,
7+
threadRowStatusText,
8+
} from "./thread-row-emphasis";
9+
10+
describe("thread row with an open async question", () => {
11+
it("shows Input only while the run keeps working", () => {
12+
expect(hasThreadRowAsyncQuestion({ status: "working", hasPendingAsyncQuestion: true })).toBe(
13+
true,
14+
);
15+
expect(hasThreadRowAsyncQuestion({ status: "working", hasPendingAsyncQuestion: false })).toBe(
16+
false,
17+
);
18+
expect(hasThreadRowAsyncQuestion({ status: "working" })).toBe(false);
19+
expect(hasThreadRowAsyncQuestion({ status: "input", hasPendingAsyncQuestion: true })).toBe(
20+
false,
21+
);
22+
});
23+
24+
it("keeps full emphasis instead of receding like other working rows", () => {
25+
expect(shouldRecedeThreadRow({ status: "working", selected: false })).toBe(true);
26+
expect(
27+
shouldRecedeThreadRow({ status: "working", selected: false, hasAsyncQuestion: true }),
28+
).toBe(false);
29+
});
30+
31+
it("leaves Working unsaid beside Input but keeps Goal", () => {
32+
expect(threadRowStatusText({ hasAsyncQuestion: true, label: "Working" })).toBeNull();
33+
expect(threadRowStatusText({ hasAsyncQuestion: true, label: "Goal" })).toBe("Goal");
34+
expect(threadRowStatusText({ hasAsyncQuestion: false, label: "Working" })).toBe("Working");
35+
});
36+
37+
it("announces the question with the title and queued messages", () => {
38+
const label = (statusLabel: string | null, hasAsyncQuestion = true) =>
39+
threadRowAccessibilityLabel({
40+
title: "Refactor auth",
41+
hasAsyncQuestion,
42+
statusLabel,
43+
hasQueuedMessages: true,
44+
});
45+
expect(label("Working")).toBe("Refactor auth, Input, still working, messages queued to send");
46+
expect(label("Goal")).toBe("Refactor auth, Input, Goal, messages queued to send");
47+
expect(label("Working", false)).toBe("Refactor auth, messages queued to send");
48+
});
49+
});

‎apps/mobile/src/features/threads/thread-row-emphasis.ts‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,47 @@ import type { ThreadListV2Status } from "./threadListV2";
33
export function shouldRecedeThreadRow(input: {
44
readonly status: ThreadListV2Status;
55
readonly selected: boolean;
6+
/** An open async question keeps the row at full emphasis while its run works. */
7+
readonly hasAsyncQuestion?: boolean;
68
}): boolean {
7-
return !input.selected && (input.status === "working" || input.status === "waiting");
9+
return (
10+
!input.selected &&
11+
input.hasAsyncQuestion !== true &&
12+
(input.status === "working" || input.status === "waiting")
13+
);
14+
}
15+
16+
/** Whether the row shows the Input marker for an async question its run keeps working through. */
17+
export function hasThreadRowAsyncQuestion(input: {
18+
readonly status: ThreadListV2Status;
19+
readonly hasPendingAsyncQuestion?: boolean | undefined;
20+
}): boolean {
21+
return input.status === "working" && input.hasPendingAsyncQuestion === true;
22+
}
23+
24+
/** Beside Input the spinner and timer already say Working; any other label, such as Goal, stays. */
25+
export function threadRowStatusText(input: {
26+
readonly hasAsyncQuestion: boolean;
27+
readonly label: string;
28+
}): string | null {
29+
return input.hasAsyncQuestion && input.label === "Working" ? null : input.label;
30+
}
31+
32+
export function threadRowAccessibilityLabel(input: {
33+
readonly title: string;
34+
readonly hasAsyncQuestion: boolean;
35+
readonly statusLabel: string | null;
36+
readonly hasQueuedMessages: boolean;
37+
}): string {
38+
const statusText =
39+
input.statusLabel === null
40+
? null
41+
: threadRowStatusText({ hasAsyncQuestion: input.hasAsyncQuestion, label: input.statusLabel });
42+
return [
43+
input.title,
44+
input.hasAsyncQuestion ? `Input, ${statusText ?? "still working"}` : null,
45+
input.hasQueuedMessages ? "messages queued to send" : null,
46+
]
47+
.filter(Boolean)
48+
.join(", ");
849
}

0 commit comments

Comments
 (0)