From 61eb2d313d7da180e96aa50d7fbd77ba322a7c70 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Wed, 5 Mar 2025 15:03:37 -0800 Subject: [PATCH] fix: Move add inbox button to below all inboxes in sidebar --- package.json | 3 +- .../components/add-agent-inbox-dialog.tsx | 10 +- .../components/settings-popover.tsx | 122 ++++++++---------- src/components/app-sidebar/index.tsx | 36 +++++- 4 files changed, 99 insertions(+), 72 deletions(-) diff --git a/package.json b/package.json index 78dd70d..8bf068f 100644 --- a/package.json +++ b/package.json @@ -111,5 +111,6 @@ "tsx": "^4.19.1", "typescript": "^5", "typescript-eslint": "^8.8.1" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/src/components/agent-inbox/components/add-agent-inbox-dialog.tsx b/src/components/agent-inbox/components/add-agent-inbox-dialog.tsx index 212c140..d801290 100644 --- a/src/components/agent-inbox/components/add-agent-inbox-dialog.tsx +++ b/src/components/agent-inbox/components/add-agent-inbox-dialog.tsx @@ -21,12 +21,13 @@ import { import { PasswordInput } from "@/components/ui/password-input"; export function AddAgentInboxDialog({ - closeSettingsPopover, hideTrigger, langchainApiKey, handleChangeLangChainApiKey, }: { - closeSettingsPopover: () => void; + /** + * Whether or not to hide the dialog trigger button. + */ hideTrigger?: boolean; langchainApiKey?: string; handleChangeLangChainApiKey?: ( @@ -70,8 +71,11 @@ export function AddAgentInboxDialog({ description: "Agent inbox added successfully", duration: 3000, }); - closeSettingsPopover(); updateQueryParams(NO_INBOXES_FOUND_PARAM); + + setGraphId(""); + setDeploymentUrl(""); + setName(""); setOpen(false); }; diff --git a/src/components/agent-inbox/components/settings-popover.tsx b/src/components/agent-inbox/components/settings-popover.tsx index 5a7133b..7fbbccf 100644 --- a/src/components/agent-inbox/components/settings-popover.tsx +++ b/src/components/agent-inbox/components/settings-popover.tsx @@ -8,7 +8,6 @@ import { import { Settings } from "lucide-react"; import React from "react"; import { PillButton } from "@/components/ui/pill-button"; -import { AddAgentInboxDialog } from "./add-agent-inbox-dialog"; import { Label } from "@/components/ui/label"; import { useLocalStorage } from "../hooks/use-local-storage"; import { INBOX_PARAM, LANGCHAIN_API_KEY_LOCAL_STORAGE_KEY } from "../constants"; @@ -51,76 +50,65 @@ export function SettingsPopover() { }; return ( - <> - { - if (!c && langchainApiKey && langchainApiKeyNotSet.current) { - // Try to fetch threads if the key was set for the first time. - langchainApiKeyNotSet.current = false; - const inboxParam = getSearchParam(INBOX_PARAM) as - | ThreadStatusWithAll - | undefined; - if (inboxParam) { - // Void and not await to avoid blocking the UI. - void fetchThreads(inboxParam); - } + { + if (!c && langchainApiKey && langchainApiKeyNotSet.current) { + // Try to fetch threads if the key was set for the first time. + langchainApiKeyNotSet.current = false; + const inboxParam = getSearchParam(INBOX_PARAM) as + | ThreadStatusWithAll + | undefined; + if (inboxParam) { + // Void and not await to avoid blocking the UI. + void fetchThreads(inboxParam); } - setOpen(c); - }} - > - - - - Settings - - - -
-
-

Settings

-

- Configuration settings for Agent Inbox -

-
-
-
-
- -

- This value is stored in your browser's local storage - and is only used to authenticate requests sent to your - LangGraph server. -

-
- + } + setOpen(c); + }} + > + + + + Settings + + + +
+
+

Settings

+

+ Configuration settings for Agent Inbox +

+
+
+
+
+ +

+ This value is stored in your browser's local storage and + is only used to authenticate requests sent to your LangGraph + server. +

- setOpen(false)} +
- - - setOpen(false)} - hideTrigger - langchainApiKey={langchainApiKey} - handleChangeLangChainApiKey={handleChangeLangChainApiKey} - /> - +
+
+ ); } diff --git a/src/components/app-sidebar/index.tsx b/src/components/app-sidebar/index.tsx index b4d75bd..ff01a33 100644 --- a/src/components/app-sidebar/index.tsx +++ b/src/components/app-sidebar/index.tsx @@ -20,13 +20,18 @@ import { TooltipIconButton } from "../ui/assistant-ui/tooltip-icon-button"; import { useThreadsContext } from "../agent-inbox/contexts/ThreadContext"; import { prettifyText } from "../agent-inbox/utils"; import { cn } from "@/lib/utils"; -import { AGENT_INBOX_GITHUB_README_URL } from "../agent-inbox/constants"; +import { + AGENT_INBOX_GITHUB_README_URL, + LANGCHAIN_API_KEY_LOCAL_STORAGE_KEY, +} from "../agent-inbox/constants"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../ui/tooltip"; +import { AddAgentInboxDialog } from "../agent-inbox/components/add-agent-inbox-dialog"; +import { useLocalStorage } from "../agent-inbox/hooks/use-local-storage"; const gradients = [ "linear-gradient(to right, #FF416C, #FF4B2B)", // Red-Orange @@ -63,6 +68,30 @@ function hashString(str: string): number { export function AppSidebar() { const { agentInboxes, changeAgentInbox, deleteAgentInbox } = useThreadsContext(); + const [langchainApiKey, setLangchainApiKey] = React.useState(""); + const { getItem, setItem } = useLocalStorage(); + + React.useEffect(() => { + try { + if (typeof window === "undefined" || langchainApiKey) { + return; + } + + const langchainApiKeyLS = getItem(LANGCHAIN_API_KEY_LOCAL_STORAGE_KEY); + if (langchainApiKeyLS) { + setLangchainApiKey(langchainApiKeyLS); + } + } catch (e) { + console.error("Error getting/setting LangChain API key", e); + } + }, [langchainApiKey]); + + const handleChangeLangChainApiKey = ( + e: React.ChangeEvent + ) => { + setLangchainApiKey(e.target.value); + setItem(LANGCHAIN_API_KEY_LOCAL_STORAGE_KEY, e.target.value); + }; return ( @@ -133,6 +162,11 @@ export function AppSidebar() { ); })} +