Generate system prompt dynamically in SessionManager

This commit is contained in:
Alex Gleason committed 2025-09-23 23:29:02 -05:00
1 parent 0c379c5495
commit 289caff882
4 files changed
+25 -34

No files matched your search

+3 -3
View File
@@ -17,13 +17,13 @@ export function SessionManagerProvider({ children }: SessionManagerProviderProps
const { fs } = useFS();
const { settings } = useAISettings();
const { models } = useProviderModels();
const { user } = useCurrentUser();
const { user, metadata } = useCurrentUser();
const sessionManager = useMemo(() => {
const getProviderModels = () => models;
const getCurrentUser = () => user;
const getCurrentUser = () => ({ user, metadata });
return new SessionManager(fs, settings, getProviderModels, getCurrentUser);
}, [fs, settings, models, user]);
}, [fs, settings, models, user, metadata]);
// Cleanup on unmount
useEffect(() => {
+1 -17
View File
@@ -37,7 +37,6 @@ import { TypecheckTool } from '@/lib/tools/TypecheckTool';
import { toolToOpenAI } from '@/lib/tools/openai-adapter';
import { Tool } from '@/lib/tools/Tool';
import OpenAI from 'openai';
import { makeSystemPrompt } from '@/lib/system';
import { saveFileToTmp } from '@/lib/fileUtils';
import { useGit } from '@/hooks/useGit';
import { useConsoleErrorAlert, useAIModelErrorAlert } from '@/hooks/useErrorDetection';
@@ -119,7 +118,6 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
}, ref) => {
const { t } = useTranslation();
const [input, setInput] = useState('');
const [systemPrompt, setSystemPrompt] = useState('');
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
const [attachedFiles, setAttachedFiles] = useState<File[]>([]);
const [isDragOver, setIsDragOver] = useState(false);
@@ -146,7 +144,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
const [searchParams, setSearchParams] = useSearchParams();
const { fs } = useFS();
const { git } = useGit();
const { user, metadata } = useCurrentUser();
const { user } = useCurrentUser();
const { models } = useProviderModels();
// Initialize AI chat with tools
@@ -210,19 +208,6 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
updateMetadata(title, description);
}, [updateMetadata]);
useEffect(() => {
makeSystemPrompt({
cwd,
fs,
mode: "agent",
name: "Shakespeare",
profession: "software extraordinaire",
tools: Object.values(tools),
user,
metadata,
}).then(setSystemPrompt)
}, [fs, cwd, tools, user, metadata]);
const {
messages,
streamingMessage,
@@ -237,7 +222,6 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
projectId,
tools,
customTools,
systemPrompt,
onUpdateMetadata,
});