everydaycats commited on
Commit
b192598
·
verified ·
1 Parent(s): 154b82e

Update stateManager.js

Browse files
Files changed (1) hide show
  1. stateManager.js +7 -4
stateManager.js CHANGED
@@ -25,8 +25,10 @@ export const StateManager = {
25
 
26
  let command = null;
27
 
28
- // 1. Check for Code Execution
29
- const codeMatch = rawResponse.match(/```lua([\s\S]*?)```/);
 
 
30
  if (codeMatch) {
31
  command = { type: "EXECUTE", payload: codeMatch[1].trim() };
32
  }
@@ -49,12 +51,13 @@ export const StateManager = {
49
  project.commandQueue.push(command);
50
  console.log(`[${projectId}] Queued Action: ${command.type}`);
51
  } else {
52
- console.log(`[${projectId}] AI Replied (No Action):`, rawResponse.substring(0, 50) + "...");
 
53
  }
54
 
55
  activeProjects.set(projectId, project);
56
  },
57
-
58
  popCommand: async (projectId) => {
59
  const project = activeProjects.get(projectId);
60
  if (!project || !project.commandQueue.length) return null;
 
25
 
26
  let command = null;
27
 
28
+ // 1. Check for Code Execution (Improved Regex)
29
+ // Matches ```lua, ```luau, or just ``` followed by code
30
+ const codeMatch = rawResponse.match(/```(?:lua|luau)?([\s\S]*?)```/i);
31
+
32
  if (codeMatch) {
33
  command = { type: "EXECUTE", payload: codeMatch[1].trim() };
34
  }
 
51
  project.commandQueue.push(command);
52
  console.log(`[${projectId}] Queued Action: ${command.type}`);
53
  } else {
54
+ // Log exactly what the AI said so we can debug why it didn't match
55
+ console.log(`[${projectId}] AI Replied (No Action/Chatter):`, rawResponse);
56
  }
57
 
58
  activeProjects.set(projectId, project);
59
  },
60
+
61
  popCommand: async (projectId) => {
62
  const project = activeProjects.get(projectId);
63
  if (!project || !project.commandQueue.length) return null;