@@ -114,7 +114,8 @@ async function spawnCursor(command, options = {}, ws) {
114114 // Send system info to frontend
115115 ws . send ( {
116116 type : 'cursor-system' ,
117- data : response
117+ data : response ,
118+ sessionId : capturedSessionId || sessionId || null
118119 } ) ;
119120 }
120121 break ;
@@ -123,7 +124,8 @@ async function spawnCursor(command, options = {}, ws) {
123124 // Forward user message
124125 ws . send ( {
125126 type : 'cursor-user' ,
126- data : response
127+ data : response ,
128+ sessionId : capturedSessionId || sessionId || null
127129 } ) ;
128130 break ;
129131
@@ -142,7 +144,8 @@ async function spawnCursor(command, options = {}, ws) {
142144 type : 'text_delta' ,
143145 text : textContent
144146 }
145- }
147+ } ,
148+ sessionId : capturedSessionId || sessionId || null
146149 } ) ;
147150 }
148151 break ;
@@ -157,7 +160,8 @@ async function spawnCursor(command, options = {}, ws) {
157160 type : 'claude-response' ,
158161 data : {
159162 type : 'content_block_stop'
160- }
163+ } ,
164+ sessionId : capturedSessionId || sessionId || null
161165 } ) ;
162166 }
163167
@@ -174,15 +178,17 @@ async function spawnCursor(command, options = {}, ws) {
174178 // Forward any other message types
175179 ws . send ( {
176180 type : 'cursor-response' ,
177- data : response
181+ data : response ,
182+ sessionId : capturedSessionId || sessionId || null
178183 } ) ;
179184 }
180185 } catch ( parseError ) {
181186 console . log ( '📄 Non-JSON response:' , line ) ;
182187 // If not JSON, send as raw text
183188 ws . send ( {
184189 type : 'cursor-output' ,
185- data : line
190+ data : line ,
191+ sessionId : capturedSessionId || sessionId || null
186192 } ) ;
187193 }
188194 }
@@ -193,7 +199,8 @@ async function spawnCursor(command, options = {}, ws) {
193199 console . error ( 'Cursor CLI stderr:' , data . toString ( ) ) ;
194200 ws . send ( {
195201 type : 'cursor-error' ,
196- error : data . toString ( )
202+ error : data . toString ( ) ,
203+ sessionId : capturedSessionId || sessionId || null
197204 } ) ;
198205 } ) ;
199206
@@ -229,7 +236,8 @@ async function spawnCursor(command, options = {}, ws) {
229236
230237 ws . send ( {
231238 type : 'cursor-error' ,
232- error : error . message
239+ error : error . message ,
240+ sessionId : capturedSessionId || sessionId || null
233241 } ) ;
234242
235243 reject ( error ) ;
@@ -264,4 +272,4 @@ export {
264272 abortCursorSession ,
265273 isCursorSessionActive ,
266274 getActiveCursorSessions
267- } ;
275+ } ;
0 commit comments