Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
e58175d
feat(git): show file diffs inside submodules
NeilMazumdar Nov 6, 2026
e014d3c
fix(git): preserve submodule paths and bounded pointer fallbacks
NeilMazumdar Nov 6, 2026
37edc71
fix(git): keep submodule patches in bounded review fallbacks
NeilMazumdar Nov 6, 2026
84b02ed
fix(git): align submodule fallback metadata with patch paths
NeilMazumdar Nov 7, 2026
fbcf0b2
feat(git): select a repository for diff review
NeilMazumdar Nov 7, 2026
4a9b933
fix(git): keep repository review paths and scopes consistent
NeilMazumdar Nov 7, 2026
f1f44f8
fix(git): refresh and deduplicate repository choices
NeilMazumdar Nov 8, 2026
c73f7b8
fix(web): keep literal child paths and the loading state during repos…
NeilMazumdar Nov 10, 2026
4429ed7
fix(mobile): reselecting the active repository keeps the selected sec…
NeilMazumdar Nov 11, 2026
b9b72b9
test(server): give the submodule clone a Git identity before committing
NeilMazumdar Nov 11, 2026
85434ce
fix(web,mobile): show a failed repository discovery instead of the pa…
NeilMazumdar Nov 11, 2026
c33562f
fix(web,mobile): retry a failed repository discovery without losing t…
NeilMazumdar Nov 11, 2026
07ca7d5
chore: merge upstream main into submodule diff branch
NeilMazumdar Nov 11, 2026
0e2a526
Merge remote-tracking branch 'github/main' into feature/submodule-diffs
maria-rcks Nov 11, 2026
5c1110d
perf(web): only discover review repositories while the Diff panel is …
maria-rcks Nov 11, 2026
a4237c6
test(web): drop the removed keep-on-open argument after merging main
maria-rcks Nov 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions apps/mobile/src/features/review/ReviewSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import { AsyncResult } from "effect/reactivity";
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
import type { ReviewRepositoriesResult, EnvironmentId, ThreadId } from "@t3tools/contracts";
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
Expand Down Expand Up @@ -63,6 +63,9 @@ import { useSelectWorkspaceDetail } from "../layout/workspace/useSelectWorkspace

function ReviewHeader(
props: Parameters<typeof useReviewHeaderPresentation>[0] & {
readonly repositories: ReviewRepositoriesResult["repositories"];
readonly selectedRepository: ReviewRepositoriesResult["repositories"][number] | undefined;
readonly onSelectRepository: (cwd: string) => void;
readonly sectionMenu: ReturnType<typeof buildReviewSectionMenu>;
readonly showSectionToolbar: boolean;
readonly showChangedFilesToggle: boolean;
Expand Down Expand Up @@ -104,6 +107,21 @@ function ReviewHeader(
: undefined
}
menus={[
...(props.repositories.length > 1
? [
{
title: "Select repository",
icon: "folder" as const,
items: props.repositories.map((repo) => ({
id: repo.cwd,
title: repo.name + ": " + (repo.branch ?? "HEAD"),
subtitle: repo.path || "Workspace repository",
selected: repo.cwd === props.selectedRepository?.cwd,
onPress: () => props.onSelectRepository(repo.cwd),
})),
},
]
: []),
...(presentation.gitMenu ? [presentation.gitMenu] : []),
...(props.showSectionToolbar
? [
Expand Down Expand Up @@ -388,6 +406,11 @@ export function ReviewSheet(props: ReviewSheetProps) {
refreshSelectedSection,
selectSection,
isSelectedSectionPending,
repositories,
selectedRepository,
selectRepository,
reviewCwd,
repositoryPath,
} = useReviewSections({
enabled: isEnvironmentReady,
environmentId,
Expand All @@ -409,7 +432,8 @@ export function ReviewSheet(props: ReviewSheetProps) {
} = useReviewDiffData({
threadKey: reviewCache.threadKey,
environmentId,
cwd: selectedThreadCwd,
cwd: reviewCwd,
repositoryPath,
selectedSection,
draftMessage,
draftContext,
Expand Down Expand Up @@ -452,6 +476,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
environmentId,
threadId,
selectedSection,
repositoryPath,
nativeReviewDiffData,
});
const nativeBridge = useNativeReviewDiffBridge({
Expand Down Expand Up @@ -555,6 +580,9 @@ export function ReviewSheet(props: ReviewSheetProps) {
});
};
const androidHeaderSubtitle = [
repositories.length > 1 && selectedSection?.kind !== "turn" && selectedRepository
? selectedRepository.name + ": " + (selectedRepository.branch ?? "HEAD")
: null,
selectedSection?.title,
headerDiffSummary.additions,
headerDiffSummary.deletions,
Expand Down Expand Up @@ -598,6 +626,9 @@ export function ReviewSheet(props: ReviewSheetProps) {
return <>{children}</>;
})();
const headerSubtitle = [
repositories.length > 1 && selectedSection?.kind !== "turn" && selectedRepository
? selectedRepository.name + ": " + (selectedRepository.branch ?? "HEAD")
: null,
headerDiffSummary.additions,
headerDiffSummary.deletions,
pendingReviewCommentCount > 0
Expand All @@ -622,7 +653,10 @@ export function ReviewSheet(props: ReviewSheetProps) {
title={headerTitleText}
subtitle={headerSubtitle}
androidSubtitle={androidHeaderSubtitle}
selectedThreadCwd={selectedThreadCwd}
selectedThreadCwd={repositoryPath ? null : selectedThreadCwd}
repositories={repositories}
selectedRepository={selectedRepository}
onSelectRepository={selectRepository}
sectionMenu={sectionMenu}
selectedSection={selectedSection}
showSectionToolbar={showSectionToolbar}
Expand Down
5 changes: 5 additions & 0 deletions apps/mobile/src/features/review/reviewModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ describe("resolveReviewSelectedSectionId", () => {

it("shows Changes before anything is picked, not the first section", () => {
expect(resolveReviewSelectedSectionId([turn, changes], null)).toBe("git:branch-range");
const childChanges = { ...changes, id: "git:branch-range:packages/auth" };
expect(resolveReviewSelectedSectionId([turn, childChanges], null)).toBe(childChanges.id);
expect(
resolveReviewSelectedSectionId([turn, childChanges], "git:branch-range:packages/ui"),
).toBe(childChanges.id);
});

it("shows the default while the picked section loads and returns to the pick once it does", () => {
Expand Down
11 changes: 7 additions & 4 deletions apps/mobile/src/features/review/reviewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ export function reviewTurnDiffsBySectionId(
}

export function buildReviewSectionItems(input: {
readonly repositoryPath?: string;
readonly checkpoints: ReadonlyArray<ThreadCheckpointSummary>;
readonly gitSections: ReadonlyArray<ReviewDiffPreviewSource>;
readonly turnDiffById: Readonly<Record<string, string | undefined>>;
Expand All @@ -534,13 +535,15 @@ export function buildReviewSectionItems(input: {
},
);

const repositorySectionId = (id: string) =>
input.repositoryPath ? `${id}:${input.repositoryPath}` : id;
const gitItems = input.gitSections
.filter(
(section): section is typeof section & { kind: ReviewSectionKind } =>
section.kind !== "commit",
)
.map<ReviewSectionItem>((section) => ({
id: `git:${section.kind}`,
id: repositorySectionId(`git:${section.kind}`),
kind: section.kind,
title: section.title,
subtitle: gitSubtitle(section),
Expand All @@ -550,12 +553,12 @@ export function buildReviewSectionItems(input: {
truncated: section.truncated,
isLoading: false,
}));
const hasChangesItem = gitItems.some((item) => item.id === CHANGES_SECTION_ID);
const hasChangesItem = gitItems.some((item) => item.kind === "branch-range");
const visibleGitItems =
input.loadingGitSections && !hasChangesItem
? [
{
id: CHANGES_SECTION_ID,
id: repositorySectionId(CHANGES_SECTION_ID),
kind: "branch-range",
title: CHANGES_TITLE,
subtitle: null,
Expand All @@ -572,7 +575,7 @@ export function buildReviewSectionItems(input: {
export function getDefaultReviewSectionId(
sections: ReadonlyArray<ReviewSectionItem>,
): string | null {
return (sections.find((section) => section.id === CHANGES_SECTION_ID) ?? sections[0])?.id ?? null;
return (sections.find((section) => section.kind === "branch-range") ?? sections[0])?.id ?? null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function useReviewCommentSelectionController(input: {
readonly environmentId?: EnvironmentId;
readonly threadId?: ThreadId;
readonly selectedSection: ReviewSectionItem | null;
readonly repositoryPath?: string;
readonly nativeReviewDiffData: NativeReviewDiffData;
}) {
const { environmentId, nativeReviewDiffData, selectedSection, threadId } = input;
Expand Down Expand Up @@ -99,19 +100,22 @@ export function useReviewCommentSelectionController(input: {
return;
}

const filePath = input.repositoryPath
? input.repositoryPath + "/" + target.filePath
: target.filePath;
if (gesture === "longPress") {
startReviewCommentRange(scope, {
sectionId: selectedSection.id,
sectionTitle: selectedSection.title,
filePath: target.filePath,
filePath,
lines: target.lines,
lineIndex: target.lineIndex,
rowId,
});
return;
}

if (pendingRange && pendingRange.filePath === target.filePath) {
if (pendingRange && pendingRange.filePath === filePath) {
completeReviewCommentRange(
scope,
buildReviewCommentTarget(pendingRange, pendingRange.lineIndex, target.lineIndex),
Expand All @@ -122,7 +126,7 @@ export function useReviewCommentSelectionController(input: {
setReviewCommentTarget(scope, {
sectionTitle: selectedSection.title,
sectionId: selectedSection.id,
filePath: target.filePath,
filePath,
lines: target.lines,
startIndex: target.lineIndex,
endIndex: target.lineIndex,
Expand Down
12 changes: 10 additions & 2 deletions apps/mobile/src/features/review/useReviewDiffData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export function useReviewDiffData(input: {
readonly threadKey: string | null;
readonly environmentId: EnvironmentId | undefined;
readonly cwd: string | null;
readonly repositoryPath?: string;
readonly selectedSection: ReviewSectionItem | null;
readonly draftMessage: string;
readonly draftContext: OrchestrationMessageContext | undefined;
Expand Down Expand Up @@ -237,8 +238,15 @@ export function useReviewDiffData(input: {
if (!selectedSectionId || inlineReviewComments.length === 0) {
return EMPTY_INLINE_REVIEW_COMMENTS;
}
return inlineReviewComments.filter((comment) => comment.sectionId === selectedSectionId);
}, [inlineReviewComments, selectedSectionId]);
const prefix = input.repositoryPath ? input.repositoryPath + "/" : "";
return inlineReviewComments
.filter((comment) => comment.sectionId === selectedSectionId)
.map((comment) =>
prefix && comment.filePath.startsWith(prefix)
? { ...comment, filePath: comment.filePath.slice(prefix.length) }
: comment,
);
}, [inlineReviewComments, selectedSectionId, input.repositoryPath]);
const nativeReviewDiffData = getCachedNativeReviewDiffData({
parsedDiff,
comments: selectedSectionInlineComments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export function useReviewHeaderPresentation(props: {
);
// Selection-based git hooks apply only to reviews of the selected thread.
const gitMenuAvailable =
selectedThread !== null && String(selectedThread.id) === String(props.threadId);
selectedThread !== null &&
String(selectedThread.id) === String(props.threadId) &&
props.selectedThreadCwd !== null;
const gitMenu = useThreadGitMenuDefinition({
environmentId: props.environmentId,
threadId: props.threadId,
Expand Down
61 changes: 56 additions & 5 deletions apps/mobile/src/features/review/useReviewSections.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useThreadSelection } from "../../state/use-thread-selection";
import { useState } from "react";
import { useAtomValue } from "@effect/atom-react";
import { resolveFilesystemReadAccess } from "@t3tools/client-runtime/state/filesystem";
import { Atom } from "effect/reactivity";
Expand Down Expand Up @@ -53,17 +55,46 @@ export function useReviewSections(input: {
const { canReadFiles } = fileAccess;
const selectedThread = useSelectedThreadProjection();
const { selectedThreadCwd } = useSelectedThreadWorktree();
const [repositoryChoice, setRepositoryChoice] = useState<{
threadKey: string | null;
cwd: string;
} | null>(null);
const repositoriesQuery = useEnvironmentQuery(
canReadFiles && enabled && environmentId && selectedThreadCwd
? reviewEnvironment.repositories({ environmentId, input: { cwd: selectedThreadCwd } })
: null,
);
const { selectedThreadProject } = useThreadSelection();
const repositories = (repositoriesQuery.data?.repositories ?? []).map((repo) =>
repo.path ? repo : { ...repo, name: selectedThreadProject?.title || repo.name },
);
const selectedRepository =
repositories.find(
(repo) =>
repositoryChoice?.threadKey === reviewCache.threadKey && repo.cwd === repositoryChoice.cwd,
) ?? repositories[0];
// A chosen child stays unresolved while discovery has no answer, so its review never shows the parent.
const repositoryUnresolved =
repositoryChoice?.threadKey === reviewCache.threadKey &&
repositoryChoice.cwd !== selectedThreadCwd &&
!repositoriesQuery.data;
const reviewCwd = repositoryUnresolved
? null
: selectedRepository?.path
? selectedRepository.cwd
: selectedThreadCwd;
const repositoryPath = selectedRepository?.path ?? "";
const diffPreview = useEnvironmentQuery(
canReadFiles && enabled && environmentId !== undefined && selectedThreadCwd !== null
canReadFiles && enabled && environmentId !== undefined && reviewCwd !== null
? reviewEnvironment.diffPreview({
environmentId,
input: { cwd: selectedThreadCwd },
input: { cwd: reviewCwd },
})
: null,
);
const lastGitSections = useAtomValue(
environmentId !== undefined && selectedThreadCwd !== null
? lastReviewGitSectionsAtom(environmentId, selectedThreadCwd)
environmentId !== undefined && reviewCwd !== null
? lastReviewGitSectionsAtom(environmentId, reviewCwd)
: NO_GIT_SECTIONS_ATOM,
);

Expand All @@ -87,6 +118,7 @@ export function useReviewSections(input: {
canReadFiles || fileAccess.isPending ? (diffPreview.data?.sources ?? lastGitSections) : [],
turnDiffById: reviewTurnDiffsBySectionId(readyCheckpoints, lastTurnDiffs),
loadingGitSections: fileAccess.isPending || diffPreview.isPending,
repositoryPath,
});
const selectedSectionId = resolveReviewSelectedSectionId(
cachedSections,
Expand Down Expand Up @@ -124,15 +156,21 @@ export function useReviewSections(input: {
const selectedSection =
reviewSections.find((section) => section.id === selectedSectionId) ?? null;

// With a child unresolved there are no Git sections, so a turn can be selected only as a fallback.
const repositoryFailureVisible =
repositoryUnresolved &&
!(selectedSection?.kind === "turn" && reviewCache.selectedSectionId === selectedSection.id);

const refreshSelectedSection = async () => {
if (!enabled) {
return;
}
if (selectedSection?.kind === "turn") {
activeTurnDiff.refresh();
return;
if (!repositoryFailureVisible) return;
}
diffPreview.refresh();
repositoriesQuery.refresh();
};

const selectSection = (sectionId: string) => {
Expand All @@ -141,8 +179,21 @@ export function useReviewSections(input: {
}
};

const selectRepository = (cwd: string) => {
if (!repositories.some((repo) => repo.cwd === cwd)) return;
if (selectedRepository?.cwd === cwd) return;
setRepositoryChoice({ threadKey: reviewCache.threadKey, cwd });
if (reviewCache.threadKey) setReviewSelectedSectionId(reviewCache.threadKey, null);
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

return {
repositories,
selectedRepository,
selectRepository,
reviewCwd: selectedSection?.kind === "turn" ? selectedThreadCwd : reviewCwd,
repositoryPath: selectedSection?.kind === "turn" ? "" : repositoryPath,
error:
(repositoryFailureVisible ? repositoriesQuery.error : null) ??
diffPreview.error ??
activeTurnDiff.error ??
(selectedSection === null && !fileAccess.isPending && !canReadFiles
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/auth/RpcAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export const RPC_REQUIRED_SCOPES = {
[WS_METHODS.vcsRefreshStatus]: AuthOrchestrationReadScope,
[WS_METHODS.gitResolvePullRequest]: AuthOrchestrationReadScope,
[WS_METHODS.vcsListRefs]: AuthOrchestrationReadScope,
[WS_METHODS.reviewGetRepositories]: AuthFilesystemReadScope,
[WS_METHODS.reviewGetBranchCommits]: AuthFilesystemReadScope,
[WS_METHODS.reviewGetDiffPreview]: AuthFilesystemReadScope,
[WS_METHODS.reviewGetDiffFileContents]: AuthFilesystemReadScope,
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/observability/RpcInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const RPC_AGGREGATES = {
[WS_METHODS.vcsCreateRef]: "vcs",
[WS_METHODS.vcsSwitchRef]: "vcs",
[WS_METHODS.vcsInit]: "vcs",
[WS_METHODS.reviewGetRepositories]: "review",
[WS_METHODS.reviewGetBranchCommits]: "review",
[WS_METHODS.reviewGetDiffPreview]: "review",
[WS_METHODS.reviewGetDiffFileContents]: "review",
Expand Down
6 changes: 6 additions & 0 deletions apps/server/src/review/ReviewService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ describe("ReviewService", () => {
return yield* review.getDiffPreview({ cwd: outsideRoot }).pipe(Effect.flip);
}).pipe(Effect.provide(layer({ workspaceRoot, baseDir, detectCalls })));

const repositoryError = yield* Effect.gen(function* () {
const review = yield* ReviewService.ReviewService;
return yield* review.getRepositories({ cwd: outsideRoot }).pipe(Effect.flip);
}).pipe(Effect.provide(layer({ workspaceRoot, baseDir, detectCalls })));
assert.strictEqual(repositoryError._tag, "VcsRepositoryDetectionError");
assert.strictEqual(repositoryError.operation, "ReviewService.getRepositories");
assert.strictEqual(error._tag, "VcsRepositoryDetectionError");
assert.strictEqual(error.operation, "ReviewService.getDiffPreview");
assert.match(
Expand Down
Loading
Loading