diff --git a/frontend/src/ai/OpenAIContext.tsx b/frontend/src/ai/OpenAIContext.tsx index 3cead47cb..9d6f1b0a8 100644 --- a/frontend/src/ai/OpenAIContext.tsx +++ b/frontend/src/ai/OpenAIContext.tsx @@ -1,5 +1,6 @@ import OpenAI from "openai"; import { useOpenSecret } from "@opensecret/react"; +import { createAccountBoundChatFetch } from "@/services/chatAccountCredential"; import { OpenAIContext } from "./OpenAIContextDef"; export const OpenAIProvider = ({ children }: { children: React.ReactNode }) => { @@ -8,7 +9,7 @@ export const OpenAIProvider = ({ children }: { children: React.ReactNode }) => { throw new Error("VITE_OPEN_SECRET_API_URL must be set"); } - const { aiCustomFetch } = useOpenSecret(); + const { aiCustomFetch, auth } = useOpenSecret(); const access_token = window.localStorage.getItem("access_token"); // If we're not logged in we can't set up openai @@ -24,7 +25,11 @@ export const OpenAIProvider = ({ children }: { children: React.ReactNode }) => { defaultHeaders: { "Accept-Encoding": "identity" }, - fetch: aiCustomFetch, + fetch: createAccountBoundChatFetch({ + expectedUserId: auth.user?.user.id, + getAccessToken: () => window.localStorage.getItem("access_token"), + fetch: aiCustomFetch + }), maxRetries: 0 // Disable automatic retries }); diff --git a/frontend/src/components/AgentMode.tsx b/frontend/src/components/AgentMode.tsx index 37fddd6cc..fb3e58294 100644 --- a/frontend/src/components/AgentMode.tsx +++ b/frontend/src/components/AgentMode.tsx @@ -59,6 +59,11 @@ import { ChatUserTurn } from "@/components/chat/ChatTurn"; import { ChatCopyButton } from "@/components/chat/ChatCopyButton"; +import { + DiscardQueuedMessageEditButton, + QUEUED_MESSAGE_EDIT_PLACEHOLDER, + QueuedComposerMessages +} from "@/components/chat/QueuedComposerMessages"; import { continueChatComposerList, continueChatComposerListBeforeInput @@ -5062,55 +5067,16 @@ function AgentComposer({ {isExpanded ? : } ) : null} - {queuedMessages.length > 0 ? ( -
- {queuedMessages.map((item) => ( -
- - {item.text || `${item.attachments?.length ?? 0} image attachment(s)`} - - {onCancelQueuedMessage ? ( - - ) : null} - {onEditQueuedMessage ? ( - - ) : null} - {onSteerQueuedMessage ? ( - - ) : null} -
- ))} -
- ) : null} + `${item.attachments?.length ?? 0} image attachment(s)`} + onRemove={onCancelQueuedMessage} + onEdit={onEditQueuedMessage} + onSendNow={onSteerQueuedMessage} + sendNowDisabled={isSendDisabled} + /> {!editingQueueId && draftImages.length > 0 ? (
{draftImages.map((image, index) => ( @@ -5149,9 +5115,7 @@ function AgentComposer({ onPaste={onImagePaste} disabled={isSendDisabled} placeholder={ - editingQueueId - ? "Edit the queued message, then send to keep its place..." - : "Ask Maple to work in this folder..." + editingQueueId ? QUEUED_MESSAGE_EDIT_PLACEHOLDER : "Ask Maple to work in this folder..." } className={cn( CHAT_COMPOSER_TEXTAREA_CLASS, @@ -5234,15 +5198,7 @@ function AgentComposer({
{editingQueueId && onDiscardQueuedMessageEdit ? ( - + ) : null} {agentComposerShowsStop(isSending) ? (