Skip to content

Commit f715e30

Browse files
committed
fix(web): polish multi-machine settings labels and rows
1 parent 0f8ab90 commit f715e30

7 files changed

Lines changed: 84 additions & 65 deletions

File tree

‎apps/web/src/components/settings/ScheduledTasksSettings.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ import { readEnvironmentScope } from "~/state/session";
6868
import { useSettingsScope } from "./SettingsScopeContext";
6969
import { EnvironmentRow, environmentTransportLabel } from "./EnvironmentRow";
7070
import { SettingsGroup } from "./SettingsGroup";
71-
import { settingsScopeEnvironmentLabels } from "./settingsScopeAxis";
71+
import {
72+
settingsScopeEnvironmentAddress,
73+
settingsScopeEnvironmentLabels,
74+
} from "./settingsScopeAxis";
7275
import {
7376
WEBHOOK_SIGNATURE_DEFAULTS,
7477
matchesScheduledTaskScope,
@@ -1202,7 +1205,7 @@ function ScheduledTaskEditorDialog({
12021205
other.label === entry.label,
12031206
) ? (
12041207
<span className="block max-w-72 truncate text-xs text-muted-foreground">
1205-
{entry.displayUrl ?? entry.environmentId}
1208+
{settingsScopeEnvironmentAddress(entry)}
12061209
</span>
12071210
) : null}
12081211
</span>

‎apps/web/src/components/settings/SettingInheritance.tsx‎

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,20 @@ export function SettingInheritance({
200200
(candidate) => candidate.environmentId === target.environmentId,
201201
);
202202
if (!environment?.serverConfig) return [];
203+
const labels = settingsScopeEnvironmentLabels(environment, environments);
204+
const path = scopeContext?.scope.members.find(
205+
(member) => member.environmentId === target.environmentId && member.id === target.projectId,
206+
)?.workspaceRoot;
207+
const secondary = [labels.secondary, path?.split(/[\\/]/).filter(Boolean).slice(-2).join("/")]
208+
.filter(Boolean)
209+
.join(" · ");
203210
return [
204211
{
205212
id: `${target.environmentId}:${target.projectId ?? ""}`,
206213
target,
207-
labels: settingsScopeEnvironmentLabels(environment, environments),
208-
path: scopeContext?.scope.members.find(
209-
(member) =>
210-
member.environmentId === target.environmentId && member.id === target.projectId,
211-
)?.workspaceRoot,
214+
labels,
215+
path,
216+
secondary,
212217
environment: { ...environment, serverConfig: environment.serverConfig },
213218
machine: resolveEnvironmentMachineKind(environment.serverConfig),
214219
},
@@ -274,7 +279,7 @@ export function SettingInheritance({
274279
onValueChange={setSelectedTargetId}
275280
>
276281
<SelectTrigger
277-
size={selected.labels.secondary ? "sm" : "xs"}
282+
size={selected.secondary ? "sm" : "xs"}
278283
aria-label="Inheritance target"
279284
>
280285
<SelectValue>
@@ -284,44 +289,31 @@ export function SettingInheritance({
284289
kind={selected.machine}
285290
className="size-3.5 shrink-0"
286291
/>
287-
<span className="min-w-0">
292+
<span className="min-w-0 flex-1">
288293
<span className="block truncate">{selected.labels.primary}</span>
289-
{selected.labels.secondary ? (
290-
<span className="block truncate text-xs text-muted-foreground">
291-
{selected.labels.secondary}
292-
</span>
294+
{selected.secondary ? (
295+
<Tooltip>
296+
<TooltipTrigger
297+
render={
298+
<span className="block truncate text-xs text-muted-foreground" />
299+
}
300+
>
301+
{selected.secondary}
302+
</TooltipTrigger>
303+
<TooltipPopup>{selected.path ?? selected.secondary}</TooltipPopup>
304+
</Tooltip>
293305
) : null}
294306
</span>
295-
{selected.path ? (
296-
<Tooltip>
297-
<TooltipTrigger
298-
render={
299-
<span
300-
dir="rtl"
301-
className="min-w-0 truncate text-left text-muted-foreground"
302-
/>
303-
}
304-
>
305-
<bdi>{selected.path}</bdi>
306-
</TooltipTrigger>
307-
<TooltipPopup>{selected.path}</TooltipPopup>
308-
</Tooltip>
309-
) : null}
310307
</span>
311308
</SelectValue>
312309
</SelectTrigger>
313310
<SelectPopup alignItemWithTrigger={false}>
314-
{chains.map(({ id, labels, path }) => (
311+
{chains.map(({ id, labels, secondary }) => (
315312
<SelectItem key={id} value={id}>
316313
<div className="max-w-64">
317314
<p className="truncate">{labels.primary}</p>
318-
{labels.secondary ? (
319-
<p className="truncate text-xs text-muted-foreground">{labels.secondary}</p>
320-
) : null}
321-
{path ? (
322-
<p dir="rtl" className="truncate text-left text-xs text-muted-foreground">
323-
<bdi>{path}</bdi>
324-
</p>
315+
{secondary ? (
316+
<p className="truncate text-xs text-muted-foreground">{secondary}</p>
325317
) : null}
326318
</div>
327319
</SelectItem>

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,21 +3650,20 @@ export function ArchivedThreadsPanel() {
36503650
}}
36513651
title={thread.title}
36523652
description={
3653-
<>
3653+
<span className={scope.environmentIds.length > 1 ? "block truncate" : undefined}>
36543654
{scope.environmentIds.length > 1 ? (
36553655
<>
3656-
<span className="block">{thread.environmentLabels.primary}</span>
3657-
{thread.environmentLabels.secondary ? (
3658-
<span className="block truncate">
3659-
{thread.environmentLabels.secondary}
3660-
</span>
3661-
) : null}
3656+
{thread.environmentLabels.primary}
3657+
{thread.environmentLabels.secondary
3658+
? ` (${thread.environmentLabels.secondary})`
3659+
: ""}
3660+
{" · "}
36623661
</>
36633662
) : null}
36643663
Archived {formatRelativeTimeLabel(thread.archivedAt ?? thread.createdAt)}
36653664
{" \u00b7 Created "}
36663665
{formatRelativeTimeLabel(thread.createdAt)}
3667-
</>
3666+
</span>
36683667
}
36693668
control={
36703669
<Button

‎apps/web/src/components/settings/SettingsScopeNotice.tsx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ export function SettingsScopeNotice({
145145
],
146146
},
147147
];
148-
const choiceCount = choiceGroups.reduce((total, group) => total + group.choices.length, 0);
149148
const renderChoices = (choices: ScopeChoice[]) =>
150149
choices.map((choice) => (
151150
<button
@@ -184,12 +183,7 @@ export function SettingsScopeNotice({
184183
<p role="status" className="px-3 text-sm text-muted-foreground sm:px-4">
185184
{children}
186185
</p>
187-
<div
188-
className={cn(
189-
"space-y-4",
190-
choiceCount > 6 && "max-h-96 overflow-y-auto overscroll-contain",
191-
)}
192-
>
186+
<div className="space-y-4">
193187
{choiceGroups.map((group) =>
194188
group.title ? (
195189
<SettingsSection key={group.key} title={group.title}>

‎apps/web/src/components/settings/SettingsScopeSentence.tsx‎

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,23 @@ function EnvironmentScopeMenu({
296296
);
297297
}
298298

299-
function ProjectScopeMenu({ value, groups, onChange }: SettingsScopeMenuProps) {
299+
function ProjectScopeMenu({ value, groups, environments, onChange }: SettingsScopeMenuProps) {
300300
const selected = groups.find((group) => group.projectKey === value.project);
301+
const projects = groups.map((group) => ({
302+
group,
303+
machines: Array.from(
304+
new Set(
305+
group.memberProjects.map((member) => {
306+
const environment = environments.find(
307+
(entry) => entry.environmentId === member.environmentId,
308+
);
309+
if (!environment) return member.environmentLabel ?? member.environmentId;
310+
const { primary, secondary } = settingsScopeEnvironmentLabels(environment);
311+
return `${primary} · ${secondary}`;
312+
}),
313+
),
314+
).join(", "),
315+
}));
301316
return (
302317
<ScopeMenu
303318
ariaLabel="Project scope"
@@ -307,12 +322,24 @@ function ProjectScopeMenu({ value, groups, onChange }: SettingsScopeMenuProps) {
307322
onChange={(next) => onChange(selectProjectAxis(value, next))}
308323
searchLabel="Search projects"
309324
allOption={{ value: ALL_PROJECTS_VALUE, label: "All projects" }}
310-
options={groups.map((group) => ({
311-
value: group.projectKey,
312-
label: group.displayName,
313-
secondary: group.workspaceRoot,
314-
icon: <ProjectFavicon project={group} className="size-3.5 shrink-0" />,
315-
}))}
325+
options={projects.map(({ group, machines }) => {
326+
const sameName = projects.filter(
327+
(other) =>
328+
other.group.projectKey !== group.projectKey &&
329+
other.group.displayName === group.displayName,
330+
);
331+
return {
332+
value: group.projectKey,
333+
label: group.displayName,
334+
secondary:
335+
sameName.length === 0
336+
? group.workspaceRoot
337+
: sameName.some((other) => other.machines === machines)
338+
? `${machines} · ${group.workspaceRoot}`
339+
: machines,
340+
icon: <ProjectFavicon project={group} className="size-3.5 shrink-0" />,
341+
};
342+
})}
316343
/>
317344
);
318345
}

‎apps/web/src/components/settings/settingsScopeAxis.test.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ describe("settings scope environment labels", () => {
2525
const environments = [first, second];
2626
expect(
2727
environments.map((environment) => settingsScopeEnvironmentLabel(environment, environments)),
28-
).toEqual([
29-
"Development · https://first.example.com",
30-
"Development · https://second.example.com",
31-
]);
28+
).toEqual(["Development · first.example.com", "Development · second.example.com"]);
3229
});
3330

3431
it("falls back to environment IDs when duplicate names have no display URL", () => {

‎apps/web/src/components/settings/settingsScopeAxis.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import type { ResolvedSettingsScope, SettingsScopeSearch } from "./settingsScope
33

44
type ScopeEnvironment = Pick<EnvironmentPresentation, "environmentId" | "label" | "displayUrl">;
55

6+
export function settingsScopeEnvironmentAddress(environment: ScopeEnvironment) {
7+
if (!environment.displayUrl) return environment.environmentId;
8+
try {
9+
return new URL(environment.displayUrl).host || environment.displayUrl;
10+
} catch {
11+
return environment.displayUrl;
12+
}
13+
}
14+
615
export function settingsScopeEnvironmentLabels(
716
environment: ScopeEnvironment,
817
environments?: readonly ScopeEnvironment[],
@@ -14,9 +23,7 @@ export function settingsScopeEnvironmentLabels(
1423
return {
1524
primary: environment.label,
1625
secondary:
17-
environments === undefined || duplicate
18-
? (environment.displayUrl ?? environment.environmentId)
19-
: "",
26+
environments === undefined || duplicate ? settingsScopeEnvironmentAddress(environment) : "",
2027
};
2128
}
2229

0 commit comments

Comments
 (0)