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
package/web/board/workspace.ts
DELETED
|
@@ -1,650 +0,0 @@
|
|
|
1
|
-
// The side menu's live parts on every page (board, notebook, video): the Icebox count,
|
|
2
|
-
// the Tasks entry's source icons and the Projects list; and the board's flat footer
|
|
3
|
-
// (agent usage, terminal count, phone). Stands alone, so the notebook and video
|
|
4
|
-
// bundles can carry it without the board.
|
|
5
|
-
import { onBoardCards, attentionTasks, setTaskAttention, taskForCard } from "./badge.ts";
|
|
6
|
-
import { store } from "./store.ts";
|
|
7
|
-
import { $, html, modal, raw } from "./dom.ts";
|
|
8
|
-
import { initResources } from "./resources.ts";
|
|
9
|
-
import { age, need } from "./labels.ts";
|
|
10
|
-
import { openAdd } from "./add-project.ts";
|
|
11
|
-
import { initSearch } from "./search.ts";
|
|
12
|
-
import { agentsHtml, dueWord, forgetAgents, gitDue, moveTo, settleIn, toggleOpen, wsAgents, type Agent } from "./ws-tabs.ts";
|
|
13
|
-
import { toast } from "./toast.ts";
|
|
14
|
-
|
|
15
|
-
const DAY = 864e5;
|
|
16
|
-
const STAGE = ["idea", "planning", "building", "reviewing", "done"];
|
|
17
|
-
// A card's state icon (.si) and the word under its title.
|
|
18
|
-
export function stateOf(c) {
|
|
19
|
-
const task = taskForCard(c);
|
|
20
|
-
// Only a task that is really working spins; a saved goal is idle, a finished run keeps its own state.
|
|
21
|
-
// An abandoned run waits on nobody, and a done one only on its own approval or commit (below), so
|
|
22
|
-
// a linked task's "needs you" never paints a finished run orange.
|
|
23
|
-
if (task && !(c.kind === "run" && (c.status === "done" || c.status === "abandoned"))) return task.attention.category === "needs-you" ? "wait" : task.attention.category === "completed" ? "done" : ["interrupted", "failed"].includes(task.status ?? "") ? "stalled" : task.status === "draft" ? "idle" : "build";
|
|
24
|
-
// A task whose agent is working is a run being born: show it as planning.
|
|
25
|
-
if (c.kind === "idea") return !c.pty?.alive ? "idle" : c.pty.asking ? "wait" : c.pty.busy ? "plan" : "idle";
|
|
26
|
-
if (c.status === "waiting" || (c.pty?.alive && c.pty.asking)) return "wait";
|
|
27
|
-
if (c.status === "done") return c.accept === "needs" || gitDue(c) ? "wait" : "done";
|
|
28
|
-
if (c.status === "abandoned") return "aband";
|
|
29
|
-
if (c.status === "stalled") return "stalled";
|
|
30
|
-
return c.column >= 3 ? "review" : c.column === 2 ? "build" : "plan";
|
|
31
|
-
}
|
|
32
|
-
export function subline(c, now) {
|
|
33
|
-
const task = taskForCard(c);
|
|
34
|
-
if (task) return task.attention.reason + " · " + task.attention.action;
|
|
35
|
-
// An idle agent and no run yet: it answered, or waits for the user.
|
|
36
|
-
if (c.kind === "idea") return !c.pty?.alive ? "idea" : c.pty.asking ? "waiting on you" : c.pty.busy ? "planning · starting" : "agent · open";
|
|
37
|
-
const t = c.moved ?? now;
|
|
38
|
-
if (c.stage === "explore") return c.awaiting ? `exploring · ${need(c.awaiting)}` : `exploring · ${age(c.moved ?? now, now)}`;
|
|
39
|
-
if (c.status === "waiting") return c.awaiting ? `${STAGE[c.column] ?? "waiting"} · ${need(c.awaiting)}` : "waiting on you";
|
|
40
|
-
if (c.accept === "needs") return "done, not approved";
|
|
41
|
-
if (gitDue(c)) return `waiting on you · ${dueWord(c)}`;
|
|
42
|
-
if (c.accept === "auto") return `auto-accepted · ${age(t, now)} ago`;
|
|
43
|
-
if (c.status === "done" || c.status === "abandoned") return `${c.status} · ${age(t, now)} ago`;
|
|
44
|
-
if (c.status === "stalled") return `stalled · ${age(t, now)}`;
|
|
45
|
-
return `${STAGE[c.column] ?? c.status} · ${age(t, now)}`;
|
|
46
|
-
}
|
|
47
|
-
export const titleOf = (c) => (c.title || c.text || "").split("\n")[0];
|
|
48
|
-
// Shown in the list: runs not archived, a finished one only for a day. Tasks not started yet
|
|
49
|
-
// live on the Tasks page; one whose agent is starting (it has a terminal) shows here.
|
|
50
|
-
export const listed = (c, now) =>
|
|
51
|
-
!c.archived && (c.kind === "idea" ? !!c.pty : !["done", "abandoned"].includes(c.status) || now - (c.moved ?? 0) < DAY);
|
|
52
|
-
export const projName = (dir, projects) => {
|
|
53
|
-
const l = projects?.find((p) => p.dir === dir)?.label || dir.replace(/[\\/]\.kaizen$/, "");
|
|
54
|
-
return l.split(/[\\/]/).pop() || l;
|
|
55
|
-
};
|
|
56
|
-
export const logo = (dir, name, projects) => {
|
|
57
|
-
const ini = html`<span class="plogo" aria-hidden="true">${(name || "?").charAt(0).toUpperCase()}</span>`;
|
|
58
|
-
return projects?.some((p) => p.dir === dir && p.logo)
|
|
59
|
-
? html`<img class="plogo" src="/project-logo?dir=${encodeURIComponent(dir)}" alt="" loading="lazy" onerror="this.outerHTML=this.dataset.f" data-f="${String(ini)}">`
|
|
60
|
-
: ini;
|
|
61
|
-
};
|
|
62
|
-
// A card's address: its run workspace (?view=run&dir=&id=, or &idea= for a task).
|
|
63
|
-
export const cardHref = (c) =>
|
|
64
|
-
`/?view=run&dir=${encodeURIComponent(c.state)}&` + (c.kind === "run" ? "id=" + encodeURIComponent(c.id) : "idea=" + encodeURIComponent(c.text));
|
|
65
|
-
|
|
66
|
-
// The Projects filter: projects ticked (none = all) and which kinds of card show. Kept per browser.
|
|
67
|
-
// Running: tasks and agents that started and are not done. Done: the finished ones. Saved tasks that never started show in neither.
|
|
68
|
-
type Filt = { dirs: string[]; running: boolean; done: boolean };
|
|
69
|
-
const ALLF: Filt = { dirs: [], running: true, done: false };
|
|
70
|
-
let filt: Filt = (() => {
|
|
71
|
-
try {
|
|
72
|
-
return { ...ALLF, ...JSON.parse(localStorage.getItem("kz-rail-filter2") || "{}") };
|
|
73
|
-
} catch {
|
|
74
|
-
return { ...ALLF };
|
|
75
|
-
}
|
|
76
|
-
})();
|
|
77
|
-
const keepFilt = () => {
|
|
78
|
-
try {
|
|
79
|
-
localStorage.setItem("kz-rail-filter2", JSON.stringify(filt));
|
|
80
|
-
} catch {}
|
|
81
|
-
};
|
|
82
|
-
let last: { cards: any[]; projects?: any[]; agents?: Agent[] } = { cards: [] };
|
|
83
|
-
// Projects that are git repositories (the main checkout has a branch): where a workspace can be made.
|
|
84
|
-
export const gitProjects = () =>
|
|
85
|
-
(last.projects ?? []).filter((p) => p.workspaces?.some((w) => w.branch)).map((p) => ({ dir: p.dir as string, name: projName(p.dir, last.projects) }));
|
|
86
|
-
// Project groups folded shut in the side menu, kept per browser.
|
|
87
|
-
const folded: Set<string> = (() => {
|
|
88
|
-
try {
|
|
89
|
-
return new Set(JSON.parse(localStorage.getItem("kz-rail-folded") || "[]"));
|
|
90
|
-
} catch {
|
|
91
|
-
return new Set();
|
|
92
|
-
}
|
|
93
|
-
})();
|
|
94
|
-
// Pinned worktrees (dir\0ws), kept per browser.
|
|
95
|
-
const pins: Set<string> = (() => {
|
|
96
|
-
try {
|
|
97
|
-
return new Set(JSON.parse(localStorage.getItem("kz-ws-pins") || "[]"));
|
|
98
|
-
} catch {
|
|
99
|
-
return new Set();
|
|
100
|
-
}
|
|
101
|
-
})();
|
|
102
|
-
// The right-click menu on a worktree row: update, copy path, copy name, pin, delete.
|
|
103
|
-
function wsMenu(e: MouseEvent, a: HTMLElement) {
|
|
104
|
-
e.preventDefault();
|
|
105
|
-
document.getElementById("wsmenu")?.remove();
|
|
106
|
-
const dir = a.dataset.dir!, ws = a.dataset.ws!, key = dir + "\0" + ws;
|
|
107
|
-
const w = last.projects?.find((p) => p.dir === dir)?.workspaces?.find((x) => x.path === ws);
|
|
108
|
-
if (!w) return;
|
|
109
|
-
const name = wsLabel(w);
|
|
110
|
-
const say = (m: string) => {
|
|
111
|
-
const t = $("toast");
|
|
112
|
-
t.textContent = m;
|
|
113
|
-
t.classList.add("on");
|
|
114
|
-
setTimeout(() => t.classList.remove("on"), 4000);
|
|
115
|
-
};
|
|
116
|
-
const copy = (text: string) => navigator.clipboard.writeText(text).then(() => say("Copied"), () => say("Could not copy"));
|
|
117
|
-
const op = async (o: string) => {
|
|
118
|
-
say(o === "update" ? "Updating…" : "Deleting…");
|
|
119
|
-
const r = await fetch("/workspace", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir, ws, op: o }) }).catch(() => null);
|
|
120
|
-
const j = await r?.json().catch(() => ({}));
|
|
121
|
-
say(r?.ok ? (o === "update" ? j.out || "Updated" : "Deleted") : j?.error || j?.why || "Failed");
|
|
122
|
-
};
|
|
123
|
-
const items: [string, () => void][] = [
|
|
124
|
-
...(w.main ? [] : ([["Update", () => op("update")]] as [string, () => void][])),
|
|
125
|
-
["Copy path", () => copy(ws)],
|
|
126
|
-
["Copy worktree name", () => copy(name)],
|
|
127
|
-
[pins.has(key) ? "Unpin" : "Pin", () => {
|
|
128
|
-
pins.has(key) ? pins.delete(key) : pins.add(key);
|
|
129
|
-
try {
|
|
130
|
-
localStorage.setItem("kz-ws-pins", JSON.stringify([...pins]));
|
|
131
|
-
} catch {}
|
|
132
|
-
drawList();
|
|
133
|
-
}],
|
|
134
|
-
...(w.main ? [] : ([["Delete", async () => {
|
|
135
|
-
const dl = modal(html`<div class="gdis" style="display:flex;flex-direction:column;gap:12px">
|
|
136
|
-
<b>Delete worktree "${name}"?</b>
|
|
137
|
-
<p>Removes the folder. Refused while it has uncommitted changes. The branch stays.</p>
|
|
138
|
-
<div class="gpath" style="font:12px monospace;overflow-wrap:anywhere">${ws}</div>
|
|
139
|
-
<div class="row"><button class="btn" value="no">Cancel</button><button class="btn danger" value="yes">Delete</button></div>
|
|
140
|
-
</div>`);
|
|
141
|
-
dl.addEventListener("close", () => dl.returnValue === "yes" && op("delete"));
|
|
142
|
-
}]] as [string, () => void][])),
|
|
143
|
-
];
|
|
144
|
-
const m = document.createElement("div");
|
|
145
|
-
m.id = "wsmenu";
|
|
146
|
-
m.style.cssText = `position:fixed;left:${Math.min(e.clientX, innerWidth - 190)}px;top:${Math.min(e.clientY, innerHeight - items.length * 34 - 16)}px;z-index:50;min-width:170px;padding:6px;background:var(--bg-2);border:1px solid var(--line);border-radius:var(--r);box-shadow:0 8px 24px #0004;display:flex;flex-direction:column`;
|
|
147
|
-
for (const [label, fn] of items) {
|
|
148
|
-
const b = document.createElement("button");
|
|
149
|
-
b.type = "button";
|
|
150
|
-
b.textContent = label;
|
|
151
|
-
b.style.cssText = "text-align:left;padding:7px 10px;font-size:13px;color:var(--ink);border-radius:var(--r-s)";
|
|
152
|
-
b.onmouseenter = () => (b.style.background = "var(--hover)");
|
|
153
|
-
b.onmouseleave = () => (b.style.background = "");
|
|
154
|
-
b.onclick = () => (m.remove(), fn());
|
|
155
|
-
m.append(b);
|
|
156
|
-
}
|
|
157
|
-
document.body.append(m);
|
|
158
|
-
const off = () => (m.remove(), removeEventListener("click", off), removeEventListener("keydown", off));
|
|
159
|
-
setTimeout(() => (addEventListener("click", off), addEventListener("keydown", off)));
|
|
160
|
-
}
|
|
161
|
-
// Workspace cards with their agent list open (dir\0ws -> true), kept per browser.
|
|
162
|
-
const wsOpen: Record<string, true> = (() => {
|
|
163
|
-
try {
|
|
164
|
-
return JSON.parse(localStorage.getItem("kz-wsopen") || "{}");
|
|
165
|
-
} catch {
|
|
166
|
-
return {};
|
|
167
|
-
}
|
|
168
|
-
})();
|
|
169
|
-
function toggleList(dir: string, ws: string) {
|
|
170
|
-
toggleOpen(wsOpen, dir, ws);
|
|
171
|
-
try {
|
|
172
|
-
localStorage.setItem("kz-wsopen", JSON.stringify(wsOpen));
|
|
173
|
-
} catch {}
|
|
174
|
-
drawList();
|
|
175
|
-
}
|
|
176
|
-
function fold(dir: string) {
|
|
177
|
-
folded.has(dir) ? folded.delete(dir) : folded.add(dir);
|
|
178
|
-
try {
|
|
179
|
-
localStorage.setItem("kz-rail-folded", JSON.stringify([...folded]));
|
|
180
|
-
} catch {}
|
|
181
|
-
drawList();
|
|
182
|
-
}
|
|
183
|
-
const svg = (d: string) => `<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
184
|
-
const FA_OPEN = svg("M4 3l4 3 4-3M4 13l4-3 4 3");
|
|
185
|
-
const FA_SHUT = svg("M4 6l4-3 4 3M4 10l4 3 4-3");
|
|
186
|
-
const foldAll = (shut: boolean) => {
|
|
187
|
-
for (const d of last.projects?.map((p) => p.dir) ?? []) shut ? folded.add(d) : folded.delete(d);
|
|
188
|
-
try {
|
|
189
|
-
localStorage.setItem("kz-rail-folded", JSON.stringify([...folded]));
|
|
190
|
-
} catch {}
|
|
191
|
-
drawList();
|
|
192
|
-
};
|
|
193
|
-
// A card's workspace row: its own (a run's worktree) when the project lists it, else the
|
|
194
|
-
// main checkout's, so a run whose worktree is gone, a task or an old run never vanishes.
|
|
195
|
-
export function wsOfCard(c, projects = last.projects) {
|
|
196
|
-
const ws = projects?.find((p) => p.dir === c.state)?.workspaces ?? [];
|
|
197
|
-
return ws.find((w) => w.path === c.ws)?.path ?? ws.find((w) => w.main)?.path ?? c.ws ?? "";
|
|
198
|
-
}
|
|
199
|
-
// The floating Home workspace's folder (~/.kaizen/home): never a project's `.kaizen` state dir, and it has no workspace view.
|
|
200
|
-
export const isHomeDir = (d: unknown) => typeof d === "string" && /[\\/]\.kaizen[\\/]home$/.test(d);
|
|
201
|
-
// A Home terminal's address opens the board with its panel (web/board/home-ws.ts), from any page.
|
|
202
|
-
export const wsHref = (dir, ws) => (isHomeDir(dir) ? "/?view=board&homews=1" : `/?view=ws&dir=${encodeURIComponent(dir)}&ws=${encodeURIComponent(ws)}`);
|
|
203
|
-
export const RANK = { wait: 0, plan: 1, build: 2, review: 3, stalled: 4, idle: 5, done: 6, aband: 7 };
|
|
204
|
-
export const folderOf = (w) => w.path.split(/[\\/]/).pop() || w.path;
|
|
205
|
-
// A worktree's mark on line 2 of its card.
|
|
206
|
-
const PIN = html`<svg viewBox="0 0 24 24" aria-label="Pinned" style="width:12px;height:12px;flex:none;margin-left:4px;color:var(--accent)"><path d="M12 17v5M9 3h6l-1 6 3 3v2H7v-2l3-3z" fill="currentColor" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`;
|
|
207
|
-
const WT = html`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/></g></svg>`;
|
|
208
|
-
let settleT: ReturnType<typeof setTimeout> | undefined;
|
|
209
|
-
let drawn = "";
|
|
210
|
-
let tasksReadAt = 0, tasksReading = false;
|
|
211
|
-
async function readTaskAttention() {
|
|
212
|
-
if (tasksReading || Date.now() - tasksReadAt < 2000) return;
|
|
213
|
-
tasksReading = true; tasksReadAt = Date.now();
|
|
214
|
-
try { const r = await fetch("/tasks?all=1"); if (r.ok) { const body = await r.json(); setTaskAttention(body.tasks ?? []); } } catch { /* retain the latest persisted projection */ }
|
|
215
|
-
finally { tasksReading = false; }
|
|
216
|
-
}
|
|
217
|
-
const taskLinks = (dir: string, w: any, cards: any[]) => (attentionTasks ?? []).filter((t) => t.dir === dir && !t.legacy && t.attention.category !== "completed" && filt.running && t.status !== "draft" && (cards.some((c) => taskForCard(c)?.id === t.id) || (w.main && !(t.runs ?? t.runIds ?? []).length))).sort((a: any, b: any) => (a.created ?? 0) - (b.created ?? 0)).map((t) => html`<a class="rtask" href="/?view=task&task=${encodeURIComponent(t.id)}&dir=${encodeURIComponent(t.dir)}" data-task-id="${t.id}" data-task-dir="${t.dir}" title="${t.attention.reason} · ${t.attention.action}"><span class="si ${t.attention.category === "needs-you" ? "wait" : t.attention.category === "completed" ? "done" : ["interrupted", "failed"].includes(t.status ?? "") ? "stalled" : t.status === "draft" ? "idle" : "build"}"></span><span><b>${t.title}</b><small>${t.attention.reason}</small></span></a>`);
|
|
218
|
-
|
|
219
|
-
// ---- ranking projects: press a project's bar and drag it up or down (pointer events, so a mouse
|
|
220
|
-
// and a finger work alike). A mouse starts after 5 px of movement; a finger after a 300 ms hold
|
|
221
|
-
// without moving, so a quick swipe still scrolls the sidebar. A line shows where it will land;
|
|
222
|
-
// letting go saves the order for every device (POST /projects/order rewrites ~/.kaizen/projects).
|
|
223
|
-
// Escape or a cancelled pointer puts it back. The click that ends a drag does not fold.
|
|
224
|
-
let ranking = false, rankDirty = false, rankClick = false;
|
|
225
|
-
function rankDrag(box: HTMLElement) {
|
|
226
|
-
let d: { dir: string; bar: HTMLElement; id: number; x: number; y: number; hold?: ReturnType<typeof setTimeout>; to: number } | null = null;
|
|
227
|
-
const groups = () => [...box.querySelectorAll<HTMLElement>(":scope > .pgrp")];
|
|
228
|
-
const clear = () => {
|
|
229
|
-
groups().forEach((g) => g.classList.remove("rank-before"));
|
|
230
|
-
box.classList.remove("rank-end");
|
|
231
|
-
d?.bar.classList.remove("rank-lift");
|
|
232
|
-
};
|
|
233
|
-
const end = (save: boolean) => {
|
|
234
|
-
if (!d) return;
|
|
235
|
-
clearTimeout(d.hold);
|
|
236
|
-
const was = ranking, { dir, to } = d;
|
|
237
|
-
clear();
|
|
238
|
-
d = null;
|
|
239
|
-
ranking = false;
|
|
240
|
-
if (was) rankClick = true; // the click that follows this pointerup
|
|
241
|
-
if (was && save) {
|
|
242
|
-
const dirs = groups().map((g) => g.querySelector<HTMLElement>(".proj")!.dataset.proj!);
|
|
243
|
-
const from = dirs.indexOf(dir);
|
|
244
|
-
if (from >= 0 && to !== from && to !== from + 1) {
|
|
245
|
-
const next = moveTo(dirs, from, to);
|
|
246
|
-
const rank = new Map(next.map((x, i) => [x, i]));
|
|
247
|
-
last.projects = [...(last.projects ?? [])].sort((a, b) => (rank.get(a.dir) ?? 1e9) - (rank.get(b.dir) ?? 1e9));
|
|
248
|
-
void fetch("/projects/order", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dirs: next }) })
|
|
249
|
-
.then((r) => { if (!r.ok) toast("Could not save the project order"); })
|
|
250
|
-
.catch(() => toast("Could not save the project order"));
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (was || rankDirty) (rankDirty = false), drawList();
|
|
254
|
-
if (was) setTimeout(() => (rankClick = false), 0);
|
|
255
|
-
};
|
|
256
|
-
const start = () => {
|
|
257
|
-
if (!d) return;
|
|
258
|
-
ranking = true;
|
|
259
|
-
d.bar.classList.add("rank-lift");
|
|
260
|
-
try { d.bar.setPointerCapture(d.id); } catch {}
|
|
261
|
-
navigator.vibrate?.(8);
|
|
262
|
-
};
|
|
263
|
-
box.addEventListener("pointerdown", (e) => {
|
|
264
|
-
const bar = (e.target as HTMLElement).closest<HTMLElement>(".pgrp > .proj");
|
|
265
|
-
if (!bar || e.button !== 0 || bar.parentElement?.parentElement !== box) return;
|
|
266
|
-
d = { dir: bar.dataset.proj!, bar, id: e.pointerId, x: e.clientX, y: e.clientY, to: -1 };
|
|
267
|
-
if (e.pointerType !== "mouse") d.hold = setTimeout(start, 300);
|
|
268
|
-
});
|
|
269
|
-
box.addEventListener("pointermove", (e) => {
|
|
270
|
-
if (!d || e.pointerId !== d.id) return;
|
|
271
|
-
const far = Math.hypot(e.clientX - d.x, e.clientY - d.y);
|
|
272
|
-
if (!ranking) {
|
|
273
|
-
if (e.pointerType === "mouse" ? far > 5 : far > 8) e.pointerType === "mouse" ? start() : end(false);
|
|
274
|
-
if (!ranking) return;
|
|
275
|
-
}
|
|
276
|
-
e.preventDefault();
|
|
277
|
-
// The landing slot: before the first project whose bar's middle is below the pointer, else the end.
|
|
278
|
-
const gs = groups();
|
|
279
|
-
const i = gs.findIndex((g) => { const r = g.getBoundingClientRect(); return e.clientY < r.top + r.height / 2; });
|
|
280
|
-
d.to = i < 0 ? gs.length : i;
|
|
281
|
-
gs.forEach((g, k) => g.classList.toggle("rank-before", k === d!.to));
|
|
282
|
-
box.classList.toggle("rank-end", d.to === gs.length);
|
|
283
|
-
});
|
|
284
|
-
box.addEventListener("pointerup", (e) => d && e.pointerId === d.id && end(true));
|
|
285
|
-
box.addEventListener("pointercancel", () => end(false));
|
|
286
|
-
// A held finger: no page scroll and no long-press menu while it drags.
|
|
287
|
-
box.addEventListener("touchmove", (e) => { if (ranking) e.preventDefault(); }, { passive: false });
|
|
288
|
-
box.addEventListener("contextmenu", (e) => { if (d) e.preventDefault(); }, true);
|
|
289
|
-
addEventListener("keydown", (e) => { if (ranking && e.key === "Escape") (e.preventDefault(), end(false)); });
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export const wsLabel = (w) => w.branch || (w.main ? "workspace" : w.path.split(/[\\/]/).pop());
|
|
293
|
-
function drawList() {
|
|
294
|
-
const box = $("plist");
|
|
295
|
-
if (!box) return;
|
|
296
|
-
// A drag in progress owns the list: a redraw would pull the bar out from under the pointer.
|
|
297
|
-
if (ranking) return void (rankDirty = true);
|
|
298
|
-
const now = Date.now();
|
|
299
|
-
const projects = (last.projects ?? []).filter((p) => p.workspaces?.length);
|
|
300
|
-
const all = new Set(projects.map((p) => p.dir));
|
|
301
|
-
// Cards by project and workspace: each lands on a row, the main checkout when its own is not listed.
|
|
302
|
-
const by = new Map<string, any[]>();
|
|
303
|
-
const shownAgents = (rs) => rs.filter((r) => (r.st === "done" ? filt.done : filt.running));
|
|
304
|
-
const shown = (c) => {
|
|
305
|
-
const st = stateOf(c);
|
|
306
|
-
return (filt.running && ["wait", "plan", "build", "review", "stalled"].includes(st)) || (filt.done && (st === "done" || st === "aband"));
|
|
307
|
-
};
|
|
308
|
-
for (const c of last.cards.filter((c) => listed(c, now) && shown(c))) {
|
|
309
|
-
const k = c.state + "\0" + wsOfCard(c);
|
|
310
|
-
if (!by.has(k)) by.set(k, []);
|
|
311
|
-
by.get(k)!.push(c);
|
|
312
|
-
}
|
|
313
|
-
const top = (cs) => (cs.length ? Math.min(...cs.map((c) => RANK[stateOf(c)])) : 9);
|
|
314
|
-
const groups = projects
|
|
315
|
-
.filter((p) => !filt.dirs.length || filt.dirs.includes(p.dir))
|
|
316
|
-
.map((p) => {
|
|
317
|
-
const rows = p.workspaces
|
|
318
|
-
.map((w) => {
|
|
319
|
-
const cs = by.get(p.dir + "\0" + w.path) ?? [];
|
|
320
|
-
const allCs = (last.cards ?? []).filter((c) => c.state === p.dir && wsOfCard(c) === w.path && listed(c, now));
|
|
321
|
-
const onlyDone = allCs.length > 0 && allCs.every((c) => ["done", "abandoned"].includes(stateOf(c)));
|
|
322
|
-
const ags = shownAgents(wsAgents(last.agents ?? [], p.dir, w.path, wsOfCard, now)).length;
|
|
323
|
-
// An empty workspace or one with a run going is active; one holding only finished runs is done.
|
|
324
|
-
const keep = cs.length > 0 || ags > 0 || (filt.running && (w.main || !onlyDone));
|
|
325
|
-
return { w, cs, keep };
|
|
326
|
-
})
|
|
327
|
-
.filter((r) => r.keep)
|
|
328
|
-
// Pinned worktrees first (a stable sort keeps the rest in git's order).
|
|
329
|
-
.sort((a, b) => +pins.has(p.dir + "\0" + b.w.path) - +pins.has(p.dir + "\0" + a.w.path));
|
|
330
|
-
return { p, rows, top: Math.min(9, ...rows.map((r) => top(r.cs))) };
|
|
331
|
-
})
|
|
332
|
-
// Running only keeps every project listed, so an idle one reads "Nothing running" rather than vanishing.
|
|
333
|
-
// In the registry's order, which the user ranks by dragging a project's bar (rankDrag below).
|
|
334
|
-
.filter((g) => g.rows.length || filt.running);
|
|
335
|
-
|
|
336
|
-
const f = $("pfilter");
|
|
337
|
-
const on = filt.dirs.some((d) => all.has(d)) || !filt.running || filt.done;
|
|
338
|
-
f.setAttribute("aria-pressed", String(on));
|
|
339
|
-
f.title = on ? "Filter on: choose projects and kinds" : "Filter projects and kinds";
|
|
340
|
-
if ($("pfpop")) drawPop(all);
|
|
341
|
-
// Agents are read from this tick's payload; one held at "working" through the 3 s settle redraws when it ends.
|
|
342
|
-
forgetAgents(last.agents ?? []);
|
|
343
|
-
clearTimeout(settleT);
|
|
344
|
-
const wait = settleIn(last.agents ?? [], now);
|
|
345
|
-
if (wait < Infinity) settleT = setTimeout(drawList, wait + 20);
|
|
346
|
-
const out =
|
|
347
|
-
groups
|
|
348
|
-
.map(({ p, rows }) => {
|
|
349
|
-
const dir = p.dir,
|
|
350
|
-
name = projName(dir, last.projects),
|
|
351
|
-
// A project with nothing to list stays as a collapsed header.
|
|
352
|
-
shut = folded.has(dir) || !rows.length;
|
|
353
|
-
// A + for a new worktree on git projects (the main checkout has a branch).
|
|
354
|
-
const git = p.workspaces.some((w) => w.branch);
|
|
355
|
-
const mainWs = p.workspaces?.find((w) => w.main)?.path ?? p.workspaces?.[0]?.path ?? dir;
|
|
356
|
-
return html`<div class="pgrp"><button type="button" class="proj${shut ? " shut" : ""}" data-proj="${dir}" data-ws="${mainWs}" data-fold="${dir}"${rows.length ? "" : " data-empty"} title="${dir}" aria-expanded="${String(!shut)}">${logo(dir, name, last.projects)}<span class="pname">${name}</span><svg class="fchev" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6l6 6-6 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>${git ? html`<button type="button" class="wadd" data-wadd="${dir}" title="New workspace in ${name}" aria-label="New workspace in ${name}"><svg aria-hidden="true"><use href="#i-plus"/></svg></button>` : ""}</div>${shut ? "" : raw('<div class="pws">')}${shut ? "" : rows.map(({ w, cs }) => {
|
|
357
|
-
// The dot: the most urgent run there, or an agent asking (amber) or working (spinner).
|
|
358
|
-
const rows = shownAgents(wsAgents(last.agents ?? [], dir, w.path, wsOfCard, now));
|
|
359
|
-
const st0 = cs.length ? stateOf([...cs].sort((a, b) => RANK[stateOf(a)] - RANK[stateOf(b)])[0]) : "";
|
|
360
|
-
const st = st0 === "wait" || rows[0]?.st === "asking" ? "wait" : rows.some((r) => r.st === "working") ? "build" : st0 || (rows.length ? "done" : "");
|
|
361
|
-
// The agent buttons are siblings of the link (a button inside a link is invalid).
|
|
362
|
-
return html`<div class="wsr wsc"><a class="row ws" href="${wsHref(dir, w.path)}" data-dir="${dir}" data-ws="${w.path}" title="${w.path}"><span class="si ${st || "none"}"></span><div class="wl"><span class="l1"><b>${wsLabel(w)}</b>${pins.has(dir + "\0" + w.path) ? PIN : ""}</span><span class="l2"><span>${folderOf(w)}</span>${w.main ? "" : WT}</span></div></a>${agentsHtml(rows, now, !!wsOpen[dir + "\0" + w.path], dir, w.path)}</div>${taskLinks(dir, w, cs)}`;
|
|
363
|
-
})}${shut ? "" : raw("</div>")}`;
|
|
364
|
-
})
|
|
365
|
-
.join("") || `<div class="none">No projects</div>`;
|
|
366
|
-
// The same markup is not written again: hover and focus stay, and a tick that changed nothing costs no layout.
|
|
367
|
-
if (out !== drawn) box.innerHTML = drawn = out;
|
|
368
|
-
markCurrent();
|
|
369
|
-
box.oncontextmenu = (e) => {
|
|
370
|
-
const a = (e.target as HTMLElement).closest<HTMLElement>("a.row.ws");
|
|
371
|
-
if (a) wsMenu(e, a);
|
|
372
|
-
};
|
|
373
|
-
box.onclick = (e) => {
|
|
374
|
-
if (rankClick) return void ((rankClick = false), e.preventDefault(), e.stopPropagation());
|
|
375
|
-
const t = e.target as HTMLElement;
|
|
376
|
-
const task = t.closest<HTMLElement>("[data-task-id]");
|
|
377
|
-
if (task) {
|
|
378
|
-
if (e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
379
|
-
if (ask("kz-open-task", { id: task.dataset.taskId, dir: task.dataset.taskDir })) e.preventDefault();
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
const term = t.closest<HTMLElement>("[data-term]");
|
|
383
|
-
if (term) return void (e.preventDefault(), openTerm(term.dataset.dir!, term.dataset.ws!, term.dataset.term!));
|
|
384
|
-
const tog = t.closest<HTMLElement>("[data-wopen]");
|
|
385
|
-
if (tog) return void (e.preventDefault(), toggleList(tog.dataset.dir!, tog.dataset.ws!));
|
|
386
|
-
const add = t.closest<HTMLElement>("[data-wadd]")?.dataset.wadd;
|
|
387
|
-
if (add) return void (e.preventDefault(), openAdd({ dir: add, start: "ws" }));
|
|
388
|
-
const chev = t.closest<HTMLElement>(".fchev");
|
|
389
|
-
if (chev) {
|
|
390
|
-
const d = t.closest<HTMLElement>("[data-fold]")?.dataset.fold;
|
|
391
|
-
if (d) return void (e.preventDefault(), fold(d));
|
|
392
|
-
}
|
|
393
|
-
// A project bar folds and unfolds, like a folder. One that lists nothing has no rows to click,
|
|
394
|
-
// so it opens its main workspace instead.
|
|
395
|
-
const proj = t.closest<HTMLElement>("[data-proj][data-empty]");
|
|
396
|
-
if (proj) {
|
|
397
|
-
e.preventDefault();
|
|
398
|
-
const dir = proj.dataset.proj!, ws = proj.dataset.ws || dir;
|
|
399
|
-
if (ask("kz-open-ws", { dir, ws })) return;
|
|
400
|
-
}
|
|
401
|
-
const d = t.closest<HTMLElement>("[data-fold]")?.dataset.fold;
|
|
402
|
-
if (d) (e.preventDefault(), fold(d));
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
// An agent's mark: the board opens that terminal tab in its workspace; the notebook and video pages open the workspace.
|
|
406
|
-
const openTerm = (dir: string, ws: string, key: string) => {
|
|
407
|
-
if (!ask("kz-open-term", { dir, ws, key })) location.href = wsHref(dir, ws);
|
|
408
|
-
};
|
|
409
|
-
// Moves the side menu's highlight to the card the address names: opening a card in place
|
|
410
|
-
// changes the address without redrawing the list.
|
|
411
|
-
export function markCurrent() {
|
|
412
|
-
const cur = new URLSearchParams(location.search);
|
|
413
|
-
// A run's address (old links, notifications) lights its workspace.
|
|
414
|
-
const c = cur.get("id") && last.cards.find((x) => x.kind === "run" && x.state === cur.get("dir") && x.id === cur.get("id"));
|
|
415
|
-
const ws = cur.get("ws") ?? (c ? wsOfCard(c) : null);
|
|
416
|
-
for (const a of document.querySelectorAll<HTMLElement>("#plist a.row")) {
|
|
417
|
-
if (cur.get("dir") === a.dataset.dir && ws === a.dataset.ws) a.setAttribute("aria-current", "true");
|
|
418
|
-
else a.removeAttribute("aria-current");
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
addEventListener("popstate", markCurrent);
|
|
422
|
-
// The pages that can open a card in place (the board) answer this event and cancel it.
|
|
423
|
-
const ask = (name, detail) => !dispatchEvent(new CustomEvent(name, { cancelable: true, detail }));
|
|
424
|
-
|
|
425
|
-
// What the Tasks page reads too: the cards, and /sources (sources plus every icebox signal).
|
|
426
|
-
let srcs: any = null;
|
|
427
|
-
export const railData = () => ({ ...last, srcs });
|
|
428
|
-
const told = () => dispatchEvent(new Event("kz-rail"));
|
|
429
|
-
let srcAt = 0;
|
|
430
|
-
export async function drawSources(force = false) {
|
|
431
|
-
if (!force && Date.now() - srcAt < 30_000) return;
|
|
432
|
-
srcAt = Date.now();
|
|
433
|
-
try {
|
|
434
|
-
const r = await fetch("/sources");
|
|
435
|
-
if (!r.ok) return;
|
|
436
|
-
const d = (srcs = await r.json());
|
|
437
|
-
told();
|
|
438
|
-
const n = (d.icebox ?? []).filter((s) => s.status === "new" && !s.asleep).length;
|
|
439
|
-
$("ice-n").textContent = n ? String(n) : "";
|
|
440
|
-
$("rail-srcs").innerHTML = (d.sources ?? [])
|
|
441
|
-
.slice(0, 3)
|
|
442
|
-
.map((s) => String(srcIcon(s)))
|
|
443
|
-
.join("");
|
|
444
|
-
} catch {
|
|
445
|
-
/* offline: keep what shows */
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
// A source's mark: a social platform's sprite, a sheet's grid, else the site's favicon.
|
|
449
|
-
export const srcIcon = (s) => {
|
|
450
|
-
if (s.social) return html`<svg aria-hidden="true"><use href="#i-b-${s.social}"/></svg>`;
|
|
451
|
-
if (/docs\.google\.com\/spreadsheets|\.(csv|tsv)$/.test(s.url)) return raw(`<svg aria-hidden="true"><use href="#i-sheet"/></svg>`);
|
|
452
|
-
try {
|
|
453
|
-
return html`<img src="${new URL(s.url).origin}/favicon.ico" alt="" loading="lazy" referrerpolicy="no-referrer" onerror="this.remove()">`;
|
|
454
|
-
} catch {
|
|
455
|
-
return raw("");
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
// The filter popover: every project listed (search when there are many), All projects, and
|
|
460
|
-
// the kinds of card. Each tick applies at once.
|
|
461
|
-
let pq = "";
|
|
462
|
-
function drawPop(all: Set<string>) {
|
|
463
|
-
const p = $("pfpop");
|
|
464
|
-
const dirs = [...all];
|
|
465
|
-
const shown = dirs.filter((d) => projName(d, last.projects).toLowerCase().includes(pq.toLowerCase()));
|
|
466
|
-
const box = (on: boolean, attrs: string, label) => html`<label class="pfrow"><input type="checkbox" ${raw(attrs)}${on ? raw(" checked") : ""}>${label}</label>`;
|
|
467
|
-
const allShut = dirs.length > 0 && dirs.every((d) => folded.has(d));
|
|
468
|
-
const had = document.activeElement?.id;
|
|
469
|
-
const top = p.querySelector(".pfl")?.scrollTop ?? 0;
|
|
470
|
-
p.innerHTML = String(
|
|
471
|
-
html`<input class="sel" id="pfq" placeholder="Search projects…" aria-label="Search projects" value="${pq}" autocomplete="off" spellcheck="false"><div class="pfall">${box(!filt.dirs.length, 'data-all="1"', "All projects")}<button type="button" class="pfb" data-fa="${allShut ? "0" : "1"}" title="${allShut ? "Expand all" : "Collapse all"}" aria-label="${allShut ? "Expand all projects" : "Collapse all projects"}">${raw(allShut ? FA_OPEN : FA_SHUT)}</button></div><div class="pfl">${shown.map((d) => box(filt.dirs.includes(d), `data-dir="${encodeURIComponent(d)}"`, html`${logo(d, projName(d, last.projects), last.projects)}<span>${projName(d, last.projects)}</span>`))}</div><div class="pff"><div class="pfh">Show</div>${(["running", "done"] as const).map((k) => box(filt[k], `data-k="${k}"`, { running: "Running", done: "Done" }[k]))}</div>`,
|
|
472
|
-
);
|
|
473
|
-
const pl = p.querySelector(".pfl");
|
|
474
|
-
if (pl) pl.scrollTop = top;
|
|
475
|
-
if (had === "pfq") {
|
|
476
|
-
const q = $("pfq") as HTMLInputElement;
|
|
477
|
-
q.focus();
|
|
478
|
-
q.setSelectionRange(pq.length, pq.length);
|
|
479
|
-
}
|
|
480
|
-
p.onclick = (e) => {
|
|
481
|
-
const b = (e.target as HTMLElement).closest("[data-fa]") as HTMLElement | null;
|
|
482
|
-
if (b) foldAll(b.dataset.fa === "1");
|
|
483
|
-
};
|
|
484
|
-
p.oninput = (e) => {
|
|
485
|
-
const t = e.target as HTMLInputElement;
|
|
486
|
-
if (t.id === "pfq") pq = t.value;
|
|
487
|
-
else if (t.dataset.all) filt.dirs = [];
|
|
488
|
-
else if (t.dataset.dir) {
|
|
489
|
-
const d = decodeURIComponent(t.dataset.dir);
|
|
490
|
-
filt.dirs = t.checked ? [...new Set([...filt.dirs, d])] : filt.dirs.filter((x) => x !== d);
|
|
491
|
-
} else if (t.dataset.k) filt[t.dataset.k] = t.checked;
|
|
492
|
-
keepFilt();
|
|
493
|
-
drawList();
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
function closePop() {
|
|
497
|
-
$("pfpop")?.remove();
|
|
498
|
-
$("pfilter").setAttribute("aria-expanded", "false");
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// Rows are redrawn on every refresh, which restarts a CSS animation from 0deg: the state
|
|
502
|
-
// icons jumped back mid-turn. Pinning each to the page clock's origin keeps them in phase
|
|
503
|
-
// (the si-* animations have no delay for this to cancel).
|
|
504
|
-
const syncSpin = () =>
|
|
505
|
-
document.getAnimations().forEach((a: any) => {
|
|
506
|
-
if (a.animationName?.startsWith("si-") && a.startTime !== 0) a.startTime = 0;
|
|
507
|
-
});
|
|
508
|
-
export function initRail() {
|
|
509
|
-
initSearch();
|
|
510
|
-
let queued = false;
|
|
511
|
-
const hasSi = (n: any) => n.nodeType === 1 && (n.classList.contains("si") || n.querySelector(".si"));
|
|
512
|
-
new MutationObserver((rs) => {
|
|
513
|
-
if (queued || !rs.some((r) => [...r.addedNodes].some(hasSi))) return;
|
|
514
|
-
queued = true;
|
|
515
|
-
requestAnimationFrame(() => {
|
|
516
|
-
queued = false;
|
|
517
|
-
syncSpin();
|
|
518
|
-
});
|
|
519
|
-
}).observe(document.body, { childList: true, subtree: true });
|
|
520
|
-
if (!$("plist")) return;
|
|
521
|
-
rankDrag($("plist"));
|
|
522
|
-
addEventListener("kz-task-attention", drawList);
|
|
523
|
-
void readTaskAttention();
|
|
524
|
-
onBoardCards((cards, projects, agents) => {
|
|
525
|
-
last = { cards, projects: projects ?? last.projects, agents: agents ?? [] };
|
|
526
|
-
drawList();
|
|
527
|
-
void drawSources();
|
|
528
|
-
void readTaskAttention();
|
|
529
|
-
onCount?.(cards);
|
|
530
|
-
dispatchEvent(new Event("kz-cards"));
|
|
531
|
-
told();
|
|
532
|
-
});
|
|
533
|
-
$("pfilter").onclick = (e) => {
|
|
534
|
-
e.stopPropagation();
|
|
535
|
-
if ($("pfpop")) return closePop();
|
|
536
|
-
const p = document.createElement("div");
|
|
537
|
-
p.id = "pfpop";
|
|
538
|
-
p.className = "pfpop";
|
|
539
|
-
p.setAttribute("role", "dialog");
|
|
540
|
-
p.setAttribute("aria-label", "Filter the Projects list");
|
|
541
|
-
const r = $("pfilter").getBoundingClientRect();
|
|
542
|
-
p.style.left = r.left + "px";
|
|
543
|
-
p.style.top = r.bottom + 4 + "px";
|
|
544
|
-
document.body.append(p);
|
|
545
|
-
$("pfilter").setAttribute("aria-expanded", "true");
|
|
546
|
-
drawList();
|
|
547
|
-
(p.querySelector("input") as HTMLElement)?.focus();
|
|
548
|
-
};
|
|
549
|
-
addEventListener("pointerdown", (e) => {
|
|
550
|
-
const p = $("pfpop");
|
|
551
|
-
if (p && !p.contains(e.target as Node) && !$("pfilter").contains(e.target as Node)) closePop();
|
|
552
|
-
});
|
|
553
|
-
addEventListener("keydown", (e) => {
|
|
554
|
-
if (e.key === "Escape" && $("pfpop")) {
|
|
555
|
-
closePop();
|
|
556
|
-
$("pfilter").focus();
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
// The sheet: add a folder, clone, create, or start a workspace; the current project is preselected.
|
|
560
|
-
$("padd").onclick = () => {
|
|
561
|
-
const p = new URLSearchParams(location.search);
|
|
562
|
-
openAdd({ dir: ["run", "ws"].includes(p.get("view")) ? p.get("dir") : filt.dirs.length === 1 ? filt.dirs[0] : null });
|
|
563
|
-
};
|
|
564
|
-
$("plist").addEventListener("click", (e) => {
|
|
565
|
-
const a = (e.target as Element).closest?.("a.row") as HTMLAnchorElement;
|
|
566
|
-
if (!a || e.ctrlKey || e.metaKey || e.shiftKey || (e as MouseEvent).button) return;
|
|
567
|
-
if (ask("kz-open-ws", { dir: a.dataset.dir, ws: a.dataset.ws })) e.preventDefault();
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
// ---- footer (board page)
|
|
572
|
-
const meter = (p) => html`<span class="umtr"><i class="${p >= 85 ? "hi" : p >= 50 ? "mid" : ""}" style="width:${Math.min(100, p)}%"></i></span>`;
|
|
573
|
-
const when = (t) => (t ? new Date(t).toLocaleString([], { weekday: "short", hour: "2-digit", minute: "2-digit" }) : "unknown");
|
|
574
|
-
const NAME = { claude: "Claude", codex: "Codex" };
|
|
575
|
-
export function usageChips(list) {
|
|
576
|
-
// The agent's mark and its 5-hour %, coloured as it fills; the full figures on hover/focus.
|
|
577
|
-
const lvl = (p) => (p >= 95 ? " hi" : p >= 80 ? " mid" : "");
|
|
578
|
-
return list
|
|
579
|
-
.filter((u) => NAME[u.agent])
|
|
580
|
-
.map((u) => {
|
|
581
|
-
const mark = html`<svg aria-hidden="true"><use href="#i-${u.agent}"/></svg>`;
|
|
582
|
-
if (u.error) return html`<span class="uchip na" tabindex="0">${mark}<b>–</b><span class="utip" role="tooltip"><b>${NAME[u.agent]}</b>Usage unavailable: ${u.error}</span></span>`;
|
|
583
|
-
const head = u.five ?? u.week;
|
|
584
|
-
const row = (label, w) => (w ? html`<span class="urow"><span>${label}</span><b class="${lvl(w.pct).trim()}">${w.pct}%</b><i><i style="width:${Math.min(100, w.pct)}%" class="${lvl(w.pct).trim()}"></i></i><small>resets ${when(w.resetsAt)}</small></span>` : "");
|
|
585
|
-
return html`<span class="uchip" tabindex="0" aria-label="${NAME[u.agent]} usage">${mark}<b class="${lvl(head?.pct ?? 0).trim()}">${head ? head.pct + "%" : ""}</b><span class="utip" role="tooltip"><b>${NAME[u.agent]}</b>${row("5-hour window", u.five)}${row("Week", u.week)}</span></span>`;
|
|
586
|
-
})
|
|
587
|
-
.join("");
|
|
588
|
-
}
|
|
589
|
-
async function usage(refresh = false) {
|
|
590
|
-
try {
|
|
591
|
-
const r = await fetch("/usage" + (refresh ? "?refresh=1" : ""));
|
|
592
|
-
if (!r.ok) return;
|
|
593
|
-
const list = await r.json();
|
|
594
|
-
$("usage").innerHTML = usageChips(list);
|
|
595
|
-
// Nothing to refresh: only Claude and Codex report usage.
|
|
596
|
-
$("usage-r").style.display = list.length ? "" : "none";
|
|
597
|
-
} catch {}
|
|
598
|
-
}
|
|
599
|
-
async function phone() {
|
|
600
|
-
try {
|
|
601
|
-
const d = await (await fetch("/phone")).json();
|
|
602
|
-
const el = $("phone");
|
|
603
|
-
el.hidden = false;
|
|
604
|
-
const [txt, on, tip] = !d.tailscale
|
|
605
|
-
? ["Tailscale off", false, "Tailscale is not running on this computer"]
|
|
606
|
-
: d.online
|
|
607
|
-
? ["Phone connected", true, "A phone is online on your tailnet"]
|
|
608
|
-
: ["Phone offline", false, d.phones ? "Your phone is not online on the tailnet" : "No phone on your tailnet"];
|
|
609
|
-
el.title = tip;
|
|
610
|
-
el.innerHTML = String(html`<svg aria-hidden="true"><use href="#i-phone"/></svg><span class="ptxt">${txt}</span><span class="dot${on ? "" : " off"}"></span>`);
|
|
611
|
-
} catch {}
|
|
612
|
-
}
|
|
613
|
-
// Live terminals: the board's agent sessions plus the shells /shell started.
|
|
614
|
-
let agentPtys = 0;
|
|
615
|
-
let onCount: ((cards: any[]) => void) | null = null;
|
|
616
|
-
async function terms() {
|
|
617
|
-
let shells = 0;
|
|
618
|
-
try {
|
|
619
|
-
store.shells = await (await fetch("/shells")).json();
|
|
620
|
-
shells = store.shells.length;
|
|
621
|
-
dispatchEvent(new Event("kz-shells"));
|
|
622
|
-
} catch {}
|
|
623
|
-
const n = agentPtys + shells,
|
|
624
|
-
a = $("tcount");
|
|
625
|
-
a.hidden = !n;
|
|
626
|
-
a.querySelector("span").textContent = String(n);
|
|
627
|
-
a.title = `${n} live terminal${n === 1 ? "" : "s"}: show them all`;
|
|
628
|
-
}
|
|
629
|
-
export function initFooter(goTerminal: () => void) {
|
|
630
|
-
if (!$("foot")) return;
|
|
631
|
-
// The Board drawer is position:fixed; it stops above the footer, whose height varies.
|
|
632
|
-
const fh = () => document.documentElement.style.setProperty("--foot-h", $("foot").offsetHeight + "px");
|
|
633
|
-
new ResizeObserver(fh).observe($("foot"));
|
|
634
|
-
fh();
|
|
635
|
-
initResources();
|
|
636
|
-
void usage();
|
|
637
|
-
void phone();
|
|
638
|
-
setInterval(() => void usage(), 5 * 60_000);
|
|
639
|
-
setInterval(() => void phone(), 60_000);
|
|
640
|
-
$("usage-r").onclick = () => void usage(true);
|
|
641
|
-
$("tcount").onclick = (e) => {
|
|
642
|
-
if (e.ctrlKey || e.metaKey || e.shiftKey || e.button) return;
|
|
643
|
-
e.preventDefault();
|
|
644
|
-
goTerminal();
|
|
645
|
-
};
|
|
646
|
-
onCount = (cards) => {
|
|
647
|
-
agentPtys = cards.filter((c) => c.pty?.alive).length;
|
|
648
|
-
void terms();
|
|
649
|
-
};
|
|
650
|
-
}
|