Skip to content

Commit

Permalink
Merge pull request #396 from tylerslaton/fix-switching-error
Browse files Browse the repository at this point in the history
fix: remove workflow code and fix issue with error boundary hit during page switch
  • Loading branch information
tylerslaton authored Oct 31, 2024
2 parents f6fba3b + 60faed5 commit 213441f
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions ui/admin/app/routes/_auth.threads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import { z } from "zod";

import { Agent } from "~/lib/model/agents";
import { Thread } from "~/lib/model/threads";
import { Workflow } from "~/lib/model/workflows";
import { AgentService } from "~/lib/service/api/agentService";
import { ThreadsService } from "~/lib/service/api/threadsService";
import { WorkflowService } from "~/lib/service/api/workflowService";
import { QueryParamSchemas } from "~/lib/service/routeQueryParams";
import { parseQueryParams, timeSince } from "~/lib/utils";

Expand Down Expand Up @@ -54,14 +52,11 @@ export default function Threads() {
AgentService.getAgents
);

const getWorkflows = useSWR(
WorkflowService.getWorkflows.key(),
WorkflowService.getWorkflows
);

const agentMap = useMemo(() => {
if (!getAgents.data) return {};

// note(tylerslaton): the or condition here is because the getAgents.data can
// be an object containing a url only when switching to the agent page from the
// threads page.
if (!getAgents.data || !Array.isArray(getAgents.data)) return {};
return getAgents.data.reduce(
(acc, agent) => {
acc[agent.id] = agent;
Expand All @@ -71,18 +66,6 @@ export default function Threads() {
);
}, [getAgents.data]);

const workflowMap = useMemo(() => {
if (!getWorkflows.data) return {};

return getWorkflows.data.reduce(
(acc, workflow) => {
acc[workflow.id] = workflow;
return acc;
},
{} as Record<string, Workflow>
);
}, [getWorkflows.data]);

const threads = useMemo(() => {
if (!getThreads.data) return [];

Expand Down Expand Up @@ -135,11 +118,6 @@ export default function Threads() {
(thread) => {
if (thread.agentID)
return agentMap[thread.agentID]?.name ?? thread.agentID;
if (thread.workflowID)
return (
workflowMap[thread.workflowID]?.name ??
thread.workflowID
);
return "Unnamed";
},
{ header: "Agent" }
Expand Down

0 comments on commit 213441f

Please sign in to comment.