diff --git a/src/renderer/src/components/app/Navbar.tsx b/src/renderer/src/components/app/Navbar.tsx index 5ab2c486b5..778431a1a7 100644 --- a/src/renderer/src/components/app/Navbar.tsx +++ b/src/renderer/src/components/app/Navbar.tsx @@ -67,14 +67,14 @@ const NavbarContainer = styled.div<{ $isFullScreen: boolean }>` flex-direction: row; min-height: ${isMac ? 'env(titlebar-area-height)' : 'var(--navbar-height)'}; max-height: var(--navbar-height); - margin-left: ${isMac ? 'calc(var(--sidebar-width) * -1)' : 0}; + margin-left: ${isMac ? 'calc(var(--sidebar-width) * -1 + 2px)' : 0}; padding-left: ${({ $isFullScreen }) => isMac ? ($isFullScreen ? 'var(--sidebar-width)' : 'env(titlebar-area-x)') : 0}; -webkit-app-region: drag; ` const NavbarLeftContainer = styled.div` - min-width: ${isMac ? 'calc(var(--assistants-width) - 20px)' : 'var(--assistants-width)'}; + /* min-width: ${isMac ? 'calc(var(--assistants-width) - 20px)' : 'var(--assistants-width)'}; */ padding: 0 10px; display: flex; flex-direction: row; diff --git a/src/renderer/src/pages/home/Chat.tsx b/src/renderer/src/pages/home/Chat.tsx index 0775a4f718..0c2d76a6e6 100644 --- a/src/renderer/src/pages/home/Chat.tsx +++ b/src/renderer/src/pages/home/Chat.tsx @@ -140,9 +140,7 @@ const Chat: FC = (props) => { firstUpdateOrNoFirstUpdateHandler() } - const mainHeight = isTopNavbar - ? 'calc(100vh - var(--navbar-height) - var(--navbar-height) - 12px)' - : 'calc(100vh - var(--navbar-height))' + const mainHeight = isTopNavbar ? 'calc(100vh - var(--navbar-height) - 6px)' : 'calc(100vh - var(--navbar-height))' const SessionMessages = useMemo(() => { if (activeAgentId === null) { @@ -192,66 +190,84 @@ const Chat: FC = (props) => { ) }, []) + return ( - {isTopNavbar && ( - - )} -
- - {activeTopicOrSession === 'topic' && ( - <> - - } - filter={contentSearchFilter} - includeUser={filterIncludeUser} - onIncludeUserChange={userOutlinedItemClickHandler} - /> - {messageNavigation === 'buttons' && } - - - )} - {activeTopicOrSession === 'session' && !activeAgentId && } - {activeTopicOrSession === 'session' && activeAgentId && !activeSessionId && } - {activeTopicOrSession === 'session' && activeAgentId && activeSessionId && ( - <> - - - - )} - {isMultiSelectMode && } - -
+ +
+ + +
+ {activeTopicOrSession === 'topic' && ( + <> + + } + filter={contentSearchFilter} + includeUser={filterIncludeUser} + onIncludeUserChange={userOutlinedItemClickHandler} + /> + {messageNavigation === 'buttons' && } + + + )} + {activeTopicOrSession === 'session' && !activeAgentId && } + {activeTopicOrSession === 'session' && activeAgentId && !activeSessionId && } + {activeTopicOrSession === 'session' && activeAgentId && activeSessionId && ( + <> + + + + )} + {isMultiSelectMode && } +
+
+
+
{topicPosition === 'right' && showTopics && ( + style={{ + position: 'absolute', + right: 0, + top: isTopNavbar ? 0 : 'calc(var(--navbar-height) + 1px)', + width: 'var(--assistants-width)', + height: '100%', + zIndex: 10 + }}> = (props) => { export const useChatMaxWidth = () => { const { showTopics, topicPosition } = useSettings() - const { isLeftNavbar } = useNavbarPosition() + const { isLeftNavbar, isTopNavbar } = useNavbarPosition() const { showAssistants } = useShowAssistants() const showRightTopics = showTopics && topicPosition === 'right' const minusAssistantsWidth = showAssistants ? '- var(--assistants-width)' : '' const minusRightTopicsWidth = showRightTopics ? '- var(--assistants-width)' : '' + const minusBorderWidth = isTopNavbar ? (showTopics ? '- 12px' : '- 6px') : '' const sidebarWidth = isLeftNavbar ? '- var(--sidebar-width)' : '' - return `calc(100vw ${sidebarWidth} ${minusAssistantsWidth} ${minusRightTopicsWidth})` + return `calc(100vw ${sidebarWidth} ${minusAssistantsWidth} ${minusRightTopicsWidth} ${minusBorderWidth})` } const Container = styled.div` diff --git a/src/renderer/src/pages/home/ChatNavbar.tsx b/src/renderer/src/pages/home/ChatNavbar.tsx index c44447da8f..43d04cd1a4 100644 --- a/src/renderer/src/pages/home/ChatNavbar.tsx +++ b/src/renderer/src/pages/home/ChatNavbar.tsx @@ -3,7 +3,7 @@ import { HStack } from '@renderer/components/Layout' import SearchPopup from '@renderer/components/Popups/SearchPopup' import { useAssistant } from '@renderer/hooks/useAssistant' import { modelGenerating } from '@renderer/hooks/useRuntime' -import { useSettings } from '@renderer/hooks/useSettings' +import { useNavbarPosition, useSettings } from '@renderer/hooks/useSettings' import { useShortcut } from '@renderer/hooks/useShortcuts' import { useShowAssistants, useShowTopics } from '@renderer/hooks/useStore' import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService' @@ -34,6 +34,7 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo const { showAssistants, toggleShowAssistants } = useShowAssistants() const { topicPosition, narrowMode } = useSettings() const { showTopics, toggleShowTopics } = useShowTopics() + const { isTopNavbar } = useNavbarPosition() const dispatch = useAppDispatch() useShortcut('toggle_show_assistants', toggleShowAssistants) @@ -73,16 +74,16 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo // ) return ( - -
- {showAssistants && ( + +
+ {isTopNavbar && showAssistants && ( )} - {!showAssistants && ( + {isTopNavbar && !showAssistants && ( toggleShowAssistants()} style={{ marginRight: 8 }}> @@ -90,13 +91,13 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo )} - {!showAssistants && ( + {!showAssistants && isTopNavbar && ( - + @@ -105,25 +106,29 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant, activeTo
- - - - - - - - SearchPopup.show()}> - - - - {topicPosition === 'right' && !showTopics && ( + {isTopNavbar && } + {isTopNavbar && ( + + + + + + )} + {isTopNavbar && ( + + SearchPopup.show()}> + + + + )} + {isTopNavbar && topicPosition === 'right' && !showTopics && ( )} - {topicPosition === 'right' && showTopics && ( + {isTopNavbar && topicPosition === 'right' && showTopics && ( diff --git a/src/renderer/src/pages/home/Navbar.tsx b/src/renderer/src/pages/home/Navbar.tsx index 6d9ccc2285..c643391d8a 100644 --- a/src/renderer/src/pages/home/Navbar.tsx +++ b/src/renderer/src/pages/home/Navbar.tsx @@ -1,14 +1,11 @@ import { Navbar, NavbarCenter, NavbarLeft, NavbarRight } from '@renderer/components/app/Navbar' import { HStack } from '@renderer/components/Layout' import SearchPopup from '@renderer/components/Popups/SearchPopup' -import { isLinux, isMac, isWin } from '@renderer/config/constant' -import { useAssistant } from '@renderer/hooks/useAssistant' +import { isLinux, isWin } from '@renderer/config/constant' import { modelGenerating } from '@renderer/hooks/useRuntime' import { useSettings } from '@renderer/hooks/useSettings' import { useShortcut } from '@renderer/hooks/useShortcuts' import { useShowAssistants, useShowTopics } from '@renderer/hooks/useStore' -import { useChatMaxWidth } from '@renderer/pages/home/Chat' -import ChatNavbarContent from '@renderer/pages/home/components/ChatNavbarContent' import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService' import { useAppDispatch } from '@renderer/store' import { setNarrowMode } from '@renderer/store/settings' @@ -17,11 +14,10 @@ import { Tooltip } from 'antd' import { t } from 'i18next' import { Menu, PanelLeftClose, PanelRightClose, Search } from 'lucide-react' import { AnimatePresence, motion } from 'motion/react' -import React, { FC } from 'react' +import { FC } from 'react' import styled from 'styled-components' import AssistantsDrawer from './components/AssistantsDrawer' -import SelectModelButton from './components/SelectModelButton' import UpdateAppButton from './components/UpdateAppButton' interface Props { @@ -40,11 +36,9 @@ const HeaderNavbar: FC = ({ setActiveTopic, activeTopicOrSession }) => { - const { assistant } = useAssistant(activeAssistant.id) const { showAssistants, toggleShowAssistants } = useShowAssistants() const { topicPosition, narrowMode } = useSettings() const { showTopics, toggleShowTopics } = useShowTopics() - const chatMaxWidth = useChatMaxWidth() const dispatch = useAppDispatch() useShortcut('toggle_show_assistants', toggleShowAssistants) @@ -101,7 +95,7 @@ const HeaderNavbar: FC = ({ justifyContent: 'flex-start', borderRight: 'none', paddingLeft: 0, - paddingRight: 10, + paddingRight: 0, minWidth: 'auto' }}> @@ -123,22 +117,7 @@ const HeaderNavbar: FC = ({ )} - - {activeTopicOrSession === 'topic' ? ( - - - - ) : ( - - - - )} - - + = ({ - children, - style -}) => { - return ( -
- {children} -
- ) -} - export default HeaderNavbar diff --git a/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx b/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx index dc272b869a..952d0a2c07 100644 --- a/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx @@ -180,7 +180,7 @@ const AssistantsTab: FC = (props) => { const Container = styled(Scrollbar)` display: flex; flex-direction: column; - padding: 10px; + padding: 12px 10px; ` export default AssistantsTab diff --git a/src/renderer/src/pages/home/Tabs/SessionSettingsTab.tsx b/src/renderer/src/pages/home/Tabs/SessionSettingsTab.tsx index 34b41a560c..099d22a72e 100644 --- a/src/renderer/src/pages/home/Tabs/SessionSettingsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/SessionSettingsTab.tsx @@ -30,7 +30,7 @@ const SessionSettingsTab: FC = ({ session, update }) => { return (
- + - ) -} +const SessionListItem = styled.div` + padding: 7px 12px; + border-radius: var(--list-item-border-radius); + font-size: 13px; + display: flex; + flex-direction: column; + justify-content: space-between; + cursor: pointer; + width: calc(var(--assistants-width) - 20px); + margin-bottom: 8px; -const SessionLabelContainer: React.FC> = ({ className, ...props }) => ( -
-) + .menu { + opacity: 0; + color: var(--color-text-3); + } + + &:hover { + background-color: var(--color-list-item-hover); + transition: background-color 0.1s; + + .menu { + opacity: 1; + } + } + + &.active { + background-color: var(--color-list-item); + box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); + .menu { + opacity: 1; + + &:hover { + color: var(--color-text-2); + } + } + } + + &.singlealone { + border-radius: 0 !important; + &:hover { + background-color: var(--color-background-soft); + } + &.active { + border-left: 2px solid var(--color-primary); + box-shadow: none; + } + } +` + +const SessionNameContainer = styled.div` + display: flex; + flex-direction: row; + align-items: center; + gap: 4px; + height: 20px; + justify-content: space-between; +` + +const SessionName = styled.div` + display: -webkit-box; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; + overflow: hidden; + font-size: 13px; + position: relative; +` + +const SessionEditInput = styled.input` + background: var(--color-background); + border: none; + color: var(--color-text-1); + font-size: 13px; + font-family: inherit; + padding: 2px 6px; + width: 100%; + outline: none; + padding: 0; +` + +const MenuButton = styled.div` + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + min-width: 20px; + min-height: 20px; + .anticon { + font-size: 12px; + } +` const PendingIndicator = styled.div.attrs({ className: 'animation-pulse' diff --git a/src/renderer/src/pages/home/Tabs/components/Sessions.tsx b/src/renderer/src/pages/home/Tabs/components/Sessions.tsx index 50020b168d..62b1df41de 100644 --- a/src/renderer/src/pages/home/Tabs/components/Sessions.tsx +++ b/src/renderer/src/pages/home/Tabs/components/Sessions.tsx @@ -12,7 +12,7 @@ import { } from '@renderer/store/runtime' import { CreateSessionForm } from '@renderer/types' import { buildAgentSessionTopicId } from '@renderer/utils/agentSession' -import { AnimatePresence, motion } from 'framer-motion' +import { motion } from 'framer-motion' import { memo, useCallback, useEffect } from 'react' import { useTranslation } from 'react-i18next' @@ -30,7 +30,7 @@ const Sessions: React.FC = ({ agentId }) => { const { agent } = useAgent(agentId) const { sessions, isLoading, error, deleteSession, createSession } = useSessions(agentId) const { chat } = useRuntime() - const { activeSessionIdMap, sessionWaiting } = chat + const { activeSessionIdMap } = chat const dispatch = useAppDispatch() const setActiveSessionId = useCallback( @@ -109,45 +109,30 @@ const Sessions: React.FC = ({ agentId }) => { if (error) return return ( - - - - {t('agent.session.add.title')} - - - - {/* h-9 */} - 9 * 4} - scrollerStyle={{ - // FIXME: This component only supports CSSProperties - overflowX: 'hidden' - }} - autoHideScrollbar> - {(session) => ( - - handleDeleteSession(session.id)} - onPress={() => setActiveSessionId(agentId, session.id)} - /> - - )} - - - +
+ + {t('agent.session.add.title')} + + {/* h-9 */} + 9 * 4} + scrollerStyle={{ + // FIXME: This component only supports CSSProperties + overflowX: 'hidden' + }} + autoHideScrollbar> + {(session) => ( + handleDeleteSession(session.id)} + onPress={() => setActiveSessionId(agentId, session.id)} + /> + )} + +
) } diff --git a/src/renderer/src/pages/home/Tabs/index.tsx b/src/renderer/src/pages/home/Tabs/index.tsx index c43c6d93a4..33d6473432 100644 --- a/src/renderer/src/pages/home/Tabs/index.tsx +++ b/src/renderer/src/pages/home/Tabs/index.tsx @@ -189,10 +189,7 @@ const Container = styled.div` background-color: var(--color-background); } [navbar-position='top'] & { - height: calc(100vh - var(--navbar-height) - 12px); - &.right { - height: calc(100vh - var(--navbar-height) - var(--navbar-height) - 12px); - } + height: calc(100vh - var(--navbar-height)); } overflow: hidden; .collapsed { diff --git a/src/renderer/src/pages/home/components/ChatNavbarContent.tsx b/src/renderer/src/pages/home/components/ChatNavbarContent.tsx index 154226973e..00b48cf8f4 100644 --- a/src/renderer/src/pages/home/components/ChatNavbarContent.tsx +++ b/src/renderer/src/pages/home/components/ChatNavbarContent.tsx @@ -1,13 +1,13 @@ -import { BreadcrumbItem, Breadcrumbs, Chip, cn } from '@heroui/react' +import { BreadcrumbItem, Breadcrumbs, cn } from '@heroui/react' import HorizontalScrollContainer from '@renderer/components/HorizontalScrollContainer' -import { permissionModeCards } from '@renderer/constants/permissionModes' import { useActiveAgent } from '@renderer/hooks/agents/useActiveAgent' import { useActiveSession } from '@renderer/hooks/agents/useActiveSession' import { useUpdateSession } from '@renderer/hooks/agents/useUpdateSession' import { useRuntime } from '@renderer/hooks/useRuntime' -import { AgentEntity, AgentSessionEntity, ApiModel, Assistant, PermissionMode } from '@renderer/types' +import { AgentEntity, AgentSessionEntity, ApiModel, Assistant } from '@renderer/types' import { formatErrorMessageWithPrefix } from '@renderer/utils/error' import { t } from 'i18next' +import { Folder } from 'lucide-react' import { FC, ReactNode, useCallback } from 'react' import { AgentSettingsPopup, SessionSettingsPopup } from '../../settings/AgentSettings' @@ -38,24 +38,15 @@ const ChatNavbarContent: FC = ({ assistant }) => { <> {activeTopicOrSession === 'topic' && } {activeTopicOrSession === 'session' && activeAgent && ( - - + + AgentSettingsPopup.show({ agentId: activeAgent.id })} - classNames={{ - base: 'self-stretch', - item: 'h-full' - }}> - - - + classNames={{ base: 'self-stretch', item: 'h-full' }}> + {activeSession && ( = ({ assistant }) => { sessionId: activeSession.id }) } - classNames={{ - base: 'self-stretch', - item: 'h-full' - }}> - - - + classNames={{ base: 'self-stretch', item: 'h-full' }}> + )} {activeSession && ( @@ -97,11 +83,11 @@ const SessionWorkspaceMeta: FC<{ agent: AgentEntity; session: AgentSessionEntity } const firstAccessiblePath = session.accessible_paths?.[0] - const permissionMode = (session.configuration?.permission_mode ?? 'default') as PermissionMode - const permissionModeCard = permissionModeCards.find((card) => card.mode === permissionMode) - const permissionModeLabel = permissionModeCard - ? t(permissionModeCard.titleKey, permissionModeCard.titleFallback) - : permissionMode + // const permissionMode = (session.configuration?.permission_mode ?? 'default') as PermissionMode + // const permissionModeCard = permissionModeCards.find((card) => card.mode === permissionMode) + // const permissionModeLabel = permissionModeCard + // ? t(permissionModeCard.titleKey, permissionModeCard.titleFallback) + // : permissionMode const infoItems: ReactNode[] = [] @@ -117,12 +103,13 @@ const SessionWorkspaceMeta: FC<{ agent: AgentEntity; session: AgentSessionEntity }) => (
+ {text}
) @@ -148,7 +135,7 @@ const SessionWorkspaceMeta: FC<{ agent: AgentEntity; session: AgentSessionEntity ) } - infoItems.push() + // infoItems.push() if (infoItems.length === 0) { return null diff --git a/src/renderer/src/pages/home/components/SelectAgentBaseModelButton.tsx b/src/renderer/src/pages/home/components/SelectAgentBaseModelButton.tsx index 74f69cf15e..0a2e6c1fbb 100644 --- a/src/renderer/src/pages/home/components/SelectAgentBaseModelButton.tsx +++ b/src/renderer/src/pages/home/components/SelectAgentBaseModelButton.tsx @@ -38,12 +38,12 @@ const SelectAgentBaseModelButton: FC = ({ agentBase: agent, onSelect, isD