Progressively rebuild when files change

This commit is contained in:
Alex Gleason committed 2025-11-04 17:22:12 -06:00
1 parent adc4dd19b7
commit ef6962d7c7
8 files changed
+225 -6

No files matched your search

+12 -3
View File
@@ -13,6 +13,7 @@ import { useKeepAlive } from '@/hooks/useKeepAlive';
import { useAppContext } from '@/hooks/useAppContext';
import { useAIChat } from '@/hooks/useAIChat';
import { useProviderModels } from '@/hooks/useProviderModels';
import { useSessionManager } from '@/hooks/useSessionManager';
import { AIMessageItem } from '@/components/AIMessageItem';
import { TextEditorViewTool } from '@/lib/tools/TextEditorViewTool';
import { TextEditorWriteTool } from '@/lib/tools/TextEditorWriteTool';
@@ -138,12 +139,20 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
// Initialize AI chat with tools
const cwd = `${projectsPath}/${projectId}`;
const esmUrlRef = useRef(config.esmUrl);
const sessionManager = useSessionManager();
// Callback to emit file changes for auto-build
const handleFileChanged = useCallback((filePath: string) => {
// Emit the fileChanged event through the session manager
sessionManager.emit('fileChanged', projectId, filePath);
}, [sessionManager, projectId]);
const customTools = useMemo(() => {
const baseTools = {
git_commit: new GitCommitTool(fs, cwd, git),
text_editor_view: new TextEditorViewTool(fs, cwd, { projectsPath }),
text_editor_write: new TextEditorWriteTool(fs, cwd, { projectsPath, tmpPath }),
text_editor_str_replace: new TextEditorStrReplaceTool(fs, cwd, { projectsPath, tmpPath }),
text_editor_write: new TextEditorWriteTool(fs, cwd, { projectsPath, tmpPath, onFileChanged: handleFileChanged }),
text_editor_str_replace: new TextEditorStrReplaceTool(fs, cwd, { projectsPath, tmpPath, onFileChanged: handleFileChanged }),
npm_add_package: new NpmAddPackageTool(fs, cwd),
npm_remove_package: new NpmRemovePackageTool(fs, cwd),
build_project: new BuildProjectTool(fs, cwd, esmUrlRef.current),
@@ -169,7 +178,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
}
return baseTools;
}, [fs, git, cwd, user, projectId, projectsPath, tmpPath]);
}, [fs, git, cwd, user, projectId, projectsPath, tmpPath, handleFileChanged]);
// Convert tools to OpenAI format
const tools = useMemo(() => {
+4 -1
View File
@@ -741,7 +741,10 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
<div className="absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10">
<div className="bg-background/90 border rounded-lg p-4 shadow-lg flex items-center gap-3">
<Loader2 className="h-5 w-5 animate-spin text-primary" />
<span className="text-sm font-medium">Building project...</span>
<div className="flex flex-col">
<span className="text-sm font-medium">Building project...</span>
<span className="text-xs text-muted-foreground">Preview will update automatically</span>
</div>
</div>
</div>
)}