@dexhq/canvas 0.17.0 → 0.18.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.
Files changed (174) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/app/canvas/canvas-commands.ts +2 -10
  3. package/app/canvas/canvas-context.tsx +11 -2
  4. package/app/canvas/canvas-document.ts +5 -1
  5. package/app/canvas/canvas-keys.ts +1 -1
  6. package/app/canvas/canvas-model.ts +195 -20
  7. package/app/canvas/canvas-scene.ts +176 -171
  8. package/app/canvas/canvas-ui.ts +4 -11
  9. package/app/canvas/canvas.css +159 -179
  10. package/app/canvas/change-pictures.tsx +156 -0
  11. package/app/canvas/comment-drafts.ts +31 -0
  12. package/app/canvas/comment-layer.tsx +125 -71
  13. package/app/canvas/comments.tsx +38 -2
  14. package/app/canvas/element-picker.ts +20 -0
  15. package/app/canvas/engine/canvas-gestures.ts +15 -3
  16. package/app/canvas/engine/canvas-store.ts +5 -0
  17. package/app/canvas/engine/canvas-view.tsx +22 -5
  18. package/app/canvas/find-bar.tsx +57 -41
  19. package/app/canvas/flow-canvas.tsx +147 -272
  20. package/app/canvas/frame-copies.ts +14 -17
  21. package/app/canvas/frame-drops.ts +15 -7
  22. package/app/canvas/frame-inspector.ts +192 -41
  23. package/app/canvas/frame-node.tsx +123 -75
  24. package/app/canvas/frame-resize.tsx +321 -83
  25. package/app/canvas/insert-hint.tsx +5 -15
  26. package/app/canvas/inspect-layer.tsx +73 -19
  27. package/app/canvas/label-action.tsx +13 -2
  28. package/app/canvas/layout.ts +233 -98
  29. package/app/canvas/live-page.ts +5 -0
  30. package/app/canvas/new-frame.ts +10 -25
  31. package/app/canvas/note-placing.ts +55 -84
  32. package/app/canvas/picked-box.tsx +5 -0
  33. package/app/canvas/picks-menu.tsx +3 -9
  34. package/app/canvas/readable-colour.ts +52 -0
  35. package/app/canvas/request-node.tsx +19 -10
  36. package/app/canvas/scrolling-page.ts +45 -0
  37. package/app/canvas/section-node.tsx +36 -53
  38. package/app/canvas/settle.ts +21 -0
  39. package/app/canvas/snapping.ts +96 -8
  40. package/app/canvas/spec-frame.tsx +8 -5
  41. package/app/canvas/spot-pins.tsx +15 -3
  42. package/app/canvas/stack-frame.tsx +13 -57
  43. package/app/canvas/stack-model.ts +5 -0
  44. package/app/canvas/stack-toggle.tsx +89 -0
  45. package/app/canvas/styles-layer.tsx +23 -43
  46. package/app/canvas/text-layer.tsx +26 -10
  47. package/app/canvas/thread-focus.tsx +18 -1
  48. package/app/canvas/tool-cursors.ts +2 -2
  49. package/app/canvas/toolbar-parts.tsx +48 -8
  50. package/app/canvas/toolbar.tsx +12 -10
  51. package/app/canvas/use-canvas-clipboard.tsx +13 -5
  52. package/app/canvas/use-reveal.ts +86 -0
  53. package/app/editor/extensions.ts +2 -0
  54. package/app/editor/line-break-caret.ts +57 -0
  55. package/app/git/branch-panel.tsx +61 -20
  56. package/app/i18n/locales/en/messages.po +64 -17
  57. package/app/i18n/locales/en/messages.ts +1 -1
  58. package/app/i18n/locales/pseudo/messages.po +64 -17
  59. package/app/i18n/locales/pseudo/messages.ts +1 -1
  60. package/app/icons/glyphs.tsx +2 -0
  61. package/app/live/studio-live.ts +29 -9
  62. package/app/pages/canvas.tsx +1 -1
  63. package/app/pages/commands-settings.tsx +70 -76
  64. package/app/pages/play-bar.tsx +6 -11
  65. package/app/pages/play.tsx +52 -33
  66. package/app/shell/feedback-form.tsx +29 -5
  67. package/app/ui/prompt-editor.tsx +2 -0
  68. package/app/ui/use-field-list.ts +90 -0
  69. package/dist/cli/commands/mcp.mjs +6 -4
  70. package/dist/cli/mcp-relay.mjs +10 -6
  71. package/dist/content/content.d.mts +26 -9
  72. package/dist/content/content.mjs +65 -8
  73. package/dist/content/screenshot.d.mts +2 -0
  74. package/dist/content/screenshot.mjs +3 -0
  75. package/dist/content/snapshot-client.d.mts +2 -0
  76. package/dist/content/snapshot-client.mjs +12 -1
  77. package/dist/inspector.js +96 -19
  78. package/dist/paste/paste.d.mts +5 -0
  79. package/dist/paste/paste.mjs +7 -2
  80. package/dist/server/agent-tools.d.mts +1 -0
  81. package/dist/server/agent-tools.mjs +4 -3
  82. package/dist/server/change-picture-store.d.mts +13 -0
  83. package/dist/server/change-picture-store.mjs +42 -0
  84. package/dist/server/change-pictures.d.mts +25 -0
  85. package/dist/server/change-pictures.mjs +104 -0
  86. package/dist/server/close-check.d.mts +11 -0
  87. package/dist/server/close-check.mjs +37 -5
  88. package/dist/server/comments/agent-actions.d.mts +8 -4
  89. package/dist/server/comments/agent-actions.mjs +16 -7
  90. package/dist/server/comments/close-tools.mjs +7 -5
  91. package/dist/server/comments/files.d.mts +5 -1
  92. package/dist/server/comments/hand-out.d.mts +1 -1
  93. package/dist/server/comments/hand-out.mjs +4 -1
  94. package/dist/server/comments/push.d.mts +19 -10
  95. package/dist/server/comments/push.mjs +45 -30
  96. package/dist/server/comments/studio-files.d.mts +14 -1
  97. package/dist/server/comments/studio-files.mjs +44 -31
  98. package/dist/server/comments/tools.d.mts +1 -1
  99. package/dist/server/comments/workspace.mjs +1 -0
  100. package/dist/server/dev-server.mjs +34 -0
  101. package/dist/server/own-copies.mjs +4 -23
  102. package/dist/server/requests.mjs +57 -3
  103. package/dist/server/response-budget.d.mts +2 -1
  104. package/dist/server/response-budget.mjs +4 -3
  105. package/dist/server/roster.d.mts +19 -8
  106. package/dist/server/roster.mjs +50 -22
  107. package/dist/server/studio-for.d.mts +7 -0
  108. package/dist/server/studio-for.mjs +23 -7
  109. package/dist/server/thread-forms.d.mts +3 -0
  110. package/dist/server/thread-forms.mjs +21 -1
  111. package/dist/server/tools/place-frame.d.mts +1 -0
  112. package/dist/server/tools/place-frame.mjs +33 -9
  113. package/dist/server/tools/result.mjs +2 -2
  114. package/dist/server/tools/snapshot.d.mts +1 -1
  115. package/dist/server/tools/snapshot.mjs +2 -1
  116. package/dist/server/tools/studio-context.d.mts +2 -1
  117. package/dist/server/tools/studio-context.mjs +2 -1
  118. package/dist/server/tools/watch.mjs +29 -12
  119. package/dist/server/work-groups.mjs +1 -1
  120. package/dist/shared/canvas-core.d.mts +39 -5
  121. package/dist/shared/canvas-core.mjs +60 -15
  122. package/dist/shared/canvas-file.d.mts +7 -4
  123. package/dist/shared/change-pictures-core.d.mts +6 -0
  124. package/dist/shared/change-pictures-core.mjs +5 -0
  125. package/dist/shared/page-looks.d.mts +12 -0
  126. package/dist/shared/page-looks.mjs +49 -0
  127. package/dist/shared/snapshot-clipboard.d.mts +6 -0
  128. package/dist/shared/studio-routes.d.mts +11 -0
  129. package/extension/dist/manifest.json +1 -1
  130. package/extension/dist/picker.js +114 -108
  131. package/package.json +4 -3
  132. package/src/cli/commands/mcp.ts +18 -8
  133. package/src/cli/mcp-relay.ts +13 -6
  134. package/src/content/content.ts +90 -16
  135. package/src/content/screenshot.ts +9 -1
  136. package/src/content/snapshot-client.ts +17 -0
  137. package/src/paste/paste.ts +18 -1
  138. package/src/server/agent-tools.ts +5 -4
  139. package/src/server/change-picture-store.ts +71 -0
  140. package/src/server/change-pictures.ts +244 -0
  141. package/src/server/close-check.ts +69 -6
  142. package/src/server/comments/agent-actions.ts +51 -12
  143. package/src/server/comments/close-tools.ts +20 -10
  144. package/src/server/comments/files.ts +10 -2
  145. package/src/server/comments/hand-out.ts +2 -2
  146. package/src/server/comments/push.ts +94 -46
  147. package/src/server/comments/studio-files.ts +77 -46
  148. package/src/server/comments/workspace.ts +1 -0
  149. package/src/server/dev-server.ts +70 -0
  150. package/src/server/own-copies.ts +5 -33
  151. package/src/server/requests.ts +84 -4
  152. package/src/server/response-budget.ts +5 -3
  153. package/src/server/roster.ts +78 -28
  154. package/src/server/studio-for.ts +32 -7
  155. package/src/server/thread-forms.ts +41 -1
  156. package/src/server/tools/place-frame.ts +71 -14
  157. package/src/server/tools/result.ts +2 -2
  158. package/src/server/tools/snapshot.ts +2 -1
  159. package/src/server/tools/studio-context.ts +24 -14
  160. package/src/server/tools/watch.ts +38 -13
  161. package/src/server/work-groups.ts +1 -1
  162. package/src/shared/canvas-core.ts +119 -27
  163. package/src/shared/canvas-file.ts +7 -4
  164. package/src/shared/change-pictures-core.ts +8 -0
  165. package/src/shared/page-looks.ts +133 -0
  166. package/src/shared/snapshot-clipboard.ts +6 -0
  167. package/src/shared/studio-routes.ts +7 -1
  168. package/templates/agents/dex-worker.md +9 -7
  169. package/templates/feedback-workflow.md +1 -1
  170. package/templates/methods/review.md +7 -6
  171. package/templates/rules/canvas-frames.md +8 -7
  172. package/templates/rules/canvas.md +10 -8
  173. package/templates/rules/prototypes.md +5 -3
  174. package/app/canvas/stack-node.tsx +0 -100
@@ -30,7 +30,8 @@ design changes; you never apply one they have not approved.
30
30
  design system (see `rules/canvas-frames.md`).
31
31
  - **A section's spec.** A thread on a section, or on a frame in a section, that has a
32
32
  spec names it, as `flowSpec` (the spec's path; `moreFlowSpecs` names any
33
- other specs the section has). Read it before you answer, and follow it: it
33
+ other specs the section has; in a group whose threads all have it, the
34
+ group's `shared` names it once). Read it before you answer, and follow it: it
34
35
  adds to the file spec and wins where they differ. When the answer changes
35
36
  what should hold for the section, edit the spec too, and say so.
36
37
  - **Comments and suggestions on a spec's words.** A thread with
@@ -71,7 +72,7 @@ Use Dex's MCP server to work with them:
71
72
  | `close` | Close threads, several at once: `summary` for done (✅, the line kept on the thread) with `where` it landed (a frame and selector, where people are taken), `dismiss` for not doing it (🚫, with why). |
72
73
  | `reply` | An answer where someone mentioned you; elsewhere, rarely, a question with `ask: true`. |
73
74
  | `comment` | Start a thread on an element, a frame, words in a spec (`spec`, `quote`; `replace` to suggest new words) or the file, for people or an agent. |
74
- | `place_frame` | Put frames for views you built in canvas cells, or in view requests' cells (`thread`), several at once. Safe while other agents edit the canvas. |
75
+ | `place_frame` | Put frames for views you built in canvas cells, in view requests' cells (`thread`), or right of a frame where it is now (`rightOf`), several at once. Says each one's step and the frame on its left. Safe while other agents edit the canvas. |
75
76
  | `prototype` | The file: its views, canvas, spec, open threads, and views no canvas shows any more (`removedViews`). |
76
77
 
77
78
  Without MCP, `npx dex threads` and `npx dex thread --id <id>` do the same.
@@ -120,10 +121,10 @@ review:
120
121
  2. When the result has `split`, the groups run side by side: if you can run
121
122
  sub-agents, start one per group straight away (`dex-worker` where you
122
123
  have it), all at once, each with its
123
- group's threads and `files`, to change only those, look at its view with
124
- `snapshot` and resolve its own threads. A
125
- sub-agent needs no brief: its group's threads and `files` say what to
126
- change. Do a whole-file group yourself, after the others.
124
+ group's threads, `shared` and `files`, to change only those, look at its
125
+ view with `snapshot` and resolve its own threads. A
126
+ sub-agent needs no brief: its group's threads, `shared` and `files` say
127
+ what to change. Do a whole-file group yourself, after the others.
127
128
  Without sub-agents, take the groups in turn.
128
129
  3. In each group, read the threads before changing anything. Comments often
129
130
  belong together: on the same element, or one referring to another. Decide
@@ -46,13 +46,14 @@ make by drawing on the canvas. `rules/canvas.md` has the grid they sit in.
46
46
  people wrote on the canvas for each other, placed with the Text tool. It is
47
47
  not a request and Dex does not send it to you; read it when it helps you
48
48
  understand a section. Leave others' notes as they are.
49
- - A note frame with `"header": true` is a section header, placed with ⇧T: a
50
- band across the whole canvas, its words large, that splits the canvas into
51
- parts, as a design file's section header rows do. It stands on its own (a
52
- section with `at`, its only frame), never in a section's cells; only its
53
- `at.y` matters, as it spans everything. Its words, in its note's file,
54
- name the part of the canvas below it. Leave headers as they are, unless
55
- asked.
49
+ - A note frame with `"header": true` is a section header, placed with ⇧T
50
+ wherever a note goes, its words large, as a design file's section header
51
+ rows are. In a section's cells (above a frame, say) it fills the section
52
+ from its column to the right edge of its frames; standing on its own (a
53
+ section with `at`, its only frame) it is a band across the whole canvas
54
+ that splits it into parts, and only its `at.y` matters. A `size.width`,
55
+ set by resizing it, is its own width instead. Its words, in its note's
56
+ file, name what is below it. Leave headers as they are, unless asked.
56
57
  - A frame with a `sketch` was drawn on the canvas. `prototype` gives
57
58
  its boxes as text (the first of them, for a large one). Leave it as it is,
58
59
  and never write or copy one. Any other
@@ -53,8 +53,8 @@ for, change its view in place. Never make a section just to hold a first frame.
53
53
  main path. When the section is played, its other steps come from the main row.
54
54
  - **A row and a step make a cell, and a cell's frames are one stack.** Every
55
55
  column starts at its row's top. Two or more frames in a cell show as a
56
- stack: the first on top, with how many it holds; people click it to fan the
57
- rest out. Put variants of one step in its stack; put a new step in a cell
56
+ stack: the first on top, how many it holds before its name; people click
57
+ it to fan the rest out. Put variants of one step in its stack; put a new step in a cell
58
58
  of its own.
59
59
  - **States are never hidden.** A view can declare states with `useViewControl`,
60
60
  but every state that matters gets its own row on the canvas, not just a
@@ -63,11 +63,11 @@ for, change its view in place. Never make a section just to hold a first frame.
63
63
  ## You share it with the person
64
64
 
65
65
  In a local Dex the person edits the canvas directly: they draw frames (F),
66
- drag frames onto a stack, between two columns (a new column) or between two
67
- rows (a new row), stack frames (⌘G) and take stacks apart (⇧⌘G), move a frame
68
- of its own anywhere, rename frames and sections, add frames from the dashed
69
- cells, set a frame's device or size and remove frames. Every change saves to
70
- `canvas.json` straight away.
66
+ drag frames, or a whole stack, onto a stack, between two columns (a new
67
+ column) or between two rows (a new row), stack frames (⌘G) and take stacks
68
+ apart (⇧⌘G), move a frame of its own anywhere, rename frames and sections,
69
+ add frames from the dashed cells, set a frame's device or size and remove
70
+ frames. Every change saves to `canvas.json` straight away.
71
71
 
72
72
  - **Read your `canvas.json` again immediately before you edit it.** It may have
73
73
  changed since you last looked.
@@ -127,7 +127,9 @@ archive", in the file's menu), put them back or move their own to the trash.
127
127
  - Every frame has an `id` unique within its row, and exactly one of `view`,
128
128
  `doc` or `spec`.
129
129
  - `step` is the frame's column. Leave it out when the frame simply follows the
130
- one before it.
130
+ one before it. To put a frame right of another, use `place_frame` with
131
+ `rightOf`: it finds that frame where it is now, even after the person moved
132
+ it. Never reuse a step from an earlier read.
131
133
  - `"under": true` puts a frame in the cell of the frame before it in its
132
134
  row, after it, with the same `step`: the cell's frames are one stack, its
133
135
  first frame on top. A note or a spec in a cell is not in its stack: it
@@ -71,8 +71,9 @@ only answer, leave the copy as it is: it is removed. A file's shared parts,
71
71
  (or `"slide"`). Unmarked, a comment on step one shows on whatever sits in
72
72
  its place on step two.
73
73
  - To link views, use `<a href="/files/<slug>/views/<view>">`:
74
- the frame moves to that view (and Play to its step). Links to other sites
75
- open in a new tab; links anywhere else go nowhere.
74
+ the frame moves to that view (and Play to the frame that shows it, in
75
+ any section). Links to other sites open in a new tab; links anywhere
76
+ else go nowhere.
76
77
  - Keep directions as separate views so they sit side by side as rows of one
77
78
  section on the canvas (`methods/explore.md`).
78
79
 
@@ -155,7 +156,8 @@ Check your own work before you show it, as much as the change needs: a
155
156
  person is waiting on the canvas while you check.
156
157
 
157
158
  - **Words, spacing, colour, one element.** Closing the thread with
158
- `close` checks the view's code, so nothing more. Without MCP, run
159
+ `close` checks the view's code, and that the comment's frame shows no
160
+ error and isn't blank, so nothing more. Without MCP, run
159
161
  `npx dex check`. No snapshot.
160
162
  - **A view's layout or states, or a new view.** With Dex running, look at
161
163
  each view you changed with `snapshot` (a state's `params`, and
@@ -1,100 +0,0 @@
1
- import { useLingui } from "@lingui/react/macro";
2
- import { type KeyboardEvent, memo } from "react";
3
-
4
- import { useCanvas } from "./canvas-context";
5
- import { moveStack } from "./canvas-model";
6
-
7
- export interface StackNodeData {
8
- /**
9
- * The cell's frames, by id, its first frame first: its stack, and any
10
- * words in it.
11
- */
12
- frames: string[];
13
- /** The first frame of the next cell to its right in its row, if any. */
14
- next?: string;
15
- row: string;
16
- section: string;
17
- /** The step its column is on. */
18
- step: number;
19
- /** How wide its first frame is: the handle is above its middle. */
20
- width: number;
21
- }
22
-
23
- /**
24
- * A stack's handle, above the name of its cell's first frame: drag it to
25
- * move the cell's frames, its stack and any words in it, along its row, into
26
- * another row or onto another stack. The left and right arrow keys move it a
27
- * step. It shows while the pointer is over the stack, on stacks of two or
28
- * more frames: a frame alone moves by itself.
29
- */
30
- export const StackNode = memo(({ data }: { data: StackNodeData }) => {
31
- const { t } = useLingui();
32
- const { editor } = useCanvas();
33
- const { frames, next, row, section, step, width } = data;
34
- const [first] = frames;
35
-
36
- const onKeyDown = (event: KeyboardEvent) => {
37
- const left = event.key === "ArrowLeft";
38
-
39
- if (!(first && (left || event.key === "ArrowRight"))) {
40
- return;
41
- }
42
-
43
- // Not the canvas's own arrow keys, which move the selection.
44
- event.preventDefault();
45
- event.stopPropagation();
46
-
47
- if (left && step > 1) {
48
- // Before the column to its left, which moves right to make room.
49
- editor.apply(
50
- (canvas) =>
51
- moveStack(
52
- canvas,
53
- { section, row, frame: first },
54
- {
55
- section,
56
- row,
57
- step: step - 1,
58
- }
59
- ).canvas
60
- );
61
- }
62
-
63
- if (!left && next) {
64
- // The stack to its right comes before it.
65
- editor.apply(
66
- (canvas) =>
67
- moveStack(
68
- canvas,
69
- { section, row, frame: next },
70
- {
71
- section,
72
- row,
73
- step,
74
- }
75
- ).canvas
76
- );
77
- }
78
- };
79
-
80
- return (
81
- // Above the middle of its first frame's name, clear of the name and of
82
- // its Play and Pick, at any zoom.
83
- <div
84
- className="studio-screen absolute top-0 flex origin-bottom -translate-x-1/2 -translate-y-full pb-8"
85
- // oxlint-disable-next-line shadcn/no-inline-styles -- computed at runtime: the middle of the stack's first frame
86
- style={{ left: width / 2 }}
87
- >
88
- <button
89
- aria-label={t`Move the stack: drag it, or press the left and right arrows`}
90
- className="studio-stack-handle pointer-events-auto"
91
- onKeyDown={onKeyDown}
92
- type="button"
93
- >
94
- <span aria-hidden className="studio-stack-dots" />
95
- </button>
96
- </div>
97
- );
98
- });
99
-
100
- StackNode.displayName = "StackNode";