@dexhq/canvas 0.14.0 → 0.16.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 +70 -0
- package/README.md +5 -3
- package/app/canvas/activity-parts.tsx +50 -6
- package/app/canvas/activity.tsx +10 -18
- package/app/canvas/agent-changes.ts +18 -8
- package/app/canvas/anchoring.ts +15 -7
- package/app/canvas/canvas-context.tsx +6 -2
- package/app/canvas/canvas-input.ts +186 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +7 -44
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +250 -27
- package/app/canvas/canvas-ui.ts +13 -3
- package/app/canvas/canvas.css +147 -29
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +270 -111
- package/app/canvas/element-link.ts +135 -0
- package/app/canvas/element-picker.ts +223 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/export-dialog.tsx +265 -0
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +83 -16
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-context-menu.tsx +61 -7
- package/app/canvas/frame-node.tsx +19 -20
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +68 -22
- package/app/canvas/linked-element.tsx +196 -0
- package/app/canvas/live-page.ts +156 -19
- package/app/canvas/mentions.tsx +209 -0
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/picked-box.tsx +21 -0
- package/app/canvas/removed-views-panel.tsx +4 -4
- package/app/canvas/request-node.tsx +151 -0
- package/app/canvas/review-panel.tsx +8 -3
- package/app/canvas/section-node.tsx +6 -133
- package/app/canvas/spec-margin.tsx +4 -1
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/teammates-layer.tsx +205 -0
- package/app/canvas/text-layer.tsx +103 -17
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/tool-cursors.ts +7 -6
- package/app/canvas/tool-icons.tsx +24 -56
- package/app/canvas/typing.ts +12 -0
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +40 -42
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/use-canvas-editor.ts +4 -2
- package/app/canvas/xray.ts +3 -12
- package/app/export/player-model.ts +159 -0
- package/app/export/player.tsx +198 -0
- package/app/export.html +31 -0
- package/app/export.tsx +9 -0
- package/app/frame/announce-refreshes.ts +21 -0
- package/app/frame/start-frame.tsx +50 -0
- package/app/frame/view-loads.ts +161 -0
- package/app/frame/views.ts +13 -49
- package/app/frame.tsx +2 -33
- package/app/i18n/locales/en/messages.po +233 -14
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +232 -13
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/dex-glyphs.tsx +219 -0
- package/app/icons/glyphs.tsx +80 -80
- package/app/kit/use-flow.ts +2 -1
- package/app/live/canvas-teammates.ts +90 -0
- package/app/live/studio-api.ts +30 -20
- package/app/main.tsx +3 -0
- package/app/pages/canvas.tsx +45 -14
- package/app/pages/commands-settings.tsx +17 -3
- package/app/pages/render.tsx +39 -11
- package/app/shell/bell.tsx +15 -5
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/presence.tsx +123 -26
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/shell/thread-list.tsx +25 -8
- package/app/shell/working-on.tsx +35 -3
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/prompt-editor.tsx +39 -11
- package/app/ui/reference.tsx +21 -8
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/bin/sudio.mjs +1 -1
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/create.d.mts +5 -5
- package/dist/cli/commands/create.mjs +4 -4
- package/dist/cli/commands/export.d.mts +40 -0
- package/dist/cli/commands/export.mjs +66 -0
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/cli/commands/init.d.mts +2 -2
- package/dist/cli/commands/upgrade.mjs +1 -1
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +13 -7
- package/dist/cli/main.d.mts +42 -5
- package/dist/cli/main.mjs +1 -0
- package/dist/config/load.mjs +14 -2
- package/dist/config/project-files.d.mts +11 -0
- package/dist/config/project-files.mjs +23 -2
- package/dist/config/renamed.d.mts +7 -2
- package/dist/config/renamed.mjs +13 -3
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/commands.d.mts +11 -9
- package/dist/content/commands.mjs +22 -16
- package/dist/content/comments-log.mjs +2 -1
- package/dist/content/content.d.mts +13 -143
- package/dist/content/content.mjs +55 -76
- package/dist/content/element-words.d.mts +42 -0
- package/dist/content/element-words.mjs +112 -0
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/hosted-person.d.mts +31 -0
- package/dist/content/hosted-person.mjs +68 -0
- package/dist/content/merge-rules.d.mts +5 -0
- package/dist/content/merge-rules.mjs +17 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/screenshot.mjs +9 -0
- package/dist/content/text-edit.d.mts +24 -14
- package/dist/content/text-edit.mjs +92 -81
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +285 -0
- package/dist/content/thread-module.d.mts +2 -4
- package/dist/content/thread-module.mjs +4 -5
- package/dist/content/threads.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/agents.d.mts +10 -0
- package/dist/server/agents.mjs +21 -6
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/canvas-presence.d.mts +22 -0
- package/dist/server/canvas-presence.mjs +160 -0
- package/dist/server/channel.d.mts +13 -24
- package/dist/server/channel.mjs +55 -37
- package/dist/server/claimed-presence.d.mts +3 -2
- package/dist/server/claimed-presence.mjs +15 -7
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/command-settings.mjs +1 -1
- package/dist/server/comments/actions.d.mts +145 -0
- package/dist/server/comments/actions.mjs +146 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +67 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +59 -23
- package/dist/server/export/build.d.mts +15 -0
- package/dist/server/export/build.mjs +220 -0
- package/dist/server/export/page.d.mts +25 -0
- package/dist/server/export/page.mjs +40 -0
- package/dist/server/export/plugin.d.mts +31 -0
- package/dist/server/export/plugin.mjs +69 -0
- package/dist/server/export/run.d.mts +9 -0
- package/dist/server/export/run.mjs +61 -0
- package/dist/server/export/save.d.mts +7 -0
- package/dist/server/export/save.mjs +29 -0
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/hosted.d.mts +8 -0
- package/dist/server/hosted.mjs +78 -0
- package/dist/server/live-mirror.mjs +66 -10
- package/dist/server/live.mjs +28 -1
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +9 -8
- package/dist/server/me.d.mts +3 -1
- package/dist/server/me.mjs +8 -2
- package/dist/server/notices.d.mts +1 -1
- package/dist/server/notices.mjs +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +1 -1
- package/dist/server/people.d.mts +8 -3
- package/dist/server/people.mjs +6 -2
- package/dist/server/pictures.d.mts +1 -1
- package/dist/server/pictures.mjs +2 -2
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/prebundle.d.mts +32 -0
- package/dist/server/prebundle.mjs +115 -0
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/problems.d.mts +8 -0
- package/dist/server/problems.mjs +13 -0
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +76 -78
- package/dist/server/source-stamp.d.mts +4 -3
- package/dist/server/source-stamp.mjs +60 -31
- package/dist/server/state.d.mts +19 -10
- package/dist/server/state.mjs +27 -18
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +17 -3
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.d.mts +8 -0
- package/dist/server/thread-source.mjs +25 -6
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/export.d.mts +5 -0
- package/dist/server/tools/export.mjs +35 -0
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/place-frame.mjs +16 -16
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +2 -2
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.d.mts +9 -4
- package/dist/server/vite.mjs +65 -63
- package/dist/server/web-app.mjs +4 -7
- package/dist/server/welcome.mjs +2 -1
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/apply.d.mts +4 -0
- package/dist/setup/apply.mjs +5 -4
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +72 -22
- package/dist/setup/design-system-checks.mjs +3 -17
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +19 -3
- package/dist/setup/detect/workspace.d.mts +10 -10
- package/dist/setup/detect/workspace.mjs +10 -12
- package/dist/setup/detect.d.mts +0 -2
- package/dist/setup/detect.mjs +1 -3
- package/dist/setup/doctor.d.mts +4 -1
- package/dist/setup/doctor.mjs +8 -6
- package/dist/setup/migrate/dex-folder.d.mts +61 -0
- package/dist/setup/migrate/dex-folder.mjs +544 -0
- package/dist/setup/migrate/files-folder.mjs +1 -1
- package/dist/setup/migrate/guides.mjs +1 -1
- package/dist/setup/migrate/migrations.mjs +4 -0
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/migrate/setup-files.d.mts +5 -0
- package/dist/setup/migrate/setup-files.mjs +115 -0
- package/dist/setup/migrate/studio-state.d.mts +2 -2
- package/dist/setup/migrate/studio-state.mjs +4 -4
- package/dist/setup/placement.d.mts +1 -1
- package/dist/setup/placement.mjs +5 -4
- package/dist/setup/plan.d.mts +5 -5
- package/dist/setup/plan.mjs +8 -12
- package/dist/setup/project.d.mts +6 -1
- package/dist/setup/project.mjs +10 -10
- package/dist/setup/prompts.d.mts +2 -1
- package/dist/setup/prompts.mjs +4 -3
- package/dist/setup/questions.mjs +3 -2
- package/dist/setup/starters.d.mts +3 -1
- package/dist/setup/starters.mjs +9 -3
- package/dist/setup/write.d.mts +15 -3
- package/dist/setup/write.mjs +23 -3
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.d.mts +22 -7
- package/dist/shared/canvas-core.mjs +39 -11
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +55 -0
- package/dist/shared/comments/routes.mjs +39 -0
- package/dist/shared/export-core.d.mts +62 -0
- package/dist/shared/export-core.mjs +101 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/live-core.d.mts +2 -0
- package/dist/shared/live-core.mjs +6 -1
- package/dist/shared/live-presence.d.mts +57 -2
- package/dist/shared/live-presence.mjs +90 -4
- package/dist/shared/page-messages.d.mts +14 -1
- package/dist/shared/page-messages.mjs +30 -3
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/people-core.d.mts +28 -0
- package/dist/shared/people-core.mjs +27 -1
- package/dist/shared/presence-core.d.mts +13 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/references-core.d.mts +4 -0
- package/dist/shared/references-core.mjs +12 -4
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +1 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +21 -0
- package/dist/shared/studio-files.mjs +16 -2
- package/dist/shared/studio-routes.d.mts +29 -63
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +29 -6
- package/dist/shared/threads-core.mjs +68 -13
- package/extension/dist/feedback.js +104 -284
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +104 -284
- package/package.json +2 -2
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/create.ts +4 -4
- package/src/cli/commands/export.ts +78 -0
- package/src/cli/commands/hook.ts +4 -1
- package/src/cli/commands/upgrade.ts +1 -1
- package/src/cli/help.ts +13 -7
- package/src/cli/main.ts +1 -0
- package/src/config/load.ts +26 -2
- package/src/config/project-files.ts +36 -6
- package/src/config/renamed.ts +19 -4
- package/src/content/capture.ts +6 -12
- package/src/content/commands.ts +30 -18
- package/src/content/comments-log.ts +4 -1
- package/src/content/content.ts +71 -257
- package/src/content/element-words.ts +175 -0
- package/src/content/flow-specs.ts +2 -1
- package/src/content/hosted-person.ts +107 -0
- package/src/content/merge-rules.ts +29 -0
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/screenshot.ts +14 -0
- package/src/content/text-edit.ts +172 -105
- package/src/content/text-replace.ts +420 -0
- package/src/content/thread-module.ts +2 -4
- package/src/content/trash.ts +1 -1
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/agents.ts +48 -17
- package/src/server/canvas-presence.ts +237 -0
- package/src/server/channel.ts +95 -53
- package/src/server/claimed-presence.ts +26 -10
- package/src/server/command-settings.ts +1 -1
- package/src/server/comments/actions.ts +333 -0
- package/src/server/comments/routes.ts +131 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +94 -33
- package/src/server/export/build.ts +310 -0
- package/src/server/export/page.ts +85 -0
- package/src/server/export/plugin.ts +138 -0
- package/src/server/export/run.ts +79 -0
- package/src/server/export/save.ts +38 -0
- package/src/server/file-lock.ts +205 -54
- package/src/server/hosted.ts +113 -0
- package/src/server/live-mirror.ts +93 -8
- package/src/server/live.ts +46 -1
- package/src/server/machine-update.ts +3 -3
- package/src/server/mcp.ts +15 -14
- package/src/server/me.ts +12 -6
- package/src/server/notices.ts +2 -2
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +13 -3
- package/src/server/pictures.ts +2 -2
- package/src/server/port.ts +94 -20
- package/src/server/prebundle.ts +230 -0
- package/src/server/presence.ts +12 -4
- package/src/server/problems.ts +11 -0
- package/src/server/requests.ts +115 -110
- package/src/server/roster.ts +1 -1
- package/src/server/saved.ts +1 -1
- package/src/server/source-stamp.ts +118 -37
- package/src/server/state.ts +53 -31
- package/src/server/studio-for.ts +26 -2
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/thread-source.ts +35 -3
- package/src/server/tools/export.ts +56 -0
- package/src/server/tools/place-frame.ts +23 -15
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/thread-list.ts +1 -1
- package/src/server/tools/watch.ts +7 -7
- package/src/server/updates.ts +2 -2
- package/src/server/vite.ts +106 -110
- package/src/server/web-app.ts +11 -9
- package/src/server/welcome.ts +3 -1
- package/src/setup/apply.ts +8 -5
- package/src/setup/create.ts +101 -27
- package/src/setup/design-system-checks.ts +8 -21
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +23 -2
- package/src/setup/detect/workspace.ts +20 -21
- package/src/setup/detect.ts +0 -4
- package/src/setup/doctor.ts +13 -6
- package/src/setup/migrate/dex-folder.ts +842 -0
- package/src/setup/migrate/files-folder.ts +1 -1
- package/src/setup/migrate/guides.ts +3 -1
- package/src/setup/migrate/migrations.ts +8 -2
- package/src/setup/migrate/setup-files.ts +198 -0
- package/src/setup/migrate/studio-state.ts +12 -10
- package/src/setup/own-app.ts +1 -1
- package/src/setup/placement.ts +7 -6
- package/src/setup/plan.ts +13 -18
- package/src/setup/project.ts +11 -10
- package/src/setup/prompts.ts +5 -4
- package/src/setup/questions.ts +6 -3
- package/src/setup/starters.ts +11 -4
- package/src/setup/write.ts +34 -3
- package/src/shared/canvas-core.ts +48 -9
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +81 -0
- package/src/shared/export-core.ts +198 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/live-core.ts +8 -0
- package/src/shared/live-presence.ts +171 -2
- package/src/shared/page-messages.ts +38 -2
- package/src/shared/page-review.ts +11 -16
- package/src/shared/people-core.ts +44 -0
- package/src/shared/presence-core.ts +18 -2
- package/src/shared/references-core.ts +22 -3
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +2 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +29 -1
- package/src/shared/studio-routes.ts +32 -65
- package/src/shared/threads-core.ts +134 -12
- package/templates/methods/explore.md +1 -1
- package/templates/methods/handoff.md +1 -1
- package/templates/methods/review.md +2 -1
- package/templates/rules/canvas-frames.md +6 -3
- package/templates/rules/commands.md +1 -0
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/studio.md +17 -11
- package/templates/skills/comprehend/SKILL.md +56 -0
- package/templates/skills/distill/SKILL.md +172 -0
- package/templates/skills/export-prototype/SKILL.md +35 -0
- package/templates/skills/riff/SKILL.md +21 -0
- package/templates/skills/riff-deep/SKILL.md +40 -0
- package/templates/skills/riff-max/SKILL.md +46 -0
- package/templates/skills/riff-state/SKILL.md +45 -0
- package/templates/skills/riff-up/SKILL.md +38 -0
- package/templates/skills/riff-wide/SKILL.md +40 -0
- package/templates/starters/standalone/README.md +1 -1
- package/templates/starters/turborepo/README.md +2 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
- package/templates/starters/vite/README.md +1 -1
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Find on a frame's page: the words it shows, where each match is, and the
|
|
2
|
+
// matches painted yellow. The paint is the browser's CSS Custom Highlight
|
|
3
|
+
// API, so the page's own elements are never touched: React keeps its tree,
|
|
4
|
+
// and nothing shifts as a match is marked. Only text a person can see is
|
|
5
|
+
// searched: not a script's, a style's, or what is hidden.
|
|
6
|
+
|
|
7
|
+
import { VIEW_RENDERED } from "../../src/shared/page-messages.ts";
|
|
8
|
+
|
|
9
|
+
/** A match on a page: where it is, and the text it is in. */
|
|
10
|
+
export interface PageHit {
|
|
11
|
+
range: Range;
|
|
12
|
+
/** The whole text the match is in, as the page has it. */
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The highlights' names, and how each paints. */
|
|
17
|
+
const HITS = "dex-find";
|
|
18
|
+
const CURRENT = "dex-find-current";
|
|
19
|
+
const STYLE_ID = "dex-find-style";
|
|
20
|
+
const STYLE = `::highlight(${HITS}){background-color:rgb(255 211 77 / 0.45);color:#0a0a0a}::highlight(${CURRENT}){background-color:#ffd34d;color:#0a0a0a}`;
|
|
21
|
+
|
|
22
|
+
const SKIPPED = new Set(["SCRIPT", "STYLE", "NOSCRIPT", "TEMPLATE", "TITLE"]);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether an element is shown: not hidden by the page, nor in its head. A
|
|
26
|
+
* page that is not laid out (its frame hidden under its picture, zoomed
|
|
27
|
+
* out) can only say what it hides itself, with `hidden`.
|
|
28
|
+
*/
|
|
29
|
+
const shown = (
|
|
30
|
+
element: Element,
|
|
31
|
+
seen: Map<Element, boolean>,
|
|
32
|
+
laidOut: boolean
|
|
33
|
+
): boolean => {
|
|
34
|
+
const known = seen.get(element);
|
|
35
|
+
if (known !== undefined) {
|
|
36
|
+
return known;
|
|
37
|
+
}
|
|
38
|
+
let visible = !SKIPPED.has(element.tagName);
|
|
39
|
+
if (visible && laidOut && typeof element.checkVisibility === "function") {
|
|
40
|
+
visible = element.checkVisibility();
|
|
41
|
+
} else if (visible && !laidOut) {
|
|
42
|
+
visible = element.closest("[hidden]") === null;
|
|
43
|
+
}
|
|
44
|
+
seen.set(element, visible);
|
|
45
|
+
return visible;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Each text on a page a person can read, in the page's order. */
|
|
49
|
+
export const pageTexts = (doc: Document): Text[] => {
|
|
50
|
+
const body = doc.body;
|
|
51
|
+
if (!body) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const seen = new Map<Element, boolean>();
|
|
55
|
+
const laidOut = (doc.documentElement?.getClientRects().length ?? 0) > 0;
|
|
56
|
+
const walker = doc.createTreeWalker(body, NodeFilter.SHOW_TEXT);
|
|
57
|
+
const texts: Text[] = [];
|
|
58
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
59
|
+
const text = node as Text;
|
|
60
|
+
const parent = text.parentElement;
|
|
61
|
+
if (text.data.trim() && parent && shown(parent, seen, laidOut)) {
|
|
62
|
+
texts.push(text);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return texts;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const SPECIAL_RE = /[.*+?^${}()|[\]\\]/g;
|
|
69
|
+
let finder: { query: string; re: RegExp } | undefined;
|
|
70
|
+
|
|
71
|
+
/** The one way words are matched, ignoring case: for finding and painting. */
|
|
72
|
+
export const matcherOf = (query: string): RegExp => {
|
|
73
|
+
if (finder?.query !== query) {
|
|
74
|
+
finder = {
|
|
75
|
+
query,
|
|
76
|
+
re: new RegExp(query.replace(SPECIAL_RE, "\\$&"), "gi"),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
finder.re.lastIndex = 0;
|
|
80
|
+
return finder.re;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Where `query` is in `text`, ignoring case: the start of each match, in the
|
|
85
|
+
* text as it is, so a letter that lowercases longer ("İ") moves no match.
|
|
86
|
+
*/
|
|
87
|
+
export const matchesIn = (text: string, query: string): number[] => {
|
|
88
|
+
const starts: number[] = [];
|
|
89
|
+
if (!query) {
|
|
90
|
+
return starts;
|
|
91
|
+
}
|
|
92
|
+
const re = matcherOf(query);
|
|
93
|
+
re.lastIndex = 0;
|
|
94
|
+
for (let found = re.exec(text); found; found = re.exec(text)) {
|
|
95
|
+
starts.push(found.index);
|
|
96
|
+
}
|
|
97
|
+
return starts;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Every match of `query` in a page's texts (pageTexts), up to `limit`. */
|
|
101
|
+
export const hitsIn = (
|
|
102
|
+
texts: readonly Text[],
|
|
103
|
+
query: string,
|
|
104
|
+
limit: number
|
|
105
|
+
): PageHit[] => {
|
|
106
|
+
const hits: PageHit[] = [];
|
|
107
|
+
for (const text of texts) {
|
|
108
|
+
for (const start of matchesIn(text.data, query)) {
|
|
109
|
+
if (hits.length >= limit) {
|
|
110
|
+
return hits;
|
|
111
|
+
}
|
|
112
|
+
const range = text.ownerDocument.createRange();
|
|
113
|
+
range.setStart(text, start);
|
|
114
|
+
range.setEnd(text, Math.min(text.length, start + query.length));
|
|
115
|
+
hits.push({ range, text: text.data });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return hits;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/** The page's highlight registry, where the browser has one. */
|
|
122
|
+
const registry = (doc: Document) => {
|
|
123
|
+
const view = doc.defaultView as
|
|
124
|
+
| (Window & { CSS?: { highlights?: HighlightRegistry } })
|
|
125
|
+
| null;
|
|
126
|
+
const highlights = view?.CSS?.highlights;
|
|
127
|
+
const Made = (view as (Window & { Highlight?: typeof Highlight }) | null)
|
|
128
|
+
?.Highlight;
|
|
129
|
+
return highlights && Made ? { highlights, Made } : undefined;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Paint matches on a page: each in a light yellow, the current one, if it is
|
|
134
|
+
* here, in the full yellow. No matches takes the paint off.
|
|
135
|
+
*/
|
|
136
|
+
export const paintHits = (
|
|
137
|
+
doc: Document,
|
|
138
|
+
hits: readonly PageHit[],
|
|
139
|
+
current: Range | undefined
|
|
140
|
+
) => {
|
|
141
|
+
const found = registry(doc);
|
|
142
|
+
if (!found) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const { highlights, Made } = found;
|
|
146
|
+
if (hits.length === 0) {
|
|
147
|
+
highlights.delete(HITS);
|
|
148
|
+
highlights.delete(CURRENT);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (!doc.getElementById(STYLE_ID)) {
|
|
152
|
+
const style = doc.createElement("style");
|
|
153
|
+
style.id = STYLE_ID;
|
|
154
|
+
style.textContent = STYLE;
|
|
155
|
+
(doc.head ?? doc.documentElement)?.append(style);
|
|
156
|
+
}
|
|
157
|
+
highlights.set(
|
|
158
|
+
HITS,
|
|
159
|
+
new Made(...hits.flatMap(({ range }) => (range === current ? [] : range)))
|
|
160
|
+
);
|
|
161
|
+
if (current) {
|
|
162
|
+
highlights.set(CURRENT, new Made(current));
|
|
163
|
+
} else {
|
|
164
|
+
highlights.delete(CURRENT);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/** Longest a page read off screen may take to render, in milliseconds. */
|
|
169
|
+
const READ_WAIT_MS = 8000;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The texts of a page that is not on the canvas, read in an iframe out of
|
|
173
|
+
* sight: once its view has rendered and painted, or when it is given up on,
|
|
174
|
+
* none. The iframe goes as soon as it has been read.
|
|
175
|
+
*/
|
|
176
|
+
export const readPageTexts = (
|
|
177
|
+
src: string,
|
|
178
|
+
size: { height: number; width: number }
|
|
179
|
+
): Promise<string[]> =>
|
|
180
|
+
new Promise((resolve) => {
|
|
181
|
+
const iframe = document.createElement("iframe");
|
|
182
|
+
iframe.setAttribute("aria-hidden", "true");
|
|
183
|
+
iframe.tabIndex = -1;
|
|
184
|
+
iframe.style.cssText = `position:fixed;left:-100000px;top:0;width:${size.width}px;height:${size.height}px;border:0;visibility:hidden;pointer-events:none`;
|
|
185
|
+
let done = false;
|
|
186
|
+
const finish = (texts: string[]) => {
|
|
187
|
+
if (done) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
done = true;
|
|
191
|
+
clearInterval(poll);
|
|
192
|
+
clearTimeout(timeout);
|
|
193
|
+
iframe.remove();
|
|
194
|
+
resolve(texts);
|
|
195
|
+
};
|
|
196
|
+
const read = () => {
|
|
197
|
+
let doc: Document | null = null;
|
|
198
|
+
try {
|
|
199
|
+
doc = iframe.contentDocument;
|
|
200
|
+
} catch {
|
|
201
|
+
finish([]);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const view = doc?.defaultView;
|
|
205
|
+
if (!(doc && view && doc.documentElement?.hasAttribute(VIEW_RENDERED))) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
clearInterval(poll);
|
|
209
|
+
// Painted once the next frame starts, as the canvas waits for it.
|
|
210
|
+
view.requestAnimationFrame(() =>
|
|
211
|
+
view.requestAnimationFrame(() =>
|
|
212
|
+
finish(pageTexts(doc).map(({ data }) => data))
|
|
213
|
+
)
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
const poll = setInterval(read, 50);
|
|
217
|
+
const timeout = setTimeout(() => finish([]), READ_WAIT_MS);
|
|
218
|
+
iframe.src = src;
|
|
219
|
+
document.body.append(iframe);
|
|
220
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// A style the studio adds to a frame's page and removes again, by its id;
|
|
2
|
+
// nothing else on the page is touched.
|
|
3
|
+
|
|
4
|
+
/** Add `css` to a page as the style `id`, once, or take it away. */
|
|
5
|
+
export function setPageStyle(
|
|
6
|
+
page: Document | null | undefined,
|
|
7
|
+
id: string,
|
|
8
|
+
css: string,
|
|
9
|
+
on: boolean
|
|
10
|
+
) {
|
|
11
|
+
if (!page?.head) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const existing = page.getElementById(id);
|
|
15
|
+
if (on && !existing) {
|
|
16
|
+
const style = page.createElement("style");
|
|
17
|
+
style.id = id;
|
|
18
|
+
style.textContent = css;
|
|
19
|
+
page.head.append(style);
|
|
20
|
+
} else if (!on && existing) {
|
|
21
|
+
existing.remove();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Box } from "./layout";
|
|
2
|
+
|
|
3
|
+
// An element outlined on a frame's page, as the comment tool tints what it
|
|
4
|
+
// picked: the open thread's elements, and what a link opened the canvas on.
|
|
5
|
+
|
|
6
|
+
/** Where a box sits on its page, as a style. */
|
|
7
|
+
export const boxStyle = ({ x, y, width, height }: Box) => ({
|
|
8
|
+
left: x,
|
|
9
|
+
top: y,
|
|
10
|
+
width,
|
|
11
|
+
height,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
/** One element's outline, over its box on the page. */
|
|
15
|
+
export const PickedBox = ({ box }: { box: Box }) => (
|
|
16
|
+
<div className="studio-pick z-20" data-picked style={boxStyle(box)} />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
/** A key for a box among others on a page. */
|
|
20
|
+
export const boxKey = ({ x, y, width, height }: Box) =>
|
|
21
|
+
`${x},${y},${width},${height}`;
|
|
@@ -29,7 +29,7 @@ import { useScheme, useViewPicture } from "./frame-pictures";
|
|
|
29
29
|
|
|
30
30
|
// "Removed from canvas": the views a delete on the canvas left behind, which
|
|
31
31
|
// nothing shows any more. Each can go back on the canvas, or, when it is
|
|
32
|
-
// yours, to the trash (.
|
|
32
|
+
// yours, to the trash (.local/trash/ in the Dex folder, on this machine) with the images only
|
|
33
33
|
// it shows. Near-copies sit together and each says where it was last, so
|
|
34
34
|
// views that look alike can be told apart.
|
|
35
35
|
|
|
@@ -267,9 +267,9 @@ const ConfirmDialog = ({
|
|
|
267
267
|
</Trans>
|
|
268
268
|
) : (
|
|
269
269
|
<Trans>
|
|
270
|
-
These files move to .
|
|
271
|
-
paths: copy one back to keep it. The trash
|
|
272
|
-
days.
|
|
270
|
+
These files move to .local/trash/ in the Dex folder, on this
|
|
271
|
+
machine, at their paths: copy one back to keep it. The trash
|
|
272
|
+
empties after 30 days.
|
|
273
273
|
</Trans>
|
|
274
274
|
)}
|
|
275
275
|
</DialogDescription>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Trans, useLingui } from "@lingui/react/macro";
|
|
2
|
+
import { Button } from "@studio/ui/shadcn/button";
|
|
3
|
+
import { memo, useMemo, useState } from "react";
|
|
4
|
+
import { threadState } from "../../src/shared/threads-core.ts";
|
|
5
|
+
import { STATE_LABELS } from "../live/thread-state";
|
|
6
|
+
import {
|
|
7
|
+
neighbourGuess,
|
|
8
|
+
Presence,
|
|
9
|
+
StillSkeleton,
|
|
10
|
+
sketchGuess,
|
|
11
|
+
} from "../shell/presence";
|
|
12
|
+
import type { Thread } from "../types";
|
|
13
|
+
import { useCanvas } from "./canvas-context";
|
|
14
|
+
import { useCanvasUi } from "./canvas-ui";
|
|
15
|
+
import { ResizeHandles, type Size } from "./frame-resize";
|
|
16
|
+
import { MessageWords } from "./mentions";
|
|
17
|
+
import { SketchPage } from "./sketch-boxes";
|
|
18
|
+
|
|
19
|
+
export interface RequestNodeData {
|
|
20
|
+
height: number;
|
|
21
|
+
/** Whether the person may move and resize it: a cell they may change. */
|
|
22
|
+
movable: boolean;
|
|
23
|
+
thread: Thread;
|
|
24
|
+
width: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const PendingStatus = ({
|
|
28
|
+
author,
|
|
29
|
+
status,
|
|
30
|
+
}: {
|
|
31
|
+
author?: string;
|
|
32
|
+
status: Thread["status"];
|
|
33
|
+
}) => {
|
|
34
|
+
if (status !== "acknowledged") {
|
|
35
|
+
return <Trans>Waiting for an agent</Trans>;
|
|
36
|
+
}
|
|
37
|
+
return author ? (
|
|
38
|
+
<Trans>{author} is building this</Trans>
|
|
39
|
+
) : (
|
|
40
|
+
<Trans>An agent is building this</Trans>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A request for a new view, in the cell it waits in until its view is
|
|
46
|
+
* there: all page, as what the person drew for it, else as the step before
|
|
47
|
+
* it in its row, else as any view in its section, with the request said
|
|
48
|
+
* above it, as a frame's name is. Dragged to another cell and resized as a
|
|
49
|
+
* frame is (flow-canvas.tsx): its thread keeps where it waits and its size,
|
|
50
|
+
* and the view is put there at that size.
|
|
51
|
+
*/
|
|
52
|
+
export const RequestNode = memo(({ data }: { data: RequestNodeData }) => {
|
|
53
|
+
const { editor, say, threads } = useCanvas();
|
|
54
|
+
const { i18n, t } = useLingui();
|
|
55
|
+
const { movable, thread } = data;
|
|
56
|
+
// Resized with the cursor, as a frame is.
|
|
57
|
+
const resizable = useCanvasUi((state) => state.tool === "select") && movable;
|
|
58
|
+
const [draft, setDraft] = useState<Size>();
|
|
59
|
+
const shown = { width: data.width, height: data.height };
|
|
60
|
+
const size = draft ?? shown;
|
|
61
|
+
const latest = thread.messages.at(-1);
|
|
62
|
+
const author = latest?.agent ? latest.author : undefined;
|
|
63
|
+
const waiting = thread.status !== "acknowledged";
|
|
64
|
+
const { sketch, target } = thread;
|
|
65
|
+
const section = target.kind === "view" ? target.section : undefined;
|
|
66
|
+
const row = target.kind === "view" ? target.row : undefined;
|
|
67
|
+
const guess = useMemo(() => {
|
|
68
|
+
if (sketch) {
|
|
69
|
+
return sketchGuess(sketch);
|
|
70
|
+
}
|
|
71
|
+
const prefixes = section ? [`${section}/`] : [];
|
|
72
|
+
if (section && row) {
|
|
73
|
+
prefixes.unshift(`${section}/${row}/`);
|
|
74
|
+
}
|
|
75
|
+
return neighbourGuess(prefixes);
|
|
76
|
+
}, [row, section, sketch]);
|
|
77
|
+
|
|
78
|
+
/** The size its view takes, or the frame's before it with none. */
|
|
79
|
+
const resize = async (next?: Size) => {
|
|
80
|
+
if (target.kind !== "view") {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const { size: _was, ...place } = target;
|
|
84
|
+
try {
|
|
85
|
+
await threads.send(thread.id, {
|
|
86
|
+
target: next ? { ...place, size: next } : place,
|
|
87
|
+
});
|
|
88
|
+
} catch {
|
|
89
|
+
say(t`The request was not resized. Try again.`);
|
|
90
|
+
} finally {
|
|
91
|
+
setDraft(undefined);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div className="studio-request relative" style={size}>
|
|
97
|
+
<div
|
|
98
|
+
className="studio-screen absolute bottom-full left-0 origin-bottom-left pb-1.5"
|
|
99
|
+
style={{ width: `calc(${size.width}px * var(--zoom))` }}
|
|
100
|
+
>
|
|
101
|
+
<div className="studio-small flex h-6 items-center gap-2 whitespace-nowrap text-muted-foreground">
|
|
102
|
+
<span className="shrink-0" role="status">
|
|
103
|
+
<PendingStatus author={author} status={thread.status} />
|
|
104
|
+
</span>
|
|
105
|
+
<span aria-hidden>·</span>
|
|
106
|
+
<span className="min-w-0 truncate text-foreground">
|
|
107
|
+
<MessageWords text={thread.messages[0]?.body ?? ""} />
|
|
108
|
+
</span>
|
|
109
|
+
{editor.editable ? (
|
|
110
|
+
<Button
|
|
111
|
+
className="nodrag nopan ml-auto shrink-0"
|
|
112
|
+
onClick={() => threads.send(thread.id, { status: "dismissed" })}
|
|
113
|
+
size="xs"
|
|
114
|
+
variant="ghost"
|
|
115
|
+
>
|
|
116
|
+
<Trans>Cancel</Trans>
|
|
117
|
+
</Button>
|
|
118
|
+
) : (
|
|
119
|
+
<span className="ml-auto shrink-0">
|
|
120
|
+
{i18n._(STATE_LABELS[threadState(thread)])}
|
|
121
|
+
</span>
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<div
|
|
126
|
+
className="studio-pending absolute inset-0 overflow-hidden"
|
|
127
|
+
data-waiting={waiting || undefined}
|
|
128
|
+
>
|
|
129
|
+
{sketch ? (
|
|
130
|
+
// What the person drew stays in sight while the page is built.
|
|
131
|
+
<div className="absolute top-0 left-0 opacity-80">
|
|
132
|
+
<SketchPage sketch={sketch} />
|
|
133
|
+
</div>
|
|
134
|
+
) : null}
|
|
135
|
+
{waiting && !sketch ? <StillSkeleton guess={guess} /> : null}
|
|
136
|
+
<Presence active={!waiting} blank guess={guess} />
|
|
137
|
+
</div>
|
|
138
|
+
{resizable ? (
|
|
139
|
+
<ResizeHandles
|
|
140
|
+
onDraft={setDraft}
|
|
141
|
+
onReset={
|
|
142
|
+
target.kind === "view" && target.size ? () => resize() : undefined
|
|
143
|
+
}
|
|
144
|
+
onResize={resize}
|
|
145
|
+
size={shown}
|
|
146
|
+
/>
|
|
147
|
+
) : null}
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
RequestNode.displayName = "RequestNode";
|
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
CommentsTools,
|
|
64
64
|
setCommentsAudience,
|
|
65
65
|
} from "./comments";
|
|
66
|
+
import { MessageWords } from "./mentions";
|
|
66
67
|
import { ReviewMarker } from "./review-marker";
|
|
67
68
|
import { matchesWords, placeOf } from "./thread-place";
|
|
68
69
|
import { VIEWPORTS } from "./viewports";
|
|
@@ -616,14 +617,16 @@ const ReviewComment = ({
|
|
|
616
617
|
</div>
|
|
617
618
|
</form>
|
|
618
619
|
) : (
|
|
619
|
-
<p className="whitespace-pre-wrap text-pretty">
|
|
620
|
+
<p className="whitespace-pre-wrap text-pretty">
|
|
621
|
+
<MessageWords text={first?.body ?? ""} />
|
|
622
|
+
</p>
|
|
620
623
|
)}
|
|
621
624
|
{replies.map((reply) => (
|
|
622
625
|
<p
|
|
623
626
|
className="studio-small mt-1 border-l-2 pl-2 text-muted-foreground"
|
|
624
627
|
key={reply.at}
|
|
625
628
|
>
|
|
626
|
-
{reply.author}: {reply.body}
|
|
629
|
+
{reply.author}: <MessageWords text={reply.body} />
|
|
627
630
|
</p>
|
|
628
631
|
))}
|
|
629
632
|
<div className={cn("absolute -top-1 right-0", locked && "hidden")}>
|
|
@@ -1324,7 +1327,9 @@ export const ReviewReport = () => {
|
|
|
1324
1327
|
{timeFormat.format(new Date(first.at))}
|
|
1325
1328
|
</time>
|
|
1326
1329
|
) : null}
|
|
1327
|
-
<p className="whitespace-pre-wrap text-pretty">
|
|
1330
|
+
<p className="whitespace-pre-wrap text-pretty">
|
|
1331
|
+
<MessageWords text={first?.body ?? ""} />
|
|
1332
|
+
</p>
|
|
1328
1333
|
</div>
|
|
1329
1334
|
<div
|
|
1330
1335
|
className="shrink-0 self-start overflow-hidden rounded-md ring-1 ring-border"
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { Trans, useLingui } from "@lingui/react/macro";
|
|
2
2
|
import { Icon } from "@studio/icons";
|
|
3
|
-
import {
|
|
4
|
-
import { memo, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { memo, useEffect, useState } from "react";
|
|
5
4
|
import { isOthers } from "../../src/shared/people-core.ts";
|
|
6
|
-
import {
|
|
7
|
-
import { STATE_LABELS } from "../live/thread-state";
|
|
8
|
-
import {
|
|
9
|
-
neighbourGuess,
|
|
10
|
-
Presence,
|
|
11
|
-
StillSkeleton,
|
|
12
|
-
sketchGuess,
|
|
13
|
-
} from "../shell/presence";
|
|
14
|
-
import type { Section, Thread } from "../types";
|
|
5
|
+
import type { Section } from "../types";
|
|
15
6
|
import { useCanvas } from "./canvas-context";
|
|
16
7
|
import { stepFrame, updateSection } from "./canvas-model";
|
|
17
8
|
import { useCanvasUi, useCanvasUiStore } from "./canvas-ui";
|
|
@@ -20,126 +11,15 @@ import { namesNow } from "./flow-naming";
|
|
|
20
11
|
import { resolveRenameTo, suggestRename } from "./flow-renames";
|
|
21
12
|
import { ResizeHandles, type Size } from "./frame-resize";
|
|
22
13
|
import { LabelAction } from "./label-action";
|
|
23
|
-
import {
|
|
24
|
-
type Box,
|
|
25
|
-
type PlacedSection,
|
|
26
|
-
sectionArea,
|
|
27
|
-
sectionSizeShowing,
|
|
28
|
-
} from "./layout";
|
|
29
|
-
import { SketchPage } from "./sketch-boxes";
|
|
14
|
+
import { type PlacedSection, sectionArea, sectionSizeShowing } from "./layout";
|
|
30
15
|
import { playHref } from "./viewports";
|
|
31
16
|
|
|
32
17
|
export interface SectionNodeData {
|
|
33
18
|
index: number;
|
|
34
19
|
layout: PlacedSection;
|
|
35
|
-
/** Requests for new views waiting in this section, with their cells. */
|
|
36
|
-
pending: { box: Box; thread: Thread }[];
|
|
37
20
|
section: Section;
|
|
38
21
|
}
|
|
39
22
|
|
|
40
|
-
const PendingStatus = ({
|
|
41
|
-
author,
|
|
42
|
-
status,
|
|
43
|
-
}: {
|
|
44
|
-
author?: string;
|
|
45
|
-
status: Thread["status"];
|
|
46
|
-
}) => {
|
|
47
|
-
if (status !== "acknowledged") {
|
|
48
|
-
return <Trans>Waiting for an agent</Trans>;
|
|
49
|
-
}
|
|
50
|
-
return author ? (
|
|
51
|
-
<Trans>{author} is building this</Trans>
|
|
52
|
-
) : (
|
|
53
|
-
<Trans>An agent is building this</Trans>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const PendingCell = ({
|
|
58
|
-
box,
|
|
59
|
-
origin,
|
|
60
|
-
thread,
|
|
61
|
-
}: {
|
|
62
|
-
box: Box;
|
|
63
|
-
origin: Box;
|
|
64
|
-
thread: Thread;
|
|
65
|
-
}) => {
|
|
66
|
-
const { editor, threads } = useCanvas();
|
|
67
|
-
const { i18n } = useLingui();
|
|
68
|
-
const latest = thread.messages.at(-1);
|
|
69
|
-
const author = latest?.agent ? latest.author : undefined;
|
|
70
|
-
const waiting = thread.status !== "acknowledged";
|
|
71
|
-
const { sketch, target } = thread;
|
|
72
|
-
const section = target.kind === "view" ? target.section : undefined;
|
|
73
|
-
const row = target.kind === "view" ? target.row : undefined;
|
|
74
|
-
// The page to come is drawn as what the person drew for it, else as the
|
|
75
|
-
// step before it in its row, else as any view in its section.
|
|
76
|
-
const guess = useMemo(() => {
|
|
77
|
-
if (sketch) {
|
|
78
|
-
return sketchGuess(sketch);
|
|
79
|
-
}
|
|
80
|
-
const prefixes = section ? [`${section}/`] : [];
|
|
81
|
-
if (section && row) {
|
|
82
|
-
prefixes.unshift(`${section}/${row}/`);
|
|
83
|
-
}
|
|
84
|
-
return neighbourGuess(prefixes);
|
|
85
|
-
}, [row, section, sketch]);
|
|
86
|
-
// The cell is all page, and the request is said above it, as a frame's
|
|
87
|
-
// name is.
|
|
88
|
-
return (
|
|
89
|
-
<div
|
|
90
|
-
className="pointer-events-auto absolute"
|
|
91
|
-
style={{
|
|
92
|
-
left: box.x - origin.x,
|
|
93
|
-
top: box.y - origin.y,
|
|
94
|
-
width: box.width,
|
|
95
|
-
height: box.height,
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
<div
|
|
99
|
-
className="studio-screen absolute bottom-full left-0 origin-bottom-left pb-1.5"
|
|
100
|
-
style={{ width: `calc(${box.width}px * var(--zoom))` }}
|
|
101
|
-
>
|
|
102
|
-
<div className="studio-small flex h-6 items-center gap-2 whitespace-nowrap text-muted-foreground">
|
|
103
|
-
<span className="shrink-0" role="status">
|
|
104
|
-
<PendingStatus author={author} status={thread.status} />
|
|
105
|
-
</span>
|
|
106
|
-
<span aria-hidden>·</span>
|
|
107
|
-
<span className="min-w-0 truncate text-foreground">
|
|
108
|
-
{thread.messages[0]?.body}
|
|
109
|
-
</span>
|
|
110
|
-
{editor.editable ? (
|
|
111
|
-
<Button
|
|
112
|
-
className="nodrag nopan ml-auto shrink-0"
|
|
113
|
-
onClick={() => threads.send(thread.id, { status: "dismissed" })}
|
|
114
|
-
size="xs"
|
|
115
|
-
variant="ghost"
|
|
116
|
-
>
|
|
117
|
-
<Trans>Cancel</Trans>
|
|
118
|
-
</Button>
|
|
119
|
-
) : (
|
|
120
|
-
<span className="ml-auto shrink-0">
|
|
121
|
-
{i18n._(STATE_LABELS[threadState(thread)])}
|
|
122
|
-
</span>
|
|
123
|
-
)}
|
|
124
|
-
</div>
|
|
125
|
-
</div>
|
|
126
|
-
<div
|
|
127
|
-
className="studio-pending absolute inset-0 overflow-hidden"
|
|
128
|
-
data-waiting={waiting || undefined}
|
|
129
|
-
>
|
|
130
|
-
{thread.sketch ? (
|
|
131
|
-
// What the person drew stays in sight while the page is built.
|
|
132
|
-
<div className="absolute top-0 left-0 opacity-80">
|
|
133
|
-
<SketchPage sketch={thread.sketch} />
|
|
134
|
-
</div>
|
|
135
|
-
) : null}
|
|
136
|
-
{waiting && !thread.sketch ? <StillSkeleton guess={guess} /> : null}
|
|
137
|
-
<Presence active={!waiting} blank guess={guess} />
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
23
|
/**
|
|
144
24
|
* Whose a section is, and the editor as it applies to it: someone else's
|
|
145
25
|
* section is theirs, shown and commented on, not changed. Naming it
|
|
@@ -190,7 +70,7 @@ export const SectionNode = memo(
|
|
|
190
70
|
);
|
|
191
71
|
const canvasEditable = canvas.editable;
|
|
192
72
|
const { t } = useLingui();
|
|
193
|
-
const { layout,
|
|
73
|
+
const { layout, section } = data;
|
|
194
74
|
const { editor, rename } = useSectionAuthor(section);
|
|
195
75
|
const firstRow = section.rows.find((row) =>
|
|
196
76
|
row.frames.some((frame) => stepFrame(frame))
|
|
@@ -222,6 +102,8 @@ export const SectionNode = memo(
|
|
|
222
102
|
className="studio-screen absolute bottom-full left-0 flex origin-bottom-left flex-col"
|
|
223
103
|
style={{ width: `calc(${layout.width}px * var(--zoom))` }}
|
|
224
104
|
>
|
|
105
|
+
{/* As tall as layout's SECTION_NAME_REMS: Play's line, taller than
|
|
106
|
+
the name's, and pb-2. */}
|
|
225
107
|
<div className="studio-reveal-group studio-section-handle @container pointer-events-auto flex select-none items-center gap-1 whitespace-nowrap pb-2">
|
|
226
108
|
<span className="studio-label shrink-0">
|
|
227
109
|
<EditableText
|
|
@@ -262,15 +144,6 @@ export const SectionNode = memo(
|
|
|
262
144
|
what="flow"
|
|
263
145
|
/>
|
|
264
146
|
) : null}
|
|
265
|
-
|
|
266
|
-
{pending.map(({ box, thread }) => (
|
|
267
|
-
<PendingCell
|
|
268
|
-
box={box}
|
|
269
|
-
key={thread.id}
|
|
270
|
-
origin={layout}
|
|
271
|
-
thread={thread}
|
|
272
|
-
/>
|
|
273
|
-
))}
|
|
274
147
|
</div>
|
|
275
148
|
);
|
|
276
149
|
}
|
|
@@ -12,6 +12,7 @@ import { Avatar } from "../shell/avatar";
|
|
|
12
12
|
import { useSpecHost } from "./canvas-context";
|
|
13
13
|
import { useCanvasUiStore } from "./canvas-ui";
|
|
14
14
|
import { ThreadBody } from "./comments";
|
|
15
|
+
import { MessageWords } from "./mentions";
|
|
15
16
|
|
|
16
17
|
// A spec's threads beside its words, each level with them, pushed down so
|
|
17
18
|
// none overlap. Three looks of one placement:
|
|
@@ -152,7 +153,9 @@ const ShortCard = ({
|
|
|
152
153
|
{t`Its words are gone from the spec.`}
|
|
153
154
|
</span>
|
|
154
155
|
) : null}
|
|
155
|
-
<span className="studio-small line-clamp-3">
|
|
156
|
+
<span className="studio-small line-clamp-3">
|
|
157
|
+
<MessageWords still text={first?.body ?? ""} />
|
|
158
|
+
</span>
|
|
156
159
|
</button>
|
|
157
160
|
);
|
|
158
161
|
};
|