Skip to content

Commit 72bbaec

Browse files
authored
Match create-channel template selector styling (#2654)
1 parent 9081ab0 commit 72bbaec

4 files changed

Lines changed: 119 additions & 22 deletions

File tree

‎desktop/src/features/sidebar/ui/CreateChannelFormFields.tsx‎

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
import { ChevronDown } from "lucide-react";
2+
13
import type { ChannelTemplate } from "@/shared/api/types";
24
import { cn } from "@/shared/lib/cn";
35
import { Button } from "@/shared/ui/button";
6+
import {
7+
DropdownMenu,
8+
DropdownMenuContent,
9+
DropdownMenuRadioGroup,
10+
DropdownMenuRadioItem,
11+
DropdownMenuTrigger,
12+
} from "@/shared/ui/dropdown-menu";
413
import { Input } from "@/shared/ui/input";
514
import { Textarea } from "@/shared/ui/textarea";
615

@@ -14,6 +23,7 @@ import type { CreateChannelFormState } from "@/features/sidebar/lib/useCreateCha
1423

1524
const CREATE_LABEL_OPTIONAL_CLASS =
1625
"ml-1 text-xs font-normal text-muted-foreground/50";
26+
const NO_TEMPLATE_VALUE = "__no-template__";
1727

1828
export const CREATE_CHANNEL_FORM_ID = "create-channel-form";
1929

@@ -29,6 +39,9 @@ export function CreateChannelFormFields({
2939
form: CreateChannelFormState;
3040
}) {
3141
const { channelKind, kindLabel, isCreating } = form;
42+
const selectedTemplate = form.templates.find(
43+
(template) => template.id === form.selectedTemplateId,
44+
);
3245

3346
return (
3447
<div className="space-y-5">
@@ -104,29 +117,59 @@ export function CreateChannelFormFields({
104117
/>
105118

106119
{form.templates.length > 0 ? (
107-
<div className="space-y-1.5">
108-
<label
109-
className="text-sm font-medium text-foreground"
110-
htmlFor="create-channel-template"
111-
>
120+
<div
121+
className={cn(
122+
"flex min-h-12 items-center justify-between gap-4 rounded-xl border border-input bg-background px-3 py-3",
123+
isCreating && "opacity-50",
124+
)}
125+
>
126+
<span className="text-sm font-medium text-foreground">
112127
Template
113128
<span className={CREATE_LABEL_OPTIONAL_CLASS}>Optional</span>
114-
</label>
115-
<select
116-
className="flex min-h-11 w-full rounded-xl border border-input bg-muted/40 px-3 py-2 text-sm text-muted-foreground/55 shadow-none transition-colors duration-150 ease-out hover:border-muted-foreground/40 focus:border-muted-foreground/50 focus:text-foreground focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50"
117-
data-testid="create-channel-template"
118-
disabled={isCreating}
119-
id="create-channel-template"
120-
onChange={(event) => form.handleTemplateChange(event.target.value)}
121-
value={form.selectedTemplateId ?? ""}
122-
>
123-
<option value="">No template</option>
124-
{form.templates.map((template: ChannelTemplate) => (
125-
<option key={template.id} value={template.id}>
126-
{template.name}
127-
</option>
128-
))}
129-
</select>
129+
</span>
130+
<DropdownMenu modal={false}>
131+
<DropdownMenuTrigger asChild>
132+
<Button
133+
aria-label={`Template: ${selectedTemplate?.name ?? "No template"}`}
134+
className="-mr-2.5 ml-auto h-9 min-w-0 max-w-[60%] justify-end px-2.5 text-right text-sm font-medium text-foreground hover:bg-muted/50"
135+
data-testid="create-channel-template"
136+
disabled={isCreating}
137+
id="create-channel-template"
138+
type="button"
139+
variant="ghost"
140+
>
141+
<span className="truncate text-right">
142+
{selectedTemplate?.name ?? "No template"}
143+
</span>
144+
<ChevronDown className="size-4 shrink-0 text-muted-foreground/70" />
145+
</Button>
146+
</DropdownMenuTrigger>
147+
<DropdownMenuContent
148+
align="end"
149+
onCloseAutoFocus={(event) => event.preventDefault()}
150+
style={{
151+
minWidth: "var(--radix-dropdown-menu-trigger-width)",
152+
}}
153+
>
154+
<DropdownMenuRadioGroup
155+
onValueChange={(templateId) =>
156+
form.handleTemplateChange(
157+
templateId === NO_TEMPLATE_VALUE ? "" : templateId,
158+
)
159+
}
160+
value={form.selectedTemplateId ?? NO_TEMPLATE_VALUE}
161+
>
162+
<DropdownMenuRadioItem value={NO_TEMPLATE_VALUE}>
163+
No template
164+
</DropdownMenuRadioItem>
165+
{form.templates.map((template: ChannelTemplate) => (
166+
<DropdownMenuRadioItem key={template.id} value={template.id}>
167+
{template.name}
168+
</DropdownMenuRadioItem>
169+
))}
170+
</DropdownMenuRadioGroup>
171+
</DropdownMenuContent>
172+
</DropdownMenu>
130173
</div>
131174
) : null}
132175

‎desktop/src/testing/e2eBridge.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { parse as yamlParse } from "yaml";
66

77
import { relayClient } from "@/shared/api/relayClient";
88
import type { ConnectionState } from "@/shared/api/relayClientShared";
9-
import type { RelayEvent } from "@/shared/api/types";
9+
import type { ChannelTemplate, RelayEvent } from "@/shared/api/types";
1010
import { getMarkdownParseCount } from "@/shared/ui/markdown/nodeCache";
1111
import { syncAgentTurnsFromEvents } from "@/features/agents/activeAgentTurnsStore";
1212
import { recordTimeoutFromRejection } from "@/features/moderation/lib/timeoutStore";
@@ -203,6 +203,7 @@ type E2eConfig = {
203203
addChannelMembersErrors?: (string | null)[];
204204
channelMembersReadDelayMs?: number;
205205
createManagedAgentDelayMs?: number;
206+
channelTemplates?: ChannelTemplate[];
206207
channelsReadError?: string;
207208
/** Reject successive mock `get_channels` calls, then resume. */
208209
channelsReadErrors?: (string | null)[];
@@ -10063,6 +10064,19 @@ export function maybeInstallE2eTauriMocks() {
1006310064
);
1006410065
case "list_teams":
1006510066
return handleListTeams();
10067+
case "list_channel_templates":
10068+
return (activeConfig?.mock?.channelTemplates ?? []).map((template) => ({
10069+
id: template.id,
10070+
name: template.name,
10071+
description: template.description,
10072+
channel_type: template.channelType,
10073+
visibility: template.visibility,
10074+
canvas_template: template.canvasTemplate,
10075+
agents: template.agents,
10076+
is_builtin: template.isBuiltin,
10077+
created_at: template.createdAt,
10078+
updated_at: template.updatedAt,
10079+
}));
1006610080
case "create_team":
1006710081
return handleCreateTeam(
1006810082
payload as Parameters<typeof handleCreateTeam>[0],

‎desktop/tests/e2e/channels.spec.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,44 @@ test("create stream with name and description", async ({ page }) => {
12941294
await expect(page.getByTestId("chat-title")).toHaveText(channelName);
12951295
});
12961296

1297+
test("create channel template selector matches the lifecycle controls", async ({
1298+
page,
1299+
}) => {
1300+
await installMockBridge(page, {
1301+
channelTemplates: [
1302+
{
1303+
id: "project-kickoff",
1304+
name: "Project kickoff",
1305+
description: "Coordinate a new project from planning through launch.",
1306+
channelType: "stream",
1307+
visibility: "private",
1308+
canvasTemplate: null,
1309+
agents: { personas: [], teams: [] },
1310+
isBuiltin: false,
1311+
createdAt: "2026-07-23T00:00:00Z",
1312+
updatedAt: "2026-07-23T00:00:00Z",
1313+
},
1314+
],
1315+
});
1316+
1317+
await page.goto("/");
1318+
await openCreateChannelDialog(page);
1319+
1320+
const templateControl = page.getByTestId("create-channel-template");
1321+
await expect(templateControl).toHaveRole("button");
1322+
await expect(templateControl).toHaveText("No template");
1323+
await templateControl.click();
1324+
await page.getByRole("menuitemradio", { name: "Project kickoff" }).click();
1325+
1326+
await expect(templateControl).toHaveText("Project kickoff");
1327+
await expect(page.getByTestId("create-channel-description")).toHaveValue(
1328+
"Coordinate a new project from planning through launch.",
1329+
);
1330+
await expect(page.getByTestId("create-channel-permissions")).toContainText(
1331+
"Private",
1332+
);
1333+
});
1334+
12971335
test("create ephemeral stream shows sidebar and header affordances", async ({
12981336
page,
12991337
}) => {

‎desktop/tests/helpers/bridge.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Page } from "@playwright/test";
2+
import type { ChannelTemplate } from "../../src/shared/api/types";
23
import { FEATURE_OVERRIDES_STORAGE_KEY, PREVIEW_FEATURE_IDS } from "./features";
34

45
export const TEST_IDENTITIES = {
@@ -214,6 +215,7 @@ type MockBridgeOptions = {
214215
relayAgents?: MockRelayAgentSeed[];
215216
agentListDelayMs?: number;
216217
createManagedAgentDelayMs?: number;
218+
channelTemplates?: ChannelTemplate[];
217219
addChannelMembersDelayMs?: number;
218220
/** Sequenced add-member failures. A string fails that call; null succeeds. */
219221
addChannelMembersErrors?: (string | null)[];

0 commit comments

Comments
 (0)