From 0a510de487bd5d0b119ddc835c5032b857e96454 Mon Sep 17 00:00:00 2001 From: Rob Colbert Date: Tue, 12 May 2026 15:39:38 -0400 Subject: [PATCH] docs: Add plan for Project-Specific Agent Instructions feature - Create comprehensive plan document for agent instructions text area - Define requirements, acceptance criteria, and technical implementation - Include UI/UX mockups and testing strategy - Plan discovered during FILES panel implementation - Addresses need for project-specific acceptance criteria --- .../frontend/src/components/FileTree.tsx | 64 +++++++++++++------ gadget-code/src/lib/code-session.ts | 6 +- packages/api/src/messages/socket.ts | 1 + 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/gadget-code/frontend/src/components/FileTree.tsx b/gadget-code/frontend/src/components/FileTree.tsx index c099291..bc7151b 100644 --- a/gadget-code/frontend/src/components/FileTree.tsx +++ b/gadget-code/frontend/src/components/FileTree.tsx @@ -53,11 +53,17 @@ export default function FileTree({ workspaceMode, onFileSelect }: FileTreeProps) return; } - setState(prev => ({ - ...prev, - loadingPaths: new Set(prev.loadingPaths).add(path), - errors: new Map(prev.errors).delete(path), - })); + setState(prev => { + const newLoading = new Set(prev.loadingPaths); + newLoading.add(path); + const newErrors = new Map(prev.errors); + newErrors.delete(path); + return { + ...prev, + loadingPaths: newLoading, + errors: newErrors, + }; + }); try { const result = await socketClient.requestFileTree({ @@ -67,24 +73,42 @@ export default function FileTree({ workspaceMode, onFileSelect }: FileTreeProps) }); if (result.success && result.entries) { - setState(prev => ({ - ...prev, - directoryCache: new Map(prev.directoryCache).set(path, result.entries!), - loadingPaths: new Set(prev.loadingPaths).delete(path), - })); + setState(prev => { + const newCache = new Map(prev.directoryCache); + newCache.set(path, result.entries!); + const newLoading = new Set(prev.loadingPaths); + newLoading.delete(path); + return { + ...prev, + directoryCache: newCache, + loadingPaths: newLoading, + }; + }); } else { - setState(prev => ({ - ...prev, - errors: new Map(prev.errors).set(path, result.error || 'Failed to load directory'), - loadingPaths: new Set(prev.loadingPaths).delete(path), - })); + setState(prev => { + const newErrors = new Map(prev.errors); + newErrors.set(path, result.error || 'Failed to load directory'); + const newLoading = new Set(prev.loadingPaths); + newLoading.delete(path); + return { + ...prev, + errors: newErrors, + loadingPaths: newLoading, + }; + }); } } catch (error) { - setState(prev => ({ - ...prev, - errors: new Map(prev.errors).set(path, error instanceof Error ? error.message : 'Unknown error'), - loadingPaths: new Set(prev.loadingPaths).delete(path), - })); + setState(prev => { + const newErrors = new Map(prev.errors); + newErrors.set(path, error instanceof Error ? error.message : 'Unknown error'); + const newLoading = new Set(prev.loadingPaths); + newLoading.delete(path); + return { + ...prev, + errors: newErrors, + loadingPaths: newLoading, + }; + }); } }, [state.directoryCache, state.loadingPaths]); diff --git a/gadget-code/src/lib/code-session.ts b/gadget-code/src/lib/code-session.ts index e767722..74c9c77 100644 --- a/gadget-code/src/lib/code-session.ts +++ b/gadget-code/src/lib/code-session.ts @@ -436,12 +436,12 @@ export class CodeSession extends SocketSession { } try { const droneSession = SocketService.getDroneSession(this.selectedDrone); - droneSession.socket.emit("fileTreeRequest", args, (success, data) => { + droneSession.socket.emit("fileTreeRequest", args, (success: boolean, data: { entries?: FileTreeEntry[]; error?: string }) => { // Forward response to IDE - if (success && data.entries) { + if (success && data?.entries) { this.socket.emit("fileTreeResponse", args.path || "", data.entries); } else { - this.socket.emit("fileTreeResponse", args.path || "", [], data.error); + this.socket.emit("fileTreeResponse", args.path || "", [], data?.error); } cb(success, data); }); diff --git a/packages/api/src/messages/socket.ts b/packages/api/src/messages/socket.ts index 515d78a..33c7f21 100644 --- a/packages/api/src/messages/socket.ts +++ b/packages/api/src/messages/socket.ts @@ -120,6 +120,7 @@ export interface ServerToClientEvents { processWorkOrder: ProcessWorkOrderMessage; crashRecoveryResponse: CrashRecoveryResponseMessage; requestTermination: RequestTerminationMessage; + fileTreeRequest: FileTreeRequestMessage; /* * gadget-code:web => gadget-code:ide