everydaytok commited on
Commit
a94f360
·
verified ·
1 Parent(s): 6a206b4

Update stateManager.js

Browse files
Files changed (1) hide show
  1. stateManager.js +13 -3
stateManager.js CHANGED
@@ -4,9 +4,10 @@ let supabase = null;
4
  const activeProjects = new Map();
5
  const initializationLocks = new Set();
6
 
7
- const streamBuffers = new Map(); // Destructive (For Plugin)
8
- const statusBuffers = new Map(); // Granular Status (For Frontend)
9
- const snapshotBuffers = new Map(); // Non-Destructive (For Frontend Visualization)
 
10
 
11
  export const initDB = () => {
12
  if (!process.env.SUPABASE_URL || !process.env.SUPABASE_SERVICE_ROLE_KEY) {
@@ -113,6 +114,9 @@ export const StateManager = {
113
  return statusBuffers.get(projectId) || "Working...";
114
  },
115
 
 
 
 
116
  appendStream: (projectId, chunk) => {
117
  const currentDestructive = streamBuffers.get(projectId) || "";
118
  streamBuffers.set(projectId, currentDestructive + chunk);
@@ -121,6 +125,12 @@ export const StateManager = {
121
  snapshotBuffers.set(projectId, currentSnapshot + chunk);
122
  },
123
 
 
 
 
 
 
 
124
  popStream: (projectId) => {
125
  const content = streamBuffers.get(projectId) || "";
126
  streamBuffers.set(projectId, "");
 
4
  const activeProjects = new Map();
5
  const initializationLocks = new Set();
6
 
7
+ // --- REALTIME BUFFERS ---
8
+ const streamBuffers = new Map(); // Destructive (For Plugin - Code Execution)
9
+ const statusBuffers = new Map(); // Granular Status (For Frontend - "Worker is typing...")
10
+ const snapshotBuffers = new Map(); // Non-Destructive (For Frontend - Ghost Text)
11
 
12
  export const initDB = () => {
13
  if (!process.env.SUPABASE_URL || !process.env.SUPABASE_SERVICE_ROLE_KEY) {
 
114
  return statusBuffers.get(projectId) || "Working...";
115
  },
116
 
117
+ // --- STREAMING HELPERS ---
118
+
119
+ // Use this for WORKER (Goes to Plugin AND Frontend)
120
  appendStream: (projectId, chunk) => {
121
  const currentDestructive = streamBuffers.get(projectId) || "";
122
  streamBuffers.set(projectId, currentDestructive + chunk);
 
125
  snapshotBuffers.set(projectId, currentSnapshot + chunk);
126
  },
127
 
128
+ // Use this for PM (Goes to Frontend ONLY - User sees thinking, Plugin ignores)
129
+ appendSnapshotOnly: (projectId, chunk) => {
130
+ const currentSnapshot = snapshotBuffers.get(projectId) || "";
131
+ snapshotBuffers.set(projectId, currentSnapshot + chunk);
132
+ },
133
+
134
  popStream: (projectId) => {
135
  const content = streamBuffers.get(projectId) || "";
136
  streamBuffers.set(projectId, "");