kaizen-agent 1.86.0 → 1.87.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/README.md +1 -1
- package/cli/annotate-proxy.ts +6 -3
- package/cli/build-web.ts +46 -16
- package/cli/dev.ts +67 -0
- package/cli/docs.ts +1 -1
- package/cli/notes.ts +9 -3
- package/cli/ports.ts +121 -0
- package/cli/settings.ts +16 -17
- package/cli/state.ts +15 -29
- package/cli/task-service.ts +44 -14
- package/cli/tasks.ts +1 -1
- package/cli/term-image.ts +18 -0
- package/cli/ui-audit.allow.json +0 -1
- package/cli/ui-audit.ts +12 -12
- package/cli/web.ts +182 -58
- package/package.json +21 -4
- package/skills/kaizen/spec.md +10 -3
- package/tsconfig.json +16 -0
- package/web/README.md +105 -0
- package/web/{annotate.js → annotate/annotate.ts} +51 -50
- package/web/boot/boot.ts +7 -0
- package/web/components/annotate/annotate-bar.tsx +78 -0
- package/web/components/annotate/annotate-panel.tsx +20 -0
- package/web/components/annotate/annotate-settings.tsx +60 -0
- package/web/components/annotate/index.ts +1 -0
- package/web/components/annotate/notes-list.tsx +75 -0
- package/web/components/board/board-card.tsx +177 -0
- package/web/components/board/board-column.tsx +212 -0
- package/web/components/board/board-mode-switch.tsx +21 -0
- package/web/components/board/board-popups.tsx +45 -0
- package/web/components/board/card-footer.tsx +58 -0
- package/web/components/board/card-form.tsx +168 -0
- package/web/components/board/card-kids.tsx +53 -0
- package/web/components/board/clear-menu.tsx +36 -0
- package/web/components/board/filter-box.tsx +42 -0
- package/web/components/board/index.ts +6 -0
- package/web/components/board/run-form.tsx +129 -0
- package/web/components/board/severity-menu.tsx +44 -0
- package/web/components/board/status-strip.tsx +75 -0
- package/web/components/board/task-form.tsx +140 -0
- package/web/components/board/ws-card.tsx +38 -0
- package/web/components/context/context-panel.tsx +244 -0
- package/web/components/context/index.ts +1 -0
- package/web/components/decision/decision-bar.tsx +422 -0
- package/web/components/decision/index.ts +1 -0
- package/web/components/decision/inline-form.tsx +47 -0
- package/web/components/decision/plan-answers-form.tsx +78 -0
- package/web/components/decision/revise-form.tsx +65 -0
- package/web/components/decision/task-reply-form.tsx +48 -0
- package/web/components/footer/foot-bar.tsx +67 -0
- package/web/components/footer/index.ts +1 -0
- package/web/components/git/git-ask.tsx +88 -0
- package/web/components/git/git-commits.tsx +53 -0
- package/web/components/git/git-confirm.tsx +78 -0
- package/web/components/git/git-counts.tsx +10 -0
- package/web/components/git/git-files.tsx +113 -0
- package/web/components/git/git-head.tsx +70 -0
- package/web/components/git/git-icon.tsx +25 -0
- package/web/components/git/git-message.tsx +44 -0
- package/web/components/git/git-split.tsx +64 -0
- package/web/components/git/git-tab.tsx +55 -0
- package/web/components/git/index.ts +1 -0
- package/web/components/home/chat-list.tsx +57 -0
- package/web/components/home/home-composer.tsx +169 -0
- package/web/components/home/home-message.tsx +120 -0
- package/web/components/home/home-window.tsx +253 -0
- package/web/components/home/home-ws-add.tsx +47 -0
- package/web/components/home/index.ts +6 -0
- package/web/components/home/onboarding-dialog.tsx +371 -0
- package/web/components/icebox/board-chip.tsx +27 -0
- package/web/components/icebox/board-menu.tsx +41 -0
- package/web/components/icebox/bulk-bar.tsx +41 -0
- package/web/components/icebox/capture-box.tsx +155 -0
- package/web/components/icebox/choice-menu.tsx +39 -0
- package/web/components/icebox/collection-dialog.tsx +60 -0
- package/web/components/icebox/favicon.tsx +39 -0
- package/web/components/icebox/index.ts +10 -0
- package/web/components/icebox/kind-label.tsx +22 -0
- package/web/components/icebox/kind-menu.tsx +20 -0
- package/web/components/icebox/promote-form.tsx +93 -0
- package/web/components/icebox/reply-box.tsx +88 -0
- package/web/components/icebox/request-actions.tsx +141 -0
- package/web/components/icebox/request-badges.tsx +13 -0
- package/web/components/icebox/request-card.tsx +99 -0
- package/web/components/icebox/request-detail.tsx +43 -0
- package/web/components/icebox/request-images.tsx +33 -0
- package/web/components/icebox/request-phone-row.tsx +181 -0
- package/web/components/icebox/request-row.tsx +120 -0
- package/web/components/icebox/service-chip.tsx +58 -0
- package/web/components/icebox/snooze-menu.tsx +83 -0
- package/web/components/icebox/source-card.tsx +225 -0
- package/web/components/icebox/source-drawer.tsx +112 -0
- package/web/components/icebox/source-form.tsx +147 -0
- package/web/components/icebox/swipe-deck.tsx +242 -0
- package/web/components/layout/index.ts +1 -0
- package/web/components/layout/page-frame.tsx +44 -0
- package/web/components/markdown/index.ts +1 -0
- package/web/components/markdown/markdown.tsx +156 -0
- package/web/components/notebook/editor-pane.tsx +23 -0
- package/web/components/notebook/index.ts +5 -0
- package/web/components/notebook/note-body.tsx +172 -0
- package/web/components/notebook/note-tree.tsx +99 -0
- package/web/components/notebook/notes-head.tsx +37 -0
- package/web/components/notebook/notes-side.tsx +46 -0
- package/web/components/notes/index.ts +1 -0
- package/web/components/notes/note-composer.tsx +90 -0
- package/web/components/notes/notes-chat.tsx +58 -0
- package/web/components/panes/browser-pane.tsx +281 -0
- package/web/components/panes/index.ts +3 -0
- package/web/components/panes/preview-pane.tsx +91 -0
- package/web/components/panes/terminal-pane.tsx +52 -0
- package/web/components/phone/haptic.tsx +29 -0
- package/web/components/phone/index.ts +6 -0
- package/web/components/phone/phone-card.tsx +118 -0
- package/web/components/phone/phone-home.tsx +304 -0
- package/web/components/phone/phone-sheets.tsx +103 -0
- package/web/components/phone/qr-code.tsx +6 -0
- package/web/components/phone/usage-chips.tsx +85 -0
- package/web/components/phone/whatsapp-card.tsx +85 -0
- package/web/components/project/add-project-dialog.tsx +435 -0
- package/web/components/project/index.ts +3 -0
- package/web/components/project/project-bar.tsx +101 -0
- package/web/components/project/ws-menu.tsx +21 -0
- package/web/components/rail/agent-chips.tsx +110 -0
- package/web/components/rail/index.ts +4 -0
- package/web/components/rail/rail-filter.tsx +118 -0
- package/web/components/rail/rail-list.tsx +259 -0
- package/web/components/rail/source-marks.tsx +21 -0
- package/web/components/resources/index.ts +1 -0
- package/web/components/resources/resources-popup.tsx +490 -0
- package/web/components/run/doc-body.tsx +123 -0
- package/web/components/run/file-viewer.tsx +53 -0
- package/web/components/run/fix-form.tsx +88 -0
- package/web/components/run/index.ts +16 -0
- package/web/components/run/inline-md.tsx +30 -0
- package/web/components/run/key-hint.tsx +29 -0
- package/web/components/run/pane-gutter.tsx +52 -0
- package/web/components/run/pane-header.tsx +35 -0
- package/web/components/run/pane.tsx +140 -0
- package/web/components/run/panel-grip.tsx +49 -0
- package/web/components/run/panel-head.tsx +56 -0
- package/web/components/run/panel-tabs.tsx +35 -0
- package/web/components/run/phase-steps.tsx +37 -0
- package/web/components/run/project-notes.tsx +49 -0
- package/web/components/run/run-add-menu.tsx +80 -0
- package/web/components/run/run-bar.tsx +40 -0
- package/web/components/run/run-empty.tsx +10 -0
- package/web/components/run/run-footer.tsx +53 -0
- package/web/components/run/run-history.tsx +24 -0
- package/web/components/run/run-panes.tsx +78 -0
- package/web/components/run/run-picker.tsx +51 -0
- package/web/components/run/run-progress.tsx +30 -0
- package/web/components/run/run-tabs.tsx +147 -0
- package/web/components/run/run-wait.tsx +18 -0
- package/web/components/search/index.ts +1 -0
- package/web/components/search/search-palette.tsx +159 -0
- package/web/components/settings/account-rows.tsx +128 -0
- package/web/components/settings/agent-rows.tsx +249 -0
- package/web/components/settings/automation-rows.tsx +211 -0
- package/web/components/settings/browser-row.tsx +111 -0
- package/web/components/settings/cleanup-row.tsx +32 -0
- package/web/components/settings/commit-input.tsx +39 -0
- package/web/components/settings/index.ts +4 -0
- package/web/components/settings/integration-row.tsx +158 -0
- package/web/components/settings/mic-row.tsx +48 -0
- package/web/components/settings/orchestration-flow.tsx +87 -0
- package/web/components/settings/setting-row.tsx +131 -0
- package/web/components/settings/settings-item.tsx +78 -0
- package/web/components/settings/settings-loading.tsx +41 -0
- package/web/components/settings/settings-nav.tsx +119 -0
- package/web/components/settings/settings-scope.tsx +66 -0
- package/web/components/settings/settings-section.tsx +33 -0
- package/web/components/settings/skill-card.tsx +131 -0
- package/web/components/settings/stepper.tsx +74 -0
- package/web/components/settings/update-bar.tsx +167 -0
- package/web/components/shared/action-menu.tsx +76 -0
- package/web/components/shared/ask-host.tsx +18 -0
- package/web/components/shared/attach-button.tsx +23 -0
- package/web/components/shared/chip.tsx +19 -0
- package/web/components/shared/client-mark.tsx +15 -0
- package/web/components/shared/confirm-dialog.tsx +35 -0
- package/web/components/shared/empty-state.tsx +29 -0
- package/web/components/shared/field.tsx +77 -0
- package/web/components/shared/filter-popover.tsx +29 -0
- package/web/components/shared/form-frame.tsx +19 -0
- package/web/components/shared/icon-button.tsx +50 -0
- package/web/components/shared/index.ts +18 -0
- package/web/components/shared/mic-button.tsx +75 -0
- package/web/components/shared/pager.tsx +49 -0
- package/web/components/shared/picker.tsx +108 -0
- package/web/components/shared/project-mark.tsx +38 -0
- package/web/components/shared/segmented.tsx +43 -0
- package/web/components/shared/state-dot.tsx +4 -0
- package/web/components/shared/status-mark.tsx +26 -0
- package/web/components/shell/index.ts +3 -0
- package/web/components/shell/rail.tsx +259 -0
- package/web/components/shell/sprite.tsx +124 -0
- package/web/components/shell/wordmark.tsx +13 -0
- package/web/components/task/artifact-view.tsx +148 -0
- package/web/components/task/chat-bubble.tsx +43 -0
- package/web/components/task/filter-menu.tsx +38 -0
- package/web/components/task/index.ts +7 -0
- package/web/components/task/result-checks.tsx +34 -0
- package/web/components/task/result-view.tsx +103 -0
- package/web/components/task/status-badge.tsx +24 -0
- package/web/components/task/task-row.tsx +34 -0
- package/web/components/task/typing-dots.tsx +16 -0
- package/web/components/terminal/index.ts +3 -0
- package/web/components/terminal/terminal-bar.tsx +91 -0
- package/web/components/terminal/terminal-grid.tsx +149 -0
- package/web/components/terminal/terminal-modes.tsx +23 -0
- package/web/components/terminal/terminal-tile.tsx +139 -0
- package/web/dist/annotate.js +24 -0
- package/web/dist/board.css +718 -0
- package/web/dist/board.js +115 -0
- package/web/dist/boot.js +2 -0
- package/web/dist/notebook.css +319 -0
- package/web/dist/notebook.js +89 -0
- package/web/dist/popup.css +41 -0
- package/web/dist/popup.js +13 -0
- package/web/{term.js → dist/term.js} +48 -48
- package/web/dist/ui.css +3 -0
- package/web/dist/video.js +108 -0
- package/web/html/board.html +17 -0
- package/web/html/notes.html +14 -0
- package/web/html/popup.html +13 -0
- package/web/{video.html → html/video.html} +14 -15
- package/web/lib/annotate/index.ts +2 -0
- package/web/lib/annotate/notes.ts +105 -0
- package/web/lib/annotate/page.ts +121 -0
- package/web/lib/annotate/rules.ts +37 -0
- package/web/lib/annotate/session.ts +336 -0
- package/web/lib/board/board-actions.ts +119 -0
- package/web/lib/board/board-open.ts +12 -0
- package/web/lib/board/board-store.ts +159 -0
- package/web/lib/board/filter-box.ts +7 -0
- package/web/lib/board/index.ts +10 -0
- package/web/lib/board/nav.ts +29 -0
- package/web/lib/board/on-state.ts +90 -0
- package/web/lib/board/popups.ts +22 -0
- package/web/lib/board/snapshot.ts +105 -0
- package/web/lib/board/strip.ts +43 -0
- package/web/{board → lib/board}/ws-board.ts +1 -1
- package/web/lib/context/context-rules.ts +27 -0
- package/web/lib/context/context-store.ts +95 -0
- package/web/lib/context/feed.ts +28 -0
- package/web/lib/context/index.ts +3 -0
- package/web/lib/core/api.ts +86 -0
- package/web/lib/core/ask.ts +24 -0
- package/web/lib/core/board.ts +290 -0
- package/web/lib/core/brief.ts +31 -0
- package/web/lib/core/format.ts +8 -0
- package/web/lib/core/host.ts +107 -0
- package/web/lib/core/index.ts +16 -0
- package/web/{board → lib/core}/labels.ts +6 -5
- package/web/lib/core/layers.ts +7 -0
- package/web/lib/core/leave.ts +7 -0
- package/web/lib/core/motion.ts +10 -0
- package/web/{board/toast.ts → lib/core/notices.ts} +2 -20
- package/web/lib/core/notifier.ts +15 -0
- package/web/lib/core/store.ts +39 -0
- package/web/lib/core/term-handle.ts +8 -0
- package/web/lib/core/toast.ts +29 -0
- package/web/lib/core/utils.ts +15 -0
- package/web/lib/decision/index.ts +1 -0
- package/web/lib/decision/plan-questions.ts +39 -0
- package/web/lib/dictation/chunks.ts +93 -0
- package/web/lib/dictation/dictation-store.ts +22 -0
- package/web/lib/dictation/engine.ts +265 -0
- package/web/lib/dictation/index.ts +5 -0
- package/web/lib/dictation/mic.ts +42 -0
- package/web/lib/dictation/terminal-dictation.ts +50 -0
- package/web/lib/footer/footer-rules.ts +13 -0
- package/web/lib/footer/footer-store.ts +42 -0
- package/web/lib/footer/index.ts +2 -0
- package/web/lib/git/git-actions.ts +110 -0
- package/web/lib/git/git-panel.ts +43 -0
- package/web/lib/git/git-store.ts +47 -0
- package/web/lib/git/git.ts +170 -0
- package/web/lib/git/index.ts +4 -0
- package/web/lib/home/home-engine.ts +16 -0
- package/web/lib/home/home-events.ts +9 -0
- package/web/lib/home/home-store.ts +247 -0
- package/web/lib/home/home-window.ts +193 -0
- package/web/lib/home/home.ts +85 -0
- package/web/lib/home/index.ts +7 -0
- package/web/lib/home/onboarding.ts +199 -0
- package/web/lib/home/use-float-drag.ts +62 -0
- package/web/lib/icebox/icebox-actions.ts +518 -0
- package/web/lib/icebox/icebox-store.ts +112 -0
- package/web/lib/icebox/icebox-view.ts +48 -0
- package/web/lib/icebox/icebox.ts +273 -0
- package/web/lib/icebox/index.ts +8 -0
- package/web/lib/icebox/use-card-drag.ts +82 -0
- package/web/lib/icebox/use-ice-keys.ts +75 -0
- package/web/lib/icebox/use-icebox.ts +41 -0
- package/web/lib/icebox/use-row-swipe.ts +107 -0
- package/web/lib/markdown/index.ts +1 -0
- package/web/lib/markdown/markdown.ts +136 -0
- package/web/lib/notebook/autosave.ts +131 -0
- package/web/lib/notebook/deal.ts +58 -0
- package/web/lib/notebook/engine-complete.ts +128 -0
- package/web/lib/notebook/engine-preview.ts +287 -0
- package/web/lib/notebook/engine-types.ts +26 -0
- package/web/lib/notebook/engine-widgets.ts +218 -0
- package/web/lib/notebook/engine.ts +74 -0
- package/web/lib/notebook/index.ts +9 -0
- package/web/lib/notebook/kit-loader.ts +16 -0
- package/web/lib/notebook/kit.ts +12 -0
- package/web/{notes-lib.ts → lib/notebook/text.ts} +11 -10
- package/web/lib/notebook/vault-actions.ts +239 -0
- package/web/lib/notebook/vault-rules.ts +74 -0
- package/web/lib/notebook/vault-session.ts +73 -0
- package/web/lib/notebook/vault-store.ts +63 -0
- package/web/lib/notes/index.ts +4 -0
- package/web/lib/notes/md-html.ts +115 -0
- package/web/lib/notes/notes-actions.ts +32 -0
- package/web/lib/notes/notes-store.ts +22 -0
- package/web/lib/notes/notes.ts +58 -0
- package/web/{board → lib/notes}/rich.ts +1 -2
- package/web/lib/phone/index.ts +7 -0
- package/web/lib/phone/phone-actions.ts +77 -0
- package/web/lib/phone/phone-home.ts +102 -0
- package/web/lib/phone/phone-setup.ts +59 -0
- package/web/lib/phone/phone-sheet.ts +25 -0
- package/web/lib/phone/phone-store.ts +32 -0
- package/web/lib/phone/sheet-swipe.ts +55 -0
- package/web/lib/phone/use-phone-setup.ts +89 -0
- package/web/lib/project/add-project.ts +37 -0
- package/web/lib/project/branch.ts +14 -0
- package/web/lib/project/index.ts +5 -0
- package/web/lib/project/project-bar.ts +76 -0
- package/web/lib/project/project-pick.ts +36 -0
- package/web/lib/project/ws-menu.ts +8 -0
- package/web/lib/rail/agents.ts +63 -0
- package/web/lib/rail/card-links.ts +20 -0
- package/web/lib/rail/index.ts +7 -0
- package/web/lib/rail/rail-actions.ts +74 -0
- package/web/lib/rail/rail-boot.ts +99 -0
- package/web/lib/rail/rail-store.ts +85 -0
- package/web/lib/rail/rules.ts +241 -0
- package/web/lib/rail/source-marks.ts +17 -0
- package/web/lib/rail/use-rank-drag.ts +108 -0
- package/web/lib/resources/index.ts +3 -0
- package/web/lib/resources/resources-actions.ts +59 -0
- package/web/lib/resources/resources-store.ts +48 -0
- package/web/lib/resources/rules.ts +56 -0
- package/web/lib/router/index.ts +3 -0
- package/web/lib/router/route-rules.ts +96 -0
- package/web/lib/router/route-store.ts +115 -0
- package/web/lib/router/use-route-classes.ts +15 -0
- package/web/lib/run/browser.ts +53 -0
- package/web/lib/run/card-terminal.ts +32 -0
- package/web/lib/run/doc.ts +42 -0
- package/web/lib/run/grip.ts +8 -0
- package/web/lib/run/index.ts +19 -0
- package/web/lib/run/kept.ts +58 -0
- package/web/lib/run/layout-store.ts +156 -0
- package/web/lib/run/layout.ts +195 -0
- package/web/lib/run/panel-actions.ts +104 -0
- package/web/lib/run/panel-derive.ts +148 -0
- package/web/lib/run/panel-store.ts +125 -0
- package/web/lib/run/preview.ts +105 -0
- package/web/lib/run/run-actions.ts +118 -0
- package/web/lib/run/run-view-store.ts +134 -0
- package/web/lib/run/term-loader.ts +19 -0
- package/web/lib/run/use-panel-run.ts +125 -0
- package/web/lib/run/use-run-lifecycle.ts +70 -0
- package/web/lib/run/viewer.ts +12 -0
- package/web/lib/run/workspace.ts +281 -0
- package/web/lib/run/ws-actions.ts +293 -0
- package/web/lib/run/ws-derive.ts +50 -0
- package/web/lib/run/ws-draw.ts +102 -0
- package/web/lib/run/ws-store.ts +21 -0
- package/web/lib/run/ws-tabs.ts +125 -0
- package/web/lib/search/index.ts +3 -0
- package/web/lib/search/search-match.ts +48 -0
- package/web/lib/search/search-rows.ts +228 -0
- package/web/lib/search/search.ts +30 -0
- package/web/lib/search/use-search-rows.ts +22 -0
- package/web/lib/server/attention.ts +29 -0
- package/web/lib/server/index.ts +6 -0
- package/web/lib/server/poll-rules.ts +57 -0
- package/web/lib/server/poller.ts +210 -0
- package/web/lib/server/server-store.ts +39 -0
- package/web/lib/server/types.ts +31 -0
- package/web/lib/server/use-server.ts +19 -0
- package/web/lib/settings/agent-favicons.ts +14 -0
- package/web/lib/settings/index.ts +7 -0
- package/web/lib/settings/panel-settings.ts +29 -0
- package/web/lib/settings/settings-actions.ts +357 -0
- package/web/lib/settings/settings-store.ts +114 -0
- package/web/lib/settings/settings.ts +413 -0
- package/web/lib/settings/skill-icons.ts +24 -0
- package/web/lib/settings/update.ts +70 -0
- package/web/lib/shared/data-urls.ts +32 -0
- package/web/lib/shared/index.ts +4 -0
- package/web/lib/shared/use-draft.ts +38 -0
- package/web/lib/shared/use-narrow.ts +11 -0
- package/web/lib/shared/use-pager.ts +24 -0
- package/web/lib/shell/appearance.ts +97 -0
- package/web/lib/shell/help-store.ts +4 -0
- package/web/lib/shell/index.ts +4 -0
- package/web/lib/shell/shell-store.ts +23 -0
- package/web/lib/shell/stored-look.ts +47 -0
- package/web/lib/task/index.ts +7 -0
- package/web/lib/task/task-results.ts +92 -0
- package/web/lib/task/tasks.ts +132 -0
- package/web/lib/task/use-live-frame.ts +85 -0
- package/web/lib/task/use-saved-text.ts +25 -0
- package/web/lib/task/use-task.ts +161 -0
- package/web/lib/task/use-tasks.ts +50 -0
- package/web/{board → lib/task}/zoom.ts +25 -12
- package/web/lib/terminal/hidden-badge.ts +15 -0
- package/web/lib/terminal/index.ts +8 -0
- package/web/lib/terminal/layout.ts +138 -0
- package/web/{term-font.ts → lib/terminal/term-font.ts} +3 -2
- package/web/lib/terminal/terminal-store.ts +65 -0
- package/web/lib/terminal/terms-feed.ts +37 -0
- package/web/lib/terminal/use-arranged.ts +15 -0
- package/web/lib/terminal/use-terminal-keys.ts +37 -0
- package/web/lib/url/index.ts +1 -0
- package/web/lib/url/safe-url.ts +9 -0
- package/web/notebook/notebook.ts +27 -0
- package/web/notebook/notes-lib.ts +3 -0
- package/web/pages/board/App.tsx +76 -0
- package/web/pages/board/header.tsx +83 -0
- package/web/pages/board/help.tsx +59 -0
- package/web/pages/board/host-bridge.ts +94 -0
- package/web/pages/board/host.tsx +19 -0
- package/web/pages/board/keys.ts +112 -0
- package/web/pages/board/live.ts +39 -0
- package/web/pages/board/main.ts +32 -0
- package/web/pages/board/pages.tsx +86 -0
- package/web/pages/board/panel.tsx +157 -0
- package/web/pages/board/portal.tsx +39 -0
- package/web/pages/board/use-boot.ts +13 -0
- package/web/pages/board/views.ts +63 -0
- package/web/pages/board-page.tsx +62 -0
- package/web/pages/home-page.tsx +127 -0
- package/web/pages/icebox-page.tsx +440 -0
- package/web/pages/notebook/App.tsx +35 -0
- package/web/pages/notebook-page.tsx +50 -0
- package/web/pages/popup/App.tsx +207 -0
- package/web/pages/settings-page.tsx +111 -0
- package/web/pages/task-page.tsx +383 -0
- package/web/pages/tasks-page.tsx +151 -0
- package/web/pages/terminal-page.tsx +15 -0
- package/web/popup/popup.ts +7 -0
- package/web/{term.ts → term/term.ts} +48 -20
- package/web/ui/alert-dialog.tsx +39 -0
- package/web/ui/badge.tsx +20 -0
- package/web/ui/button.tsx +37 -0
- package/web/ui/checkbox.tsx +20 -0
- package/web/ui/command.tsx +41 -0
- package/web/ui/dialog.tsx +28 -0
- package/web/ui/dropdown-menu.tsx +54 -0
- package/web/ui/icon.tsx +17 -0
- package/web/ui/index.ts +21 -0
- package/web/ui/input.tsx +9 -0
- package/web/ui/label.tsx +7 -0
- package/web/ui/legacy/board.css +715 -0
- package/web/{notes.html → ui/legacy/notes.css} +23 -157
- package/web/ui/legacy/popup.css +40 -0
- package/web/ui/popover.tsx +28 -0
- package/web/ui/select.tsx +61 -0
- package/web/ui/sheet.tsx +43 -0
- package/web/ui/skeleton.tsx +6 -0
- package/web/ui/sonner.tsx +25 -0
- package/web/ui/spinner.tsx +12 -0
- package/web/ui/switch.tsx +18 -0
- package/web/ui/tabs.tsx +18 -0
- package/web/ui/textarea.tsx +14 -0
- package/web/ui/theme.css +125 -0
- package/web/ui/toggle.tsx +8 -0
- package/web/ui/tooltip.tsx +26 -0
- package/web/{video.ts → video/video.ts} +5 -5
- package/web/board/add-project.ts +0 -147
- package/web/board/agent-favicons.ts +0 -9
- package/web/board/agent-term.ts +0 -51
- package/web/board/annotate-lib.ts +0 -19
- package/web/board/annotate.ts +0 -221
- package/web/board/api.ts +0 -180
- package/web/board/approvals.ts +0 -109
- package/web/board/badge.ts +0 -115
- package/web/board/cards.ts +0 -1080
- package/web/board/chat.ts +0 -128
- package/web/board/context.ts +0 -248
- package/web/board/dictation.ts +0 -343
- package/web/board/dom.ts +0 -132
- package/web/board/drafts.ts +0 -21
- package/web/board/fixes.ts +0 -89
- package/web/board/git.ts +0 -416
- package/web/board/home-ws.ts +0 -266
- package/web/board/home.ts +0 -421
- package/web/board/icebox.ts +0 -1788
- package/web/board/keys.ts +0 -121
- package/web/board/live.ts +0 -87
- package/web/board/main.ts +0 -94
- package/web/board/markdown.ts +0 -210
- package/web/board/onboarding.ts +0 -227
- package/web/board/panel.ts +0 -437
- package/web/board/phone-setup.ts +0 -79
- package/web/board/phone.ts +0 -219
- package/web/board/projects.ts +0 -277
- package/web/board/resources.ts +0 -170
- package/web/board/run-pick.ts +0 -41
- package/web/board/run-view.ts +0 -1316
- package/web/board/search-match.ts +0 -20
- package/web/board/search.ts +0 -330
- package/web/board/settings-accounts.ts +0 -76
- package/web/board/settings-agents.ts +0 -102
- package/web/board/settings-automations.ts +0 -71
- package/web/board/settings-cleanup.ts +0 -42
- package/web/board/settings-orchestration.ts +0 -32
- package/web/board/settings-pages.ts +0 -62
- package/web/board/settings-skills.ts +0 -103
- package/web/board/settings-voice.ts +0 -28
- package/web/board/settings.ts +0 -490
- package/web/board/store.ts +0 -47
- package/web/board/task-page.ts +0 -628
- package/web/board/task-results.ts +0 -234
- package/web/board/tasks.ts +0 -242
- package/web/board/terms.ts +0 -390
- package/web/board/update.ts +0 -171
- package/web/board/viewer.ts +0 -47
- package/web/board/views.ts +0 -164
- package/web/board/whatsapp-setup.ts +0 -149
- package/web/board/workspace.ts +0 -650
- package/web/board/ws-board-ui.ts +0 -95
- package/web/board/ws-tabs.ts +0 -227
- package/web/board.html +0 -1563
- package/web/board.js +0 -505
- package/web/notebook.js +0 -519
- package/web/notebook.ts +0 -1254
- package/web/popup.html +0 -141
- package/web/video.js +0 -575
- /package/web/{term.css → dist/term.css} +0 -0
- /package/web/{board/term-sessions.ts → lib/terminal/sessions.ts} +0 -0
- /package/web/{board/terminal-viewport.ts → lib/terminal/viewport.ts} +0 -0
- /package/web/{term-paste.ts → term/term-paste.ts} +0 -0
package/web/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# web/ — the board's front end
|
|
2
|
+
|
|
3
|
+
The board is React (Tailwind + Radix through `ui/`) built into `dist/board.js`. Each page is one small `App`
|
|
4
|
+
(`pages/board/App.tsx`, `pages/notebook/App.tsx`, `pages/popup/App.tsx`) rendered into `<div id="root">`; there is no `board/` folder any more: the
|
|
5
|
+
engines that react to the server and the router live in the feature folders of `lib/`, the page's glue in `pages/board/`. `bun run build:web` bundles everything into `dist/`
|
|
6
|
+
and a test fails when the committed bundles are stale. `checks/structure.test.ts` enforces the rules below.
|
|
7
|
+
|
|
8
|
+
## What is in web/
|
|
9
|
+
|
|
10
|
+
Only folders and this file; `checks/structure.test.ts` (which checks the whole tree, so
|
|
11
|
+
it stays here; it also fails on any other file at this level).
|
|
12
|
+
|
|
13
|
+
| Path | Holds |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `html/` | `board.html`, `notes.html`, `popup.html`: shells of about 12 lines (the head, `<div id="root">`, the page's one stylesheet and one script; no inline CSS, markup or script, a test holds it). `video.html` is still a whole page. |
|
|
16
|
+
| `notebook/` | The Notes page's entry (`notebook.ts`: boots the shell, renders `pages/notebook/App.tsx`), `kit.ts` (registers the kit's stores as `window.kzKit` for code shared with Video), `kit-loader.ts` (hands that kit to shared code) and `notes-lib.ts` (re-exports `lib/notebook/text.ts` for `cli/`). |
|
|
17
|
+
| `popup/` | The chat popup's entry (`popup.ts`): renders `pages/popup/App.tsx` (`kaizen chat`), bundled to `dist/popup.js`. |
|
|
18
|
+
| `term/` | The in-card terminal's entry (`term.ts`, xterm.js) with its font and paste helpers and their tests. |
|
|
19
|
+
| `video/` | The Video page's entry (`video.ts`). |
|
|
20
|
+
| `annotate/` | `annotate.ts`: the annotator's page-side script (the part injected into the framed page: picker, overlay, note box, picture of the pick), bundled to `dist/annotate.js`. It imports only `lib/annotate/page.ts`. |
|
|
21
|
+
| `ui/`, `components/`, `pages/`, `lib/` | The board's layers, below. `ui/theme.css` is the Tailwind theme the kit is built from; `ui/legacy/` holds the page styles that were inline in the shells (`board.css`, `notes.css`, `popup.css`), moved unchanged and not yet rewritten as utilities. |
|
|
22
|
+
| `dist/` | Generated by `bun run build:web`, committed, never edited: `board.js`, `notebook.js`, `popup.js`, `term.js`, `video.js`, `annotate.js`, and the stylesheets `ui.css` (the kit; Video links it), `board.css` and `notebook.css` (the kit and the page's styles, one link per page), `popup.css`, `term.css`. |
|
|
23
|
+
| `sounds/` | The notification sounds the board plays. |
|
|
24
|
+
|
|
25
|
+
The server keeps serving the bundles at their old flat URLs (`/board.js`, `/ui.css`, `/notebook.js`,
|
|
26
|
+
`/term.js`, `/term.css`, `/video.js`, `/annotate.js`; the new `/board.css`, `/notebook.css`, `/popup.css` and `/popup.js` are in `AT_START` in `cli/web.ts`, which a test checks for every file in `html/` and `dist/`); only the files on disk moved, so a board that is
|
|
27
|
+
running during `kaizen upgrade` and old pages keep working. Entry sources are grouped by app because each
|
|
28
|
+
bundle's imports are the app's own helpers plus the layers below; `lib/` may import
|
|
29
|
+
a helper from an app folder (`notebook/notes-lib.ts`).
|
|
30
|
+
|
|
31
|
+
## Layers (imports only go downward)
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
pages/ -> components/<feature>/ -> ui/ -> lib/core/utils.ts
|
|
35
|
+
\-> lib/<feature>/ (lib imports only lib)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
| Folder | Holds |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `pages/` | `board/`, `notebook/` and `popup/` each hold the page's `App.tsx` (providers, shell, the page picker, popups); the board's App is split into `header`, `pages`, `panel`, `portal`, `help` and `host`. Beside them one file per page: tasks, task, icebox, board, home, terminal, settings and notebook. Composes components; no logic of its own. The Board's App holds no state and is the page picker: the router (`lib/router`, no router library) holds the view the address names, `useRouteClasses` sets the `<body>` classes that show one page area, a page is drawn the first time its view opens (`Once`) and kept after, and the panel's body is one component (`pages/board/panel.tsx`) that shows what `lib/run/panel-store.ts` says and unmounts what it replaces. |
|
|
41
|
+
| `components/<feature>/` | Pieces a page draws. Popups, dialogs and menus come from `ui/`, never hand-built, no `innerHTML`. |
|
|
42
|
+
| `ui/` | Flat, one file per control (button, dialog, popover, select...). The only place that touches Radix or cmdk. |
|
|
43
|
+
| `lib/<feature>/` | Rules, stores (zustand), actions (requests) and hooks for one feature. No JSX. |
|
|
44
|
+
| `boot/` | `boot.ts`, built to `dist/boot.js` (1 KB): a blocking script in the head of the board and the Notebook that puts the stored theme, colour, motion and menu fold on `<html>` before the first paint (the one script besides the bundle; no inline script). |
|
|
45
|
+
| (no `board/`) | The old `board/` plumbing is gone and none is left as a named exception: the engines (`init…` functions that react to `lib/server` and `lib/router`) are in their feature folders (`lib/run`: the panel as `panel-store.ts`, `panel-actions.ts`, `panel-derive.ts` (pure) and the `usePanelRun` hook; `workspace.ts` (lifecycle) with `ws-derive.ts`, `ws-store.ts`, `ws-draw.ts`, `ws-actions.ts`, `kept.ts` and the `useRunLifecycle` hook, `card-terminal.ts`; `lib/board`: `snapshot.ts`, `on-state.ts`, `popups.ts`, `nav.ts`; and `lib/home`, `lib/terminal`, `lib/context`, `lib/git`, `lib/settings`, `lib/project`, `lib/search`, `lib/rail/rail-boot.ts`), and the page's glue in `pages/board/` (`main.ts`, `use-boot.ts` (the App's start-up effects), `views.ts`, `keys.ts`, `live.ts`, `host-bridge.ts`, which also answers `host.open`: what a page opens in place). The test `web/board is gone` fails on a new `web/board/` folder or an import of one; `BY_DESIGN` in `checks/structure.test.ts` names the only files left imperative on purpose (the terminal engine, the annotator's page script, CodeMirror, the note editor, dictation, the gestures), each with a signature the file must still show; every other `.ts` file in `lib/` and `pages/` is a module under the rules (no polling the server but `lib/server`, no page class but `lib/router`, no look-up of an element by id or selector but the named places, never a file that only forwards). |
|
|
46
|
+
|
|
47
|
+
## Feature folders
|
|
48
|
+
|
|
49
|
+
`components/<f>/` and `lib/<f>/` use the same name when both exist.
|
|
50
|
+
|
|
51
|
+
| Folder | What it is |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `shared` | Pieces two or more features use: chip, icon button, field, picker, segmented, pager, project mark, empty state, confirm dialog and `AskHost`, mic/attach buttons, and the hooks `use-draft`, `use-narrow`, `use-pager`. |
|
|
54
|
+
| `core` (lib only) | Generic helpers and the base model: `api`, `host`, `utils`, `format`, `labels`, `toast`, `store` (the Tasks pages' state), `ask`, plus `board.ts` (the card/run model) and `brief`. |
|
|
55
|
+
| `task` | The Tasks list and one task: rows, status badge, chat bubbles, result view, artifact frame; `useTasks`, `useTask`, `useDock`. |
|
|
56
|
+
| `decision` | The decision bar a task or run waits on, and its forms (revise, reply, plan answers). |
|
|
57
|
+
| `icebox` | Icebox requests (row, card, phone row, swipe deck), capture box, sources (card, form, drawer), collections, board/kind/snooze menus. |
|
|
58
|
+
| `board` | The Kanban board: card, column, popups, the New task / run / card forms, the mode switch. |
|
|
59
|
+
| `run` | The run panel and run view: head, tabs, history, picker, footer, wait/empty states, file viewer, fix form; the centre's panes (`run-panes`, `pane`, `pane-gutter`) and panel grip; in `lib/run`: the pane layout rules (`layout`) and its saved store (`layout-store`), the Browser's history (`browser`), `run-actions`. |
|
|
60
|
+
| `panes` | What fills a pane of the run workspace: `TerminalPane` (xterm.js, mounted once; also the Home window's terminal, the Terminal page's and the in-card agent's in the run panel), `BrowserPane` (address bar, frame, annotator) and `PreviewPane` (the run's Preview: report, screenshots, or the agent's last `kaizen preview`; its rules are `lib/run/preview.ts`). |
|
|
61
|
+
| `terminal` | The Terminal page (`?view=terminal`): the tiles of every agent session and shell (header, state, Resume, maximise, hide, exit, drag to swap), the border handles, the hidden chips, a phone's tabs, and the header's layout switch. `lib/terminal`: the rules (`layout`: arrange, grid shape, handle places, drag math), the store (sessions from `lib/terminal/terms-feed.ts`, the saved `kz-terms` layout) and the Ctrl+Shift+M / Alt+1-9 keys; `sessions` (one tile per PTY) and `viewport` (the phone's keyboard fit, used by `term/term.ts`). Each terminal is a `TerminalPane`. |
|
|
62
|
+
| `footer` | The board's footer bar: Claude and Codex usage chips (the phone page's `UsageChips`, opening on hover or focus here), the refresh button, the resource button, the live terminal count and the phone chip; `lib/footer` holds what the chips read (store, the phone chip's words). The board's status strip (a chip per status, the Archive chip, the phone's status button and its popover) is in `board`, its rules in `lib/board/strip.ts`. |
|
|
63
|
+
| `server` | What the server says, as slices of one Zustand store: this page's `/state`, every project's cards and agents (`/state?all=1`), the tasks that need you, `/sources` and the live shells. `poller.ts` is the only reader (quiet gap, hidden-tab gap, identical replies skipped, the event stream, the all-projects read at most every 2 s); the board's engines hear of a new `/state` through `setEngine` and `onState`. Components read the slice they draw (`useRailData`, `useLiveTerminals`). Pure rules in `poll-rules.ts`, tested. |
|
|
64
|
+
| `router` | The Board's router as a store: the view the address names (`?view=`, `ws`/`icebox`/`ideas` aliases, the phone's rules), the lit menu item, title, drawn-once pages, the query and the run it names. `navigate` is the only way a view changes; `startRouter` takes the menu links and back/forward; `setRouterHooks` is where `pages/board/views.ts` starts what the docked panel, run workspace and Home still do. Rules in `route-rules.ts`, tested. |
|
|
65
|
+
| `shell` | The page's frame, shared by the Board and the Notebook: `Rail` (the side menu: logo, fold, search, pages, Projects list and filter, Settings with the update dot, theme switch), `Sprite` (the SVG icons every `<use href="#i-...">` points at) and `Wordmark`. `lib/shell`: the view and which pages have been seen (`shell-store`), the title and lit item rules, and the page's look (theme, colour, motion, fold, the desktop and iPhone-app fit) kept in `localStorage` and applied by `bootShell()` (`appearance`); Settings and onboarding call `setTheme`, `setColor`, `setMotion`, which replace the old `window.setTheme` globals. |
|
|
66
|
+
| `context` | The Project context pane (Files, Notes, Terminal sessions): a side pane or, narrow, a dialog that makes the page behind inert and keeps Tab inside. `lib/context`: the rows' words, the requests (`/project-tree`, `/project-text`, `/vault`) and the store. It keeps the board's own markup and CSS (kz-keep). Its open button (`ContextOpen`) is in the Board header, shown on the Board; the pane reads nothing while closed. |
|
|
67
|
+
| `git` | The run's Source control tab. |
|
|
68
|
+
| `layout` | Page templates. `PageFrame`: the shape of the Chat screen for a page that draws its own sidebar. Slots: `sidebar` (280 px, like the side menu), `title` and `actions` (the header bar, 52 px, in a rounded bordered card), children (the scrolling body, `bodyRef` for scroll-to-top), and `phone` (`sidebar` or `content`: which one shows at 640 px and below, where the card and header bar go). The card keeps the shell's 8 px gap above and beside it and ends flush on the footer. Use it for any page that is a sidebar beside one page of content (Settings, its loading skeleton); a page that lives in the shell's own card (Chat, the Board) already has this look from `.app` and the Header, and does not use it. |
|
|
69
|
+
| `settings` | Settings page rows, nav, sections, update bar; settings store and actions, update check (the microphone choice row is here, its rules are `dictation`). |
|
|
70
|
+
| `notes` | A card's Notes tab in the panel: the notes as messages, the box that adds one (over the note editor `lib/notes/rich.ts`, reached through `host.rich`), files picked and pasted; `lib/notes` holds the notes-file rules, the per-card files store and the send. |
|
|
71
|
+
| `notebook` | The Notes page (its own bundle, `notebook.js`): header with the project Picker, sidebar (search, tags, folder tree), the paper (name box, meta bar, backlinks, blank states) and `EditorPane`, the CodeMirror engine as one component. In `lib/notebook`: the text rules (`text`, also for `cli/`), search, tag, backlink and rename rules (`vault-rules`), the 600 ms save as a state machine (`autosave`), the store, actions and session (`vault-*`), the page-turn animation (`deal`) and the engine (`engine*`). Not `notes`, which is a card's Notes tab. |
|
|
72
|
+
| `dictation` (lib only) | Speech to text in the page: the Whisper worker and recording session (`engine`), the chunk, order and caret rules (`chunks`), each button's state (`dictation-store`), Ctrl+Alt+D into a terminal, and the microphone choice (`mic`). The button is `MicButton` in `shared`. |
|
|
73
|
+
| `phone` | Phone setup (QR, WhatsApp card), the phone-sized new-run sheets, and the phone's Home and Runs pages (agents, devices, runs, usage chips; `lib/phone`: their rules, the store, the taps' requests, the run sheet's swipe rules) with the tap tick. |
|
|
74
|
+
| `home` | Home: chat list, messages, composer, onboarding dialog; the home store; the floating Home window (its tabs, drag, minimized sidebar row and "+" menu; `lib/home/home-window.ts` holds its rules and requests, the terminal is `panes`' `TerminalPane`). |
|
|
75
|
+
| `annotate` | The Browser tab's annotator, board side: the dark toolbar, the notes list with its settings box (`components/annotate`, mounted by `BrowserPane` (in `panes`) as `AnnotatePanel`). In `lib/annotate`: the note model and request bodies (`notes`), the message and address rules (`rules`: only the frame, the proxy origin and the open's token are heard), the page-side rules the injected script shares (`page`: selection geometry, where the box opens, what a note holds, the plan for the picture), and the Zustand store with the keys and the conversation with the page (`session`, one per Browser tab). |
|
|
76
|
+
| `project` | Project picker, Add project dialog, workspace menu, branch rules. |
|
|
77
|
+
| `rail` | The side menu's Projects list (rows, folds, pins, project drag, agent chips, task links, worktree right-click menu), its filter and the Icebox item's source marks (`SourceMarks`); rules, store and requests in `lib/rail`. Rows keep the board's legacy classes. |
|
|
78
|
+
| `resources` | The footer resource popup: Memory, Storage, Terminals; store, requests and sizes in `lib/resources`. |
|
|
79
|
+
| `search` | The search palette and its matching. |
|
|
80
|
+
| `markdown`, `url` | The markdown renderer (component and parser) and `safeUrl`, kept apart so the notebook bundle takes only `safeUrl`. |
|
|
81
|
+
|
|
82
|
+
## Rules
|
|
83
|
+
|
|
84
|
+
- **Index.** Every feature folder has an `index.ts` exporting what other folders use. Import another
|
|
85
|
+
folder through it (`../../lib/task/index.ts`), never a file inside it. Inside a folder, import files
|
|
86
|
+
directly (that keeps barrels out of cycles). `import type` follows the same rule.
|
|
87
|
+
- **Size.** A folder over 25 files is split by feature.
|
|
88
|
+
- **Where to add a thing.** Used by one feature: that feature's folder. Used by two: `shared` (a
|
|
89
|
+
component) or `core` (a helper), and add it to the index. A new feature: a folder in `components/`
|
|
90
|
+
and `lib/` with an `index.ts`, and a row in the table above.
|
|
91
|
+
- **Names.** Kebab-case files (`task-row.tsx`, `use-task.ts`); the file's main export is its
|
|
92
|
+
PascalCase name; hooks start with `use-`; stores end `-store`, request functions `-actions`.
|
|
93
|
+
Tests live beside the code they test as `*.test.ts` (in the feature folder, , import the file they test directly, and are not counted in the 25-file limit; an `index.ts` never exports them. `checks/structure.test.ts` stays in `web/` because it checks the whole tree.
|
|
94
|
+
- **Nothing draws by hand.** No `innerHTML`, `insertAdjacentHTML`, `DOMParser`, `createContextualFragment`, hand-built dialog or `x.createElement(...)` on any document anywhere in `web/` except `video/` (its own page, no React) and the named files in `EXEMPT` (`checks/structure.test.ts`), each with its reason and the most uses it may keep (a new use fails until the count is raised on purpose): `term/term.ts` (xterm's own bundle: find box, paste, reconnect strip and the phone key bar, whose `pointerdown` + `preventDefault` keeps the soft keyboard open; turning it into React needs a controller API out of the engine and a real phone to check), `lib/notes/rich.ts` (the note editor's contenteditable engine), `annotate/annotate.ts` (injected into the framed page), the two CodeMirror widget files, `pages/tasks-page.tsx` (one span in the header), and Video's fallback toast (`lib/core/notices.ts`). A stale line fails the test.
|
|
95
|
+
- **Exceptions.** `ui/` takes `lib/core/utils.ts` directly. A few bridge files (`rail-boot`, `search-rows`, `ws-tabs`, `ws-board`, and the board's `main.ts` and `use-boot.ts`) import small lib files
|
|
96
|
+
directly because they run in the notebook and Video bundles or in DOM-less tests, where a
|
|
97
|
+
barrel would pull in the board's stores (list: `BRIDGE_DIRECT` in `checks/structure.test.ts`).
|
|
98
|
+
- **Core's type imports.** `lib/core/api.ts` and `store.ts` use `import type` from `lib/task` and
|
|
99
|
+
`lib/icebox` for data shapes; erased at build, so no runtime cycle.
|
|
100
|
+
|
|
101
|
+
## Imports
|
|
102
|
+
Across folders always use an alias (tsconfig `paths`, resolved by Bun), never `../../`:
|
|
103
|
+
`import { Button } from "@web/ui"`, `import { useGit } from "@lib/git"`, `import { ActionMenu } from "@components/shared"`.
|
|
104
|
+
A folder alias means its `index.ts`; a file alias keeps its extension (`@lib/core/labels.ts`, only the listed bridge files).
|
|
105
|
+
Inside one folder import siblings relatively (`./card-footer.tsx`). New ui files get one line in `web/ui/index.ts`.
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
// kaizen's annotator, the script the board's proxy adds to a framed page (cli/annotate-proxy.ts).
|
|
2
|
-
//
|
|
1
|
+
// kaizen's annotator, the script the board's proxy adds to a framed page (cli/annotate-proxy.ts). Bundled by
|
|
2
|
+
// `bun run build:web` into web/dist/annotate.js, one wrapped script with no dependencies and nothing else loaded
|
|
3
|
+
// (the rules that need no page are in web/lib/annotate/page.ts). It lets the user pick an element, text, several
|
|
3
4
|
// elements or an area, write a note and see numbered markers. It never changes the page except for
|
|
4
5
|
// its own overlay (and Pause). It talks to the board only by postMessage, signed with the per-open
|
|
5
6
|
// token in its own URL; the board keeps the notes and decides what to do with them.
|
|
7
|
+
import { AREA_MAX, CROP_BUDGET, CROP_CHARS, areaBigEnough, areaLabel, buildNote, composerPos, cropScales, cropWindow, goodClass, insideArea, markerPos, quote, rectOf, tipPos, tooBig, union } from "@lib/annotate/page.ts";
|
|
8
|
+
|
|
6
9
|
(() => {
|
|
7
10
|
// Framed by the board, or the desktop app's Browser tab (a <webview>, where the page has no parent
|
|
8
11
|
// and the app's preload sets __kzHost and relays the messages).
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const W = window as any;
|
|
13
|
+
const hosted = window.parent !== window || W.__kzHost === true;
|
|
14
|
+
if (W.__kzAnnotate || !hosted) return;
|
|
15
|
+
W.__kzAnnotate = true;
|
|
16
|
+
const script = document.currentScript as HTMLScriptElement | null;
|
|
13
17
|
// The proxy's <script src="…?t=token">, or (desktop app, public site) the token the board set
|
|
14
18
|
// before running this script in the page.
|
|
15
|
-
let token = typeof
|
|
16
|
-
if (!token) try { token = new URL(script
|
|
19
|
+
let token = typeof W.__kzAnnToken === "string" ? W.__kzAnnToken : "";
|
|
20
|
+
if (!token) try { token = new URL(script!.src).searchParams.get("t") || ""; } catch {}
|
|
17
21
|
const parent = window.parent;
|
|
18
22
|
// `out` marks what the page says, so the webview's relay forwards it and not what the board sends.
|
|
19
23
|
const send = (m) => parent.postMessage({ kz: 1, t: token, out: 1, ...m }, "*");
|
|
@@ -50,7 +54,6 @@
|
|
|
50
54
|
// ---- naming an element: a selector that finds exactly it, a path, source and component ----
|
|
51
55
|
const esc = (s) => (window.CSS && CSS.escape ? CSS.escape(s) : s.replace(/[^\w-]/g, "\\$&"));
|
|
52
56
|
const uniq = (sel) => { try { return document.querySelectorAll(sel).length === 1; } catch { return false; } };
|
|
53
|
-
const goodClass = (c) => c.length < 24 && !/\d{3,}|^css-|^_|^sc-|^jsx-/.test(c);
|
|
54
57
|
function selectorFor(el) {
|
|
55
58
|
if (el.id && uniq("#" + esc(el.id))) return "#" + esc(el.id);
|
|
56
59
|
const t = el.getAttribute("data-testid");
|
|
@@ -112,7 +115,8 @@
|
|
|
112
115
|
const host = document.createElement("div");
|
|
113
116
|
host.style.cssText = "all:initial;position:fixed;inset:0;z-index:2147483647;pointer-events:none";
|
|
114
117
|
const root = host.attachShadow({ mode: "closed" });
|
|
115
|
-
|
|
118
|
+
const sheet = document.createElement("style");
|
|
119
|
+
sheet.textContent = `
|
|
116
120
|
*{box-sizing:border-box;font:12px/1.4 system-ui,sans-serif}
|
|
117
121
|
.b{position:fixed;pointer-events:none;border:2px solid var(--c);background:color-mix(in srgb,var(--c) 14%,transparent);border-radius:2px}
|
|
118
122
|
.b.mk{border-width:1.5px;border-style:dashed;background:color-mix(in srgb,var(--c) 6%,transparent)}.b.mk.on{border-style:solid;background:color-mix(in srgb,var(--c) 14%,transparent)}
|
|
@@ -134,15 +138,15 @@
|
|
|
134
138
|
.t{position:fixed;width:260px;background:#1c1c1e;color:#f2f2f7;border:1px solid #2c2c2e;border-radius:12px;padding:8px 12px;pointer-events:none;box-shadow:0 8px 28px #0008;white-space:pre-wrap;word-break:break-word}
|
|
135
139
|
.t small{display:block;color:#98989f;margin-top:4px}
|
|
136
140
|
.p{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);background:#1c1c1e;color:#f2f2f7;border:1px solid #2c2c2e;border-radius:999px;padding:6px 8px 6px 16px;pointer-events:auto;display:flex;gap:8px;align-items:center}
|
|
137
|
-
|
|
138
|
-
const layer =
|
|
141
|
+
`;
|
|
142
|
+
const layer = document.createElement("div");
|
|
143
|
+
root.append(sheet, layer);
|
|
139
144
|
layer.style.setProperty("--c", cfg.color);
|
|
140
145
|
const mount = () => document.documentElement.append(host);
|
|
141
146
|
mount();
|
|
142
147
|
|
|
143
148
|
const el = (cls, css, text) => { const d = document.createElement("div"); d.className = cls; if (css) d.style.cssText = css; if (text) d.textContent = text; return d; };
|
|
144
149
|
const box = (r, cls = "b") => el(cls, `left:${r.left}px;top:${r.top}px;width:${r.width}px;height:${r.height}px`);
|
|
145
|
-
const union = (rs) => { const l = Math.min(...rs.map((r) => r.left)), t = Math.min(...rs.map((r) => r.top)), rr = Math.max(...rs.map((r) => r.right)), b = Math.max(...rs.map((r) => r.bottom)); return { left: l, top: t, right: rr, bottom: b, width: rr - l, height: b - t }; };
|
|
146
150
|
|
|
147
151
|
let hov = null, tip = null;
|
|
148
152
|
function paint() {
|
|
@@ -172,14 +176,16 @@
|
|
|
172
176
|
if (!r) return;
|
|
173
177
|
// What the note marks stays outlined (dashed; solid while its number is hovered), not only its number.
|
|
174
178
|
add(box(r, "b mk" + (m.kind === "multi" || m.kind === "area" ? " g" : "") + (tip === m ? " on" : "")));
|
|
175
|
-
const
|
|
179
|
+
const mp = markerPos(r, innerWidth);
|
|
180
|
+
const d = el("m dyn" + (m.kind === "multi" || m.kind === "area" ? " g" : ""), `left:${mp.left}px;top:${mp.top}px`, String(m.n));
|
|
176
181
|
d.onclick = (e) => { e.stopPropagation(); send({ type: "marker", n: m.n }); };
|
|
177
|
-
d.onmouseenter = () => { tip = m; paint(); };
|
|
178
|
-
d.onmouseleave = () => { tip = null; paint(); };
|
|
182
|
+
d.onmouseenter = () => { if (tip !== m) { tip = m; paint(); } };
|
|
183
|
+
d.onmouseleave = () => { if (tip === m) { tip = null; paint(); } };
|
|
179
184
|
add(d);
|
|
180
185
|
// the comment sits under its block, as in Agentation
|
|
181
186
|
if (tip === m && m.comment && !draft) {
|
|
182
|
-
const
|
|
187
|
+
const tp = tipPos(r, innerWidth, innerHeight);
|
|
188
|
+
const t = el("t", `left:${tp.left}px;top:${tp.top}px`);
|
|
183
189
|
t.append(String(m.comment).slice(0, 600));
|
|
184
190
|
const sm = document.createElement("small"); sm.textContent = `${m.intent || ""} · ${m.severity || ""}`; t.append(sm);
|
|
185
191
|
add(t);
|
|
@@ -187,7 +193,6 @@
|
|
|
187
193
|
});
|
|
188
194
|
}
|
|
189
195
|
}
|
|
190
|
-
const rectOf = (d) => { const l = Math.min(d.x0, d.x1), t = Math.min(d.y0, d.y1); return { left: l, top: t, width: Math.abs(d.x1 - d.x0), height: Math.abs(d.y1 - d.y0), right: l + Math.abs(d.x1 - d.x0), bottom: t + Math.abs(d.y1 - d.y0) }; };
|
|
191
196
|
|
|
192
197
|
// ---- the note box ----
|
|
193
198
|
let composer = null;
|
|
@@ -196,9 +201,9 @@
|
|
|
196
201
|
closeComposerUi();
|
|
197
202
|
const r = d.rect;
|
|
198
203
|
const c = el("c");
|
|
199
|
-
const
|
|
200
|
-
c.style.left =
|
|
201
|
-
c.style.top =
|
|
204
|
+
const at = composerPos(r, innerWidth, innerHeight);
|
|
205
|
+
c.style.left = at.left + "px";
|
|
206
|
+
c.style.top = at.top + "px";
|
|
202
207
|
const code = document.createElement("code"); code.textContent = d.label;
|
|
203
208
|
const ta = document.createElement("textarea"); ta.placeholder = d.kind === "text" ? "What should change about this text?" : "What should change?";
|
|
204
209
|
const row = el("r");
|
|
@@ -224,19 +229,18 @@
|
|
|
224
229
|
async function finish(comment, intent, severity) {
|
|
225
230
|
const d = draft, first = d.els[0];
|
|
226
231
|
closeComposerUi();
|
|
227
|
-
const note = {
|
|
228
|
-
kind: d.kind, comment, intent, severity,
|
|
229
|
-
selector: selectorFor(first), items: d.els.length > 1 ? d.els.map(selectorFor) : [],
|
|
230
|
-
path: pathOf(first), text: textOf(first).slice(0, 200), tag: describe(first), url: location.href,
|
|
231
|
-
box: `${Math.round(d.rect.left + scrollX)},${Math.round(d.rect.top + scrollY)} ${Math.round(d.rect.width)}x${Math.round(d.rect.height)}`,
|
|
232
|
-
pb: { x: d.rect.left + scrollX, y: d.rect.top + scrollY, w: d.rect.width, h: d.rect.height }, page: location.pathname,
|
|
233
|
-
attrs: attrsOf(first), styles: stylesOf(first),
|
|
234
|
-
nearby: [first.previousElementSibling, first.nextElementSibling].filter(Boolean).map((e) => textOf(e).slice(0, 80)).filter(Boolean).join(" | "),
|
|
235
|
-
selected: d.selected || "",
|
|
236
|
-
};
|
|
237
232
|
const s = sourceOf(first);
|
|
238
|
-
note
|
|
239
|
-
|
|
233
|
+
const note: any = buildNote(
|
|
234
|
+
{ kind: d.kind, rect: d.rect, count: d.els.length, selected: d.selected },
|
|
235
|
+
{
|
|
236
|
+
selector: selectorFor(first), items: d.els.length > 1 ? d.els.map(selectorFor) : [], path: pathOf(first), text: textOf(first), tag: describe(first), url: location.href, page: location.pathname,
|
|
237
|
+
attrs: attrsOf(first), styles: stylesOf(first),
|
|
238
|
+
nearby: [first.previousElementSibling, first.nextElementSibling].filter(Boolean).map((e) => textOf(e).slice(0, 80)).filter(Boolean).join(" | "),
|
|
239
|
+
source: s.source, components: cfg.components ? s.components : "",
|
|
240
|
+
},
|
|
241
|
+
{ comment, intent, severity },
|
|
242
|
+
{ x: scrollX, y: scrollY },
|
|
243
|
+
);
|
|
240
244
|
draft = null; multi = []; paint();
|
|
241
245
|
note.crop = await crop(d.els, d.rect);
|
|
242
246
|
send({ type: "note", note });
|
|
@@ -270,19 +274,16 @@
|
|
|
270
274
|
try {
|
|
271
275
|
let base = common(els);
|
|
272
276
|
let br = base.getBoundingClientRect();
|
|
273
|
-
if (br
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const w
|
|
277
|
+
if (tooBig(br)) { base = els[0]; br = base.getBoundingClientRect(); }
|
|
278
|
+
const win = cropWindow(br, want);
|
|
279
|
+
if (!win) return undefined;
|
|
280
|
+
const { w, h, sx, sy, sw, sh } = win;
|
|
281
|
+
const c = snap(base, { n: CROP_BUDGET });
|
|
277
282
|
c.style.cssText += `;margin:0;transform:none;position:static;width:${w}px;height:${h}px;box-sizing:border-box`;
|
|
278
283
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}"><foreignObject x="0" y="0" width="100%" height="100%">${new XMLSerializer().serializeToString(c)}</foreignObject></svg>`;
|
|
279
284
|
const img = new Image();
|
|
280
285
|
await new Promise((ok, no) => { img.onload = ok; img.onerror = () => no(new Error("render")); setTimeout(() => no(new Error("timeout")), 2500); img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg); });
|
|
281
|
-
const
|
|
282
|
-
const sw = Math.min(w - sx, want.width), sh = Math.min(h - sy, want.height);
|
|
283
|
-
if (sw < 2 || sh < 2) return undefined;
|
|
284
|
-
for (let k = Math.min(2, window.devicePixelRatio || 1); k >= 0.5; k -= 0.5) {
|
|
285
|
-
const scale = Math.min(k, 1600 / Math.max(sw, sh));
|
|
286
|
+
for (const scale of cropScales(sw, sh, window.devicePixelRatio)) {
|
|
286
287
|
const cv = document.createElement("canvas");
|
|
287
288
|
cv.width = Math.round(sw * scale); cv.height = Math.round(sh * scale);
|
|
288
289
|
const g = cv.getContext("2d");
|
|
@@ -291,7 +292,7 @@
|
|
|
291
292
|
g.fillRect(0, 0, cv.width, cv.height);
|
|
292
293
|
g.drawImage(img, sx, sy, sw, sh, 0, 0, cv.width, cv.height);
|
|
293
294
|
const url = cv.toDataURL("image/png");
|
|
294
|
-
if (url.length <
|
|
295
|
+
if (url.length < CROP_CHARS) return url;
|
|
295
296
|
}
|
|
296
297
|
} catch {}
|
|
297
298
|
return undefined;
|
|
@@ -301,7 +302,7 @@
|
|
|
301
302
|
const inHost = (e) => e.composedPath && e.composedPath().includes(host);
|
|
302
303
|
const target = (x, y) => { const e = document.elementFromPoint(x, y); return e && e !== host && e !== document.documentElement ? e : null; };
|
|
303
304
|
const rectFor = (els) => union(els.map((e) => e.getBoundingClientRect()));
|
|
304
|
-
const quoted = (e) =>
|
|
305
|
+
const quoted = (e) => quote(textOf(e), describe(e));
|
|
305
306
|
const pickElement = (e) => openComposer({ kind: "element", els: [e], rect: rectFor([e]), label: quoted(e) });
|
|
306
307
|
function commitMulti() { if (!multi.length) return; const els = multi.slice(); openComposer({ kind: "multi", els, rect: rectFor(els), label: `${els.length} elements` }); }
|
|
307
308
|
function areaItems(r) {
|
|
@@ -309,9 +310,8 @@
|
|
|
309
310
|
for (const e of document.body.querySelectorAll("*")) {
|
|
310
311
|
if (SKIP.has(e.tagName) || e === host) continue;
|
|
311
312
|
const b = e.getBoundingClientRect();
|
|
312
|
-
if (b.
|
|
313
|
-
if (
|
|
314
|
-
if (out.length >= 20) break;
|
|
313
|
+
if (insideArea(b, r) && !out.some((o) => o.contains(e))) { for (let i = out.length - 1; i >= 0; i--) if (e.contains(out[i])) out.splice(i, 1); out.push(e); }
|
|
314
|
+
if (out.length >= AREA_MAX) break;
|
|
315
315
|
}
|
|
316
316
|
return out;
|
|
317
317
|
}
|
|
@@ -330,7 +330,7 @@
|
|
|
330
330
|
if (ev === "mousedown" && cfg.mode === "area" && e.button === 0) { e.preventDefault(); drag = { x0: e.clientX, y0: e.clientY, x1: e.clientX, y1: e.clientY }; stop(e); }
|
|
331
331
|
if (ev === "mouseup" && drag) {
|
|
332
332
|
const r = rectOf(drag); drag = null;
|
|
333
|
-
if (r
|
|
333
|
+
if (areaBigEnough(r)) { const els = areaItems(r); openComposer({ kind: "area", els: els.length ? els : [document.body], rect: r, label: areaLabel(r, els.length) }); } else paint();
|
|
334
334
|
}
|
|
335
335
|
if (ev === "mouseup" && cfg.mode === "text") {
|
|
336
336
|
setTimeout(() => {
|
|
@@ -363,7 +363,8 @@
|
|
|
363
363
|
}, true);
|
|
364
364
|
addEventListener("scroll", () => marks.length && paint(), true);
|
|
365
365
|
addEventListener("resize", () => paint());
|
|
366
|
-
|
|
366
|
+
// (not while a marker is hovered: paint() replaces the marker, and a click needs the same element from press to release)
|
|
367
|
+
setInterval(() => marks.length && !draft && !tip && paint(), 700);
|
|
367
368
|
|
|
368
369
|
// ---- the board speaks, the page listens (only the framing window, with the token) ----
|
|
369
370
|
addEventListener("message", (e) => {
|
|
@@ -377,7 +378,7 @@
|
|
|
377
378
|
if (cfg.mode !== "multi") multi = [];
|
|
378
379
|
document.documentElement.style.cursor = "";
|
|
379
380
|
paint();
|
|
380
|
-
} else if (d.type === "markers") { marks = Array.isArray(d.list) ? d.list : []; paint(); }
|
|
381
|
+
} else if (d.type === "markers") { marks = Array.isArray(d.list) ? d.list : []; if (tip) tip = marks.find((m) => m.n === tip.n) || null; paint(); }
|
|
381
382
|
else if (d.type === "commit") commitMulti();
|
|
382
383
|
else if (d.type === "copy" && typeof d.text === "string") {
|
|
383
384
|
(navigator.clipboard ? navigator.clipboard.writeText(d.text) : Promise.reject()).catch(() => {
|
package/web/boot/boot.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// A blocking script in the head of the board and the Notebook (served as /boot.js): the stored theme, colour, motion and menu
|
|
2
|
+
// fold are on <html> before the first paint, however long the bundle takes. Everything else starts with the bundle (bootShell).
|
|
3
|
+
import { applyStoredLook, fitStandalone } from "@lib/shell/stored-look.ts";
|
|
4
|
+
|
|
5
|
+
applyStoredLook();
|
|
6
|
+
fitStandalone();
|
|
7
|
+
document.documentElement.dataset.boot = "1";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Annotator } from "@lib/annotate";
|
|
3
|
+
import { cn } from "@lib/core";
|
|
4
|
+
import { Icon } from "@web/ui";
|
|
5
|
+
|
|
6
|
+
const MODES: [string, string, string][] = [
|
|
7
|
+
["element", "a-pick", "Pick an element"],
|
|
8
|
+
["text", "a-text", "Select text"],
|
|
9
|
+
["multi", "a-multi", "Pick several elements"],
|
|
10
|
+
["area", "a-area", "Drag an area"],
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
// One icon button of the pill: a round 32 px target, lit when its tool is on, dimmed when it has nothing to act on.
|
|
14
|
+
function Tool({
|
|
15
|
+
icon,
|
|
16
|
+
title,
|
|
17
|
+
on,
|
|
18
|
+
off,
|
|
19
|
+
badge,
|
|
20
|
+
onClick,
|
|
21
|
+
}: {
|
|
22
|
+
icon: string;
|
|
23
|
+
title: string;
|
|
24
|
+
on?: boolean;
|
|
25
|
+
off?: boolean;
|
|
26
|
+
badge?: number;
|
|
27
|
+
onClick: () => void;
|
|
28
|
+
}) {
|
|
29
|
+
return (
|
|
30
|
+
<button
|
|
31
|
+
type="button"
|
|
32
|
+
title={title}
|
|
33
|
+
aria-label={title}
|
|
34
|
+
disabled={off}
|
|
35
|
+
onClick={onClick}
|
|
36
|
+
className={cn(
|
|
37
|
+
"relative m-0 grid size-8 cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 text-inherit hover:bg-[#2c2c2e] hover:text-white disabled:cursor-default disabled:opacity-35 disabled:hover:bg-transparent disabled:hover:text-inherit",
|
|
38
|
+
on && "bg-[#3a3a3c] text-white",
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<Icon name={icon} className="size-[17px]" />
|
|
42
|
+
{!!badge && (
|
|
43
|
+
<i className="absolute top-px right-0 h-[15px] min-w-[15px] rounded-lg bg-[#f59e0b] px-1 text-center text-[10px] leading-[15px] font-semibold text-[#1c1c1e] not-italic">
|
|
44
|
+
{badge}
|
|
45
|
+
</i>
|
|
46
|
+
)}
|
|
47
|
+
</button>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const Sep = (): ReactNode => <span className="mx-1 h-[18px] w-px bg-[#3a3a3c]" />;
|
|
51
|
+
|
|
52
|
+
// Icon buttons in one dark pill, as in Agentation: modes, then pause, markers, copy, send, clear, notes, settings, close.
|
|
53
|
+
export function AnnotateBar({ ann, wide }: { ann: Annotator; wide: boolean }) {
|
|
54
|
+
const s = ann.use((x) => x),
|
|
55
|
+
none = !s.notes.length;
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
className={cn(
|
|
59
|
+
"absolute bottom-3.5 z-[6] flex max-w-[calc(100%-28px)] flex-wrap items-center justify-center gap-0.5 rounded-[26px] border border-[#3a3a3c] bg-[#1c1c1e] p-1.5 text-[#c7c7cc] shadow-[0_8px_28px_#0007]",
|
|
60
|
+
wide ? "right-[314px] max-sm:right-[254px]" : "right-3.5",
|
|
61
|
+
)}
|
|
62
|
+
>
|
|
63
|
+
{MODES.map(([id, icon, title]) => (
|
|
64
|
+
<Tool key={id} icon={icon} title={title} on={s.on && s.settings.mode === id} onClick={() => ann.mode(id)} />
|
|
65
|
+
))}
|
|
66
|
+
<Sep />
|
|
67
|
+
<Tool icon="a-pause" title="Freeze animations (P)" on={s.pause} onClick={ann.togglePause} />
|
|
68
|
+
<Tool icon="eye" title="Show or hide markers (H)" on={!s.hide} onClick={ann.toggleHide} />
|
|
69
|
+
<Tool icon="a-copy" title="Copy notes as markdown (C)" off={none} onClick={() => void ann.copy()} />
|
|
70
|
+
<Tool icon="send" title="Type the notes into this run's agent (S)" off={none} onClick={() => void ann.send()} />
|
|
71
|
+
<Tool icon="trash" title="Remove all notes (X)" off={none} onClick={ann.clear} />
|
|
72
|
+
<Sep />
|
|
73
|
+
<Tool icon="note" title="Notes list" on={s.list} badge={s.notes.length} onClick={ann.toggleList} />
|
|
74
|
+
<Tool icon="gear" title="Output detail, colour, behaviour" on={s.setOpen} onClick={ann.toggleSettings} />
|
|
75
|
+
<Tool icon="x" title="Close the annotator (the Annotate button brings it back)" onClick={ann.close} />
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import type { Annotator } from "@lib/annotate";
|
|
3
|
+
import { AnnotateBar } from "./annotate-bar.tsx";
|
|
4
|
+
import { NotesList } from "./notes-list.tsx";
|
|
5
|
+
|
|
6
|
+
// The annotator's two floating parts over the Browser tab's frame (inside its `.annrow`, which is `position: relative`):
|
|
7
|
+
// the dark toolbar bottom right and the notes list on the right. Always mounted, because it owns the window's listeners
|
|
8
|
+
// (keys, the page's messages); it draws only while the page is open through the proxy.
|
|
9
|
+
export function AnnotatePanel({ ann }: { ann: Annotator }) {
|
|
10
|
+
const open = ann.use((s) => !!s.px),
|
|
11
|
+
list = ann.use((s) => s.list);
|
|
12
|
+
useEffect(() => ann.listen(), [ann]);
|
|
13
|
+
if (!open) return null;
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
{list && <NotesList ann={ann} />}
|
|
17
|
+
<AnnotateBar ann={ann} wide={list} />
|
|
18
|
+
</>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useEffect, useRef, type ReactNode } from "react";
|
|
2
|
+
import { LEVELS, type Annotator } from "@lib/annotate";
|
|
3
|
+
import { Checkbox, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@web/ui";
|
|
4
|
+
|
|
5
|
+
const row = "flex items-center justify-between gap-1.5 text-[12px] font-normal";
|
|
6
|
+
function Flag({ ann, k, label }: { ann: Annotator; k: "components" | "clear" | "block"; label: string }) {
|
|
7
|
+
const on = ann.use((x) => x.settings[k]);
|
|
8
|
+
return (
|
|
9
|
+
<Label className={row}>
|
|
10
|
+
<span className="flex items-center gap-1.5">
|
|
11
|
+
<Checkbox checked={on} onCheckedChange={(v) => ann.setting(k, v === true)} />
|
|
12
|
+
{label}
|
|
13
|
+
</span>
|
|
14
|
+
</Label>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// The colour is taken when the picker closes (the input's own `change`), not on every step of a drag: each one would be
|
|
19
|
+
// saved and would repaint the framed page.
|
|
20
|
+
function Color({ ann, value }: { ann: Annotator; value: string }) {
|
|
21
|
+
const ref = useRef<HTMLInputElement>(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const el = ref.current!,
|
|
24
|
+
done = () => ann.setting("color", el.value);
|
|
25
|
+
el.addEventListener("change", done);
|
|
26
|
+
return () => el.removeEventListener("change", done);
|
|
27
|
+
}, []);
|
|
28
|
+
return <input ref={ref} type="color" defaultValue={value} key={value} />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Output detail, marker colour and behaviour, at the top of the notes list; each change is saved at once.
|
|
32
|
+
export function AnnotateSettings({ ann }: { ann: Annotator }): ReactNode {
|
|
33
|
+
const s = ann.use((x) => x.settings);
|
|
34
|
+
return (
|
|
35
|
+
<div className="flex flex-col gap-1.5 rounded-sm border border-border p-2">
|
|
36
|
+
<div className={row}>
|
|
37
|
+
<Label className={row}>Output detail</Label>
|
|
38
|
+
<Select value={s.level} onValueChange={(v) => ann.setting("level", v)}>
|
|
39
|
+
<SelectTrigger size="sm" aria-label="Output detail">
|
|
40
|
+
<SelectValue />
|
|
41
|
+
</SelectTrigger>
|
|
42
|
+
<SelectContent>
|
|
43
|
+
{LEVELS.map((l) => (
|
|
44
|
+
<SelectItem key={l} value={l}>
|
|
45
|
+
{l}
|
|
46
|
+
</SelectItem>
|
|
47
|
+
))}
|
|
48
|
+
</SelectContent>
|
|
49
|
+
</Select>
|
|
50
|
+
</div>
|
|
51
|
+
<Flag ann={ann} k="components" label="Component names" />
|
|
52
|
+
<Label className={row}>
|
|
53
|
+
Marker colour
|
|
54
|
+
<Color ann={ann} value={s.color} />
|
|
55
|
+
</Label>
|
|
56
|
+
<Flag ann={ann} k="clear" label="Clear after copy or send" />
|
|
57
|
+
<Flag ann={ann} k="block" label="Block page clicks while picking" />
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./annotate-panel.tsx";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { group, type Annotator, type Note } from "@lib/annotate";
|
|
3
|
+
import { cn } from "@lib/core";
|
|
4
|
+
import { Textarea } from "@web/ui";
|
|
5
|
+
import { AnnotateSettings } from "./annotate-settings.tsx";
|
|
6
|
+
|
|
7
|
+
// One note: its number (green for a group), the comment (edit it in place, saved when you leave the box), the selector,
|
|
8
|
+
// intent and severity, the picture of what was picked, and delete. Scrolls into view and flashes when its marker is
|
|
9
|
+
// clicked on the page.
|
|
10
|
+
function NoteRow({ ann, note, flash }: { ann: Annotator; note: Note; flash: boolean }) {
|
|
11
|
+
const row = useRef<HTMLDivElement>(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (flash) row.current?.scrollIntoView({ block: "nearest" });
|
|
14
|
+
}, [flash]);
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
ref={row}
|
|
18
|
+
className={cn("flex items-start gap-2 rounded-sm border border-border p-2", flash && "outline-2 outline-primary")}
|
|
19
|
+
>
|
|
20
|
+
<b
|
|
21
|
+
className={cn(
|
|
22
|
+
"grid size-[22px] shrink-0 place-items-center rounded-full bg-primary text-[12px] font-normal text-primary-foreground",
|
|
23
|
+
group(note.kind) && "bg-[#34c759] text-white",
|
|
24
|
+
)}
|
|
25
|
+
>
|
|
26
|
+
{note.n}
|
|
27
|
+
</b>
|
|
28
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
29
|
+
<Textarea
|
|
30
|
+
key={note.comment}
|
|
31
|
+
defaultValue={note.comment}
|
|
32
|
+
spellCheck={false}
|
|
33
|
+
rows={1}
|
|
34
|
+
aria-label={`Note ${note.n}`}
|
|
35
|
+
className="m-0 field-sizing-content min-h-[1lh] font-[inherit] rounded-[3px] border-0 p-0 text-[12px] break-words whitespace-pre-wrap focus:bg-muted"
|
|
36
|
+
onBlur={(e) => ann.editNote(note.n, e.currentTarget.value)}
|
|
37
|
+
/>
|
|
38
|
+
<code className="block truncate text-[11px] text-muted-foreground">{note.selector}</code>
|
|
39
|
+
<small className="text-[10px] text-muted-foreground">
|
|
40
|
+
{note.intent} · {note.severity}
|
|
41
|
+
{note.crop ? "" : " · no crop"}
|
|
42
|
+
</small>
|
|
43
|
+
{note.crop && <img alt="crop" src={note.crop} className="max-w-full rounded-xs border border-border" />}
|
|
44
|
+
</div>
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
title="Delete"
|
|
48
|
+
aria-label="Delete"
|
|
49
|
+
onClick={() => ann.removeNote(note.n)}
|
|
50
|
+
className="m-0 cursor-pointer border-0 bg-transparent p-0 text-[16px] leading-none text-muted-foreground"
|
|
51
|
+
>
|
|
52
|
+
×
|
|
53
|
+
</button>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function NotesList({ ann }: { ann: Annotator }) {
|
|
59
|
+
const notes = ann.use((s) => s.notes),
|
|
60
|
+
flash = ann.use((s) => s.flash),
|
|
61
|
+
settings = ann.use((s) => s.setOpen);
|
|
62
|
+
return (
|
|
63
|
+
<div className="absolute inset-y-0 right-0 z-[5] flex w-[300px] max-w-[85%] flex-col gap-2 overflow-auto border-l border-border bg-background p-2.5 text-[12px] shadow-[-8px_0_24px_#0003] max-sm:w-[240px]">
|
|
64
|
+
{settings && <AnnotateSettings ann={ann} />}
|
|
65
|
+
{!notes.length && (
|
|
66
|
+
<p className="m-2 text-muted-foreground">
|
|
67
|
+
No notes yet. Pick something on the page and write what should change.
|
|
68
|
+
</p>
|
|
69
|
+
)}
|
|
70
|
+
{notes.map((n) => (
|
|
71
|
+
<NoteRow key={n.id} ann={ann} note={n} flash={flash === n.n} />
|
|
72
|
+
))}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|