feat(worktrees): manage lifecycle on orchestrator v2 #5589
ClosedStiensWout(GitHub profile, opens in a new tab)wants to merge 8 commits into
t3code/codex-turn-mapping fromrefs/pull/5589/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/vcs/WorktreeRevivalService.ts lines 33 to 34OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +14,21 @@14+ WorktreeMutationError,15+} from "@t3tools/contracts";16+17+import * as ServerConfig from "../config.ts";18+import * as ProjectService from "../project/ProjectService.ts";19+import * as ProjectSetupScriptRunner from "../project/ProjectSetupScriptRunner.ts";20+import * as GitVcsDriver from "./GitVcsDriver.ts";21+import * as WorktreeLifecycle from "./WorktreeLifecycle.ts";22+23+const PROJECT_SCAN_CONCURRENCY = 4;24+25+function isPathInside(26+ root: string,27+ candidate: string,28+ path: {29+ readonly relative: (from: string, to: string) => string;30+ readonly isAbsolute: (value: string) => boolean;31+ },32+): boolean {33+ const relative = path.relative(root, candidate);34+ return relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative);apps/server/src/vcs/WorktreeService.ts line 260OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +240,21 @@240+ });241+242+ const worktreeMtime = (worktreePath: string) =>243+ fs.stat(worktreePath).pipe(244+ Effect.map((info) =>245+ Option.match(info.mtime, {246+ onNone: () => null,247+ onSome: (mtime) => mtime.toISOString(),248+ }),249+ ),250+ Effect.orElseSucceed(() => null),251+ );252+253+ const listGroup = Effect.fn("WorktreeService.listGroup")(function* (254+ group: ProjectGroup,255+ shells: ReadonlyArray<OrchestrationV2ThreadShell>,256+ ) {257+ const primaryProject = group.projects[0];258+ if (primaryProject === undefined) return [] as WorktreeInfo[];259+260+ const entries = yield* git.listWorkspaces(group.canonicalWorkspaceRoot).pipe(apps/server/src/vcs/GitVcsDriver.ts line 673OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -513,0 +521,21 @@521+ )(function* (cwd) {522+ const result = yield* gitCommand(523+ vcsProcess,524+ "GitVcsDriver.listWorkspaces",525+ cwd,526+ ["worktree", "list", "--porcelain", "-z"],527+ {528+ timeoutMs: 30_000,529+ maxOutputBytes: 16 * 1024 * 1024,530+ },531+ );532+ if (result.exitCode !== 0) {533+ return yield* new VcsProcessExitError({534+ operation: "GitVcsDriver.listWorkspaces",535+ command: "git worktree list",536+ cwd,537+ exitCode: result.exitCode,538+ detail: result.stderr.trim() || "git worktree list failed",539+ });540+ }541+ return parseGitWorktreeListPorcelain(result.stdout) satisfies ReadonlyArray<VcsWorkspace>;apps/server/src/vcs/WorktreeDeletionCleanup.ts line 66OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +46,21 @@46+ const started = yield* Ref.make(false);47+48+ const processDeletion = Effect.fn("WorktreeDeletionCleanup.processDeletion")(function* (49+ request: ThreadDeletionCleanupRequest,50+ ) {51+ if (request.worktreePath === null) return;52+53+ const policy = (yield* settings.getSettings).worktrees;54+ if (!policy.deleteOrphanedImmediately) return;55+56+ const removed = yield* worktrees.pruneOrphanedWorktree(request.worktreePath);57+ if (removed) {58+ yield* Effect.logInfo("worktree.deletion-cleanup.removed", {59+ threadId: request.threadId,60+ worktreePath: request.worktreePath,61+ });62+ }63+ });64+65+ const worker = yield* makeDrainableWorker((request: ThreadDeletionCleanupRequest) =>66+ processDeletion(request).pipe(apps/web/src/components/settings/SourceControlSettings.tsx line 935OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -509,0 +718,21 @@718+ <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>719+ <Button variant="destructive" onClick={onConfirm}>720+ Remove worktree721+ </Button>722+ </AlertDialogFooter>723+ </AlertDialogPopup>724+ </AlertDialog>725+ );726+}727+728+function WorktreeManagementSection() {729+ const environmentId = usePrimaryEnvironment()?.environmentId ?? null;730+ const settings = usePrimarySettings();731+ const updateSettings = useUpdatePrimarySettings();732+ const inventory = useEnvironmentQuery(733+ environmentId === null ? null : worktreeEnvironment.list({ environmentId, input: {} }),734+ );735+ const inventoryChanges = useEnvironmentQuery(736+ environmentId === null ? null : worktreeEnvironment.changes({ environmentId, input: {} }),737+ );738+ const pruneWorktrees = useAtomCommand(worktreeEnvironment.prune, {apps/server/src/vcs/WorktreeRevivalService.ts lines 394 to 396OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +376,21 @@376+ `Cannot revive '${input.worktreePath}': the target directory appeared before creation.`,377+ undefined,378+ { path: worktreePath, workspaceRoot, branch: input.branch },379+ );380+ }381+382+ yield* validateBranchExists(workspaceRoot, input.branch);383+ yield* git384+ .createWorktree({ cwd: workspaceRoot, refName: input.branch, path: worktreePath })385+ .pipe(386+ Effect.mapError((cause) =>387+ mutationError("Failed to create the revived Git worktree.", cause, {388+ path: worktreePath,389+ workspaceRoot,390+ branch: input.branch,391+ }),392+ ),393+ );394+ const generation = yield* advanceGeneration(worktreePath);395+396+ const finalExists = yield* fs.exists(worktreePath).pipe(
- packages/contracts/src/worktrees.ts lines 124 to 133OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +113,21 @@113+ detail: Schema.optional(Schema.String),114+ }),115+ ),116+});117+export type VcsPruneWorktreesResult = typeof VcsPruneWorktreesResult.Type;118+119+export const VcsReviveWorktreeResult = Schema.Struct({120+ revived: Schema.Boolean,121+});122+export type VcsReviveWorktreeResult = typeof VcsReviveWorktreeResult.Type;123+124+export class WorktreeInventoryError extends Schema.TaggedErrorClass<WorktreeInventoryError>()(125+ "WorktreeInventoryError",126+ {127+ operation: Schema.Literal("list"),128+ message: Schema.String,129+ projectId: Schema.optional(ProjectId),130+ workspaceRoot: Schema.optional(Schema.String),131+ cause: Schema.optional(Schema.Defect()),132+ },133+) {}apps/server/src/vcs/WorktreeRevivalService.ts lines 63 to 73OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +53,21 @@53+ });54+}55+56+export interface WorktreeRevivalForThreadInput {57+ readonly threadId: ThreadId;58+ readonly projectId: ProjectId;59+ readonly worktreePath: string;60+ readonly branch: string;61+}62+63+export interface WorktreeRevivalServiceShape {64+ readonly reviveWorktree: (65+ input: VcsReviveWorktreeInput,66+ ) => Effect.Effect<VcsReviveWorktreeResult, WorktreeMutationError>;67+ readonly reviveForThread: (68+ input: WorktreeRevivalForThreadInput,69+ ) => Effect.Effect<70+ VcsReviveWorktreeResult & { readonly generation: number },71+ WorktreeMutationError72+ >;73+}apps/server/src/vcs/WorktreeLifecycle.ts lines 10 to 14OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,14 @@1+import * as Context from "effect/Context";2+import * as Effect from "effect/Effect";3+import * as Layer from "effect/Layer";4+import * as Semaphore from "effect/Semaphore";5+import * as Stream from "effect/Stream";6+import * as SubscriptionRef from "effect/SubscriptionRef";7+8+import type { WorktreeInventoryChange } from "@t3tools/contracts";9+10+export interface WorktreeLifecycleShape {11+ readonly withMutationPermit: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;12+ readonly markInventoryChanged: Effect.Effect<void>;13+ readonly changes: Stream.Stream<WorktreeInventoryChange>;14+}
- apps/server/src/vcs/WorktreeService.ts line 549OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +529,21 @@529+ const worktree = byPath.get(canonicalPath);530+ if (worktree === undefined) {531+ skipped.push({ path: requestedPath, reason: "unknown_worktree" });532+ continue;533+ }534+ // Thread deletion cleanup is allowed to remove only an orphan. This is535+ // deliberately checked on the fresh inventory above so a worktree that536+ // became shared after the deletion event cannot be removed by a stale537+ // observation.538+ if (options?.requireOrphaned === true && !worktree.orphaned) {539+ continue;540+ }541+ if (!worktree.safeToPrune) {542+ skipped.push({543+ path: worktree.path,544+ reason: worktree.pruneBlockers[0] ?? "status_unavailable",545+ });546+ continue;547+ }548+549+ const removal = yield* gitapps/server/src/orchestration-v2/ProviderTurnStartService.ts line 186OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -159,3 +166,21 @@159166 thread: projection.thread,160167 modelSelection: run.modelSelection,161168 });169+ let observedWorktreeGeneration:170+ | { readonly path: string; readonly generation: number }171+ | undefined;172+ if (projection.thread.worktreePath !== null && projection.thread.branch !== null) {173+ const revival = yield* worktreeRevival.reviveForThread({174+ threadId: projection.thread.id,175+ projectId: projection.thread.projectId,176+ worktreePath: projection.thread.worktreePath,177+ branch: projection.thread.branch,178+ });179+ observedWorktreeGeneration = {180+ path: projection.thread.worktreePath,181+ generation: revival.generation,182+ };183+ const previousWorktreeGeneration = (yield* Ref.get(184+ worktreeGenerationByProviderSession,185+ )).get(providerSessionId);186+ if (apps/server/src/orchestration-v2/ProviderTurnStartService.ts line 183OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -159,3 +166,18 @@159166 thread: projection.thread,160167 modelSelection: run.modelSelection,161168 });169+ let observedWorktreeGeneration:170+ | { readonly path: string; readonly generation: number }171+ | undefined;172+ if (projection.thread.worktreePath !== null && projection.thread.branch !== null) {173+ const revival = yield* worktreeRevival.reviveForThread({174+ threadId: projection.thread.id,175+ projectId: projection.thread.projectId,176+ worktreePath: projection.thread.worktreePath,177+ branch: projection.thread.branch,178+ });179+ observedWorktreeGeneration = {180+ path: projection.thread.worktreePath,181+ generation: revival.generation,182+ };183+ const previousWorktreeGeneration = (yield* Ref.get(
- apps/server/src/vcs/WorktreeDeletionCleanup.ts line 98OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +78,21 @@78+ const worker = yield* makeDrainableWorker((request: ThreadDeletionCleanupRequest) =>79+ processDeletion(request).pipe(recoverDeletionFailure(request)),80+ );81+82+ const start: WorktreeDeletionCleanup["Service"]["start"] = Effect.fn(83+ "WorktreeDeletionCleanup.start",84+ )(function* () {85+ const shouldStart = yield* Ref.modify(started, (isStarted) => [!isStarted, true]);86+ if (!shouldStart) return;87+88+ yield* domainEvents.pipe(89+ Stream.catchCauseIf(90+ (cause) => !Cause.hasInterruptsOnly(cause),91+ (cause) =>92+ Stream.fromEffect(93+ Effect.logWarning("worktree.deletion-cleanup.stream-failed", {94+ cause,95+ }).pipe(Effect.andThen(Effect.fail(cause))),96+ ),97+ ),98+ Stream.retry(Schedule.exponential("1 second")),
github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
- apps/web/src/components/settings/SourceControlSettings.tsx line 939OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -509,0 +906,21 @@906+ </AlertDialogFooter>907+ </AlertDialogPopup>908+ </AlertDialog>909+ );910+}911+912+function WorktreeManagementSection() {913+ const environmentId = usePrimaryEnvironment()?.environmentId ?? null;914+ const settings = usePrimarySettings();915+ const updateSettings = useUpdatePrimarySettings();916+ const inventory = useEnvironmentQuery(917+ environmentId === null ? null : worktreeEnvironment.list({ environmentId, input: {} }),918+ );919+ const inventoryChanges = useEnvironmentQuery(920+ environmentId === null ? null : worktreeEnvironment.changes({ environmentId, input: {} }),921+ );922+ const pruneWorktrees = useAtomCommand(worktreeEnvironment.prune, {923+ label: "prune worktrees",924+ });925+ const [pendingPath, setPendingPath] = useState<string | null>(null);926+ const [pruneCandidate, setPruneCandidate] = useState<WorktreeInfo | null>(null);apps/web/src/components/settings/SourceControlSettings.tsx lines 932 to 937OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -509,0 +917,21 @@917+ environmentId === null ? null : worktreeEnvironment.list({ environmentId, input: {} }),918+ );919+ const inventoryChanges = useEnvironmentQuery(920+ environmentId === null ? null : worktreeEnvironment.changes({ environmentId, input: {} }),921+ );922+ const pruneWorktrees = useAtomCommand(worktreeEnvironment.prune, {923+ label: "prune worktrees",924+ });925+ const [pendingPath, setPendingPath] = useState<string | null>(null);926+ const [pruneCandidate, setPruneCandidate] = useState<WorktreeInfo | null>(null);927+ const [pruneDialogOpen, setPruneDialogOpen] = useState(false);928+ const worktrees = inventory.data?.worktrees ?? [];929+ const defaults = DEFAULT_UNIFIED_SETTINGS.worktrees;930+ const observedInventoryRevision = useRef<number | null>(null);931+932+ useEffect(() => {933+ const revision = inventoryChanges.data?.revision;934+ if (revision === undefined || observedInventoryRevision.current === revision) return;935+ observedInventoryRevision.current = revision;936+ inventory.refresh();937+ }, [inventory.refresh, inventoryChanges.data?.revision]);apps/web/src/components/settings/SourceControlSettings.tsx line 644OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -509,0 +624,21 @@624+ readonly onResetPruneAfterDays: () => void;625+ readonly onResetDeleteOrphaned: () => void;626+};627+628+function WorktreeRetentionSelect({629+ pruneAfterDays,630+ onChange,631+ className = "w-full sm:w-36",632+}: {633+ readonly pruneAfterDays: number | null;634+ readonly onChange: (days: number | null) => void;635+ readonly className?: string;636+}) {637+ const value = pruneAfterDays === null ? "never" : String(pruneAfterDays);638+ return (639+ <Select640+ value={value}641+ onValueChange={(nextValue) => onChange(nextValue === "never" ? null : Number(nextValue))}642+ >643+ <SelectTrigger className={className} aria-label="Automatic worktree cleanup">644+ <SelectValue>{pruneAfterDays === null ? "Never" : `${pruneAfterDays} days`}</SelectValue>
- apps/web/src/components/SidebarV2.tsx line 1257OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1206,0 +1237,21 @@1237+1238+ return (1239+ <AlertDialog open={candidate !== null} onOpenChange={onOpenChange}>1240+ <AlertDialogPopup>1241+ <AlertDialogHeader>1242+ <AlertDialogTitle>Remove {targetLabel}?</AlertDialogTitle>1243+ <AlertDialogDescription className="space-y-2">1244+ <span className="block">1245+ {threadCount > 01246+ ? `This removes the project from T3 Code and permanently deletes its ${threadCount} thread${threadCount === 1 ? "" : "s"}.`1247+ : members.length > 11248+ ? `This removes ${members.length} grouped project entries from T3 Code.`1249+ : "This removes the project from T3 Code."}1250+ </span>1251+ {singleMember ? (1252+ <span className="block truncate font-mono text-xs" title={singleMember.workspaceRoot}>1253+ {singleMember.workspaceRoot}1254+ </span>1255+ ) : null}1256+ <span className="block">1257+ Files on disk, Git branches, and worktrees are not deleted.apps/server/src/vcs/WorktreeDeletionCleanup.ts line 89OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +69,21 @@69+70+ const removed = yield* worktrees.pruneOrphanedWorktree(request.worktreePath);71+ if (removed) {72+ yield* Effect.logInfo("worktree.deletion-cleanup.removed", {73+ threadId: request.threadId,74+ worktreePath: request.worktreePath,75+ });76+ }77+ });78+79+ const worker = yield* makeDrainableWorker((request: ThreadDeletionCleanupRequest) =>80+ processDeletion(request).pipe(recoverDeletionFailure(request)),81+ );82+83+ const start: WorktreeDeletionCleanup["Service"]["start"] = Effect.fn(84+ "WorktreeDeletionCleanup.start",85+ )(function* () {86+ const shouldStart = yield* Ref.modify(started, (isStarted) => [!isStarted, true]);87+ if (!shouldStart) return;88+89+ const storedEvents = Stream.unwrap(
StiensWout(GitHub profile, opens in a new tab) changed the title
StiensWout(GitHub profile, opens in a new tab) changed the title
- apps/server/src/vcs/GitVcsDriver.ts line 588OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -560 +568,21 @@560568569+ const listWorkspaces: VcsDriver.VcsDriver["Service"]["listWorkspaces"] = Effect.fn(570+ "GitVcsDriver.listWorkspaces",571+ )(function* (cwd) {572+ const result = yield* gitCommand(573+ vcsProcess,574+ "GitVcsDriver.listWorkspaces",575+ cwd,576+ ["worktree", "list", "--porcelain", "-z"],577+ {578+ timeoutMs: 30_000,579+ maxOutputBytes: WORKTREE_LIST_MAX_OUTPUT_BYTES,580+ },581+ );582+ if (result.exitCode !== 0) {583+ return yield* new VcsProcessExitError({584+ operation: "GitVcsDriver.listWorkspaces",585+ command: "git worktree list",586+ cwd,587+ exitCode: result.exitCode,588+ detail: result.stderr.trim() || "git worktree list failed",
- apps/server/src/vcs/GitVcsDriver.ts line 576OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -558,3 +566,11 @@558566 ),559567 );560568569+ const listWorkspaces: VcsDriver.VcsDriver["Service"]["listWorkspaces"] = Effect.fn(570+ "GitVcsDriver.listWorkspaces",571+ )(function* (cwd) {572+ const result = yield* gitCommand(573+ vcsProcess,574+ "GitVcsDriver.listWorkspaces",575+ cwd,576+ ["worktree", "list", "--porcelain", "-z"],
- apps/server/src/vcs/WorktreeService.ts line 600OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +580,21 @@580+ path: worktree.path,581+ reason: worktree.pruneBlockers[0] ?? "status_unavailable",582+ });583+ continue;584+ }585+586+ const freshBlocker = yield* freshPruneBlocker(worktree).pipe(587+ Effect.catchCause((cause) =>588+ Effect.gen(function* () {589+ yield* Effect.logWarning("worktrees.prune.status-failed", {590+ worktreePath: worktree.path,591+ cause,592+ });593+ return "status_unavailable" as const;594+ }),595+ ),596+ );597+ if (freshBlocker !== null) {598+ skipped.push({ path: worktree.path, reason: freshBlocker });599+ continue;600+ }apps/server/src/orchestration-v2/ProviderTurnStartService.ts line 213OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -199,12 +204,10 @@204+ // A provider session can retain an adapter process (and its cwd)205+ // across turns. Serialize the full startup sequence by session206+ // so another starter cannot replace the runtime before this one207+ // has loaded its thread and submitted the provider turn.208+ if (!(yield* isCurrentAttemptInStatus("starting"))) return;209+ yield* providerSessions.close(providerSessionId);210+ }199211 }200- return yield* session.forkThread({201- sourceProviderThread,202- sourceProviderTurns: sourceProjection.providerTurns,203- targetThreadId: projection.thread.id,204- modelSelection: run.modelSelection,205- runtimePolicy: resolvedRuntimePolicy,206- ...(sourceProviderTurn === undefined ? {} : { providerTurnId: sourceProviderTurn.id }),207- });208- }209- if (providerThread.nativeThreadRef === null) {210- return yield* session.ensureThread({212+213+ if (!(yield* isCurrentAttemptInStatus("starting"))) return;
- apps/server/src/vcs/WorktreeService.ts line 638OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +618,21 @@618+ ),619+ Effect.catchCause((cause) =>620+ Effect.logWarning("worktrees.prune.thread-recheck-failed", {621+ worktreePath: worktree.path,622+ cause,623+ }).pipe(Effect.as({ ok: false as const, references: [] as WorktreeThreadStatus[] })),624+ ),625+ );626+ if (!freshThreadCheck.ok) {627+ skipped.push({ path: worktree.path, reason: "status_unavailable" });628+ continue;629+ }630+ if (options?.requireOrphaned === true && freshThreadCheck.references.length > 0) {631+ continue;632+ }633+ if (freshThreadCheck.references.includes("active")) {634+ skipped.push({ path: worktree.path, reason: "active_thread" });635+ continue;636+ }637+638+ const removal = yield* git
- apps/server/src/orchestration-v2/ProviderTurnStartService.ts line 218OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -199,12 +209,10 @@209+ if (!(yield* isCurrentAttemptInStatus("starting"))) return;210+ yield* providerSessions.close(providerSessionId);211+ closedForRestart = true;212+ }199213 }200- return yield* session.forkThread({201- sourceProviderThread,202- sourceProviderTurns: sourceProjection.providerTurns,203- targetThreadId: projection.thread.id,204- modelSelection: run.modelSelection,205- runtimePolicy: resolvedRuntimePolicy,206- ...(sourceProviderTurn === undefined ? {} : { providerTurnId: sourceProviderTurn.id }),207- });208- }209- if (providerThread.nativeThreadRef === null) {210- return yield* session.ensureThread({214+215+ // After closing for restart, the reopen must happen even if this216+ // attempt just left "starting": the session can be shared, and217+ // bailing here would strand sibling threads without a runtime.218+ if (!closedForRestart && !(yield* isCurrentAttemptInStatus("starting"))) return;apps/server/src/vcs/GitVcsDriverCore.ts line 877OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -900,3 +871,7 @@900871 },901872 });902873874+ const listWorkspaces: GitVcsDriver.GitVcsDriver["Service"]["listWorkspaces"] = Effect.fn(875+ "GitVcsDriver.listWorkspaces",876+ )(function* (cwd) {877+ const args = ["worktree", "list", "--porcelain"] as const;
StiensWout(GitHub profile, opens in a new tab) changed the title
- apps/server/src/orchestration-v2/ProviderTurnStartService.ts line 229OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -213,15 +221,9 @@213- runtimePolicy: resolvedRuntimePolicy,214221 providerSessionId,215- });216- }217- const resumed = yield* Effect.result(218- session.resumeThread({219- providerThread,220- threadId: projection.thread.id,221222 modelSelection: run.modelSelection,222223 runtimePolicy: resolvedRuntimePolicy,223- }),224- );225- if (resumed._tag === "Success") {226- return resumed.success;227- }224+ ...(existingSessionProjection === undefined225+ ? {}226+ : { resumeFromSession: existingSessionProjection }),227+ });228+ if (observedWorktreeGeneration !== undefined) {229+ yield* Ref.update(worktreeGenerationByProviderSession, (current) => {
- apps/web/src/components/settings/SourceControlSettings.tsx lines 1048 to 1050OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -493,0 +1030,21 @@1030+ )1031+ .map((environment) => ({1032+ environmentId: environment.environmentId,1033+ label: environment.label,1034+ isPrimary: environment.environmentId === primaryEnvironmentId,1035+ }))1036+ .sort((a, b) => Number(b.isPrimary) - Number(a.isPrimary) || a.label.localeCompare(b.label));1037+1038+ return (1039+ <SettingsSection1040+ id={searchableSetting("worktrees").id}1041+ title="Worktrees"1042+ icon={<GitBranchIcon className="size-4 text-muted-foreground" />}1043+ headerAction={1044+ <Tooltip>1045+ <TooltipTrigger1046+ render={1047+ <Button1048+ size="icon-xs"1049+ variant="ghost"1050+ className="size-5 rounded-sm p-0 text-muted-foreground hover:text-foreground"apps/web/src/components/settings/SourceControlSettings.tsx lines 826 to 829OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -493,0 +809,21 @@809+ </Badge>810+ ) : (811+ worktreeBlockerDetails(worktree).map((detail) => (812+ <Badge key={detail} variant="warning" size="sm">813+ {detail}814+ </Badge>815+ ))816+ )}817+ </div>818+ <WorktreeRichMetadata worktree={worktree} />819+ </div>820+ {isPending ? null : (821+ <WorktreeRemoveButton worktree={worktree} onPrune={onPrune} pendingPath={pendingPath} />822+ )}823+ </div>824+ {isPending ? (825+ <div className="pt-2">826+ <div827+ role="status"828+ aria-live="polite"829+ className="rounded-md border border-input bg-muted/40 px-3 py-2 text-xs text-muted-foreground dark:border-transparent dark:bg-white/[0.035]"
- apps/web/src/hooks/useThreadActions.ts line 484OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -478,2 +483,2 @@478483 );479484 return cleanupFailure;
- apps/web/src/components/settings/SourceControlSettings.tsx lines 682 to 687OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -493,0 +667,21 @@667+ <span className="flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5 text-[11px] text-muted-foreground">668+ {parts.map((part, index) => (669+ <span key={part.key} className="flex min-w-0 items-center gap-x-1.5">670+ {index > 0 ? <span aria-hidden>·</span> : null}671+ {part.node}672+ </span>673+ ))}674+ </span>675+ );676+}677+678+/** House inline error strip. */679+function WorktreeErrorStrip({ error }: { readonly error: string | null }) {680+ if (error === null) return null;681+ return (682+ <div683+ role="alert"684+ className="mx-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive sm:mx-4"685+ >686+ <span className="font-medium">Couldn't load worktrees.</span>{" "}687+ <span className="text-destructive/90">{error}</span>
- apps/web/src/components/settings/SourceControlSettings.tsx line 691OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -493,0 +671,21 @@671+ readonly worktree: WorktreeInfo;672+}) {673+ const linkedThreads = worktree.threads.filter((thread) => thread.status !== "deleted");674+ const firstThread =675+ linkedThreads.find((thread) => thread.status === "active") ?? linkedThreads[0] ?? null;676+ const otherThreadCount = firstThread === null ? 0 : linkedThreads.length - 1;677+ const parts: ReadonlyArray<{ key: string; node: ReactNode }> = [678+ ...(firstThread679+ ? [680+ {681+ key: "thread",682+ node: (683+ <Link684+ to="/$environmentId/$threadId"685+ params={{ environmentId, threadId: firstThread.threadId }}686+ className="inline-flex min-w-0 max-w-full items-center gap-1 text-foreground/70 hover:text-foreground"687+ title={firstThread.title}688+ >689+ <ArrowUpRightIcon className="size-3 shrink-0" aria-hidden />690+ <span className="truncate">{firstThread.title || "Untitled thread"}</span>691+ </Link>
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
241aad84-47f4-4428-b412-3c651f409505You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.