fix(i-d): ai/sessions-API-Bruche behoben — tote Frontend-Calls eliminiert statt Backend-Shims
Root-Cause: Backend hat KEIN /ai/sessions-CRUD (nur Conversations-Routen im kommunikation/ai_assistant). Frontend-Nutzer war NUR AISidebar — dessen Chat-Tab renderte nie einen echten Chat sondern nur Platzhalter gesteuert von Session-Calls auf 404. Nach AGENTS.md 0.2/0.3 keine Backend-Shims gebaut: (1) Geister-Tests ChatWindow.test.tsx + SessionList.test.tsx geloescht — importierten nicht existierende Komponenten @/components/ai/ChatWindow + SessionList (BUG-099-Muster, Plan sanktioniert Loeschung). (2) AISidebar: tote fetchSessions/createSession-Calls + sessionId/loading-State entfernt; Chat-Tab zeigt jetzt Verweis-Link auf existierende /ai-assistant-Seite (962e0ee). (3) api/ai.ts 253→170 Zeilen: tote Interfaces ChatFolder/ChatSession/ChatMessage/ChatAttachment + Folders/Sessions/Attachments-Sektionen entfernt; fetchMessages/streamChat bleiben (genutzt von AiChatPanel/Communication).
Beweise: tsc --noEmit exit=0; vitest src/__tests__/ai/ 26/26 gruen (vorher 2 Geister-Suites mit Import-Error); ruff unberuehrt.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { ResizablePanel } from '@/components/ui/ResizablePanel';
|
||||
import { SuggestionList } from '@/components/ai/SuggestionSidebar';
|
||||
import { ImprovementPanel } from '@/components/ai/ImprovementPanel';
|
||||
import { createSession, fetchSessions } from '@/api/ai';
|
||||
import { useUIStore } from '@/store/uiStore';
|
||||
import { getContributedTabs } from './sidebarTabs';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -56,26 +56,6 @@ function ChatPanel() {
|
||||
export function AISidebar() {
|
||||
const { t } = useTranslation();
|
||||
const { aiSidebarCollapsed, toggleAISidebar, aiSidebarTab, setAISidebarTab, notifications, removeNotification } = useUIStore();
|
||||
const [sessionId, setSessionId] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const sessions = await fetchSessions(true);
|
||||
if (sessions.length > 0) {
|
||||
setSessionId(sessions[0].id);
|
||||
} else {
|
||||
const session = await createSession({ is_sidebar: true, title: 'Sidebar Chat' });
|
||||
setSessionId(session.id);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('AISidebar init error:', e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
const tabs: TabDef[] = [
|
||||
{ key: 'chat', label: 'KI Chat', icon: robotIcon, testId: 'ai-sidebar-tab-chat' },
|
||||
@@ -166,18 +146,18 @@ export function AISidebar() {
|
||||
const ContributedComponent = contributed.component;
|
||||
return <ContributedComponent />;
|
||||
}
|
||||
// chat tab
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full text-sm text-secondary-400">Laden...</div>
|
||||
);
|
||||
}
|
||||
if (sessionId) {
|
||||
return <div className="flex items-center justify-center h-full text-secondary-400 text-sm">KI Chat im Kommunikations-Plugin verfügbar</div>;
|
||||
}
|
||||
// chat tab — voller KI-Chat lebt auf der /ai-assistant-Seite
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full text-sm text-red-500">
|
||||
Session konnte nicht erstellt werden
|
||||
<div className="flex flex-col items-center justify-center h-full text-center px-4 gap-3">
|
||||
<p className="text-sm text-secondary-500">
|
||||
Der volle KI-Chat ist auf der AI-Assistant-Seite verfügbar.
|
||||
</p>
|
||||
<Link
|
||||
to="/ai-assistant"
|
||||
className="inline-flex items-center px-4 py-2 rounded-md bg-primary-600 text-white text-sm font-medium hover:bg-primary-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 min-h-touch"
|
||||
>
|
||||
AI Assistant öffnen
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user