feat(projects): turn changes and diffs cover tracked repositories #35923
Closedjuliusmarmingewants to merge 1 commit into
t3/multi-repo-1-tracked-repos fromrefs/pull/35923/headopened View on GitHubtanstack-source added labelsfeature
github-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
- @@ -0,0 +68,21 @@68+const NO_REPOSITORY_CHANGES: ReadonlyArray<TurnRepositoryChanges> = Object.freeze([]);69+const NO_TURN_REPOSITORY_CHANGES: ReadonlyMap<70+ RunId,71+ ReadonlyArray<TurnRepositoryChanges>72+> = new Map();73+74+export function isRepositoryCheckpointScope(75+ scope: Pick<OrchestrationV2CheckpointScope, "repositoryPath">,76+): boolean {77+ return typeof scope.repositoryPath === "string";78+}79+80+/** Scopes whose checkpoints belong to a repository, never to the thread's own timeline. */81+export function repositoryCheckpointScopeIds(82+ scopes: ReadonlyArray<Pick<OrchestrationV2CheckpointScope, "id" | "repositoryPath">>,83+): ReadonlySet<CheckpointScopeId> {84+ return new Set(scopes.flatMap((scope) => (isRepositoryCheckpointScope(scope) ? [scope.id] : [])));85+}86+87+function pathSegments(path: string): { root: string; segments: string[] } | undefined {88+ const normalized = path.replaceAll("\\", "/");@@ -416,3 +450,4 @@416450 selectedSection,417451 draftMessage,418452 draftContext,453+ repositoryFilter:@@ -741,3 +777,11 @@741777 }742778 }, [collapseScopeKey, selectedFilePath, selectedFileRevealRequestId, revealDiffFile]);743779780+ // A tracked repository's file is named from the thread's folder; on disk it belongs to the781+ // repository's own folder, which may sit outside the thread's.782+ const repositoryFileTarget = (filePath: string) => {783+ const match = repositorySectionForPath(repositorySections, filePath);784+ if (match === null) return null;785+ return {786+ path: match.path,787+ insideThreadFolder: !match.section.relativePath.startsWith(".."),
- @@ -1576,0 +1654,21 @@1654+ const lines = status.stdout.split("\n").filter((line) => line.length > 0);1655+ if (lines.some((line) => !line.startsWith("# "))) return null;1656+ const head = lines.find((line) => line.startsWith("# branch.oid "))?.slice(13);1657+ if (head === undefined || !/^[0-9a-f]{40,64}$/.test(head)) return null;1658+ return (yield* hasFlaggedIndexEntries(cwd)) ? null : head;1659+ }),1660+1661+ captureHeadCheckpoint: Effect.fn("GitVcsDriver.checkpoints.captureHeadCheckpoint")(1662+ function* (input) {1663+ const operation = VcsProcess.CHECKPOINT_CAPTURE_OPERATION;1664+ const commit = yield* execute({1665+ operation,1666+ cwd: input.cwd,1667+ args: [1668+ ...durableWrite,1669+ "commit-tree",1670+ `${input.head}^{tree}`,1671+ "-p",1672+ input.head,1673+ "-m",1674+ `t3 checkpoint ref=${input.checkpointRef}`,@@ -163,3 +336,7 @@163336 });164337 }165338339+ const nested = hasRepositories340+ ? yield* nestedScopePaths([341+ toScope,342+ ...projection.checkpointScopes.filter(
- @@ -155,0 +224,21 @@224+ onClick={() => {225+ setCollapsed(!collapsed);226+ syncTimelineLayout();227+ }}228+ >229+ <ChevronRightIcon230+ aria-hidden="true"231+ className={cn(232+ "size-3.5 shrink-0 text-muted-foreground/70 transition-transform group-hover:text-foreground/80",233+ !collapsed && "rotate-90",234+ )}235+ />236+ <FolderGit2Icon className="size-3.5 shrink-0 text-muted-foreground/75" />237+ <span className="truncate font-mono text-2xs text-foreground/90">{group.name}</span>238+ {hasNonZeroStat(group.totals) && (239+ <span className="ml-auto shrink-0 font-mono text-3xs tabular-nums">240+ <DiffStatLabel additions={group.totals.additions} deletions={group.totals.deletions} />241+ </span>242+ )}243+ </button>244+ {collapsed ? null : group.note !== undefined ? (
- @@ -240,0 +285,21 @@285+ : Effect.succeed([]),286+ ),287+ );288+ },289+ { concurrency: DETECTION_CONCURRENCY },290+ ),291+ ),292+ Effect.map((found) => found.flat()),293+ );294+295+ const submodulesOf = Effect.fnUntraced(function* (296+ roots: ReadonlyArray<{ readonly path: string; readonly identity: string }>,297+ ) {298+ const found = yield* Effect.forEach(roots, submodulesBelow, {299+ concurrency: DETECTION_CONCURRENCY,300+ });301+ const taken = new Set(roots.map((root) => root.path));302+ return found303+ .flat()304+ .filter((folder) => !taken.has(folder.path))305+ .slice(0, THREAD_SUBMODULES_MAX);@@ -750,3 +786,11 @@750786 }751787 }, [collapseScopeKey, selectedFilePath, selectedFileRevealRequestId, revealDiffFile]);752788789+ // A tracked repository's file is named from the thread's folder; on disk it belongs to the790+ // repository's own folder, which may sit outside the thread's.791+ const repositoryFileTarget = (filePath: string) => {792+ const match = repositorySectionForPath(repositorySections, filePath);793+ if (match === null) return null;794+ return {795+ path: match.path,796+ insideThreadFolder: !match.section.relativePath.startsWith(".."),
juliusmarminge closed this
Sign in to join this conversation.


This PR changes the test suite by +29 test cases (browser +1, unit +21, server +7).
Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing.