UI Debugging & Docs: Fix React error #130, update README, and cleanup dead backend logic
This commit is contained in:
@@ -2422,8 +2422,7 @@ Format: { "ideas": [{ "title": "Short Title", "subtitle": "One line", "tag": "To
|
||||
}, 45000);
|
||||
|
||||
let systemPrompt = '';
|
||||
const isBackendRequest = userPrompt.includes('[BACKEND_REQUEST]');
|
||||
const isModificationMode = (state.state === OrchestratorState.PreviewReady || state.state === OrchestratorState.Editing) && !isBackendRequest;
|
||||
const isModificationMode = (state.state === OrchestratorState.PreviewReady || state.state === OrchestratorState.Editing);
|
||||
let requestKind: 'chat' | 'plan' | 'code' = (isChatMode || isBrainstormMode) ? 'chat' : 'plan';
|
||||
|
||||
// SMART ROUTING: REMOVED CONCIERGE (F4: Plan First Enforcement)
|
||||
@@ -2431,9 +2430,7 @@ Format: { "ideas": [{ "title": "Short Title", "subtitle": "One line", "tag": "To
|
||||
if (isChatMode) {
|
||||
const sysP = personaSystem(state, state.chatPersona, state.customChatPersonaPrompt);
|
||||
systemPrompt = `[SYSTEM INSTRUCTION]: ${sysP}\n\n[CONTEXT]: This is CHAT mode (not building). Do not generate code unless explicitly asked. If user asks for a change to an existing project, propose a plan starting with '[PLAN]' and wait for approval. Use PLAIN PROSE for conversation, no markdown code blocks for speech.\n\n[IMAGE GENERATION]: You CAN generate images! If the user asks for an image, painting, illustration, or visual content, acknowledge that you're generating it. The system will handle the actual generation. Say something like "I'm creating that image for you now, please wait a moment...".`;
|
||||
} else if (isBackendRequest) {
|
||||
// Backend requests are effectively "new plans" but we handle the prompt generation specifically below
|
||||
requestKind = 'plan';
|
||||
|
||||
} else if (isBrainstormMode) {
|
||||
const lower = userPrompt.toLowerCase();
|
||||
const wantsPlan = lower.includes('plan') || lower.includes('formalize') || lower.includes('blueprint');
|
||||
@@ -2474,19 +2471,7 @@ Format: { "ideas": [{ "title": "Short Title", "subtitle": "One line", "tag": "To
|
||||
(window as any)._redesignApprovedSessions[state.activeProject.id] = true;
|
||||
}
|
||||
|
||||
const isBackendRequest = userPrompt.includes('[BACKEND_REQUEST]');
|
||||
|
||||
if (isBackendRequest) {
|
||||
// --- BACKEND GENERATION MODE ---
|
||||
systemPrompt = `[SYSTEM INSTRUCTION]: BACKEND GENERATION REQUEST.
|
||||
|
||||
The user wants to generate a server-side implementation for the existing frontend.
|
||||
1. Analyze the provided frontend code in the user prompt.
|
||||
2. Identify all API endpoints and data structures.
|
||||
3. Propose a plan to create a 'server.js' (Node.js/Express) file.
|
||||
4. The plan MUST start with '[PLAN]'.
|
||||
5. Do NOT modify the frontend code. Only build the backend.`;
|
||||
} else if (isQaFailureArtifact) {
|
||||
// --- REPAIR MODE (F3: Retention & Match) ---
|
||||
// "Broken frontend is treated as a REPAIR task"
|
||||
const originalIntent = state.activeProject?.originalPrompt || "Unknown Intent";
|
||||
@@ -2572,22 +2557,22 @@ Brief plan starting with '[PLAN]'.`;
|
||||
// We ignore overrideInput / one-shot triggers for the initial build request.
|
||||
requestKind = 'plan';
|
||||
systemPrompt = `[SYSTEM INSTRUCTION]: Propose an implementation plan starting with '[PLAN]'. DO NOT output code yet.`;
|
||||
}
|
||||
}
|
||||
|
||||
if (state.preferredFramework) {
|
||||
if (state.preferredFramework) {
|
||||
systemPrompt += `\n\n[USER PREFERENCE]: The user has explicitly requested to use the "${state.preferredFramework}" framework. You MUST prioritize this framework, along with its standard ecosystem (e.g. if React, use typical React libs; if Tailwind, use utility classes).`;
|
||||
}
|
||||
}
|
||||
|
||||
// IMMEDIATE FEEDBACK: If we are planning, switch to Plan tab immediately so user sees the stream
|
||||
if (requestKind === 'plan') {
|
||||
// IMMEDIATE FEEDBACK: If we are planning, switch to Plan tab immediately so user sees the stream
|
||||
if (requestKind === 'plan') {
|
||||
dispatch({ type: 'TRANSITION', to: OrchestratorState.Planning });
|
||||
dispatch({ type: 'SET_TAB', tab: TabId.Plan });
|
||||
dispatch({ type: 'UPDATE_PLAN', plan: "# Analyzing Request...\n\n*Forging blueprint based on 2025 System Standards...*" });
|
||||
}
|
||||
}
|
||||
|
||||
setThinkingLabel('Thinking...');
|
||||
setThinkingLabel('Thinking...');
|
||||
|
||||
if ((window as any).electron) {
|
||||
if ((window as any).electron) {
|
||||
const sessionId = Date.now().toString();
|
||||
let currentProjectId = state.activeProject?.id || null;
|
||||
|
||||
@@ -2712,28 +2697,28 @@ Brief plan starting with '[PLAN]'.`;
|
||||
{ role: 'user', content: userPrompt }
|
||||
], state.chatSettings.activeModel);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
clearTimeout(timeoutId);
|
||||
setTimeout(() => {
|
||||
dispatch({ type: 'ADD_LOG', log: { id: Date.now().toString(), timestamp: Date.now(), type: 'system', message: "[OFFLINE] Simulated response." } });
|
||||
finalizeRequest();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const showStreaming = (state.state === OrchestratorState.Building) && state.activeBuildSessionId != null && state.streamingCode != null;
|
||||
const showStreaming = (state.state === OrchestratorState.Building) && state.activeBuildSessionId != null && state.streamingCode != null;
|
||||
|
||||
useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (!showStreaming) return;
|
||||
const id = setInterval(() => {
|
||||
setActiveTechIndex((i) => (techTags.length ? (i + 1) % techTags.length : 0));
|
||||
}, 900);
|
||||
return () => clearInterval(id);
|
||||
}, [showStreaming, techTags.length]);
|
||||
}, [showStreaming, techTags.length]);
|
||||
|
||||
return (
|
||||
return (
|
||||
<div className={`flex flex-col glass-panel z-20 transition-all duration-500 overflow-hidden relative ${state.chatDocked === 'bottom' ? 'h-96 w-[calc(100%-24px)] fixed bottom-3 left-3 rounded-2xl shadow-2xl border-t border-white/10' : 'w-96 m-3 rounded-2xl shadow-2xl'}`}>
|
||||
|
||||
{/* STREAMING EDITOR OVERLAY (SLIDES IN) */}
|
||||
@@ -3201,7 +3186,7 @@ Brief plan starting with '[PLAN]'.`;
|
||||
{showSkillsSelector && <SkillsSelectorModal onClose={() => setShowSkillsSelector(false)} onSelect={(cmd) => setInput(prev => prev + ' ' + cmd)} />}
|
||||
{state.personaCreateModalOpen && <PersonaCreateModal state={state} dispatch={dispatch} />}
|
||||
</div>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
const LogMessage = ({ message, type }: { message: string, type: 'user' | 'system' | 'error' }) => {
|
||||
|
||||
@@ -83,26 +83,6 @@ Example Output:
|
||||
</artifact_payload>
|
||||
`;
|
||||
|
||||
export const BACKEND_GENERATOR_PROMPT = `
|
||||
You are an expert Backend Engineer. Your task is to build a robust Node.js/Express backend for the provided frontend code.
|
||||
|
||||
### ANALYSIS PHASE
|
||||
1. **Endpoint Extraction**: Scan the frontend code for all 'fetch', 'axios', or 'XMLHttpRequest' calls. Identify the methods (GET, POST, etc.) and paths (e.g., /api/users).
|
||||
2. **Data Modeling**: Infer the data structure expected by these endpoints based on how the frontend uses the response (e.g., if it maps over 'response.data.users', create a 'users' array).
|
||||
|
||||
### IMPLEMENTATION REQUIREMENTS
|
||||
1. **Single File**: Output a single 'server.js' file.
|
||||
2. **Express.js**: Use Express as the framework.
|
||||
3. **Mock Data**: Create realistic mock data to populate the endpoints.
|
||||
4. **CORS**: Enable CORS to allow the frontend to connect (if running separately) or serve the static frontend file if requested.
|
||||
5. **Static Serving**: Include code to serve 'index.html' from the current directory.
|
||||
|
||||
### OUTPUT FORMAT
|
||||
- Return ONLY the raw JavaScript code for 'server.js'.
|
||||
- Start with 'const express = require("express");'.
|
||||
- Do NOT wrap in markdown blocks.
|
||||
`;
|
||||
|
||||
|
||||
|
||||
export const MockComputerDriver: GooseUltraComputerDriver = {
|
||||
|
||||
Reference in New Issue
Block a user