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,125 @@
|
|
|
1
|
+
// The run panel's reader, a hook of the panel (pages/board/panel.tsx). The panel store says which card is up and what it asked
|
|
2
|
+
// for (panel-actions.ts); this hook reads the card's /run reply, and derives what the panel shows from the card, the reply and the
|
|
3
|
+
// tab (panel-derive.ts): the header, the tabs, the document or notes or Source control body, the Fix form and the footer. A run
|
|
4
|
+
// is read again after each changed /state; a task is drawn again with its card. Nothing waits on a draw: an open is a write,
|
|
5
|
+
// and the panel follows.
|
|
6
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
7
|
+
import { toast } from "@lib/core";
|
|
8
|
+
import { cardKey as key, getServer, useServer } from "@lib/server";
|
|
9
|
+
import { getRoute } from "@lib/router";
|
|
10
|
+
import { gitLeave, gitPendingIn, gitShownIn, gitTab } from "@lib/git";
|
|
11
|
+
import { setNotes } from "@lib/notes";
|
|
12
|
+
import { showTerm, termStop } from "./card-terminal.ts";
|
|
13
|
+
import { deriveRun, taskPanel } from "./panel-derive.ts";
|
|
14
|
+
import { editingNotes, getPanel, panelWaiters, setPanel, usePanel } from "./panel-store.ts";
|
|
15
|
+
|
|
16
|
+
let markN = 0; // each request to mark a line is a new number, so the document marks it once
|
|
17
|
+
const settle = () => {
|
|
18
|
+
for (const f of [...panelWaiters]) f();
|
|
19
|
+
panelWaiters.clear();
|
|
20
|
+
};
|
|
21
|
+
// The live copy of the open card; the one the open passed only while its own first draw has not happened.
|
|
22
|
+
const cardOf = (fresh: boolean) => getServer().state.cards.find((x: any) => key(x) === getPanel().openKey) ?? (fresh ? getPanel().card : null);
|
|
23
|
+
|
|
24
|
+
export function usePanelRun() {
|
|
25
|
+
const k = usePanel((s) => s.openKey),
|
|
26
|
+
openN = usePanel((s) => s.openN),
|
|
27
|
+
fetchAsk = usePanel((s) => s.fetchAsk),
|
|
28
|
+
drawAsk = usePanel((s) => s.drawAsk),
|
|
29
|
+
runDoc = usePanel((s) => s.runDoc),
|
|
30
|
+
state = useServer((s) => s.state);
|
|
31
|
+
const asked = useRef(""), // the open and read the last read answered
|
|
32
|
+
landed = useRef(""), // the open whose own read has landed
|
|
33
|
+
drawn = useRef(""); // the open that has drawn
|
|
34
|
+
const id = `${k}|${openN}`;
|
|
35
|
+
|
|
36
|
+
// The read: for a new open, a read again, or a changed /state (not while notes are being typed: a redraw would wipe them).
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const c = cardOf(drawn.current !== id);
|
|
39
|
+
if (!k || !c || c.kind !== "run") return void settle();
|
|
40
|
+
const ask = `${id}|${fetchAsk}`,
|
|
41
|
+
fresh = asked.current !== ask;
|
|
42
|
+
asked.current = ask;
|
|
43
|
+
if (!fresh && getPanel().runDoc?.id === c.id && editingNotes()) return;
|
|
44
|
+
const ac = new AbortController();
|
|
45
|
+
fetch(`/run/${encodeURIComponent(c.id)}?dir=${encodeURIComponent(c.state)}`, { signal: ac.signal })
|
|
46
|
+
.then((r) => r.json())
|
|
47
|
+
.then(
|
|
48
|
+
(d) => {
|
|
49
|
+
if (getPanel().openKey !== k) return;
|
|
50
|
+
// A run that is gone answers {error} with no id: not a document. Whoever waits on this read is let go.
|
|
51
|
+
if (!d || d.id !== c.id) {
|
|
52
|
+
toast(d?.error || "Could not read this run");
|
|
53
|
+
return settle();
|
|
54
|
+
}
|
|
55
|
+
landed.current = id;
|
|
56
|
+
setPanel({ runDoc: d });
|
|
57
|
+
},
|
|
58
|
+
() => ac.signal.aborted || settle(),
|
|
59
|
+
);
|
|
60
|
+
// A newer open, a changed /state or closing aborts it, so a slow reply never draws another card as this run.
|
|
61
|
+
return () => ac.abort();
|
|
62
|
+
}, [k, openN, fetchAsk, state]);
|
|
63
|
+
|
|
64
|
+
// The draw: a run when its reply lands (every /state change reads again) or a tab or redraw is asked for; a task whenever its card
|
|
65
|
+
// changes. Layout effect: the panel never paints the previous card's header under the new title.
|
|
66
|
+
const idea = k && cardOf(true)?.kind === "idea";
|
|
67
|
+
useLayoutEffect(() => {
|
|
68
|
+
const first = drawn.current !== id,
|
|
69
|
+
c = cardOf(first);
|
|
70
|
+
if (!k || !c) return;
|
|
71
|
+
const p = getPanel();
|
|
72
|
+
// A new open waits for its own read; a redraw of what is up leaves notes being typed alone.
|
|
73
|
+
if (c.kind === "run" && first && landed.current !== id) return;
|
|
74
|
+
if (!first && editingNotes()) return;
|
|
75
|
+
if (c.kind === "run" && p.runDoc?.id !== c.id) return;
|
|
76
|
+
drawn.current = id;
|
|
77
|
+
if (p.wantTerm === key(c)) setPanel({ wantTerm: null });
|
|
78
|
+
if (c.kind === "idea") {
|
|
79
|
+
const t = taskPanel(c);
|
|
80
|
+
setPanel({ head: t.head, tabs: [], tab: "", ptabs: [], footer: t.footer });
|
|
81
|
+
// A task's panel: its terminal while the run it started is being born there, else its notes. In the run workspace the
|
|
82
|
+
// agent is a centre tab; on the Tasks page a task shows its notes only.
|
|
83
|
+
if (c.pty && getRoute().view !== "run" && getRoute().view !== "tasks") showTerm(c);
|
|
84
|
+
else {
|
|
85
|
+
termStop();
|
|
86
|
+
setPanel((s) => ({ body: "notes", top: s.top + 1 }));
|
|
87
|
+
setNotes({ view: { card: c, src: c.notes, ro: !!c.archived || c.status !== "idea" } });
|
|
88
|
+
}
|
|
89
|
+
return settle();
|
|
90
|
+
}
|
|
91
|
+
const d = deriveRun({
|
|
92
|
+
card: c,
|
|
93
|
+
runDoc: p.runDoc,
|
|
94
|
+
wantTab: p.wantTab,
|
|
95
|
+
view: getRoute().view,
|
|
96
|
+
wide: getRoute().view === "run" || innerWidth > 640,
|
|
97
|
+
git: { shown: gitShownIn(c, p.runDoc), pending: gitPendingIn(c, p.runDoc) },
|
|
98
|
+
hit: p.hit,
|
|
99
|
+
refresh: !first,
|
|
100
|
+
key,
|
|
101
|
+
});
|
|
102
|
+
termStop();
|
|
103
|
+
if (d.tab !== "git") gitLeave();
|
|
104
|
+
setPanel((s) => ({
|
|
105
|
+
wide: false,
|
|
106
|
+
head: d.head,
|
|
107
|
+
tabs: d.tabs,
|
|
108
|
+
tab: d.tab,
|
|
109
|
+
wantTab: d.tab,
|
|
110
|
+
ptabs: d.tabs.map((t) => t.k),
|
|
111
|
+
fix: d.fix,
|
|
112
|
+
footer: d.footer,
|
|
113
|
+
...(d.kind === "doc" ? { body: "doc" as const, doc: { ...d.doc!, mark: d.needle && first ? ++markN : 0 }, top: s.top + 1 } : {}),
|
|
114
|
+
...(d.kind === "notes" ? { body: "notes" as const, top: s.top + 1 } : {}),
|
|
115
|
+
}));
|
|
116
|
+
if (d.kind === "notes") setNotes({ view: d.notes! });
|
|
117
|
+
else if (d.kind === "git") gitTab(c);
|
|
118
|
+
// Only the panel the link asked for: another card opened meanwhile drops the request.
|
|
119
|
+
if (p.hit && first) {
|
|
120
|
+
if (p.hit.k === key(c) && !d.needle) toast("That item is not in this run");
|
|
121
|
+
setPanel({ hit: null });
|
|
122
|
+
}
|
|
123
|
+
settle();
|
|
124
|
+
}, [k, openN, drawAsk, runDoc, idea ? state : null]);
|
|
125
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// What the run panes need while mounted and what runs only while the run view is shown (a hook of the run panes, torn down with them): the panes' actions and kept-terminal pruning (bindRunView), then:
|
|
2
|
+
// reading the address on each visit (showRunView, an effect of the route), the Preview polling every 3 s, the tmux-style keyboard (Ctrl+Space, then a key) and the workspace's reaction to a new
|
|
3
|
+
// /state (a run reaching review opens the Browser, a new run takes the panel's pick, the tabs are read again). Off the run
|
|
4
|
+
// view none of it runs: no timer, no key listener, no reaction.
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { layerOpen } from "@lib/core";
|
|
7
|
+
import { onState } from "@lib/server";
|
|
8
|
+
import { useRoute } from "@lib/router";
|
|
9
|
+
import { autoBrowse, bindRunView, pollPreview, showRunView } from "./workspace.ts";
|
|
10
|
+
import { followNew } from "./ws-draw.ts";
|
|
11
|
+
import { paneKey } from "./ws-actions.ts";
|
|
12
|
+
import { getWs, screens, saved } from "./ws-store.ts";
|
|
13
|
+
import { focusPane, setRunView } from "./index.ts";
|
|
14
|
+
|
|
15
|
+
const POLL = 3000;
|
|
16
|
+
const keyHint = (on: boolean) => setRunView({ hint: on });
|
|
17
|
+
// Capture: xterm must not see these. Ctrl+B would reach an agent or a tmux inside the pane. While the prefix waits for its
|
|
18
|
+
// key, a chip says so and lists the keys (components/run/key-hint.tsx).
|
|
19
|
+
function paneKeys() {
|
|
20
|
+
let armed: ReturnType<typeof setTimeout> | undefined;
|
|
21
|
+
const on = (e: KeyboardEvent) => {
|
|
22
|
+
// A dialog or an open menu has the keyboard (Ctrl+Space may be an input-method switch there): the pane behind takes none.
|
|
23
|
+
if (!getWs().ctx || layerOpen()) return;
|
|
24
|
+
if (e.ctrlKey && !e.shiftKey && e.code === "Space") {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
focusPane(screens().find((x) => x.id === saved().on)?.focus);
|
|
28
|
+
clearTimeout(armed);
|
|
29
|
+
keyHint(true);
|
|
30
|
+
armed = setTimeout(() => ((armed = undefined), keyHint(false)), 2000);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!armed || ["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
clearTimeout(armed);
|
|
37
|
+
armed = undefined;
|
|
38
|
+
keyHint(false);
|
|
39
|
+
paneKey(e.key);
|
|
40
|
+
};
|
|
41
|
+
addEventListener("keydown", on, true);
|
|
42
|
+
return () => (clearTimeout(armed), keyHint(false), removeEventListener("keydown", on, true));
|
|
43
|
+
}
|
|
44
|
+
export function useRunLifecycle() {
|
|
45
|
+
const shown = useRoute((s) => s.view === "run"),
|
|
46
|
+
visit = useRoute((s) => s.visit);
|
|
47
|
+
// The actions the panes call, and the pruning of kept terminals whose session is gone, for as long as the panes are mounted.
|
|
48
|
+
useEffect(() => bindRunView(), []);
|
|
49
|
+
// The address names the workspace, run or task to show: read on every visit to the run view (the router counts one for each
|
|
50
|
+
// `navigate`, also when the view was already showing), in a microtask so the page's own panel handling in the router's
|
|
51
|
+
// `enter` runs first. A visit left before then does not read it. Visit 0 is the first paint, drawn from the address before the
|
|
52
|
+
// board has loaded; the first `navigate` (once it has) is the first visit.
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!shown || !visit) return;
|
|
55
|
+
let on = true;
|
|
56
|
+
queueMicrotask(() => on && void showRunView(true));
|
|
57
|
+
return () => void (on = false);
|
|
58
|
+
}, [shown, visit]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!shown) return;
|
|
61
|
+
const offKeys = paneKeys(),
|
|
62
|
+
timer = setInterval(() => void pollPreview(), POLL),
|
|
63
|
+
offState = onState(() => {
|
|
64
|
+
void autoBrowse();
|
|
65
|
+
followNew();
|
|
66
|
+
if (getWs().ctx) void showRunView();
|
|
67
|
+
});
|
|
68
|
+
return () => (offKeys(), clearInterval(timer), offState());
|
|
69
|
+
}, [shown]);
|
|
70
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Files the board links to (attachments, Preview screenshots, icebox images) open in a popup over the board rather than
|
|
2
|
+
// a new tab. components/run/file-viewer.tsx catches the click and draws the popup.
|
|
3
|
+
import { create } from "zustand";
|
|
4
|
+
|
|
5
|
+
const IMG = /\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i;
|
|
6
|
+
export const useViewer = create<{ file: { href: string; name: string } | null }>()(() => ({ file: null }));
|
|
7
|
+
// Only the board's own file routes open here; anything else is left to the browser.
|
|
8
|
+
export const viewable = (href: string) => /^\/(file|ice-image)\?/.test(href);
|
|
9
|
+
export const fileName = (href: string) => new URLSearchParams(href.split("?")[1]).get("p")?.split("/").pop() ?? "Image";
|
|
10
|
+
export const isImage = (href: string, name: string) => href.startsWith("/ice-image") || IMG.test(name);
|
|
11
|
+
export const openFile = (href: string) => useViewer.setState({ file: { href, name: fileName(href) } });
|
|
12
|
+
export const closeFile = () => useViewer.setState({ file: null });
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// The run workspace's lifecycle (?view=ws&dir=&ws=; a run's or task's old address resolves to its workspace and picks that run
|
|
2
|
+
// in the panel): a tab bar over one folder holding terminals and the Browser, never runs. This module reads the address and
|
|
3
|
+
// the server, decides what the workspace opens (a shell in an empty one, a run's resumed agent, the Browser on a run's
|
|
4
|
+
// Preview), and answers the router's enter and leave. The rest is split by what it is: which tabs there are
|
|
5
|
+
// (ws-derive.ts, pure), the state it keeps (ws-store.ts), the redraw and the panel's pick (ws-draw.ts), what a person does
|
|
6
|
+
// (ws-actions.ts), which workspaces keep their panes mounted (kept.ts, pure), and what runs only while the run view is shown,
|
|
7
|
+
// the Preview polling, the keyboard and the reaction to a new /state (use-run-lifecycle.ts, a hook of the run panes). The
|
|
8
|
+
// panes, their layout and the Browser tab are React (components/run, lib/run/layout-store.ts). Panes of every workspace
|
|
9
|
+
// visited stay mounted, hidden, up to a cap, so leaving a workspace and coming back keeps a Browser page, a note's scroll and
|
|
10
|
+
// a terminal's screen; the run panel (#panel, usePanelRun) docks on the right and shows one run, chosen in its picker.
|
|
11
|
+
// A workspace with no tab opens a shell in its folder. Split right or down shows a second tab beside the first.
|
|
12
|
+
import { cardHref, titleOf, wsHref, wsOfCardNow as wsOfCard } from "@lib/rail";
|
|
13
|
+
import { getRoute, navigate, setTitle, touchRoute } from "@lib/router";
|
|
14
|
+
import { cardKey as key, getServer, load, onServer, onState, railDataNow, readShells } from "@lib/server";
|
|
15
|
+
import { preview } from "@lib/markdown";
|
|
16
|
+
import { pick } from "@lib/project";
|
|
17
|
+
import { isTerm, liveKeys, pruneDead } from "./kept.ts";
|
|
18
|
+
import { followNew, mineNow, picked, seenRuns, tabs, draw } from "./ws-draw.ts";
|
|
19
|
+
import { byKey, autoTab, closeScreen, closeTab, moveItem, newPty, openAgent, openNew, openNoteTab, previewApp, projectNotes, show } from "./ws-actions.ts";
|
|
20
|
+
import { cx, edit, getWs, saved, setWs } from "./ws-store.ts";
|
|
21
|
+
import { devUrl, finished, leaves, loopbackUrl, migrate, previewOpens, reviewing, toOpen, wsKey } from "./ws-tabs.ts";
|
|
22
|
+
import { clearBrowse, fetchPreview, keepUrl, layoutOf, refreshPreview, replaceAll, requestBrowse, selectScreen, setDragging, getPanel, setPanel, setRunActions, setRunView, useLayout, useRunView } from "./index.ts";
|
|
23
|
+
|
|
24
|
+
export { openNoteTab, openPreview, projectNotes } from "./ws-actions.ts";
|
|
25
|
+
let switched: string | null = null; // the project a deep link last switched the board to
|
|
26
|
+
const none = (t: string) => setRunView({ message: t });
|
|
27
|
+
// Called by navigate("run") and on every /state: draws the tab strip and keeps the panes.
|
|
28
|
+
export async function showRunView(nav = false) {
|
|
29
|
+
const p = new URLSearchParams(location.search),
|
|
30
|
+
dir = p.get("dir"),
|
|
31
|
+
id = p.get("id"),
|
|
32
|
+
task = p.get("idea");
|
|
33
|
+
let ws = p.get("ws"),
|
|
34
|
+
want: any = null; // the card the address names, whose tab is selected
|
|
35
|
+
// A project this board is not showing: a deep link names its project, switched to once, as a rail click does.
|
|
36
|
+
const away = async () => {
|
|
37
|
+
if (getServer().all || !dir || dir === getServer().dir || dir === switched) return false;
|
|
38
|
+
switched = dir;
|
|
39
|
+
await pick(dir).catch(() => {});
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
if (p.get("view") === "ws" && ws) {
|
|
43
|
+
if (await away()) return showRunView(nav);
|
|
44
|
+
} else {
|
|
45
|
+
const find = (cs) => cs.find((x) => x.state === dir && (id ? x.kind === "run" && x.id === id : x.kind === "idea" && x.text === task));
|
|
46
|
+
const c = find(getServer().state.cards);
|
|
47
|
+
// A launched task becomes a run: its agent session moves to the run's card, and the view follows.
|
|
48
|
+
const pk = task && (c ?? getWs().card)?.kind === "idea" && (c ?? getWs().card)?.pty?.key;
|
|
49
|
+
const run = pk && getServer().state.cards.find((x) => x.kind === "run" && x.state === dir && (x.pty?.key === pk || x.pty?.all?.includes(pk)));
|
|
50
|
+
if (run) {
|
|
51
|
+
history.replaceState(null, "", cardHref(run));
|
|
52
|
+
touchRoute();
|
|
53
|
+
return showRunView(nav);
|
|
54
|
+
}
|
|
55
|
+
if (!c) {
|
|
56
|
+
if (await away()) return showRunView(nav);
|
|
57
|
+
if (!getServer().all && find(railDataNow().cards)) location.href = "/?all=1&" + p.toString();
|
|
58
|
+
else (stopPanes(), setWs({ ctx: null, card: null }), none(`That ${id ? "run" : "idea"} was not found.`));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
want = c;
|
|
62
|
+
ws = wsOfCard(c);
|
|
63
|
+
}
|
|
64
|
+
if (!dir || !ws) return void (stopPanes(), setWs({ ctx: null, card: null }), none("That workspace was not found."));
|
|
65
|
+
const k = wsKey(dir, ws);
|
|
66
|
+
const fresh = getWs().ctx?.k !== k;
|
|
67
|
+
// Each workspace has its own centre: switching hides this one's terminals and drops its other panes (its shells keep running on the server).
|
|
68
|
+
if (fresh) (stopPanes(), setWs({ card: null, ctx: { dir, ws, k } }));
|
|
69
|
+
if (fresh && !was.has(k)) was.set(k, new Set(mineNow().filter(reviewing).map(key))); // what is already in review does not open the Browser
|
|
70
|
+
if (fresh) seenRuns.set(k, new Set(mineNow().map(key))); // what is here on arrival is not new
|
|
71
|
+
if (fresh) previewAt.delete(k); // nor is a preview: arriving only records it
|
|
72
|
+
// The header titles a phone's workspace: the run, else the branch.
|
|
73
|
+
const w = railDataNow().projects?.find((x) => x.dir === dir)?.workspaces?.find((x) => x.path === ws);
|
|
74
|
+
setTitle(want ? titleOf(want) : w?.branch || ws.split(/[\\/]/).pop() || "Workspace");
|
|
75
|
+
// Layouts saved per run before workspaces move to their workspace; keys no card owns stay.
|
|
76
|
+
if (getServer().state.cards.some((c) => key(c) in useLayout.getState().all)) {
|
|
77
|
+
const all = structuredClone(useLayout.getState().all);
|
|
78
|
+
if (migrate(all as any, getServer().state.cards, key, wsOfCard)) replaceAll(all);
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const r = await fetch("/shells?dir=" + encodeURIComponent(dir));
|
|
82
|
+
setWs({ shells: r.ok ? await r.json() : [] });
|
|
83
|
+
} catch {}
|
|
84
|
+
if (fresh) {
|
|
85
|
+
try {
|
|
86
|
+
const d = await (await fetch("/agents?dir=" + encodeURIComponent(dir))).json();
|
|
87
|
+
setWs({ agents: d.agents ?? [], defAgent: d.default ?? "" });
|
|
88
|
+
} catch {}
|
|
89
|
+
}
|
|
90
|
+
if (getWs().ctx?.k !== k) return;
|
|
91
|
+
// Every navigation (a notification, a Board card, a link) picks the card's run in the panel, even for an address already open: a finished run opens read-only.
|
|
92
|
+
// A fresh visit forgets the old pick (waiting first again); one made during the visit stays.
|
|
93
|
+
if (fresh) picked.delete(k);
|
|
94
|
+
if (want?.kind === "run" && (nav || fresh)) picked.set(k, key(want));
|
|
95
|
+
followNew(); // a run created while the view was away (the lifecycle hook only reacts while shown) takes the pick before the first draw
|
|
96
|
+
// A workspace with nothing open starts a shell in its folder (no agent, no run). A live run whose own Claude
|
|
97
|
+
// session is not open anywhere on the board is resumed here, once per visit.
|
|
98
|
+
if (!getWs().noPty) {
|
|
99
|
+
if (!tabs().length && !autoShell.has(k)) return void (autoShell.add(k), newPty());
|
|
100
|
+
// Not while a launch from the board is coming up: its terminal is not tied to the new run card yet, and
|
|
101
|
+
// resuming the run here would open a second agent on the same session beside it (the stray "Agent" tab).
|
|
102
|
+
const launching = !!getPanel().wantPty && Date.now() - getPanel().wantPty!.at < 20_000;
|
|
103
|
+
if (want && want.kind === "run" && !finished(want) && !want.pty && !launching && !getWs().shells.some((x) => x.run === key(want)) && !autoShell.has(key(want))) {
|
|
104
|
+
autoShell.add(key(want));
|
|
105
|
+
void openAgent(want, false, false);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!showTerm()) draw();
|
|
109
|
+
}
|
|
110
|
+
// The terminal the sidebar asked for (`selectTerm`, the workspace store), selected once the workspace's tabs are known.
|
|
111
|
+
function showTerm() {
|
|
112
|
+
// A launch from the board names its terminal (the panel store's wantPty): it is selected once its tab exists,
|
|
113
|
+
// and the ask lapses after a while so a launch that never came up cannot pull focus later.
|
|
114
|
+
const pty = getPanel().wantPty,
|
|
115
|
+
w = pty && Date.now() - pty.at < 20_000 ? pty.key : null;
|
|
116
|
+
if (pty && !w) setPanel({ wantPty: null });
|
|
117
|
+
// Asked for by name (the sidebar's mark, a launch): shown even if its tab was closed before.
|
|
118
|
+
const want = getWs().selectTerm || w;
|
|
119
|
+
if (want) edit((s) => ({ ...s, hidden: s.hidden.filter((h) => h !== "agent:" + want && h !== "sh:" + want) }));
|
|
120
|
+
const t = tabs().find((x) => x.key === want);
|
|
121
|
+
setWs({ selectTerm: null });
|
|
122
|
+
if (t && getPanel().wantPty?.key === t.key) setPanel({ wantPty: null });
|
|
123
|
+
return !!t && (show(t.id), true);
|
|
124
|
+
}
|
|
125
|
+
const autoShell = new Set<string>();
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
// Leaving the workspace: its panes stay mounted (hidden), the shells keep running on the server.
|
|
129
|
+
export function stopPanes() {
|
|
130
|
+
setPanel({ parked: true });
|
|
131
|
+
// No items, no workspace shown: its panes stay in `kept` (run-view-store), hidden.
|
|
132
|
+
setRunView({ items: [], wsk: null, ws: null });
|
|
133
|
+
clearBrowse();
|
|
134
|
+
}
|
|
135
|
+
export function runStop() {
|
|
136
|
+
stopPanes();
|
|
137
|
+
setWs({ card: null, ctx: null });
|
|
138
|
+
setPanel({ pn: false });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// The keys of the workspace's runs that were at review/done on the last tick, per workspace.
|
|
142
|
+
const was = new Map<string, Set<string>>();
|
|
143
|
+
// A run in the open workspace moves into review or done with a localhost address in its ## Preview:
|
|
144
|
+
// the Browser opens on it, once per run. The first tick of a workspace only records.
|
|
145
|
+
export async function autoBrowse() {
|
|
146
|
+
if (!getWs().ctx) return;
|
|
147
|
+
const k = cx().k,
|
|
148
|
+
mine = mineNow(),
|
|
149
|
+
prev = was.get(k);
|
|
150
|
+
was.set(k, new Set(mine.filter(reviewing).map(key)));
|
|
151
|
+
if (!prev) return;
|
|
152
|
+
for (const c of toOpen(mine, prev, saved().seen ?? [], key)) {
|
|
153
|
+
let u: string | undefined;
|
|
154
|
+
try {
|
|
155
|
+
const doc = await (await fetch(`/run/${encodeURIComponent(c.id)}?dir=${encodeURIComponent(c.state)}`)).json();
|
|
156
|
+
// Only an address the report names: with none, the lowest port in the workspace was a guess
|
|
157
|
+
// (it once opened Claude Code's own local port, "not found").
|
|
158
|
+
const pv = preview(doc.impl);
|
|
159
|
+
if (!loopbackUrl(pv)) continue;
|
|
160
|
+
u = devUrl(pv, await (await fetch("/devports?ws=" + encodeURIComponent(cx().ws))).json());
|
|
161
|
+
} catch {}
|
|
162
|
+
if (!u || getWs().ctx?.k !== k || saved().seen?.includes(key(c))) continue;
|
|
163
|
+
edit((s) => ({ ...s, seen: [...(s.seen ?? []), key(c)] }));
|
|
164
|
+
keepUrl(k, u);
|
|
165
|
+
autoTab({ id: "local", kind: "local", title: "Browser" });
|
|
166
|
+
requestBrowse(k, u);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// `kaizen preview <url|image>` (cli/preview.ts) wrote what an agent changed: the Browser tab opens
|
|
171
|
+
// on it, inside the board. Never an outside window. Only in the workspace it was written from, and
|
|
172
|
+
// only while you watch it: each visit's first look records the newest (`previewAt`, per visit), so a
|
|
173
|
+
// click, a switch or a reload never opens a tab, or reopens one you closed.
|
|
174
|
+
const previewAt = new Map<string, number>();
|
|
175
|
+
export async function pollPreview() {
|
|
176
|
+
if (!getWs().ctx) return;
|
|
177
|
+
const k = cx().k, dir = cx().dir;
|
|
178
|
+
const p = await fetchPreview(dir, cx().ws);
|
|
179
|
+
if (getWs().ctx?.k !== k) return;
|
|
180
|
+
const at = p?.at ?? 0, last = previewAt.get(k);
|
|
181
|
+
if (last !== undefined && at <= last) return;
|
|
182
|
+
previewAt.set(k, at);
|
|
183
|
+
if (!p || !previewOpens(at, last)) return;
|
|
184
|
+
if (p.image) {
|
|
185
|
+
// A screenshot belongs in Preview; a live page in the Browser. An open Preview reads the new one.
|
|
186
|
+
const open = saved().tabs.some((x) => x.id === "preview");
|
|
187
|
+
autoTab({ id: "preview", kind: "preview", title: "Preview" });
|
|
188
|
+
if (open) refreshPreview();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
keepUrl(k, p.url!);
|
|
192
|
+
autoTab({ id: "local", kind: "local", title: "Browser" });
|
|
193
|
+
requestBrowse(k, p.url!);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
// A kept terminal whose session is gone (ended, or its tab closed in another window) is unmounted (kept.ts). `dropDead` reads
|
|
199
|
+
// the lists the board already has; those lag a session started a moment ago (/shells is read with each all-projects /state),
|
|
200
|
+
// so a /state tick or a terminal that ended reads /shells first (`pruneKept`, only when a hidden workspace holds a terminal).
|
|
201
|
+
// Without that read a live terminal started just before leaving the workspace would count as gone.
|
|
202
|
+
function dropDead() {
|
|
203
|
+
const s = getServer(),
|
|
204
|
+
cur = useRunView.getState().kept,
|
|
205
|
+
next = pruneDead(cur, liveKeys(s.shells, s.state.agents ?? [], s.state.cards), getWs().ctx?.k ?? null);
|
|
206
|
+
if (next !== cur) setRunView({ kept: next });
|
|
207
|
+
}
|
|
208
|
+
export async function pruneKept() {
|
|
209
|
+
const shown = getWs().ctx?.k;
|
|
210
|
+
if (!Object.entries(useRunView.getState().kept).some(([k, v]) => k !== shown && v.items.some(isTerm))) return;
|
|
211
|
+
if (await readShells()) dropDead(); // offline: no list to judge by, nothing is dropped
|
|
212
|
+
}
|
|
213
|
+
export const ended = () => void (load(true), pruneKept());
|
|
214
|
+
// The workspace address, in the history, and the run view for it.
|
|
215
|
+
function goWs(dir: string, ws: string) {
|
|
216
|
+
history.pushState(null, "", wsHref(dir, ws));
|
|
217
|
+
touchRoute();
|
|
218
|
+
navigate("ws");
|
|
219
|
+
}
|
|
220
|
+
// A workspace row opens in place: the run view resolves it (showRunView).
|
|
221
|
+
export const openWsIn = goWs;
|
|
222
|
+
// The sidebar's agent mark: open that workspace with the agent's terminal tab selected.
|
|
223
|
+
export function openTermIn({ dir, ws, key }: { dir: string; ws: string; key: string }) {
|
|
224
|
+
setWs({ selectTerm: key });
|
|
225
|
+
if (getWs().ctx?.k === wsKey(dir, ws) && getRoute().view === "run") return void showTerm();
|
|
226
|
+
goWs(dir, ws);
|
|
227
|
+
}
|
|
228
|
+
// Search's Tabs group: open the workspace on the screen holding that tab.
|
|
229
|
+
export function openTabIn({ dir, ws, id }: { dir: string; ws: string; id: string }) {
|
|
230
|
+
const k = wsKey(dir, ws),
|
|
231
|
+
sc = layoutOf(k).screens.find((x) => leaves(x.tree).includes(id));
|
|
232
|
+
if (sc) selectScreen(k, sc.id);
|
|
233
|
+
if (getWs().ctx?.k === k && getRoute().view === "run") return void draw();
|
|
234
|
+
goWs(dir, ws);
|
|
235
|
+
}
|
|
236
|
+
// What the run panes call, and what keeps their terminals honest: started by useRunLifecycle when the panes mount, undone with them.
|
|
237
|
+
export function bindRunView() {
|
|
238
|
+
// A /state change, new shells or a session that ended: terminals kept hidden whose session is gone are unmounted.
|
|
239
|
+
const offs = [onServer((x) => x.shells, dropDead), onState(() => void pruneKept())];
|
|
240
|
+
setRunActions({
|
|
241
|
+
select: (sid) => {
|
|
242
|
+
selectScreen(cx().k, sid);
|
|
243
|
+
draw();
|
|
244
|
+
},
|
|
245
|
+
close: (sid) => void closeScreen(sid),
|
|
246
|
+
closeItem: (id) => void closeTab(id),
|
|
247
|
+
openNew,
|
|
248
|
+
runApp: () => void previewApp(),
|
|
249
|
+
move: moveItem,
|
|
250
|
+
drag: setDragging,
|
|
251
|
+
dragging: () => useLayout.getState().dragging,
|
|
252
|
+
drop: (to) => {
|
|
253
|
+
const id = useLayout.getState().dragging;
|
|
254
|
+
if (id) moveItem(id, to);
|
|
255
|
+
},
|
|
256
|
+
openHere: (k) => byKey(k) && void openAgent(byKey(k), true),
|
|
257
|
+
pick: (k) => byKey(k) && (picked.set(cx().k, k), draw()),
|
|
258
|
+
openNote: openNoteTab,
|
|
259
|
+
termEnded: ended,
|
|
260
|
+
currentRun: () => (getWs().card?.id ? { dir: getWs().card.state, id: getWs().card.id } : null),
|
|
261
|
+
previewTarget: () => {
|
|
262
|
+
const { ctx, card } = getWs();
|
|
263
|
+
return (
|
|
264
|
+
ctx && {
|
|
265
|
+
dir: ctx.dir,
|
|
266
|
+
ws: ctx.ws,
|
|
267
|
+
card: card ? { id: card.id, kind: card.kind, state: card.state } : null,
|
|
268
|
+
impl: getPanel().runDoc && getPanel().runDoc.id === card?.id ? getPanel().runDoc.impl : null,
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
return () => offs.forEach((off) => off());
|
|
274
|
+
}
|
|
275
|
+
// Opens a card's workspace, its address in the history.
|
|
276
|
+
export function openWorkspace(c) {
|
|
277
|
+
const u = cardHref(c);
|
|
278
|
+
if (location.pathname + location.search !== u) history.pushState(null, "", u);
|
|
279
|
+
touchRoute();
|
|
280
|
+
navigate("run");
|
|
281
|
+
}
|