everydaytok commited on
Commit
5fa1c4d
·
verified ·
1 Parent(s): a842e18

Update stateManager.js

Browse files
Files changed (1) hide show
  1. stateManager.js +16 -16
stateManager.js CHANGED
@@ -159,17 +159,26 @@ export const StateManager = {
159
 
160
  if (rawResponse.includes("[ASK_PM:")) return;
161
  if (rawResponse.includes("[ROUTE_TO_PM:")) return;
 
162
  if (rawResponse.includes("[GENERATE_IMAGE:") && !rawResponse.includes("```")) return;
163
 
164
  const codeMatch = rawResponse.match(/```(?:lua|luau)?([\s\S]*?)```/i);
165
- const readScriptMatch = rawResponse.match(/\[READ_SCRIPT:\s*(.*?)\]/);
166
- const readHierarchyMatch = rawResponse.match(/\[READ_HIERARCHY:\s*(.*?)\]/);
167
  const readLogsMatch = rawResponse.includes("[READ_LOGS]");
168
 
169
- if (codeMatch) command = { type: "EXECUTE", payload: codeMatch[1].trim() };
170
- else if (readScriptMatch) command = { type: "READ_SCRIPT", payload: readScriptMatch[1].trim() };
171
- else if (readHierarchyMatch) command = { type: "READ_HIERARCHY", payload: readHierarchyMatch[1].trim() };
172
- else if (readLogsMatch) command = { type: "READ_LOGS", payload: null };
 
 
 
 
 
 
 
 
173
  }
174
 
175
  if (command) {
@@ -205,7 +214,7 @@ export const StateManager = {
205
  stats: data.stats,
206
  description: data.description,
207
  failureCount: data.failureCount,
208
- last_edited: now // Update JSON timestamp
209
  }
210
  };
211
 
@@ -217,20 +226,11 @@ export const StateManager = {
217
  const mergedInfo = { ...currentDb.info, ...payload.info };
218
  delete mergedInfo.commandQueue;
219
 
220
- // 1. Update info JSON (including status and last_edited)
221
  const { error: infoError } = await supabase.from('projects')
222
  .update({ info: mergedInfo })
223
  .eq('id', projectId);
224
 
225
  if (infoError) console.error("[DB ERROR] Update Project Info failed:", infoError.message);
226
-
227
- // 2. Try updating root column for sorting
228
- /* try {
229
- await supabase.from('projects').update({ updated_at: now }).eq('id', projectId);
230
- } catch (e) {
231
- // Ignore if column doesn't exist
232
- }
233
- */
234
  }
235
  },
236
 
 
159
 
160
  if (rawResponse.includes("[ASK_PM:")) return;
161
  if (rawResponse.includes("[ROUTE_TO_PM:")) return;
162
+ // Only skip image generation if there's no code block, otherwise logic flow handles it
163
  if (rawResponse.includes("[GENERATE_IMAGE:") && !rawResponse.includes("```")) return;
164
 
165
  const codeMatch = rawResponse.match(/```(?:lua|luau)?([\s\S]*?)```/i);
166
+ const readScriptMatch = rawResponse.match(/\[READ_SCRIPT:\s*(.*?)\]/i);
167
+ const readHierarchyMatch = rawResponse.match(/\[READ_HIERARCHY(?::\s*(.*?))?\]/i);
168
  const readLogsMatch = rawResponse.includes("[READ_LOGS]");
169
 
170
+ if (codeMatch) {
171
+ command = { type: "EXECUTE", payload: codeMatch[1].trim() };
172
+ }
173
+ else if (readScriptMatch) {
174
+ command = { type: "READ_SCRIPT", payload: readScriptMatch[1].trim() };
175
+ }
176
+ else if (readHierarchyMatch) {
177
+ command = { type: "READ_HIERARCHY", payload: readHierarchyMatch[1] ? readHierarchyMatch[1].trim() : "All" };
178
+ }
179
+ else if (readLogsMatch) {
180
+ command = { type: "READ_LOGS", payload: null };
181
+ }
182
  }
183
 
184
  if (command) {
 
214
  stats: data.stats,
215
  description: data.description,
216
  failureCount: data.failureCount,
217
+ last_edited: now
218
  }
219
  };
220
 
 
226
  const mergedInfo = { ...currentDb.info, ...payload.info };
227
  delete mergedInfo.commandQueue;
228
 
 
229
  const { error: infoError } = await supabase.from('projects')
230
  .update({ info: mergedInfo })
231
  .eq('id', projectId);
232
 
233
  if (infoError) console.error("[DB ERROR] Update Project Info failed:", infoError.message);
 
 
 
 
 
 
 
 
234
  }
235
  },
236