@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
@@ -327,27 +327,47 @@ export const agentNames = (entries: PresenceEntry[], i18n: I18n) => {
327
327
  return i18n._(msg`${others} and ${last}`);
328
328
  };
329
329
 
330
- /** A frame just captured into this prototype and not shown yet, if any. */
331
- export const pendingReveal = (slug: string) => {
330
+ /**
331
+ * A frame to show when its canvas next opens. Kept in view (`keepView`), the
332
+ * canvas moves only when it is not in view there, as on coming back from
333
+ * Play to where you were; otherwise the canvas zooms to it.
334
+ */
335
+ export interface Reveal {
336
+ frame: string;
337
+ keepView: boolean;
338
+ }
339
+
340
+ /** A frame not shown yet on this file's canvas, if any. */
341
+ export const pendingReveal = (slug: string): Reveal | undefined => {
332
342
  try {
333
- // SAFETY: only revealFrame writes this key, as a frame and its slug.
343
+ // SAFETY: only revealFrame writes this key, as a frame and its slug, and
344
+ // whether to keep the view (a studio before that left it out).
334
345
  const event = JSON.parse(
335
346
  window.sessionStorage.getItem(REVEAL_KEY) ?? "null"
336
- ) as { frame: string; slug: string } | null;
347
+ ) as { frame: string; keepView?: boolean; slug: string } | null;
337
348
 
338
- return event?.slug === slug ? event.frame : undefined;
349
+ return event?.slug === slug
350
+ ? { frame: event.frame, keepView: event.keepView ?? false }
351
+ : undefined;
339
352
  } catch {
340
353
  // Revealing is a convenience only.
341
354
  }
342
355
  };
343
356
 
344
- /** The captured frame has been shown. */
357
+ /** The frame has been shown. */
345
358
  export const clearReveal = () => window.sessionStorage.removeItem(REVEAL_KEY);
346
359
 
347
- /** Show a frame when its canvas next opens, as on coming back from playing. */
348
- export const revealFrame = (slug: string, frame: string) => {
360
+ /** Show a frame when its canvas next opens: kept in view, or zoomed to. */
361
+ export const revealFrame = (
362
+ slug: string,
363
+ frame: string,
364
+ { keepView = false }: { keepView?: boolean } = {}
365
+ ) => {
349
366
  try {
350
- window.sessionStorage.setItem(REVEAL_KEY, JSON.stringify({ slug, frame }));
367
+ window.sessionStorage.setItem(
368
+ REVEAL_KEY,
369
+ JSON.stringify({ slug, frame, keepView })
370
+ );
351
371
  } catch {
352
372
  // Revealing is a convenience only.
353
373
  }
@@ -76,7 +76,6 @@ import {
76
76
  import { FindBar } from "../canvas/find-bar";
77
77
  import { FlowCanvas } from "../canvas/flow-canvas";
78
78
  import { askName } from "../canvas/flow-naming";
79
- import { settle } from "../canvas/frame-node";
80
79
  import { CommentsOrReviewsBody } from "../canvas/imported-reviews";
81
80
  import { useInspectTools } from "../canvas/inspect-tools";
82
81
  import { LargeCanvasNotice } from "../canvas/large-canvas-notice";
@@ -108,6 +107,7 @@ import {
108
107
  import { CanvasSceneProvider } from "../canvas/scene-context";
109
108
  import { keepSelection } from "../canvas/selection";
110
109
  import { ServerNotice } from "../canvas/server-notice";
110
+ import { settle } from "../canvas/settle";
111
111
  import {
112
112
  drawingOn,
113
113
  runKeyAction,
@@ -16,13 +16,7 @@ import {
16
16
  import { Switch } from "@studio/ui/shadcn/switch";
17
17
  import { Textarea } from "@studio/ui/shadcn/textarea";
18
18
  import { cn } from "cn";
19
- import {
20
- type DragEvent,
21
- Fragment,
22
- type ReactNode,
23
- useId,
24
- useState,
25
- } from "react";
19
+ import { type DragEvent, Fragment, type ReactNode, useState } from "react";
26
20
 
27
21
  import {
28
22
  type Command,
@@ -40,6 +34,7 @@ import {
40
34
  SettingsCard,
41
35
  SettingsSection,
42
36
  } from "../shell/settings-ui";
37
+ import { useFieldList } from "../ui/use-field-list.ts";
43
38
 
44
39
  // Settings → Commands: skills people run from a comment by typing / in it,
45
40
  // "/break german". Dex ships some; the team's own are skills in the
@@ -106,12 +101,6 @@ const SOURCE_TITLES = {
106
101
  dex: msg`Built in`,
107
102
  };
108
103
 
109
- /** The keys that move through the list of skills, and which way. */
110
- const LIST_MOVES = new Map([
111
- ["ArrowDown", 1],
112
- ["ArrowUp", -1],
113
- ]);
114
-
115
104
  /**
116
105
  * Add to the quick bar from any number of skills: type to find one by its
117
106
  * name or what it does, grouped as the page groups them; ↑ ↓ move, Enter or
@@ -125,17 +114,21 @@ const SkillPicker = ({
125
114
  skills: readonly Command[];
126
115
  }) => {
127
116
  const { i18n, t } = useLingui();
128
- const id = useId();
129
117
  const [query, setQuery] = useState("");
130
118
  const [active, setActive] = useState(0);
131
119
  // Best matches first while searching; grouped by where they are from
132
120
  // when browsing.
133
121
  const found = findCommands(skills, query);
134
122
 
135
- const shown = query.trim()
136
- ? found
137
- : SOURCES.flatMap(({ of }) => found.filter(of));
123
+ const groups = query.trim()
124
+ ? [{ commands: found, id: undefined }]
125
+ : SOURCES.flatMap(({ id, of }) => {
126
+ const commands = found.filter(of);
138
127
 
128
+ return commands.length > 0 ? [{ commands, id }] : [];
129
+ });
130
+
131
+ const shown = groups.flatMap(({ commands }) => commands);
139
132
  const at = Math.min(active, shown.length - 1);
140
133
 
141
134
  const pick = (command: Command | undefined) => {
@@ -146,8 +139,12 @@ const SkillPicker = ({
146
139
  }
147
140
  };
148
141
 
149
- const groupOf = (command: Command) =>
150
- SOURCES.find(({ of }) => of(command))?.id ?? "dex";
142
+ const list = useFieldList({
143
+ active: at,
144
+ expanded: shown.length > 0,
145
+ onMove: (by) => setActive((at + by + shown.length) % shown.length),
146
+ onPick: (index) => pick(shown[index]),
147
+ });
151
148
 
152
149
  return (
153
150
  <Popover>
@@ -167,9 +164,7 @@ const SkillPicker = ({
167
164
  <Icon name="Search" />
168
165
  </InputGroupAddon>
169
166
  <InputGroupInput
170
- aria-activedescendant={shown[at] ? `${id}-${at}` : undefined}
171
- aria-controls={id}
172
- aria-expanded
167
+ {...list.field}
173
168
  aria-label={t`Search skills`}
174
169
  autoFocus
175
170
  onChange={(event) => {
@@ -177,76 +172,75 @@ const SkillPicker = ({
177
172
  setActive(0);
178
173
  }}
179
174
  onKeyDown={(event) => {
180
- const move = LIST_MOVES.get(event.key);
181
-
182
- if (move !== undefined && shown.length > 0) {
183
- event.preventDefault();
184
- setActive((at + move + shown.length) % shown.length);
185
- } else if (event.key === "Enter") {
175
+ if (
176
+ !list.moves(event) &&
177
+ event.key === "Enter" &&
178
+ !event.nativeEvent.isComposing
179
+ ) {
186
180
  event.preventDefault();
187
181
  pick(shown[at]);
188
182
  }
189
183
  }}
190
184
  placeholder={t`Search skills`}
191
- // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a search field that filters a list of its own, not a native <select> or <datalist>
192
- role="combobox"
193
185
  value={query}
194
186
  />
195
187
  </InputGroup>
196
188
  </div>
197
- <div
198
- aria-label={t`Skills`}
199
- className="flex max-h-80 flex-col overflow-y-auto p-1"
200
- id={id}
201
- // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a list of suggestions the field filters as it is typed in, which a native <select> or <datalist> cannot draw
202
- role="listbox"
203
- >
204
- {shown.length === 0 ? (
205
- <p className="studio-small text-muted-foreground px-2 py-3">
206
- <Trans>No matching skills</Trans>
207
- </p>
208
- ) : null}
209
- {shown.map((command, index) => {
210
- const group = groupOf(command);
211
-
212
- // SAFETY: past the first, the one before is in the list.
213
- const heading =
214
- !query.trim() &&
215
- (index === 0 || groupOf(shown[index - 1] as Command) !== group);
189
+ {shown.length === 0 ? (
190
+ <p className="studio-small text-muted-foreground px-3 py-4">
191
+ <Trans>No matching skills</Trans>
192
+ </p>
193
+ ) : (
194
+ <div
195
+ {...list.listbox}
196
+ aria-label={t`Skills`}
197
+ className="flex max-h-80 flex-col overflow-y-auto p-1"
198
+ >
199
+ {groups.map(({ commands, id }) => {
200
+ const options = commands.map((command) => {
201
+ const index = shown.indexOf(command);
216
202
 
217
- return (
218
- <Fragment key={command.name}>
219
- {heading ? (
203
+ return (
220
204
  <div
221
- className="studio-small text-muted-foreground px-2 pt-2 pb-1 first:pt-1"
222
- role="presentation"
205
+ {...list.option(index)}
206
+ className="aria-selected:bg-accent aria-selected:text-accent-foreground flex cursor-default flex-col rounded-md px-2 py-1.5"
207
+ key={command.name}
208
+ onMouseEnter={() => setActive(index)}
223
209
  >
224
- {i18n._(SOURCE_TITLES[group])}
210
+ <span>{spokenName(command.name)}</span>
211
+ {command.description ? (
212
+ <span className="studio-small text-muted-foreground truncate">
213
+ {command.description}
214
+ </span>
215
+ ) : null}
225
216
  </div>
226
- ) : null}
227
- {/* oxlint-disable-next-line jsx-a11y/click-events-have-key-events -- the search field's keys choose (arrows, Enter), as focus stays in it */}
217
+ );
218
+ });
219
+
220
+ if (!id) {
221
+ return <Fragment key="found">{options}</Fragment>;
222
+ }
223
+
224
+ const title = i18n._(SOURCE_TITLES[id]);
225
+
226
+ return (
228
227
  <div
229
- aria-selected={index === at}
230
- className="aria-selected:bg-accent aria-selected:text-accent-foreground flex cursor-default flex-col rounded-md px-2 py-1.5"
231
- id={`${id}-${index}`}
232
- onClick={() => pick(command)}
233
- onMouseDown={(event) => event.preventDefault()}
234
- onMouseEnter={() => setActive(index)}
235
- // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- one suggestion of the list above, drawn as the field needs it
236
- role="option"
237
- tabIndex={-1}
228
+ {...list.group(title)}
229
+ className="pt-1 first:pt-0"
230
+ key={id}
238
231
  >
239
- <span>{spokenName(command.name)}</span>
240
- {command.description ? (
241
- <span className="studio-small text-muted-foreground truncate">
242
- {command.description}
243
- </span>
244
- ) : null}
232
+ <div
233
+ aria-hidden
234
+ className="studio-small text-muted-foreground px-2 pt-1 pb-1"
235
+ >
236
+ {title}
237
+ </div>
238
+ {options}
245
239
  </div>
246
- </Fragment>
247
- );
248
- })}
249
- </div>
240
+ );
241
+ })}
242
+ </div>
243
+ )}
250
244
  </PopoverContent>
251
245
  </Popover>
252
246
  );
@@ -2,7 +2,6 @@ import type { MessageDescriptor } from "@lingui/core";
2
2
  import { msg } from "@lingui/core/macro";
3
3
  import { Trans, useLingui } from "@lingui/react/macro";
4
4
  import { Icon, type IconName } from "@studio/icons";
5
- import { Button } from "@studio/ui/shadcn/button";
6
5
  import {
7
6
  DropdownMenu,
8
7
  DropdownMenuContent,
@@ -36,6 +35,7 @@ import {
36
35
  ToolButton,
37
36
  ToolbarControl,
38
37
  ToolbarSurface,
38
+ ToolbarMenuButton,
39
39
  } from "../canvas/toolbar-parts";
40
40
  import { VIEWPORTS } from "../canvas/viewports";
41
41
  import { CAN_WRITE } from "../live/studio-api";
@@ -190,11 +190,8 @@ const SizeMenu = ({
190
190
  render={
191
191
  <DropdownMenuTrigger
192
192
  render={
193
- <Button
193
+ <ToolbarMenuButton
194
194
  aria-label={t`Size: ${i18n._(current.label)}`}
195
- className="h-7 gap-0.5 px-1.5"
196
- size="sm"
197
- variant="ghost"
198
195
  >
199
196
  <Icon name={current.icon} />
200
197
  <Icon
@@ -202,7 +199,7 @@ const SizeMenu = ({
202
199
  name="ChevronDown"
203
200
  size={12}
204
201
  />
205
- </Button>
202
+ </ToolbarMenuButton>
206
203
  }
207
204
  />
208
205
  }
@@ -389,11 +386,9 @@ export const PlayBar = ({
389
386
  label={t`Frames`}
390
387
  onPick={onPick}
391
388
  trigger={
392
- <Button
389
+ <ToolbarMenuButton
393
390
  aria-label={t`Frames: ${title}, ${position} of ${count}`}
394
- className="studio-small h-7 max-w-full items-center gap-2 px-2 font-normal"
395
- size="sm"
396
- variant="ghost"
391
+ className="studio-small max-w-full items-center gap-2 px-2 font-normal"
397
392
  >
398
393
  <span className="min-w-0 truncate font-medium">{title}</span>
399
394
  <span className="text-muted-foreground shrink-0 tabular-nums">
@@ -406,7 +401,7 @@ export const PlayBar = ({
406
401
  name="ChevronDown"
407
402
  size={12}
408
403
  />
409
- </Button>
404
+ </ToolbarMenuButton>
410
405
  }
411
406
  />
412
407
  </div>
@@ -32,6 +32,8 @@ import {
32
32
  import {
33
33
  adjacentRow,
34
34
  frameKey,
35
+ linkedStep,
36
+ type PlayAt,
35
37
  type PlayFrame,
36
38
  playFrames,
37
39
  playSteps,
@@ -495,9 +497,10 @@ const CommentOverlay = ({
495
497
  ) : null}
496
498
  </div>
497
499
  ) : null}
500
+ {/* The pointer goes through to the page's outline under it. */}
498
501
  {draftPoint ? (
499
502
  <div
500
- className="absolute flex -translate-y-full"
503
+ className="pointer-events-none absolute flex -translate-y-full"
501
504
  style={{ left: draftPoint.x * scale, top: draftPoint.y * scale }}
502
505
  >
503
506
  <DraftPin />
@@ -600,9 +603,8 @@ const isTaken = (target: EventTarget | null) =>
600
603
  (target instanceof Element && target.closest('[role="menu"]') !== null);
601
604
 
602
605
  /**
603
- * A link in the view to another view of the prototype: the frame moves there
604
- * itself (frame/frame-app.tsx), and the section follows to the step that shows
605
- * it, when one does.
606
+ * A link in the view to another view of the file: the frame moves there
607
+ * itself (frame/frame-app.tsx), and `toView` hears which view it went to.
606
608
  */
607
609
  const useViewLinks = (
608
610
  page: LivePage | null,
@@ -689,6 +691,7 @@ const Player = ({
689
691
  canvas,
690
692
  firstPlayed,
691
693
  onPlayed,
694
+ openedOn,
692
695
  prototype,
693
696
  rowId,
694
697
  section,
@@ -696,7 +699,10 @@ const Player = ({
696
699
  canvas: Canvas;
697
700
  /** The first section played since the page opened, not one stepped on to. */
698
701
  firstPlayed: boolean;
699
- onPlayed: () => void;
702
+ /** A frame is playing, by key: the first since the page opened is kept. */
703
+ onPlayed: (frame: string) => void;
704
+ /** The frame played first since the page opened, by key, once it is. */
705
+ openedOn: string | undefined;
700
706
  prototype: Prototype;
701
707
  rowId?: string;
702
708
  section: Section;
@@ -707,11 +713,10 @@ const Player = ({
707
713
  const params = new URLSearchParams(useSearch());
708
714
  const steps = playSteps(section, rowId ?? undefined);
709
715
 
710
- const start = useOnce(() =>
716
+ const [index, setIndex] = useState(() =>
711
717
  stepIndex(steps, Number(params.get("step") ?? 1))
712
718
  );
713
719
 
714
- const [index, setIndex] = useState(start);
715
720
  const [iframe, setIframe] = useState<HTMLIFrameElement | null>(null);
716
721
  const live = useLivePage(iframe);
717
722
  const [commenting, setCommenting] = useState(false);
@@ -722,7 +727,6 @@ const Player = ({
722
727
  // Hidden by a link or by you, the bar says how to get it back: not again on
723
728
  // stepping into the next section.
724
729
  const [justHidden, setJustHidden] = useState(firstPlayed && toolbarHidden);
725
- useEffect(() => onPlayed(), [onPlayed]);
726
730
 
727
731
  const toggleToolbar = () => {
728
732
  if (toolbarHidden) {
@@ -760,6 +764,7 @@ const Player = ({
760
764
  frame: keyOfFrame || undefined,
761
765
  view: view?.view,
762
766
  });
767
+ useEffect(() => onPlayed(keyOfFrame), [keyOfFrame, onPlayed]);
763
768
  const rowAt = section.rows.findIndex((row) => row.id === rowId);
764
769
  // Only a frame is named: what sets a row apart is in its frames' names.
765
770
  const stepTitle = designed?.title;
@@ -778,12 +783,8 @@ const Player = ({
778
783
  const playingRow = rowAt > 0 ? rowId : undefined;
779
784
 
780
785
  /** Another section or row, from its step, at the same size. */
781
- const playElsewhere = (
782
- flow: Section,
783
- row: string | undefined,
784
- step: number
785
- ) => {
786
- const href = playHref(prototype.href, flow.id, { row, step });
786
+ const playElsewhere = ({ section: target, row, step }: PlayAt) => {
787
+ const href = playHref(prototype.href, target.id, { row, step });
787
788
  const keep = new URLSearchParams();
788
789
 
789
790
  for (const name of ["size", "viewport", HIDE_UI]) {
@@ -811,7 +812,7 @@ const Player = ({
811
812
 
812
813
  const back = () => {
813
814
  if (before) {
814
- playElsewhere(before.section, before.row, before.step);
815
+ playElsewhere(before);
815
816
  } else {
816
817
  go(index - 1);
817
818
  }
@@ -819,7 +820,7 @@ const Player = ({
819
820
 
820
821
  const next = () => {
821
822
  if (after) {
822
- playElsewhere(after.section, after.row, after.step);
823
+ playElsewhere(after);
823
824
  } else {
824
825
  go(index + 1);
825
826
  }
@@ -844,31 +845,42 @@ const Player = ({
844
845
  .filter((flow) => flow.frames.length > 0);
845
846
 
846
847
  /**
847
- * A frame picked from the frames menu: a step of this row plays here; one
848
- * of another row or section plays that, from its step, at the same size.
848
+ * A frame picked from the frames menu, or one a link went to: a step of
849
+ * this row plays here; one of another row or section plays that, from its
850
+ * step, at the same size.
849
851
  */
850
- const pick = (flow: Section, frame: PlayFrame) => {
851
- if (flow.id === section.id && frame.row === playingRow) {
852
- go(steps.findIndex((entry) => entry.step === frame.step));
852
+ const playAt = (at: PlayAt) => {
853
+ if (at.section.id === section.id && at.row === playingRow) {
854
+ go(steps.findIndex((entry) => entry.step === at.step));
853
855
 
854
856
  return;
855
857
  }
856
858
 
857
- playElsewhere(flow, frame.row, frame.step);
859
+ playElsewhere(at);
858
860
  };
859
861
 
860
- /** Back on the canvas, show the frame you were on if you moved. */
862
+ const pick = (target: Section, frame: PlayFrame) =>
863
+ playAt({ section: target, row: frame.row, step: frame.step });
864
+
865
+ /**
866
+ * Back on the canvas as it was, when you leave from the frame Play opened
867
+ * on. From another, it keeps that frame in view, moving only if it is off
868
+ * screen there.
869
+ */
861
870
  const leave = () => {
862
- if (index !== start && keyOfFrame) {
863
- revealFrame(prototype.slug, keyOfFrame);
871
+ if (keyOfFrame && keyOfFrame !== openedOn) {
872
+ revealFrame(prototype.slug, keyOfFrame, { keepView: true });
864
873
  }
865
874
  };
866
875
 
876
+ // A link takes Play to the step that shows where the live page went,
877
+ // wherever it is on the canvas, so the bar, comments, the agent and leaving
878
+ // all follow it. A view no step shows leaves Play on this one.
867
879
  useViewLinks(live, (linked) => {
868
- const at = steps.findIndex((entry) => entry.frame.view === linked);
880
+ const showing = linkedStep(canvas, playing, linked);
869
881
 
870
- if (at !== -1 && at !== index) {
871
- go(at);
882
+ if (showing) {
883
+ playAt(showing);
872
884
  }
873
885
  });
874
886
  usePlayKeys(live, {
@@ -1033,10 +1045,16 @@ export const PlayPage = () => {
1033
1045
  const { slug = "", section: sectionId = "" } = useParams();
1034
1046
  const rowParam = new URLSearchParams(useSearch()).get("row");
1035
1047
  const prototype = findPrototype(slug);
1036
- // Kept across sections, which each play afresh: only the first is played
1037
- // as the page opens.
1038
- const [played, setPlayed] = useState(false);
1039
- const markPlayed = useCallback(() => setPlayed(true), []);
1048
+ // Kept across sections, which each play afresh: the frame played first as
1049
+ // the page opened, so only the first section is played as it opens, and
1050
+ // leaving from that frame leaves the canvas as it was.
1051
+ const [openedOn, setOpenedOn] = useState<string>();
1052
+
1053
+ const markPlayed = useCallback(
1054
+ (frame: string) => setOpenedOn((first) => first ?? frame),
1055
+ []
1056
+ );
1057
+
1040
1058
  // The canvas as saved now, not as the page loaded: a section made since then
1041
1059
  // is only there. A generated canvas has nothing saved to ask for.
1042
1060
  const saved = useSavedCanvas(slug);
@@ -1063,9 +1081,10 @@ export const PlayPage = () => {
1063
1081
  return (
1064
1082
  <Player
1065
1083
  canvas={canvas}
1066
- firstPlayed={!played}
1084
+ firstPlayed={openedOn === undefined}
1067
1085
  key={`${section.id}/${rowId}`}
1068
1086
  onPlayed={markPlayed}
1087
+ openedOn={openedOn}
1069
1088
  prototype={prototype}
1070
1089
  rowId={rowId}
1071
1090
  section={section}
@@ -111,6 +111,7 @@ export const FeedbackForm = ({
111
111
  const [files, setFiles] = useState<File[]>([]);
112
112
  const [withDetails, setWithDetails] = useState(true);
113
113
  const [status, setStatus] = useState<Status>({ step: "writing" });
114
+ const [writingAnother, setWritingAnother] = useState(false);
114
115
 
115
116
  const feedback: Feedback = {
116
117
  kind,
@@ -142,6 +143,13 @@ export const FeedbackForm = ({
142
143
  );
143
144
  };
144
145
 
146
+ const writeAnother = () => {
147
+ setMessage("");
148
+ setFiles([]);
149
+ setWritingAnother(true);
150
+ setStatus({ step: "writing" });
151
+ };
152
+
145
153
  const attach = (more: File[]) =>
146
154
  // Every file, so one it can't take stays to say why, not vanish.
147
155
  setFiles((current) => [...current, ...more]);
@@ -150,7 +158,9 @@ export const FeedbackForm = ({
150
158
  const { over, zone } = useFileDrop(attach);
151
159
 
152
160
  if (status.step === "sent") {
153
- return <Thanks email={status.email} onClose={onClose} />;
161
+ return (
162
+ <Thanks email={status.email} onAnother={writeAnother} onClose={onClose} />
163
+ );
154
164
  }
155
165
 
156
166
  const failures: Record<Failure, string> = {
@@ -208,6 +218,7 @@ export const FeedbackForm = ({
208
218
  <Textarea
209
219
  aria-describedby={`${ids}-message-hint`}
210
220
  aria-invalid={message.trim().length > MAX_MESSAGE || undefined}
221
+ autoFocus={writingAnother}
211
222
  className="max-h-60 min-h-28"
212
223
  id={`${ids}-message`}
213
224
  onChange={(event) => setMessage(event.target.value)}
@@ -604,7 +615,15 @@ const Thumbnail = ({ file }: { file: File }) => {
604
615
  };
605
616
 
606
617
  /** Sent: thanks, where a reply would go, and a way out. */
607
- const Thanks = ({ email, onClose }: { email: string; onClose: () => void }) => (
618
+ const Thanks = ({
619
+ email,
620
+ onAnother,
621
+ onClose,
622
+ }: {
623
+ email: string;
624
+ onAnother: () => void;
625
+ onClose: () => void;
626
+ }) => (
608
627
  <div className="flex flex-col items-center gap-3 px-6 py-10 text-center">
609
628
  <span className="bg-muted flex size-10 items-center justify-center rounded-xl">
610
629
  <Icon className="size-5" name="CircleCheck" />
@@ -620,8 +639,13 @@ const Thanks = ({ email, onClose }: { email: string; onClose: () => void }) => (
620
639
  </Trans>
621
640
  </p>
622
641
  ) : null}
623
- <Button className="mt-2" onClick={onClose} type="button" variant="outline">
624
- <Trans>Done</Trans>
625
- </Button>
642
+ <div className="mt-2 flex flex-wrap justify-center gap-2">
643
+ <Button onClick={onAnother} type="button" variant="outline">
644
+ <Trans>Add more</Trans>
645
+ </Button>
646
+ <Button onClick={onClose} type="button" variant="outline">
647
+ <Trans>Done</Trans>
648
+ </Button>
649
+ </div>
626
650
  </div>
627
651
  );
@@ -22,6 +22,7 @@ import {
22
22
  referenceText,
23
23
  triggerAt,
24
24
  } from "../../src/shared/references-core.ts";
25
+ import { LineBreakCaret } from "../editor/line-break-caret";
25
26
  import {
26
27
  REFERENCE_CLASS,
27
28
  Reference,
@@ -465,6 +466,7 @@ export const PromptEditor = ({
465
466
  const editor = useEditor({
466
467
  extensions: [
467
468
  PLAIN_TEXT,
469
+ LineBreakCaret,
468
470
  ReferenceNode,
469
471
  Placeholder.configure({ placeholder: () => now.current.placeholder }),
470
472
  ],