Skip to content

Commit 844cd6e

Browse files
Merge upstream PR benjitaylor#114: Polish drawing UX
Cherry-pick of benjitaylor#114 by stevysmith (includes draw-wip branch). Adds freehand drawing mode, screenshot capture, drawing context, webhook integration. Polish: loosens circle detection, adds pencil cursor, fixes Escape key behavior. # Conflicts: # package/src/components/page-toolbar-css/index.tsx # package/src/components/page-toolbar-css/styles.module.scss # package/src/types.ts
2 parents 268bbc3 + 79dd00a commit 844cd6e

15 files changed

Lines changed: 3414 additions & 474 deletions

File tree

mcp/src/server/http.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
CallToolRequestSchema,
1111
ListToolsRequestSchema,
1212
} from "@modelcontextprotocol/sdk/types.js";
13-
import { TOOLS, handleTool, error as toolError } from "./mcp.js";
13+
import { TOOLS, handleTool, error as toolError, saveScreenshotToDisk } from "./mcp.js";
1414
import {
1515
createSession,
1616
getSession,
@@ -367,6 +367,17 @@ const addAnnotationHandler: RouteHandler = async (req, res, params) => {
367367
return sendError(res, 400, "comment, element, and elementPath are required");
368368
}
369369

370+
// Save screenshot to disk and replace base64 with file path before storing.
371+
// This way the SSE event and stored record both have the path, never the blob.
372+
if (body.drawingContext?.screenshot) {
373+
const fileId = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
374+
const screenshotPath = saveScreenshotToDisk(fileId, body.drawingContext.screenshot);
375+
if (screenshotPath) {
376+
(body.drawingContext as any).screenshotPath = screenshotPath;
377+
}
378+
delete (body.drawingContext as any).screenshot;
379+
}
380+
370381
const annotation = addAnnotation(params.id, body);
371382

372383
if (!annotation) {

0 commit comments

Comments
 (0)