From c036d20664579fd26bd31ace211b80da70bf6692 Mon Sep 17 00:00:00 2001 From: Rishi Sharma Date: Sat, 21 Nov 2026 16:58:48 -0500 Subject: [PATCH 1/2] Cover Shift-panning after a click inside a live page --- .../skills/verify-screens/features/camera-focus.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.agents/skills/verify-screens/features/camera-focus.md b/.agents/skills/verify-screens/features/camera-focus.md index c346569..9271c63 100644 --- a/.agents/skills/verify-screens/features/camera-focus.md +++ b/.agents/skills/verify-screens/features/camera-focus.md @@ -5,6 +5,7 @@ A person pans with Hand, Shift-drag, the middle button or the wheel. They zoom w ## Sub-features - `cam-pan`: Hand, Shift-drag and the wheel pan by the screen delta, with no revision. +- `shift-pan-page`: Shift-drag pans at once after a click inside a selected live page, which takes keyboard focus. Releasing Shift gives the page the pointer again. - `minimap`: the map is off by default. Turn it on to see the canvas and navigate by click or drag. The choice survives a reload. - `cam-zoom`: zoom out and in around the centre; Cmd+0 goes to 100%; Fit all frames everything and turns auto-fit back on. - `zoom-preview`: background boards use a preview at their current size during zoom. The selected board stays live. @@ -48,6 +49,17 @@ drag @A.title by 40,0 expect doc.@A.x=40 doc.rev=+1 storage.rev=doc.rev ``` +```screens id=shift-pan-page +add_object title=A files=fixture:plain x=0 y=0 width=800 height=600 as=@A +zoom 100 +click @A +inside @A click body +expect view.interacting=@A frames.@A.input=page +mark +drag @A by 60,0 --shift +expect view.camera.x=+60 doc.@A.x=0 doc.rev=+0 view.shiftPanning=false frames.@A.input=page +``` + ```screens id=cam-zoom add_object title=A files=fixture:plain x=0 y=0 height=300 as=@A zoom 100 From 5e6e1bab58c100f6ca904578fdd541d4b372cdf3 Mon Sep 17 00:00:00 2001 From: Rishi Sharma Date: Sat, 21 Nov 2026 16:58:48 -0500 Subject: [PATCH 2/2] Pan with Shift while a live page has keyboard focus A click inside a selected board's live page moves keyboard focus into its frame, so the canvas never saw Shift and Shift-drag interacted with the page instead of panning. The frame bridge now reports Shift down and up, and Shift shields an interacting page as it does a selected one. A focused page keeps Shift for selecting its own pieces. --- packages/canvas/src/engine/controller.ts | 10 ++++++---- packages/canvas/src/shell/runtime.ts | 1 + packages/frames/src/index.ts | 1 + packages/frames/src/inline.ts | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/canvas/src/engine/controller.ts b/packages/canvas/src/engine/controller.ts index 5ae7f1e..deec1f3 100644 --- a/packages/canvas/src/engine/controller.ts +++ b/packages/canvas/src/engine/controller.ts @@ -114,7 +114,7 @@ export type CanvasInput = | { readonly type: "key-down"; readonly key: string; readonly code: string; readonly mod: boolean; readonly shift: boolean; readonly editable: boolean; readonly control: boolean } | { readonly type: "key-up"; readonly code: string } | { readonly type: "window-blur"; readonly activeFrameItem: ItemId | null } - | { readonly type: "bridge"; readonly itemId: ItemId; readonly msg: { readonly kind: "pointer"; readonly x: number; readonly y: number } | { readonly kind: "zoom"; readonly x: number; readonly y: number; readonly dy: number; readonly pinch: boolean } | { readonly kind: "pan"; readonly dx: number; readonly dy: number } | { readonly kind: "escape" } } + | { readonly type: "bridge"; readonly itemId: ItemId; readonly msg: { readonly kind: "pointer"; readonly x: number; readonly y: number } | { readonly kind: "zoom"; readonly x: number; readonly y: number; readonly dy: number; readonly pinch: boolean } | { readonly kind: "pan"; readonly dx: number; readonly dy: number } | { readonly kind: "escape" } | { readonly kind: "shift"; readonly down: boolean } } | { readonly type: "tick"; readonly now: number } | { readonly type: "camera-settled" } | { readonly type: "resize"; readonly viewport: Size } @@ -298,6 +298,8 @@ function stepInner(s: ViewState, input: CanvasInput, doc: BaseDoc, env: Env, fx: if (!it) return s; const m = input.msg; if (m.kind === "pointer") return s.tool === "move" ? { ...s, interacting: input.itemId } : s; + // Shift pressed while a live page has keyboard focus. A focused page keeps Shift for selecting its own pieces. + if (m.kind === "shift") return presenting(s, doc) || (s.focus.mode === "focused" && s.focus.itemId === input.itemId) ? s : { ...s, shiftPanning: m.down }; if (m.kind === "escape") { fx.push({ type: "blur-active" }); const n = { ...s, interacting: null }; @@ -1122,8 +1124,8 @@ export interface FramePresentation { readonly hiddenByFocus: boolean; readonly input: "shield" | "page"; readonly showActions: boolean; } /** - * The page takes pointer input only when it is a ready live snapshot and it is interacting, or the Move tool is - * active without Shift and it is the sole selection or the focused item. Everything else gets the shield. + * The page takes pointer input only when it is a ready live snapshot, Shift is not held, and it is interacting or the + * Move tool is active and it is the sole selection or the focused item. Everything else gets the shield. */ export function presentFrame(item: { readonly id: ItemId; readonly kind: string; readonly width: number; readonly removing: boolean }, s: ViewState, ready: boolean): FramePresentation { const ids = selectedIds(s); @@ -1132,7 +1134,7 @@ export function presentFrame(item: { readonly id: ItemId; readonly kind: string; const focused = focusedId === item.id; // Only the scroll view (every canvas is in it) lets a page take input: in the grid a press reorders or opens, and Present steps. const page = item.kind === "html-snapshot" && ready && !item.removing && s.gesture === null && s.pages.view === "scroll" && - (s.interacting === item.id || (s.tool === "move" && !s.shiftPanning && ((selected && ids.length === 1) || focused))); + !s.shiftPanning && (s.interacting === item.id || (s.tool === "move" && ((selected && ids.length === 1) || focused))); return { selected: selected && ids.length === 1, multiSelected: selected && ids.length > 1, interacting: s.interacting === item.id, focused, hiddenByFocus: focusedId !== null && !focused, input: page ? "page" : "shield", diff --git a/packages/canvas/src/shell/runtime.ts b/packages/canvas/src/shell/runtime.ts index fc51a35..a8392f6 100644 --- a/packages/canvas/src/shell/runtime.ts +++ b/packages/canvas/src/shell/runtime.ts @@ -454,6 +454,7 @@ export class CanvasRuntime { else if (d.kind === "zoom") this.dispatch({ type: "bridge", itemId: host.itemId, msg: { kind: "zoom", x: Number(d.x), y: Number(d.y), dy: Number(d.dy), pinch: d.pinch === true } }); else if (d.kind === "pan") this.dispatch({ type: "bridge", itemId: host.itemId, msg: { kind: "pan", dx: Number(d.dx) || 0, dy: Number(d.dy) || 0 } }); else if (d.kind === "escape") this.dispatch({ type: "bridge", itemId: host.itemId, msg: { kind: "escape" } }); + else if (d.kind === "shift") this.dispatch({ type: "bridge", itemId: host.itemId, msg: { kind: "shift", down: d.down === true } }); }; } diff --git a/packages/frames/src/index.ts b/packages/frames/src/index.ts index d7dba52..7ad302c 100644 --- a/packages/frames/src/index.ts +++ b/packages/frames/src/index.ts @@ -44,6 +44,7 @@ else if(d.kind==="text")parent.postMessage({kind:"text",gen,pid:pid(d.pid),text: else if(d.kind==="move")parent.postMessage({kind:"move",gen,items:Array.isArray(d.items)?d.items.slice(0,50).map((m)=>m&&typeof m==="object"?{pid:pid(m.pid),rel:m.rel===true,x:opt(m.x),y:opt(m.y),w:opt(m.w),h:opt(m.h)}:null).filter((m)=>m&&m.pid):[]},to); else if(d.kind==="zoom")parent.postMessage({kind:"zoom",gen,x:num(d.x),y:num(d.y),dy:num(d.dy),pinch:d.pinch===true},to); else if(d.kind==="pan")parent.postMessage({kind:"pan",gen,dx:num(d.dx),dy:num(d.dy)},to); +else if(d.kind==="shift")parent.postMessage({kind:"shift",gen,down:d.down===true},to); else if(d.kind==="escape")parent.postMessage({kind:"escape",gen},to);});})();`; } diff --git a/packages/frames/src/inline.ts b/packages/frames/src/inline.ts index 0249158..36394dc 100644 --- a/packages/frames/src/inline.ts +++ b/packages/frames/src/inline.ts @@ -172,6 +172,8 @@ const k=e.deltaMode===1?16:e.deltaMode===2?innerHeight:1,dx=e.deltaX*k,dy=e.delt addEventListener("keydown",(e)=>{if(ed){e.stopPropagation();if(e.key==="Escape"){e.preventDefault();finish(false)}else if(e.key==="Enter"&&!e.shiftKey){e.preventDefault();finish(true)}return} // A form control or the page's own editable text keeps its keys: arrows move its caret and undo is its own. const t=e.target;if(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))){if(e.key==="Escape")p({kind:"escape"});return} +// Shift held over the canvas pans it. The canvas cannot see keys pressed in here, so the page reports Shift. +if(e.key==="Shift"&&!e.repeat){p({kind:"shift",down:true});return} // Arrow keys nudge the selection, ten pixels with Shift. A run of presses is reported once it pauses, as one move. const dir={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key]; if(dir&&sel.length&&!e.metaKey&&!e.ctrlKey&&!e.altKey){e.preventDefault();e.stopPropagation();const k=e.shiftKey?10:1; @@ -179,4 +181,5 @@ if(!nudged)nudged={list:starts(),x:0,y:0};nudged.x+=dir[0]*k;nudged.y+=dir[1]*k; clearTimeout(nudgeTimer);nudgeTimer=setTimeout(()=>{const n=nudged;nudged=null;if(n&&n.list.length)report(n.list)},350);return} // The person's undo and redo belong to the canvas, which cannot see keys pressed in here. if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="z"){e.preventDefault();p({kind:"history",redo:e.shiftKey});return} -if(e.key==="Escape")p({kind:"escape"})},true);})();`; +if(e.key==="Escape")p({kind:"escape"})},true); +addEventListener("keyup",(e)=>{if(e.key==="Shift")p({kind:"shift",down:false})},true);})();`;