From 4cdd257735b304559bc561e52438f65a1ecc5983 Mon Sep 17 00:00:00 2001 From: Andre Padez Date: Tue, 17 Feb 2026 01:49:42 +0000 Subject: [PATCH] chat history as plugin --- src/apps/officer-web/App.tsx | 3 ++- src/apps/officer-web/Screens/Dashboard/Chat/index.tsx | 11 +---------- src/apps/officer-web/Screens/Dashboard/Home/index.tsx | 2 +- src/apps/officer-web/state/useInitialData.ts | 2 +- src/workspaces/plugins/Chat/client/useClaude.ts | 2 +- src/workspaces/plugins/Chat/client/useOpenCode.ts | 2 +- .../plugins/ChatHistory/client/ChatPanel.tsx} | 6 +++--- .../plugins/ChatHistory/client/Screen.tsx} | 4 ++-- .../plugins/ChatHistory/client}/SessionBar.tsx | 0 .../plugins/ChatHistory/client/Widget.tsx} | 4 ++-- src/workspaces/plugins/ChatHistory/client/index.ts | 7 +++++++ .../ChatHistory/client}/state/useOpenCodeSessions.ts | 0 .../plugins/ChatHistory/client}/state/useSessions.ts | 0 .../ChatHistory/client}/state/useSlashCommands.ts | 0 src/workspaces/plugins/ChatHistory/index.ts | 7 +++++++ src/workspaces/plugins/package.json | 4 +++- 16 files changed, 31 insertions(+), 23 deletions(-) rename src/{apps/officer-web/Screens/Dashboard/Chat/ChatPanel/index.tsx => workspaces/plugins/ChatHistory/client/ChatPanel.tsx} (96%) rename src/{apps/officer-web/Screens/Dashboard/Chat/SessionList.tsx => workspaces/plugins/ChatHistory/client/Screen.tsx} (97%) rename src/{apps/officer-web/Screens/Dashboard/Chat/ChatPanel => workspaces/plugins/ChatHistory/client}/SessionBar.tsx (100%) rename src/{apps/officer-web/Screens/Dashboard/Home/ChatHistory.tsx => workspaces/plugins/ChatHistory/client/Widget.tsx} (97%) create mode 100644 src/workspaces/plugins/ChatHistory/client/index.ts rename src/{apps/officer-web => workspaces/plugins/ChatHistory/client}/state/useOpenCodeSessions.ts (100%) rename src/{apps/officer-web => workspaces/plugins/ChatHistory/client}/state/useSessions.ts (100%) rename src/{apps/officer-web => workspaces/plugins/ChatHistory/client}/state/useSlashCommands.ts (100%) create mode 100644 src/workspaces/plugins/ChatHistory/index.ts diff --git a/src/apps/officer-web/App.tsx b/src/apps/officer-web/App.tsx index 6aa83cd5..1f7f0cb4 100644 --- a/src/apps/officer-web/App.tsx +++ b/src/apps/officer-web/App.tsx @@ -5,7 +5,8 @@ import { useInitialData } from '@/state/useInitialData'; import { LandingPage, AuthLayout } from './Screens/LandingPage'; import { Home } from './Screens/Dashboard/Home'; import { ProfileSettings } from './Screens/Dashboard/Settings/ProfileSettings'; -import { ClaudeSessions, ClaudeChat, OpenCodeChat, NewChat } from './Screens/Dashboard/Chat'; +import { ClaudeChat, OpenCodeChat, NewChat } from './Screens/Dashboard/Chat'; +import { Screen as ClaudeSessions } from 'plugins/ChatHistory/client'; import { Plans } from './Screens/Dashboard/Plans'; import { Skills } from './Screens/Dashboard/Skills'; import { Tasks } from './Screens/Dashboard/Tasks'; diff --git a/src/apps/officer-web/Screens/Dashboard/Chat/index.tsx b/src/apps/officer-web/Screens/Dashboard/Chat/index.tsx index dfbbc2fd..73728210 100644 --- a/src/apps/officer-web/Screens/Dashboard/Chat/index.tsx +++ b/src/apps/officer-web/Screens/Dashboard/Chat/index.tsx @@ -2,19 +2,10 @@ import { useState } from 'react'; import { useParams } from 'react-router'; import { useQueryClient } from '@tanstack/react-query'; import { useClaude, useOpenCode, type SessionEntry } from 'plugins/Chat/client'; +import { ChatPanel } from 'plugins/ChatHistory/client'; import { DashboardLayout } from '../Layout'; -import { ChatPanel } from './ChatPanel'; -import { SessionList } from './SessionList'; import { useVisibleClaudeModels, useVisibleOpenCodeModels } from '@/state/useModels'; -export const ClaudeSessions = () => { - return ( - - - - ); -}; - export const ClaudeChat = () => { const { sessionId } = useParams<{ sessionId: string }>(); const queryClient = useQueryClient(); diff --git a/src/apps/officer-web/Screens/Dashboard/Home/index.tsx b/src/apps/officer-web/Screens/Dashboard/Home/index.tsx index 64fe23b9..a048457a 100644 --- a/src/apps/officer-web/Screens/Dashboard/Home/index.tsx +++ b/src/apps/officer-web/Screens/Dashboard/Home/index.tsx @@ -1,7 +1,7 @@ import { DashboardLayout } from '../Layout'; import { ChatLauncher } from './ChatLauncher'; import { Widget as FileBrowser } from 'plugins/FileBrowser/client'; -import { ChatHistory } from './ChatHistory'; +import { Widget as ChatHistory } from 'plugins/ChatHistory/client'; import { Catalog } from 'sounds'; import { useServerSettings } from '@/state/useServerSettings'; diff --git a/src/apps/officer-web/state/useInitialData.ts b/src/apps/officer-web/state/useInitialData.ts index fa65496a..48ae9cb0 100644 --- a/src/apps/officer-web/state/useInitialData.ts +++ b/src/apps/officer-web/state/useInitialData.ts @@ -1,4 +1,4 @@ -import { useSessions } from './useSessions'; +import { useSessions } from 'plugins/ChatHistory/client'; import { usePlans } from './usePlans'; import { useSettings } from './useSettings'; import { useThemeSync } from './useThemeSync'; diff --git a/src/workspaces/plugins/Chat/client/useClaude.ts b/src/workspaces/plugins/Chat/client/useClaude.ts index 866bac01..ece4dfbf 100644 --- a/src/workspaces/plugins/Chat/client/useClaude.ts +++ b/src/workspaces/plugins/Chat/client/useClaude.ts @@ -1,6 +1,6 @@ import { useState, useEffect, useRef } from 'react'; import { useChatWebSocket } from 'hooks/useChatWebSocket'; -import { useSessions } from '@/state/useSessions'; +import { useSessions } from 'plugins/ChatHistory/client'; import type { ChatMessage, ServerMessage, TaskInfo } from './types'; const SAVE_DEBOUNCE_MS = 1000; diff --git a/src/workspaces/plugins/Chat/client/useOpenCode.ts b/src/workspaces/plugins/Chat/client/useOpenCode.ts index e4811615..d86e5594 100644 --- a/src/workspaces/plugins/Chat/client/useOpenCode.ts +++ b/src/workspaces/plugins/Chat/client/useOpenCode.ts @@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from 'react'; import { useChatWebSocket } from 'hooks/useChatWebSocket'; import { useSettings } from '@/state/useSettings'; import { useVisibleOpenCodeModels } from '@/state/useModels'; -import { useOpenCodeSessions } from '@/state/useOpenCodeSessions'; +import { useOpenCodeSessions } from 'plugins/ChatHistory/client'; import type { ChatMessage, ServerMessage, TaskInfo } from './types'; type UseOpenCodeOptions = { diff --git a/src/apps/officer-web/Screens/Dashboard/Chat/ChatPanel/index.tsx b/src/workspaces/plugins/ChatHistory/client/ChatPanel.tsx similarity index 96% rename from src/apps/officer-web/Screens/Dashboard/Chat/ChatPanel/index.tsx rename to src/workspaces/plugins/ChatHistory/client/ChatPanel.tsx index 7e4435c7..b14991ff 100644 --- a/src/apps/officer-web/Screens/Dashboard/Chat/ChatPanel/index.tsx +++ b/src/workspaces/plugins/ChatHistory/client/ChatPanel.tsx @@ -1,11 +1,11 @@ import { useRef, useEffect, useState } from 'react'; import { useNavigate, useLocation } from 'react-router'; -import { useSessions } from '@/state/useSessions'; +import { useSessions } from './state/useSessions'; import type { ModelOption } from '@/state/useModels'; -import { useOpenCodeSessions } from '@/state/useOpenCodeSessions'; +import { useOpenCodeSessions } from './state/useOpenCodeSessions'; import type { useClaude, Attachment } from 'plugins/Chat/client'; import { EmbeddableChat } from 'plugins/Chat/client'; -import { useSlashCommands } from '@/state/useSlashCommands'; +import { useSlashCommands } from './state/useSlashCommands'; import { Card } from '@/components/Card'; import { SessionBar } from './SessionBar'; diff --git a/src/apps/officer-web/Screens/Dashboard/Chat/SessionList.tsx b/src/workspaces/plugins/ChatHistory/client/Screen.tsx similarity index 97% rename from src/apps/officer-web/Screens/Dashboard/Chat/SessionList.tsx rename to src/workspaces/plugins/ChatHistory/client/Screen.tsx index 7e7f9966..7ec337c6 100644 --- a/src/apps/officer-web/Screens/Dashboard/Chat/SessionList.tsx +++ b/src/workspaces/plugins/ChatHistory/client/Screen.tsx @@ -3,8 +3,8 @@ import { Link } from 'react-router'; import { Plus, MessageSquare, Trash2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/Card'; -import { useSessions } from '@/state/useSessions'; -import { useOpenCodeSessions } from '@/state/useOpenCodeSessions'; +import { useSessions } from './state/useSessions'; +import { useOpenCodeSessions } from './state/useOpenCodeSessions'; type Filter = 'all' | 'claude' | 'opencode'; diff --git a/src/apps/officer-web/Screens/Dashboard/Chat/ChatPanel/SessionBar.tsx b/src/workspaces/plugins/ChatHistory/client/SessionBar.tsx similarity index 100% rename from src/apps/officer-web/Screens/Dashboard/Chat/ChatPanel/SessionBar.tsx rename to src/workspaces/plugins/ChatHistory/client/SessionBar.tsx diff --git a/src/apps/officer-web/Screens/Dashboard/Home/ChatHistory.tsx b/src/workspaces/plugins/ChatHistory/client/Widget.tsx similarity index 97% rename from src/apps/officer-web/Screens/Dashboard/Home/ChatHistory.tsx rename to src/workspaces/plugins/ChatHistory/client/Widget.tsx index 2f96f0e0..232fde4e 100644 --- a/src/apps/officer-web/Screens/Dashboard/Home/ChatHistory.tsx +++ b/src/workspaces/plugins/ChatHistory/client/Widget.tsx @@ -2,8 +2,8 @@ import { useMemo } from 'react'; import { Link } from 'react-router'; import { MessageSquare, Trash2, ChevronDown, ChevronUp } from 'lucide-react'; import { Card } from '@/components/Card'; -import { useSessions } from '@/state/useSessions'; -import { useOpenCodeSessions } from '@/state/useOpenCodeSessions'; +import { useSessions } from './state/useSessions'; +import { useOpenCodeSessions } from './state/useOpenCodeSessions'; import { useUserState } from '@/state/useUserState'; export const ChatHistory = () => { diff --git a/src/workspaces/plugins/ChatHistory/client/index.ts b/src/workspaces/plugins/ChatHistory/client/index.ts new file mode 100644 index 00000000..964d9c50 --- /dev/null +++ b/src/workspaces/plugins/ChatHistory/client/index.ts @@ -0,0 +1,7 @@ +export { ChatHistory as Widget } from './Widget'; +export { SessionList as Screen } from './Screen'; +export { ChatPanel } from './ChatPanel'; +export { SessionBar } from './SessionBar'; +export { useSessions } from './state/useSessions'; +export { useOpenCodeSessions } from './state/useOpenCodeSessions'; +export { useSlashCommands, type SlashCommandResult } from './state/useSlashCommands'; diff --git a/src/apps/officer-web/state/useOpenCodeSessions.ts b/src/workspaces/plugins/ChatHistory/client/state/useOpenCodeSessions.ts similarity index 100% rename from src/apps/officer-web/state/useOpenCodeSessions.ts rename to src/workspaces/plugins/ChatHistory/client/state/useOpenCodeSessions.ts diff --git a/src/apps/officer-web/state/useSessions.ts b/src/workspaces/plugins/ChatHistory/client/state/useSessions.ts similarity index 100% rename from src/apps/officer-web/state/useSessions.ts rename to src/workspaces/plugins/ChatHistory/client/state/useSessions.ts diff --git a/src/apps/officer-web/state/useSlashCommands.ts b/src/workspaces/plugins/ChatHistory/client/state/useSlashCommands.ts similarity index 100% rename from src/apps/officer-web/state/useSlashCommands.ts rename to src/workspaces/plugins/ChatHistory/client/state/useSlashCommands.ts diff --git a/src/workspaces/plugins/ChatHistory/index.ts b/src/workspaces/plugins/ChatHistory/index.ts new file mode 100644 index 00000000..7ccfde25 --- /dev/null +++ b/src/workspaces/plugins/ChatHistory/index.ts @@ -0,0 +1,7 @@ +export { Widget, Screen, ChatPanel, SessionBar } from './client'; + +export const plugin = { + id: 'ChatHistory', + name: 'Chat History', + description: 'Session management for chat history', +}; diff --git a/src/workspaces/plugins/package.json b/src/workspaces/plugins/package.json index b03f904f..fe3d03e0 100644 --- a/src/workspaces/plugins/package.json +++ b/src/workspaces/plugins/package.json @@ -11,6 +11,8 @@ "./Terminal/client": "./Terminal/client/index.ts", "./Terminal/server": "./Terminal/server/index.ts", "./Chat": "./Chat/index.ts", - "./Chat/client": "./Chat/client/index.ts" + "./Chat/client": "./Chat/client/index.ts", + "./ChatHistory": "./ChatHistory/index.ts", + "./ChatHistory/client": "./ChatHistory/client/index.ts" } }