feat(web): 移除 Settings 按钮,在 Header 直接显示工作目录
- 移除 ConfigPanel 及其入口按钮 - 在 Chat 页面 Header 左侧显示当前工作目录 - 初始化时并行获取会话列表和工作目录
This commit is contained in:
@@ -8,7 +8,6 @@ import { useState, useEffect, useCallback } from 'react';
|
||||
import {
|
||||
Sidebar,
|
||||
FileBrowser,
|
||||
ConfigPanel,
|
||||
CommandPanel,
|
||||
MCPPanel,
|
||||
HooksPanel,
|
||||
@@ -19,6 +18,7 @@ import {
|
||||
ThemeProvider,
|
||||
listSessions,
|
||||
createSession,
|
||||
getWorkingDirectory,
|
||||
type Session,
|
||||
} from '@ai-assistant/ui';
|
||||
import { ChatPage } from './pages/Chat';
|
||||
@@ -27,7 +27,6 @@ export function App() {
|
||||
const [currentSessionId, setCurrentSessionId] = useState<string | null>(null);
|
||||
const [isInitializing, setIsInitializing] = useState(true);
|
||||
const [showFileBrowser, setShowFileBrowser] = useState(false);
|
||||
const [showConfig, setShowConfig] = useState(false);
|
||||
const [showCommands, setShowCommands] = useState(false);
|
||||
const [showMCP, setShowMCP] = useState(false);
|
||||
const [showHooks, setShowHooks] = useState(false);
|
||||
@@ -35,14 +34,26 @@ export function App() {
|
||||
const [showCheckpoints, setShowCheckpoints] = useState(false);
|
||||
const [showProviders, setShowProviders] = useState(false);
|
||||
const [sessionTitleUpdate, setSessionTitleUpdate] = useState<{ sessionId: string; name: string } | null>(null);
|
||||
const [workingDirectory, setWorkingDirectory] = useState<string>('');
|
||||
|
||||
// 初始化:加载会话(只在首次启动时自动创建)
|
||||
// 初始化:加载会话和工作目录
|
||||
useEffect(() => {
|
||||
const HAS_SESSIONS_KEY = 'ai-assistant-has-sessions';
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
const { data: sessions } = await listSessions();
|
||||
// 并行获取会话和工作目录
|
||||
const [sessionsResult, workdirResult] = await Promise.all([
|
||||
listSessions(),
|
||||
getWorkingDirectory().catch(() => null),
|
||||
]);
|
||||
|
||||
const { data: sessions } = sessionsResult;
|
||||
|
||||
// 设置工作目录
|
||||
if (workdirResult?.data?.workingDirectory) {
|
||||
setWorkingDirectory(workdirResult.data.workingDirectory);
|
||||
}
|
||||
|
||||
if (sessions.length > 0) {
|
||||
// 有会话,选择最近的
|
||||
@@ -130,13 +141,13 @@ export function App() {
|
||||
responsive
|
||||
showFileBrowser={showFileBrowser}
|
||||
onToggleFileBrowser={() => setShowFileBrowser(!showFileBrowser)}
|
||||
onOpenConfig={() => setShowConfig(true)}
|
||||
onOpenCommands={() => setShowCommands(true)}
|
||||
onOpenMCP={() => setShowMCP(true)}
|
||||
onOpenHooks={() => setShowHooks(true)}
|
||||
onOpenAgents={() => setShowAgents(true)}
|
||||
onOpenCheckpoints={() => setShowCheckpoints(true)}
|
||||
onOpenProviders={() => setShowProviders(true)}
|
||||
workingDirectory={workingDirectory}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex-1 flex items-center justify-center h-full">
|
||||
@@ -182,9 +193,6 @@ export function App() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 配置面板 */}
|
||||
{showConfig && <ConfigPanel onClose={() => setShowConfig(false)} responsive />}
|
||||
|
||||
{/* 命令面板 */}
|
||||
{showCommands && <CommandPanel onClose={() => setShowCommands(false)} responsive />}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user