MCPcopy
hub / github.com/garrytan/gstack / handleBoardFeedback

Function handleBoardFeedback

design/src/daemon.ts:375–422  ·  view source on GitHub ↗
(board: Board, req: Request)

Source from the content-addressed store, hash-verified

373}
374
375async function handleBoardFeedback(board: Board, req: Request): Promise<Response> {
376 let body: any;
377 try {
378 body = await req.json();
379 } catch {
380 return Response.json({ error: "Invalid JSON" }, { status: 400 });
381 }
382 if (!body || typeof body !== "object") {
383 return Response.json({ error: "Expected JSON object" }, { status: 400 });
384 }
385 const isSubmit = body.regenerated === false;
386 const isRegen = body.regenerated === true;
387
388 // Augment with boardId + publishedAt so multi-board agents can disambiguate
389 // which board produced a given feedback.json.
390 const augmented = {
391 ...body,
392 boardId: board.id,
393 publishedAt: new Date(board.publishedAt).toISOString(),
394 };
395
396 const feedbackFile = isSubmit ? "feedback.json" : "feedback-pending.json";
397 const feedbackPath = path.join(board.sourceDir, feedbackFile);
398 try {
399 fs.writeFileSync(feedbackPath, JSON.stringify(augmented, null, 2));
400 } catch (e: any) {
401 dlog(`feedback write failed for ${board.id}: ${e.message}`);
402 return Response.json(
403 { error: `Cannot write ${feedbackFile}: ${e.message}` },
404 { status: 500 },
405 );
406 }
407
408 board.lastTouched = Date.now();
409 markMeaningfulActivity();
410
411 if (isSubmit) {
412 board.state = "done";
413 dlog(`board ${board.id} submitted → ${feedbackPath}`);
414 return Response.json({ received: true, action: "submitted" });
415 }
416 if (isRegen) {
417 board.state = "regenerating";
418 dlog(`board ${board.id} regenerate → ${feedbackPath}`);
419 return Response.json({ received: true, action: "regenerate" });
420 }
421 return Response.json({ received: true, action: "unknown" });
422}
423
424async function handleBoardReload(board: Board, req: Request): Promise<Response> {
425 let body: any;

Callers 1

fetchHandlerFunction · 0.85

Calls 2

dlogFunction · 0.85
markMeaningfulActivityFunction · 0.85

Tested by

no test coverage detected