diff --git a/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/ThreadItem/index.jsx b/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/ThreadItem/index.jsx index d30e218cdb0..40b2c5c1f2b 100644 --- a/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/ThreadItem/index.jsx +++ b/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/ThreadItem/index.jsx @@ -24,12 +24,15 @@ export default function ThreadItem({ hasNext, ctrlPressed = false, }) { - const { slug, threadSlug = null } = useParams(); + const { slug: urlSlug, threadSlug = null } = useParams(); + const workspaceSlug = workspace?.slug ?? urlSlug; const optionsContainer = useRef(null); const [showOptions, setShowOptions] = useState(false); - const linkTo = !thread.slug - ? paths.workspace.chat(slug) - : paths.workspace.thread(slug, thread.slug); + const linkTo = thread.virtual + ? "/" + : !thread.slug + ? paths.workspace.chat(workspaceSlug) + : paths.workspace.thread(workspaceSlug, thread.slug); const { ref } = useScrollActiveItemIntoView({ isActive, @@ -112,7 +115,7 @@ export default function ThreadItem({

)} - {!!thread.slug && !thread.deleted && ( + {!!thread.slug && !thread.deleted && !thread.virtual && (
{" "} {/* Added flex and items-center */} diff --git a/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/index.jsx b/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/index.jsx index f9c0ea4edb7..3e219f155be 100644 --- a/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/index.jsx +++ b/frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/index.jsx @@ -7,7 +7,10 @@ import ThreadItem from "./ThreadItem"; import { useParams } from "react-router-dom"; export const THREAD_RENAME_EVENT = "renameThread"; -export default function ThreadContainer({ workspace }) { +export default function ThreadContainer({ + workspace, + isVirtualThread = false, +}) { const { threadSlug = null } = useParams(); const [threads, setThreads] = useState([]); const [loading, setLoading] = useState(true); @@ -109,6 +112,12 @@ export default function ThreadContainer({ workspace }) { }, 500); } + function getActiveThreadIdx() { + if (isVirtualThread) return threads.length + 1; + const idx = threads.findIndex((t) => t?.slug === threadSlug); + return idx >= 0 ? idx + 1 : 0; + } + if (loading) { return (
@@ -117,11 +126,7 @@ export default function ThreadContainer({ workspace }) { ); } - const activeThreadIdx = !!threads.find( - (thread) => thread?.slug === threadSlug - ) - ? threads.findIndex((thread) => thread?.slug === threadSlug) + 1 - : 0; + const activeThreadIdx = getActiveThreadIdx(); return (
@@ -129,8 +134,9 @@ export default function ThreadContainer({ workspace }) { idx={0} activeIdx={activeThreadIdx} isActive={activeThreadIdx === 0} + workspace={workspace} thread={{ slug: null, name: "default" }} - hasNext={threads.length > 0} + hasNext={threads.length > 0 || isVirtualThread} /> {threads.map((thread, i) => ( ))} + {isVirtualThread && ( + + )} { async function getWorkspaces() { @@ -71,6 +73,20 @@ export default function ActiveWorkspaces() { reorderWorkspaces(result.source.index, result.destination.index); }; + // When on the home page, resolve which workspace should be virtually active + const virtualActiveSlug = (() => { + if (!isHomePage || workspaces.length === 0) return null; + const lastVisited = safeJsonParse( + localStorage.getItem(LAST_VISITED_WORKSPACE) + ); + if ( + lastVisited?.slug && + workspaces.some((ws) => ws.slug === lastVisited.slug) + ) + return lastVisited.slug; + return workspaces[0]?.slug ?? null; + })(); + return ( @@ -83,7 +99,8 @@ export default function ActiveWorkspaces() { {...provided.droppableProps} > {workspaces.map((workspace, index) => { - const isActive = workspace.slug === slug; + const isVirtuallyActive = workspace.slug === virtualActiveSlug; + const isActive = workspace.slug === slug || isVirtuallyActive; return ( )}
diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/index.jsx index e439502ad50..de2b89712e4 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/index.jsx @@ -13,7 +13,6 @@ import { useManageWorkspaceModal } from "../../../Modals/ManageWorkspace"; import ManageWorkspace from "../../../Modals/ManageWorkspace"; import { ArrowDown } from "@phosphor-icons/react"; import debounce from "lodash.debounce"; -import useUser from "@/hooks/useUser"; import Chartable from "./Chartable"; import Workspace from "@/models/workspace"; import { useParams } from "react-router-dom"; @@ -21,7 +20,6 @@ import paths from "@/utils/paths"; import Appearance from "@/models/appearance"; import useTextSize from "@/hooks/useTextSize"; import useChatHistoryScrollHandle from "@/hooks/useChatHistoryScrollHandle"; -import { useTranslation } from "react-i18next"; import { useChatMessageAlignment } from "@/hooks/useChatMessageAlignment"; import { ThoughtExpansionProvider } from "./ThoughtContainer"; @@ -32,16 +30,13 @@ export default forwardRef(function ( sendCommand, updateHistory, regenerateAssistantMessage, - hasAttachments = false, }, ref ) { - const { t } = useTranslation(); const lastScrollTopRef = useRef(0); const chatHistoryRef = useRef(null); - const { user } = useUser(); const { threadSlug = null } = useParams(); - const { showing, showModal, hideModal } = useManageWorkspaceModal(); + const { showing, hideModal } = useManageWorkspaceModal(); const [isAtBottom, setIsAtBottom] = useState(true); const [isUserScrolling, setIsUserScrolling] = useState(false); const isStreaming = history[history.length - 1]?.animate; @@ -98,10 +93,6 @@ export default forwardRef(function ( scrollToBottom, }); - const handleSendSuggestedMessage = (heading, message) => { - sendCommand({ text: `${heading} ${message}`, autoSubmit: true }); - }; - const saveEditedMessage = async ({ editedMessage, chatId, @@ -197,46 +188,6 @@ export default forwardRef(function ( [compiledHistory.length, lastMessageInfo] ); - if (history.length === 0 && !hasAttachments) { - return ( -
-
-

- {t("chat_window.welcome")} -

- {!user || user.role !== "default" ? ( -

- {t("chat_window.get_started")} - - {t("chat_window.upload")} - - {t("chat_window.or")}{" "} - {t("chat_window.send_chat")} -

- ) : ( -

- {t("chat_window.get_started_default")}{" "} - {t("chat_window.send_chat")} -

- )} - -
- {showing && ( - - )} -
- ); - } - return (
{ }; }; -function WorkspaceChatSuggestions({ suggestions = [], sendSuggestion }) { - if (suggestions.length === 0) return null; - return ( -
- {suggestions.map((suggestion, index) => ( - - ))} -
- ); -} - /** * Builds the history of messages for the chat. * This is mostly useful for rendering the history in a way that is easy to understand. diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/AgentMenu/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/AgentMenu/index.jsx index 59662bf01f0..bd855a37fb0 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/AgentMenu/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/AgentMenu/index.jsx @@ -16,13 +16,13 @@ export default function AvailableAgentsButton({ showing, setShowAgents }) { data-tooltip-content={t("chat_window.agents")} aria-label={t("chat_window.agents")} onClick={() => setShowAgents(!showing)} - className={`flex justify-center items-center cursor-pointer ${ + className={`flex justify-center items-center cursor-pointer opacity-60 hover:opacity-100 light:opacity-100 light:hover:opacity-60 ${ showing ? "!opacity-100" : "" }`} >