Skip to content

Commit a381c42

Browse files
fix(web): keep clone folder names readable in the setup project picker
Nested rows in the Choose your projects step showed the full path with an end ellipsis, so sibling checkouts that share a prefix looked identical until hovered. Each nested row now shows the folder name first and lets the shared parent path truncate instead. Fixes #12056 Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 9ea9c3d commit a381c42

3 files changed

Lines changed: 77 additions & 13 deletions

File tree

‎apps/web/src/components/onboarding/WelcomeWizard.tsx‎

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
resolveOnboardingLandingProject,
4040
resolveOnboardingProjectId,
4141
type OnboardingProjectGroup,
42+
splitOnboardingProjectPath,
4243
} from "../../onboarding/projectImport.logic";
4344
import {
4445
getOnboardingProviderState,
@@ -1352,7 +1353,7 @@ function ImportCandidateList({
13521353
<ImportCandidateRow
13531354
key={candidate.key}
13541355
candidate={candidate}
1355-
label={candidate.path}
1356+
path={candidate.path}
13561357
nested
13571358
checked={selectedKeys.has(candidate.key)}
13581359
onCheckedChange={(checked) => setKeys([candidate.key], checked)}
@@ -1383,7 +1384,7 @@ function ImportRepositoryGroup({
13831384
<ImportCandidateRow
13841385
candidate={only}
13851386
label={group.label}
1386-
{...(group.repository === null ? {} : { secondary: only.path })}
1387+
{...(group.repository === null ? {} : { path: only.path })}
13871388
checked={selectedKeys.has(only.key)}
13881389
onCheckedChange={(checked) => onToggle([only.key], checked)}
13891390
/>
@@ -1412,7 +1413,7 @@ function ImportRepositoryGroup({
14121413
<ImportCandidateRow
14131414
key={candidate.key}
14141415
candidate={candidate}
1415-
label={candidate.path}
1416+
path={candidate.path}
14161417
nested
14171418
checked={selectedKeys.has(candidate.key)}
14181419
onCheckedChange={(checked) => onToggle([candidate.key], checked)}
@@ -1423,17 +1424,39 @@ function ImportRepositoryGroup({
14231424
);
14241425
}
14251426

1427+
/**
1428+
* Clones of one repository and plain folders differ only by folder name, so
1429+
* the name stays visible and the shared parent path truncates first.
1430+
*/
1431+
function ProjectPathText({
1432+
path,
1433+
className,
1434+
}: {
1435+
readonly path: string;
1436+
readonly className?: string;
1437+
}) {
1438+
const { name, parent } = splitOnboardingProjectPath(path);
1439+
return (
1440+
<span className={cn("flex min-w-0 items-baseline font-mono", className)}>
1441+
{parent.length > 0 ? <span className="truncate">{parent}</span> : null}
1442+
<span className="max-w-full shrink-0 truncate">{name}</span>
1443+
</span>
1444+
);
1445+
}
1446+
14261447
function ImportCandidateRow({
14271448
candidate,
14281449
label,
1429-
secondary,
1450+
path,
14301451
nested = false,
14311452
checked,
14321453
onCheckedChange,
14331454
}: {
14341455
readonly candidate: ImportCandidate;
1435-
readonly label: string;
1436-
readonly secondary?: string;
1456+
/** Text primary label. Nested rows omit it and are labelled by their path. */
1457+
readonly label?: string;
1458+
/** Shown with the folder name kept visible while the parent path truncates. */
1459+
readonly path?: string;
14371460
readonly nested?: boolean;
14381461
readonly checked: boolean;
14391462
readonly onCheckedChange: (checked: boolean) => void;
@@ -1450,13 +1473,14 @@ function ImportCandidateRow({
14501473
<TooltipTrigger
14511474
render={<span className="flex min-w-0 flex-1 items-baseline gap-2 truncate" />}
14521475
>
1453-
<span className={cn("truncate", nested ? "font-mono text-xs" : "text-sm font-medium")}>
1454-
{label}
1455-
</span>
1456-
{secondary !== undefined ? (
1457-
<span className="truncate font-mono text-[11px] text-muted-foreground">
1458-
{secondary}
1459-
</span>
1476+
{label !== undefined ? (
1477+
<span className="truncate text-sm font-medium">{label}</span>
1478+
) : null}
1479+
{path !== undefined ? (
1480+
<ProjectPathText
1481+
path={path}
1482+
className={label === undefined ? "text-xs" : "text-[11px] text-muted-foreground"}
1483+
/>
14601484
) : null}
14611485
</TooltipTrigger>
14621486
<TooltipPopup className="max-w-96 break-all font-mono">{candidate.path}</TooltipPopup>

‎apps/web/src/onboarding/projectImport.logic.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
onboardingProjectKey,
88
resolveOnboardingLandingProject,
99
resolveOnboardingProjectId,
10+
splitOnboardingProjectPath,
1011
} from "./projectImport.logic";
1112

1213
const now = Date.parse("2026-08-22T12:00:00.000Z");
@@ -349,3 +350,26 @@ describe("projects on multiple computers", () => {
349350
expect(partitionOnboardingProjects([first, second], now).recent).toEqual([first, second]);
350351
});
351352
});
353+
354+
describe("splitOnboardingProjectPath", () => {
355+
it("keeps sibling checkouts that share a prefix distinguishable by name", () => {
356+
const left = splitOnboardingProjectPath("/Users/me/Projects/clients/acme/t3code");
357+
const right = splitOnboardingProjectPath("/Users/me/Projects/clients/acme/t3code-worktree");
358+
expect(left).toEqual({ name: "t3code", parent: "/Users/me/Projects/clients/acme/" });
359+
expect(right).toEqual({ name: "t3code-worktree", parent: "/Users/me/Projects/clients/acme/" });
360+
expect(left.name).not.toBe(right.name);
361+
});
362+
363+
it("splits Windows paths and ignores a trailing separator", () => {
364+
expect(splitOnboardingProjectPath("C:\\Users\\me\\t3code\\")).toEqual({
365+
name: "t3code",
366+
parent: "C:\\Users\\me\\",
367+
});
368+
});
369+
370+
it("keeps a root or bare name whole", () => {
371+
expect(splitOnboardingProjectPath("/")).toEqual({ name: "/", parent: "" });
372+
expect(splitOnboardingProjectPath("/t3code")).toEqual({ name: "t3code", parent: "/" });
373+
expect(splitOnboardingProjectPath("t3code")).toEqual({ name: "t3code", parent: "" });
374+
});
375+
});

‎apps/web/src/onboarding/projectImport.logic.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ export function resolveOnboardingLandingProject<T>(
135135
return undefined;
136136
}
137137

138+
/**
139+
* Splits a scan path into the folder name and the directory above it (with
140+
* its trailing separator), so a picker row can keep the name visible and let
141+
* the shared prefix truncate. Handles both separators because candidates
142+
* come from any environment.
143+
*/
144+
export function splitOnboardingProjectPath(path: string): {
145+
readonly name: string;
146+
readonly parent: string;
147+
} {
148+
const trimmed = path.replace(/[\\/]+$/, "");
149+
const separatorIndex = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
150+
if (trimmed.length === 0 || separatorIndex < 0) return { name: path, parent: "" };
151+
return { name: trimmed.slice(separatorIndex + 1), parent: trimmed.slice(0, separatorIndex + 1) };
152+
}
153+
138154
/** Paths identify projects only within the computer that owns them. */
139155
export function onboardingProjectKey(environmentId: EnvironmentId, path: string): string {
140156
return JSON.stringify([environmentId, path]);

0 commit comments

Comments
 (0)