Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Publish URL showing based on aliasAssigned and entityID check #693

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ui/admin/app/components/agent/Agent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LibraryIcon, PlusIcon, WrenchIcon } from "lucide-react";
import { useCallback, useState } from "react";
import { useCallback, useEffect, useState } from "react";

import { Agent as AgentType } from "~/lib/model/agents";
import { cn } from "~/lib/utils";
Expand Down Expand Up @@ -27,6 +27,15 @@

const [agentUpdates, setAgentUpdates] = useState(agent);

useEffect(() => {
if (agent.id === agentUpdates.id) {
setAgentUpdates({
...agentUpdates,
aliasAssigned: agent.aliasAssigned ?? false,
});
}
}, [agent]);

Check warning on line 37 in ui/admin/app/components/agent/Agent.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'agentUpdates'. Either include it or remove the dependency array. You can also do a functional update 'setAgentUpdates(a => ...)' if you only need 'agentUpdates' in the 'setAgentUpdates' call
ivyjeong13 marked this conversation as resolved.
Show resolved Hide resolved
ivyjeong13 marked this conversation as resolved.
Show resolved Hide resolved

const partialSetAgent = useCallback(
(changes: Partial<typeof agent>) => {
const updatedAgent = { ...agent, ...agentUpdates, ...changes };
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/app/components/agent/AgentContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function AgentProvider({
<AgentContext.Provider
value={{
agentId,
agent,
agent: getAgent.data ?? agent,
updateAgent: updateAgent.execute,
isUpdating: updateAgent.isLoading,
lastUpdated,
Expand Down
14 changes: 7 additions & 7 deletions ui/admin/app/components/agent/AgentPublishStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function AgentPublishStatus({
() => AssistantApiService.getAssistants()
);

const refAgent = useMemo(() => {
const refAssistant = useMemo(() => {
if (!getAssistants.data) return null;

return getAssistants.data.find(({ id }) => id === agent.alias);
Expand All @@ -53,14 +53,14 @@ export function AgentPublishStatus({
function renderAgentRef() {
if (!agent.alias) return <div />;

if (refAgent && refAgent.id !== agent.id) {
if (refAssistant && refAssistant.entityID !== agent.id) {
const route =
refAgent.type === "agent"
refAssistant.type === "agent"
? $path("/agents/:agent", {
agent: refAgent.entityID,
agent: refAssistant.entityID,
})
: $path("/workflows/:workflow", {
workflow: refAgent.entityID,
workflow: refAssistant.entityID,
});

return (
Expand All @@ -72,13 +72,13 @@ export function AgentPublishStatus({

<TypographySmall className="pb-0 text-muted-foreground">
<span className="min-w-fit">
Ref name <b>{refAgent.id}</b> used by{" "}
Ref name <b>{refAssistant.id}</b> used by{" "}
</span>
<Link
className="text-accent-foreground underline"
to={route}
>
{refAgent.name}
{refAssistant.name}
</Link>
</TypographySmall>
</div>
Expand Down