Repository navigation
fix(client): new threads from a grouped repository start in its root checkout #37191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a8ab67
fe68c22
26ddf2c
995936c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,20 @@ function deriveRepositoryRelativeProjectPath( | |
| return normalizedProjectPath.slice(rootPrefix.length).replaceAll("\\", "/"); | ||
| } | ||
|
|
||
| /** The project's workspace root is its repository's git top-level, not a sub-folder. */ | ||
| export function isRepositoryRootProject( | ||
| project: Pick<EnvironmentProject, "workspaceRoot" | "repositoryIdentity">, | ||
| ): boolean { | ||
| return deriveRepositoryRelativeProjectPath(project) === ""; | ||
| } | ||
|
|
||
| /** A group's default checkout for new threads: its repository root, else its first member. */ | ||
| export function selectGroupDefaultProject< | ||
| TProject extends Pick<EnvironmentProject, "workspaceRoot" | "repositoryIdentity">, | ||
| >(projects: ReadonlyArray<TProject>): TProject | undefined { | ||
| return projects.find(isRepositoryRootProject) ?? projects[0]; | ||
| } | ||
|
|
||
| export function derivePhysicalProjectKeyFromPath(environmentId: string, cwd: string): string { | ||
| return `${environmentId}:${normalizeProjectPathForComparison(cwd)}`; | ||
| } | ||
|
|
@@ -165,6 +179,23 @@ export function deriveLogicalProjectKeyFromSettings( | |
| }); | ||
| } | ||
|
|
||
| /** The checkout a new thread in `project`'s group starts in on its environment: the group's root. */ | ||
| export function resolveGroupDefaultProject<TProject extends EnvironmentProject>( | ||
| project: TProject, | ||
| projects: ReadonlyArray<TProject>, | ||
| settings: ProjectGroupingSettings, | ||
| ): TProject { | ||
| const groupKey = deriveLogicalProjectKeyFromSettings(project, settings); | ||
| return ( | ||
| projects.find( | ||
| (candidate) => | ||
| candidate.environmentId === project.environmentId && | ||
| isRepositoryRootProject(candidate) && | ||
| deriveLogicalProjectKeyFromSettings(candidate, settings) === groupKey, | ||
|
Comment on lines
+193
to
+194
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep If Apply root preference only in
|
||
| ) ?? project | ||
| ); | ||
| } | ||
|
|
||
| export function resolveScratchProjectScopeKey( | ||
| key: string | null, | ||
| projects: ReadonlyArray< | ||
|
|
@@ -381,10 +412,13 @@ export function buildProjectGroups<TProject extends EnvironmentProject>( | |
|
|
||
| const preferredEnvironmentId = input.preferredEnvironmentId ?? null; | ||
| return Array.from(groupedMembers, ([key, members]) => { | ||
| const projects = members.map((member) => member.project); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Retain root status from the physical project's identity source. If the newest root registration has no identity, Preserve root status from
|
||
| const representative = | ||
| (preferredEnvironmentId | ||
| ? members.find((member) => member.project.environmentId === preferredEnvironmentId)?.project | ||
| : null) ?? members[0]!.project; | ||
| ? selectGroupDefaultProject( | ||
| projects.filter((project) => project.environmentId === preferredEnvironmentId), | ||
| ) | ||
| : undefined) ?? selectGroupDefaultProject(projects)!; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exclude archived checkouts when the group representative is chosen. The root-first representative rule does not check
|
||
| return { | ||
| key, | ||
| label: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve project ordering when selecting among repository roots.
If two live roots share a repository and environment, this call can discard
projectOrder. Withprojects=[A,B]and B ordered first,firstProjectis B, but this call searches the original list and returns A. Previously, the resolver returned B.Retain the ordered live-project list and pass that list to
resolveGroupDefaultProject. This preserves ordering between roots and still prefers a root over a subfolder.