feat: treeview with folders, toolbar, file attachments in chat
This commit is contained in:
@@ -1,13 +1,43 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { SessionList } from '@/components/ai/SessionList';
|
||||
import { ChatWindow } from '@/components/ai/ChatWindow';
|
||||
import { usePluginToolbarStore } from '@/store/pluginToolbarStore';
|
||||
import { fetchAgents, type AIAgent } from '@/api/ai';
|
||||
|
||||
export function AIAssistantPage() {
|
||||
const [activeSessionId, setActiveSessionId] = useState<string | null>(null);
|
||||
const [agents, setAgents] = useState<AIAgent[]>([]);
|
||||
const [selectedAgentId, setSelectedAgentId] = useState<string | null>(null);
|
||||
const { registerItems, unregisterPlugin } = usePluginToolbarStore();
|
||||
|
||||
useEffect(() => {
|
||||
fetchAgents().then(setAgents).catch(() => {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
registerItems('ai_assistant', [
|
||||
{
|
||||
id: 'agent-select',
|
||||
label: 'Agent',
|
||||
type: 'select',
|
||||
options: agents.map((a) => ({ value: a.id, label: a.name })),
|
||||
value: selectedAgentId || '',
|
||||
onChange: (val: string) => setSelectedAgentId(val || null),
|
||||
},
|
||||
{
|
||||
id: 'new-chat',
|
||||
label: 'Neuer Chat',
|
||||
type: 'button',
|
||||
onClick: () => setActiveSessionId(null),
|
||||
},
|
||||
]);
|
||||
|
||||
return () => unregisterPlugin('ai_assistant');
|
||||
}, [agents, selectedAgentId, registerItems, unregisterPlugin]);
|
||||
|
||||
return (
|
||||
<div className="flex h-full" data-testid="ai-assistant-page">
|
||||
{/* Left: Session List */}
|
||||
{/* Left: Session List with TreeView */}
|
||||
<div className="w-72 flex-shrink-0 border-r border-secondary-200 bg-white">
|
||||
<div className="h-16 flex items-center px-6 border-b border-secondary-200">
|
||||
<h1 className="text-lg font-bold text-secondary-900">KI Assistent</h1>
|
||||
@@ -21,7 +51,7 @@ export function AIAssistantPage() {
|
||||
{/* Right: Chat Window */}
|
||||
<div className="flex-1 flex flex-col">
|
||||
{activeSessionId ? (
|
||||
<ChatWindow sessionId={activeSessionId} className="flex-1" />
|
||||
<ChatWindow sessionId={activeSessionId} agentId={selectedAgentId} className="flex-1" />
|
||||
) : (
|
||||
<div className="flex-1 flex items-center justify-center text-secondary-400">
|
||||
<div className="text-center">
|
||||
|
||||
Reference in New Issue
Block a user