Skip to content

feat(editor,editormcp): add viewport sketch layer, reading card, and scene_edit hold gate - #1214

Merged
houko merged 5 commits into
mainfrom
feat/editor-viewport-sketch-agent-1025
Nov 26, 2026
Merged

houko merged 5 commits into
mainfrom
feat/editor-viewport-sketch-agent-1025

Conversation

@houko

@houko houko commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #1025

Summary

Implements the session-only 2D viewport sketch layer for agent collaboration (docs/design/editor/Sketch.dc.html, styled strictly with docs/design/editor/Spec.dc.html tokens):

  • Session-only 2D viewport sketch layer (packages/game/editor/sketch.go, sketch_png.go, sketch_ui.go):
    • Four sketch tools strictly in scene coordinates (CanvasToWorld / WorldToCanvas): Pen (polyline), Arrow (start → end), Box (rect), and Text (point + label).
    • Sequential numbered badges (1, 2, 3, …) and optional text labels (e.g. "3 spikes", "platform, back and forth", "locked until the lever").
    • Stored purely in session state (Editor.sketch synced per sceneTab) with an isolated mark undo stack — never modifies SceneDoc, never written into *.scene.yaml, never pollutes scene undo History.
    • Floating sketch bar showing the four tools, Undo last mark, Hide/Show marks, "N marks not saved", Clear, and Done; Esc exits sketch mode while keeping marks until sent, cleared, or kept; Scene Tree SKETCH LAYER row; live status bar scene coordinates and active sketch tool.
    • Dedicated ScopeSketch keyboard scope (D toggles Sketch from ScopeViewport2D; P/A/B/T switch tools; I adds a mark at the cursor; H toggles visibility; ⌘Z undoes last mark; plus View > Sketch menu and registered shortcuts for every sketch action) — keeping the 2D editor-toolbar compact with zero added buttons.
  • Sending a sketch to the agent (SendSketch / OnSendSketch):
    • Composer attaches a "Sketch · N marks" context chip (toggling a "Sent with this request" scene-coordinate preview).
    • Request carries structured marks (number, kind, exact scene-coordinate geometry, label) plus a rendered PNG of the viewport with numbered sketch marks and labels overlaid (RenderSketchViewportPNG).
  • Agent reading card & scene_edit confirmation hold gate (packages/game/editor/editormcp/sketch.go):
    • Adds sketch_read and sketch_reading MCP tools (updated tool list conformance tests in server_test.go, proxy_test.go, example_test.go).
    • Arms a hold gate (SketchHoldActive()) when a sketch is sent; scene_edit and other mutating scene MCP tools (tile_paint, tile_autotile, tile_erase, object_paste_yaml, object_duplicate, object_group, object_move_under, object_set_field) refuse cleanly with a structured *EditError until the user clicks Go ahead (ApproveSketchReading) or replies in words (ReplyToSketchReading).
    • Correct a mark (CorrectSketchMark, or clicking a numbered reading item) reopens sketch mode with that exact mark selected while keeping the hold active.
  • Review overlay & Keep / Revert:
    • Post-edit review card (and TileReview) provides a Sketch overlay toggle laying the faint dotted sketch over the result.
    • Keep clears the sketch layer; Revert keeps the sketch marks ready to send again.
  • Docs, changelog, and design note:
    • Updated docs/en/editor.md, docs/zh/editor.md, docs/en/mcp.md, docs/zh/mcp.md with EN/ZH parity.
    • Added changelog.d/editor-viewport-sketch-agent.md and .agents/notes/implemented/feature/2026-11-26-editor-viewport-sketch-agent.md.

Verification

  • env -u GOROOT go tool nsgo check (default host target & -target ios) on ./editor, ./editor/editormcp, ./editor/editorcmd — all passed.
  • TMPDIR=/tmp env -u GOROOT go tool nsgo test ./editor (sketch zoom accuracy, keyboard path, reading card, hold gate, Correct a mark, review overlay Keep/Revert, plus toolbar compactness, menu bar, locale completeness, file browser tabs, lighting parallax, shortcuts, overlays, tile review, and Spec theme tests — 33/33 passed).
  • TMPDIR=/tmp env -u GOROOT go tool nsgo test ./editor/editormcp (including TestSketchMCPReadReadingHoldGateAndKeepRevert and tool list tests — 39/39 passed).
  • Real native macOS screenshots captured via TMPDIR=/tmp env -u GOROOT go tool nsgo test -target macos -screenshots tmp-sketch-shots -run '^TestSketchMacOSScreenshots$' ./editor/editorcmd (sketch-active.png, sketch-reading.png, sketch-review.png), visually inspected beside Sketch.dc.html and Spec.dc.html, and temp PNGs removed before commit.
  • bun run verify-notes and env -u GOROOT go run ./tools/changelog check — both passed.

@github-actions github-actions Bot added enhancement New feature or request size/XL documentation Improvements or additions to documentation pkg/editor area/agents conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-viewport-sketch-agent-1025 branch from df4e0ae to d0fc00d Compare November 26, 2026 03:20
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-viewport-sketch-agent-1025 branch 3 times, most recently from 2db66f6 to 679ec47 Compare November 26, 2026 11:16
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-viewport-sketch-agent-1025 branch from 679ec47 to 9413d1e Compare November 26, 2026 12:05
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-viewport-sketch-agent-1025 branch from 9413d1e to 7ed11bf Compare November 26, 2026 12:21
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-viewport-sketch-agent-1025 branch from 7ed11bf to f4aeb89 Compare November 26, 2026 12:59
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-viewport-sketch-agent-1025 branch 2 times, most recently from 8bab98b to e6c6a02 Compare November 26, 2026 18:00
@github-actions github-actions Bot removed the conflict Conflicts with the target branch; resolve before merging label Nov 26, 2026
…scene_edit hold gate

Add a session-only 2D viewport sketch layer in scene coordinates (Pen, Arrow, Box, Text) with sequential numbered badges, optional labels, floating sketch bar, Scene Tree row, keyboard scope (ScopeSketch) without adding extra buttons to the compact 2D editor-toolbar, structured + PNG agent request payload, MCP tools (sketch_read, sketch_reading), a scene_edit confirmation hold gate, and post-edit review Sketch overlay with Keep/Revert behavior.

Fixes #1025
…w guards, label spaces, and modal/drag safety
@houko
houko force-pushed the feat/editor-viewport-sketch-agent-1025 branch from e6c6a02 to 833512a Compare November 26, 2026 18:00
@houko
houko merged commit a939d29 into main Nov 26, 2026
47 of 51 checks passed
@houko
houko deleted the feat/editor-viewport-sketch-agent-1025 branch November 26, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents documentation Improvements or additions to documentation enhancement New feature or request pkg/editor size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor: sketch on the viewport for the agent

1 participant