Sidebar v2 beta: flat thread list with a server-backed settled lifecycle #4026
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 46 commits into
main fromrefs/pull/4026/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/web/src/components/SidebarV2.tsx line 1044Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +914,21 @@914+ [settleThread],915+ );916+ const attemptUnsettle = useCallback(917+ (threadRef: ScopedThreadRef) => {918+ void (async () => {919+ const result = await unsettleThread(threadRef);920+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {921+ const error = squashAtomCommandFailure(result);922+ toastManager.add(923+ stackedThreadToast({924+ type: "error",925+ title: "Failed to un-settle thread",926+ description: error instanceof Error ? error.message : "An error occurred.",927+ }),928+ );929+ return;930+ }931+ refreshArchivedThreadsForEnvironment(threadRef.environmentId);932+ })();933+ },934+ [unsettleThread],apps/web/src/components/SidebarV2.tsx line 914OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +894,21 @@894+ const attemptSettle = useCallback(895+ (threadRef: ScopedThreadRef) => {896+ void (async () => {897+ const result = await settleThread(threadRef);898+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {899+ const error = squashAtomCommandFailure(result);900+ toastManager.add(901+ stackedThreadToast({902+ type: "error",903+ title: "Failed to settle thread",904+ description: error instanceof Error ? error.message : "An error occurred.",905+ }),906+ );907+ return;908+ }909+ // Settle = archive: the shell stream drops the thread, so pull the910+ // archived snapshot immediately to keep it visible as a settled row.911+ refreshArchivedThreadsForEnvironment(threadRef.environmentId);912+ })();913+ },914+ [settleThread],apps/mobile/src/features/threads/threadListV2.ts line 82OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +62,21 @@62+ readonly threads: ReadonlyArray<EnvironmentThreadShell>;63+ readonly environmentId: EnvironmentId | null;64+ readonly searchQuery: string;65+ readonly autoSettleAfterDays?: number;66+ /** Injectable for tests; defaults to now. */67+ readonly now?: string;68+}): ThreadListV2Item[] {69+ const now = input.now ?? new Date().toISOString();70+ const autoSettleAfterDays = input.autoSettleAfterDays ?? 3;71+ const query = input.searchQuery.trim().toLocaleLowerCase();72+73+ const active: EnvironmentThreadShell[] = [];74+ const settled: EnvironmentThreadShell[] = [];75+ for (const thread of input.threads) {76+ // Archived threads stay in the list: in the client-only settled model,77+ // archive IS settle, so they render as the settled tail.78+ if (input.environmentId !== null && thread.environmentId !== input.environmentId) continue;79+ if (query.length > 0 && !thread.title.toLocaleLowerCase().includes(query)) continue;80+ // PR state feeds the web partition per-row; mobile shells don't watch PRs81+ // from the list, so the partition here is archive/session/inactivity.82+ if (effectiveSettled(thread, { now, autoSettleAfterDays, changeRequestState: null })) {apps/web/src/components/SidebarV2.tsx line 731OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +711,21 @@711+ // (thread.archived → thread-removed). Merge them back in from the archived712+ // snapshot query; live shells win on the (brief) overlap.713+ const archivedEnvironmentIds = useMemo(714+ () => environments.map((environment) => environment.environmentId),715+ [environments],716+ );717+ const { snapshots: archivedSnapshots } = useArchivedThreadSnapshots(archivedEnvironmentIds);718+ const allThreads = useMemo(() => {719+ const liveKeys = new Set(720+ threads.map((thread) => scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))),721+ );722+ const archived = archivedSnapshots.flatMap(({ environmentId, snapshot }) =>723+ snapshot.threads724+ .map((thread) => ({ ...thread, environmentId }))725+ .filter(726+ (thread) =>727+ !liveKeys.has(scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))),728+ ),729+ );730+ return [...threads, ...archived];731+ }, [archivedSnapshots, threads]);
- apps/mobile/src/features/threads/thread-list-v2-items.tsx line 294Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +304,21 @@304+ size={18}305+ projectTitle={props.project.title}306+ workspaceRoot={props.project.workspaceRoot}307+ />308+ </View>309+ ) : null}310+ <Text className="flex-1 text-lg text-foreground-muted" numberOfLines={1}>311+ {thread.title}312+ </Text>313+ <Text314+ className="text-sm tabular-nums text-foreground-tertiary"315+ style={{ fontFamily: MONO_FONT }}316+ >317+ {relativeTime(thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt)}318+ </Text>319+ </View>320+ </Pressable>321+ );322+323+ return (324+ <>apps/web/src/components/SidebarV2.tsx line 413OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +393,21 @@393+ <span394+ className={cn(395+ "shrink-0 transition-opacity",396+ !props.isActive &&397+ "opacity-40 grayscale group-hover/v2-row:opacity-100 group-hover/v2-row:grayscale-0",398+ )}399+ >400+ <ProjectFavicon401+ environmentId={thread.environmentId}402+ cwd={props.projectCwd ?? ""}403+ className="size-3.5"404+ />405+ </span>406+ {title}407+ {prBadge}408+ <span className="relative flex h-6 w-14 shrink-0 items-center justify-end">409+ <span className="font-mono text-[11px] tabular-nums text-muted-foreground/40 transition-opacity group-hover/v2-row:opacity-0">410+ {props.jumpLabel ??411+ formatRelativeTimeLabel(thread.latestUserMessageAt ?? thread.updatedAt)}412+ </span>413+ {variantAction === "unsettle" ? (apps/web/src/hooks/useThreadActions.ts line 385Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -345,3 +357,5 @@345357 ],346358 );347359360+ const settleThread = useCallback(361+ async (target: ScopedThreadRef) => {apps/web/src/hooks/useThreadActions.ts line 422Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -347,0 +466,21 @@466+ description:467+ error instanceof Error ? error.message : "Could not remove the worktree.",468+ }),469+ );470+ return;471+ }472+ await refreshVcsStatus({473+ environmentId: threadRef.environmentId,474+ input: { cwd: threadProject.workspaceRoot },475+ });476+ })();477+ },478+ },479+ }),480+ );481+ return settleResult;482+ },483+ [refreshVcsStatus, removeWorktree, resolveThreadTarget, settleThreadMutation],484+ );485+486+ const unsettleThread = useCallback(
- apps/web/src/hooks/useThreadActions.ts line 422OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -347,0 +402,21 @@402+ title: "Thread settled",403+ description: `Worktree ${displayWorktreePath} is no longer used by any thread.`,404+ actionProps: {405+ children: "Remove worktree",406+ onClick: () => {407+ void (async () => {408+ // Re-validate at click time: the toast may be stale — the409+ // thread can have woken up or another thread adopted the410+ // worktree since the settle happened.411+ const currentShell = readThreadShell(threadRef);412+ const currentThreads = readEnvironmentThreadRefs(threadRef.environmentId).flatMap(413+ (ref) => {414+ const shell = readThreadShell(ref);415+ return shell === null ? [] : [shell];416+ },417+ );418+ const stillOrphaned =419+ getOrphanedWorktreePathForThread(currentThreads, threadRef.threadId) ===420+ orphanedWorktreePath;421+ const stillSettled = currentShell?.archivedAt != null;422+ if (!stillOrphaned || !stillSettled) {apps/web/src/hooks/useThreadActions.ts line 417Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -345,3 +357,10 @@345357 ],346358 );347359360+ const settleThread = useCallback(361+ async (target: ScopedThreadRef) => {362+ const resolved = resolveThreadTarget(target);363+ const settleResult = await settleThreadMutation({364+ environmentId: target.environmentId,365+ input: { threadId: target.threadId },366+ });apps/web/src/components/AppSidebarLayout.tsx line 108Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -55,3 +57,9 @@55575658 export function AppSidebarLayout({ children }: { children: ReactNode }) {5759 const navigate = useNavigate();60+ const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);61+ // Settings routes render the settings nav, which lives in the v1 component62+ // and is identical for both sidebars — so v1 stays mounted there.63+ const pathname = useLocation({ select: (location) => location.pathname });64+ const isOnSettings = pathname === "/settings" || pathname.startsWith("/settings/");65+ const useSidebarV2 = sidebarV2Enabled && !isOnSettings;
- apps/mobile/src/features/home/HomeScreen.tsx line 792Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -440,3 +599,9 @@440599 )441600 ) : null;442601602+ if (threadListV2Enabled) {603+ return (604+ <View className="flex-1 bg-screen">605+ <SwipeableScrollGateProvider enabled={swipeEnabled}>606+ <LegendList607+ data={threadListV2Items}apps/mobile/src/features/home/HomeScreen.tsx line 416Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -269,0 +304,21 @@304+ setChangeRequestStateByKey((current) => {305+ if ((current.get(threadKey) ?? null) === state) return current;306+ const next = new Map(current);307+ if (state === null) {308+ next.delete(threadKey);309+ } else {310+ next.set(threadKey, state);311+ }312+ return next;313+ });314+ },315+ [],316+ );317+ // Bridge the gap between the live stream dropping a just-settled thread318+ // and the archived snapshot returning it: hold the shell we settled,319+ // marked archived, until the snapshot carries it. Held explicitly at320+ // settle time so deleted threads are never resurrected.321+ const [settledHolds, setSettledHolds] = useState<ReadonlyMap<string, EnvironmentThreadShell>>(322+ () => new Map(),323+ );324+ const handleSettleThread = useCallback(
- apps/mobile/src/features/home/HomeScreen.tsx line 421OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -269,0 +315,21 @@315+ [],316+ );317+ // Bridge the gap between the live stream dropping a just-settled thread318+ // and the archived snapshot returning it: hold the shell we settled,319+ // marked archived, until the snapshot carries it. Held explicitly at320+ // settle time so deleted threads are never resurrected.321+ const [settledHolds, setSettledHolds] = useState<ReadonlyMap<string, EnvironmentThreadShell>>(322+ () => new Map(),323+ );324+ const handleSettleThread = useCallback(325+ (thread: EnvironmentThreadShell) => {326+ setSettledHolds((current) =>327+ new Map(current).set(scopedThreadKey(thread.environmentId, thread.id), {328+ ...thread,329+ archivedAt: thread.archivedAt ?? new Date().toISOString(),330+ }),331+ );332+ props.onSettleThread(thread);333+ },334+ [props.onSettleThread],335+ );apps/mobile/src/features/home/HomeScreen.tsx line 415Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -269,0 +296,21 @@296+ const { snapshots: archivedSnapshots } = useArchivedThreadSnapshots(archivedEnvironmentIds);297+ // PR states stream in per-row (rows own the VCS subscriptions); a merged or298+ // closed PR auto-settles its thread on the next partition (mirrors web).299+ const [changeRequestStateByKey, setChangeRequestStateByKey] = useState<300+ ReadonlyMap<string, "open" | "closed" | "merged">301+ >(() => new Map());302+ const handleChangeRequestState = useCallback(303+ (threadKey: string, state: "open" | "closed" | "merged" | null) => {304+ setChangeRequestStateByKey((current) => {305+ if ((current.get(threadKey) ?? null) === state) return current;306+ const next = new Map(current);307+ if (state === null) {308+ next.delete(threadKey);309+ } else {310+ next.set(threadKey, state);311+ }312+ return next;313+ });314+ },315+ [],316+ );apps/mobile/src/features/home/useThreadListActions.ts line 108OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -49,3 +62,21 @@4962 inFlightThreadKeys.current.add(key);5063 selectionHaptic();5164 try {65+ // Settle rides archive, so it inherits archive's guard: never66+ // interrupt a thread mid-turn.67+ if (68+ (action === "settle" || action === "archive") &&69+ thread.session?.status === "running" &&70+ thread.session.activeTurnId != null71+ ) {72+ Alert.alert(73+ actionFailureTitle(action),74+ "This thread is working. Interrupt it first, then try again.",75+ );76+ return;77+ }78+ // Auto-settled rows (inactivity / merged PR) are not archived;79+ // unarchiving them would be rejected. Nothing to undo — no-op.80+ if (action === "unsettle" && thread.archivedAt === null) {81+ return;82+ }apps/web/src/hooks/useThreadActions.ts line 433Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -347,0 +490,21 @@490+ input: { cwd: threadProject.workspaceRoot },491+ });492+ })();493+ },494+ },495+ }),496+ );497+ return settleResult;498+ },499+ [refreshVcsStatus, removeWorktree, resolveThreadTarget, settleThreadMutation],500+ );501+502+ const unsettleThread = useCallback(503+ async (target: ScopedThreadRef) => {504+ // Auto-settled rows (inactivity / merged PR) are not archived; sending505+ // unarchive for them would be rejected by the server. There is nothing506+ // to undo client-side, so succeed as a no-op.507+ const resolved = resolveThreadTarget(target);508+ if (resolved && resolved.thread.archivedAt === null) {509+ return AsyncResult.success(undefined);510+ }
- apps/mobile/src/features/threads/thread-list-v2-items.tsx lines 317 to 317OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +297,21 @@297+ </Text>298+ ) : null}299+ </View>300+ ) : null}301+ </View>302+ {/* Trailing chevron: the universal "this navigates" affordance. */}303+ <View className="pr-3.5">304+ <SymbolView305+ name="chevron.right"306+ size={14}307+ tintColor={iconSubtleColor}308+ type="monochrome"309+ weight="semibold"310+ />311+ </View>312+ </View>313+ </View>314+ </PressableScaleCard>315+ ) : (316+ <Pressable317+ accessibilityHint="Opens the thread. Swipe left to un-settle."
- @@ -347,0 +423,21 @@423+ type: "info",424+ title: "Thread settled",425+ description: `Worktree ${displayWorktreePath} is no longer used by any thread.`,426+ actionProps: {427+ children: "Remove worktree",428+ onClick: () => {429+ void (async () => {430+ // Re-validate at click time: the toast may be stale — the431+ // thread can have woken up or another thread adopted the432+ // worktree since the settle happened.433+ const currentShell = readThreadShell(threadRef);434+ const currentLiveThreads = readEnvironmentThreadRefs(435+ threadRef.environmentId,436+ ).flatMap((ref) => {437+ const shell = readThreadShell(ref);438+ return shell === null ? [] : [shell];439+ });440+ // Archived threads leave the live store entirely, so absence441+ // IS the settled state; a live shell means it woke back up442+ // (unarchive puts it back in the stream).443+ const stillSettled = currentShell === null || currentShell.archivedAt != null;
- @@ -269,0 +324,21 @@324+ );325+ const handleSettleThread = useCallback(326+ (thread: EnvironmentThreadShell) => {327+ const threadKey = scopedThreadKey(thread.environmentId, thread.id);328+ setSettledHolds((current) =>329+ new Map(current).set(threadKey, {330+ ...thread,331+ archivedAt: thread.archivedAt ?? new Date().toISOString(),332+ }),333+ );334+ void (async () => {335+ // Roll the optimistic hold back if the settle was blocked or failed —336+ // otherwise a never-archived thread would render settled forever.337+ const succeeded = await props.onSettleThread(thread);338+ if (!succeeded) {339+ setSettledHolds((current) => {340+ const next = new Map(current);341+ next.delete(threadKey);342+ return next;343+ });344+ }
- apps/web/src/components/SidebarV2.tsx line 1010OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +990,21 @@990+ const result = await settleThread(threadRef);991+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {992+ setSettledHolds((current) => {993+ const next = new Map(current);994+ next.delete(threadKey);995+ return next;996+ });997+ const error = squashAtomCommandFailure(result);998+ toastManager.add(999+ stackedThreadToast({1000+ type: "error",1001+ title: "Failed to settle thread",1002+ description: error instanceof Error ? error.message : "An error occurred.",1003+ }),1004+ );1005+ return;1006+ }1007+ // Settle = archive: the shell stream drops the thread, so pull the1008+ // archived snapshot immediately to keep it visible as a settled row.1009+ refreshArchivedThreadsForEnvironment(threadRef.environmentId);1010+ navigateAfterSettle?.();apps/web/src/components/SidebarV2.tsx line 1010OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +990,21 @@990+ const result = await settleThread(threadRef);991+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {992+ setSettledHolds((current) => {993+ const next = new Map(current);994+ next.delete(threadKey);995+ return next;996+ });997+ const error = squashAtomCommandFailure(result);998+ toastManager.add(999+ stackedThreadToast({1000+ type: "error",1001+ title: "Failed to settle thread",1002+ description: error instanceof Error ? error.message : "An error occurred.",1003+ }),1004+ );1005+ return;1006+ }1007+ // Settle = archive: the shell stream drops the thread, so pull the1008+ // archived snapshot immediately to keep it visible as a settled row.1009+ refreshArchivedThreadsForEnvironment(threadRef.environmentId);1010+ navigateAfterSettle?.();apps/web/src/components/SidebarV2.tsx line 988OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +968,21 @@968+ }969+ // Settling the thread you're looking at moves you forward: the next970+ // remaining card (never a settled row), or the new-thread screen971+ // when this was the last active one. Snapshot the target before the972+ // settle mutates the partition. Background settles never navigate.973+ let navigateAfterSettle: (() => void) | null = null;974+ if (routeThreadKey === threadKey) {975+ const orderedKeys = orderedThreadKeysRef.current;976+ const settledKeys = settledThreadKeysRef.current;977+ const currentIndex = orderedKeys.indexOf(threadKey);978+ const nextCardKey =979+ currentIndex === -1980+ ? null981+ : ([982+ ...orderedKeys.slice(currentIndex + 1),983+ ...orderedKeys.slice(0, currentIndex),984+ ].find((key) => !settledKeys.has(key)) ?? null);985+ const nextThread = nextCardKey ? threadByKeyRef.current.get(nextCardKey) : null;986+ navigateAfterSettle = nextThread987+ ? () => navigateToThread(scopeThreadRef(nextThread.environmentId, nextThread.id))988+ : () => void router.navigate({ to: "/" });
- apps/mobile/src/features/threads/threadListV2.ts line 145Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +84,21 @@84+ const settled: EnvironmentThreadShell[] = [];85+ for (const thread of input.threads) {86+ // Archived threads stay in the list: in the client-only settled model,87+ // archive IS settle, so they render as the settled tail.88+ if (input.environmentId !== null && thread.environmentId !== input.environmentId) continue;89+ if (query.length > 0 && !thread.title.toLocaleLowerCase().includes(query)) continue;90+ const changeRequestState =91+ input.changeRequestStateByKey?.get(`${thread.environmentId}:${thread.id}`) ?? null;92+ if (effectiveSettled(thread, { now, autoSettleAfterDays, changeRequestState })) {93+ settled.push(thread);94+ } else {95+ active.push(thread);96+ }97+ }98+99+ const orderedActive = sortThreadsForListV2(active);100+ const orderedSettled = [...settled].sort(101+ (left, right) =>102+ Date.parse(right.latestUserMessageAt ?? right.updatedAt) -103+ Date.parse(left.latestUserMessageAt ?? left.updatedAt),104+ );apps/web/src/components/Sidebar.logic.ts line 482Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -419,0 +432,21 @@432+ }433+ if (thread.session?.status === "running" || thread.session?.status === "starting") {434+ return "working";435+ }436+ if (thread.session?.status === "error") {437+ return "failed";438+ }439+ return "ready";440+}441+442+// v2 sort: static creation order, newest thread on top. Activity NEVER443+// reorders the list — a row holds its position from open until settled, so444+// the screen only moves at lifecycle transitions. Status (including pending445+// approval) is carried by each card's edge strip, not by position.446+export function sortThreadsForSidebarV2<447+ T extends { readonly id: string; readonly createdAt: string },448+>(threads: readonly T[]): T[] {449+ return [...threads].toSorted(450+ (left, right) =>451+ Date.parse(right.createdAt) - Date.parse(left.createdAt) || left.id.localeCompare(right.id),452+ );
- apps/mobile/src/features/home/HomeScreen.tsx line 734Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -436,3 +662,7 @@436662 </>437663 );438664665+ // v2 renders queued offline tasks above the thread cards — they are not666+ // thread shells, so the v2 item builder never sees them, but they must667+ // stay visible and deletable while their environment is offline.668+ const v2ListHeader = (
- apps/mobile/src/features/home/HomeScreen.tsx line 599OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -360,5 +591,9 @@360591 const keyExtractor = useCallback((item: HomeListItem) => item.key, []);361592362593 /* Empty states */594+ // v2 shows archived threads as its settled tail, so an archived-only595+ // workspace still has a list to render there.363596 const hasAnyThreads =364- props.threads.some((thread) => thread.archivedAt === null) || props.pendingTasks.length > 0;597+ props.threads.some((thread) => thread.archivedAt === null) ||598+ props.pendingTasks.length > 0 ||599+ (threadListV2Enabled && threadListV2Items.length > 0);apps/web/src/components/SidebarV2.tsx line 800OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +780,21 @@780+ scopedProject === null ||781+ (thread.environmentId === scopedProject.environmentId &&782+ thread.projectId === scopedProject.id),783+ );784+ const active: EnvironmentThreadShell[] = [];785+ const settled: EnvironmentThreadShell[] = [];786+ for (const thread of visible) {787+ const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));788+ const changeRequestState = changeRequestStateByKey.get(threadKey) ?? null;789+ if (effectiveSettled(thread, { now, autoSettleAfterDays, changeRequestState })) {790+ settled.push(thread);791+ } else {792+ active.push(thread);793+ }794+ }795+ return {796+ activeThreads: sortThreadsForSidebarV2(active),797+ settledThreads: settled.toSorted(798+ (left, right) =>799+ parseTimestampMs(right.latestUserMessageAt ?? right.updatedAt) -800+ parseTimestampMs(left.latestUserMessageAt ?? left.updatedAt),
- apps/web/src/components/SidebarV2.tsx line 1078Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1110,21 @@1110+ const api = readLocalApi();1111+ if (!api) return;1112+ const threadKeys = [...useThreadSelectionStore.getState().selectedThreadKeys];1113+ if (threadKeys.length === 0) return;1114+ const count = threadKeys.length;1115+ const clicked = await settlePromise(() =>1116+ api.contextMenu.show(1117+ [1118+ { id: "settle", label: `Settle (${count})` },1119+ { id: "mark-unread", label: `Mark unread (${count})` },1120+ { id: "delete", label: `Delete (${count})`, destructive: true },1121+ ],1122+ position,1123+ ),1124+ );1125+ if (clicked._tag === "Failure") return;1126+ if (clicked.value === "settle") {1127+ // Post-settle navigation must skip threads settling in this same1128+ // batch — they are all leaving the card block together.1129+ const coSettlingKeys = new Set(threadKeys);1130+ for (const threadKey of threadKeys) {
- apps/mobile/src/features/home/HomeScreen.tsx line 603OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -360,5 +591,13 @@360591 const keyExtractor = useCallback((item: HomeListItem) => item.key, []);361592362593 /* Empty states */594+ // v2 shows archived threads as its settled tail, so an archived-only595+ // workspace still has a list to render there. The signal must ignore the596+ // search/environment filters: an active query that matches nothing needs597+ // the in-list "No results" state, not the full-page "No threads yet".363598 const hasAnyThreads =364- props.threads.some((thread) => thread.archivedAt === null) || props.pendingTasks.length > 0;599+ props.threads.some((thread) => thread.archivedAt === null) ||600+ props.pendingTasks.length > 0 ||601+ (threadListV2Enabled &&602+ (props.threads.length > 0 ||603+ archivedSnapshots.some(({ snapshot }) => snapshot.threads.length > 0)));
t3dotgg(GitHub profile, opens in a new tab) changed the title
- apps/mobile/src/features/threads/thread-list-v2-items.tsx line 175Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +219,21 @@219+ return canUnsettle220+ ? {221+ accessibilityLabel: `Un-settle ${thread.title}`,222+ icon: "arrow.uturn.backward" as const,223+ label: "Un-settle",224+ onPress: handleUnsettle,225+ }226+ : {227+ accessibilityLabel: `Settle ${thread.title}`,228+ icon: "checkmark" as const,229+ label: "Settle",230+ onPress: handleSettle,231+ };232+ }, [233+ canUnsettle,234+ handleArchive,235+ handleSettle,236+ handleUnsettle,237+ props.settlementSupported,238+ thread.title,239+ ]);
- packages/client-runtime/src/state/threadSettled.ts line 106OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +86,21 @@86+ return true;87+}88+89+/**90+ * Settled resolution over the server-backed settled lifecycle. The explicit91+ * user override (thread.settle / thread.unsettle commands, projected into92+ * settledOverride + settledAt) wins in both directions; without one, a93+ * thread auto-settles on a merged/closed PR or inactivity past the window.94+ * The server un-settles on real activity (user message, session start,95+ * approval/user-input request), so an override never goes stale silently.96+ */97+export function effectiveSettled(98+ shell: OrchestrationThreadShell,99+ options: {100+ readonly now: string;101+ readonly autoSettleAfterDays: number | null;102+ readonly changeRequestState?: ChangeRequestStateLike | null;103+ },104+): boolean {105+ // Blocked work must remain visible even when a user explicitly settled it.106+ if (!canSettle(shell, { now: options.now })) return false;
- apps/web/src/components/SidebarV2.tsx line 1114Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1078,21 @@1078+ }1079+ clearSelection();1080+ return;1081+ }1082+ if (clicked.value !== "delete") return;1083+ if (confirmThreadDelete) {1084+ const confirmed = await settlePromise(() =>1085+ api.dialogs.confirm(1086+ [1087+ `Delete ${count} thread${count === 1 ? "" : "s"}?`,1088+ "This permanently clears conversation history for these threads.",1089+ ].join("\n"),1090+ ),1091+ );1092+ if (confirmed._tag === "Failure" || !confirmed.value) return;1093+ }1094+ const deletedThreadKeys = new Set(threadKeys);1095+ for (const threadKey of threadKeys) {1096+ const thread = threadByKeyRef.current.get(threadKey);1097+ if (!thread) continue;1098+ const result = await deleteThread(scopeThreadRef(thread.environmentId, thread.id), {
- @@ -452,0 +480,21 @@480+ --accent-foreground: oklch(0.24 0.012 265);481+ --muted: oklch(0.9 0.018 265);482+ --muted-foreground: oklch(0.49 0.03 265);483+ --border: oklch(0.72 0.025 265 / 28%);484+ --input: oklch(0.62 0.03 265 / 28%);485+ --sidebar-stage-fade: var(--card);486+ background-color: var(--card);487+}488+489+.dark .app-sidebar {490+ --background: #000;491+ --foreground: #f1f3f7;492+ --card: #000;493+ --card-foreground: var(--foreground);494+ --accent: #191a1d;495+ --accent-foreground: #f7f9ff;496+ --muted: #0a0a0a;497+ --muted-foreground: #a3a3a3;498+ --border: rgb(255 255 255 / 14%);499+ --input: rgb(255 255 255 / 18%);500+}apps/web/src/components/SidebarV2.tsx line 573Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +549,21 @@549+ Settle550+ </button>551+ ) : null}552+ </span>553+ </div>554+ <div className="mt-1 flex min-w-0">{title}</div>555+ <div className="mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground/65">556+ {thread.branch ? (557+ <span className="min-w-0 flex-1 overflow-hidden whitespace-nowrap font-mono [mask-image:linear-gradient(to_right,#000_0,#000_calc(100%-1rem),transparent_100%)] [-webkit-mask-image:linear-gradient(to_right,#000_0,#000_calc(100%-1rem),transparent_100%)]">558+ {thread.branch}559+ </span>560+ ) : (561+ <span className="flex-1" />562+ )}563+ {prBadge}564+ {diff ? (565+ <span className="shrink-0 font-mono">566+ <span className="text-emerald-600 dark:text-emerald-400">+{diff.insertions}</span>{" "}567+ <span className="text-red-600 dark:text-red-400">−{diff.deletions}</span>568+ </span>569+ ) : null}
- apps/server/src/orchestration/decider.ts line 80Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -26,0 +36,21 @@36+ * hasPendingUserInput flags, which the decider read model does not carry.37+ */38+function hasOpenBlockingRequest(thread: {39+ readonly activities: ReadonlyArray<{ readonly kind: string; readonly payload: unknown }>;40+}): boolean {41+ const openRequestIds = new Set<string>();42+ for (const activity of thread.activities) {43+ const payload =44+ typeof activity.payload === "object" && activity.payload !== null45+ ? (activity.payload as Record<string, unknown>)46+ : null;47+ const requestId = typeof payload?.requestId === "string" ? payload.requestId : null;48+ if (requestId === null) continue;49+ if (activity.kind === "approval.requested" || activity.kind === "user-input.requested") {50+ openRequestIds.add(requestId);51+ } else if (activity.kind === "approval.resolved" || activity.kind === "user-input.resolved") {52+ openRequestIds.delete(requestId);53+ }54+ }55+ return openRequestIds.size > 0;56+}
- apps/server/src/orchestration/decider.ts lines 421 to 422OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -329,0 +402,21 @@402+ (latest, message) =>403+ message.role === "user" ? Math.max(latest, Date.parse(message.createdAt)) : latest,404+ Number.NEGATIVE_INFINITY,405+ );406+ const latestTurnAtMs =407+ thread.latestTurn === null408+ ? Number.NEGATIVE_INFINITY409+ : Math.max(410+ ...[411+ thread.latestTurn.requestedAt,412+ thread.latestTurn.startedAt,413+ thread.latestTurn.completedAt,414+ ].map((candidate) =>415+ candidate == null ? Number.NEGATIVE_INFINITY : Date.parse(candidate),416+ ),417+ );418+ const hasQueuedTurnStart =419+ thread.session?.status !== "error" &&420+ Number.isFinite(latestUserMessageAtMs) &&421+ latestUserMessageAtMs > latestTurnAtMs &&422+ Date.parse(occurredAt) - latestUserMessageAtMs <= QUEUED_TURN_START_GRACE_MS;apps/server/src/orchestration/decider.ts lines 67 to 77Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -26,0 +33,21 @@33+ * Blocked-on-you work derived from the thread's retained activities: an34+ * approval or user-input request with no later resolution for the same35+ * requestId. The server-side twin of the shell's hasPendingApprovals /36+ * hasPendingUserInput flags, which the decider read model does not carry.37+ */38+function hasOpenBlockingRequest(thread: {39+ readonly activities: ReadonlyArray<{ readonly kind: string; readonly payload: unknown }>;40+}): boolean {41+ const openRequestIds = new Set<string>();42+ for (const activity of thread.activities) {43+ const payload =44+ typeof activity.payload === "object" && activity.payload !== null45+ ? (activity.payload as Record<string, unknown>)46+ : null;47+ const requestId = typeof payload?.requestId === "string" ? payload.requestId : null;48+ if (requestId === null) continue;49+ if (activity.kind === "approval.requested" || activity.kind === "user-input.requested") {50+ openRequestIds.add(requestId);51+ } else if (activity.kind === "approval.resolved" || activity.kind === "user-input.resolved") {52+ openRequestIds.delete(requestId);53+ }
- apps/mobile/src/features/home/HomeScreen.tsx line 785Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -448,3 +767,12 @@448767 <EmptyState title="No threads yet" detail="Create a task to start a new coding session." />449768 )450769 ) : null;770+ const v2ListEmpty =771+ threadListV2Items.length === 0 && v2PendingTasks.length === 0 && v2ScopedProject !== null ? (772+ <EmptyState773+ title={`No threads in ${v2ScopedProject.title}`}774+ detail="Choose another project or create a new task."775+ />776+ ) : (777+ listEmpty778+ );
- @@ -0,0 +22,21 @@22+ useEffect(() => {23+ setDraft(String(value));24+ }, [value]);25+26+ return (27+ <Input28+ type="number"29+ min={AUTO_SETTLE_MIN_DAYS}30+ max={AUTO_SETTLE_MAX_DAYS}31+ className="w-full sm:w-24"32+ value={draft}33+ onChange={(event) => {34+ setDraft(event.target.value);35+ const parsed = Number.parseInt(event.target.value, 10);36+ if (37+ Number.isFinite(parsed) &&38+ parsed >= AUTO_SETTLE_MIN_DAYS &&39+ parsed <= AUTO_SETTLE_MAX_DAYS40+ ) {41+ onCommit(parsed);42+ }
juliusmarminge added labels🚀 Mobile Continuous Deployment
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.