From c68e9fa23cfc9eed4c0377ddd64de19f1c387924 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Thu, 23 Jul 2026 22:25:20 -0700 Subject: [PATCH] Address cursor round-3 review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Group sweep cards and resolve project titles by scoped (environmentId, projectId) key — bare project ids can collide across connected environments. - Withdraw a settle recommendation from the card when the apply-time canSettle guard refuses it, instead of leaving a CTA the guard will keep rejecting. - Document why summarizeThread's two projection reads are ordered transcript-then-shell: reading the activity view last catches sessions that start mid-read, and the reverse skew only affects summary staleness — settles are re-validated at apply time and by the decider, so no consistency window can settle live work. Co-Authored-By: Claude Fable 5 --- apps/server/src/review/ReviewService.ts | 6 ++++ .../reviewSweep/ReviewSweepView.tsx | 29 ++++++++++++------- apps/web/src/reviewSweepStore.ts | 5 ++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/apps/server/src/review/ReviewService.ts b/apps/server/src/review/ReviewService.ts index a79e6729ba..c1a66d5e9e 100644 --- a/apps/server/src/review/ReviewService.ts +++ b/apps/server/src/review/ReviewService.ts @@ -203,6 +203,12 @@ export const make = Effect.gen(function* () { // Never trust the client's canSettleNow alone: re-derive activity from the // server's own projection so a session that started (or approval/input // that appeared) after the client read its shell still blocks settling. + // The shell is deliberately read AFTER the transcript: the two reads are + // separate transactions, and reading the activity view last means a + // session starting in between is still caught. The reverse skew (activity + // ending in between) only staleness-affects the summary text — an actual + // settle is re-validated by the client at apply time and by the decider's + // thread.settle guards, so a recommendation can never settle live work. const shellOption = yield* projectionSnapshotQuery .getThreadShellById(input.threadId) .pipe(Effect.mapError(mapProjectionError)); diff --git a/apps/web/src/components/reviewSweep/ReviewSweepView.tsx b/apps/web/src/components/reviewSweep/ReviewSweepView.tsx index 7fd948e83a..95f9b92b0f 100644 --- a/apps/web/src/components/reviewSweep/ReviewSweepView.tsx +++ b/apps/web/src/components/reviewSweep/ReviewSweepView.tsx @@ -1,5 +1,8 @@ -import { scopedThreadKey } from "@t3tools/client-runtime/environment"; -import type { ProjectId } from "@t3tools/contracts"; +import { + scopedProjectKey, + scopedThreadKey, + scopeProjectRef, +} from "@t3tools/client-runtime/environment"; import { Link } from "@tanstack/react-router"; import { ArrowRightIcon, ListChecksIcon, RotateCcwIcon, XIcon } from "lucide-react"; import { useMemo, useState } from "react"; @@ -255,10 +258,15 @@ export function ReviewSweepView() { const truncatedCount = useReviewSweepStore((state) => state.truncatedCount); const projects = useProjects(); + // Projects are only unique per (environmentId, projectId) — ids can + // collide across connected environments. const projectTitles = useMemo(() => { - const titles = new Map(); + const titles = new Map(); for (const project of projects) { - titles.set(project.id, project.title); + titles.set( + scopedProjectKey(scopeProjectRef(project.environmentId, project.id)), + project.title, + ); } return titles; }, [projects]); @@ -271,13 +279,14 @@ export function ReviewSweepView() { [items, order], ); const groups = useMemo(() => { - const byProject = new Map(); + const byProject = new Map(); for (const item of visibleItems) { - const group = byProject.get(item.projectId); + const key = scopedProjectKey(scopeProjectRef(item.ref.environmentId, item.projectId)); + const group = byProject.get(key); if (group) { group.push(item); } else { - byProject.set(item.projectId, [item]); + byProject.set(key, [item]); } } return [...byProject.entries()]; @@ -361,10 +370,10 @@ export function ReviewSweepView() { were skipped this run.

) : null} - {groups.map(([projectId, groupItems]) => ( -
+ {groups.map(([projectKey, groupItems]) => ( +

- {projectTitles.get(projectId) ?? "Unknown project"} + {projectTitles.get(projectKey) ?? "Unknown project"} · {groupItems.length} {groupItems.length === 1 ? "thread" : "threads"} diff --git a/apps/web/src/reviewSweepStore.ts b/apps/web/src/reviewSweepStore.ts index 548b9f7632..e3e095d3d4 100644 --- a/apps/web/src/reviewSweepStore.ts +++ b/apps/web/src/reviewSweepStore.ts @@ -276,6 +276,11 @@ export async function applySweepSettle(key: string): Promise { description: "This thread picked up new activity since the review, so it stays active.", }), ); + // The recommendation is now known-stale — withdraw it so the card stops + // advertising a settle the live guard just refused. + store.patchItem(key, { + result: { ...item.result, recommendSettle: false, settleReason: null }, + }); return false; } const result = await runAtomCommand(