@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
|
@@ -12,6 +12,22 @@ import { useCanvasView } from "./engine/canvas-view";
|
|
|
12
12
|
// from a link (?thread=<id>). An agent's replies show in the comments list,
|
|
13
13
|
// never as a pop-up.
|
|
14
14
|
|
|
15
|
+
const THREAD_PARAM = "thread";
|
|
16
|
+
|
|
17
|
+
const withoutThreadLink = (href: string): string => {
|
|
18
|
+
const url = new URL(href);
|
|
19
|
+
url.searchParams.delete(THREAD_PARAM);
|
|
20
|
+
|
|
21
|
+
return url.toString();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const dropThreadLinkFromAddress = () =>
|
|
25
|
+
window.history.replaceState(
|
|
26
|
+
window.history.state,
|
|
27
|
+
"",
|
|
28
|
+
withoutThreadLink(window.location.href)
|
|
29
|
+
);
|
|
30
|
+
|
|
15
31
|
/** Room around what the canvas moves to, as a share of its size. */
|
|
16
32
|
export const FOCUS_PADDING = 0.25;
|
|
17
33
|
|
|
@@ -82,7 +98,7 @@ export function useThreadFocus(
|
|
|
82
98
|
);
|
|
83
99
|
|
|
84
100
|
const linked = useRef(
|
|
85
|
-
new URLSearchParams(window.location.search).get(
|
|
101
|
+
new URLSearchParams(window.location.search).get(THREAD_PARAM)
|
|
86
102
|
);
|
|
87
103
|
|
|
88
104
|
useEffect(() => {
|
|
@@ -97,6 +113,7 @@ export function useThreadFocus(
|
|
|
97
113
|
// cancel the timer, and the next render starts it again.
|
|
98
114
|
const timer = window.setTimeout(() => {
|
|
99
115
|
linked.current = null;
|
|
116
|
+
dropThreadLinkFromAddress();
|
|
100
117
|
focus(thread);
|
|
101
118
|
}, FOCUS_MS);
|
|
102
119
|
|
|
@@ -88,8 +88,8 @@ const CURSORS: Record<ToolCursor, Cursor> = {
|
|
|
88
88
|
),
|
|
89
89
|
].join(""),
|
|
90
90
|
},
|
|
91
|
-
// A band across, below the crosshair: a section header goes
|
|
92
|
-
//
|
|
91
|
+
// A band across, below the crosshair: a section header goes where a note
|
|
92
|
+
// would, across what it is in, its top where the click is.
|
|
93
93
|
header: {
|
|
94
94
|
fallback: "crosshair",
|
|
95
95
|
hotspot: AIM,
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Toolbar } from "@base-ui/react/toolbar";
|
|
2
2
|
import { Button, buttonVariants } from "@studio/ui/shadcn/button";
|
|
3
3
|
import { cn } from "cn";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type ComponentProps,
|
|
6
|
+
type ReactElement,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
} from "react";
|
|
5
10
|
import { Link } from "wouter";
|
|
6
11
|
|
|
7
12
|
import { buttonsOverPage } from "../shell/window-buttons";
|
|
@@ -11,7 +16,9 @@ import { Tip, TipGroup } from "./tip";
|
|
|
11
16
|
// its bottom and Play's bar. One surface, one button, one separator, any
|
|
12
17
|
// other control joined to its arrow keys, and one tooltip that moves from
|
|
13
18
|
// control to control (TipGroup). On Base UI's Toolbar, as the WAI-ARIA
|
|
14
|
-
// toolbar pattern has it: one tab stop, the arrows between controls.
|
|
19
|
+
// toolbar pattern has it: one tab stop, the arrows between controls. Every
|
|
20
|
+
// control is 32px tall and at least 24px wide (CONTROL_SIZE), and the bar
|
|
21
|
+
// takes its height from them.
|
|
15
22
|
|
|
16
23
|
/** Where each of Dex's floating bars sits. */
|
|
17
24
|
const DOCKS = {
|
|
@@ -85,7 +92,7 @@ export const ToolbarSurface = ({
|
|
|
85
92
|
}) => (
|
|
86
93
|
<Toolbar.Root
|
|
87
94
|
aria-label={label}
|
|
88
|
-
className="studio-float text-popover-foreground flex
|
|
95
|
+
className="studio-float text-popover-foreground flex items-center gap-0.75 p-0.75"
|
|
89
96
|
>
|
|
90
97
|
<TipGroup>{children}</TipGroup>
|
|
91
98
|
</Toolbar.Root>
|
|
@@ -95,13 +102,27 @@ export const ToolbarSurface = ({
|
|
|
95
102
|
* A toolbar control's tint: the same 7% fill on hover and while its menu is
|
|
96
103
|
* open, and deeper while pressed, hovered or not, so a toggle such as X-ray
|
|
97
104
|
* shows it is on even under the pointer. No tool is accented. The toolbars'
|
|
98
|
-
*
|
|
99
|
-
* so shadcn's rules can read it.
|
|
105
|
+
* controls drawn elsewhere (the theme switch in toolbar.tsx, grid-panel.tsx)
|
|
106
|
+
* write it out, so shadcn's rules can read it.
|
|
100
107
|
*/
|
|
101
108
|
const TOOL_TINT =
|
|
102
109
|
"hover:bg-studio-hover aria-expanded:bg-studio-hover aria-pressed:bg-studio-pressed aria-pressed:hover:bg-studio-pressed";
|
|
103
110
|
|
|
104
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* A toolbar control's size: a 32px square. Every control on a toolbar is
|
|
113
|
+
* 32px tall and never narrower than 24px, the smallest target WCAG 2.2
|
|
114
|
+
* allows (2.5.8); a menu's button is as wide as what it shows
|
|
115
|
+
* (MENU_BUTTON_SIZE). Classes that go last, over the Button's own size: the
|
|
116
|
+
* Button may be the project's (`ui.primitives`), whose sizes are its own.
|
|
117
|
+
* The theme switch (toolbar.tsx) writes it out, so shadcn's rules can read
|
|
118
|
+
* it.
|
|
119
|
+
*/
|
|
120
|
+
const CONTROL_SIZE = "size-8";
|
|
121
|
+
|
|
122
|
+
/** A menu's button on a toolbar: 32px tall and at least 24px wide. */
|
|
123
|
+
const MENU_BUTTON_SIZE = "h-8 min-w-6 gap-0.5 px-1.5";
|
|
124
|
+
|
|
125
|
+
/** A toolbar control's look: flat, sized by CONTROL_SIZE. */
|
|
105
126
|
const look = { size: "icon-sm", variant: "ghost" } as const;
|
|
106
127
|
|
|
107
128
|
/**
|
|
@@ -135,7 +156,7 @@ export const ToolButton = ({
|
|
|
135
156
|
<Toolbar.Link
|
|
136
157
|
aria-keyshortcuts={keys ?? shortcut}
|
|
137
158
|
aria-label={label}
|
|
138
|
-
className={cn(buttonVariants(look),
|
|
159
|
+
className={cn(buttonVariants(look), CONTROL_SIZE, TOOL_TINT)}
|
|
139
160
|
render={<Link href={href} onClick={onClick} />}
|
|
140
161
|
>
|
|
141
162
|
{icon}
|
|
@@ -152,7 +173,8 @@ export const ToolButton = ({
|
|
|
152
173
|
render={
|
|
153
174
|
<Button
|
|
154
175
|
className={cn(
|
|
155
|
-
|
|
176
|
+
CONTROL_SIZE,
|
|
177
|
+
"aria-disabled:pointer-events-none aria-disabled:opacity-50",
|
|
156
178
|
TOOL_TINT
|
|
157
179
|
)}
|
|
158
180
|
{...look}
|
|
@@ -165,6 +187,24 @@ export const ToolButton = ({
|
|
|
165
187
|
</Tip>
|
|
166
188
|
);
|
|
167
189
|
|
|
190
|
+
/**
|
|
191
|
+
* The button of a menu on a toolbar, such as a split button's chevron or
|
|
192
|
+
* Play's Size: tinted as the toolbar's controls are, 32px tall, and as wide
|
|
193
|
+
* as what it shows, at least 24px (MENU_BUTTON_SIZE). The trigger's render,
|
|
194
|
+
* inside ToolbarControl; passes on the props and ref the trigger gives it.
|
|
195
|
+
*/
|
|
196
|
+
export const ToolbarMenuButton = ({
|
|
197
|
+
className,
|
|
198
|
+
...props
|
|
199
|
+
}: Omit<ComponentProps<typeof Button>, "size" | "variant">) => (
|
|
200
|
+
<Button
|
|
201
|
+
{...props}
|
|
202
|
+
className={cn(MENU_BUTTON_SIZE, TOOL_TINT, className)}
|
|
203
|
+
size="sm"
|
|
204
|
+
variant="ghost"
|
|
205
|
+
/>
|
|
206
|
+
);
|
|
207
|
+
|
|
168
208
|
/**
|
|
169
209
|
* Any other control in a toolbar, such as a menu's trigger, joined to its
|
|
170
210
|
* arrow keys. The control must pass on the props and ref it is given.
|
package/app/canvas/toolbar.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import type { MessageDescriptor } from "@lingui/core";
|
|
|
2
2
|
import { msg } from "@lingui/core/macro";
|
|
3
3
|
import { useLingui } from "@lingui/react/macro";
|
|
4
4
|
import { Icon } from "@studio/icons";
|
|
5
|
-
import { Button } from "@studio/ui/shadcn/button";
|
|
6
5
|
import {
|
|
7
6
|
DropdownMenu,
|
|
8
7
|
DropdownMenuContent,
|
|
@@ -31,6 +30,7 @@ import {
|
|
|
31
30
|
ToolButton,
|
|
32
31
|
ToolbarControl,
|
|
33
32
|
ToolbarSurface,
|
|
33
|
+
ToolbarMenuButton,
|
|
34
34
|
} from "./toolbar-parts";
|
|
35
35
|
import {
|
|
36
36
|
NOTE_TOOLS,
|
|
@@ -49,22 +49,22 @@ import {
|
|
|
49
49
|
// corner. Every tip along it is one tooltip (TipGroup), which moves from
|
|
50
50
|
// control to control.
|
|
51
51
|
|
|
52
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* The chevron of a split button, which opens its menu: a target of its own,
|
|
54
|
+
* the toolbar's height and at least 24px wide, as every control on it is.
|
|
55
|
+
*/
|
|
53
56
|
const SplitChevron = ({ label }: { label: string }) => (
|
|
54
57
|
<Tip label={label}>
|
|
55
58
|
<ToolbarControl
|
|
56
59
|
render={
|
|
57
60
|
<DropdownMenuTrigger
|
|
58
61
|
render={
|
|
59
|
-
<
|
|
62
|
+
<ToolbarMenuButton
|
|
60
63
|
aria-label={label}
|
|
61
|
-
|
|
62
|
-
className="text-muted-foreground hover:bg-studio-hover aria-expanded:bg-studio-hover aria-pressed:bg-studio-pressed aria-pressed:hover:bg-studio-pressed h-7 w-4 min-w-4 rounded-sm px-0"
|
|
63
|
-
size="icon-sm"
|
|
64
|
-
variant="ghost"
|
|
64
|
+
className="text-muted-foreground rounded-sm"
|
|
65
65
|
>
|
|
66
66
|
<Icon className="size-3" name="ChevronDown" size={12} />
|
|
67
|
-
</
|
|
67
|
+
</ToolbarMenuButton>
|
|
68
68
|
}
|
|
69
69
|
/>
|
|
70
70
|
}
|
|
@@ -315,7 +315,7 @@ export const Toolbar = ({
|
|
|
315
315
|
/>
|
|
316
316
|
) : null}
|
|
317
317
|
{/* Text (T), which writes on the canvas and in frames, or a section
|
|
318
|
-
header (⇧T), a band across
|
|
318
|
+
header (⇧T), its words large on a band across what it is in. */}
|
|
319
319
|
{offersTool("text", studio) ? (
|
|
320
320
|
<SplitButton
|
|
321
321
|
active={tool}
|
|
@@ -379,7 +379,9 @@ export const Toolbar = ({
|
|
|
379
379
|
<Tip label={t`Light or dark`}>
|
|
380
380
|
<ToolbarControl
|
|
381
381
|
render={
|
|
382
|
-
|
|
382
|
+
// A toolbar control's tint and size (TOOL_TINT,
|
|
383
|
+
// CONTROL_SIZE), written out so they can be checked.
|
|
384
|
+
<ThemeSwitch className="hover:bg-studio-hover aria-expanded:bg-studio-hover aria-pressed:bg-studio-pressed aria-pressed:hover:bg-studio-pressed size-8" />
|
|
383
385
|
}
|
|
384
386
|
/>
|
|
385
387
|
</Tip>
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from "react";
|
|
13
13
|
|
|
14
14
|
import type { PastedImage } from "../../src/shared/pasted-image.ts";
|
|
15
|
-
import type { PasteSource } from "../../src/shared/snapshot-clipboard.ts";
|
|
16
15
|
import { CAN_WRITE } from "../live/studio-api";
|
|
17
16
|
import type { Prototype } from "../registry";
|
|
18
17
|
import { carriesFiles, takeFileDrag } from "../ui/file-drop";
|
|
@@ -26,7 +25,7 @@ import {
|
|
|
26
25
|
readPasted,
|
|
27
26
|
} from "./canvas-clipboard.ts";
|
|
28
27
|
import type { CanvasCommands, Copied } from "./canvas-commands.ts";
|
|
29
|
-
import type { Clipboard } from "./canvas-document";
|
|
28
|
+
import type { Clipboard, Pasted as PasteMade } from "./canvas-document";
|
|
30
29
|
import type { Cell } from "./canvas-model";
|
|
31
30
|
import { useCanvasView } from "./engine/canvas-view";
|
|
32
31
|
import type { ClipCount, PastePlace } from "./frame-copies.ts";
|
|
@@ -120,9 +119,18 @@ const useClipboardWords = () => {
|
|
|
120
119
|
other: "# files weren't images, so they weren't added.",
|
|
121
120
|
}),
|
|
122
121
|
}),
|
|
123
|
-
snapshot: (
|
|
122
|
+
snapshot: ({
|
|
123
|
+
from,
|
|
124
|
+
saved,
|
|
125
|
+
images: missed,
|
|
126
|
+
sizedByScripts,
|
|
127
|
+
}: PasteMade) => {
|
|
128
|
+
const count = saved.length;
|
|
129
|
+
|
|
124
130
|
if (from === "extension") {
|
|
125
|
-
return
|
|
131
|
+
return sizedByScripts
|
|
132
|
+
? t`Pasted a snapshot. Part of it was sized by the page's scripts, so it keeps that size when you resize the frame.`
|
|
133
|
+
: t`Pasted a snapshot.`;
|
|
126
134
|
}
|
|
127
135
|
|
|
128
136
|
if (from === "image") {
|
|
@@ -210,7 +218,7 @@ export const useClipboard = ({
|
|
|
210
218
|
}
|
|
211
219
|
|
|
212
220
|
const said = result.ok
|
|
213
|
-
? now().words.snapshot(result
|
|
221
|
+
? now().words.snapshot(result)
|
|
214
222
|
: result.problems.join(" ");
|
|
215
223
|
|
|
216
224
|
now().say(leftOut ? `${said} ${leftOut}` : said);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { clearReveal, onStudioEvent, pendingReveal } from "../live/studio-live";
|
|
4
|
+
import { FIT_PADDING } from "./canvas-commands.ts";
|
|
5
|
+
import type { CanvasScene } from "./canvas-scene";
|
|
6
|
+
import { useCanvasView } from "./engine/canvas-view";
|
|
7
|
+
|
|
8
|
+
/** Room around a small frame shown: never closer in than this. */
|
|
9
|
+
const REVEAL_MIN_SIZE = { width: 800, height: 500 };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A snapshot just captured into this file, or a frame an agent asked to
|
|
13
|
+
* show: zoom to it once its frame is on the canvas, whether it arrives live
|
|
14
|
+
* or after a reload. The frame Play was on when it was left is kept in view:
|
|
15
|
+
* the canvas stays where it was looked at while that frame is on screen.
|
|
16
|
+
*/
|
|
17
|
+
export const useReveal = ({
|
|
18
|
+
scene,
|
|
19
|
+
showOthers,
|
|
20
|
+
slug,
|
|
21
|
+
}: {
|
|
22
|
+
scene: Pick<CanvasScene, "frame" | "hides">;
|
|
23
|
+
/** Show teammates' frames too, when the one to show is theirs. */
|
|
24
|
+
showOthers: () => void;
|
|
25
|
+
/** The file this canvas is: a reveal is for one file. */
|
|
26
|
+
slug: string;
|
|
27
|
+
}) => {
|
|
28
|
+
const view = useCanvasView();
|
|
29
|
+
const [reveal, setReveal] = useState(() => pendingReveal(slug));
|
|
30
|
+
useEffect(
|
|
31
|
+
() =>
|
|
32
|
+
onStudioEvent((event) => {
|
|
33
|
+
const revealed = event.type === "captured" || event.type === "show";
|
|
34
|
+
|
|
35
|
+
if (revealed && event.slug === slug) {
|
|
36
|
+
setReveal({ frame: event.frame, keepView: false });
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
[slug]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// The scene is laid out by the time this runs, and the canvas has taken
|
|
43
|
+
// its items: zoom as soon as the frame is in it. A teammate's, hidden
|
|
44
|
+
// while only yours shows, shows first: the next scene zooms.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!reveal) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (scene.hides(reveal.frame)) {
|
|
51
|
+
showOthers();
|
|
52
|
+
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const box = scene.frame(reveal.frame);
|
|
57
|
+
|
|
58
|
+
if (!box) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Kept in view, a frame on screen is shown already. Otherwise zoom to
|
|
63
|
+
// where the layout puts it, with room around a small one.
|
|
64
|
+
const width = Math.max(box.width, REVEAL_MIN_SIZE.width);
|
|
65
|
+
const height = Math.max(box.height, REVEAL_MIN_SIZE.height);
|
|
66
|
+
|
|
67
|
+
const shown =
|
|
68
|
+
(reveal.keepView && view.shows(box)) ||
|
|
69
|
+
view.fitBounds(
|
|
70
|
+
{
|
|
71
|
+
x: box.x - (width - box.width) / 2,
|
|
72
|
+
y: box.y - (height - box.height) / 2,
|
|
73
|
+
width,
|
|
74
|
+
height,
|
|
75
|
+
},
|
|
76
|
+
{ padding: FIT_PADDING, duration: 300 }
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// A canvas not yet on screen tries again with the next layout.
|
|
80
|
+
if (shown) {
|
|
81
|
+
clearReveal();
|
|
82
|
+
// oxlint-disable-next-line react/set-state-in-effect -- only the view, once laid out, knows the reveal is done
|
|
83
|
+
setReveal(undefined);
|
|
84
|
+
}
|
|
85
|
+
}, [view, scene, reveal, showOthers]);
|
|
86
|
+
};
|
package/app/editor/extensions.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
SlideDocument,
|
|
14
14
|
SlideText,
|
|
15
15
|
} from "./blocks";
|
|
16
|
+
import { LineBreakCaret } from "./line-break-caret";
|
|
16
17
|
import { SourceBlocks } from "./markdown-source";
|
|
17
18
|
|
|
18
19
|
// What a document on the canvas can hold: Dex's one editor, for the file
|
|
@@ -47,6 +48,7 @@ export const documentExtensions = ({
|
|
|
47
48
|
slide?: boolean;
|
|
48
49
|
} = {}): AnyExtension[] => [
|
|
49
50
|
StarterKit.configure(starterOptions(slide)),
|
|
51
|
+
LineBreakCaret,
|
|
50
52
|
TaskList,
|
|
51
53
|
TaskItem.configure({ nested: true }),
|
|
52
54
|
TableKit.configure({ table: { resizable: false } }),
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { type EditorState, Plugin } from "@tiptap/pm/state";
|
|
3
|
+
import type { EditorView } from "@tiptap/pm/view";
|
|
4
|
+
|
|
5
|
+
// WebKit (Safari, the Dex app) can draw the caret on the line it left.
|
|
6
|
+
// Shift+Enter on an empty line puts the new line break in front of the
|
|
7
|
+
// <br> that ends the line, and the caret back in front of that same <br>,
|
|
8
|
+
// now a line down. WebKit takes that as the place it was, so it goes on
|
|
9
|
+
// drawing the caret a line up while letters go on the new line, until the
|
|
10
|
+
// caret next blinks. ProseMirror sets the caret again after a <br> for
|
|
11
|
+
// WebKit, but only by moving it there, which WebKit ignores; taking the
|
|
12
|
+
// selection away first makes WebKit draw it afresh. Chromium and Firefox
|
|
13
|
+
// draw it where it is, so they skip this. Once prosemirror-view clears the
|
|
14
|
+
// selection there itself, this can go: e2e/line-break-caret.e2e.mjs checks.
|
|
15
|
+
|
|
16
|
+
/** WebKit, told apart as ProseMirror does: by the browser's maker. */
|
|
17
|
+
const inWebKit = (): boolean =>
|
|
18
|
+
typeof navigator !== "undefined" &&
|
|
19
|
+
(navigator.vendor ?? "").includes("Apple Computer");
|
|
20
|
+
|
|
21
|
+
/** Whether a line break, a <br>, is right before a place in the page. */
|
|
22
|
+
const afterLineBreak = (node: Node, offset: number): boolean =>
|
|
23
|
+
node.childNodes[offset - 1]?.nodeName === "BR";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* After a change to the text, has WebKit draw the caret again where it is,
|
|
27
|
+
* when it is right after a line break.
|
|
28
|
+
*/
|
|
29
|
+
const redrawCaret = (view: EditorView, before: EditorState) => {
|
|
30
|
+
const textChanged = view.state.doc !== before.doc;
|
|
31
|
+
const typing = view.state.selection.empty && view.hasFocus();
|
|
32
|
+
|
|
33
|
+
if (!textChanged || !typing || view.composing) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const selection = view.dom.ownerDocument.getSelection();
|
|
38
|
+
const node = selection?.focusNode;
|
|
39
|
+
const offset = selection?.focusOffset ?? 0;
|
|
40
|
+
|
|
41
|
+
const caretAfterBreak =
|
|
42
|
+
selection?.isCollapsed && node && afterLineBreak(node, offset);
|
|
43
|
+
|
|
44
|
+
if (!caretAfterBreak) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
selection.removeAllRanges();
|
|
49
|
+
selection.collapse(node, offset);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** The caret drawn on its own line after Shift+Enter, in WebKit too. */
|
|
53
|
+
export const LineBreakCaret = Extension.create({
|
|
54
|
+
name: "lineBreakCaret",
|
|
55
|
+
addProseMirrorPlugins: () =>
|
|
56
|
+
inWebKit() ? [new Plugin({ view: () => ({ update: redrawCaret }) })] : [],
|
|
57
|
+
});
|
package/app/git/branch-panel.tsx
CHANGED
|
@@ -43,6 +43,7 @@ import { useAgents } from "../live/studio-live";
|
|
|
43
43
|
import type { Prototype } from "../registry";
|
|
44
44
|
import { CopyText } from "../shell/copy-text";
|
|
45
45
|
import { OpenDefaultAgent } from "../shell/open-agent";
|
|
46
|
+
import { useFieldList } from "../ui/use-field-list.ts";
|
|
46
47
|
import { ChangeList, titleOf } from "./change-list";
|
|
47
48
|
import { Clash } from "./clash";
|
|
48
49
|
import { gitLook, STEPS, ToneButton, useAsk } from "./git-controls";
|
|
@@ -313,6 +314,9 @@ const OpenPullRequest = ({
|
|
|
313
314
|
);
|
|
314
315
|
};
|
|
315
316
|
|
|
317
|
+
const BRANCH_OPTION =
|
|
318
|
+
"flex h-7 shrink-0 cursor-default items-center gap-1.5 rounded-full px-3 text-sm font-medium whitespace-nowrap select-none hover:bg-studio-hover aria-selected:bg-studio-hover aria-disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0";
|
|
319
|
+
|
|
316
320
|
/** Every branch, local and on the remote, to find one by name. */
|
|
317
321
|
const AllBranchesDialog = ({
|
|
318
322
|
current,
|
|
@@ -326,13 +330,32 @@ const AllBranchesDialog = ({
|
|
|
326
330
|
const { t } = useLingui();
|
|
327
331
|
const [branches, setBranches] = useState<string[]>();
|
|
328
332
|
const [filter, setFilter] = useState("");
|
|
333
|
+
const [active, setActive] = useState(0);
|
|
329
334
|
useEffect(() => {
|
|
330
335
|
listBranches()
|
|
331
336
|
.then(setBranches)
|
|
332
337
|
.catch(() => setBranches([]));
|
|
333
338
|
}, []);
|
|
334
339
|
const query = filter.trim().toLowerCase();
|
|
335
|
-
|
|
340
|
+
|
|
341
|
+
const shown =
|
|
342
|
+
branches?.filter((name) => name.toLowerCase().includes(query)) ?? [];
|
|
343
|
+
|
|
344
|
+
const at = Math.min(active, shown.length - 1);
|
|
345
|
+
|
|
346
|
+
const switchTo = (name: string | undefined) => {
|
|
347
|
+
if (name && name !== current) {
|
|
348
|
+
onOpenChange(false);
|
|
349
|
+
onSwitch(name);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
const list = useFieldList({
|
|
354
|
+
active: at,
|
|
355
|
+
expanded: shown.length > 0,
|
|
356
|
+
onMove: (by) => setActive((at + by + shown.length) % shown.length),
|
|
357
|
+
onPick: (index) => switchTo(shown[index]),
|
|
358
|
+
});
|
|
336
359
|
|
|
337
360
|
return (
|
|
338
361
|
<Dialog onOpenChange={onOpenChange} open>
|
|
@@ -346,37 +369,55 @@ const AllBranchesDialog = ({
|
|
|
346
369
|
</DialogDescription>
|
|
347
370
|
</DialogHeader>
|
|
348
371
|
<Input
|
|
372
|
+
{...list.field}
|
|
349
373
|
aria-label={t`Find a branch`}
|
|
350
374
|
autoFocus
|
|
351
|
-
onChange={(event) =>
|
|
375
|
+
onChange={(event) => {
|
|
376
|
+
setFilter(event.target.value);
|
|
377
|
+
setActive(0);
|
|
378
|
+
}}
|
|
379
|
+
onKeyDown={(event) => {
|
|
380
|
+
if (
|
|
381
|
+
!list.moves(event) &&
|
|
382
|
+
event.key === "Enter" &&
|
|
383
|
+
!event.nativeEvent.isComposing
|
|
384
|
+
) {
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
switchTo(shown[at]);
|
|
387
|
+
}
|
|
388
|
+
}}
|
|
352
389
|
placeholder={t`Find a branch`}
|
|
353
390
|
spellCheck={false}
|
|
354
391
|
value={filter}
|
|
355
392
|
/>
|
|
356
393
|
<div className="-mx-2 flex max-h-80 flex-col overflow-auto">
|
|
357
|
-
{
|
|
358
|
-
{shown
|
|
394
|
+
{branches === undefined ? <Spinner className="m-2" /> : null}
|
|
395
|
+
{branches && shown.length === 0 ? (
|
|
359
396
|
<p className="studio-small text-muted-foreground p-2">
|
|
360
397
|
<Trans>No branch matches.</Trans>
|
|
361
398
|
</p>
|
|
362
399
|
) : null}
|
|
363
|
-
{shown
|
|
364
|
-
<
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
onClick={() => {
|
|
369
|
-
onOpenChange(false);
|
|
370
|
-
onSwitch(name);
|
|
371
|
-
}}
|
|
372
|
-
variant="ghost"
|
|
400
|
+
{shown.length > 0 ? (
|
|
401
|
+
<div
|
|
402
|
+
{...list.listbox}
|
|
403
|
+
aria-label={t`Branches`}
|
|
404
|
+
className="flex flex-col"
|
|
373
405
|
>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
406
|
+
{shown.map((name, index) => (
|
|
407
|
+
<div
|
|
408
|
+
{...list.option(index)}
|
|
409
|
+
aria-disabled={name === current ? true : undefined}
|
|
410
|
+
className={BRANCH_OPTION}
|
|
411
|
+
key={name}
|
|
412
|
+
>
|
|
413
|
+
<span className="truncate">{name}</span>
|
|
414
|
+
{name === current ? (
|
|
415
|
+
<Icon className="ml-auto" name="Check" />
|
|
416
|
+
) : null}
|
|
417
|
+
</div>
|
|
418
|
+
))}
|
|
419
|
+
</div>
|
|
420
|
+
) : null}
|
|
380
421
|
</div>
|
|
381
422
|
</DialogContent>
|
|
382
423
|
</Dialog>
|