From 291b1a0fc1dad6316896cebbc8eefed2b02d630a Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Fri, 10 Apr 2026 18:30:30 +0100 Subject: [PATCH] cleanup --- .../src/ee/ai-chat/components/ai-chat-layout.tsx | 15 +++++++++++++++ .../ee/ai-chat/components/aside-chat-panel.tsx | 9 +++++++++ apps/server/src/ee | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/client/src/ee/ai-chat/components/ai-chat-layout.tsx b/apps/client/src/ee/ai-chat/components/ai-chat-layout.tsx index bbd1fb6b..f0fe3035 100644 --- a/apps/client/src/ee/ai-chat/components/ai-chat-layout.tsx +++ b/apps/client/src/ee/ai-chat/components/ai-chat-layout.tsx @@ -13,6 +13,15 @@ export default function AiChatLayout() { const location = useLocation(); const navigate = useNavigate(); const chatInfoQuery = useChatInfoQuery(chatId); + + // If the URL points at a chat the user does not own, the info fetch 404s. + // Bounce them back to /ai so they cannot interact with any chat UI (including + // kicking off orphan uploads) tied to a chat they have no access to. + useEffect(() => { + if (chatId && chatInfoQuery.isError) { + navigate("/ai", { replace: true }); + } + }, [chatId, chatInfoQuery.isError, navigate]); const { messages, streamingContent, @@ -48,6 +57,12 @@ export default function AiChatLayout() { const hasMessages = messages.length > 0 || isStreaming; + // While the redirect effect is running (or if the user is still on this + // component for any reason) never render the chat UI for a forbidden chat. + if (chatId && chatInfoQuery.isError) { + return null; + } + return (