Skip to content

Commit 7076b3c

Browse files
committed
link to docs in toast and use validate for uuid
1 parent fc50b1b commit 7076b3c

File tree

4 files changed

+50
-12
lines changed

4 files changed

+50
-12
lines changed

src/components/agent-inbox/components/generic-inbox-item.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { constructOpenInStudioURL } from "../utils";
99
import { Button } from "@/components/ui/button";
1010
import { useThreadsContext } from "../contexts/ThreadContext";
1111
import { useQueryParams } from "../hooks/use-query-params";
12-
import { VIEW_STATE_THREAD_QUERY_PARAM } from "../constants";
12+
import {
13+
STUDIO_NOT_WORKING_TROUBLESHOOTING_URL,
14+
VIEW_STATE_THREAD_QUERY_PARAM,
15+
} from "../constants";
1316

1417
interface GenericInboxItemProps<
1518
ThreadValues extends Record<string, any> = Record<string, any>,
@@ -50,10 +53,26 @@ export function GenericInboxItem<
5053
if (studioUrl === "#") {
5154
toast({
5255
title: "Error",
53-
description:
54-
"Could not construct Studio URL. Check if inbox has necessary details (Project ID, Tenant ID).",
56+
description: (
57+
<>
58+
<p>
59+
Could not construct Studio URL. Check if inbox has necessary
60+
details (Project ID, Tenant ID).
61+
</p>
62+
<p>
63+
If the issue persists, see the{" "}
64+
<a
65+
href={STUDIO_NOT_WORKING_TROUBLESHOOTING_URL}
66+
target="_blank"
67+
rel="noopener noreferrer"
68+
>
69+
troubleshooting section
70+
</a>
71+
</p>
72+
</>
73+
),
5574
variant: "destructive",
56-
duration: 5000,
75+
duration: 10000,
5776
});
5877
} else {
5978
window.open(studioUrl, "_blank");

src/components/agent-inbox/components/thread-actions-view.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { ThreadIdCopyable } from "./thread-id";
66
import { InboxItemInput } from "./inbox-item-input";
77
import useInterruptedActions from "../hooks/use-interrupted-actions";
88
import { TooltipIconButton } from "@/components/ui/assistant-ui/tooltip-icon-button";
9-
import { VIEW_STATE_THREAD_QUERY_PARAM } from "../constants";
9+
import {
10+
STUDIO_NOT_WORKING_TROUBLESHOOTING_URL,
11+
VIEW_STATE_THREAD_QUERY_PARAM,
12+
} from "../constants";
1013
import { useToast } from "@/hooks/use-toast";
1114
import { cn } from "@/lib/utils";
1215
import { useQueryParams } from "../hooks/use-query-params";
@@ -122,10 +125,26 @@ export function ThreadActionsView<
122125
// Handle case where URL construction failed (e.g., missing data)
123126
toast({
124127
title: "Error",
125-
description:
126-
"Could not construct Studio URL. Check if inbox has necessary details (Project ID, Tenant ID).",
128+
description: (
129+
<>
130+
<p>
131+
Could not construct Studio URL. Check if inbox has necessary
132+
details (Project ID, Tenant ID).
133+
</p>
134+
<p>
135+
If the issue persists, see the{" "}
136+
<a
137+
href={STUDIO_NOT_WORKING_TROUBLESHOOTING_URL}
138+
target="_blank"
139+
rel="noopener noreferrer"
140+
>
141+
troubleshooting section
142+
</a>
143+
</p>
144+
</>
145+
),
127146
variant: "destructive",
128-
duration: 5000,
147+
duration: 10000,
129148
});
130149
} else {
131150
window.open(studioUrl, "_blank");

src/components/agent-inbox/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export const AGENT_INBOX_PARAM = "agent_inbox";
88
export const NO_INBOXES_FOUND_PARAM = "no_inboxes_found";
99
export const AGENT_INBOX_GITHUB_README_URL =
1010
"https://github.com/langchain-ai/agent-inbox/blob/main/README.md";
11+
export const STUDIO_NOT_WORKING_TROUBLESHOOTING_URL = `${AGENT_INBOX_GITHUB_README_URL}#the-open-in-studio-button-doesnt-work-for-my-deployed-graphs`;

src/components/agent-inbox/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
AgentInbox,
99
} from "./types";
1010
import { logger } from "./utils/logger";
11+
import { validate } from "uuid";
1112

1213
export function prettifyText(action: string) {
1314
return startCase(action.replace(/_/g, " "));
@@ -329,10 +330,8 @@ export function extractProjectId(inboxId: string): string | null {
329330
}
330331
const parts = inboxId.split(":");
331332
if (parts.length === 2) {
332-
// Basic check if the first part looks like a UUID v4
333-
const uuidV4Regex =
334-
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
335-
if (uuidV4Regex.test(parts[0])) {
333+
// Ensure the first part is a valid UUID
334+
if (validate(parts[0])) {
336335
return parts[0];
337336
}
338337
}

0 commit comments

Comments
 (0)