kaizen-agent 1.85.2 → 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/rea.ts +99 -11
- package/cli/settings.ts +16 -17
- package/cli/state.ts +15 -29
- package/cli/task-service.ts +114 -34
- package/cli/tasks.ts +8 -2
- 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 +197 -61
- package/package.json +21 -4
- package/skills/kaizen/spec.md +12 -4
- package/skills/optional/disk-cleanup/SKILL.md +60 -0
- package/skills/optional/disk-cleanup/skill.json +1 -0
- package/skills/optional/disk-cleanup/tui.py +90 -0
- 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/term-paste.ts +10 -0
- package/web/{term.ts → term/term.ts} +101 -27
- 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 -86
- 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 -615
- 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 -500
- package/web/notebook.js +0 -514
- package/web/notebook.ts +0 -1254
- package/web/popup.html +0 -141
- package/web/video.js +0 -570
- /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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./browser.ts";
|
|
2
|
+
export * from "./grip.ts";
|
|
3
|
+
export * from "./layout.ts";
|
|
4
|
+
export * from "./layout-store.ts";
|
|
5
|
+
export * from "./panel-store.ts";
|
|
6
|
+
export * from "./run-actions.ts";
|
|
7
|
+
export * from "./run-view-store.ts";
|
|
8
|
+
export * from "./viewer.ts";
|
|
9
|
+
export * from "./term-loader.ts";
|
|
10
|
+
export * from "./preview.ts";
|
|
11
|
+
export * from "./doc.ts";
|
|
12
|
+
export * from "./ws-tabs.ts";
|
|
13
|
+
export * from "./card-terminal.ts";
|
|
14
|
+
export * from "./panel-actions.ts";
|
|
15
|
+
export * from "./panel-derive.ts";
|
|
16
|
+
export * from "./use-panel-run.ts";
|
|
17
|
+
export * from "./workspace.ts";
|
|
18
|
+
export * from "./use-run-lifecycle.ts";
|
|
19
|
+
export * from "./kept.ts";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Which workspaces keep their panes mounted (hidden) once visited, and when one goes. No DOM, tested alone (kept.test.ts).
|
|
2
|
+
// A kept workspace holds every pane it had (terminals, the Browser frame, notes iframes, History, Preview), so leaving it for
|
|
3
|
+
// another page and coming back keeps a frame's page, scroll and typed text and a terminal's screen. Each terminal holds a
|
|
4
|
+
// 5000-line scrollback and a WebGL context, and Chrome keeps about 16 contexts, dropping the oldest, so the hidden ones are
|
|
5
|
+
// capped: the shown workspace always stays, then the most recently visited ones while both limits hold. A workspace over
|
|
6
|
+
// the limit is unmounted and made again on return (/pty replays a session on attach; a frame loads its address again).
|
|
7
|
+
import type { RvPane } from "./run-view-store.ts";
|
|
8
|
+
|
|
9
|
+
export type KeptWs = { items: RvPane[]; ws: { dir: string; ws: string } };
|
|
10
|
+
export type Kept = Record<string, KeptWs>;
|
|
11
|
+
export const KEEP_WORKSPACES = 4; // the shown one and the three visited most recently before it
|
|
12
|
+
export const KEEP_TERMINALS = 12; // under the ~16 WebGL contexts one page gets, with room for the Terminal page and in-card ones
|
|
13
|
+
export const isTerm = (i: Pick<RvPane, "kind">) => i.kind === "agent" || i.kind === "shell";
|
|
14
|
+
export const termsIn = (v: KeptWs) => v.items.filter(isTerm).length;
|
|
15
|
+
|
|
16
|
+
// `recent`: workspace keys, least recently shown first. Showing one moves it to the end.
|
|
17
|
+
export const touch = (recent: string[], k: string) => [...recent.filter((x) => x !== k), k];
|
|
18
|
+
|
|
19
|
+
// The keys to keep: the shown workspace, then the most recent others while the workspace and terminal counts fit. A
|
|
20
|
+
// workspace that does not fit ends the walk, so a recent one is never dropped for an older, smaller one.
|
|
21
|
+
export function keepKeys(kept: Kept, recent: string[], shown: string | null, caps = { workspaces: KEEP_WORKSPACES, terminals: KEEP_TERMINALS }): Set<string> {
|
|
22
|
+
const keep = new Set<string>();
|
|
23
|
+
let terms = 0;
|
|
24
|
+
if (shown && kept[shown]) (keep.add(shown), (terms += termsIn(kept[shown]!)));
|
|
25
|
+
const order = [...Object.keys(kept).filter((k) => !recent.includes(k)), ...recent].filter((k) => k !== shown && kept[k]).reverse();
|
|
26
|
+
for (const k of order) {
|
|
27
|
+
if (keep.size >= caps.workspaces || terms + termsIn(kept[k]!) > caps.terminals) break;
|
|
28
|
+
keep.add(k);
|
|
29
|
+
terms += termsIn(kept[k]!);
|
|
30
|
+
}
|
|
31
|
+
return keep;
|
|
32
|
+
}
|
|
33
|
+
// `kept` without the workspaces over the cap (the same object when nothing goes).
|
|
34
|
+
export function evict(kept: Kept, recent: string[], shown: string | null, caps?: { workspaces: number; terminals: number }): Kept {
|
|
35
|
+
const keep = keepKeys(kept, recent, shown, caps);
|
|
36
|
+
if (Object.keys(kept).every((k) => keep.has(k))) return kept;
|
|
37
|
+
return Object.fromEntries(Object.entries(kept).filter(([k]) => keep.has(k)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Session keys that are alive: the shells, the agents the board lists, and every pty of every card.
|
|
41
|
+
export const liveKeys = (shells: { key: string }[], agents: { key: string }[], cards: any[]) =>
|
|
42
|
+
new Set<string>([...shells.map((x) => x.key), ...agents.map((a) => a.key), ...cards.flatMap((c) => (c.pty ? [c.pty.key, ...(c.pty.all ?? [])] : []))]);
|
|
43
|
+
// A kept terminal whose session is gone (it ended, or its tab was closed in another window) is unmounted; the shown
|
|
44
|
+
// workspace is left to its own redraw. Only terminals carry a session key, so every other pane stays. Same object when
|
|
45
|
+
// nothing goes.
|
|
46
|
+
export function pruneDead(kept: Kept, live: Set<string>, shown: string | null): Kept {
|
|
47
|
+
let changed = false;
|
|
48
|
+
const next = Object.fromEntries(
|
|
49
|
+
Object.entries(kept).map(([k, v]) => {
|
|
50
|
+
if (k === shown) return [k, v];
|
|
51
|
+
const items = v.items.filter((i) => !isTerm(i) || !i.key || live.has(i.key));
|
|
52
|
+
if (items.length === v.items.length) return [k, v];
|
|
53
|
+
changed = true;
|
|
54
|
+
return [k, { ...v, items }];
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
return changed ? next : kept;
|
|
58
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// The run workspace's saved layout (Zustand, kept in localStorage "kz-runtabs" as before): per workspace the extra tabs
|
|
2
|
+
// opened by hand (localhost, Preview, notes, History), the agent tabs closed, and the screens with their pane trees.
|
|
3
|
+
// The pane tree rules are in layout.ts; this store only holds them, so the panes (components/run/run-panes.tsx) are
|
|
4
|
+
// drawn from it and a resize, a split or a drag is a state change, never a DOM move.
|
|
5
|
+
import { create } from "zustand";
|
|
6
|
+
import {
|
|
7
|
+
leaves,
|
|
8
|
+
moveItem as moveIn,
|
|
9
|
+
prune,
|
|
10
|
+
reconcile,
|
|
11
|
+
resize,
|
|
12
|
+
type Dir,
|
|
13
|
+
type Node,
|
|
14
|
+
type Screen,
|
|
15
|
+
type Target,
|
|
16
|
+
} from "./layout.ts";
|
|
17
|
+
|
|
18
|
+
export type SavedTab = { id: string; kind: string; title: string; key?: string; note?: string; agent?: string };
|
|
19
|
+
// `seen`: the runs that already opened the Browser on their Preview, so a run does it once.
|
|
20
|
+
export type Saved = {
|
|
21
|
+
tabs: SavedTab[];
|
|
22
|
+
hidden: string[];
|
|
23
|
+
hb?: Record<string, number>;
|
|
24
|
+
screens: Screen[];
|
|
25
|
+
on: string | null;
|
|
26
|
+
seen?: string[];
|
|
27
|
+
};
|
|
28
|
+
const KEY = "kz-runtabs";
|
|
29
|
+
export const EMPTY: Saved = { tabs: [], hidden: [], screens: [], on: null };
|
|
30
|
+
|
|
31
|
+
// Layouts saved while runs were tabs: those tabs are gone, the panel picks runs now. Older saves had one split.
|
|
32
|
+
export function clean(s: Partial<Saved>): Saved {
|
|
33
|
+
const screens = Array.isArray(s.screens) && s.screens.every((sc) => sc?.tree) ? s.screens : [];
|
|
34
|
+
const { split: _old, ...rest } = s as Partial<Saved> & { split?: unknown }; // the one-split key of older saves is not written back
|
|
35
|
+
return {
|
|
36
|
+
...rest,
|
|
37
|
+
tabs: (s.tabs ?? []).filter((t) => t && t.kind !== "run"),
|
|
38
|
+
hidden: (s.hidden ?? []).filter((h) => typeof h === "string" && !h.startsWith("rn:")),
|
|
39
|
+
screens,
|
|
40
|
+
on: s.on ?? null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// One workspace's entry that is not an object is dropped alone: it must not take every other workspace's layout with it.
|
|
44
|
+
export function readSaved(raw: string | null): Record<string, Saved> {
|
|
45
|
+
try {
|
|
46
|
+
const all = JSON.parse(raw || "{}") as Record<string, Partial<Saved> | null>;
|
|
47
|
+
return Object.fromEntries(
|
|
48
|
+
Object.entries(all)
|
|
49
|
+
.filter(([, s]) => s && typeof s === "object")
|
|
50
|
+
.map(([k, s]) => [k, clean(s!)]),
|
|
51
|
+
);
|
|
52
|
+
} catch {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const read = () => {
|
|
57
|
+
try {
|
|
58
|
+
return readSaved(localStorage.getItem(KEY));
|
|
59
|
+
} catch {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const persist = (all: Record<string, Saved>) => {
|
|
64
|
+
try {
|
|
65
|
+
localStorage.setItem(KEY, JSON.stringify(all));
|
|
66
|
+
} catch {}
|
|
67
|
+
};
|
|
68
|
+
const newId = () => "s" + Date.now().toString(36) + Math.random().toString(36).slice(2, 5);
|
|
69
|
+
|
|
70
|
+
export type Layout = {
|
|
71
|
+
all: Record<string, Saved>;
|
|
72
|
+
dragging: string | null; // the item whose header or tab is being dragged
|
|
73
|
+
target: Target; // where the next item goes (set by the split menus)
|
|
74
|
+
// A request to open an address in a workspace's Browser tab; the tab takes it when it shows.
|
|
75
|
+
browse: { k: string; url: string } | null;
|
|
76
|
+
previewTick: number; // bumped to make the Preview tab read its run again
|
|
77
|
+
};
|
|
78
|
+
export const useLayout = create<Layout>()(() => ({
|
|
79
|
+
all: read(),
|
|
80
|
+
dragging: null,
|
|
81
|
+
target: null,
|
|
82
|
+
browse: null,
|
|
83
|
+
previewTick: 0,
|
|
84
|
+
}));
|
|
85
|
+
const set = useLayout.setState;
|
|
86
|
+
export const layoutOf = (k: string): Saved => useLayout.getState().all[k] ?? EMPTY;
|
|
87
|
+
// Changes one workspace's record; `save: false` for the middle of a drag (the end saves).
|
|
88
|
+
export function patch(k: string, fn: (s: Saved) => Saved, save = true) {
|
|
89
|
+
const { all } = useLayout.getState(),
|
|
90
|
+
cur = all[k] ?? EMPTY,
|
|
91
|
+
next = fn(cur);
|
|
92
|
+
if (next === cur) return;
|
|
93
|
+
const a = { ...all, [k]: next };
|
|
94
|
+
set({ all: a });
|
|
95
|
+
if (save) persist(a);
|
|
96
|
+
}
|
|
97
|
+
export const saveLayout = () => persist(useLayout.getState().all);
|
|
98
|
+
// Replaces every record (the old per-run layouts moved to their workspace).
|
|
99
|
+
export function replaceAll(all: Record<string, Saved>) {
|
|
100
|
+
const a = Object.fromEntries(Object.entries(all).map(([k, s]) => [k, clean(s)]));
|
|
101
|
+
set({ all: a });
|
|
102
|
+
persist(a);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const setTarget = (target: Target) => set({ target });
|
|
106
|
+
export const setDragging = (dragging: string | null) => set({ dragging });
|
|
107
|
+
export const requestBrowse = (k: string, url: string) => set({ browse: { k, url } });
|
|
108
|
+
export const clearBrowse = () => set({ browse: null });
|
|
109
|
+
export const refreshPreview = () => set((s) => ({ previewTick: s.previewTick + 1 }));
|
|
110
|
+
|
|
111
|
+
// After the open items changed: each sits in one screen (see layout.ts reconcile). Saves only when something moved.
|
|
112
|
+
export function placeItems(k: string, ids: string[]) {
|
|
113
|
+
const { target } = useLayout.getState(),
|
|
114
|
+
s = layoutOf(k),
|
|
115
|
+
r = reconcile(s.screens, s.on, ids, target, newId);
|
|
116
|
+
if (r.target !== target) set({ target: r.target });
|
|
117
|
+
patch(k, (c) => (r.screens === c.screens && r.on === c.on ? c : { ...c, screens: r.screens, on: r.on }));
|
|
118
|
+
}
|
|
119
|
+
export const selectScreen = (k: string, sid: string) => patch(k, (s) => (s.on === sid ? s : { ...s, on: sid }));
|
|
120
|
+
export const focusItem = (k: string, id: string) =>
|
|
121
|
+
patch(k, (s) => {
|
|
122
|
+
const sc = s.screens.find((x) => x.id === s.on);
|
|
123
|
+
return !sc || sc.focus === id ? s : { ...s, screens: s.screens.map((x) => (x === sc ? { ...sc, focus: id } : x)) };
|
|
124
|
+
});
|
|
125
|
+
// Shows the screen that holds the item, if one does.
|
|
126
|
+
export const showItem = (k: string, id: string) =>
|
|
127
|
+
patch(k, (s) => {
|
|
128
|
+
const on = s.screens.find((sc) => leaves(sc.tree).includes(id))?.id ?? s.on;
|
|
129
|
+
return on === s.on ? s : { ...s, on };
|
|
130
|
+
});
|
|
131
|
+
export function moveInLayout(
|
|
132
|
+
k: string,
|
|
133
|
+
id: string,
|
|
134
|
+
to: string | null,
|
|
135
|
+
at?: { pane: string; dir: Dir; before: boolean },
|
|
136
|
+
) {
|
|
137
|
+
const r = moveIn(layoutOf(k).screens, id, to, at, newId);
|
|
138
|
+
if (r) patch(k, (s) => ({ ...s, screens: r.screens, on: r.on }));
|
|
139
|
+
return !!r;
|
|
140
|
+
}
|
|
141
|
+
// Moving an open item into the target screen means taking it out of its old one.
|
|
142
|
+
export const detach = (k: string, id: string) =>
|
|
143
|
+
patch(k, (s) => ({
|
|
144
|
+
...s,
|
|
145
|
+
screens: s.screens.map((sc) => ({ ...sc, tree: prune(sc.tree, (x) => x !== id) ?? sc.tree })),
|
|
146
|
+
}));
|
|
147
|
+
// A gutter drag: the sizes follow the pointer without saving; the end saves.
|
|
148
|
+
export const resizeAt = (k: string, sid: string, path: number[], i: number, f: number) =>
|
|
149
|
+
patch(
|
|
150
|
+
k,
|
|
151
|
+
(s) => ({
|
|
152
|
+
...s,
|
|
153
|
+
screens: s.screens.map((sc) => (sc.id === sid ? { ...sc, tree: resize(sc.tree, path, i, f) as Node } : sc)),
|
|
154
|
+
}),
|
|
155
|
+
false,
|
|
156
|
+
);
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// The run workspace's pane layout as plain data, no DOM. A screen is one tab of the workspace's bar and holds a
|
|
2
|
+
// tmux-style tree: a leaf is an item id, a split holds two or more children side by side ("cols") or stacked ("rows")
|
|
3
|
+
// with their relative sizes. Every function returns a new value (or the same one when nothing changed), so the layout
|
|
4
|
+
// store can compare by identity and React can draw each pane from its rectangle without moving any pane element.
|
|
5
|
+
// A workspace's key in the saved layouts (localStorage kz-runtabs).
|
|
6
|
+
export const wsKey = (dir: string, ws: string) => `ws:${dir}:${ws}`;
|
|
7
|
+
export type Dir = "cols" | "rows";
|
|
8
|
+
export type Node = string | { dir: Dir; kids: Node[]; sizes: number[] };
|
|
9
|
+
export type Screen = { id: string; tree: Node; focus: string };
|
|
10
|
+
// Where the next new item goes: beside or below the focused pane of a screen; null: a screen of its own.
|
|
11
|
+
export type Target = { screen: string; dir: Dir } | null;
|
|
12
|
+
export type Box = { left: number; top: number; right: number; bottom: number };
|
|
13
|
+
// A pane's place in its container as fractions (0..1).
|
|
14
|
+
export type Rect = { l: number; t: number; w: number; h: number };
|
|
15
|
+
// The bar between two children: where it sits, and the span of the two children it divides (`start`, `total` along
|
|
16
|
+
// its axis, as container fractions) so a pointer position maps to their share.
|
|
17
|
+
export type Gut = {
|
|
18
|
+
path: number[];
|
|
19
|
+
i: number;
|
|
20
|
+
dir: Dir;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
len: number;
|
|
24
|
+
start: number;
|
|
25
|
+
total: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const leaves = (n: Node): string[] => (typeof n === "string" ? [n] : n.kids.flatMap(leaves));
|
|
29
|
+
// Drops ids no longer open; a split left with one child becomes that child.
|
|
30
|
+
export function prune(n: Node, keep: (id: string) => boolean): Node | null {
|
|
31
|
+
if (typeof n === "string") return keep(n) ? n : null;
|
|
32
|
+
const kids: Node[] = [],
|
|
33
|
+
sizes: number[] = [];
|
|
34
|
+
n.kids.forEach((k, i) => {
|
|
35
|
+
const p = prune(k, keep);
|
|
36
|
+
if (p) (kids.push(p), sizes.push(n.sizes[i] ?? 1));
|
|
37
|
+
});
|
|
38
|
+
if (!kids.length) return null;
|
|
39
|
+
if (kids.length === 1) return kids[0]!;
|
|
40
|
+
// Nothing dropped: the same node.
|
|
41
|
+
return kids.length === n.kids.length && kids.every((k, i) => k === n.kids[i]) ? n : { dir: n.dir, kids, sizes };
|
|
42
|
+
}
|
|
43
|
+
// tmux: the pane `at` splits in two, the new item right of or under it (`before`: left of or above).
|
|
44
|
+
export function splitAt(n: Node, at: string, add: string, dir: Dir, before = false): Node {
|
|
45
|
+
if (typeof n === "string") return n === at ? { dir, kids: before ? [add, n] : [n, add], sizes: [1, 1] } : n;
|
|
46
|
+
return { ...n, kids: n.kids.map((k) => splitAt(k, at, add, dir, before)) };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// The pane next to `from` in a direction: it must lie past that edge and share some of the
|
|
50
|
+
// other axis; the closest wins, then the one lined up best.
|
|
51
|
+
export function nearestPane(boxes: Record<string, Box>, from: string, dir: "l" | "r" | "u" | "d"): string | null {
|
|
52
|
+
const a = boxes[from];
|
|
53
|
+
if (!a) return null;
|
|
54
|
+
const across = dir === "l" || dir === "r";
|
|
55
|
+
const gap = (b: Box) =>
|
|
56
|
+
dir === "l" ? a.left - b.right : dir === "r" ? b.left - a.right : dir === "u" ? a.top - b.bottom : b.top - a.bottom;
|
|
57
|
+
const lap = (b: Box) =>
|
|
58
|
+
across
|
|
59
|
+
? Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top)
|
|
60
|
+
: Math.min(a.right, b.right) - Math.max(a.left, b.left);
|
|
61
|
+
let best: string | null = null;
|
|
62
|
+
for (const [id, b] of Object.entries(boxes)) {
|
|
63
|
+
if (id === from || gap(b) < -1 || lap(b) <= 0) continue;
|
|
64
|
+
const cur = best && boxes[best];
|
|
65
|
+
if (!cur || gap(b) < gap(cur) - 1 || (Math.abs(gap(b) - gap(cur)) <= 1 && lap(b) > lap(cur))) best = id;
|
|
66
|
+
}
|
|
67
|
+
return best;
|
|
68
|
+
}
|
|
69
|
+
// The panes' rectangles as boxes in thousandths of the container, for nearestPane (which forgives a gap of one unit).
|
|
70
|
+
export const boxesOf = (r: Record<string, Rect>): Record<string, Box> =>
|
|
71
|
+
Object.fromEntries(
|
|
72
|
+
Object.entries(r).map(([id, b]) => [
|
|
73
|
+
id,
|
|
74
|
+
{ left: b.l * 1000, top: b.t * 1000, right: (b.l + b.w) * 1000, bottom: (b.t + b.h) * 1000 },
|
|
75
|
+
]),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const whole: Rect = { l: 0, t: 0, w: 1, h: 1 };
|
|
79
|
+
// Every pane's rectangle and every gutter of a tree laid out in the whole container.
|
|
80
|
+
export function rects(tree: Node, box: Rect = whole): { panes: Record<string, Rect>; guts: Gut[] } {
|
|
81
|
+
const panes: Record<string, Rect> = {},
|
|
82
|
+
guts: Gut[] = [];
|
|
83
|
+
const walk = (n: Node, b: Rect, path: number[]) => {
|
|
84
|
+
if (typeof n === "string") return void (panes[n] = b);
|
|
85
|
+
const cols = n.dir === "cols",
|
|
86
|
+
sum = n.sizes.reduce((s, x) => s + x, 0) || 1,
|
|
87
|
+
span = cols ? b.w : b.h;
|
|
88
|
+
let at = cols ? b.l : b.t,
|
|
89
|
+
prev = at;
|
|
90
|
+
n.kids.forEach((k, i) => {
|
|
91
|
+
const share = ((n.sizes[i] ?? 1) / sum) * span;
|
|
92
|
+
if (i) {
|
|
93
|
+
const total = at + share - prev;
|
|
94
|
+
guts.push(
|
|
95
|
+
cols
|
|
96
|
+
? { path, i, dir: n.dir, x: at, y: b.t, len: b.h, start: prev, total }
|
|
97
|
+
: { path, i, dir: n.dir, x: b.l, y: at, len: b.w, start: prev, total },
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
walk(k, cols ? { ...b, l: at, w: share } : { ...b, t: at, h: share }, [...path, i]);
|
|
101
|
+
prev = at;
|
|
102
|
+
at += share;
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
walk(tree, box, []);
|
|
106
|
+
return { panes, guts };
|
|
107
|
+
}
|
|
108
|
+
// The share of a gutter's two children that the first one gets when the pointer is at `pos` (a container fraction).
|
|
109
|
+
export const gutFrac = (g: Gut, pos: number) => Math.min(0.9, Math.max(0.1, (pos - g.start) / g.total));
|
|
110
|
+
// A tree with the two children around gutter `i` of the split at `path` sharing their space as `f` : 1 - f.
|
|
111
|
+
export function resize(tree: Node, path: number[], i: number, f: number): Node {
|
|
112
|
+
if (typeof tree === "string") return tree;
|
|
113
|
+
if (path.length) {
|
|
114
|
+
const [head, ...rest] = path as [number, ...number[]];
|
|
115
|
+
return { ...tree, kids: tree.kids.map((k, j) => (j === head ? resize(k, rest, i, f) : k)) };
|
|
116
|
+
}
|
|
117
|
+
const sum = tree.sizes[i - 1]! + tree.sizes[i]!,
|
|
118
|
+
sizes = tree.sizes.slice();
|
|
119
|
+
sizes[i - 1] = sum * f;
|
|
120
|
+
sizes[i] = sum * (1 - f);
|
|
121
|
+
return { ...tree, sizes };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// The edge of a pane a pointer is nearest to (x and y are its place in the pane as fractions): where a dropped item splits it.
|
|
125
|
+
export function edgeOf(x: number, y: number): "l" | "r" | "t" | "b" {
|
|
126
|
+
const d: ["l" | "r" | "t" | "b", number][] = [
|
|
127
|
+
["l", x],
|
|
128
|
+
["r", 1 - x],
|
|
129
|
+
["t", y],
|
|
130
|
+
["b", 1 - y],
|
|
131
|
+
];
|
|
132
|
+
return d.sort((a, b) => a[1] - b[1])[0]![0];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const sameList = <T>(a: T[], b: T[]) => a.length === b.length && a.every((x, i) => x === b[i]);
|
|
136
|
+
// Every item sits in exactly one screen. Items no longer open leave their screen (an emptied screen goes); an item
|
|
137
|
+
// not placed yet goes to `target`, else to a screen of its own. `on` falls back to the first screen. Returns the
|
|
138
|
+
// same arrays when nothing changed. `target` comes back null once it was used.
|
|
139
|
+
export function reconcile(
|
|
140
|
+
screens: Screen[],
|
|
141
|
+
on: string | null,
|
|
142
|
+
ids: string[],
|
|
143
|
+
target: Target,
|
|
144
|
+
newId: () => string,
|
|
145
|
+
): { screens: Screen[]; on: string | null; target: Target } {
|
|
146
|
+
let list = screens.flatMap((sc) => {
|
|
147
|
+
const tree = prune(sc.tree, (id) => ids.includes(id));
|
|
148
|
+
if (!tree) return [];
|
|
149
|
+
const focus = leaves(tree).includes(sc.focus) ? sc.focus : leaves(tree)[0]!;
|
|
150
|
+
return [tree === sc.tree && focus === sc.focus ? sc : { ...sc, tree, focus }];
|
|
151
|
+
});
|
|
152
|
+
for (const id of ids)
|
|
153
|
+
if (!list.some((sc) => leaves(sc.tree).includes(id))) {
|
|
154
|
+
const into = target && list.find((sc) => sc.id === target!.screen);
|
|
155
|
+
if (into) {
|
|
156
|
+
const t = target!;
|
|
157
|
+
list = list.map((sc) => (sc === into ? { ...sc, tree: splitAt(sc.tree, sc.focus, id, t.dir), focus: id } : sc));
|
|
158
|
+
on = into.id;
|
|
159
|
+
} else list = [...list, { id: newId(), tree: id, focus: id }];
|
|
160
|
+
target = null;
|
|
161
|
+
}
|
|
162
|
+
if (!list.some((sc) => sc.id === on)) on = list[0]?.id ?? null;
|
|
163
|
+
return { screens: sameList(list, screens) ? screens : list, on, target };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Moves an item out of its screen into another one (split beside pane `at.pane` there, or next to that screen's
|
|
167
|
+
// focused pane), or into a screen of its own (to = null). Null when there is nothing to do.
|
|
168
|
+
export function moveItem(
|
|
169
|
+
screens: Screen[],
|
|
170
|
+
id: string,
|
|
171
|
+
to: string | null,
|
|
172
|
+
at: { pane: string; dir: Dir; before: boolean } | undefined,
|
|
173
|
+
newId: () => string,
|
|
174
|
+
): { screens: Screen[]; on: string } | null {
|
|
175
|
+
if (at?.pane === id) return null;
|
|
176
|
+
// Dropped on the screen it is already in, with no pane edge to split at: nothing to do.
|
|
177
|
+
if (!at && to && screens.some((sc) => sc.id === to && leaves(sc.tree).includes(id))) return null;
|
|
178
|
+
let list = screens
|
|
179
|
+
.map((sc) => {
|
|
180
|
+
const tree = prune(sc.tree, (x) => x !== id) ?? "";
|
|
181
|
+
return { ...sc, tree, focus: tree !== "" && !leaves(tree).includes(sc.focus) ? leaves(tree)[0]! : sc.focus };
|
|
182
|
+
})
|
|
183
|
+
.filter((sc) => sc.tree !== "");
|
|
184
|
+
const dest = to ? list.find((sc) => sc.id === to) : undefined;
|
|
185
|
+
if (dest) {
|
|
186
|
+
list = list.map((sc) =>
|
|
187
|
+
sc === dest
|
|
188
|
+
? { ...sc, tree: splitAt(sc.tree, at?.pane ?? sc.focus, id, at?.dir ?? "cols", at?.before ?? false), focus: id }
|
|
189
|
+
: sc,
|
|
190
|
+
);
|
|
191
|
+
return { screens: list, on: dest.id };
|
|
192
|
+
}
|
|
193
|
+
const sid = newId();
|
|
194
|
+
return { screens: [...list, { id: sid, tree: id, focus: id }], on: sid };
|
|
195
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// What asks the run panel for something: open a card, a tab, an item of a run, a read again, close. Each is a write to the
|
|
2
|
+
// panel store; nothing here draws or awaits a draw. usePanelRun (use-panel-run.ts) answers by reading the run and publishing
|
|
3
|
+
// what the panel shows. Keys, the host bridge, the /state reaction, the workspace and search all call these.
|
|
4
|
+
import { cardKey as key, getServer } from "@lib/server";
|
|
5
|
+
import { isPhone, toast } from "@lib/core";
|
|
6
|
+
import { stopDictation } from "@lib/dictation";
|
|
7
|
+
import { deepOf, getRoute } from "@lib/router";
|
|
8
|
+
import { cardEl } from "@lib/board";
|
|
9
|
+
import { gitLeave } from "@lib/git";
|
|
10
|
+
import { termStop } from "./card-terminal.ts";
|
|
11
|
+
import { defaultTab, TABS, tipOf, titleOf } from "./panel-derive.ts";
|
|
12
|
+
import { getPanel, panelWaiters, setPanel, usePanel } from "./panel-store.ts";
|
|
13
|
+
import { setFlip } from "./run-view-store.ts";
|
|
14
|
+
import { openPreview, openWorkspace, projectNotes } from "./workspace.ts";
|
|
15
|
+
|
|
16
|
+
const bump = (f: "fetchAsk" | "drawAsk") => usePanel.setState((s) => ({ [f]: s[f] + 1 }) as any);
|
|
17
|
+
|
|
18
|
+
// Opens a card's panel. A run is worked on in its workspace, which docks this panel; so is everything on a phone. Tasks keep
|
|
19
|
+
// the panel on the Board and Tasks pages. An archived run has no workspace row: it stays here to be restored. `keepTab`: a link
|
|
20
|
+
// already chose the tab.
|
|
21
|
+
export function openPanel(c: any, keepTab?: boolean) {
|
|
22
|
+
const view = getRoute().view,
|
|
23
|
+
here = view === "board" || view === "tasks";
|
|
24
|
+
if (view !== "run" && (isPhone() || !here || (c.kind === "run" && !c.archived))) {
|
|
25
|
+
setPanel({ keepNext: !!keepTab });
|
|
26
|
+
return void openWorkspace(c);
|
|
27
|
+
}
|
|
28
|
+
keepTab ||= getPanel().keepNext;
|
|
29
|
+
stopDictation(true); // the panel body is about to be replaced
|
|
30
|
+
gitLeave();
|
|
31
|
+
usePanel.setState((s) => ({
|
|
32
|
+
keepNext: false,
|
|
33
|
+
openKey: key(c),
|
|
34
|
+
card: c,
|
|
35
|
+
openN: s.openN + 1,
|
|
36
|
+
off: [],
|
|
37
|
+
open: true,
|
|
38
|
+
title: titleOf(c),
|
|
39
|
+
titleTip: tipOf(c),
|
|
40
|
+
// A task has no /run reply; a run keeps the last one on screen until its own read lands.
|
|
41
|
+
...(c.kind === "idea" ? { runDoc: null, ptabs: [] } : {}),
|
|
42
|
+
...(c.kind !== "idea" && !keepTab ? { wantTab: defaultTab(c) } : {}),
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
// A link from a note (?run= or ?idea=, with dir, tab, item) opens that card's panel; a finding or backlog item named is
|
|
46
|
+
// scrolled to and marked, found by its text since the rendered list does not carry the numbers.
|
|
47
|
+
export function deep() {
|
|
48
|
+
const d = deepOf(location.search);
|
|
49
|
+
if (!d) return;
|
|
50
|
+
history.replaceState(null, "", location.pathname + "?all=1");
|
|
51
|
+
const c = getServer().state.cards.find(
|
|
52
|
+
(x) => x.state === d.dir && (d.run ? x.kind === "run" && x.id === d.run : x.kind === "idea" && x.text === d.idea),
|
|
53
|
+
);
|
|
54
|
+
if (!c) {
|
|
55
|
+
toast(d.run ? "That run was not found" : "That task was not found");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const t = TABS.find((x) => x[1] === d.tab);
|
|
59
|
+
setPanel({ ...(t ? { wantTab: t[1] } : {}), hit: d.item ? { type: d.item.type, n: d.item.n, k: key(c) } : null });
|
|
60
|
+
openPanel(c, !!t);
|
|
61
|
+
}
|
|
62
|
+
// A run's panel on the tab of one of its items, that item scrolled to and marked.
|
|
63
|
+
export function openAt(c: any, type: string, n: number) {
|
|
64
|
+
setPanel({ wantTab: type === "finding" ? "review" : "backlog", hit: { type, n, k: key(c) } });
|
|
65
|
+
openPanel(c, true);
|
|
66
|
+
}
|
|
67
|
+
// `page`: a page change closes the board's own panel although the route already names the new page.
|
|
68
|
+
export function closePanel(page = false) {
|
|
69
|
+
const view = getRoute().view;
|
|
70
|
+
if (!page && view !== "board" && view !== "run" && view !== "tasks") return;
|
|
71
|
+
const k = getPanel().openKey;
|
|
72
|
+
stopDictation(true);
|
|
73
|
+
termStop();
|
|
74
|
+
gitLeave();
|
|
75
|
+
setPanel({ openKey: null, card: null, runDoc: null, open: false }); // `hit` and `keepNext` stay: a link opened from the Board closes and reopens the panel in its workspace
|
|
76
|
+
if (k) cardEl(k)?.focus({ preventScroll: true });
|
|
77
|
+
}
|
|
78
|
+
// The close button and the scrim: a phone's run sheet only hides (the card stays), every other panel closes.
|
|
79
|
+
export const dismissPanel = () => (getRoute().view === "run" ? setFlip(false) : closePanel());
|
|
80
|
+
// Draws the open card's panel again from the reply it has (an action changed the card, a tab was picked).
|
|
81
|
+
export const redrawPanel = () => bump("drawAsk");
|
|
82
|
+
// Reads the open run again; resolves once the panel has drawn the new reply (or the read failed or the card changed).
|
|
83
|
+
export const refetchPanel = () =>
|
|
84
|
+
new Promise<void>((done) => {
|
|
85
|
+
panelWaiters.add(done);
|
|
86
|
+
bump("fetchAsk");
|
|
87
|
+
});
|
|
88
|
+
// A tab of the open run: the run workspace shows Preview as a centre tab, not a panel tab.
|
|
89
|
+
export function pickPanelTab(k: string) {
|
|
90
|
+
if (getRoute().view === "run" && k === "preview") return void openPreview();
|
|
91
|
+
setPanel({ pn: false, wantTab: k });
|
|
92
|
+
redrawPanel();
|
|
93
|
+
}
|
|
94
|
+
// The arrow keys: the next or previous tab of the open run.
|
|
95
|
+
export function stepPanelTab(by: number) {
|
|
96
|
+
const { ptabs: ks, tab } = getPanel(),
|
|
97
|
+
i = ks.indexOf(tab),
|
|
98
|
+
t = ks[i < 0 ? (by > 0 ? 0 : ks.length - 1) : Math.max(0, Math.min(ks.length - 1, i + by))];
|
|
99
|
+
if (t && t !== tab) {
|
|
100
|
+
setPanel({ wantTab: t });
|
|
101
|
+
redrawPanel();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export const openProjectNotes = () => void projectNotes();
|