فهرست منبع

fix: preserve original event type, use source field for wrapper

Jesse Vincent 7 ماه پیش
والد
کامیت
91fbffc994
3فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 1 1
      lib/brainstorm-server/index.js
  2. 2 2
      skills/brainstorming/visual-companion.md
  3. 1 1
      tests/brainstorm-server/server.test.js

+ 1 - 1
lib/brainstorm-server/index.js

@@ -47,7 +47,7 @@ wss.on('connection', (ws) => {
   ws.on('message', (data) => {
   ws.on('message', (data) => {
     // User interaction event - write to stdout for Claude
     // User interaction event - write to stdout for Claude
     const event = JSON.parse(data.toString());
     const event = JSON.parse(data.toString());
-    console.log(JSON.stringify({ ...event, type: 'user-event' }));
+    console.log(JSON.stringify({ source: 'user-event', ...event }));
   });
   });
 });
 });
 
 

+ 2 - 2
skills/brainstorming/visual-companion.md

@@ -19,8 +19,8 @@ Write HTML to `/tmp/brainstorm/screen.html`. The server watches this file and au
 Check the background task output for JSON events:
 Check the background task output for JSON events:
 
 
 ```json
 ```json
-{"text":"Option A","choice":"optionA","timestamp":1234567890,"type":"user-event"}
-{"data":{"notes":"My feedback"},"timestamp":1234567891,"type":"user-event"}
+{"source":"user-event","type":"click","text":"Option A","choice":"optionA","timestamp":1234567890}
+{"source":"user-event","type":"submit","data":{"notes":"My feedback"},"timestamp":1234567891}
 ```
 ```
 
 
 Event types:
 Event types:

+ 1 - 1
tests/brainstorm-server/server.test.js

@@ -68,7 +68,7 @@ async function runTests() {
     ws.send(JSON.stringify({ type: 'click', text: 'Test Button' }));
     ws.send(JSON.stringify({ type: 'click', text: 'Test Button' }));
     await sleep(300);
     await sleep(300);
 
 
-    assert(stdout.includes('user-event'), 'Should relay user events');
+    assert(stdout.includes('"source":"user-event"'), 'Should relay user events with source field');
     assert(stdout.includes('Test Button'), 'Should include event data');
     assert(stdout.includes('Test Button'), 'Should include event data');
     ws.close();
     ws.close();
     console.log('  PASS');
     console.log('  PASS');