@skillre/dsh-plugin-sticky-wall 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -17,9 +17,9 @@ Non-goals: task management (no scheduling, assignment or reminders), collaborati
17
17
  - **Sidebar entry** — a "Notes" glyph in `sidebar.panellist`; clicking it swaps the centre column to the wall.
18
18
  - **Free canvas** — notes are cards on a canvas, not list rows. Position, rotation and a three-step width (small/medium/large) are note data owned by the Host, so the same wall opens with the same arrangement in another window.
19
19
  - **Drag to place** — press anywhere on a card and drag; the drop lands on the new position immediately and then writes it to the Host, so the card never snaps back first. A drag does **not** bump `updatedAt`, so tidying your desk never reshuffles a "by updated" sort.
20
- - **A wall with a middle** — "Tidy" packs every note into a **phyllotaxis ring centred on the world origin**, leaving a clear **rectangle** at the middle for the greeting and the quick-capture field; the camera opens with the whole wall framed and centred. The reserve is measured against each card's **edge** and converted from screen space at the current zoom, so zooming out widens it and no card can cover the field at any zoom.
21
- - **The centre is the entry point** — the middle of the wall is an always-available capture field: type a line, press Enter, and it becomes a note without opening the form. The new note lands in the **nearest free gap** rather than being thrown off screen.
22
- - **The arrival is visible** — a new card pops in and holds a ring for about 0.9s; if the gap is outside the current viewport the camera **glides and zooms out just enough** to bring it into view, so a capture never leaves you guessing whether it worked.
20
+ - **A wall with a middle** — "Tidy" packs every note into a **compact composition hugging a clear rectangle** at the world origin, which is kept free for the greeting and the quick-capture field; the camera opens with the whole wall framed and centred. The packer follows the rectangle's own **contour** rather than a circle, so every card is only half its own size away from the middle: the same fourteen notes occupy 1261x705 instead of 1645x1794, and frame at **84% instead of 36%**. Each candidate slot is scored by the zoom the whole wall would need, so the result is a wide, low cluster rather than a disc that leaves the window's sides empty. The reserve is measured against each card's **edge**. Tidy keeps it constant in world space; a **single new note** instead follows where the field really is in world space, so capturing after panning or zooming still lands beside the field rather than behind it.
21
+ - **The centre is the entry point** — the middle of the wall is an always-available capture field: type a line, press Enter, and it becomes a note without opening the form. The new note lands in the **nearest free gap to the field** rather than being thrown off screen — or hidden behind it.
22
+ - **The arrival is visible** — a new card pops in and holds a ring for about 0.9s; if the gap is not on screen the camera brings it to the free space **beside the capture field** (whichever of above/below/left/right needs the least movement), zooming out only when nothing fits, so a capture never leaves you guessing whether it worked. It deliberately does **not** centre the card, because the centre of the viewport is where the field is drawn.
23
23
  - **The reserve is a magnetic edge** — dragging a card onto the capture field pushes it to the nearest clear spot instead of letting it cover the input.
24
24
  - **One-click tidy** — "Tidy" repacks deterministically and collision-checks every card against the ones already placed, so the same wall always yields the same arrangement and cards never overlap.
25
25
  - **Three views** — canvas (default, free placement), grid (responsive masonry for reading long notes) and list (one line per note for finding one by title).
@@ -135,7 +135,7 @@ The install path was verified end to end: derive the spec from the live index, i
135
135
  - Card width has only **three presets** (small/medium/large); there is no arbitrary resize. A drag keeps the card's existing tilt.
136
136
  - Tidy is O(n) spiral placement plus a spatial-grid collision check; the wall holds at most 400 notes, and a wall larger than the viewport needs panning or zooming out.
137
137
  - The canvas is a flat plane: no grouping, layers, connectors or snap alignment, and no rotation gesture beyond the stored tilt.
138
- - Auto-framing has a legibility floor (50%): a large wall is centred rather than crammed entirely into view, so panning is expected. The middle is reserved space — tidy never places a card under the greeting or the capture field.
138
+ - Auto-framing has a legibility floor (42%): a large wall is centred rather than crammed entirely into view, so panning is expected. The middle is reserved space — tidy never places a card under the greeting or the capture field, and a capture on a panned or zoomed wall avoids wherever the field currently sits.
139
139
  - Placement is owned by the Host, but two windows open on the same wall each render their own snapshot and do not live-push the other's drags.
140
140
  - Archived notes do not occupy a `maxNotes` slot, but restoring them does; a restore at the cap is rejected instead of silently overshooting.
141
141
  - "Clear archive" is a permanent, irreversible delete.
package/README.md CHANGED
@@ -17,9 +17,9 @@
17
17
  - **左侧栏入口**:`sidebar.panellist` 中的「便签墙」图标,点击把中央区域切换到便签墙页面。
18
18
  - **自由画布**:便签不是列表项,而是画布上的卡片。位置、旋转角、宽度三档(小/中/大)都属于便签数据,由 Host 保存;同一面墙在另一个窗口打开时摆位一致。
19
19
  - **拖动摆放**:按住卡片任意位置即可拖动,松手立刻落到新位置再把结果写回 Host(不会先弹回原处)。拖动本身**不会**改 `updatedAt`,所以「按更新」排序不会因为你整理桌面而乱掉。
20
- - **圆心构图**:整理把整面墙排成一个**以原点为中心的圆环**(向日葵螺旋排布),中心空出一块**矩形留白**给问候语和快速记录框;相机打开时把整面墙框进视野并居中。留白按**卡片边缘**判定,并按当前缩放换算成世界坐标 —— 缩小看全墙时留白会同步变大,任何缩放下都不会有卡片压住记录框。
21
- - **中心即入口**:便签墙正中是随时可用的快速记录框 —— 写一句按回车就落成一张便签,不用打开表单。新便签落在**离中心最近的空缺位置**,不会甩到视野之外。
22
- - **落点可见**:新便签生成时会在落点**弹入并亮一圈**(约 0.9 秒);如果落点在当前视野之外,相机**自动滑动并适度缩小**把它带进视野 —— 记下一条之后不用猜它到底有没有生成。
20
+ - **圆心构图**:整理把整面墙排成**贴着中心留白的一圈紧凑构图**,中心空出一块**矩形留白**给问候语和快速记录框;相机打开时把整面墙框进视野并居中。排布不是按「圆环」而是按**留白矩形的轮廓**铺开,所以每张卡片离中心都只有它自己的一半尺寸那么远 —— 同样 14 张便签,0.5.0 的圆环要占 1645×1794、只能框到 36%,现在占 1261×705、能框到 84%。留白按**卡片边缘**判定;整理时它在世界坐标里恒定,而**单张新便签的落点跟随记录框当前在世界里的真实位置**,所以平移到别处或放大之后再记一条,卡片仍然落在记录框旁边而不是它背后。
21
+ - **中心即入口**:便签墙正中是随时可用的快速记录框 —— 写一句按回车就落成一张便签,不用打开表单。新便签落在**离记录框最近的空缺位置**,不会甩到视野之外,也不会被记录框本身挡住。
22
+ - **落点可见**:新便签生成时会在落点**弹入并亮一圈**(约 0.9 秒);如果落点不在视野里,相机会把它带到**记录框旁边的空位**(上/下/左/右取最省力的那侧),必要时才适度缩小 —— 记下一条之后不用猜它到底有没有生成。相机不会把新便签对到画面正中,因为那里正是记录框。
23
23
  - **留白是磁吸边界**:把卡片拖到中间记录框上会被自动推到最近的空位,不会盖住输入框。
24
24
  - **一键整理**:「整理」把全部便签按确定性算法重新排布并做真实碰撞检测 —— 同一面墙按两次得到同一个结果,卡片永不重叠。
25
25
  - **三种视图**:画布(默认,自由摆位)、网格(响应式瀑布流,适合读长文)、列表(一行一条,适合按标题找)。
@@ -146,7 +146,7 @@ node scripts/preview.mjs check # 离线校验预览图与 locale 元数据(n
146
146
  - 卡片宽度只有小/中/大**三档预设**,不支持任意拖拽调整宽度;拖动会保留卡片原有的轻微倾角。
147
147
  - 整理是 O(n) 的螺旋放置 + 网格碰撞检测;便签上限 400 张,超出视野的墙需要自己平移或缩小。
148
148
  - 画布是二维平面:没有分组、图层、连线或吸附对齐;也不支持双指旋转或触屏捏合之外的手势。
149
- - 自动取景有可读性下限(50%):便签很多时整面墙不会全部挤进视野,而是居中显示、需要平移查看。中心区域是固定留白,整理不会把卡片放在问候语和记录框下面。
149
+ - 自动取景有可读性下限(42%):便签很多时整面墙不会全部挤进视野,而是居中显示、需要平移查看。整理不会把卡片放在问候语和记录框下面;平移到别处再新建时,落点也会避开记录框当前所在的位置。
150
150
  - 便签的位置由 Host 保存;同一面墙在两个窗口同时打开时,各自渲染自己的快照,不会实时推送另一个窗口的拖动结果。
151
151
  - 归档便签不占 `maxNotes` 名额,但恢复它们会占名额;名额已满时恢复会被拒绝而不是悄悄超限。
152
152
  - 「清空归档」是永久删除,不可撤销。
@@ -4,7 +4,7 @@
4
4
  "verified": [
5
5
  {
6
6
  "dsh": "0.2.2-rc.1",
7
- "verifiedAt": "2026-11-08",
7
+ "verifiedAt": "2026-11-10",
8
8
  "result": "passed",
9
9
  "checks": [
10
10
  "dump-config",
@@ -38,7 +38,7 @@
38
38
  "browser-theme-switch",
39
39
  "display-detail-image",
40
40
  "display-locale-detail",
41
- "browser-canvas-centred-disc",
41
+ "browser-canvas-centred-cluster",
42
42
  "browser-camera-centre-framing",
43
43
  "browser-camera-transform-not-scroll",
44
44
  "browser-canvas-pan",
@@ -54,9 +54,11 @@
54
54
  "browser-centre-capture-lands-visible",
55
55
  "browser-dock-no-overflow",
56
56
  "browser-dock-menu-show-archived",
57
- "browser-wall-is-a-ring"
57
+ "browser-wall-is-a-ring",
58
+ "browser-capture-clear-of-field-on-panned-wall",
59
+ "browser-capture-clear-of-field-on-zoomed-wall"
58
60
  ],
59
- "notes": "Packed tarball 0.2.0 installed into an owned, disposable, non-Desktop web profile created from the shipped template (DSH 0.2.2-rc.1). dsh --profile <test> --dump-config composed the bundle row; a bounded real startup served the Web app; the authenticated browser transport exercised the exact /api/skillre-sticky-wall/execute route: list, create, update, move (placement echoed back without bumping updatedAt), an out-of-bounds move CLAMPED into the world while a non-finite one is refused as sticky-wall/bad-request, arrange, archive, delete, plus storage persistence of both the note and its canvas placement across a full restart, and an unauthenticated request returning 401. Cleanup stopped every owned process, removed the owned profile root and verified it was gone. The real DSH Web UI was then driven in headless Chromium against a FRESH owned profile: the 便签墙 sidebar entry appeared and selected the panel (the shell's own preview-notice mask was dismissed first, otherwise it swallows pointer input), the wall mounted with the seeded welcome note, the composer created a note whose Markdown body rendered as strong/code/list elements with no literal markers left, pin moved it first, search filtered to it, archive hid it from the default wall, the archived toggle showed it again, the note survived a full page reload, canvas cards were absolutely positioned from stored layouts, a real pointer drag wrote a new placement through the Host, 整理 repacked the wall and left NO overlapping cards, grid and list views rendered the same note set, and the note palette switched between light and dark. 24/24 UI assertions passed with no uncaught errors. Cleanup stopped the harness, killed Chrome, removed both the owned profile and the Chrome scratch directory, and verified they were gone. The display contract was verified offline: meta.detail resolves to docs/DETAIL*.md, each carries exactly one banner image at the 640x300 ratio, and both SVGs render (evidence PNGs committed). Two real defects were found and fixed during this verification: card heights were under-estimated for CJK text (so the tidy pass overlapped cards), and arrange packed only the live set (so an archived visible card stayed on top of tidied ones). A post-review pass fixed four defects the independent review found and proved each with a test that fails when the fix is reverted: (1) the height estimate charged a long title a flat 1.4 lines, so a 120-char CJK title estimated 104px against a rendered ~244px and tidy overlapped; the title and tag pills are now measured by columns. (2) The packer silently clamped cards past the world coordinate limit, pinning hundreds to one edge; the shelf width now scales with the wall and a 300-card worst case is asserted overlap-free. (3) Every drag wrote rotate: 0, destroying the tilt tidy applied; the drag now carries rotation through and the UI harness asserts it. (4) Derived preview positions were indexed off the filtered list, so legacy notes jumped while typing in the search box; the index now comes from the unfiltered snapshot. Rotation is also budgeted into the shelf gap, and the transport clamps instead of rejecting an out-of-bounds drag. 0.2.1 makes the drag direct: the canvas card no longer transitions its transform (which turned every per-frame write into an animation target and made the card trail the pointer), the drag flag moved from React state to a node attribute so pressing no longer re-renders the wall, pointer moves are coalesced into one write per animation frame, the pointer loop is registered once instead of per press, and the hover lift no longer overwrites the drag transform on the canvas. The UI harness caught a regression in that rewrite (the drop cleared the inline transform and stripped the card's tilt) and the fix is covered by a test. 0.3.0 gives the wall a centre and makes the canvas direct. Tidy now packs a phyllotaxis spiral centred on the world origin with a real spatial-grid collision check (no shelf estimate), and the finished disc is re-centred on its centre of mass; the camera opens on that middle and frames the whole wall, capped at 100%. The canvas became a clipping viewport with one transform-driven world instead of a padded scroll container, so panning and zooming cost zero React renders and dragging a card can no longer move the wall under it. Pan is drag-on-paper or wheel, zoom is ctrl/cmd+wheel anchored on the pointer, and reset re-frames the wall. The drop is optimistic: the card lands on its final world position before the Host round-trip. Cards are memoized and note objects are reconciled by identity, the per-note full-size wrapper element is gone, and body clamping follows the width preset. Verified in the real DSH Web UI with 31/31 assertions on a fresh owned profile, including a 14-note wall that tidies into a centred disc with zero overlaps (aspect ratio 0.94) and is framed at 54% by the camera, a real pointer drag that persists its placement and keeps its rotation, a real drag on empty paper that pans the camera by exactly the pointer delta, a wheel zoom that keeps the world point under the cursor fixed to under 2px, and a reset that re-frames the whole wall. The harness itself caught two real defects during this verification: the wheel listener was bound to a canvas node that did not exist yet while the wall was loading (so zoom silently did nothing), and a pan that ended inside a single animation frame was dropped entirely. Both are fixed and asserted. 0.4.0 turns the wall into a centre-anchored board. The tidy pass now packs a phyllotaxis RING that leaves a clear disc (CENTRE_RADIUS, measured to each card's nearest EDGE, not its centre) at the middle, and the re-centring shift is applied only when it preserves that reserve. The wall's middle is now its centrepiece: a time-aware greeting, a running tally and an always-available quick-capture field, rendered as a screen-space overlay that stays put under pan and zoom. The header and toolbar rows are gone — the canvas fills the whole window and every control lives in one floating dock along the bottom. Auto-framing measures the RENDERED card boxes from the DOM instead of deriving them, is capped at 100% and floored at 50% for legibility, and runs one animation frame after the reconcile so tidy frames the wall it actually produced. Canvas cards are rendered at exactly the height the Host estimated, which is what makes the packer's collision geometry true by construction. Verified in the real DSH Web UI with 36/36 assertions: the centrepiece sits at the exact viewport middle and does not move while panning, tidy leaves the centre clear with zero card overlaps, a 14-note wall tidies to a centred ring (offset 1,1; aspect 1.01), quick capture creates a note and clears the field, the canvas covers 100% of the page with a single-row dock, and a real drag, a paper pan and a pointer-anchored wheel zoom all behave. The harness caught four real defects during this pass: the wheel listener bound to a canvas that did not exist yet, a same-frame pan being dropped, tidy consuming a fit request against the pre-tidy bounds, and a fit floor that shrank a large wall to unreadable size.",
61
+ "notes": "Packed tarball 0.2.0 installed into an owned, disposable, non-Desktop web profile created from the shipped template (DSH 0.2.2-rc.1). dsh --profile <test> --dump-config composed the bundle row; a bounded real startup served the Web app; the authenticated browser transport exercised the exact /api/skillre-sticky-wall/execute route: list, create, update, move (placement echoed back without bumping updatedAt), an out-of-bounds move CLAMPED into the world while a non-finite one is refused as sticky-wall/bad-request, arrange, archive, delete, plus storage persistence of both the note and its canvas placement across a full restart, and an unauthenticated request returning 401. Cleanup stopped every owned process, removed the owned profile root and verified it was gone. The real DSH Web UI was then driven in headless Chromium against a FRESH owned profile: the 便签墙 sidebar entry appeared and selected the panel (the shell's own preview-notice mask was dismissed first, otherwise it swallows pointer input), the wall mounted with the seeded welcome note, the composer created a note whose Markdown body rendered as strong/code/list elements with no literal markers left, pin moved it first, search filtered to it, archive hid it from the default wall, the archived toggle showed it again, the note survived a full page reload, canvas cards were absolutely positioned from stored layouts, a real pointer drag wrote a new placement through the Host, 整理 repacked the wall and left NO overlapping cards, grid and list views rendered the same note set, and the note palette switched between light and dark. 24/24 UI assertions passed with no uncaught errors. Cleanup stopped the harness, killed Chrome, removed both the owned profile and the Chrome scratch directory, and verified they were gone. The display contract was verified offline: meta.detail resolves to docs/DETAIL*.md, each carries exactly one banner image at the 640x300 ratio, and both SVGs render (evidence PNGs committed). Two real defects were found and fixed during this verification: card heights were under-estimated for CJK text (so the tidy pass overlapped cards), and arrange packed only the live set (so an archived visible card stayed on top of tidied ones). A post-review pass fixed four defects the independent review found and proved each with a test that fails when the fix is reverted: (1) the height estimate charged a long title a flat 1.4 lines, so a 120-char CJK title estimated 104px against a rendered ~244px and tidy overlapped; the title and tag pills are now measured by columns. (2) The packer silently clamped cards past the world coordinate limit, pinning hundreds to one edge; the shelf width now scales with the wall and a 300-card worst case is asserted overlap-free. (3) Every drag wrote rotate: 0, destroying the tilt tidy applied; the drag now carries rotation through and the UI harness asserts it. (4) Derived preview positions were indexed off the filtered list, so legacy notes jumped while typing in the search box; the index now comes from the unfiltered snapshot. Rotation is also budgeted into the shelf gap, and the transport clamps instead of rejecting an out-of-bounds drag. 0.2.1 makes the drag direct: the canvas card no longer transitions its transform (which turned every per-frame write into an animation target and made the card trail the pointer), the drag flag moved from React state to a node attribute so pressing no longer re-renders the wall, pointer moves are coalesced into one write per animation frame, the pointer loop is registered once instead of per press, and the hover lift no longer overwrites the drag transform on the canvas. The UI harness caught a regression in that rewrite (the drop cleared the inline transform and stripped the card's tilt) and the fix is covered by a test. 0.3.0 gives the wall a centre and makes the canvas direct. Tidy now packs a phyllotaxis spiral centred on the world origin with a real spatial-grid collision check (no shelf estimate), and the finished disc is re-centred on its centre of mass; the camera opens on that middle and frames the whole wall, capped at 100%. The canvas became a clipping viewport with one transform-driven world instead of a padded scroll container, so panning and zooming cost zero React renders and dragging a card can no longer move the wall under it. Pan is drag-on-paper or wheel, zoom is ctrl/cmd+wheel anchored on the pointer, and reset re-frames the wall. The drop is optimistic: the card lands on its final world position before the Host round-trip. Cards are memoized and note objects are reconciled by identity, the per-note full-size wrapper element is gone, and body clamping follows the width preset. Verified in the real DSH Web UI with 31/31 assertions on a fresh owned profile, including a 14-note wall that tidies into a centred disc with zero overlaps (aspect ratio 0.94) and is framed at 54% by the camera, a real pointer drag that persists its placement and keeps its rotation, a real drag on empty paper that pans the camera by exactly the pointer delta, a wheel zoom that keeps the world point under the cursor fixed to under 2px, and a reset that re-frames the whole wall. The harness itself caught two real defects during this verification: the wheel listener was bound to a canvas node that did not exist yet while the wall was loading (so zoom silently did nothing), and a pan that ended inside a single animation frame was dropped entirely. Both are fixed and asserted. 0.4.0 turns the wall into a centre-anchored board. The tidy pass now packs a phyllotaxis RING that leaves a clear disc (CENTRE_RADIUS, measured to each card's nearest EDGE, not its centre) at the middle, and the re-centring shift is applied only when it preserves that reserve. The wall's middle is now its centrepiece: a time-aware greeting, a running tally and an always-available quick-capture field, rendered as a screen-space overlay that stays put under pan and zoom. The header and toolbar rows are gone — the canvas fills the whole window and every control lives in one floating dock along the bottom. Auto-framing measures the RENDERED card boxes from the DOM instead of deriving them, is capped at 100% and floored at 50% for legibility, and runs one animation frame after the reconcile so tidy frames the wall it actually produced. Canvas cards are rendered at exactly the height the Host estimated, which is what makes the packer's collision geometry true by construction. Verified in the real DSH Web UI with 36/36 assertions: the centrepiece sits at the exact viewport middle and does not move while panning, tidy leaves the centre clear with zero card overlaps, a 14-note wall tidies to a centred ring (offset 1,1; aspect 1.01), quick capture creates a note and clears the field, the canvas covers 100% of the page with a single-row dock, and a real drag, a paper pan and a pointer-anchored wheel zoom all behave. The harness caught four real defects during this pass: the wheel listener bound to a canvas that did not exist yet, a same-frame pan being dropped, tidy consuming a fit request against the pre-tidy bounds, and a fit floor that shrank a large wall to unreadable size. 0.6.0 re-verified on the same DSH line: contour packing replaces ring packing (see CHANGELOG 0.6.0); the packed 0.6.0 tarball mounts, composes, boots and passes the full API suite in an owned isolated profile, and the 38-check real-UI run passes.",
60
62
  "evidence": [
61
63
  "docs/evidence/market-install-0.2.1.json",
62
64
  "docs/evidence/ui-verification.json",
@@ -73,7 +75,7 @@
73
75
  "tests/layout.spec.ts",
74
76
  "tests/markdown.spec.tsx",
75
77
  "docs/evidence/sticky-wall-canvas-many.png",
76
- "docs/evidence/isolated-mount-0.5.0.json"
78
+ "docs/evidence/isolated-mount-0.7.0.json"
77
79
  ]
78
80
  }
79
81
  ],
package/lib/client.js CHANGED
@@ -293,6 +293,7 @@ window.__ModuleLoader__.load({
293
293
  var GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));
294
294
  var PREVIEW_STEP = 196;
295
295
  var PREVIEW_NOMINAL_HEIGHT = 200;
296
+ var PREVIEW_SQUASH = 1.4;
296
297
  var PREVIEW_TILT = 4;
297
298
  function hash(text) {
298
299
  let value = 2166136261;
@@ -373,7 +374,7 @@ window.__ModuleLoader__.load({
373
374
  const radius = PREVIEW_STEP * Math.sqrt(Math.max(0, index) + (startRadius / PREVIEW_STEP) ** 2);
374
375
  const theta = index * GOLDEN_ANGLE + (unit(`${note.id}:pa`) - 0.5) * 0.55;
375
376
  return clampLayout({
376
- x: Math.cos(theta) * radius - WIDTH_PX[width] / 2,
377
+ x: Math.cos(theta) * radius * PREVIEW_SQUASH - WIDTH_PX[width] / 2,
377
378
  y: Math.sin(theta) * radius - PREVIEW_NOMINAL_HEIGHT / 2,
378
379
  rotate: (unit(`${note.id}:pr`) - 0.5) * 2 * PREVIEW_TILT,
379
380
  width
@@ -385,22 +386,38 @@ window.__ModuleLoader__.load({
385
386
  const sin = Math.sin(radians);
386
387
  return { width: width * cos + height * sin, height: height * cos + width * sin };
387
388
  }
388
- function intersectsReserve(box, reserve = CENTRE_RESERVE) {
389
- const clear = clearsReserve(box, reserve);
390
- return !clear;
391
- }
392
389
  var RESERVE_EPSILON = 0.05;
393
390
  function clearsReserve(box, reserve) {
394
- return !(box.x < reserve.halfWidth - RESERVE_EPSILON && box.x + box.width > -reserve.halfWidth + RESERVE_EPSILON && box.y < reserve.halfHeight - RESERVE_EPSILON && box.y + box.height > -reserve.halfHeight + RESERVE_EPSILON);
391
+ return !(box.x < reserve.x + reserve.halfWidth - RESERVE_EPSILON && box.x + box.width > reserve.x - reserve.halfWidth + RESERVE_EPSILON && box.y < reserve.y + reserve.halfHeight - RESERVE_EPSILON && box.y + box.height > reserve.y - reserve.halfHeight + RESERVE_EPSILON);
392
+ }
393
+ function normalizeReserve(raw) {
394
+ const cap = LAYOUT_LIMITS.coord / 4;
395
+ const clampHalf = (value) => {
396
+ const number = Number(value);
397
+ if (!Number.isFinite(number) || number <= 0) return 0;
398
+ return Math.min(cap, number);
399
+ };
400
+ const clampCoord = (value) => {
401
+ const number = Number(value);
402
+ if (!Number.isFinite(number)) return 0;
403
+ return Math.min(LAYOUT_LIMITS.coord, Math.max(-LAYOUT_LIMITS.coord, number));
404
+ };
405
+ return {
406
+ x: clampCoord(raw?.x ?? 0),
407
+ y: clampCoord(raw?.y ?? 0),
408
+ halfWidth: clampHalf(raw?.halfWidth),
409
+ halfHeight: clampHalf(raw?.halfHeight)
410
+ };
395
411
  }
396
412
  function pushOutOfReserve(note, layout, reserve = CENTRE_RESERVE) {
413
+ const rect = normalizeReserve(reserve);
397
414
  const box = footprintOf(note, layout);
398
- if (!intersectsReserve(box, reserve)) return layout;
415
+ if (clearsReserve(box, rect)) return layout;
399
416
  const moves = [
400
- { dx: -reserve.halfWidth - (box.x + box.width), dy: 0 },
401
- { dx: reserve.halfWidth - box.x, dy: 0 },
402
- { dx: 0, dy: -reserve.halfHeight - (box.y + box.height) },
403
- { dx: 0, dy: reserve.halfHeight - box.y }
417
+ { dx: rect.x - rect.halfWidth - (box.x + box.width), dy: 0 },
418
+ { dx: rect.x + rect.halfWidth - box.x, dy: 0 },
419
+ { dx: 0, dy: rect.y - rect.halfHeight - (box.y + box.height) },
420
+ { dx: 0, dy: rect.y + rect.halfHeight - box.y }
404
421
  ];
405
422
  let best = moves[0];
406
423
  for (const move of moves) {
@@ -1793,16 +1810,11 @@ window.__ModuleLoader__.load({
1793
1810
  tween.current = 0;
1794
1811
  }
1795
1812
  }, []);
1796
- const glideTo = (0, import_react.useCallback)((zoomTarget, worldX, worldY) => {
1797
- const viewport = viewportRefCurrent.current;
1798
- if (viewport === null) return;
1813
+ const glideCameraTo = (0, import_react.useCallback)((zoomTarget, panX, panY) => {
1814
+ const target = clampZoom(zoomTarget);
1815
+ const to = { zoom: target, panX, panY };
1799
1816
  stopTween();
1800
1817
  const from = { ...camera.current };
1801
- const to = {
1802
- zoom: clampZoom(zoomTarget),
1803
- panX: viewport.clientWidth / 2 - worldX * clampZoom(zoomTarget),
1804
- panY: viewport.clientHeight / 2 - worldY * clampZoom(zoomTarget)
1805
- };
1806
1818
  if (typeof requestAnimationFrame !== "function") {
1807
1819
  camera.current = { ...to };
1808
1820
  setZoom(to.zoom);
@@ -1831,6 +1843,12 @@ window.__ModuleLoader__.load({
1831
1843
  tween.current = requestAnimationFrame(frame);
1832
1844
  setZoom(to.zoom);
1833
1845
  }, [applyCamera, stopTween]);
1846
+ const glideTo = (0, import_react.useCallback)((zoomTarget, worldX, worldY) => {
1847
+ const viewport = viewportRefCurrent.current;
1848
+ if (viewport === null) return;
1849
+ const target = clampZoom(zoomTarget);
1850
+ glideCameraTo(target, viewport.clientWidth / 2 - worldX * target, viewport.clientHeight / 2 - worldY * target);
1851
+ }, [glideCameraTo]);
1834
1852
  const centreOn = (0, import_react.useCallback)((worldX, worldY) => {
1835
1853
  stopTween();
1836
1854
  const viewport = viewportRefCurrent.current;
@@ -1912,27 +1930,90 @@ window.__ModuleLoader__.load({
1912
1930
  const resetView = (0, import_react.useCallback)(() => {
1913
1931
  fitWall();
1914
1932
  }, [fitWall]);
1915
- const centreReserve = (0, import_react.useCallback)(() => CENTRE_RESERVE, []);
1933
+ const centreReserve = (0, import_react.useCallback)(() => {
1934
+ const base = CENTRE_RESERVE;
1935
+ const viewport = viewportRefCurrent.current;
1936
+ const centre = centreRef.current;
1937
+ if (viewport === null || centre === null) return base;
1938
+ const view2 = viewport.getBoundingClientRect();
1939
+ const block = centre.getBoundingClientRect();
1940
+ if (view2.width === 0 || view2.height === 0 || block.width === 0 || block.height === 0) return base;
1941
+ const zoomNow = camera.current.zoom;
1942
+ const screenX = block.left + block.width / 2 - view2.left;
1943
+ const screenY = block.top + block.height / 2 - view2.top;
1944
+ return {
1945
+ x: (screenX - camera.current.panX) / zoomNow,
1946
+ y: (screenY - camera.current.panY) / zoomNow,
1947
+ halfWidth: base.halfWidth,
1948
+ halfHeight: base.halfHeight
1949
+ };
1950
+ }, []);
1916
1951
  const revealBox = (0, import_react.useCallback)((box) => {
1917
1952
  const viewport = viewportRefCurrent.current;
1918
1953
  if (viewport === null) return;
1919
- const zoomNow = camera.current.zoom;
1920
- const centreX = box.x + box.width / 2;
1921
- const centreY = box.y + box.height / 2;
1922
- const screenX = centreX * zoomNow + camera.current.panX;
1923
- const screenY = centreY * zoomNow + camera.current.panY;
1954
+ const width = viewport.clientWidth || 960;
1955
+ const height = viewport.clientHeight || 640;
1924
1956
  const margin = 72;
1925
- const visible2 = screenX > margin && screenX < viewport.clientWidth - margin && screenY > margin && screenY < viewport.clientHeight - margin;
1926
- if (visible2) return;
1927
- const targetZoom = Math.min(
1928
- zoomNow,
1929
- Math.max(ZOOM_MIN, Math.min(
1930
- (viewport.clientWidth - margin * 2) / Math.max(1, box.width),
1931
- (viewport.clientHeight - margin * 2) / Math.max(1, box.height)
1932
- ))
1933
- );
1934
- glideTo(targetZoom, centreX, centreY);
1935
- }, [glideTo]);
1957
+ const dock = dockRef.current;
1958
+ const bottomInset = dock === null ? 0 : dock.offsetHeight + 24;
1959
+ const usableBottom = height - margin - bottomInset;
1960
+ const view2 = viewport.getBoundingClientRect();
1961
+ const centre = centreRef.current;
1962
+ const blockRect = centre === null ? null : centre.getBoundingClientRect();
1963
+ const fieldX = blockRect === null ? width / 2 : blockRect.left + blockRect.width / 2 - view2.left;
1964
+ const fieldY = blockRect === null ? height / 2 : blockRect.top + blockRect.height / 2 - view2.top;
1965
+ const reserve = CENTRE_RESERVE;
1966
+ const blockHalf = (zoom2) => ({
1967
+ // The painted overlay is counter-scaled by `min(1, zoom)`, while its world
1968
+ // footprint stays fixed; taking the larger of the two keeps the card clear
1969
+ // of whichever is actually on screen.
1970
+ halfW: reserve.halfWidth * Math.max(1, zoom2),
1971
+ halfH: reserve.halfHeight * Math.max(1, zoom2)
1972
+ });
1973
+ const cardX = box.x + box.width / 2;
1974
+ const cardY = box.y + box.height / 2;
1975
+ const screenX = cardX * camera.current.zoom + camera.current.panX;
1976
+ const screenY = cardY * camera.current.zoom + camera.current.panY;
1977
+ const fitsAt = (x, y2, zoom2) => x - box.width * zoom2 / 2 >= margin && x + box.width * zoom2 / 2 <= width - margin && y2 - box.height * zoom2 / 2 >= margin && y2 + box.height * zoom2 / 2 <= usableBottom;
1978
+ const hiddenAt = (x, y2, zoom2) => {
1979
+ const { halfW, halfH: halfH2 } = blockHalf(zoom2);
1980
+ return x - box.width * zoom2 / 2 < fieldX + halfW && x + box.width * zoom2 / 2 > fieldX - halfW && y2 - box.height * zoom2 / 2 < fieldY + halfH2 && y2 + box.height * zoom2 / 2 > fieldY - halfH2;
1981
+ };
1982
+ if (fitsAt(screenX, screenY, camera.current.zoom) && !hiddenAt(screenX, screenY, camera.current.zoom)) return;
1983
+ const gap = 26;
1984
+ for (let step = 0; step <= 8; step += 1) {
1985
+ const zoom2 = step === 0 ? camera.current.zoom : Math.max(ZOOM_MIN, camera.current.zoom * 0.88 ** step);
1986
+ const { halfW, halfH: halfH2 } = blockHalf(zoom2);
1987
+ const halfCardW = box.width * zoom2 / 2;
1988
+ const halfCardH = box.height * zoom2 / 2;
1989
+ const candidates = [
1990
+ { x: fieldX, y: fieldY - halfH2 - gap - halfCardH },
1991
+ { x: fieldX, y: fieldY + halfH2 + gap + halfCardH },
1992
+ { x: fieldX - halfW - gap - halfCardW, y: fieldY },
1993
+ { x: fieldX + halfW + gap + halfCardW, y: fieldY }
1994
+ ];
1995
+ let best = null;
1996
+ for (const candidate of candidates) {
1997
+ if (!fitsAt(candidate.x, candidate.y, zoom2)) continue;
1998
+ if (hiddenAt(candidate.x, candidate.y, zoom2)) continue;
1999
+ const cost = Math.hypot(candidate.x - screenX, candidate.y - screenY);
2000
+ if (best === null || cost < best.cost) best = { x: candidate.x, y: candidate.y, zoom: zoom2, cost };
2001
+ }
2002
+ if (best !== null) {
2003
+ glideCameraTo(best.zoom, best.x - cardX * best.zoom, best.y - cardY * best.zoom);
2004
+ return;
2005
+ }
2006
+ if (zoom2 <= ZOOM_MIN) break;
2007
+ }
2008
+ const targetZoom = Math.max(ZOOM_MIN, Math.min(
2009
+ camera.current.zoom,
2010
+ (width - margin * 2) / Math.max(1, box.width),
2011
+ (usableBottom - margin) / Math.max(1, box.height)
2012
+ ));
2013
+ const { halfH } = blockHalf(targetZoom);
2014
+ const y = fieldY + halfH + gap + box.height * targetZoom / 2;
2015
+ glideCameraTo(targetZoom, width / 2 - cardX * targetZoom, y - cardY * targetZoom);
2016
+ }, [glideCameraTo]);
1936
2017
  const arrival = (0, import_react.useRef)(null);
1937
2018
  (0, import_react.useEffect)(() => {
1938
2019
  const pending = arrival.current;
package/lib/layout.d.ts CHANGED
@@ -5,22 +5,22 @@
5
5
  * rotation and a width preset. Two operations produce those numbers:
6
6
  *
7
7
  * - {@link arrangeLayouts} is the Host-side "tidy" pass. It packs the wall into
8
- * a phyllotaxis (sunflower) disc **centred on the world origin**, so the wall
9
- * has a middle instead of a top-left corner: the Client opens looking at that
10
- * middle, and a tidied wall reads as one composition rather than a list that
11
- * happens to wrap. It is deterministic — the same notes always produce the
12
- * same wall — and it is collision-checked rather than estimated, so two cards
13
- * can never overlap even at the height cap.
8
+ * a compact cluster **centred on the world origin**, hugging the rectangle the
9
+ * centrepiece reserves: the Client opens looking at that middle, and a tidied
10
+ * wall reads as one composition rather than a list that happens to wrap. It is
11
+ * deterministic — the same notes always produce the same wall — and it is
12
+ * collision-checked rather than estimated, so two cards can never overlap even
13
+ * at the height cap.
14
14
  * - {@link previewLayout} is the Client-side fallback for a note that was never
15
15
  * placed (a wall written before the canvas existed, or a note created by the
16
- * agent tool). It is the same spiral without the collision check: O(1) per
17
- * note, index-stable, and centred, so the first render is already a scattered
18
- * wall around the middle instead of one tall stack.
16
+ * agent tool). It is a golden-angle spiral without the collision check: O(1)
17
+ * per note, index-stable, and centred, so the first render is already a
18
+ * scattered wall around the middle instead of one tall stack.
19
19
  *
20
20
  * Both halves import this module, so the geometry never drifts between the
21
21
  * value the Host persists and the value the Client previews.
22
22
  */
23
- import { type CentreReserve, type Note, type NoteLayout, type NoteWidth } from './types.js';
23
+ import { type CentreReserve, type Note, type NoteLayout, type NoteWidth, type ReserveRect } from './types.js';
24
24
  /** Clamp one layout into the declared world bounds. */
25
25
  export declare function clampLayout(layout: NoteLayout): NoteLayout;
26
26
  /** True when two layouts describe the same position (rounded comparison). */
@@ -44,10 +44,14 @@ export declare function layoutOf(note: Note, index: number): NoteLayout;
44
44
  /**
45
45
  * Derived position for a note the user never placed.
46
46
  *
47
- * Index-based so two never-placed notes cannot collide, golden-angle spiralled
48
- * so the result reads as a wall scattered around the middle rather than a grid.
49
- * The height used for centring is a nominal constant, not the real estimate:
50
- * a derived position must not move when the user edits the note's text.
47
+ * Index-based so two never-placed notes cannot collide, and laid out on a
48
+ * SQUASHED spiral — the same golden-angle walk with its radius stretched along
49
+ * the x axis — so the result reads as a wide cluster around the middle rather
50
+ * than a circle or a grid. The squash matters: a circle leaves the left and
51
+ * right of a wide window empty and the camera then has to zoom out to frame the
52
+ * empty corners, which is the same "everything looks small" failure the tidy
53
+ * pass fixes. The height used for centring is a nominal constant, not the real
54
+ * estimate: a derived position must not move when the user edits the text.
51
55
  */
52
56
  export declare function previewLayout(note: Note, index: number): NoteLayout;
53
57
  /**
@@ -83,25 +87,45 @@ export interface Box {
83
87
  /**
84
88
  * Deterministic tidy arrangement for the whole wall.
85
89
  *
86
- * The wall is packed into CONCENTRIC RINGS around the world origin, outside the
87
- * rectangle the centrepiece reserves. This replaced a phyllotaxis first-fit
88
- * spiral, and the reason is measurable rather than aesthetic: a sunflower spiral
89
- * has to keep every candidate clear of a card's full bounding circle, so it
90
- * saturates at roughly a quarter of the available area and the only way to place
91
- * the next card is to walk further out. A fourteen-card wall therefore spread
92
- * over ~2700px of paper while its cards covered ~430,000px² — a sparse scatter,
93
- * not a wall. Ring packing instead computes how many cards fit on each circle
94
- * (`2πR / pitch`) and fills that circle evenly, so the same fourteen cards fit
95
- * within ~1200px and the result reads as a ring around the middle.
96
- *
97
- * Cards are sorted largest-first within the ring they land on, which is the
98
- * classic first-fit-decreasing heuristic: big cards claim the inner ring where
99
- * there is less room to waste, and small cards take up the slack outside.
90
+ * The wall is packed against a CONTOUR: the reserved rectangle's own outline,
91
+ * walked outward frame by frame. This is the third packer in this file's
92
+ * history and each replacement fixed a measured failure rather than a taste.
93
+ *
94
+ * 1. A phyllotaxis first-fit spiral had to keep every candidate clear of a
95
+ * card's full bounding circle, so it saturated at roughly a quarter of the
96
+ * available area and the only way to place the next card was to walk further
97
+ * out: fourteen cards spread over ~2700px of paper.
98
+ * 2. Concentric RINGS fixed that density but paid for it with distance. A ring
99
+ * is a circle, and the first ring's radius is the reserve's half-DIAGONAL —
100
+ * so the innermost cards sit at the rectangle's corner distance in every
101
+ * direction, including the four directions where the rectangle is only a
102
+ * card's width away. A fourteen-card wall then filled a 1645x1794 box, which
103
+ * the camera could only frame at 36%: the cards were individually packed
104
+ * tightly but the wall as a whole looked small and far away. That is the
105
+ * complaint this packer answers.
106
+ * 3. A contour hugs the rectangle instead: along the left and right edges a card
107
+ * sits one card-half-width from the reserve, and along the top and bottom one
108
+ * card-half-height from it. Every card is therefore as close to the middle as
109
+ * its own size allows, which is what makes the wall read as one composition.
110
+ *
111
+ * Two further decisions do the rest of the work:
112
+ *
113
+ * - **Score by how well the wall FRAMES, not by how free the slot is.** A
114
+ * candidate slot is judged by the zoom the whole wall would need in a
115
+ * reference viewport if the card went there. Filling a slot that widens the
116
+ * wall's box costs zoom, so the packer prefers slots that keep the box close
117
+ * to the window's own aspect — which is why the result is a wide, low cluster
118
+ * instead of a disc that leaves the left and right of the window empty.
119
+ * - **The first frame with room wins.** Walking outward frame by frame and
120
+ * taking the best-scoring slot on the first frame that has any is what makes
121
+ * every card land near the middle: an outer frame is only reached when the
122
+ * inner ones are genuinely full.
100
123
  *
101
124
  * A collision check still runs on every candidate rather than trusting the
102
125
  * height estimate, because the estimate is a line count and a code block's
103
- * padding is not something a line count can see. If a candidate does not fit the
104
- * check pushes to the next ring — the packer never produces an overlap.
126
+ * padding is not something a line count can see. The packer never produces an
127
+ * overlap, and the final centring passes repair any card the centring shift
128
+ * nudged into the reserved rectangle.
105
129
  *
106
130
  * Returns a map from note id to its new layout, for every note that needs to
107
131
  * move. Notes already at exactly that layout are omitted by the caller, so
@@ -121,7 +145,21 @@ export declare function normalizeWidth(raw: unknown): NoteWidth;
121
145
  * capped well inside the world bounds so the packer can never be asked to keep
122
146
  * a middle clear that leaves no paper for the cards.
123
147
  */
124
- export declare function normalizeReserve(raw: CentreReserve): CentreReserve;
148
+ /**
149
+ * Clamp a reserve into something the packer can actually honour.
150
+ *
151
+ * The Client sends a reserve positioned where the centrepiece currently sits in
152
+ * world space, so it can arrive with huge coordinates (a deeply zoomed-out wall)
153
+ * or as garbage. Both extremes are refused here: a non-finite coordinate becomes
154
+ * the origin, and the half-extents are capped well inside the world bounds so the
155
+ * packer can never be asked to keep a middle clear that leaves no paper for the
156
+ * cards.
157
+ *
158
+ * The position is clamped to the world bounds rather than to zero: a panned wall
159
+ * legitimately puts the field far from the origin, and snapping it back to the
160
+ * origin would reintroduce the very bug this position exists to fix.
161
+ */
162
+ export declare function normalizeReserve(raw: CentreReserve): ReserveRect;
125
163
  /**
126
164
  * The nearest free spot for one new card, in world coordinates.
127
165
  *
@@ -132,11 +170,19 @@ export declare function normalizeReserve(raw: CentreReserve): CentreReserve;
132
170
  * the user could not see it, which reads exactly like the capture silently
133
171
  * failing.
134
172
  *
135
- * This searches outward from the middle instead: the spiral is walked from just
173
+ * This searches outward from the field instead: the spiral is walked from just
136
174
  * outside the centrepiece's reserve, and the first candidate that clears every
137
175
  * existing card (plus a gap) and stays out of the reserve is the answer. The
138
- * result is therefore the gap nearest the centre of the wall, which is both
139
- * where the user is looking and where the wall has room.
176
+ * result is therefore the gap nearest the place the user is actually looking at,
177
+ * which is where the wall has room.
178
+ *
179
+ * The spiral orbits the RESERVE, not the world origin. That distinction is the
180
+ * fix for a note appearing behind the capture field: the field is a screen-space
181
+ * overlay, so on a panned wall it covers a patch of world that is nowhere near
182
+ * the origin. Orbiting the origin placed the card beside a point the user could
183
+ * not see, and the reveal then centred that point — with the field drawn on top
184
+ * of it. Orbiting the reserve puts the card next to the field, which is both
185
+ * visible and the only placement that can never be hidden by it.
140
186
  *
141
187
  * Deterministic for the same inputs, so two windows creating at once cannot
142
188
  * disagree about the free spot for the same wall.