#7439: fix(canvas): auto-present on snapshot if canvas not shown
agents
Cluster:
Workspace Path Fixes
## 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
#4222: fix: canvas root should respect agents.defaults.workspace
by sanool · 2026-01-29
72.4%
#2084: Add Slack canvas read/create/update support
by alfongj-com · 2026-01-26
72.3%
#13412: fix(sessions): refresh allowAgents permissions after gateway restart
by arun-dev-des · 2026-02-10
68.2%
#21667: fix(canvas): add CSP and security headers to HTML responses
by AI-Reviewer-QS · 2026-02-20
67.5%
#19548: fix(android): show scaffold instead of raw JSON on canvas auth errors
by gregmousseau · 2026-02-17
67.2%
#2544: fix(security): XSS vulnerability in Canvas Host + Windows CI stability
by Kiwitwitter · 2026-01-27
66.6%
#7852: fix(gateway): use port from Host header for canvasHostUrl (reverse ...
by tonimelisma · 2026-02-03
66.0%
#11740: fix(gateway): remove IP-based canvas auth fallback
by coygeek · 2026-02-08
65.5%
#15896: fix(memory-lancedb): capture even with injected recall context
by aelaguiz · 2026-02-14
64.7%
#2958: fix(media): wire tools.media.image.maxBytes config to image processin…
by shamsulalam1114 · 2026-01-27
64.6%