Skip to content

Commit ff354ee

Browse files
Fix Android showcase capture and rebuild v2 queued rows
The Android showcase job died two seconds after the environment server started, printing one line: "cannot rollback - no transaction is active". That error was the masking, not the failure. The seed opens state.sqlite while the server it just started is still writing, so BEGIN IMMEDIATE loses the write-lock race and returns "database is locked"; the catch block's unguarded ROLLBACK then threw over it. A local probe against a fresh server reproduces both strings — 1 failure in 40 attempts on an idle machine, and none in 120 once the connection carries a busy timeout. Give the seed a 30s timeout, guard the rollback, and print stacks from the harness: it only fails in CI, where the line that threw is the whole diagnosis. Queued tasks rendered in Thread List v2 with the v1 row design — a bold `text-lg` title, a zinc "Pending" pill, and a chevron — so the one row you cannot act on shouted louder than the live work above it. Rebuild them in the v2 card idiom (project line, title, `branch · machine`) under a "Pending" divider that mirrors "Settled", with "Queued" in the status slot. The label stays uncolored: v2 reserves hue for act-now, in-motion, and broken, and a queued task asks nothing of the user. The showcase fixture had no settled threads, so the list screenshotted as one undifferentiated block. Seed three (one per project, 5h/28h/2d) with an explicit settled override, and drop the oldest unlabeled active thread so the settled tail starts above the fold on a phone. Co-Authored-By: Claude <[email protected]>
1 parent 3c50a64 commit ff354ee

6 files changed

Lines changed: 224 additions & 29 deletions

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
ThreadListRow,
3737
ThreadListShowMoreRow,
3838
} from "../threads/thread-list-items";
39-
import { ThreadListV2Row } from "../threads/thread-list-v2-items";
39+
import { ThreadListV2PendingRow, ThreadListV2Row } from "../threads/thread-list-v2-items";
4040
import {
4141
buildThreadListV2Items,
4242
THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
@@ -809,14 +809,21 @@ export function HomeScreen(props: HomeScreenProps) {
809809
<>
810810
{listHeader}
811811
{v2PendingTasks.map((pendingTask, index) => (
812-
<PendingTaskListRow
812+
<ThreadListV2PendingRow
813813
key={pendingTask.message.messageId}
814-
variant="compact"
815814
pendingTask={pendingTask}
815+
project={
816+
projectByKey.get(
817+
scopedProjectKey(pendingTask.message.environmentId, pendingTask.creation.projectId),
818+
) ?? null
819+
}
820+
projectTitle={v2ProjectTitleByProjectKey.get(
821+
scopedProjectKey(pendingTask.message.environmentId, pendingTask.creation.projectId),
822+
)}
816823
environmentLabel={
817824
props.savedConnectionsById[pendingTask.message.environmentId]?.environmentLabel ?? null
818825
}
819-
isLast={index === v2PendingTasks.length - 1}
826+
showPendingDivider={index === 0}
820827
onSelectPendingTask={props.onSelectPendingTask}
821828
onDeletePendingTask={props.onDeletePendingTask}
822829
/>

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
ThreadListRow,
6363
ThreadListShowMoreRow,
6464
} from "./thread-list-items";
65-
import { ThreadListV2Row } from "./thread-list-v2-items";
65+
import { ThreadListV2PendingRow, ThreadListV2Row } from "./thread-list-v2-items";
6666
import {
6767
buildThreadListV2Items,
6868
THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
@@ -79,7 +79,8 @@ type SidebarListItem =
7979
readonly type: "v2-pending-task";
8080
readonly key: string;
8181
readonly pendingTask: PendingNewTask;
82-
readonly isLast: boolean;
82+
/** Only the leading queued row draws the "Pending" divider. */
83+
readonly isFirst: boolean;
8384
}
8485
| { readonly type: "v2-thread"; readonly key: string; readonly item: ThreadListV2Item }
8586
| { readonly type: "v2-show-more"; readonly key: string; readonly hiddenCount: number };
@@ -494,7 +495,7 @@ function ThreadNavigationSidebarPane(
494495
type: "v2-pending-task" as const,
495496
key: `v2-pending:${pendingTask.message.messageId}`,
496497
pendingTask,
497-
isLast: index === v2PendingTasks.length - 1,
498+
isFirst: index === 0,
498499
}));
499500
for (const item of threadListV2Layout.items) {
500501
items.push({
@@ -712,7 +713,7 @@ function ThreadNavigationSidebarPane(
712713
return previous.hiddenCount === item.hiddenCount;
713714
}
714715
if (previous.type === "v2-pending-task" && item.type === "v2-pending-task") {
715-
return previous.pendingTask === item.pendingTask && previous.isLast === item.isLast;
716+
return previous.pendingTask === item.pendingTask && previous.isFirst === item.isFirst;
716717
}
717718
if (
718719
previous.type === "v2-thread" ||
@@ -748,20 +749,27 @@ function ThreadNavigationSidebarPane(
748749
const renderListItem = useCallback(
749750
({ item }: { readonly item: SidebarListItem }) => {
750751
switch (item.type) {
751-
case "v2-pending-task":
752+
case "v2-pending-task": {
753+
const pendingScopeKey = scopedProjectKey(
754+
item.pendingTask.message.environmentId,
755+
item.pendingTask.creation.projectId,
756+
);
752757
return (
753-
<PendingTaskListRow
754-
variant="sidebar"
758+
<ThreadListV2PendingRow
755759
pendingTask={item.pendingTask}
760+
project={projectByKey.get(pendingScopeKey) ?? null}
761+
projectTitle={projectTitleByProjectKey.get(pendingScopeKey)}
756762
environmentLabel={
757763
savedConnectionsById[item.pendingTask.message.environmentId]?.environmentLabel ??
758764
null
759765
}
760-
isLast={item.isLast}
766+
pane="sidebar"
767+
showPendingDivider={item.isFirst}
761768
onSelectPendingTask={openPendingTask}
762769
onDeletePendingTask={confirmDeletePendingTask}
763770
/>
764771
);
772+
}
765773
case "v2-thread": {
766774
const thread = item.item.thread;
767775
const scopeKey = scopedProjectKey(thread.environmentId, thread.projectId);

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

Lines changed: 124 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ProviderIcon } from "../../components/ProviderIcon";
1414
import { cn } from "../../lib/cn";
1515
import { relativeTime } from "../../lib/time";
1616
import { useThemeColor } from "../../lib/useThemeColor";
17+
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
1718
import { useThreadPr } from "../../state/use-thread-pr";
1819
import { ThreadSwipeable } from "../home/thread-swipe-actions";
1920
import { resolveThreadListV2Status, type ThreadListV2Status } from "./threadListV2";
@@ -68,23 +69,140 @@ const LEGACY_MENU_ACTIONS: MenuAction[] = [
6869
/** Rounded-row radius shared with the v1 sidebar rows. */
6970
const SIDEBAR_V2_ROW_RADIUS = 12;
7071

71-
export const ThreadListV2SettledDivider = memo(function ThreadListV2SettledDivider(props: {
72+
/** Section label + rule: the only structure in an otherwise flat list. */
73+
export const ThreadListV2SectionDivider = memo(function ThreadListV2SectionDivider(props: {
74+
readonly label: string;
7275
readonly pane?: "screen" | "sidebar";
76+
/** Leading sections sit right under the list header and need no top gap. */
77+
readonly first?: boolean;
7378
}) {
7479
const borderColor = useThemeColor("--color-border");
7580
return (
7681
<View
7782
className={cn(
78-
"mb-1.5 mt-4 flex-row items-center gap-2.5",
83+
"mb-1.5 flex-row items-center gap-2.5",
84+
props.first ? "mt-1" : "mt-4",
7985
props.pane === "sidebar" ? "px-3" : "px-5",
8086
)}
8187
>
82-
<Text className="text-xs font-t3-medium text-foreground-tertiary">Settled</Text>
88+
<Text className="text-xs font-t3-medium text-foreground-tertiary">{props.label}</Text>
8389
<View className="h-px flex-1" style={{ backgroundColor: borderColor }} />
8490
</View>
8591
);
8692
});
8793

94+
const PENDING_TASK_MENU_ACTIONS: MenuAction[] = [
95+
{ id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
96+
];
97+
98+
/**
99+
* A queued new task, in the same idiom as an active v2 row: it is work the
100+
* user wrote, so it reads like the threads it will become. "Queued" takes
101+
* the status slot — the state is the one thing that differs — and stays
102+
* uncolored because nothing is asked of the user; the environment is simply
103+
* not reachable yet.
104+
*/
105+
export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props: {
106+
readonly pendingTask: PendingNewTask;
107+
readonly project: EnvironmentProject | null;
108+
readonly projectTitle?: string;
109+
readonly environmentLabel: string | null;
110+
readonly pane?: "screen" | "sidebar";
111+
/** Draws the "Pending" divider above the first queued row. */
112+
readonly showPendingDivider: boolean;
113+
readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
114+
readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
115+
}) {
116+
const { pendingTask, onSelectPendingTask, onDeletePendingTask } = props;
117+
const drawerColor = useThemeColor("--color-drawer");
118+
const pressedBackgroundColor = useThemeColor("--color-subtle");
119+
const sidebarPane = props.pane === "sidebar";
120+
const projectTitle =
121+
props.projectTitle ?? props.project?.title ?? pendingTask.creation.projectTitle ?? "";
122+
const branch = pendingTask.creation.branch;
123+
124+
const handleMenuAction = useCallback(
125+
({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
126+
if (nativeEvent.event === "delete") onDeletePendingTask(pendingTask);
127+
},
128+
[onDeletePendingTask, pendingTask],
129+
);
130+
131+
const rowContent = (
132+
<>
133+
<View className="flex-row items-center gap-1.5">
134+
{props.project ? (
135+
<ProjectFavicon
136+
environmentId={pendingTask.message.environmentId}
137+
size={15}
138+
projectTitle={projectTitle}
139+
workspaceRoot={props.project.workspaceRoot}
140+
/>
141+
) : null}
142+
<Text className="flex-1 text-sm font-t3-medium text-foreground-muted" numberOfLines={1}>
143+
{projectTitle}
144+
</Text>
145+
<Text className="text-xs text-foreground-tertiary">Queued</Text>
146+
</View>
147+
<Text className="mt-1 text-base font-t3-medium text-foreground" numberOfLines={2}>
148+
{pendingTask.title}
149+
</Text>
150+
{branch || props.environmentLabel ? (
151+
<Text className="mt-1 text-xs text-foreground-muted" numberOfLines={1}>
152+
{branch ? (
153+
<Text className="text-xs text-foreground-muted" style={{ fontFamily: MONO_FONT }}>
154+
{branch}
155+
</Text>
156+
) : null}
157+
{branch && props.environmentLabel ? " · " : null}
158+
{props.environmentLabel ? (
159+
<Text className="text-xs text-foreground-tertiary">{props.environmentLabel}</Text>
160+
) : null}
161+
</Text>
162+
) : null}
163+
</>
164+
);
165+
166+
return (
167+
<>
168+
{props.showPendingDivider ? (
169+
<ThreadListV2SectionDivider first label="Pending" pane={props.pane} />
170+
) : null}
171+
<ControlPillMenu
172+
actions={PENDING_TASK_MENU_ACTIONS}
173+
onPressAction={handleMenuAction}
174+
shouldOpenOnLongPress
175+
>
176+
<Pressable
177+
accessibilityHint="Opens the queued task for editing"
178+
accessibilityLabel={pendingTask.title}
179+
accessibilityRole="button"
180+
onPress={() => onSelectPendingTask(pendingTask)}
181+
style={
182+
sidebarPane
183+
? ({ pressed }) => ({
184+
backgroundColor: pressed ? pressedBackgroundColor : drawerColor,
185+
borderRadius: SIDEBAR_V2_ROW_RADIUS,
186+
paddingHorizontal: 12,
187+
paddingVertical: 10,
188+
})
189+
: ({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })
190+
}
191+
>
192+
{sidebarPane ? (
193+
rowContent
194+
) : (
195+
<View className="bg-screen">
196+
<View className="px-5 py-2.5">{rowContent}</View>
197+
<View className="ml-5 h-px bg-border-subtle" />
198+
</View>
199+
)}
200+
</Pressable>
201+
</ControlPillMenu>
202+
</>
203+
);
204+
});
205+
88206
export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
89207
readonly thread: EnvironmentThreadShell;
90208
readonly variant: "card" | "slim";
@@ -423,7 +541,9 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
423541

424542
return (
425543
<>
426-
{props.showSettledDivider ? <ThreadListV2SettledDivider pane={props.pane} /> : null}
544+
{props.showSettledDivider ? (
545+
<ThreadListV2SectionDivider label="Settled" pane={props.pane} />
546+
) : null}
427547
<ThreadSwipeable
428548
backgroundColor={sidebarPane ? drawerColor : screenColor}
429549
compactActions={variant === "slim"}

‎scripts/mobile-showcase-environment.ts‎

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,42 @@ export const SHOWCASE_THREADS = [
201201
response:
202202
"The plan groups milestones without changing the underlying log stream, preserves plain-text output, and adds zero work to the hot path.",
203203
},
204+
// Finished work, settled by hand: the list keeps it as a receded tail so
205+
// the active block above reads as everything still in flight. The active
206+
// block stays small enough that the settled tail begins above the fold —
207+
// a store screenshot has to show that history exists, not just imply it.
204208
{
205-
id: "scheduler-breathe",
209+
id: "handoff-haptics",
210+
projectId: "t3code",
211+
title: "Tune the handoff haptics",
212+
branch: "feat/handoff-haptics",
213+
minutesAgo: 5 * 60,
214+
settled: true,
215+
request: "Give the desktop-to-phone handoff a haptic that lands with the animation.",
216+
response:
217+
"The handoff now taps once as the thread lands and stays silent on failure, so the phone never celebrates a handoff that did not happen.",
218+
},
219+
{
220+
id: "streaming-shell",
221+
projectId: "react",
222+
title: "Stream the shell before the data",
223+
branch: "feat/streaming-shell",
224+
minutesAgo: 28 * 60,
225+
settled: true,
226+
request: "Get the app shell painted before any data request resolves.",
227+
response:
228+
"The shell now flushes on first byte and the data boundaries hydrate underneath it, so the first paint no longer waits on the slowest query.",
229+
},
230+
{
231+
id: "quieter-oom",
206232
projectId: "linux",
207-
title: "Let the scheduler breathe",
208-
branch: "perf/scheduler-breathe",
209-
minutesAgo: 76,
210-
request:
211-
"Find a calmer balancing strategy for bursty mixed workloads without hurting tail latency.",
233+
title: "Make the OOM killer explain itself",
234+
branch: "feat/quieter-oom",
235+
minutesAgo: 2 * 24 * 60,
236+
settled: true,
237+
request: "Make out-of-memory kills legible without adding a single allocation to the hot path.",
212238
response:
213-
"The new heuristic reduces needless migrations during short bursts while preserving the existing latency guardrails.",
239+
"Kills now report the winning heuristic and the runner-up alongside the usual dump, assembled entirely from data the path already had.",
214240
},
215241
] as const;
216242

@@ -300,6 +326,7 @@ function insertThread(
300326
readonly branch: string;
301327
readonly minutesAgo: number;
302328
readonly state?: "working" | "approval" | "plan";
329+
readonly settled?: boolean;
303330
readonly workspaceRoot: string;
304331
},
305332
): void {
@@ -312,8 +339,8 @@ function insertThread(
312339
thread_id, project_id, title, model_selection_json, runtime_mode, interaction_mode,
313340
branch, worktree_path, latest_turn_id, latest_user_message_at, pending_approval_count,
314341
pending_user_input_count, has_actionable_proposed_plan, created_at, updated_at,
315-
archived_at, deleted_at
316-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, NULL, NULL)`,
342+
archived_at, deleted_at, settled_override, settled_at
343+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, NULL, NULL, ?, ?)`,
317344
)
318345
.run(
319346
input.id,
@@ -330,6 +357,8 @@ function insertThread(
330357
input.state === "plan" ? 1 : 0,
331358
minutesBefore(now, input.minutesAgo + 120),
332359
updatedAt,
360+
input.settled ? "settled" : null,
361+
input.settled ? updatedAt : null,
333362
);
334363
database
335364
.prepare(
@@ -365,7 +394,11 @@ function seedDatabase(
365394
threads: ReadonlyArray<(typeof SHOWCASE_THREADS)[number]>,
366395
now: number,
367396
): void {
368-
const database = new NodeSqlite.DatabaseSync(dbPath);
397+
// The environment server is already running against this file and keeps
398+
// writing (migrations, projections) while we seed, so the write lock is
399+
// genuinely contended — without a busy timeout `BEGIN IMMEDIATE` fails
400+
// instantly with SQLITE_BUSY on a loaded machine.
401+
const database = new NodeSqlite.DatabaseSync(dbPath, { timeout: 30_000 });
369402
try {
370403
database.exec("BEGIN IMMEDIATE");
371404
for (const table of [
@@ -506,7 +539,14 @@ function seedDatabase(
506539
}
507540
database.exec("COMMIT");
508541
} catch (error) {
509-
database.exec("ROLLBACK");
542+
// A failed BEGIN (or an error SQLite already auto-rolled back) leaves no
543+
// transaction, and the rollback's own "cannot rollback" error would then
544+
// replace the one that actually explains the failure.
545+
try {
546+
database.exec("ROLLBACK");
547+
} catch {
548+
// Nothing to roll back.
549+
}
510550
throw error;
511551
} finally {
512552
database.close();

‎scripts/mobile-showcase.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,23 @@ it("seeds a playful multi-environment project spectrum", () => {
272272
SHOWCASE_ENVIRONMENTS.map((environment) => environment.label),
273273
["Moonbase Terminal", "Suspense Station", "Kernel Cabin"],
274274
);
275-
assert.equal(SHOWCASE_THREADS.length, 6);
275+
assert.equal(SHOWCASE_THREADS.length, 8);
276276
assert.equal(new Set(SHOWCASE_THREADS.map((thread) => thread.projectId)).size, 3);
277+
// Every project contributes to both the active block and the settled tail,
278+
// so each list scope screenshots with the same two-part structure.
279+
for (const project of SHOWCASE_PROJECTS) {
280+
const projectThreads = SHOWCASE_THREADS.filter((thread) => thread.projectId === project.id);
281+
assert.equal(
282+
projectThreads.some((thread) => "settled" in thread && thread.settled),
283+
true,
284+
`${project.title} has no settled thread`,
285+
);
286+
assert.equal(
287+
projectThreads.some((thread) => !("settled" in thread && thread.settled)),
288+
true,
289+
`${project.title} has no active thread`,
290+
);
291+
}
277292
assert.equal(
278293
SHOWCASE_PROJECTS.every((project) => project.favicon.includes("<svg")),
279294
true,

0 commit comments

Comments
 (0)