Skip to content

Commit 3a45848

Browse files
committed
fix(web): grouped projects renamed to the repo name keep the new label
Renaming a grouped project to just the repository name (e.g. stripping 'group/subgroup/' down to 'repo') silently snapped back to the derived 'group/subgroup/repo' label: deriveProjectGroupLabel ignored a shared title matching the repository name, and the settings rename gate skipped the write when every member title already equaled the new title. Honor a shared title that differs from the display path even when it equals the repository name, and persist every explicit settings edit. The shared-runtime fix covers web, desktop, and mobile; divergent titles still fall back to the derived display path. Built with Muse Spark 1.3 Free via OpenCode harness.
1 parent fed41fa commit 3a45848

4 files changed

Lines changed: 63 additions & 13 deletions

File tree

‎apps/web/src/components/settings/ProjectSettingsPanel.logic.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ describe("projectGroupTitleNeedsUpdate", () => {
1515
);
1616
});
1717

18-
it("skips an update when every member already has the next title", () => {
19-
expect(projectGroupTitleNeedsUpdate(["Shared name", "Shared name"], "Shared name", true)).toBe(
20-
false,
21-
);
18+
it("persists an explicit edit even when every member already has the next title", () => {
19+
expect(projectGroupTitleNeedsUpdate(["repo", "repo"], "repo", true)).toBe(true);
20+
});
21+
22+
it("still skips an untouched blur when member titles diverge", () => {
23+
expect(
24+
projectGroupTitleNeedsUpdate(["local-title", "remote-title"], "local-title", false),
25+
).toBe(false);
2226
});
2327
});
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
export function projectGroupTitleNeedsUpdate(
2-
memberTitles: ReadonlyArray<string>,
3-
nextTitle: string,
2+
_memberTitles: ReadonlyArray<string>,
3+
_nextTitle: string,
44
wasEdited: boolean,
55
): boolean {
6-
return wasEdited && memberTitles.some((title) => title !== nextTitle);
6+
// The settings field shows the derived group label, so an explicit edit is
7+
// always a rename the user expects to stick — even when every member title
8+
// already equals the next title (e.g. stripping "group/subgroup/" down to
9+
// "repo"). Untouched blurs still skip the fan-out via wasEdited.
10+
return wasEdited;
711
}

‎packages/client-runtime/src/state/projectGrouping.test.ts‎

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,57 @@ describe("buildProjectGroups", () => {
147147
);
148148
});
149149

150-
it("keeps the repository label when shared titles match its repository name", () => {
150+
it("keeps a shared rename to the plain repository name instead of the display path", () => {
151+
const gitlabIdentity = {
152+
...repositoryIdentity,
153+
canonicalKey: "gitlab.com/group/subgroup/repo",
154+
locator: {
155+
source: "git-remote" as const,
156+
remoteName: "origin",
157+
remoteUrl: "https://gitlab.com/group/subgroup/repo.git",
158+
},
159+
provider: "gitlab",
160+
owner: "group/subgroup",
161+
name: "repo",
162+
displayName: "group/subgroup/repo",
163+
};
151164
const projects = [
152-
makeProject("first", "/work/t3code", { title: "t3code" }),
153-
makeProject("second", "/work/t3code-2", { title: "t3code" }),
165+
makeProject("first", "/work/repo", { title: "repo", repositoryIdentity: gitlabIdentity }),
166+
makeProject("second", "/work/repo-2", { title: "repo", repositoryIdentity: gitlabIdentity }),
167+
];
168+
169+
expect(buildProjectGroups({ projects, settings: settings("repository") })[0]?.label).toBe(
170+
"repo",
171+
);
172+
});
173+
174+
it("falls back to the display path when grouped member titles diverge", () => {
175+
const gitlabIdentity = {
176+
...repositoryIdentity,
177+
canonicalKey: "gitlab.com/group/subgroup/repo",
178+
locator: {
179+
source: "git-remote" as const,
180+
remoteName: "origin",
181+
remoteUrl: "https://gitlab.com/group/subgroup/repo.git",
182+
},
183+
provider: "gitlab",
184+
owner: "group/subgroup",
185+
name: "repo",
186+
displayName: "group/subgroup/repo",
187+
};
188+
const projects = [
189+
makeProject("first", "/work/repo", {
190+
title: "local-checkout",
191+
repositoryIdentity: gitlabIdentity,
192+
}),
193+
makeProject("second", "/work/repo-2", {
194+
title: "remote-checkout",
195+
repositoryIdentity: gitlabIdentity,
196+
}),
154197
];
155198

156199
expect(buildProjectGroups({ projects, settings: settings("repository") })[0]?.label).toBe(
157-
"T3 Code",
200+
"group/subgroup/repo",
158201
);
159202
});
160203

‎packages/client-runtime/src/state/projectGrouping.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ export function deriveProjectGroupLabel(input: {
167167
if (
168168
sharedTitles.length === 1 &&
169169
sharedTitle !== undefined &&
170-
!sharedDisplayNames.includes(sharedTitle) &&
171-
!sharedRepositoryNames.includes(sharedTitle)
170+
!sharedDisplayNames.includes(sharedTitle)
172171
) {
173172
return sharedTitle;
174173
}

0 commit comments

Comments
 (0)