@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.
- package/CHANGELOG.md +31 -0
- package/app/canvas/canvas-commands.ts +2 -10
- package/app/canvas/canvas-context.tsx +11 -2
- package/app/canvas/canvas-document.ts +5 -1
- package/app/canvas/canvas-keys.ts +1 -1
- package/app/canvas/canvas-model.ts +195 -20
- package/app/canvas/canvas-scene.ts +176 -171
- package/app/canvas/canvas-ui.ts +4 -11
- package/app/canvas/canvas.css +159 -179
- package/app/canvas/change-pictures.tsx +156 -0
- package/app/canvas/comment-drafts.ts +31 -0
- package/app/canvas/comment-layer.tsx +125 -71
- package/app/canvas/comments.tsx +38 -2
- package/app/canvas/element-picker.ts +20 -0
- package/app/canvas/engine/canvas-gestures.ts +15 -3
- package/app/canvas/engine/canvas-store.ts +5 -0
- package/app/canvas/engine/canvas-view.tsx +22 -5
- package/app/canvas/find-bar.tsx +57 -41
- package/app/canvas/flow-canvas.tsx +147 -272
- package/app/canvas/frame-copies.ts +14 -17
- package/app/canvas/frame-drops.ts +15 -7
- package/app/canvas/frame-inspector.ts +192 -41
- package/app/canvas/frame-node.tsx +123 -75
- package/app/canvas/frame-resize.tsx +321 -83
- package/app/canvas/insert-hint.tsx +5 -15
- package/app/canvas/inspect-layer.tsx +73 -19
- package/app/canvas/label-action.tsx +13 -2
- package/app/canvas/layout.ts +233 -98
- package/app/canvas/live-page.ts +5 -0
- package/app/canvas/new-frame.ts +10 -25
- package/app/canvas/note-placing.ts +55 -84
- package/app/canvas/picked-box.tsx +5 -0
- package/app/canvas/picks-menu.tsx +3 -9
- package/app/canvas/readable-colour.ts +52 -0
- package/app/canvas/request-node.tsx +19 -10
- package/app/canvas/scrolling-page.ts +45 -0
- package/app/canvas/section-node.tsx +36 -53
- package/app/canvas/settle.ts +21 -0
- package/app/canvas/snapping.ts +96 -8
- package/app/canvas/spec-frame.tsx +8 -5
- package/app/canvas/spot-pins.tsx +15 -3
- package/app/canvas/stack-frame.tsx +13 -57
- package/app/canvas/stack-model.ts +5 -0
- package/app/canvas/stack-toggle.tsx +89 -0
- package/app/canvas/styles-layer.tsx +23 -43
- package/app/canvas/text-layer.tsx +26 -10
- package/app/canvas/thread-focus.tsx +18 -1
- package/app/canvas/tool-cursors.ts +2 -2
- package/app/canvas/toolbar-parts.tsx +48 -8
- package/app/canvas/toolbar.tsx +12 -10
- package/app/canvas/use-canvas-clipboard.tsx +13 -5
- package/app/canvas/use-reveal.ts +86 -0
- package/app/editor/extensions.ts +2 -0
- package/app/editor/line-break-caret.ts +57 -0
- package/app/git/branch-panel.tsx +61 -20
- package/app/i18n/locales/en/messages.po +64 -17
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +64 -17
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/glyphs.tsx +2 -0
- package/app/live/studio-live.ts +29 -9
- package/app/pages/canvas.tsx +1 -1
- package/app/pages/commands-settings.tsx +70 -76
- package/app/pages/play-bar.tsx +6 -11
- package/app/pages/play.tsx +52 -33
- package/app/shell/feedback-form.tsx +29 -5
- package/app/ui/prompt-editor.tsx +2 -0
- package/app/ui/use-field-list.ts +90 -0
- package/dist/cli/commands/mcp.mjs +6 -4
- package/dist/cli/mcp-relay.mjs +10 -6
- package/dist/content/content.d.mts +26 -9
- package/dist/content/content.mjs +65 -8
- package/dist/content/screenshot.d.mts +2 -0
- package/dist/content/screenshot.mjs +3 -0
- package/dist/content/snapshot-client.d.mts +2 -0
- package/dist/content/snapshot-client.mjs +12 -1
- package/dist/inspector.js +96 -19
- package/dist/paste/paste.d.mts +5 -0
- package/dist/paste/paste.mjs +7 -2
- package/dist/server/agent-tools.d.mts +1 -0
- package/dist/server/agent-tools.mjs +4 -3
- package/dist/server/change-picture-store.d.mts +13 -0
- package/dist/server/change-picture-store.mjs +42 -0
- package/dist/server/change-pictures.d.mts +25 -0
- package/dist/server/change-pictures.mjs +104 -0
- package/dist/server/close-check.d.mts +11 -0
- package/dist/server/close-check.mjs +37 -5
- package/dist/server/comments/agent-actions.d.mts +8 -4
- package/dist/server/comments/agent-actions.mjs +16 -7
- package/dist/server/comments/close-tools.mjs +7 -5
- package/dist/server/comments/files.d.mts +5 -1
- package/dist/server/comments/hand-out.d.mts +1 -1
- package/dist/server/comments/hand-out.mjs +4 -1
- package/dist/server/comments/push.d.mts +19 -10
- package/dist/server/comments/push.mjs +45 -30
- package/dist/server/comments/studio-files.d.mts +14 -1
- package/dist/server/comments/studio-files.mjs +44 -31
- package/dist/server/comments/tools.d.mts +1 -1
- package/dist/server/comments/workspace.mjs +1 -0
- package/dist/server/dev-server.mjs +34 -0
- package/dist/server/own-copies.mjs +4 -23
- package/dist/server/requests.mjs +57 -3
- package/dist/server/response-budget.d.mts +2 -1
- package/dist/server/response-budget.mjs +4 -3
- package/dist/server/roster.d.mts +19 -8
- package/dist/server/roster.mjs +50 -22
- package/dist/server/studio-for.d.mts +7 -0
- package/dist/server/studio-for.mjs +23 -7
- package/dist/server/thread-forms.d.mts +3 -0
- package/dist/server/thread-forms.mjs +21 -1
- package/dist/server/tools/place-frame.d.mts +1 -0
- package/dist/server/tools/place-frame.mjs +33 -9
- package/dist/server/tools/result.mjs +2 -2
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/snapshot.mjs +2 -1
- package/dist/server/tools/studio-context.d.mts +2 -1
- package/dist/server/tools/studio-context.mjs +2 -1
- package/dist/server/tools/watch.mjs +29 -12
- package/dist/server/work-groups.mjs +1 -1
- package/dist/shared/canvas-core.d.mts +39 -5
- package/dist/shared/canvas-core.mjs +60 -15
- package/dist/shared/canvas-file.d.mts +7 -4
- package/dist/shared/change-pictures-core.d.mts +6 -0
- package/dist/shared/change-pictures-core.mjs +5 -0
- package/dist/shared/page-looks.d.mts +12 -0
- package/dist/shared/page-looks.mjs +49 -0
- package/dist/shared/snapshot-clipboard.d.mts +6 -0
- package/dist/shared/studio-routes.d.mts +11 -0
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +114 -108
- package/package.json +4 -3
- package/src/cli/commands/mcp.ts +18 -8
- package/src/cli/mcp-relay.ts +13 -6
- package/src/content/content.ts +90 -16
- package/src/content/screenshot.ts +9 -1
- package/src/content/snapshot-client.ts +17 -0
- package/src/paste/paste.ts +18 -1
- package/src/server/agent-tools.ts +5 -4
- package/src/server/change-picture-store.ts +71 -0
- package/src/server/change-pictures.ts +244 -0
- package/src/server/close-check.ts +69 -6
- package/src/server/comments/agent-actions.ts +51 -12
- package/src/server/comments/close-tools.ts +20 -10
- package/src/server/comments/files.ts +10 -2
- package/src/server/comments/hand-out.ts +2 -2
- package/src/server/comments/push.ts +94 -46
- package/src/server/comments/studio-files.ts +77 -46
- package/src/server/comments/workspace.ts +1 -0
- package/src/server/dev-server.ts +70 -0
- package/src/server/own-copies.ts +5 -33
- package/src/server/requests.ts +84 -4
- package/src/server/response-budget.ts +5 -3
- package/src/server/roster.ts +78 -28
- package/src/server/studio-for.ts +32 -7
- package/src/server/thread-forms.ts +41 -1
- package/src/server/tools/place-frame.ts +71 -14
- package/src/server/tools/result.ts +2 -2
- package/src/server/tools/snapshot.ts +2 -1
- package/src/server/tools/studio-context.ts +24 -14
- package/src/server/tools/watch.ts +38 -13
- package/src/server/work-groups.ts +1 -1
- package/src/shared/canvas-core.ts +119 -27
- package/src/shared/canvas-file.ts +7 -4
- package/src/shared/change-pictures-core.ts +8 -0
- package/src/shared/page-looks.ts +133 -0
- package/src/shared/snapshot-clipboard.ts +6 -0
- package/src/shared/studio-routes.ts +7 -1
- package/templates/agents/dex-worker.md +9 -7
- package/templates/feedback-workflow.md +1 -1
- package/templates/methods/review.md +7 -6
- package/templates/rules/canvas-frames.md +8 -7
- package/templates/rules/canvas.md +10 -8
- package/templates/rules/prototypes.md +5 -3
- package/app/canvas/stack-node.tsx +0 -100
package/app/live/studio-live.ts
CHANGED
|
@@ -327,27 +327,47 @@ export const agentNames = (entries: PresenceEntry[], i18n: I18n) => {
|
|
|
327
327
|
return i18n._(msg`${others} and ${last}`);
|
|
328
328
|
};
|
|
329
329
|
|
|
330
|
-
/**
|
|
331
|
-
|
|
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
|
|
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
|
|
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
|
|
348
|
-
export const revealFrame = (
|
|
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(
|
|
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
|
}
|
package/app/pages/canvas.tsx
CHANGED
|
@@ -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
|
|
136
|
-
? found
|
|
137
|
-
: SOURCES.flatMap(({ 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
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
event.
|
|
184
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
218
|
-
<Fragment key={command.name}>
|
|
219
|
-
{heading ? (
|
|
203
|
+
return (
|
|
220
204
|
<div
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
{
|
|
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
|
-
)
|
|
227
|
-
|
|
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
|
-
|
|
230
|
-
className="
|
|
231
|
-
|
|
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
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
|
|
240
|
+
);
|
|
241
|
+
})}
|
|
242
|
+
</div>
|
|
243
|
+
)}
|
|
250
244
|
</PopoverContent>
|
|
251
245
|
</Popover>
|
|
252
246
|
);
|
package/app/pages/play-bar.tsx
CHANGED
|
@@ -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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
<
|
|
389
|
+
<ToolbarMenuButton
|
|
393
390
|
aria-label={t`Frames: ${title}, ${position} of ${count}`}
|
|
394
|
-
className="studio-small
|
|
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
|
-
</
|
|
404
|
+
</ToolbarMenuButton>
|
|
410
405
|
}
|
|
411
406
|
/>
|
|
412
407
|
</div>
|
package/app/pages/play.tsx
CHANGED
|
@@ -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
|
|
604
|
-
* itself (frame/frame-app.tsx), and
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
848
|
-
* of another row or section plays that, from its
|
|
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
|
|
851
|
-
if (
|
|
852
|
-
go(steps.findIndex((entry) => entry.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(
|
|
859
|
+
playElsewhere(at);
|
|
858
860
|
};
|
|
859
861
|
|
|
860
|
-
|
|
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 (
|
|
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
|
|
880
|
+
const showing = linkedStep(canvas, playing, linked);
|
|
869
881
|
|
|
870
|
-
if (
|
|
871
|
-
|
|
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:
|
|
1037
|
-
//
|
|
1038
|
-
|
|
1039
|
-
const
|
|
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={
|
|
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
|
|
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 = ({
|
|
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
|
-
<
|
|
624
|
-
<
|
|
625
|
-
|
|
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
|
);
|
package/app/ui/prompt-editor.tsx
CHANGED
|
@@ -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
|
],
|