diff --git a/frontend/src/components/ai/SessionList.tsx b/frontend/src/components/ai/SessionList.tsx
index 791b56c..26d50b0 100644
--- a/frontend/src/components/ai/SessionList.tsx
+++ b/frontend/src/components/ai/SessionList.tsx
@@ -43,7 +43,7 @@ function buildTree(folders: ChatFolder[], sessions: ChatSession[]): TreeNode[] {
}
function TreeItem({
- node, activeSessionId, onSelectSession, depth, onContextMenu, onDragSession, onDropToFolder, onDelete,
+ node, activeSessionId, onSelectSession, depth, onContextMenu, onDragSession, onDragFolder, onDropToFolder, onDelete,
}: {
node: TreeNode;
activeSessionId: string | null;
@@ -51,6 +51,7 @@ function TreeItem({
depth: number;
onContextMenu: (e: React.MouseEvent, type: 'session' | 'folder' | 'root', id: string | null) => void;
onDragSession: (sessionId: string) => void;
+ onDragFolder: (folderId: string) => void;
onDropToFolder: (folderId: string | null) => void;
onDelete: (id: string, type: 'session' | 'folder') => void;
}) {
@@ -63,7 +64,15 @@ function TreeItem({
e.preventDefault();
e.stopPropagation();
setIsDragOver(false);
- onDropToFolder(folderId);
+ const data = e.dataTransfer.getData('text/plain');
+ if (data.startsWith('folder:')) {
+ const draggedFolderId = data.slice(7);
+ if (draggedFolderId !== folderId) {
+ onDropToFolder(folderId);
+ }
+ } else {
+ onDropToFolder(folderId);
+ }
};
const handleDragOver = (e: React.DragEvent) => {
@@ -77,6 +86,12 @@ function TreeItem({
{/* Folder header - drop target */}
{!isRoot && (
{
+ e.dataTransfer.setData('text/plain', `folder:${node.folder!.id}`);
+ e.dataTransfer.effectAllowed = 'move';
+ onDragFolder(node.folder!.id);
+ }}
onDragOver={handleDragOver}
onDragLeave={() => setIsDragOver(false)}
onDrop={handleDrop}
@@ -166,6 +181,7 @@ function TreeItem({
depth={depth + 1}
onContextMenu={onContextMenu}
onDragSession={onDragSession}
+ onDragFolder={onDragFolder}
onDropToFolder={onDropToFolder}
onDelete={onDelete}
/>
@@ -236,6 +252,7 @@ export function SessionList({ activeSessionId, onSelectSession, isSidebar, class
const [loading, setLoading] = useState(true);
const [error, setError] = useState
(null);
const [dragSessionId, setDragSessionId] = useState(null);
+ const [dragFolderId, setDragFolderId] = useState(null);
const [contextMenu, setContextMenu] = useState(null);
const loadData = async () => {
@@ -296,6 +313,14 @@ export function SessionList({ activeSessionId, onSelectSession, isSidebar, class
};
const handleDropToFolder = async (folderId: string | null) => {
+ if (dragFolderId) {
+ try {
+ await updateFolder(dragFolderId, { parent_id: folderId });
+ setDragFolderId(null);
+ loadData();
+ } catch (e) { setError(e instanceof Error ? e.message : 'Failed to move folder'); }
+ return;
+ }
if (!dragSessionId) return;
try {
await updateSession(dragSessionId, { folder_id: folderId });
@@ -326,6 +351,7 @@ export function SessionList({ activeSessionId, onSelectSession, isSidebar, class
depth={0}
onContextMenu={handleContextMenu}
onDragSession={setDragSessionId}
+ onDragFolder={setDragFolderId}
onDropToFolder={handleDropToFolder}
onDelete={handleDelete}
/>
diff --git a/frontend/src/pages/AIAssistant.tsx b/frontend/src/pages/AIAssistant.tsx
index 8e5f797..221f1fe 100644
--- a/frontend/src/pages/AIAssistant.tsx
+++ b/frontend/src/pages/AIAssistant.tsx
@@ -3,7 +3,7 @@ import { SessionList } from '@/components/ai/SessionList';
import { ChatWindow } from '@/components/ai/ChatWindow';
import { ResizablePanel } from '@/components/ui/ResizablePanel';
import { usePluginToolbarStore } from '@/store/pluginToolbarStore';
-import { fetchAgents, type AIAgent } from '@/api/ai';
+import { fetchAgents, createSession, type AIAgent } from '@/api/ai';
export function AIAssistantPage() {
const [activeSessionId, setActiveSessionId] = useState(null);
@@ -39,7 +39,16 @@ export function AIAssistantPage() {
),
- onClick: () => { setActiveSessionId(null); setMobileView('list'); setRefreshKey(k => k + 1); },
+ onClick: async () => {
+ try {
+ const session = await createSession({ is_sidebar: false });
+ setActiveSessionId(session.id);
+ setMobileView('chat');
+ setRefreshKey(k => k + 1);
+ } catch (e) {
+ console.error('Failed to create session:', e);
+ }
+ },
},
{
id: 'new-folder',