Skip to content

Commit 6f70049

Browse files
authored
fix: rearrange sidebar nav items & combobox multi-highlight name fix (#1732)
* fix: rearrange sidebar nav items & combobox multi-highlight name fix * add sublabel and min-w for combobox table filter * Update ComboBox.tsx
1 parent 533b216 commit 6f70049

File tree

5 files changed

+69
-16
lines changed

5 files changed

+69
-16
lines changed

ui/admin/app/components/composed/ComboBox.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { CheckIcon, ChevronsUpDownIcon } from "lucide-react";
22
import { ReactNode, useState } from "react";
33

4+
import { cn } from "~/lib/utils";
5+
46
import { Button, ButtonProps } from "~/components/ui/button";
57
import {
68
Command,
@@ -20,7 +22,8 @@ import { useIsMobile } from "~/hooks/use-mobile";
2022

2123
type BaseOption = {
2224
id: string;
23-
name?: string | undefined;
25+
name?: string;
26+
sublabel?: string;
2427
};
2528

2629
type GroupedOption<T extends BaseOption> = {
@@ -42,6 +45,9 @@ type ComboBoxProps<T extends BaseOption> = {
4245
renderOption?: (option: T) => ReactNode;
4346
validateCreate?: (value: string) => boolean;
4447
value?: T | null;
48+
classNames?: {
49+
command?: string;
50+
};
4551
};
4652

4753
export function ComboBox<T extends BaseOption>({
@@ -125,6 +131,7 @@ function ComboBoxList<T extends BaseOption>({
125131
placeholder = "Filter...",
126132
emptyLabel = "No results found.",
127133
closeOnSelect = true,
134+
classNames,
128135
}: { setOpen: (open: boolean) => void } & ComboBoxProps<T>) {
129136
const [filteredOptions, setFilteredOptions] =
130137
useState<typeof options>(options);
@@ -173,7 +180,10 @@ function ComboBoxList<T extends BaseOption>({
173180
return (
174181
<Command
175182
shouldFilter={false}
176-
className="max-h-[50vh] w-[var(--radix-popper-anchor-width)]"
183+
className={cn(
184+
"max-h-[50vh] w-[var(--radix-popper-anchor-width)]",
185+
classNames?.command
186+
)}
177187
>
178188
<CommandInput
179189
placeholder={placeholder}
@@ -235,7 +245,7 @@ function ComboBoxList<T extends BaseOption>({
235245
return (
236246
<CommandItem
237247
key={option.id}
238-
value={option.name}
248+
value={option.id}
239249
onSelect={() => {
240250
onChange(option);
241251
if (closeOnSelect) setOpen(false);
@@ -244,6 +254,12 @@ function ComboBoxList<T extends BaseOption>({
244254
>
245255
<span>
246256
{renderOption ? renderOption(option) : (option.name ?? option.id)}
257+
{option.sublabel && (
258+
<small className="text-muted-foreground">
259+
{" "}
260+
({option.sublabel})
261+
</small>
262+
)}
247263
</span>
248264
{value?.id === option.id && <CheckIcon className="h-4 w-4" />}
249265
</CommandItem>

ui/admin/app/components/composed/DataTable.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ export const DataTableFilter = ({
161161
placeholder={field}
162162
onChange={(option) => onSelect(option?.id ?? "")}
163163
options={values}
164+
classNames={{
165+
command: "min-w-64",
166+
}}
164167
/>
165168
);
166169
};

ui/admin/app/components/sidebar/Sidebar.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ const items = [
5151
url: $path("/chat-threads"),
5252
icon: MessageSquare,
5353
},
54+
{
55+
title: "Tasks",
56+
url: $path("/tasks"),
57+
icon: PuzzleIcon,
58+
},
59+
{
60+
title: "Task Runs",
61+
url: $path("/task-runs"),
62+
icon: CpuIcon,
63+
},
5464
{
5565
title: "Tools",
5666
url: $path("/tools"),
@@ -62,16 +72,6 @@ const items = [
6272
icon: User,
6373
requiresAuth: true,
6474
},
65-
{
66-
title: "Tasks",
67-
url: $path("/tasks"),
68-
icon: PuzzleIcon,
69-
},
70-
{
71-
title: "Task Runs",
72-
url: $path("/task-runs"),
73-
icon: CpuIcon,
74-
},
7575
{
7676
title: "Model Providers",
7777
url: $path("/model-providers"),

ui/admin/app/routes/_auth.task-runs._index.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,21 @@ export default function TaskRuns() {
7575
WorkflowService.getWorkflows
7676
);
7777

78+
const getAgents = useSWR(...AgentService.getAgents.swr({}));
7879
const getUsers = useSWR(UserService.getUsers.key(), UserService.getUsers);
7980

81+
const agentThreadMap = useMemo(() => {
82+
const agentMap = new Map(getAgents.data?.map((agent) => [agent.id, agent]));
83+
return new Map(
84+
getThreads?.data
85+
?.filter((thread) => thread.agentID)
86+
.map((thread) => {
87+
const agent = agentMap.get(thread.agentID!);
88+
return [thread.id, agent?.name ?? "-"];
89+
})
90+
);
91+
}, [getAgents.data, getThreads.data]);
92+
8093
const workflowMap = useMemo(
8194
() =>
8295
new Map(getWorkflows.data?.map((workflow) => [workflow.id, workflow])),
@@ -128,6 +141,15 @@ export default function TaskRuns() {
128141
return filteredThreads;
129142
}, [threads, taskId, userId]);
130143

144+
const namesCount = useMemo(() => {
145+
return (
146+
getWorkflows.data?.reduce<Record<string, number>>((acc, workflow) => {
147+
acc[workflow.name] = (acc[workflow.name] || 0) + 1;
148+
return acc;
149+
}, {}) ?? {}
150+
);
151+
}, [getWorkflows.data]);
152+
131153
const itemsToDisplay = search
132154
? data.filter(
133155
(item) =>
@@ -171,6 +193,10 @@ export default function TaskRuns() {
171193
getWorkflows.data?.map((workflow) => ({
172194
id: workflow.id,
173195
name: workflow.name,
196+
sublabel:
197+
namesCount?.[workflow.name] > 1
198+
? agentThreadMap.get(workflow.threadID ?? "")
199+
: "",
174200
})) ?? []
175201
}
176202
onSelect={(value) => {

ui/admin/app/routes/_auth.tasks._index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ export default function Tasks() {
143143
return filteredTasks;
144144
}, [tasks, search, agentId, userId, taskId]);
145145

146+
const namesCount = useMemo(() => {
147+
return data.reduce<Record<string, number>>((acc, task) => {
148+
acc[task.name] = (acc[task.name] || 0) + 1;
149+
return acc;
150+
}, {});
151+
}, [data]);
152+
146153
return (
147154
<div>
148155
<div className="flex h-full flex-col gap-4 p-6">
@@ -183,9 +190,10 @@ export default function Tasks() {
183190
key={column.id}
184191
field="Task"
185192
values={
186-
getWorkflows.data?.map((workflow) => ({
187-
id: workflow.id,
188-
name: workflow.name,
193+
data?.map((task) => ({
194+
id: task.id,
195+
name: task.name,
196+
sublabel: namesCount[task.name] > 1 ? task.agent : "",
189197
})) ?? []
190198
}
191199
onSelect={(value) => {

0 commit comments

Comments
 (0)