← Back to PRs

#7439: fix(canvas): auto-present on snapshot if canvas not shown

by aidencullo open 2026-02-02 20:42 View on GitHub →
agents
## Problem Canvas snapshot was failing with 'Canvas not presented' error when trying to capture a snapshot before calling present. ## Solution When snapshot is called before present, the tool now automatically presents the canvas with a default target ('clawd-canvas') and retries the snapshot. ## Changes - Added auto-present logic to snapshot action that detects 'canvas not presented' error - Auto-presents with default target and retries the snapshot - Respects delayMs parameter to allow canvas initialization time after auto-presenting - Allows snapshot to work standalone without requiring explicit present call first ## Testing Tested locally - snapshot now works without requiring a prior present call. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the `canvas` agent tool’s `snapshot` action to handle the common failure case where a snapshot is requested before the canvas has been presented. On a detected “canvas not presented” error, it automatically calls `canvas.present` (defaulting the target to `clawd-canvas` when none is supplied) and retries the snapshot, optionally waiting `delayMs` after the implicit present. Overall, this makes `snapshot` usable as a standalone action without requiring an explicit `present` call first, while keeping existing gateway invocation patterns intact. <h3>Confidence Score: 4/5</h3> - This PR is reasonably safe to merge; the change is localized and adds a sensible retry path. - The new behavior is confined to the `snapshot` action and only triggers on a specific error message, with otherwise unchanged code paths. Main risk is semantic: `delayMs` is now interpreted as a post-auto-present delay rather than a general snapshot delay, which could surprise callers relying on it to avoid initialization races. - src/agents/tools/canvas-tool.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs