Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
3ade73a
refactor: Update import path for externalChatImporter and remove unus…
experdot Aug 1, 2025
bccae07
refactor: Remove settings component from layout and sidebar, integrat…
experdot Aug 1, 2025
1085848
refactor: Update settings page handling to default to LLM configurati…
experdot Aug 1, 2025
fcdc826
refactor: Simplify Settings component by removing unused state and ha…
experdot Aug 1, 2025
973174a
refactor: Reinstate UpdateSettings tab in Settings component and add …
experdot Aug 1, 2025
1eeb089
feat: Enhance update handling by introducing startup check state mana…
experdot Aug 1, 2025
1d0be9b
refactor: Adjust padding in SettingsPage component for improved layou…
experdot Aug 1, 2025
3a7e8d5
refactor: Update ChatInput component to remove unnecessary disabled c…
experdot Aug 1, 2025
7920d10
refactor: Remove disabled condition from delete button in MessageItem…
experdot Aug 1, 2025
67497d9
feat: Implement comprehensive data reset functionality in DataManagem…
experdot Aug 1, 2025
f0fc424
feat: Enhance DataManagement component with new export/import functio…
experdot Aug 1, 2025
0ae2772
refactor: Clean up DataManagement component by removing success messa…
experdot Aug 1, 2025
656a5e5
style: Update chat component styles to improve message alignment duri…
experdot Aug 1, 2025
332c69f
refactor: Update MessageItem component to prioritize editing state in…
experdot Aug 1, 2025
4d34c80
style: Adjust ActivityBar width in Layout component and import CSS fo…
experdot Aug 1, 2025
852c1da
style: Change axis data container layout from row to column in crosst…
experdot Aug 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/renderer/src/components/common/UpdateNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export default function UpdateNotification() {
const handleUpdateAvailable = (info: UpdateInfo) => {
console.log('收到更新可用事件:', info)
updateStore.handleUpdateAvailable(info)
// 重置启动检查标识(有更新可用时需要显示通知)
updateStore.setIsStartupCheck(false)
showUpdateAvailableNotification(info)
}

Expand All @@ -61,13 +63,24 @@ export default function UpdateNotification() {
const handleUpdateError = (error: string) => {
console.error('收到更新错误事件:', error)
updateStore.handleUpdateError(error)
// 重置启动检查标识
updateStore.setIsStartupCheck(false)
// 静默处理错误,避免过多通知打扰用户
console.warn('Update check failed:', error)
}

const handleUpdateNotAvailable = (info: any) => {
console.log('收到无更新事件:', info)
updateStore.handleUpdateNotAvailable(info)

// 如果是启动检查且已是最新版本,不显示通知
if (updateStore.isStartupCheck) {
console.log('启动检查:已是最新版本,不显示通知')
updateStore.setIsStartupCheck(false) // 重置标识
return
}

// 手动检查时显示通知
notification.info({
message: '当前已是最新版本',
description: `当前版本: ${info.version || '未知'}`,
Expand Down Expand Up @@ -114,12 +127,17 @@ export default function UpdateNotification() {
return
}

// 标记为启动检查
updateStore.setIsStartupCheck(true)

const result = await window.api.updater.checkForUpdates()
console.log('启动检查更新结果:', result)
} catch (error) {
console.error('启动检查更新失败:', error)
// 静默失败,不打扰用户
console.warn('Startup update check failed:', error)
// 重置启动检查标识
updateStore.setIsStartupCheck(false)
}
}

Expand Down
11 changes: 2 additions & 9 deletions src/renderer/src/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Sidebar from './sidebar/Sidebar'
import ActivityBar, { ActivityBarTab } from './activitybar/ActivityBar'
import TabsArea from './tabs/TabsArea'
import ResizeHandle from './ResizeHandle'
import Settings from '../settings/Settings'
import GlobalSearch from './sidebar_items/search/GlobalSearch'
import TitleBar from './titlebar/TitleBar'

Expand All @@ -17,7 +16,6 @@ export default function Layout() {
const { clearSearch } = useSearchStore()
const [activeTab, setActiveTab] = useState<ActivityBarTab>('explore')
const [searchOpen, setSearchOpen] = useState(false)
const [settingsOpen, setSettingsOpen] = useState(false)

// 处理键盘快捷键
useEffect(() => {
Expand Down Expand Up @@ -59,10 +57,6 @@ export default function Layout() {
setSearchOpen(true)
}

const handleSettingsOpen = () => {
setSettingsOpen(true)
}

return (
<div className="app-layout">
{/* 自定义标题栏 */}
Expand All @@ -74,7 +68,7 @@ export default function Layout() {

<AntLayout className="app-main-layout">
{/* ActivityBar */}
<Sider width={50} collapsedWidth={50} theme="light" className="app-activity-bar">
<Sider width={64} collapsedWidth={64} theme="light" className="app-activity-bar">
<ActivityBar activeTab={activeTab} onTabChange={handleActivityTabChange} />
</Sider>

Expand All @@ -91,7 +85,7 @@ export default function Layout() {
collapsed={sidebarCollapsed}
activeTab={activeTab}
onSearchOpen={handleSearchOpen}
onSettingsOpen={handleSettingsOpen}
onSettingsOpen={handleSearchOpen}
/>
<ResizeHandle />
</Sider>
Expand All @@ -103,7 +97,6 @@ export default function Layout() {

{/* 全局模态框 */}
<GlobalSearch visible={searchOpen} onClose={handleCloseSearch} />
<Settings open={settingsOpen} onClose={() => setSettingsOpen(false)} />
</div>
)
}
30 changes: 23 additions & 7 deletions src/renderer/src/components/layout/activitybar/ActivityBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import React from 'react'
import { Button, Badge, Tooltip } from 'antd'
import { FolderOutlined, SearchOutlined, MonitorOutlined, SettingOutlined } from '@ant-design/icons'
import { useAITasksStore } from '../../../stores/aiTasksStore'
import { usePagesStore } from '../../../stores/pagesStore'
import { useTabsStore } from '../../../stores/tabsStore'
import './activitybar.css'

export type ActivityBarTab = 'explore' | 'search' | 'tasks' | 'settings'
export type ActivityBarTab = 'explore' | 'search' | 'tasks'

interface ActivityBarProps {
activeTab: ActivityBarTab
Expand All @@ -12,10 +15,18 @@ interface ActivityBarProps {

export default function ActivityBar({ activeTab, onTabChange }: ActivityBarProps) {
const { getRunningTasksCount } = useAITasksStore()
const { createAndOpenSettingsPage } = usePagesStore()
const { openTab } = useTabsStore()

// 计算活跃任务数量
const activeTaskCount = getRunningTasksCount()

// 处理设置按钮点击
const handleSettingsClick = () => {
const settingsPageId = createAndOpenSettingsPage('llm') // 默认打开LLM配置,因为这是用户最常需要的设置
openTab(settingsPageId)
}

const items = [
{
key: 'explore' as ActivityBarTab,
Expand All @@ -35,12 +46,6 @@ export default function ActivityBar({ activeTab, onTabChange }: ActivityBarProps
label: '任务监控',
tooltip: '任务监控 - AI任务状态',
badge: activeTaskCount > 0 ? activeTaskCount : undefined
},
{
key: 'settings' as ActivityBarTab,
icon: <SettingOutlined />,
label: '设置',
tooltip: '设置 - 应用程序设置'
}
]

Expand All @@ -59,6 +64,17 @@ export default function ActivityBar({ activeTab, onTabChange }: ActivityBarProps
</Badge>
</Tooltip>
))}

{/* 设置按钮独立处理 */}
<Tooltip title="设置 - 应用程序设置" placement="right">
<Button
type="text"
size="large"
icon={<SettingOutlined />}
className="activity-bar-button"
onClick={handleSettingsClick}
/>
</Tooltip>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.activity-bar {
display: flex;
flex-direction: column;
align-items: center;
padding: 16px 8px;
background: #fafafa;
border-right: 1px solid #f0f0f0;
gap: 4px;
}
12 changes: 1 addition & 11 deletions src/renderer/src/components/layout/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,7 @@ export default function Sidebar({
</div>
</div>
)
case 'settings':
return (
<div className="sidebar-settings">
<div className="sidebar-header">
<h3>设置</h3>
</div>
<div className="sidebar-content">
<Settings open={true} onClose={() => {}} embedded={true} />
</div>
</div>
)

default:
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ export default function ChatHistoryTree({ onChatClick }: ChatHistoryTreeProps) {
.filter((folder) => folder.parentId === parentId)
.sort((a, b) => (a.order || 0) - (b.order || 0))

// 获取指定父级下的聊天
// 获取指定父级下的聊天(过滤掉设置页面)
const chats = pages
.filter((chat) => chat.folderId === parentId)
.filter((chat) => chat.folderId === parentId && chat.type !== 'settings')
.sort((a, b) => (a.order || 0) - (b.order || 0))

// 添加文件夹
Expand Down
22 changes: 15 additions & 7 deletions src/renderer/src/components/layout/tabs/TabsArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ import { useSettingsStore } from '../../../stores/settingsStore'
import { ChatWindow, ChatWindowRef } from '../../pages/chat/index'
import { CrosstabChat } from '../../pages/crosstab/index'
import { ObjectPage } from '../../pages/object/index'
import Settings from '../../settings/Settings'
import SettingsPage from '../../pages/settings/SettingsPage'
import './TabsArea.css'

export default function TabsArea() {
const { pages, createAndOpenChat, createAndOpenCrosstabChat, createAndOpenObjectChat } =
usePagesStore()
const {
pages,
createAndOpenChat,
createAndOpenCrosstabChat,
createAndOpenObjectChat,
createAndOpenSettingsPage
} = usePagesStore()
const {
openTabs,
activeTabId,
Expand All @@ -40,7 +45,6 @@ export default function TabsArea() {
const {} = useUIStore()
const { settings } = useSettingsStore()
const chatWindowRefs = useRef<Map<string, ChatWindowRef>>(new Map())
const [settingsOpen, setSettingsOpen] = React.useState(false)
const [draggedTabId, setDraggedTabId] = React.useState<string | null>(null)
const [dragOverTabId, setDragOverTabId] = React.useState<string | null>(null)

Expand Down Expand Up @@ -70,8 +74,9 @@ export default function TabsArea() {

// 处理打开设置
const handleOpenSettings = useCallback(() => {
setSettingsOpen(true)
}, [])
const settingsPageId = createAndOpenSettingsPage('llm') // 配置模型按钮应该打开LLM配置
setActiveTab(settingsPageId)
}, [createAndOpenSettingsPage, setActiveTab])

// 拖拽排序处理函数
const handleDragStart = useCallback((event: React.DragEvent, chatId: string) => {
Expand Down Expand Up @@ -436,7 +441,6 @@ export default function TabsArea() {
}
/>
)}
<Settings open={settingsOpen} onClose={() => setSettingsOpen(false)} />
</div>
)
}
Expand Down Expand Up @@ -474,6 +478,8 @@ export default function TabsArea() {
<TableOutlined className="message-icon" />
) : chat.type === 'object' ? (
<BlockOutlined className="message-icon" />
) : chat.type === 'settings' ? (
<SettingOutlined className="message-icon" />
) : (
<MessageOutlined className="message-icon" />
)}
Expand All @@ -494,6 +500,8 @@ export default function TabsArea() {
<CrosstabChat chatId={chatId} />
) : chat.type === 'object' ? (
<ObjectPage chatId={chatId} />
) : chat.type === 'settings' ? (
<SettingsPage chatId={chatId} defaultActiveTab={chat.data?.defaultActiveTab} />
) : (
<ChatWindow chatId={chatId} ref={(ref) => setChatWindowRef(chatId, ref)} />
),
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/pages/chat/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const ChatInput = forwardRef<ChatInputRef, ChatInputProps>(
onChange={(e) => onChange(e.target.value)}
onKeyDown={handleKeyDown}
autoSize={{ minRows: 1, maxRows: 10 }}
disabled={disabled || hasNoModels}
disabled={hasNoModels}
/>
<Flex align="center" gap={8} justify="space-between" style={{ width: '100%' }}>
<Space>
Expand Down
16 changes: 10 additions & 6 deletions src/renderer/src/components/pages/chat/ChatWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useState, useMemo, useRef, forwardRef, useImperativeHandle } from 'react'
import { usePagesStore } from '../../../stores/pagesStore'
import { useTabsStore } from '../../../stores/tabsStore'
import { useUIStore } from '../../../stores/uiStore'
import { useSettingsStore } from '../../../stores/settingsStore'
import { useMessagesStore } from '../../../stores/messagesStore'
import ChatLogic from './ChatLogic'
import ChatHeader from './ChatHeader'
import MessageList from './MessageList'
import ChatInput, { ChatInputRef } from './ChatInput'
import Settings from '../../settings/Settings'
import PageLineageDisplay from '../../common/PageLineageDisplay'
import MessageTreeSidebar from './MessageTreeSidebar'
import { MessageTree } from './messageTree'
Expand All @@ -21,7 +21,8 @@ export interface ChatWindowRef {
}

const ChatWindow = forwardRef<ChatWindowRef, ChatWindowProps>(({ chatId }, ref) => {
const { pages } = usePagesStore()
const { pages, createAndOpenSettingsPage } = usePagesStore()
const { setActiveTab } = useTabsStore()
const {
collapsedMessages,
allMessagesCollapsed,
Expand All @@ -32,7 +33,6 @@ const ChatWindow = forwardRef<ChatWindowRef, ChatWindowProps>(({ chatId }, ref)
const { settings } = useSettingsStore()
const { updateCurrentPath } = useMessagesStore()
const [inputValue, setInputValue] = useState('')
const [settingsOpen, setSettingsOpen] = useState(false)
const [messageTreeCollapsed, setMessageTreeCollapsed] = useState(true)
const [messageTreeWidth, setMessageTreeWidth] = useState(() => {
const saved = localStorage.getItem('messageTreeWidth')
Expand Down Expand Up @@ -84,7 +84,8 @@ const ChatWindow = forwardRef<ChatWindowRef, ChatWindowProps>(({ chatId }, ref)
}

const handleOpenSettings = () => {
setSettingsOpen(true)
const settingsPageId = createAndOpenSettingsPage('llm') // 从聊天窗口点击设置通常是想配置模型
setActiveTab(settingsPageId)
}

const handleToggleMessageTree = () => {
Expand Down Expand Up @@ -239,8 +240,12 @@ const ChatWindow = forwardRef<ChatWindowRef, ChatWindowProps>(({ chatId }, ref)
onChange={setInputValue}
onSend={async () => {
if (inputValue.trim()) {
setInputValue('') // 立即清空输入框
await onSendMessage(inputValue)
setInputValue('')
// 在下一个tick中聚焦,确保界面更新完成
setTimeout(() => {
chatInputRef.current?.focus()
}, 0)
}
}}
onStop={onStopGeneration}
Expand All @@ -263,7 +268,6 @@ const ChatWindow = forwardRef<ChatWindowRef, ChatWindowProps>(({ chatId }, ref)
)}
</ChatLogic>
</div>
<Settings open={settingsOpen} onClose={() => setSettingsOpen(false)} />
</div>
)
})
Expand Down
11 changes: 5 additions & 6 deletions src/renderer/src/components/pages/chat/MessageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default function MessageItem({
}}
/>
</div>
<div className="message-content">
<div className={isEditing ? 'message-content message-content-editing' : 'message-content'}>
<div className="message-header">
<div className="message-title">
<Text strong>{message.role === 'user' ? '您' : 'AI助手'}</Text>
Expand Down Expand Up @@ -249,8 +249,8 @@ export default function MessageItem({
</div>
</div>

{/* 消息内容区域 - 可折叠 */}
{!isCollapsed && (
{/* 消息内容区域 - 可折叠,但编辑状态优先级最高 */}
{(!isCollapsed || isEditing) && (
<>
{/* 推理模型思考过程展示 */}
{currentReasoningContent && (
Expand Down Expand Up @@ -349,8 +349,8 @@ export default function MessageItem({
</>
)}

{/* 折叠状态下的预览 */}
{isCollapsed && (
{/* 折叠状态下的预览 - 编辑状态时不显示 */}
{isCollapsed && !isEditing && (
<Card size="small" className="message-card message-collapsed">
<div className="message-preview">
<Text type="secondary" className="message-preview-text">
Expand Down Expand Up @@ -425,7 +425,6 @@ export default function MessageItem({
size="small"
icon={<DeleteOutlined />}
onClick={handleDelete}
disabled={isCurrentlyStreaming}
className="message-delete-btn"
/>
</Tooltip>
Expand Down
Loading