-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: workflows to user tasks, task runs & chat threads (#1695)
* enhance: workflows -> user tasks, task runs & chat threads * add filter & update tests * style fixes * change useRowNavigate * add meta to Tasks * Update _auth.chat-threads._index.tsx * cronjob, account for taskSchedule & remove unused ScheduleForm * remove preauth from workflow/task tools
- Loading branch information
1 parent
c66ee15
commit daa59c2
Showing
57 changed files
with
1,600 additions
and
1,743 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { XIcon } from "lucide-react"; | ||
import { useMemo } from "react"; | ||
import { useNavigate, useSearchParams } from "react-router"; | ||
import { $path, Routes } from "safe-routes"; | ||
|
||
import { Agent } from "~/lib/model/agents"; | ||
import { User } from "~/lib/model/users"; | ||
import { Workflow } from "~/lib/model/workflows"; | ||
import { RouteService } from "~/lib/service/routeService"; | ||
|
||
import { Button } from "~/components/ui/button"; | ||
|
||
type QueryParams = { | ||
agentId?: string; | ||
userId?: string; | ||
taskId?: string; | ||
}; | ||
|
||
export function Filters({ | ||
agentMap, | ||
userMap, | ||
workflowMap, | ||
url, | ||
}: { | ||
agentMap?: Map<string, Agent>; | ||
userMap?: Map<string, User>; | ||
workflowMap?: Map<string, Workflow>; | ||
url: keyof Routes; | ||
}) { | ||
const [searchParams] = useSearchParams(); | ||
const navigate = useNavigate(); | ||
|
||
const filters = useMemo(() => { | ||
const query = | ||
(RouteService.getQueryParams( | ||
url, | ||
searchParams.toString() | ||
) as QueryParams) ?? {}; | ||
const { ...filters } = query; // TODO: from | ||
|
||
const updateFilters = (param: keyof QueryParams) => { | ||
const newQuery = { ...query }; | ||
delete newQuery[param]; | ||
// Filter out null/undefined values and ensure all values are strings | ||
const cleanQuery = Object.fromEntries( | ||
Object.entries(newQuery) | ||
.filter(([_, v]) => v != null) | ||
.map(([k, v]) => [k, String(v)]) | ||
) as Parameters<typeof $path>[1]; | ||
return navigate($path(url, cleanQuery)); | ||
}; | ||
|
||
return [ | ||
"agentId" in filters && | ||
filters.agentId && | ||
agentMap && { | ||
key: "agentId", | ||
label: "Agent", | ||
value: agentMap.get(filters.agentId)?.name ?? filters.agentId, | ||
onRemove: () => updateFilters("agentId"), | ||
}, | ||
"userId" in filters && | ||
filters.userId && | ||
userMap && { | ||
key: "userId", | ||
label: "User", | ||
value: userMap.get(filters.userId)?.email ?? filters.userId, | ||
onRemove: () => updateFilters("userId"), | ||
}, | ||
"taskId" in filters && | ||
filters.taskId && | ||
workflowMap && { | ||
key: "taskId", | ||
label: "Task", | ||
value: workflowMap?.get(filters.taskId)?.name ?? filters.taskId, | ||
onRemove: () => updateFilters("taskId"), | ||
}, | ||
].filter((x) => !!x); | ||
}, [navigate, searchParams, agentMap, userMap, workflowMap, url]); | ||
|
||
return ( | ||
<div className="flex gap-2 pb-2"> | ||
{filters.map((filter) => ( | ||
<Button | ||
key={filter.key} | ||
size="badge" | ||
onClick={filter.onRemove} | ||
variant="accent" | ||
shape="pill" | ||
endContent={<XIcon />} | ||
> | ||
<b>{filter.label}:</b> {filter.value} | ||
</Button> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { SearchIcon } from "lucide-react"; | ||
import { useState } from "react"; | ||
|
||
import { Input } from "~/components/ui/input"; | ||
import { useDebounce } from "~/hooks/useDebounce"; | ||
|
||
export function SearchInput({ | ||
onChange, | ||
placeholder = "Search...", | ||
}: { | ||
onChange: (value: string) => void; | ||
placeholder?: string; | ||
}) { | ||
const [searchQuery, setSearchQuery] = useState(""); | ||
const debounceOnChange = useDebounce(onChange, 300); | ||
return ( | ||
<div className="relative"> | ||
<Input | ||
type="text" | ||
placeholder={placeholder} | ||
value={searchQuery} | ||
onChange={(e) => { | ||
setSearchQuery(e.target.value); | ||
debounceOnChange(e.target.value); | ||
}} | ||
startContent={<SearchIcon className="h-5 w-5 text-gray-400" />} | ||
className="w-64" | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.