Skip to content

Commit fcf9f40

Browse files
maria-rcksclaude
andcommitted
fix(web): pin project environment label order and keep the popup viewport clamp
"Local" now always leads a grouped project's labels instead of following registration order, an unlabeled remote member reads "Remote" instead of disappearing, the scope popup keeps its available-width clamp under the 20rem cap, the scoped trigger lets the label yield to the project name, and search matches the rendered "Local · <remote>" string. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 0bca90c commit fcf9f40

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,8 +2382,10 @@ export default function Sidebar() {
23822382
matches: (item, query) =>
23832383
projectScopeFilter.contains(item, query, (candidate) => candidate.label) ||
23842384
(showProjectEnvironments &&
2385-
item.environmentLabels.some((label) =>
2386-
projectScopeFilter.contains(label, query, (candidate) => candidate),
2385+
projectScopeFilter.contains(
2386+
item.environmentLabels.join(" · "),
2387+
query,
2388+
(candidate) => candidate,
23872389
)),
23882390
}),
23892391
[
@@ -4471,6 +4473,9 @@ export default function Sidebar() {
44714473
</span>
44724474
{scopedProjectGroup && showProjectEnvironments ? (
44734475
<ProjectEnvironmentLabel
4476+
// The trigger has no tooltip, so at narrow sidebar
4477+
// widths the label yields to the project name.
4478+
className="shrink"
44744479
labels={scopedProjectGroup.environmentLabels}
44754480
machine={resolveProjectGroupMachine({
44764481
group: scopedProjectGroup,
@@ -4489,7 +4494,7 @@ export default function Sidebar() {
44894494
className={cn(
44904495
"min-w-0 overflow-hidden",
44914496
showProjectEnvironments
4492-
? "w-max min-w-(--anchor-width) max-w-80"
4497+
? "w-max min-w-(--anchor-width) max-w-[min(20rem,var(--available-width))]"
44934498
: "w-(--anchor-width)",
44944499
)}
44954500
>

‎apps/web/src/environmentGrouping.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,22 @@ describe("environment grouping", () => {
109109
environmentId === remoteEnvironmentId ? "Mac mini" : "Primary",
110110
});
111111

112-
const groups = build([grouped, groupedRemote, separateLocal, separateRemote]);
112+
const groups = build([groupedRemote, grouped, separateLocal, separateRemote]);
113113
expect(groups.map((group) => group.environmentLabels)).toEqual([
114114
["Local", "Mac mini"],
115115
["Local"],
116116
["Mac mini"],
117117
]);
118118
expect(projectGroupsSpanEnvironments(groups)).toBe(true);
119119
expect(projectGroupsSpanEnvironments(build([grouped, separateLocal]))).toBe(false);
120+
121+
const unlabeled = buildSidebarProjectSnapshots({
122+
projects: [grouped, groupedRemote],
123+
settings: defaultGroupingSettings,
124+
primaryEnvironmentId,
125+
resolveEnvironmentLabel: () => null,
126+
});
127+
expect(unlabeled[0]?.environmentLabels).toEqual(["Local", "Remote"]);
120128
});
121129

122130
it("keeps projects without repository identity physically scoped", () => {

‎apps/web/src/sidebarProjectGrouping.ts‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,14 @@ export function buildSidebarProjectSnapshots(input: {
114114
const remoteEnvironmentLabels = remoteMembers
115115
.flatMap((member) => (member.environmentLabel ? [member.environmentLabel] : []))
116116
.filter((label, index, labels) => labels.indexOf(label) === index);
117-
const environmentLabels = members
118-
.flatMap((member) =>
119-
member.environmentId === input.primaryEnvironmentId
120-
? ["Local"]
121-
: member.environmentLabel
122-
? [member.environmentLabel]
123-
: [],
124-
)
125-
.filter((label, index, labels) => labels.indexOf(label) === index);
117+
// "Local" leads regardless of member order, which follows registration
118+
// order and so can differ between sessions.
119+
const environmentLabels = [
120+
...(hasLocal ? ["Local"] : []),
121+
...members
122+
.filter((member) => member.environmentId !== input.primaryEnvironmentId)
123+
.map((member) => member.environmentLabel ?? "Remote"),
124+
].filter((label, index, labels) => labels.indexOf(label) === index);
126125
const isDesktopLocal = input.isDesktopLocalEnvironment ?? (() => false);
127126
const isWsl = input.isWslEnvironment ?? (() => false);
128127
const allRemoteMembersAreDesktopLocal =

0 commit comments

Comments
 (0)