Skip to content

Commit e9aac9d

Browse files
t3dotggclaude
andcommitted
feat(projects): projects with several repos get per-repo review and worktrees
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3b2f958 commit e9aac9d

247 files changed

Lines changed: 15809 additions & 1272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/src/connection/environment-cache-store.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const SHELL_SNAPSHOT: OrchestrationV2ShellSnapshot = {
4545
repositoryIdentity: null,
4646
defaultModelSelection: null,
4747
scripts: [],
48+
trackedFolders: [],
4849
createdAt: "2026-07-29T12:00:00.000Z",
4950
updatedAt: "2026-07-29T12:00:00.000Z",
5051
},

‎apps/mobile/src/features/home/homeThreadList.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function makeProject(
1717
repositoryIdentity: null,
1818
defaultModelSelection: null,
1919
scripts: [],
20+
trackedFolders: [],
2021
createdAt: "2026-06-01T00:00:00.000Z",
2122
updatedAt: "2026-06-01T00:00:00.000Z",
2223
...input,

‎apps/mobile/src/features/review/ReviewSheet.tsx‎

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
88
import { AppBar } from "../../components/ui/AppBar";
99
import type { AppBarMenuItem } from "../../components/ui/AppBar.types";
1010
import type { ReviewSectionItem } from "./reviewModel";
11+
import type { ReviewRepository } from "./reviewRepositories";
1112
import { useReviewHeaderPresentation } from "./useReviewHeaderPresentation";
1213
import { Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-screens";
1314
import { type Ref, type ReactElement, useImperativeHandle, useRef, useState } from "react";
@@ -42,7 +43,6 @@ import {
4243
useAdaptiveWorkspacePaneRole,
4344
useRegisterWorkspaceInspector,
4445
} from "../layout/AdaptiveWorkspaceLayout";
45-
import { useSelectedThreadWorktree } from "../../state/use-selected-thread-worktree";
4646
import { useReviewCacheForThread } from "./reviewState";
4747
import {
4848
isNativeReviewDiffDrawEvent,
@@ -69,6 +69,10 @@ function ReviewHeader(
6969
readonly sectionMenu: ReturnType<typeof buildReviewSectionMenu>;
7070
readonly showSectionToolbar: boolean;
7171
readonly showChangedFilesToggle: boolean;
72+
/** Multi-repo threads only. */
73+
readonly repositories: ReadonlyArray<ReviewRepository>;
74+
readonly repository: ReviewRepository | null;
75+
readonly onSelectRepository: (repository: ReviewRepository) => void;
7276
readonly onSelectSection: (sectionId: string) => void;
7377
readonly onReturnToThread: () => void;
7478
},
@@ -114,6 +118,21 @@ function ReviewHeader(
114118
title: "Select diff",
115119
icon: presentation.menuIcon,
116120
items: [
121+
...(props.repositories.length > 1
122+
? [
123+
{
124+
id: "repositories",
125+
title: "Repository",
126+
icon: "folder",
127+
items: props.repositories.map((repository) => ({
128+
id: `repository:${repository.cwd}`,
129+
title: repository.name,
130+
selected: repository.cwd === props.repository?.cwd,
131+
onPress: () => props.onSelectRepository(repository),
132+
})),
133+
},
134+
]
135+
: []),
117136
{
118137
id: "sections",
119138
inline: true,
@@ -420,6 +439,9 @@ function ReviewFileNavigator({
420439
type ReviewSheetProps = StaticScreenProps<{
421440
readonly environmentId: EnvironmentId;
422441
readonly threadId: ThreadId;
442+
/** A repo the agent edited outside the thread; review lists it next to the thread's repos. */
443+
readonly outsideRepositoryRoot?: string;
444+
readonly outsideRepositoryName?: string;
423445
}>;
424446

425447
export function ReviewSheet(props: ReviewSheetProps) {
@@ -431,13 +453,13 @@ export function ReviewSheet(props: ReviewSheetProps) {
431453
const insets = useSafeAreaInsets();
432454
const { themeAppearance: selectedTheme } = useAppearancePreferences();
433455
const headerIcon = String(useUniwindTheme()["--color-icon"]);
434-
const { environmentId, threadId } = props.route.params;
456+
const { environmentId, threadId, outsideRepositoryRoot, outsideRepositoryName } =
457+
props.route.params;
435458
const environment = useEnvironmentPresentation(environmentId);
436459
const retryEnvironment = useAtomCommand(environmentCatalog.retryNow, "environment retry");
437460
const isEnvironmentReady = environment.presentation?.connection.phase === "connected";
438461
const { draftMessage } = useThreadDraftForThread({ environmentId, threadId });
439462
const reviewCache = useReviewCacheForThread({ environmentId, threadId });
440-
const { selectedThreadCwd } = useSelectedThreadWorktree();
441463
const columnMetrics = useNativeColumnLayoutMetrics();
442464
const safeArea = columnMetrics?.safeArea ?? insets;
443465
const topContentInset = Platform.OS === "ios" ? safeArea.top : 0;
@@ -451,11 +473,18 @@ export function ReviewSheet(props: ReviewSheetProps) {
451473
refreshSelectedSection,
452474
selectSection,
453475
isSelectedSectionPending,
476+
repositories,
477+
repository,
478+
cwd: reviewCwd,
479+
selectRepository,
454480
} = useReviewSections({
455481
enabled: isEnvironmentReady,
456482
environmentId,
457483
threadId,
458484
reviewCache,
485+
outsideRepository: outsideRepositoryRoot
486+
? { root: outsideRepositoryRoot, name: outsideRepositoryName ?? outsideRepositoryRoot }
487+
: null,
459488
});
460489
useReviewDiffPrewarming({
461490
threadKey: reviewCache.threadKey,
@@ -472,7 +501,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
472501
} = useReviewDiffData({
473502
threadKey: reviewCache.threadKey,
474503
environmentId,
475-
cwd: selectedThreadCwd,
504+
cwd: reviewCwd,
476505
selectedSection,
477506
draftMessage,
478507
});
@@ -669,11 +698,19 @@ export function ReviewSheet(props: ReviewSheetProps) {
669698
subtitle={headerSubtitle}
670699
androidSubtitle={androidHeaderSubtitle}
671700
iconColor={headerIcon}
672-
selectedThreadCwd={selectedThreadCwd}
701+
selectedThreadCwd={reviewCwd}
702+
gitRepository={
703+
repository === null
704+
? undefined
705+
: { cwd: repository.cwd, home: repository.history === "home" }
706+
}
673707
sectionMenu={sectionMenu}
674708
selectedSection={selectedSection}
675709
showSectionToolbar={showSectionToolbar}
676710
showChangedFilesToggle={showChangedFilesToggle}
711+
repositories={repositories}
712+
repository={repository}
713+
onSelectRepository={selectRepository}
677714
onRefresh={handlePullToRefresh}
678715
onSelectSection={selectSection}
679716
onReturnToThread={handleReturnToThread}

‎apps/mobile/src/features/review/reviewModel.ts‎

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import * as Arr from "effect/Array";
77
import { pipe } from "effect/Function";
88
import * as Order from "effect/Order";
99

10+
import {
11+
reviewRepositorySectionPrefix,
12+
turnDiffForReviewRepository,
13+
type ReviewRepository,
14+
type ReviewTurnDiff,
15+
} from "./reviewRepositories";
16+
1017
export type ReviewSectionKind = "turn" | "working-tree" | "branch-range";
1118

1219
const CHANGES_SECTION_ID = "git:branch-range";
@@ -501,29 +508,39 @@ export function getReadyReviewCheckpoints(
501508

502509
export function reviewTurnDiffsBySectionId(
503510
checkpoints: ReadonlyArray<Pick<ThreadCheckpointSummary, "checkpointTurnCount">>,
504-
diffByTurnCount: Readonly<Record<number, string | undefined>>,
511+
diffByTurnCount: Readonly<Record<number, ReviewTurnDiff | undefined>>,
512+
repository: ReviewRepository | null = null,
505513
): Readonly<Record<string, string | undefined>> {
514+
const prefix = reviewRepositorySectionPrefix(repository);
506515
return Object.fromEntries(
507516
checkpoints.map((checkpoint) => [
508-
getReviewSectionIdForCheckpoint(checkpoint),
509-
diffByTurnCount[checkpoint.checkpointTurnCount],
517+
`${prefix}${getReviewSectionIdForCheckpoint(checkpoint)}`,
518+
turnDiffForReviewRepository(diffByTurnCount[checkpoint.checkpointTurnCount], repository),
510519
]),
511520
);
512521
}
513522

523+
/**
524+
* `idPrefix` and `titleSuffix` name a tracked repo in multi-repo threads; the title carries the
525+
* repo into inline review comments.
526+
*/
514527
export function buildReviewSectionItems(input: {
515528
readonly checkpoints: ReadonlyArray<ThreadCheckpointSummary>;
516529
readonly gitSections: ReadonlyArray<ReviewDiffPreviewSource>;
517530
readonly turnDiffById: Readonly<Record<string, string | undefined>>;
518531
readonly loadingGitSections: boolean;
532+
readonly idPrefix?: string;
533+
readonly titleSuffix?: string;
519534
}): ReadonlyArray<ReviewSectionItem> {
535+
const idPrefix = input.idPrefix ?? "";
536+
const titleSuffix = input.titleSuffix ?? "";
520537
const turnItems = getReadyReviewCheckpoints(input.checkpoints).map<ReviewSectionItem>(
521538
(checkpoint) => {
522-
const id = getReviewSectionIdForCheckpoint(checkpoint);
539+
const id = `${idPrefix}${getReviewSectionIdForCheckpoint(checkpoint)}`;
523540
return {
524541
id,
525542
kind: "turn",
526-
title: checkpointTitle(checkpoint),
543+
title: `${checkpointTitle(checkpoint)}${titleSuffix}`,
527544
subtitle: checkpointSubtitle(checkpoint),
528545
diff: input.turnDiffById[id] ?? null,
529546
isLoading: false,
@@ -532,24 +549,24 @@ export function buildReviewSectionItems(input: {
532549
);
533550

534551
const gitItems = input.gitSections.map<ReviewSectionItem>((section) => ({
535-
id: `git:${section.kind}`,
552+
id: `${idPrefix}git:${section.kind}`,
536553
kind: section.kind,
537-
title: section.title,
554+
title: `${section.title}${titleSuffix}`,
538555
subtitle: gitSubtitle(section),
539556
diff: section.diff,
540557
source: section,
541558
...(section.files ? { files: section.files } : {}),
542559
truncated: section.truncated,
543560
isLoading: false,
544561
}));
545-
const hasChangesItem = gitItems.some((item) => item.id === CHANGES_SECTION_ID);
562+
const hasChangesItem = gitItems.some((item) => item.kind === "branch-range");
546563
const visibleGitItems =
547564
input.loadingGitSections && !hasChangesItem
548565
? [
549566
{
550-
id: CHANGES_SECTION_ID,
567+
id: `${idPrefix}${CHANGES_SECTION_ID}`,
551568
kind: "branch-range",
552-
title: CHANGES_TITLE,
569+
title: `${CHANGES_TITLE}${titleSuffix}`,
553570
subtitle: null,
554571
diff: null,
555572
isLoading: true,
@@ -564,7 +581,7 @@ export function buildReviewSectionItems(input: {
564581
export function getDefaultReviewSectionId(
565582
sections: ReadonlyArray<ReviewSectionItem>,
566583
): string | null {
567-
return (sections.find((section) => section.id === CHANGES_SECTION_ID) ?? sections[0])?.id ?? null;
584+
return (sections.find((section) => section.kind === "branch-range") ?? sections[0])?.id ?? null;
568585
}
569586

570587
/**

0 commit comments

Comments
 (0)