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/icebox.ts
DELETED
|
@@ -1,1788 +0,0 @@
|
|
|
1
|
-
import { store } from "./store.ts";
|
|
2
|
-
import { termStop } from "./agent-term.ts";
|
|
3
|
-
import { load, post } from "./api.ts";
|
|
4
|
-
import { via } from "./cards.ts";
|
|
5
|
-
import { mic, stopDictation } from "./dictation.ts";
|
|
6
|
-
import { $, dataUrls, html, ico, modal, motion, pageOf, pager, pagerHtml, raw, SKEL, toggleSwitch, wirePager } from "./dom.ts";
|
|
7
|
-
import { plogo, setShown, short, showable } from "./projects.ts";
|
|
8
|
-
import { playSound, soundPick, toast } from "./toast.ts";
|
|
9
|
-
import { go, view } from "./views.ts";
|
|
10
|
-
|
|
11
|
-
// A link from sources.json or a gathered post: the server checks it on the way in, this keeps a javascript: URL from ever being a clickable href.
|
|
12
|
-
const web = (u: string) => (/^https?:\/\//i.test(String(u)) ? u : "#");
|
|
13
|
-
|
|
14
|
-
// ---- the icebox: requests gathered from request sources, read like an inbox, until
|
|
15
|
-
// someone promotes them to tasks or dismisses them. The sources themselves sit in a
|
|
16
|
-
// section below, folded. Same panel as settings.
|
|
17
|
-
const SRC = "Icebox";
|
|
18
|
-
// What the page keeps across the rebuild every server change brings: the item whose
|
|
19
|
-
// promote form is open and the one the cursor is on (both "<dir> <id>"), the checked
|
|
20
|
-
// items, the source filter ("<dir> <url>"), whether the sources section is open, and
|
|
21
|
-
// whether a bulk action is still posting.
|
|
22
|
-
// The category filter, and whether the add form takes a link or a social account/tag. The
|
|
23
|
-
// project filter is the board's own `shown`, so the board and the icebox narrow alike.
|
|
24
|
-
// The reply being written to a gathered post: its item, the text, and whether it is out.
|
|
25
|
-
// The reply style is per project: a promo voice in one need not leak into another's drafts.
|
|
26
|
-
let iceReply = null;
|
|
27
|
-
// The task ChatGPT drafted for the open promote form: its item key, whether it is still coming,
|
|
28
|
-
// the title and details, or why there is none. The person's own typing always wins.
|
|
29
|
-
let iceTask = null;
|
|
30
|
-
const iceStyle = {};
|
|
31
|
-
const icePg = pager("icebox");
|
|
32
|
-
const rStyle = (dir) => {
|
|
33
|
-
if (!iceStyle[dir])
|
|
34
|
-
try {
|
|
35
|
-
iceStyle[dir] = localStorage.getItem("kz-reply-style:" + dir);
|
|
36
|
-
} catch (e) {}
|
|
37
|
-
return iceStyle[dir] || "casual";
|
|
38
|
-
};
|
|
39
|
-
const STYLES = { casual: "Casual", fun: "Fun", helpful: "Helpful", promo: "Promo" };
|
|
40
|
-
export let iceForm = null,
|
|
41
|
-
// The item whose promote form is showing: opened by its "+", never by opening the row.
|
|
42
|
-
icePro = null,
|
|
43
|
-
iceCur = null,
|
|
44
|
-
iceSrc = "",
|
|
45
|
-
iceCat = "",
|
|
46
|
-
srcKind = "link",
|
|
47
|
-
srcShow = null,
|
|
48
|
-
srcAdd = false,
|
|
49
|
-
iceBusy = false,
|
|
50
|
-
iceNav = null;
|
|
51
|
-
const iceSel = new Set();
|
|
52
|
-
// The swipe view: one waiting request at a time, decided by drag, button or arrow key.
|
|
53
|
-
// Null when the list shows. It counts this session's decisions, keeps the last dismiss
|
|
54
|
-
// for Undo, and how often each request was skipped (skipped ones go to the back).
|
|
55
|
-
let iceSwipe = null;
|
|
56
|
-
// A rebuild while the card is held would drop the drag: it waits for the release.
|
|
57
|
-
let swHeld = false,
|
|
58
|
-
swLate = false;
|
|
59
|
-
const PLAT = { x: "X", tiktok: "TikTok", instagram: "Instagram", threads: "Threads" };
|
|
60
|
-
// What an item is: a client asked for it, you found it, or people say it (the server's KINDS).
|
|
61
|
-
const KIND = { client: "Client", finding: "Finding", people: "People say" };
|
|
62
|
-
// The capture box outlives every rebuild: its field and mic are kept nodes, so the text, the caret
|
|
63
|
-
// and a dictation in progress survive a server change. Files and the picked board wait with it.
|
|
64
|
-
const cap = { ta: null, mic: null, files: [], board: "", boardDir: null, dir: null, busy: false };
|
|
65
|
-
// Cards or Sort, per browser; the board and kind filters; the item menu that is open ("<item key> <menu>").
|
|
66
|
-
let iceView = "cards";
|
|
67
|
-
try {
|
|
68
|
-
iceView = localStorage.getItem("kz-ice-view") === "sort" ? "sort" : "cards";
|
|
69
|
-
} catch (e) {}
|
|
70
|
-
let iceBoard = "",
|
|
71
|
-
iceMenu = "",
|
|
72
|
-
// When the open menu was drawn: the redraw that shows it restores the scroll, and that scroll
|
|
73
|
-
// event must not shut it again.
|
|
74
|
-
iceMenuAt = 0,
|
|
75
|
-
iceMenuFor = "";
|
|
76
|
-
const iceKinds = new Set();
|
|
77
|
-
// Wired on the first open, not at import: tests load this module with no window.
|
|
78
|
-
let narrowQ = null;
|
|
79
|
-
function wireOnce() {
|
|
80
|
-
if (narrowQ) return;
|
|
81
|
-
narrowQ = matchMedia("(max-width:640px)");
|
|
82
|
-
// A window crossing 640 px swaps cards for the list.
|
|
83
|
-
narrowQ.addEventListener("change", () => view === "sources" && srcOpen() && openSources());
|
|
84
|
-
// A click anywhere but a menu or its button shuts the open item menu.
|
|
85
|
-
document.addEventListener("click", (e) => {
|
|
86
|
-
if (!iceMenu || (e.target as Element).closest?.(".ice-mpop,[data-m]")) return;
|
|
87
|
-
iceMenu = "";
|
|
88
|
-
if (view === "sources" && srcOpen()) openSources();
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
// A new collection: its name and whether it is a client's, asked in the board's own dialog
|
|
92
|
-
// (the desktop app has no window.prompt). Resolves null when cancelled.
|
|
93
|
-
function askCollection(where = ""): Promise<{ name: string; client: boolean } | null> {
|
|
94
|
-
return new Promise((done) => {
|
|
95
|
-
const dl = modal(html`<label class="hint" for="ice-cn" style="margin:0">New collection${where ? ` in ${where}` : ""}: a client or a topic</label><input class="sel" id="ice-cn" maxlength="40" placeholder="e.g. Arupadatu, Pricing" autocomplete="off" spellcheck="false"><label class="ice-cn-cl"><input type="checkbox" id="ice-cn-c"> A client — its items count as Client</label><div class="row"><button type="button" class="btn ghost" value="">Cancel</button><button class="btn pri">Create</button></div>`);
|
|
96
|
-
const f = dl.querySelector("form"), inp = dl.querySelector("#ice-cn") as HTMLInputElement;
|
|
97
|
-
let answer = null;
|
|
98
|
-
dl.querySelector(".btn.ghost").onclick = () => dl.close();
|
|
99
|
-
f.onsubmit = (e) => {
|
|
100
|
-
e.preventDefault();
|
|
101
|
-
const name = inp.value.trim();
|
|
102
|
-
if (!name) return inp.focus();
|
|
103
|
-
answer = { name, client: (dl.querySelector("#ice-cn-c") as HTMLInputElement).checked };
|
|
104
|
-
dl.close();
|
|
105
|
-
};
|
|
106
|
-
dl.addEventListener("close", () => done(answer));
|
|
107
|
-
inp.focus();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
// A person mark for a client's collection.
|
|
111
|
-
const PERSON = raw(
|
|
112
|
-
'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="5.2" r="2.6" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M3 13.6c.7-2.5 2.6-3.8 5-3.8s4.3 1.3 5 3.8" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
113
|
-
);
|
|
114
|
-
const sameName = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
|
|
115
|
-
// The day a snooze lands on, said as the server works it out (1d, 1w, 1m or a date).
|
|
116
|
-
const wakeDay = (until) => {
|
|
117
|
-
const d = new Date();
|
|
118
|
-
if (until === "1d") d.setDate(d.getDate() + 1);
|
|
119
|
-
else if (until === "1w") d.setDate(d.getDate() + 7);
|
|
120
|
-
else if (until === "1m") d.setMonth(d.getMonth() + 1);
|
|
121
|
-
else return new Date(until + "T00:00:00");
|
|
122
|
-
return d;
|
|
123
|
-
};
|
|
124
|
-
const ymd = (d) => d.toLocaleDateString("sv");
|
|
125
|
-
export const srcOpen = () => $("panel").classList.contains("open") && $("ptitle").textContent === SRC;
|
|
126
|
-
const ago = (at) => {
|
|
127
|
-
const m = Math.round((Date.now() - Date.parse(at)) / 60000);
|
|
128
|
-
return m < 1
|
|
129
|
-
? "just now"
|
|
130
|
-
: m < 60
|
|
131
|
-
? m + " min ago"
|
|
132
|
-
: m < 1440
|
|
133
|
-
? Math.round(m / 60) + " h ago"
|
|
134
|
-
: Math.round(m / 1440) + " d ago";
|
|
135
|
-
};
|
|
136
|
-
// A searchable filter picker: the button opens it, typing narrows the rows (a group header
|
|
137
|
-
// stays while any of its rows does), Enter or a click picks.
|
|
138
|
-
function wirePick(id, set) {
|
|
139
|
-
const c = $(id);
|
|
140
|
-
if (!c) return;
|
|
141
|
-
const btn = c.querySelector("button.sel"),
|
|
142
|
-
pp = c.querySelector(".menu-pop"),
|
|
143
|
-
q = pp.querySelector("input"),
|
|
144
|
-
box = pp.querySelector(".pick-list");
|
|
145
|
-
const show = (on) => {
|
|
146
|
-
pp.hidden = !on;
|
|
147
|
-
btn.setAttribute("aria-expanded", on);
|
|
148
|
-
if (on) {
|
|
149
|
-
q.value = "";
|
|
150
|
-
narrow();
|
|
151
|
-
q.focus();
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
const narrow = () => {
|
|
155
|
-
const t = q.value.trim().toLowerCase();
|
|
156
|
-
let g = null,
|
|
157
|
-
any = false;
|
|
158
|
-
for (const el of box.children) {
|
|
159
|
-
if (el.classList.contains("grp")) {
|
|
160
|
-
if (g) g.hidden = !any;
|
|
161
|
-
g = el;
|
|
162
|
-
any = false;
|
|
163
|
-
} else {
|
|
164
|
-
const hit = !t || el.dataset.q.includes(t) || (g && g.dataset.g.includes(t));
|
|
165
|
-
el.hidden = !hit;
|
|
166
|
-
any ||= hit;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (g) g.hidden = !any;
|
|
170
|
-
};
|
|
171
|
-
btn.onclick = () => show(pp.hidden);
|
|
172
|
-
q.oninput = narrow;
|
|
173
|
-
q.onkeydown = (e) => {
|
|
174
|
-
if (e.key === "Escape") {
|
|
175
|
-
e.stopPropagation();
|
|
176
|
-
show(false);
|
|
177
|
-
btn.focus();
|
|
178
|
-
} else if (e.key === "Enter") {
|
|
179
|
-
e.preventDefault();
|
|
180
|
-
box.querySelector("button:not([hidden])")?.click();
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
box.onclick = (e) => {
|
|
184
|
-
const b = e.target.closest("button[data-v]");
|
|
185
|
-
if (!b) return;
|
|
186
|
-
show(false);
|
|
187
|
-
set(b.dataset.v);
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
export async function openSources() {
|
|
191
|
-
if (swHeld) {
|
|
192
|
-
swLate = true;
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (view !== "sources") return;
|
|
196
|
-
wireOnce();
|
|
197
|
-
const gen = ++store.pageGen;
|
|
198
|
-
// A dictation into the capture box keeps going: its field is carried over, not rebuilt.
|
|
199
|
-
stopDictation(!$("ice-cap"));
|
|
200
|
-
// What is half typed survives a refresh from the server.
|
|
201
|
-
const typed = srcOpen()
|
|
202
|
-
? [
|
|
203
|
-
$("src-url")?.value || "",
|
|
204
|
-
$("src-label")?.value || "",
|
|
205
|
-
document.activeElement?.id,
|
|
206
|
-
$("src-dir")?.value,
|
|
207
|
-
$("src-cat")?.value || "",
|
|
208
|
-
$("src-plat")?.value,
|
|
209
|
-
$("src-q")?.value || "",
|
|
210
|
-
]
|
|
211
|
-
: ["", ""];
|
|
212
|
-
// So does a project picked on a row but not yet moved.
|
|
213
|
-
const picked = new Map(
|
|
214
|
-
srcOpen() ? [...$("pbody").querySelectorAll("[data-mv]")].map((m) => [m.dataset.k, m.value]) : [],
|
|
215
|
-
);
|
|
216
|
-
// And a promote form half filled, for the item it was typed on.
|
|
217
|
-
// And which control of which inbox row had focus, by item key: row indices shift when a row goes.
|
|
218
|
-
const fRow = srcOpen() && document.activeElement?.closest?.(".ice-row,.ice-card"),
|
|
219
|
-
fPick = fRow ? [fRow.dataset.k, document.activeElement.id.replace(/-\d+$/, "")] : null;
|
|
220
|
-
// And a Snooze date half picked in an open menu.
|
|
221
|
-
const sdKeep = srcOpen() && $("ice-sd")?.value ? [iceMenu, $("ice-sd").value] : null;
|
|
222
|
-
const iceDraft =
|
|
223
|
-
srcOpen() && $("ice-title") ? [$("ice-title").dataset.k, $("ice-title").value, $("ice-details").value] : null;
|
|
224
|
-
// And a category typed on a row but not yet saved.
|
|
225
|
-
const cats = new Map(
|
|
226
|
-
srcOpen() ? [...$("pbody").querySelectorAll("[data-ct]")].map((m) => [m.dataset.k, m.value]) : [],
|
|
227
|
-
);
|
|
228
|
-
if (!srcOpen()) $("pbody").innerHTML = SKEL;
|
|
229
|
-
termStop();
|
|
230
|
-
store.openKey = null;
|
|
231
|
-
store.runDoc = null;
|
|
232
|
-
$("pterm").hidden = true;
|
|
233
|
-
$("panel").classList.add("open");
|
|
234
|
-
$("scrim").classList.add("on");
|
|
235
|
-
$("ptitle").textContent = SRC;
|
|
236
|
-
$("ptabs").innerHTML = "";
|
|
237
|
-
$("pfoot").innerHTML = "";
|
|
238
|
-
$("psub").textContent = "";
|
|
239
|
-
$("psub").title = "";
|
|
240
|
-
const dir = store.all ? null : store.S.dir,
|
|
241
|
-
q = dir ? "?dir=" + encodeURIComponent(dir) : "";
|
|
242
|
-
const d = await fetch("/sources" + q)
|
|
243
|
-
.then((r) => r.json())
|
|
244
|
-
.catch(() => null);
|
|
245
|
-
if (gen !== store.pageGen || !srcOpen()) return;
|
|
246
|
-
const host = (u) => {
|
|
247
|
-
try {
|
|
248
|
-
return new URL(u).hostname;
|
|
249
|
-
} catch {
|
|
250
|
-
return u;
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
// The favicon of the site a link is on, asked of that site itself (Google's own static host for
|
|
254
|
-
// Sheets and Docs, whose site icon is generic): nothing but the host reaches anyone. A social
|
|
255
|
-
// platform's mark is drawn here instead: Meta's favicons are same-origin only.
|
|
256
|
-
const fav = (u, fb, soc) => {
|
|
257
|
-
if (PLAT[soc]) return html`<span class="fav">${ico("b-" + soc)}</span>`;
|
|
258
|
-
let h;
|
|
259
|
-
try {
|
|
260
|
-
const x = new URL(u);
|
|
261
|
-
if (/^https?:$/.test(x.protocol)) h = x.origin;
|
|
262
|
-
} catch {}
|
|
263
|
-
const src = !h
|
|
264
|
-
? ""
|
|
265
|
-
: u.includes("docs.google.com/spreadsheets")
|
|
266
|
-
? "https://ssl.gstatic.com/docs/spreadsheets/favicon3.ico"
|
|
267
|
-
: u.includes("docs.google.com/document")
|
|
268
|
-
? "https://ssl.gstatic.com/docs/documents/images/kix-favicon7.ico"
|
|
269
|
-
: h + "/favicon.ico";
|
|
270
|
-
return html`<span class="fav">${src ? html`<img src="${src}" alt="" loading="lazy" referrerpolicy="no-referrer" onerror="this.remove()">` : ""}${ico(fb)}</span>`;
|
|
271
|
-
};
|
|
272
|
-
// What a source is called when nothing names it: its platform, else its site.
|
|
273
|
-
const platOf = (s) => PLAT[s?.social] || (s ? host(s.url).replace(/^www\./, "") : "") || "Other";
|
|
274
|
-
const srcType = (s) => {
|
|
275
|
-
if (s.social) return "social";
|
|
276
|
-
const u = s.url;
|
|
277
|
-
if (u.includes("docs.google.com/spreadsheets") || u.endsWith(".csv") || u.endsWith(".tsv")) return "sheet";
|
|
278
|
-
if (u.includes("docs.google.com/document")) return "doc";
|
|
279
|
-
return "link";
|
|
280
|
-
};
|
|
281
|
-
const list = (d && d.sources) || [],
|
|
282
|
-
// Dismissed items ride along, shown only under their own category. A snoozed item is
|
|
283
|
-
// left out of the list, the count and Swipe until its date (the server says `asleep`).
|
|
284
|
-
awake = ((d && d.icebox) || []).filter((it) => !it.asleep),
|
|
285
|
-
ice = [...awake, ...((d && d.dismissed) || [])],
|
|
286
|
-
waiting = awake.filter((it) => it.status === "new").length,
|
|
287
|
-
G = (d && d.gatherer) || {},
|
|
288
|
-
chatOn = G.use === "chatgpt" && G.connected;
|
|
289
|
-
// A source belongs to one project, named on its row. Picking another only arms Move: a select
|
|
290
|
-
// changes on every arrow key, and each change would have moved the source. The names are the picker's;
|
|
291
|
-
// a row whose project the picker does not list still gets its own, selected, so Move never points elsewhere.
|
|
292
|
-
const opts = (on, name) =>
|
|
293
|
-
html`${on && !store.S.projects.some((p) => p.dir === on) ? html`<option value="${on}" title="${name || on}" selected>${short(name || on)}</option>` : ""}${store.S.projects.map((p) => html`<option value="${p.dir}" title="${p.label}"${p.dir === on ? " selected" : ""}>${short(p.label)}</option>`)}`;
|
|
294
|
-
const cards = list
|
|
295
|
-
.map((s, i) => {
|
|
296
|
-
const st = srcType(s),
|
|
297
|
-
title = s.label || host(s.url);
|
|
298
|
-
// A social source is never read by kaizen, so its not-ok is the agent's turn, not a failure.
|
|
299
|
-
const statusHtml =
|
|
300
|
-
s.social && (!s.last || (!s.last.ok && /gathered by your agent/i.test(s.last.note)))
|
|
301
|
-
? html`<span class="src-badge dim">${ico("at")}${chatOn ? "Gathered with ChatGPT" : "Gathered by your agent"}</span>`
|
|
302
|
-
: !s.last
|
|
303
|
-
? html`<span class="src-badge dim">Not gathered yet</span>`
|
|
304
|
-
: s.last.ok
|
|
305
|
-
? html`<span class="src-badge ok"><svg viewBox="0 0 16 16"><path d="M3.5 8.5l3 3 6-6" stroke="currentColor" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>${s.last.note}</span><span class="hint" style="margin:0">${ago(s.last.at)}</span>`
|
|
306
|
-
: html`<span class="src-badge warn"><svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" stroke="currentColor" fill="none" stroke-width="1.8"/><path d="M8 5v3.5M8 11v.1" stroke="currentColor" fill="none" stroke-width="2" stroke-linecap="round"/></svg>Failed: ${s.last.note}</span><span class="hint" style="margin:0">${ago(s.last.at)}</span>`;
|
|
307
|
-
const kind = st === "sheet" ? "sheet" : st === "doc" ? "doc" : st === "social" ? "at" : "link",
|
|
308
|
-
bare = s.url.replace(/^https?:\/\/(www\.)?/, "");
|
|
309
|
-
return html`<div class="src-card" id="src-card-${i}"><div class="src-hd"><span class="src-ico" title="${st === "social" ? (PLAT[s.social] || "social") : st}">${fav(s.url, kind, s.social)}</span><div class="src-info"><span class="src-title" title="${title}">${title}</span><a class="src-url" href="${web(s.url)}" target="_blank" rel="noopener noreferrer" title="${s.url}"><span>${bare}</span>${ico("ext")}</a></div><div class="src-acts">${s.social ? html`<button class="ib sm" id="src-ag-${i}" data-ag="${i}" aria-label="Gather ${title} with your agent" title="${chatOn ? "Gather with your ChatGPT plan" : "Gather: opens your agent on /kaizen gather"}">${ico("refresh")}</button>` : html`<button class="ib sm" id="src-chk-${i}" data-chk="${i}" aria-label="Check ${title} now" title="Check now">${ico("refresh")}</button>`}<button class="ib sm danger" id="src-rm-${i}" data-rm="${i}" aria-label="Remove ${title}" title="Remove source">${ico("trash")}</button></div></div><div class="src-status">${statusHtml}</div><div class="src-fields"><label class="src-f" title="Category"><span>Category</span><input class="sel" id="src-ct-${i}" data-ct="${i}" data-k="${s.dir + " " + s.url}" value="${s.category || ""}" placeholder="${platOf(s)}" maxlength="40" aria-label="Category of ${title}"><button class="btn sm pri" id="src-cs-${i}" aria-label="Save the category of ${title}" disabled>Save</button></label><label class="src-f" title="Project"><span>Project</span>${plogo(s.dir, s.project || "")}<select class="sel" id="src-mv-${i}" data-mv="${i}" data-k="${s.dir + " " + s.url}" aria-label="Project of ${title}">${opts(s.dir, s.project)}</select><button class="btn sm pri" id="src-mb-${i}" aria-label="Move ${title} to the chosen project" disabled>Move</button></label></div><div class="src-sws">${st === "sheet" || /github\.com/.test(s.url) ? html`<label class="src-sw">Write back${toggleSwitch(!!s.writeback, { sm: true, attrs: { id: `src-wb-${i}`, "data-wb": String(i), "aria-label": `Write back to ${title}` } })}</label>` : ""}<label class="src-sw" title="Off: the scheduled gather skips this source; Check now still reads it">Auto gather${toggleSwitch(!s.paused, { sm: true, attrs: { id: `src-ag-on-${i}`, "data-ag-on": String(i), "aria-label": `Auto gather ${title}` } })}</label></div></div>`;
|
|
310
|
-
});
|
|
311
|
-
const fails = ((d && d.failed) || []).map((f) => html`<p style="color:var(--dim)">The sources of ${f} could not be read.</p>`);
|
|
312
|
-
const emptyState = html`<div class="src-empty"><div class="src-empty-ico">${ico("link")}</div><h4>No sources yet</h4></div>`;
|
|
313
|
-
const social = srcKind === "social";
|
|
314
|
-
const addOn = !list.length || srcAdd || [typed[0], typed[1], typed[4], typed[6]].some(Boolean);
|
|
315
|
-
const addBox = html`<div class="src-add" id="src-addbox"${addOn ? "" : " hidden"}><div class="hd"><h4>Add a source</h4><div class="src-kind" role="group" aria-label="Kind of source"><button id="src-k-link" data-kind="link" aria-pressed="${String(!social)}">Link</button><button id="src-k-social" data-kind="social" aria-pressed="${String(social)}">Social</button></div></div><label for="src-url"${social ? " hidden" : ""}><span>Link</span><input class="sel" id="src-url" placeholder="Link" spellcheck="false" autocomplete="off"></label><div class="two plat"${social ? "" : " hidden"}><label for="src-plat"><span>Platform</span><select class="sel" id="src-plat">${Object.entries(
|
|
316
|
-
PLAT,
|
|
317
|
-
)
|
|
318
|
-
.map(([k, v]) => html`<option value="${k}">${v}</option>`)}</select></label><label for="src-q"><span>Follow</span><input class="sel" id="src-q" placeholder="keyword, #hashtag or @account" maxlength="100" spellcheck="false" autocomplete="off"></label></div><div class="two"><label for="src-label"><span>Label <i>optional</i></span><input class="sel" id="src-label" placeholder="${social ? "e.g. Mentions on X" : "e.g. Feedback Q4"}"></label><label for="src-cat"><span>Category <i>optional</i></span><input class="sel" id="src-cat" placeholder="${social ? "e.g. Social" : "e.g. Bugs"}" maxlength="40"></label></div><label for="src-dir"><span>Project</span><select class="sel" id="src-dir">${dir ? "" : html`<option value="">Choose project…</option>`}${opts(dir)}</select></label><div class="acts"><span class="end"></span><button class="btn pri" id="src-add">Add source</button></div></div>`;
|
|
319
|
-
// The inbox: one row per request, by project when showing all, then by category,
|
|
320
|
-
// narrowed to one source by its chip. Checked, open and cursor items are kept by key.
|
|
321
|
-
const srcName = (it) => {
|
|
322
|
-
const s = list.find((x) => x.dir === it.dir && x.url === it.source);
|
|
323
|
-
return s ? s.label || host(s.url) : host(it.source);
|
|
324
|
-
};
|
|
325
|
-
const iceKey = (it) => it.dir + " " + it.id,
|
|
326
|
-
srcKey = (it) => it.dir + " " + it.source;
|
|
327
|
-
// Filters narrow in turn: project (the board's own picker, all projects only), then
|
|
328
|
-
// category, then source; each chip counts what the filters before it leave.
|
|
329
|
-
// An item with no category of its own takes its source's, else the source's platform or site.
|
|
330
|
-
const srcOf = (it) => list.find((x) => x.dir === it.dir && x.url === it.source),
|
|
331
|
-
catOf = (it) =>
|
|
332
|
-
it.status === "dismissed"
|
|
333
|
-
? "Dismissed"
|
|
334
|
-
: it.status === "done"
|
|
335
|
-
? "Done"
|
|
336
|
-
: it.status === "promoted"
|
|
337
|
-
? "Promoted"
|
|
338
|
-
: it.category || srcOf(it)?.category || platOf(srcOf(it) || { url: it.source }),
|
|
339
|
-
count = (xs, f) => {
|
|
340
|
-
const m = new Map();
|
|
341
|
-
xs.forEach((it) => {
|
|
342
|
-
const k = f(it);
|
|
343
|
-
m.set(k, { it, n: (m.get(k)?.n || 0) + 1 });
|
|
344
|
-
});
|
|
345
|
-
return m;
|
|
346
|
-
};
|
|
347
|
-
const byProj = dir ? new Map() : count(ice, (it) => it.dir);
|
|
348
|
-
if (!dir)
|
|
349
|
-
for (const pd of store.shown)
|
|
350
|
-
if (!byProj.has(pd)) {
|
|
351
|
-
const p = showable().find((x) => x.dir === pd);
|
|
352
|
-
if (p) byProj.set(pd, { it: { dir: pd, project: p.label }, n: 0 });
|
|
353
|
-
}
|
|
354
|
-
const inProj = (it) => dir || !store.shown.size || store.shown.has(it.dir),
|
|
355
|
-
pv = ice.filter(inProj);
|
|
356
|
-
const isWaiting = (it) => !["promoted", "dismissed", "done"].includes(it.status);
|
|
357
|
-
// Boards, then kinds, narrow before category and source. A board is its name: two projects'
|
|
358
|
-
// boards of one name are one chip in All projects.
|
|
359
|
-
const boards = [...new Map(((d && d.boards) || []).filter(inProj).map((b) => [b.name.toLowerCase(), b])).values()];
|
|
360
|
-
if (iceBoard && !boards.some((b) => sameName(b.name, iceBoard))) iceBoard = "";
|
|
361
|
-
const onBoard = (it) => !iceBoard || sameName(it.board, iceBoard),
|
|
362
|
-
ofKind = (it) => !iceKinds.size || iceKinds.has(it.kind);
|
|
363
|
-
const byCat = count(pv.filter((it) => onBoard(it) && ofKind(it)), catOf);
|
|
364
|
-
if (iceCat && !byCat.has(iceCat)) iceCat = "";
|
|
365
|
-
const cv = pv.filter((it) => onBoard(it) && ofKind(it) && (!iceCat || catOf(it) === iceCat));
|
|
366
|
-
const bySrc = count(cv, srcKey);
|
|
367
|
-
if (iceSrc && !bySrc.has(iceSrc)) iceSrc = "";
|
|
368
|
-
const keys = new Set(ice.map(iceKey));
|
|
369
|
-
if (iceForm && !keys.has(iceForm)) iceForm = null;
|
|
370
|
-
if (icePro !== iceForm) icePro = null;
|
|
371
|
-
// Newest first, in the order they are drawn, which is the order j and k walk. Category is a filter.
|
|
372
|
-
const filtered = ice
|
|
373
|
-
.map((_, i) => i)
|
|
374
|
-
.filter((i) => {
|
|
375
|
-
const it = ice[i];
|
|
376
|
-
return inProj(it) && onBoard(it) && ofKind(it) && (iceCat ? catOf(it) === iceCat : it.status === "new") && (!iceSrc || srcKey(it) === iceSrc);
|
|
377
|
-
})
|
|
378
|
-
.sort((a, b) => (Date.parse(ice[b].at) || 0) - (Date.parse(ice[a].at) || 0));
|
|
379
|
-
// Only the page: j and k, select-all and bulk actions stay on what shows.
|
|
380
|
-
const order = pageOf(icePg, filtered);
|
|
381
|
-
// A checked request a filter hides is unchecked: a bulk action only ever acts on what shows.
|
|
382
|
-
{
|
|
383
|
-
const vis = new Set(order.map((i) => iceKey(ice[i])));
|
|
384
|
-
[...iceSel].forEach((k) => vis.has(k) || iceSel.delete(k));
|
|
385
|
-
}
|
|
386
|
-
if (!order.some((i) => iceKey(ice[i]) === iceCur)) iceCur = order.length ? iceKey(ice[order[0]]) : null;
|
|
387
|
-
const nSel = order.filter((i) => iceSel.has(iceKey(ice[i]))).length;
|
|
388
|
-
// Filters are plain dropdowns, each shown only when it has a choice to make. Projects are
|
|
389
|
-
// narrowed by the board's own Showing picker above, not here.
|
|
390
|
-
const many = byProj.size > 1;
|
|
391
|
-
// Filters are searchable pickers (the header's combo): a button, then a search over the list.
|
|
392
|
-
const pick = (id, label, cur, rows) =>
|
|
393
|
-
html`<div class="combo ice-combo" id="${id}"><button class="sel" aria-label="${label}" aria-haspopup="listbox" aria-expanded="false">${cur}</button><div class="menu-pop" hidden><input class="sel" aria-label="Search ${label.toLowerCase()}" placeholder="Search…" spellcheck="false" autocomplete="off"><div class="pick-list" role="listbox">${rows}</div></div></div>`;
|
|
394
|
-
const opt = (v, on, inner, q, cls = "") =>
|
|
395
|
-
html`<button type="button" role="option" data-v="${v}" data-q="${q.toLowerCase()}" class="${on ? "on" : ""}${cls}" aria-selected="${String(on)}">${inner}</button>`;
|
|
396
|
-
// Sources group by platform: two Threads searches sit under one Threads.
|
|
397
|
-
const srcGroups = new Map();
|
|
398
|
-
for (const [k, { it }] of bySrc) {
|
|
399
|
-
const g = platOf(srcOf(it) || { url: it.source });
|
|
400
|
-
srcGroups.has(g) || srcGroups.set(g, []);
|
|
401
|
-
srcGroups.get(g).push([k, it]);
|
|
402
|
-
}
|
|
403
|
-
const srcIco = (it) => fav(it.source, "link", srcOf(it)?.social);
|
|
404
|
-
const curSrc = iceSrc && [...bySrc].find(([k]) => k === iceSrc)?.[1].it;
|
|
405
|
-
const chips = html`${
|
|
406
|
-
// Promoted, Dismissed and Done are hidden until picked, so even a lone one is a choice.
|
|
407
|
-
byCat.size > 1 || byCat.has("Dismissed") || byCat.has("Done") || byCat.has("Promoted")
|
|
408
|
-
? pick(
|
|
409
|
-
"ice-fc",
|
|
410
|
-
"Category",
|
|
411
|
-
html`<span>${iceCat || "All categories"}</span>`,
|
|
412
|
-
html`${opt("", !iceCat, html`<span>All categories</span>`, "all categories")}${[...byCat].map(([k, { n }]) => opt(k, iceCat === k, html`<span>${k}</span><i>${n}</i>`, k))}`,
|
|
413
|
-
)
|
|
414
|
-
: ""}${
|
|
415
|
-
bySrc.size > 1
|
|
416
|
-
? pick(
|
|
417
|
-
"ice-fs",
|
|
418
|
-
"Source",
|
|
419
|
-
curSrc ? html`${srcIco(curSrc)}<span>${srcName(curSrc)}</span>` : html`<span>All sources</span>`,
|
|
420
|
-
html`${opt("", !iceSrc, html`<span>All sources</span>`, "all sources")}${[...srcGroups].map(
|
|
421
|
-
([g, xs]) =>
|
|
422
|
-
html`<div class="grp" data-g="${g.toLowerCase()}">${srcIco(xs[0][1])}${g}</div>${xs.map(([k, it]) => opt(k, iceSrc === k, html`${srcIco(it)}<span>${srcName(it).toLowerCase().startsWith(g.toLowerCase() + ":") ? srcName(it).slice(g.length + 1).trim() : srcName(it)}</span><i>${bySrc.get(k).n}</i>`, g + " " + srcName(it), " sub"))}`,
|
|
423
|
-
)}`,
|
|
424
|
-
)
|
|
425
|
-
: ""}`;
|
|
426
|
-
// Under 640 px there are no cards: the list shows, and the switch goes.
|
|
427
|
-
const narrow = narrowQ.matches,
|
|
428
|
-
cardsOn = iceView === "cards" && !narrow;
|
|
429
|
-
// The boards bar: All, each board with what waits on it, + Board; the kind filters on the right.
|
|
430
|
-
const nOn = (b) => pv.filter((it) => isWaiting(it) && sameName(it.board, b.name)).length;
|
|
431
|
-
const boardsBar = html`<div class="ice-boards"><div class="ice-chips" role="group" aria-label="Collections"><button class="ice-chip${iceBoard ? "" : " on"}" data-bd="" aria-pressed="${String(!iceBoard)}">All</button>${boards.map((b) => html`<button class="ice-chip${sameName(iceBoard, b.name) ? " on" : ""}" data-bd="${b.name}" aria-pressed="${String(sameName(iceBoard, b.name))}"${b.client ? raw(' title="A client\'s collection: its items are Client"') : ""}>${b.client ? PERSON : ""}<span>${b.name}</span><i>${nOn(b)}</i></button>`)}<button class="ice-chip add" id="ice-nb" title="Make a collection for a client or a topic">${ico("plus")}Collection</button></div><div class="ice-chips" role="group" aria-label="Kinds">${Object.entries(KIND).map(([k, l]) => html`<button class="ice-chip k-${k}${iceKinds.has(k) ? " on" : ""}" data-kf="${k}" aria-pressed="${String(iceKinds.has(k))}">${l}</button>`)}</div></div>`;
|
|
432
|
-
const bar = html`<div class="tk-bar ice-bar">${!cardsOn && !narrow && order.length ? html`<input type="checkbox" id="ice-all" aria-label="Select every request shown"${nSel && nSel === order.length ? " checked" : ""}>` : ""}${narrow ? "" : html`<div class="ice-view" role="group" aria-label="View"><button data-view="cards" aria-pressed="${String(cardsOn)}">Cards</button><button data-view="sort" aria-pressed="${String(!cardsOn)}">Sort</button></div>`}<span class="count">${iceCat === "Dismissed" || iceCat === "Done" || iceCat === "Promoted" ? `${order.length} ${iceCat.toLowerCase()}` : `${order.length < waiting ? `${order.length} of ${waiting}` : waiting} waiting`}</span><span class="end"></span>${String(chips) ? html`<details class="ice-filt"><summary class="ib${iceCat || iceSrc ? " on" : ""}" aria-label="Filter requests" title="Filter by category or source">${ico("filter")}</summary><div class="ice-fpop">${chips}</div></details>` : ""}${order.some((i) => isWaiting(ice[i])) ? html`<button class="btn ghost sm" id="ice-sw" title="Sort one at a time: swipe right to promote, left to dismiss"><span aria-hidden="true">⇆</span> Swipe</button>` : ""}${narrow ? "" : html`<button class="btn sm" id="src-tog" aria-expanded="${String(!!srcShow)}" aria-controls="src-sec" title="Sources, and Gather all">${ico("link")} Sources · ${list.length}</button>`}</div>`;
|
|
433
|
-
// The capture box: what is typed, pasted, attached or dictated lands in the icebox on the picked
|
|
434
|
-
// board. In All projects it names the project, as the Add pop-up did. Field and mic are slotted in.
|
|
435
|
-
const capPs = dir ? [] : showable();
|
|
436
|
-
if (!dir && !capPs.some((p) => p.dir === cap.dir))
|
|
437
|
-
cap.dir = (store.shown.size === 1 ? [...store.shown][0] : null) || capPs[0]?.dir || null;
|
|
438
|
-
const capTo0 = dir || cap.dir;
|
|
439
|
-
// A board picked for another project never goes along when the box's project changes.
|
|
440
|
-
if (cap.board && cap.boardDir && cap.boardDir !== capTo0) cap.board = "";
|
|
441
|
-
const capTo = capTo0,
|
|
442
|
-
capP = capPs.find((p) => p.dir === cap.dir);
|
|
443
|
-
const capBoards = ((d && d.boards) || []).filter((b) => b.dir === capTo);
|
|
444
|
-
const capBox = html`<div class="ice-cap" id="ice-cap"><span id="ice-cap-slot"></span>${cap.files.length ? html`<div class="ice-att">${cap.files.map((f, n) => html`<span class="ice-file">${ico("clip")}<span>${f.name}</span><button type="button" class="ib sm" data-rf="${n}" aria-label="Remove ${f.name}" title="Remove">${ico("x")}</button></span>`)}</div>` : ""}<div class="ice-cap-row"><button type="button" class="ib" id="ice-pick" aria-label="Attach files" title="Attach files">${ico("clip")}</button><span id="ice-mic-slot"></span><input type="file" id="ice-file" multiple hidden>${dir ? "" : pick("ice-cp", "Project", capP ? html`${plogo(capP.dir, capP.label)}<span>${short(capP.label)}</span>` : html`<span>Choose project</span>`, html`${capPs.map((p) => opt(p.dir, p.dir === cap.dir, html`${plogo(p.dir, p.label)}<span>${p.label}</span>`, p.label))}`)}${pick("ice-cb", "Collection", html`<span>${cap.board || "Inbox"}</span>`, html`${opt("", !cap.board, html`<span>Inbox</span>`, "inbox")}${capBoards.map((b) => opt(b.name, sameName(cap.board, b.name), html`${b.client ? PERSON : ""}<span>${b.name}</span>`, b.name))}${cap.board && !capBoards.some((b) => sameName(b.name, cap.board)) ? opt(cap.board, true, html`<span>${cap.board}</span><i>new</i>`, cap.board) : ""}${opt("\n", false, html`${ico("plus")}<span>New collection…</span>`, "new collection")}`)}<span class="end"></span><button type="button" class="btn pri sm" id="ice-save" aria-label="Save to the icebox"${cap.busy ? " disabled" : ""}>${ico("send")}<span>${cap.busy ? "Saving…" : "Save ↵"}</span></button></div></div>`;
|
|
445
|
-
const bulk = iceSel.size
|
|
446
|
-
? html`<div class="ice-bulk" role="toolbar" aria-label="Selected requests"><span>${iceSel.size} selected</span><span class="end"></span><button class="btn sm" id="ice-bp" title="Promote (p)">${ico("plus")} Promote</button><button class="btn ghost sm" id="ice-bz" title="Snooze a week (h)">${ico("clock")} Snooze</button><button class="btn ghost sm" id="ice-bd" title="Dismiss (d)">${ico("x")} Dismiss</button><button class="btn ghost sm" id="ice-bc" title="Clear selection (Esc)">Clear</button></div>`
|
|
447
|
-
: "";
|
|
448
|
-
// The open item's form: a clean title for the task's card and the person's own details;
|
|
449
|
-
// what was gathered is added to the task's notes by the server.
|
|
450
|
-
const form = (it) => {
|
|
451
|
-
const t = iceTask && iceTask.k === iceKey(it) ? iceTask : null,
|
|
452
|
-
say = t?.wait ? "Drafting a task with ChatGPT…" : t?.kept ? "ChatGPT's draft came after you started typing, so your words stay. Redraft to use it." : t?.note ? `No draft: ${t.note}` : t?.title ? "Drafted by ChatGPT. Edit it before promoting." : "";
|
|
453
|
-
return html`<div class="ice-form"><label for="ice-title" class="hint" style="margin:0">Task title</label><input class="sel" id="ice-title" data-k="${iceKey(it)}" maxlength="200" value="${t?.title || it.text}" aria-label="Task title"><label for="ice-details" class="hint" style="margin:0">Details</label><textarea class="sel" id="ice-details" rows="${t?.details ? 5 : 3}" aria-label="Details">${t?.details || ""}</textarea>${say ? html`<span class="hint ice-tdraft" id="ice-tdn" role="status" style="margin:0">${say}</span>` : ""}<div class="ice-form-acts">${G.connected ? html`<button class="btn ghost sm" id="ice-td"${t?.wait ? " disabled" : ""} title="Ask ChatGPT for another draft">${ico("ai")}${t?.title ? "Redraft" : "Draft with ChatGPT"}</button>` : ""}<span class="end"></span><button class="btn ghost sm" id="ice-cancel">Cancel</button><button class="btn pri sm" id="ice-ok">Promote</button></div></div>`;
|
|
454
|
-
};
|
|
455
|
-
// A gathered post can be answered: Reply drafts, the box is the approval, Send reply posts that text.
|
|
456
|
-
const replyBox = (it) => {
|
|
457
|
-
if (!it.post) return "";
|
|
458
|
-
if (it.replied) return html`<span class="hint" style="margin:0">You replied to this post ${ago(it.replied)}.</span>`;
|
|
459
|
-
const r = iceReply && iceReply.k === iceKey(it) ? iceReply : null;
|
|
460
|
-
const style = (d) =>
|
|
461
|
-
html`<select class="sel" id="ice-rst" aria-label="Reply style"${d ? " disabled" : ""}>${Object.entries(
|
|
462
|
-
STYLES,
|
|
463
|
-
)
|
|
464
|
-
.map(([v, l]) => html`<option value="${v}"${v === rStyle(it.dir) ? " selected" : ""}>${l}</option>`)}</select>`;
|
|
465
|
-
if (!r)
|
|
466
|
-
return html`<div class="ice-form-acts"><span class="hint">You review it before it posts.</span>${G.connected ? style(false) : ""}<button class="btn sm" id="ice-rp">Reply</button></div>`;
|
|
467
|
-
if (r.wait) return html`<div class="ice-form-acts"><span class="hint">Drafting…</span></div>`;
|
|
468
|
-
return html`<div class="ice-form"><label for="ice-reply" class="hint" style="margin:0">Your reply${r.note ? ` · ${r.note}` : ""}</label><textarea class="sel" id="ice-reply" rows="3" maxlength="2000" aria-label="Your reply"${r.busy || r.again ? " disabled" : ""}>${r.text}</textarea><span class="hint" id="ice-rn" style="margin:0">${r.again ? "Writing another…" : `${r.text.length} chars`}</span><div class="ice-form-acts"><span class="end"></span>${G.connected ? html`${style(r.busy || r.again)}<button class="btn ghost sm" id="ice-rg"${r.busy || r.again ? " disabled" : ""}>Regenerate</button>` : ""}<button class="btn ghost sm" id="ice-rc"${r.busy ? " disabled" : ""}>Cancel</button><button class="btn pri sm" id="ice-rs"${r.busy || r.again || !r.text.trim() ? " disabled" : ""}>${r.busy ? "Sending…" : "Send reply"}</button></div></div>`;
|
|
469
|
-
};
|
|
470
|
-
const imgs = (it, card = false) =>
|
|
471
|
-
(it.images || []).filter((u) => /^https:\/\//.test(u)).length ? html`<details class="ice-imgs"><summary${card ? raw(' title="Loads them from the source\'s site"') : ""}>${card ? `${it.images.filter((u) => /^https:\/\//.test(u)).length} pictures · show` : `Show images (${it.images.filter((u) => /^https:\/\//.test(u)).length}) — loads them from the source's site`}</summary>${it.images.filter((u) => /^https:\/\//.test(u)).map((u, n) => { const src = `/ice-image?dir=${encodeURIComponent(it.dir)}&id=${encodeURIComponent(it.id)}&i=${n}`; return html`<a href="${src}" target="_blank" rel="noopener noreferrer"><img data-src="${src}" alt="" referrerpolicy="no-referrer"></a>`; })}</details>` : "";
|
|
472
|
-
// The pieces rows and cards share. Only a waiting item has menus; Snooze needs one too.
|
|
473
|
-
const live = (it) => it.status === "new";
|
|
474
|
-
const kindOf = (it) => html`<span class="ice-k k-${it.kind || "none"}">${KIND[it.kind] || "Unsorted"}</span>`;
|
|
475
|
-
const menuBtn = (i, it, m, inner, cls, label) =>
|
|
476
|
-
html`<button type="button" class="${cls}" id="ice-m${m[0]}-${i}" data-m="${m}" data-mi="${i}" aria-haspopup="menu" aria-expanded="${String(iceMenu === iceKey(it) + " " + m)}" title="${label}" aria-label="${label}: ${it.text}">${inner}</button>`;
|
|
477
|
-
// The open item menu, drawn inside its row or card: Snooze, Kind or Board.
|
|
478
|
-
const menu = (i, it) => {
|
|
479
|
-
const k = iceKey(it),
|
|
480
|
-
m = iceMenu.startsWith(k + " ") ? iceMenu.slice(k.length + 1) : "";
|
|
481
|
-
if (!m) return "";
|
|
482
|
-
const b = (attr, v, label, on = false) => html`<button type="button" role="menuitem" ${raw(attr)}="${v}"${on ? raw(' class="on" aria-current="true"') : ""}>${label}</button>`;
|
|
483
|
-
const day = (n) => ymd(new Date(Date.now() + n * 864e5));
|
|
484
|
-
const inner =
|
|
485
|
-
m === "snooze"
|
|
486
|
-
? html`${b("data-sz", "1d", "Tomorrow")}${b("data-sz", "1w", "Next week")}${b("data-sz", "1m", "Next month")}<div class="ice-date"><input type="date" class="sel" id="ice-sd" min="${day(1)}" max="${day(365)}" aria-label="Snooze until"><button type="button" class="btn sm" data-sz="">Snooze</button></div>`
|
|
487
|
-
: m === "kind"
|
|
488
|
-
? html`${Object.entries(KIND).map(([v, l]) => b("data-kd", v, l, it.kind === v && it.sorted !== "rules"))}`
|
|
489
|
-
: html`${b("data-bo", "", "Inbox", !it.board)}${((d && d.boards) || []).filter((x) => x.dir === it.dir).map((x) => b("data-bo", x.name, html`${x.client ? PERSON : ""}${x.name}`, sameName(it.board, x.name)))}<button type="button" role="menuitem" data-bo-new="1">${ico("plus")}New collection…</button>`;
|
|
490
|
-
return html`<div class="menu-pop ice-mpop" role="menu" data-mi="${i}" aria-label="${m === "snooze" ? "Snooze until" : m === "kind" ? "Kind" : "Collection"}">${inner}</div>`;
|
|
491
|
-
};
|
|
492
|
-
const badges = (it) =>
|
|
493
|
-
html`${it.status === "done" && it.written ? html`<span title="Written back ${ago(it.written)}">written back</span>` : ""}${it.status === "done" && it.writeError ? html`<span title="${it.writeError}">write-back failed</span>` : ""}${it.status === "promoted" ? html`<span title="Promoted to Tasks: ${it.idea || ""}">promoted</span>` : ""}${it.replied ? html`<span title="Replied ${ago(it.replied)}">replied</span>` : ""}`;
|
|
494
|
-
const proj = (it) => (many ? html`<span class="nm" title="${it.project || ""}">${plogo(it.dir, it.project || "")}${short(it.project || "")}</span>` : "");
|
|
495
|
-
const row = (i) => {
|
|
496
|
-
const it = ice[i],
|
|
497
|
-
k = iceKey(it),
|
|
498
|
-
open = iceForm === k;
|
|
499
|
-
const head = html`<div class="ice-row${iceCur === k ? " cur" : ""}${iceSel.has(k) ? " sel" : ""}" data-i="${i}" data-k="${k}"><input type="checkbox" id="ice-ck-${i}" data-ck="${i}"${iceSel.has(k) ? " checked" : ""} aria-label="Select: ${it.text}">${live(it) ? menuBtn(i, it, "kind", kindOf(it), "ice-kb", "Kind") : kindOf(it)}<span class="ice-src" title="${srcName(it)}">${fav(it.source, "link", srcOf(it)?.social)}</span><button class="ice-t" id="ice-o-${i}" data-o="${i}" aria-expanded="${String(open)}" title="${it.text}">${it.text}</button><span class="ice-meta">${proj(it)}${badges(it)}${live(it) ? menuBtn(i, it, "board", it.board || "Inbox", "ice-bo" + (it.board ? "" : " none"), "Collection") : it.board ? html`<span>${it.board}</span>` : ""}<span class="ice-age">${ago(it.at)}</span><span class="ice-ra">${it.status === "promoted" || it.status === "done" ? "" : html`<button class="btn ghost sm" id="ice-pr-${i}" data-pr="${i}" title="Promote to Tasks (p)" aria-label="Promote to Tasks: ${it.text}">${ico("plus")}</button>`}${live(it) ? menuBtn(i, it, "snooze", ico("clock"), "btn ghost sm", "Snooze (h: a week)") : ""}${it.status === "promoted" || it.status === "done" ? "" : it.status === "dismissed" ? html`<button class="btn ghost sm" id="ice-rs-${i}" data-rs="${i}" title="Restore to waiting" aria-label="Restore: ${it.text}">Restore</button>` : html`<button class="btn ghost sm" id="ice-ds-${i}" data-ds="${i}" title="Dismiss (d)" aria-label="Dismiss: ${it.text}">${ico("x")}</button>`}</span></span>${menu(i, it)}</div>`;
|
|
500
|
-
const more = open
|
|
501
|
-
? html`<div class="ice-open">${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${imgs(it)}<span class="hint" style="margin:0">From ${srcName(it)} · ${ago(it.at)}${it.post ? html` · <a href="${web(it.post)}" target="_blank" rel="noopener">open post</a>` : ""}</span>${replyBox(it)}${icePro === k ? form(it) : ""}</div>`
|
|
502
|
-
: "";
|
|
503
|
-
return html`${head}${more}`;
|
|
504
|
-
};
|
|
505
|
-
const hue = (t) => [...t].reduce((a, c) => (a * 31 + c.charCodeAt(0)) % 360, 7);
|
|
506
|
-
// A phone row (under 640 px): kind, two lines, board and age, a thumbnail for a link (its
|
|
507
|
-
// site's hue and letter) or pictures (an icon and the count: nothing is fetched from their
|
|
508
|
-
// site), → Task. A swipe decides it: right a task, left dismissed; a long press snoozes.
|
|
509
|
-
const thumb = (it) => {
|
|
510
|
-
const lk = it.link && /^https?:\/\//i.test(it.link.url) ? it.link : null,
|
|
511
|
-
n = (it.images || []).filter((u) => /^https:\/\//.test(u)).length;
|
|
512
|
-
if (lk) {
|
|
513
|
-
const site = host(lk.url).replace(/^www\./, "");
|
|
514
|
-
return html`<span class="ice-th" style="--h:${hue(site)}" title="${lk.title || site}" aria-hidden="true">${(site[0] || "").toUpperCase()}</span>`;
|
|
515
|
-
}
|
|
516
|
-
return n ? html`<span class="ice-th pic" title="${n} pictures" aria-hidden="true">${ico("img")}<i>${n}</i></span>` : "";
|
|
517
|
-
};
|
|
518
|
-
const prow = (i) => {
|
|
519
|
-
const it = ice[i],
|
|
520
|
-
k = iceKey(it),
|
|
521
|
-
open = iceForm === k,
|
|
522
|
-
done = it.status === "promoted" || it.status === "done";
|
|
523
|
-
const head = html`<div class="ice-row ice-prow${iceCur === k ? " cur" : ""}" data-i="${i}" data-k="${k}"${live(it) ? raw(' data-swipe="1"') : ""}><div class="ice-pbg" aria-hidden="true"><span class="pro">${ico("check")}Task</span><span class="dis">Dismiss${ico("x")}</span></div><div class="ice-pf"><div class="ice-pm"><div class="ice-ph">${live(it) ? menuBtn(i, it, "kind", kindOf(it), "ice-kb", "Kind") : kindOf(it)}${it.sorted === "rules" && live(it) ? html`<span class="ice-uns">unsorted</span>` : ""}<span class="ice-meta">${badges(it)}</span></div><button class="ice-t" id="ice-o-${i}" data-o="${i}" aria-expanded="${String(open)}">${it.text}</button><span class="ice-pmeta">${proj(it)}${it.board ? html`<span>${it.board}</span>` : ""}<span>${ago(it.at)}</span></span></div>${thumb(it)}${done ? "" : it.status === "dismissed" ? html`<button class="btn ghost sm" id="ice-rs-${i}" data-rs="${i}" aria-label="Restore: ${it.text}">Restore</button>` : html`<button class="ib ice-ptask" id="ice-pr-${i}" data-pr="${i}" aria-label="Make a task: ${it.text}" title="Make a task">${ico("arrow")}</button>`}</div>${menu(i, it)}</div>`;
|
|
524
|
-
// Opened, a phone row also offers what its gestures do, for anyone who cannot swipe or hold.
|
|
525
|
-
const acts = live(it)
|
|
526
|
-
? html`<div class="ice-form-acts ice-pacts">${menuBtn(i, it, "snooze", html`${ico("clock")}Snooze`, "btn ghost sm", "Snooze")}${menuBtn(i, it, "board", html`${it.board || "Inbox"}`, "btn ghost sm", "Collection")}<span class="end"></span><button class="btn ghost sm" id="ice-ds-${i}" data-ds="${i}" aria-label="Dismiss: ${it.text}">${ico("x")}Dismiss</button></div>`
|
|
527
|
-
: "";
|
|
528
|
-
const more = open
|
|
529
|
-
? html`<div class="ice-open">${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${imgs(it)}<span class="hint" style="margin:0">From ${srcName(it)} · ${ago(it.at)}${it.post ? html` · <a href="${web(it.post)}" target="_blank" rel="noopener">open post</a>` : ""}</span>${acts}${replyBox(it)}${icePro === k ? form(it) : ""}</div>`
|
|
530
|
-
: "";
|
|
531
|
-
return html`${head}${more}`;
|
|
532
|
-
};
|
|
533
|
-
// A card: what it is, the words, where it sits, how old. A link leads with its title and summary,
|
|
534
|
-
// coloured from the site's name; nothing is fetched from the site to draw it.
|
|
535
|
-
const cardOf = (i) => {
|
|
536
|
-
const it = ice[i],
|
|
537
|
-
k = iceKey(it),
|
|
538
|
-
lk = it.link && /^https?:\/\//i.test(it.link.url) ? it.link : null,
|
|
539
|
-
site = lk ? host(lk.url).replace(/^www\./, "") : "";
|
|
540
|
-
const acts = html`${it.status === "promoted" || it.status === "done" ? "" : html`<button class="btn ghost sm" id="ice-pr-${i}" data-pr="${i}" title="Promote to Tasks (p)" aria-label="Promote to Tasks: ${it.text}">${ico("arrow")}Task</button>`}${live(it) ? html`${menuBtn(i, it, "snooze", html`${ico("clock")}Snooze`, "btn ghost sm", "Snooze")}${menuBtn(i, it, "kind", "Kind", "btn ghost sm", "Kind")}${menuBtn(i, it, "board", "Collection", "btn ghost sm", "Collection")}` : ""}<span class="end"></span>${it.status === "promoted" || it.status === "done" ? "" : it.status === "dismissed" ? html`<button class="btn ghost sm" id="ice-rs-${i}" data-rs="${i}" title="Restore to waiting" aria-label="Restore: ${it.text}">Restore</button>` : html`<button class="btn ghost sm" id="ice-ds-${i}" data-ds="${i}" title="Dismiss (d)" aria-label="Dismiss: ${it.text}">${ico("x")}</button>`}`;
|
|
541
|
-
return html`<article class="ice-card${iceCur === k ? " cur" : ""}" data-i="${i}" data-k="${k}">${lk ? html`<a class="ice-lk" href="${web(lk.url)}" target="_blank" rel="noopener noreferrer" style="--h:${hue(site)}"><b>${lk.title || site}</b>${lk.summary ? html`<span>${lk.summary}</span>` : ""}<small>${site}</small></a>` : ""}<div class="ice-cb"><div class="ice-ch">${kindOf(it)}${it.sorted === "rules" && live(it) ? html`<span class="ice-uns" title="Kind set by a rule: pick one with Kind">unsorted</span>` : ""}<span class="ice-meta">${badges(it)}</span></div><button class="ice-ct" id="ice-o-${i}" data-o="${i}" title="Open in the Sort list">${it.text}</button>${imgs(it, true)}<div class="ice-cf">${it.board ? html`<span class="ice-cbd">${it.board}</span>` : ""}${(it.tags || []).map((t) => html`<span class="ice-tag">#${t}</span>`)}${proj(it)}<span class="end"></span><span class="ice-when">${it.source !== "manual" ? `${srcName(it)} · ` : ""}${ago(it.at)}</span></div></div><div class="ice-ca">${acts}</div>${menu(i, it)}</article>`;
|
|
542
|
-
};
|
|
543
|
-
const inbox =
|
|
544
|
-
waiting && !order.length
|
|
545
|
-
? html`<div class="ice-zero"><h4>No matches</h4><p style="margin-top:10px"><button class="btn sm" id="ice-unf">Clear filters</button></p></div>`
|
|
546
|
-
: order.length
|
|
547
|
-
? cardsOn
|
|
548
|
-
? html`<div class="ice-cards">${order.map(cardOf)}</div><div class="ice-cpg">${pagerHtml(icePg)}</div>`
|
|
549
|
-
: html`<div class="tk-list ice-list${narrow ? " ice-plist" : ""}">${order.map(narrow ? prow : row)}${pagerHtml(icePg)}</div>`
|
|
550
|
-
: html`<div class="ice-zero"><h4>Nothing waiting</h4><p>Drop anything above: what a client asked for, something you found, what people say.</p>${list.length ? "" : html`<p style="margin-top:10px"><button class="btn sm pri" id="ice-addsrc">${ico("plus")} Add a source</button></p>`}</div>`;
|
|
551
|
-
// Swipe: the waiting requests the filters show, least skipped first; a restored one
|
|
552
|
-
// comes back on top. Nothing is written by a skip.
|
|
553
|
-
const deck = iceSwipe
|
|
554
|
-
? filtered.filter((i) => isWaiting(ice[i])).sort((a, b) => (iceSwipe.skip.get(iceKey(ice[a])) || 0) - (iceSwipe.skip.get(iceKey(ice[b])) || 0))
|
|
555
|
-
: [];
|
|
556
|
-
// The card always names its project: a swipe decides for that project's Tasks.
|
|
557
|
-
const pName = (it) => it.project || store.S.projects.find((p) => p.dir === it.dir)?.label || "";
|
|
558
|
-
const swCard = (i, back) => {
|
|
559
|
-
const it = ice[i];
|
|
560
|
-
return html`<div class="sw-card${back ? " back" : ""}"${back ? raw(' aria-hidden="true"') : raw(' id="sw-card" tabindex="-1" aria-label="Request: swipe or press → to promote, ← to dismiss"')}><div class="sw-hd">${fav(it.source, "link", srcOf(it)?.social)}<span class="sw-src" title="${srcName(it)}">${srcName(it)}</span><span class="sw-proj" title="${pName(it)}">${plogo(it.dir, pName(it))}${short(pName(it))}</span><span class="ice-age">${ago(it.at)}</span></div><p class="sw-t">${it.text}</p>${back ? "" : html`${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${imgs(it)}${it.post ? html`<a class="hint" href="${web(it.post)}" target="_blank" rel="noopener">open post</a>` : ""}<span class="sw-stamp pro">Promote</span><span class="sw-stamp dis">Dismiss</span>`}</div>`;
|
|
561
|
-
};
|
|
562
|
-
// Icebox zero: the day's streak counts days in a row the stack was emptied, per project
|
|
563
|
-
// filter, in this browser only.
|
|
564
|
-
const swZero = () => {
|
|
565
|
-
const S = iceSwipe;
|
|
566
|
-
if (S.n && S.days === undefined) {
|
|
567
|
-
const key = "kz-ice-streak:" + (dir || "all"),
|
|
568
|
-
day = (t) => new Date(t).toLocaleDateString("sv"),
|
|
569
|
-
today = day(Date.now());
|
|
570
|
-
let st = { last: "", days: 0 };
|
|
571
|
-
try {
|
|
572
|
-
st = JSON.parse(localStorage.getItem(key) || "") || st;
|
|
573
|
-
} catch (e) {}
|
|
574
|
-
if (st.last !== today) st = { last: today, days: st.last === day(Date.now() - 864e5) ? st.days + 1 : 1 };
|
|
575
|
-
try {
|
|
576
|
-
localStorage.setItem(key, JSON.stringify(st));
|
|
577
|
-
} catch (e) {}
|
|
578
|
-
S.days = st.days;
|
|
579
|
-
}
|
|
580
|
-
const s = Math.round((Date.now() - S.t0) / 1000),
|
|
581
|
-
took = s < 60 ? s + " s" : Math.floor(s / 60) + " min " + (s % 60) + " s";
|
|
582
|
-
const bits = motion() ? html`<div class="sw-confetti" aria-hidden="true">${Array.from({ length: 14 }, (_, n) => raw(`<i style="--x:${(n * 37) % 100}%;--d:${(n % 5) * 0.08}s;--h:${(n * 53) % 360}"></i>`))}</div>` : "";
|
|
583
|
-
return html`<div class="sw-zero">${S.n ? bits : ""}<h4>Icebox zero</h4><p>${S.n ? `${S.n} sorted · ${S.pro} promoted · ${S.dis} dismissed · in ${took}` : "Nothing waiting here."}</p>${S.days ? html`<p>${S.days}-day streak${S.days > 1 ? " — cleared every day" : ""}</p>` : ""}<p style="margin-top:14px"><button class="btn pri sm" id="sw-back">Back to list</button></p></div>`;
|
|
584
|
-
};
|
|
585
|
-
const swipe = () => {
|
|
586
|
-
const S = iceSwipe,
|
|
587
|
-
total = S.n + deck.length,
|
|
588
|
-
pop = S.pop;
|
|
589
|
-
S.pop = false;
|
|
590
|
-
const top = html`<div class="sw-top"><button class="btn ghost sm" id="sw-x" title="Back to the list (Esc)">← List</button><div class="sw-prog" role="progressbar" aria-valuemin="0" aria-valuemax="${total}" aria-valuenow="${S.n}"><i style="width:${total ? Math.round((S.n / total) * 100) : 100}%"></i></div><span class="sw-of">${deck.length ? `${S.n + 1} of ${total}` : `${total} of ${total}`}</span><span class="sw-streak" title="Sorted this session">${S.n} sorted${pop ? html`<b class="sw-plus">+1</b>` : ""}</span></div>`;
|
|
591
|
-
if (!deck.length) return html`<div class="sw" id="sw">${top}${swZero()}</div>`;
|
|
592
|
-
const b = (id, cls, icon, label, key, off = false) =>
|
|
593
|
-
html`<button class="sw-b ${cls}" id="${id}" aria-label="${label} (${key})" title="${label} (${key})"${off ? " disabled" : ""}><span>${icon}</span><small>${label}</small><kbd>${key}</kbd></button>`;
|
|
594
|
-
return html`<div class="sw" id="sw">${top}<div class="sw-stack">${deck[1] !== undefined ? swCard(deck[1], true) : ""}${swCard(deck[0], false)}</div><div class="sw-acts">${b("sw-d", "dis", ico("x"), "Dismiss", "←")}${b("sw-s", "", "↓", "Skip", "↓", deck.length < 2)}${b("sw-u", "", ico("restore"), "Undo", "z", !S.last)}${b("sw-p", "pro", ico("check"), "Promote", "→")}</div></div>`;
|
|
595
|
-
};
|
|
596
|
-
// The sources, in the right-hand drawer: shut until asked for. Slid in only when opened;
|
|
597
|
-
// a rebuild while open shows it in place.
|
|
598
|
-
const drawer = !!srcShow,
|
|
599
|
-
slide = drawer && !$("src-sec")?.classList.contains("open");
|
|
600
|
-
const sec = html`<div class="src-scrim${drawer && !slide ? " on" : ""}" id="src-scrim"></div><aside class="src-sec${drawer && !slide ? " open" : ""}" id="src-sec" aria-label="Sources"${drawer ? "" : " inert"}><header><div class="t"><b>Sources</b><div class="src-chips"><a id="src-to-settings" class="schip" role="button" tabindex="0" title="${d && d.every && d.every !== "off" ? `Checked every ${d.every}` : "Auto-check off"}: change in Settings">${ico("clock")}${d && d.every && d.every !== "off" ? (d.every) : "Off"}</a>${G.connected ? html`<span class="schip on" title="ChatGPT${G.email ? ": " + (G.email) : ""}">${ico("ai")}ChatGPT<a id="cg-out" role="button" tabindex="0" aria-label="Disconnect ChatGPT" title="Disconnect">${ico("x")}</a></span>` : html`<a id="cg-in" class="schip" role="button" tabindex="0" title="Connect ChatGPT">${ico("ai")}ChatGPT</a>`}${(d.google || {}).connected ? html`<span class="schip on" title="Google connected">${ico("google")}Google<a id="gg-out" role="button" tabindex="0" aria-label="Disconnect Google" title="Disconnect">${ico("x")}</a></span>` : html`<a id="gg-in" class="schip" role="button" tabindex="0" title="Connect Google">${ico("google")}Google</a>`}</div></div><div class="src-hda">${list.length ? html`<button class="btn sm" id="src-go">${ico("refresh")} Gather all</button><button class="btn sm" id="src-new" aria-expanded="${String(addOn)}" aria-controls="src-addbox">${ico("plus")} Add</button>` : ""}<button class="ib" id="src-x" aria-label="Close sources" title="Close">${ico("close")}</button></div></header><div class="body">${addBox}${list.length ? html`<div class="src-list">${cards}</div>` : emptyState}</div></aside>`;
|
|
601
|
-
// First visit: offer the ChatGPT plan for social sources, or keep the agent.
|
|
602
|
-
const onb =
|
|
603
|
-
G.use === "ask" && !G.connected
|
|
604
|
-
? html`<div class="cg-onb"><div class="acts"><b>Gather social posts with ChatGPT?</b><span class="end"></span><button class="btn ghost" id="cg-skip">Skip</button><button class="btn pri" id="cg-go">Connect</button></div></div>`
|
|
605
|
-
: "";
|
|
606
|
-
// A rebuild replaces the drawer: keep where it was scrolled to.
|
|
607
|
-
const at = $("src-sec")?.querySelector(".body")?.scrollTop ?? 0;
|
|
608
|
-
const capFocus = cap.ta && document.activeElement === cap.ta ? [cap.ta.selectionStart, cap.ta.selectionEnd] : null;
|
|
609
|
-
$("pbody").innerHTML =
|
|
610
|
-
d && d.error
|
|
611
|
-
? html`<p style="color:var(--dim)">${d.error}</p>`
|
|
612
|
-
: !d
|
|
613
|
-
? html`<p style="color:var(--dim)">The icebox could not be read.</p>`
|
|
614
|
-
: iceSwipe
|
|
615
|
-
? html`${swipe()}${sec}`
|
|
616
|
-
: html`${capBox}${narrow ? "" : onb}${boardsBar}${bar}${bulk}${fails}${inbox}${sec}`;
|
|
617
|
-
if (!d || d.error) return;
|
|
618
|
-
const body = $("src-sec")?.querySelector(".body");
|
|
619
|
-
if (body) body.scrollTop = at;
|
|
620
|
-
if ($("ice-cap")) {
|
|
621
|
-
if (!cap.ta) {
|
|
622
|
-
const ta = document.createElement("textarea");
|
|
623
|
-
ta.id = "ice-cap-t";
|
|
624
|
-
ta.className = "ice-cap-t";
|
|
625
|
-
ta.rows = 2;
|
|
626
|
-
ta.placeholder = "Drop anything: a note, a link, a picture — or dictate";
|
|
627
|
-
ta.setAttribute("aria-label", "Drop anything into the icebox");
|
|
628
|
-
cap.ta = ta;
|
|
629
|
-
cap.mic = mic([ta]);
|
|
630
|
-
}
|
|
631
|
-
// A phone has room for one short line.
|
|
632
|
-
cap.ta.placeholder = narrowQ.matches ? "Drop a note, link or picture…" : "Drop anything: a note, a link, a picture — or dictate";
|
|
633
|
-
$("ice-cap-slot").replaceWith(cap.ta);
|
|
634
|
-
if (cap.mic) $("ice-mic-slot").replaceWith(cap.mic);
|
|
635
|
-
else $("ice-mic-slot").remove();
|
|
636
|
-
if (capFocus) {
|
|
637
|
-
cap.ta.focus();
|
|
638
|
-
cap.ta.setSelectionRange(capFocus[0], capFocus[1]);
|
|
639
|
-
}
|
|
640
|
-
const addFile = (f) => {
|
|
641
|
-
cap.files.push(f);
|
|
642
|
-
openSources().then(() => cap.ta.focus());
|
|
643
|
-
};
|
|
644
|
-
$("ice-pick").onclick = () => $("ice-file").click();
|
|
645
|
-
$("ice-file").onchange = (e) => {
|
|
646
|
-
const fs = [...e.target.files];
|
|
647
|
-
e.target.value = "";
|
|
648
|
-
cap.files.push(...fs);
|
|
649
|
-
openSources().then(() => cap.ta.focus());
|
|
650
|
-
};
|
|
651
|
-
$("pbody")
|
|
652
|
-
.querySelectorAll("[data-rf]")
|
|
653
|
-
.forEach((b) => (b.onclick = () => {
|
|
654
|
-
cap.files.splice(+b.dataset.rf, 1);
|
|
655
|
-
openSources().then(() => cap.ta.focus());
|
|
656
|
-
}));
|
|
657
|
-
// A pasted picture is a file; pasted text stays text.
|
|
658
|
-
cap.ta.onpaste = (e) => {
|
|
659
|
-
for (const it of e.clipboardData.items)
|
|
660
|
-
if (it.kind === "file") {
|
|
661
|
-
const x = it.getAsFile();
|
|
662
|
-
e.preventDefault();
|
|
663
|
-
addFile(new File([x], x.name === "image.png" ? `paste-${Date.now()}.png` : x.name, { type: x.type }));
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
// Saved with the text it had: the field is read-only until the server answers.
|
|
667
|
-
const save = async () => {
|
|
668
|
-
const text = cap.ta.value.trim(),
|
|
669
|
-
to = dir || cap.dir;
|
|
670
|
-
if (cap.busy) return;
|
|
671
|
-
if (!text) {
|
|
672
|
-
if (cap.files.length) toast("Write a line about it first");
|
|
673
|
-
return cap.ta.focus();
|
|
674
|
-
}
|
|
675
|
-
if (!to) return toast("Pick a project first");
|
|
676
|
-
cap.busy = cap.ta.readOnly = true;
|
|
677
|
-
$("ice-save").disabled = true;
|
|
678
|
-
$("ice-save").textContent = "Saving…";
|
|
679
|
-
let j = { ok: false };
|
|
680
|
-
try {
|
|
681
|
-
j = await post("/icebox", { op: "add", dir: to, text, board: cap.board || undefined, files: await dataUrls(cap.files) });
|
|
682
|
-
} finally {
|
|
683
|
-
cap.busy = cap.ta.readOnly = false;
|
|
684
|
-
}
|
|
685
|
-
if (j.ok) {
|
|
686
|
-
cap.ta.value = "";
|
|
687
|
-
cap.files = [];
|
|
688
|
-
iceCur = null;
|
|
689
|
-
toast(`Added to the icebox${cap.board ? " · " + cap.board : ""}`);
|
|
690
|
-
load();
|
|
691
|
-
}
|
|
692
|
-
if (srcOpen()) await openSources();
|
|
693
|
-
cap.ta.focus();
|
|
694
|
-
};
|
|
695
|
-
cap.ta.onkeydown = (e) => {
|
|
696
|
-
if (e.key === "Enter" && !e.shiftKey && !e.isComposing) {
|
|
697
|
-
e.preventDefault();
|
|
698
|
-
save();
|
|
699
|
-
}
|
|
700
|
-
};
|
|
701
|
-
$("ice-save").onclick = save;
|
|
702
|
-
wirePick("ice-cp", (v) => {
|
|
703
|
-
cap.dir = v;
|
|
704
|
-
openSources().then(() => cap.ta.focus());
|
|
705
|
-
});
|
|
706
|
-
wirePick("ice-cb", async (v) => {
|
|
707
|
-
if (v === "\n") {
|
|
708
|
-
const a = await askCollection();
|
|
709
|
-
if (!a) return cap.ta.focus();
|
|
710
|
-
if (a.client) await post("/icebox", { op: "boards", act: "add", dir: dir || cap.dir, name: a.name, client: true });
|
|
711
|
-
v = a.name;
|
|
712
|
-
}
|
|
713
|
-
cap.board = v;
|
|
714
|
-
cap.boardDir = dir || cap.dir;
|
|
715
|
-
openSources().then(() => cap.ta.focus());
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
if (iceMenu !== iceMenuFor) {
|
|
719
|
-
iceMenuFor = iceMenu;
|
|
720
|
-
iceMenuAt = iceMenu ? Date.now() : 0;
|
|
721
|
-
}
|
|
722
|
-
$("pbody").onscroll = () => {
|
|
723
|
-
if (!iceMenu || Date.now() - iceMenuAt < 400) return;
|
|
724
|
-
iceMenu = "";
|
|
725
|
-
$("pbody").querySelector(".ice-mpop")?.remove();
|
|
726
|
-
$("pbody").querySelector('[data-m][aria-expanded="true"]')?.setAttribute("aria-expanded", "false");
|
|
727
|
-
};
|
|
728
|
-
// The boards bar and the kind filters; the view switch.
|
|
729
|
-
$("pbody")
|
|
730
|
-
.querySelectorAll("[data-bd]")
|
|
731
|
-
.forEach((b) => (b.onclick = () => {
|
|
732
|
-
iceBoard = b.dataset.bd;
|
|
733
|
-
// The box follows the chip: its board, and in All projects that board's project.
|
|
734
|
-
const fb = iceBoard && boards.find((x) => sameName(x.name, iceBoard));
|
|
735
|
-
if (fb) {
|
|
736
|
-
cap.board = fb.name;
|
|
737
|
-
cap.boardDir = fb.dir;
|
|
738
|
-
if (!dir) cap.dir = fb.dir;
|
|
739
|
-
}
|
|
740
|
-
openSources();
|
|
741
|
-
}));
|
|
742
|
-
$("pbody")
|
|
743
|
-
.querySelectorAll("[data-kf]")
|
|
744
|
-
.forEach((b) => (b.onclick = () => {
|
|
745
|
-
iceKinds.has(b.dataset.kf) ? iceKinds.delete(b.dataset.kf) : iceKinds.add(b.dataset.kf);
|
|
746
|
-
openSources();
|
|
747
|
-
}));
|
|
748
|
-
$("pbody")
|
|
749
|
-
.querySelectorAll("[data-view]")
|
|
750
|
-
.forEach((b) => (b.onclick = () => {
|
|
751
|
-
iceView = b.dataset.view;
|
|
752
|
-
try {
|
|
753
|
-
localStorage.setItem("kz-ice-view", iceView);
|
|
754
|
-
} catch (e) {}
|
|
755
|
-
openSources();
|
|
756
|
-
}));
|
|
757
|
-
// + Collection: a name, and whether it is a client's (its items then count as Client).
|
|
758
|
-
if ($("ice-nb"))
|
|
759
|
-
$("ice-nb").onclick = async () => {
|
|
760
|
-
const to = dir || cap.dir;
|
|
761
|
-
if (!to) return toast("Pick a project first");
|
|
762
|
-
const a = await askCollection(dir ? "" : capP?.label || "this project");
|
|
763
|
-
if (!a) return;
|
|
764
|
-
const { name, client } = a;
|
|
765
|
-
const j = await post("/icebox", { op: "boards", act: "add", dir: to, name, client });
|
|
766
|
-
if (j.ok) {
|
|
767
|
-
toast(`Collection ${name} made`);
|
|
768
|
-
load();
|
|
769
|
-
}
|
|
770
|
-
if (srcOpen()) openSources();
|
|
771
|
-
};
|
|
772
|
-
if (sdKeep && sdKeep[0] === iceMenu && $("ice-sd")) $("ice-sd").value = sdKeep[1];
|
|
773
|
-
if (iceDraft && iceDraft[0] === iceForm && $("ice-title")) {
|
|
774
|
-
$("ice-title").value = iceDraft[1];
|
|
775
|
-
$("ice-details").value = iceDraft[2];
|
|
776
|
-
}
|
|
777
|
-
if ($("src-add")) {
|
|
778
|
-
if (typed[5]) $("src-plat").value = typed[5];
|
|
779
|
-
$("src-q").value = typed[6] || "";
|
|
780
|
-
$("src-url").value = typed[0];
|
|
781
|
-
$("src-label").value = typed[1];
|
|
782
|
-
$("src-cat").value = typed[4] || "";
|
|
783
|
-
if (typed[3] !== undefined && $("src-dir")) $("src-dir").value = typed[3];
|
|
784
|
-
}
|
|
785
|
-
if ($("src-to-settings"))
|
|
786
|
-
$("src-to-settings").onclick = () => {
|
|
787
|
-
store.setQ = "sources";
|
|
788
|
-
go("settings", true);
|
|
789
|
-
};
|
|
790
|
-
// The tab is opened inside the click, before the sign-in URL comes back: a popup blocker
|
|
791
|
-
// lets only that through. The board hears of the result through /events.
|
|
792
|
-
const connect = async () => {
|
|
793
|
-
const w = window.open("", "_blank");
|
|
794
|
-
const j = await post("/chatgpt", { op: "connect" });
|
|
795
|
-
if (j.ok && w) w.location = j.url;
|
|
796
|
-
else {
|
|
797
|
-
w?.close();
|
|
798
|
-
if (j.ok) location.href = j.url;
|
|
799
|
-
}
|
|
800
|
-
};
|
|
801
|
-
for (const id of ["cg-go", "cg-in"]) if ($(id)) $(id).onclick = connect;
|
|
802
|
-
// Google needs the user's own OAuth client (Desktop app, Sheets API on); asked once.
|
|
803
|
-
if ($("gg-in"))
|
|
804
|
-
$("gg-in").onclick = async () => {
|
|
805
|
-
if (!(d.google || {}).hasClient) {
|
|
806
|
-
toast("Add your Google client in Settings first");
|
|
807
|
-
store.setQ = "google";
|
|
808
|
-
go("settings", true);
|
|
809
|
-
return;
|
|
810
|
-
}
|
|
811
|
-
const w = window.open("", "_blank");
|
|
812
|
-
const j = await post("/google", { op: "connect" });
|
|
813
|
-
if (j.ok && w) w.location = j.url;
|
|
814
|
-
else {
|
|
815
|
-
w?.close();
|
|
816
|
-
if (j.ok) location.href = j.url;
|
|
817
|
-
else toast(j.error || "Could not start Google sign-in");
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
if ($("gg-out"))
|
|
821
|
-
$("gg-out").onclick = async () => {
|
|
822
|
-
if (!confirm("Disconnect Google? Done requests stop being written to sheets.")) return;
|
|
823
|
-
if ((await post("/google", { op: "disconnect" })).ok) {
|
|
824
|
-
toast("Google disconnected");
|
|
825
|
-
openSources();
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
if ($("cg-skip"))
|
|
829
|
-
$("cg-skip").onclick = async () => {
|
|
830
|
-
if ((await post("/chatgpt", { op: "skip" })).ok) {
|
|
831
|
-
openSources();
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
if ($("cg-out"))
|
|
835
|
-
$("cg-out").onclick = async () => {
|
|
836
|
-
if (!confirm("Disconnect ChatGPT? Gather goes back to your agent.")) return;
|
|
837
|
-
if ((await post("/chatgpt", { op: "disconnect" })).ok) {
|
|
838
|
-
toast("ChatGPT disconnected");
|
|
839
|
-
openSources();
|
|
840
|
-
}
|
|
841
|
-
};
|
|
842
|
-
if (slide) {
|
|
843
|
-
$("src-sec").offsetWidth;
|
|
844
|
-
$("src-sec").classList.add("open");
|
|
845
|
-
$("src-scrim").classList.add("on");
|
|
846
|
-
}
|
|
847
|
-
const srcShut = () => {
|
|
848
|
-
srcShow = false;
|
|
849
|
-
$("src-sec").classList.remove("open");
|
|
850
|
-
$("src-scrim").classList.remove("on");
|
|
851
|
-
$("src-sec").inert = true;
|
|
852
|
-
$("src-tog").setAttribute("aria-expanded", "false");
|
|
853
|
-
$("src-tog").focus();
|
|
854
|
-
};
|
|
855
|
-
$("src-x").onclick = $("src-scrim").onclick = srcShut;
|
|
856
|
-
if ($("src-new"))
|
|
857
|
-
$("src-new").onclick = () => {
|
|
858
|
-
const b = $("src-addbox");
|
|
859
|
-
srcAdd = b.hidden;
|
|
860
|
-
b.hidden = !srcAdd;
|
|
861
|
-
$("src-new").setAttribute("aria-expanded", srcAdd);
|
|
862
|
-
if (srcAdd) $(srcKind === "social" ? "src-q" : "src-url").focus();
|
|
863
|
-
};
|
|
864
|
-
$("src-sec").onkeydown = (e) => {
|
|
865
|
-
if (e.key === "Escape") {
|
|
866
|
-
e.stopPropagation();
|
|
867
|
-
srcShut();
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
const srcTog = () => {
|
|
871
|
-
if ($("src-sec").classList.contains("open")) return srcShut();
|
|
872
|
-
srcShow = true;
|
|
873
|
-
openSources().then(() => srcShow && $("src-url")?.focus());
|
|
874
|
-
};
|
|
875
|
-
if ($("src-tog")) $("src-tog").onclick = srcTog;
|
|
876
|
-
if ($("ice-addsrc")) $("ice-addsrc").onclick = srcTog;
|
|
877
|
-
wirePick("ice-fs", (v) => {
|
|
878
|
-
iceSrc = v;
|
|
879
|
-
openSources();
|
|
880
|
-
});
|
|
881
|
-
wirePick("ice-fc", (v) => {
|
|
882
|
-
iceCat = v;
|
|
883
|
-
openSources();
|
|
884
|
-
});
|
|
885
|
-
if ($("ice-unf"))
|
|
886
|
-
$("ice-unf").onclick = () => {
|
|
887
|
-
iceCat = iceSrc = iceBoard = "";
|
|
888
|
-
iceKinds.clear();
|
|
889
|
-
if (!dir) store.shown.clear();
|
|
890
|
-
setShown();
|
|
891
|
-
openSources();
|
|
892
|
-
};
|
|
893
|
-
$("pbody")
|
|
894
|
-
.querySelectorAll("[data-kind]")
|
|
895
|
-
.forEach(
|
|
896
|
-
(b) =>
|
|
897
|
-
(b.onclick = () => {
|
|
898
|
-
if (srcKind === b.dataset.kind) return;
|
|
899
|
-
srcKind = b.dataset.kind;
|
|
900
|
-
openSources().then(() => $(srcKind === "social" ? "src-q" : "src-url")?.focus());
|
|
901
|
-
}),
|
|
902
|
-
);
|
|
903
|
-
const act = async (body, done) => {
|
|
904
|
-
const j = await post("/sources", body);
|
|
905
|
-
if (j.ok) {
|
|
906
|
-
done(j);
|
|
907
|
-
load();
|
|
908
|
-
}
|
|
909
|
-
if (srcOpen()) openSources();
|
|
910
|
-
};
|
|
911
|
-
$("pbody")
|
|
912
|
-
.querySelectorAll("[data-mv]")
|
|
913
|
-
.forEach((m) => {
|
|
914
|
-
const s = list[+m.dataset.mv],
|
|
915
|
-
b = $("src-mb-" + m.dataset.mv),
|
|
916
|
-
to = picked.get(m.dataset.k);
|
|
917
|
-
if (to && [...m.options].some((o) => o.value === to)) m.value = to;
|
|
918
|
-
(m.onchange = () => {
|
|
919
|
-
b.disabled = m.value === s.dir;
|
|
920
|
-
})();
|
|
921
|
-
b.onclick = () =>
|
|
922
|
-
act({ op: "move", dir: s.dir, to: m.value, url: s.url }, () =>
|
|
923
|
-
toast("Source moved"),
|
|
924
|
-
);
|
|
925
|
-
});
|
|
926
|
-
$("pbody")
|
|
927
|
-
.querySelectorAll("[data-wb]")
|
|
928
|
-
.forEach((m) => {
|
|
929
|
-
const s = list[+m.dataset.wb];
|
|
930
|
-
m.onclick = () => {
|
|
931
|
-
const on = !m.classList.contains("on");
|
|
932
|
-
if (on && s.social === undefined && /docs\.google\.com/.test(s.url) && !(d.google || {}).connected) {
|
|
933
|
-
alert("Connect Google first (Sources header), so kaizen can write to the sheet.");
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
if (on && !confirm("When a promoted request's run is done, kaizen will write that back to this source. A closed issue or a changed cell is visible to others. Turn on?")) return;
|
|
937
|
-
act({ op: "writeback", dir: s.dir, url: s.url, on }, () =>
|
|
938
|
-
toast(on ? "Write back on" : "Write back off"),
|
|
939
|
-
);
|
|
940
|
-
};
|
|
941
|
-
});
|
|
942
|
-
$("pbody")
|
|
943
|
-
.querySelectorAll("[data-ag-on]")
|
|
944
|
-
.forEach((m) => {
|
|
945
|
-
const s = list[+m.dataset.agOn];
|
|
946
|
-
m.onclick = () => {
|
|
947
|
-
const on = !m.classList.contains("on");
|
|
948
|
-
act({ op: "paused", dir: s.dir, url: s.url, on: !on }, () =>
|
|
949
|
-
toast(on ? "Auto gather on" : "Auto gather off"),
|
|
950
|
-
);
|
|
951
|
-
};
|
|
952
|
-
});
|
|
953
|
-
// The category saves on its button or Enter, never per keystroke.
|
|
954
|
-
$("pbody")
|
|
955
|
-
.querySelectorAll("[data-ct]")
|
|
956
|
-
.forEach((m) => {
|
|
957
|
-
const s = list[+m.dataset.ct],
|
|
958
|
-
b = $("src-cs-" + m.dataset.ct),
|
|
959
|
-
was = cats.get(m.dataset.k);
|
|
960
|
-
if (was !== undefined) m.value = was;
|
|
961
|
-
(m.oninput = () => {
|
|
962
|
-
b.disabled = m.value.trim() === (s.category || "");
|
|
963
|
-
})();
|
|
964
|
-
m.onkeydown = (e) => {
|
|
965
|
-
if (e.key === "Enter" && !b.disabled) b.click();
|
|
966
|
-
};
|
|
967
|
-
b.onclick = () => {
|
|
968
|
-
b.disabled = true;
|
|
969
|
-
act({ op: "category", dir: s.dir, url: s.url, category: m.value.trim() }, () =>
|
|
970
|
-
toast(
|
|
971
|
-
m.value.trim()
|
|
972
|
-
? `New requests from ${s.label || host(s.url)} go under ${m.value.trim()}`
|
|
973
|
-
: "Category cleared",
|
|
974
|
-
),
|
|
975
|
-
);
|
|
976
|
-
};
|
|
977
|
-
});
|
|
978
|
-
// The acting button is disabled as it is pressed, which drops focus to the page; it goes back to the cursor row.
|
|
979
|
-
const focusCur = () => {
|
|
980
|
-
if (!document.activeElement || document.activeElement === document.body)
|
|
981
|
-
$("pbody").querySelector(".ice-row.cur .ice-t,.ice-card.cur .ice-ct")?.focus();
|
|
982
|
-
};
|
|
983
|
-
// Before rows go, the cursor steps to the next row that stays, else the one before.
|
|
984
|
-
const stepPast = (gone) => {
|
|
985
|
-
const at = order.findIndex((i) => iceKey(ice[i]) === iceCur);
|
|
986
|
-
if (at < 0 || !gone.has(iceCur)) return;
|
|
987
|
-
const stay = (i) => !gone.has(iceKey(ice[i])),
|
|
988
|
-
n = order.slice(at + 1).find(stay) ?? order.slice(0, at).reverse().find(stay);
|
|
989
|
-
iceCur = n === undefined ? null : iceKey(ice[n]);
|
|
990
|
-
};
|
|
991
|
-
const iceAct = (op, it, msg, extra = {}) =>
|
|
992
|
-
(async () => {
|
|
993
|
-
stepPast(new Set([iceKey(it)]));
|
|
994
|
-
const j = await post("/icebox", { op, dir: it.dir, ids: [it.id], ...extra });
|
|
995
|
-
if (j.ok) {
|
|
996
|
-
if (op === "promote" && iceForm === iceKey(it)) iceForm = icePro = null;
|
|
997
|
-
toast(msg);
|
|
998
|
-
load();
|
|
999
|
-
}
|
|
1000
|
-
if (srcOpen()) openSources().then(focusCur);
|
|
1001
|
-
})();
|
|
1002
|
-
// Snooze: the items leave the page until their day, with Undo on the toast.
|
|
1003
|
-
const snoozeAll = async (its, until) => {
|
|
1004
|
-
if (!its.length) return;
|
|
1005
|
-
stepPast(new Set(its.map(iceKey)));
|
|
1006
|
-
iceMenu = "";
|
|
1007
|
-
iceBusy = true;
|
|
1008
|
-
const done = [];
|
|
1009
|
-
try {
|
|
1010
|
-
for (const dd of new Set(its.map((it) => it.dir))) {
|
|
1011
|
-
const xs = its.filter((it) => it.dir === dd);
|
|
1012
|
-
if ((await post("/icebox", { op: "snooze", dir: dd, ids: xs.map((it) => it.id), until })).ok) done.push(...xs);
|
|
1013
|
-
}
|
|
1014
|
-
} finally {
|
|
1015
|
-
iceBusy = false;
|
|
1016
|
-
}
|
|
1017
|
-
if (done.length) {
|
|
1018
|
-
done.forEach((it) => iceSel.delete(iceKey(it)));
|
|
1019
|
-
toast(`${done.length > 1 ? done.length + " snoozed" : "Snoozed"} until ${wakeDay(until).toLocaleDateString(undefined, { weekday: "short", month: "short", day: "numeric" })}`);
|
|
1020
|
-
const t = $("toast"),
|
|
1021
|
-
u = document.createElement("button");
|
|
1022
|
-
u.type = "button";
|
|
1023
|
-
u.className = "ice-undo";
|
|
1024
|
-
u.textContent = "Undo";
|
|
1025
|
-
u.onclick = async () => {
|
|
1026
|
-
t.classList.remove("on");
|
|
1027
|
-
let back = 0;
|
|
1028
|
-
for (const dd of new Set(done.map((it) => it.dir)))
|
|
1029
|
-
if ((await post("/icebox", { op: "unsnooze", dir: dd, ids: done.filter((it) => it.dir === dd).map((it) => it.id) })).ok) back++;
|
|
1030
|
-
if (back) {
|
|
1031
|
-
iceCur = iceKey(done[0]);
|
|
1032
|
-
toast("Back in the icebox");
|
|
1033
|
-
}
|
|
1034
|
-
load();
|
|
1035
|
-
if (srcOpen()) openSources();
|
|
1036
|
-
};
|
|
1037
|
-
t.classList.add("rep");
|
|
1038
|
-
t.append(" · ", u);
|
|
1039
|
-
}
|
|
1040
|
-
load();
|
|
1041
|
-
if (srcOpen()) openSources().then(focusCur);
|
|
1042
|
-
};
|
|
1043
|
-
// Kind and board: the item stays, changed.
|
|
1044
|
-
const setOne = async (it, body, msg) => {
|
|
1045
|
-
iceMenu = "";
|
|
1046
|
-
const j = await post("/icebox", { dir: it.dir, ids: [it.id], ...body });
|
|
1047
|
-
if (j.ok) {
|
|
1048
|
-
toast(msg);
|
|
1049
|
-
load();
|
|
1050
|
-
}
|
|
1051
|
-
if (srcOpen()) openSources().then(() => $("pbody").querySelector(`[data-k="${CSS.escape(iceKey(it))}"] [data-m]`)?.focus());
|
|
1052
|
-
};
|
|
1053
|
-
$("pbody")
|
|
1054
|
-
.querySelectorAll("[data-m]")
|
|
1055
|
-
.forEach((b) => (b.onclick = (e) => {
|
|
1056
|
-
e.stopPropagation();
|
|
1057
|
-
const it = ice[+b.dataset.mi],
|
|
1058
|
-
m = iceKey(it) + " " + b.dataset.m;
|
|
1059
|
-
iceCur = iceKey(it);
|
|
1060
|
-
iceMenu = iceMenu === m ? "" : m;
|
|
1061
|
-
openSources().then(() => iceMenu && $("pbody").querySelector(".ice-mpop button")?.focus());
|
|
1062
|
-
}));
|
|
1063
|
-
// The open menu sits fixed under its button: inside the cards' columns an absolute one is split
|
|
1064
|
-
// between columns. Scrolling the page shuts it.
|
|
1065
|
-
$("pbody")
|
|
1066
|
-
.querySelectorAll(".ice-mpop")
|
|
1067
|
-
.forEach((pp) => {
|
|
1068
|
-
const it = ice[+pp.dataset.mi],
|
|
1069
|
-
btn = pp.parentElement.querySelector(`[data-m="${iceMenu.slice(iceKey(it).length + 1)}"]`) || pp.parentElement.querySelector(".ice-pf");
|
|
1070
|
-
if (btn) {
|
|
1071
|
-
const r = btn.getBoundingClientRect(),
|
|
1072
|
-
h = pp.offsetHeight,
|
|
1073
|
-
w = pp.offsetWidth;
|
|
1074
|
-
pp.style.left = Math.max(8, Math.min(r.left, innerWidth - w - 8)) + "px";
|
|
1075
|
-
pp.style.top = (r.bottom + 4 + h > innerHeight - 8 ? Math.max(8, r.top - 4 - h) : r.bottom + 4) + "px";
|
|
1076
|
-
}
|
|
1077
|
-
pp.onclick = (e) => e.stopPropagation();
|
|
1078
|
-
pp.onkeydown = (e) => {
|
|
1079
|
-
const bs = [...pp.querySelectorAll("button,input")],
|
|
1080
|
-
n = bs.indexOf(document.activeElement);
|
|
1081
|
-
if (e.key === "Escape") {
|
|
1082
|
-
e.stopPropagation();
|
|
1083
|
-
iceMenu = "";
|
|
1084
|
-
openSources().then(focusCur);
|
|
1085
|
-
} else if ((e.key === "ArrowDown" || e.key === "ArrowUp") && document.activeElement?.type !== "date") {
|
|
1086
|
-
e.preventDefault();
|
|
1087
|
-
bs[(n + (e.key === "ArrowDown" ? 1 : bs.length - 1)) % bs.length]?.focus();
|
|
1088
|
-
}
|
|
1089
|
-
};
|
|
1090
|
-
pp.querySelectorAll("[data-sz]").forEach((b) => (b.onclick = () => {
|
|
1091
|
-
const v = b.dataset.sz || $("ice-sd").value;
|
|
1092
|
-
if (!v) return $("ice-sd").focus();
|
|
1093
|
-
snoozeAll([it], v);
|
|
1094
|
-
}));
|
|
1095
|
-
pp.querySelectorAll("[data-kd]").forEach((b) => (b.onclick = () => setOne(it, { op: "kind", kind: b.dataset.kd }, `Kind: ${KIND[b.dataset.kd]}`)));
|
|
1096
|
-
pp.querySelectorAll("[data-bo]").forEach((b) => (b.onclick = () => setOne(it, { op: "board", board: b.dataset.bo }, b.dataset.bo ? `Moved to ${b.dataset.bo}` : "Moved to the Inbox")));
|
|
1097
|
-
pp.querySelectorAll("[data-bo-new]").forEach((b) => (b.onclick = async () => {
|
|
1098
|
-
iceMenu = "";
|
|
1099
|
-
const a = await askCollection();
|
|
1100
|
-
if (!a) return;
|
|
1101
|
-
if (a.client) await post("/icebox", { op: "boards", act: "add", dir: it.dir, name: a.name, client: true });
|
|
1102
|
-
setOne(it, { op: "board", board: a.name }, `Moved to ${a.name}`);
|
|
1103
|
-
}));
|
|
1104
|
-
});
|
|
1105
|
-
// Bulk: one dismiss per project; promote one request at a time, each its own task
|
|
1106
|
-
// titled as gathered (one promote call with several ids would merge them into one).
|
|
1107
|
-
const bulkDo = async (op) => {
|
|
1108
|
-
const its = ice.filter((it) => iceSel.has(iceKey(it)));
|
|
1109
|
-
if (!its.length) return;
|
|
1110
|
-
stepPast(new Set(its.map(iceKey)));
|
|
1111
|
-
iceBusy = true;
|
|
1112
|
-
$("ice-bp").disabled = $("ice-bd").disabled = $("ice-bz").disabled = true;
|
|
1113
|
-
let ok = 0;
|
|
1114
|
-
try {
|
|
1115
|
-
if (op === "dismiss")
|
|
1116
|
-
for (const dd of new Set(its.map((it) => it.dir))) {
|
|
1117
|
-
const ids = its.filter((it) => it.dir === dd).map((it) => it.id);
|
|
1118
|
-
if ((await post("/icebox", { op, dir: dd, ids })).ok) ok += ids.length;
|
|
1119
|
-
}
|
|
1120
|
-
else for (const it of its) if ((await post("/icebox", { op, dir: it.dir, ids: [it.id] })).ok) ok++;
|
|
1121
|
-
} finally {
|
|
1122
|
-
iceBusy = false;
|
|
1123
|
-
}
|
|
1124
|
-
iceSel.clear();
|
|
1125
|
-
if (ok)
|
|
1126
|
-
toast(
|
|
1127
|
-
`${ok} ${op === "promote" ? "promoted to Tasks" : "dismissed"}${ok < its.length ? `, ${its.length - ok} not` : ""}`,
|
|
1128
|
-
);
|
|
1129
|
-
load();
|
|
1130
|
-
if (srcOpen()) openSources().then(focusCur);
|
|
1131
|
-
};
|
|
1132
|
-
if (bulk) {
|
|
1133
|
-
$("ice-bz").onclick = () => snoozeAll(ice.filter((it) => iceSel.has(iceKey(it)) && live(it)), "1w");
|
|
1134
|
-
$("ice-bp").onclick = () => bulkDo("promote");
|
|
1135
|
-
$("ice-bd").onclick = () => bulkDo("dismiss");
|
|
1136
|
-
$("ice-bc").onclick = () => {
|
|
1137
|
-
iceSel.clear();
|
|
1138
|
-
openSources();
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
wirePager(icePg, openSources);
|
|
1142
|
-
if ($("ice-all"))
|
|
1143
|
-
$("ice-all").onchange = () => {
|
|
1144
|
-
const k = order.map((i) => iceKey(ice[i]));
|
|
1145
|
-
if (nSel === order.length) k.forEach((x) => iceSel.delete(x));
|
|
1146
|
-
else k.forEach((x) => iceSel.add(x));
|
|
1147
|
-
openSources();
|
|
1148
|
-
};
|
|
1149
|
-
if ($("ice-all")) $("ice-all").indeterminate = nSel > 0 && nSel < order.length;
|
|
1150
|
-
$("pbody")
|
|
1151
|
-
.querySelectorAll("[data-ck]")
|
|
1152
|
-
.forEach(
|
|
1153
|
-
(c) =>
|
|
1154
|
-
(c.onchange = () => {
|
|
1155
|
-
const k = iceKey(ice[+c.dataset.ck]);
|
|
1156
|
-
iceCur = k;
|
|
1157
|
-
c.checked ? iceSel.add(k) : iceSel.delete(k);
|
|
1158
|
-
openSources();
|
|
1159
|
-
}),
|
|
1160
|
-
);
|
|
1161
|
-
// A row opens on its title or anywhere not a control; open shows what was gathered and the promote form.
|
|
1162
|
-
// A card opens in the Sort list (for this visit; the saved view stays), where notes, reply and promote are.
|
|
1163
|
-
const toggle = (i) => {
|
|
1164
|
-
const k = iceKey(ice[i]);
|
|
1165
|
-
iceCur = k;
|
|
1166
|
-
iceForm = iceForm === k && !cardsOn ? null : k;
|
|
1167
|
-
iceView = "sort";
|
|
1168
|
-
icePro = null;
|
|
1169
|
-
openSources().then(() => $("ice-o-" + i)?.focus());
|
|
1170
|
-
};
|
|
1171
|
-
$("pbody")
|
|
1172
|
-
.querySelectorAll(".ice-row")
|
|
1173
|
-
.forEach(
|
|
1174
|
-
(r) =>
|
|
1175
|
-
(r.onclick = (e) => {
|
|
1176
|
-
if (!e.target.closest("input,button,.ice-mpop")) toggle(+r.dataset.i);
|
|
1177
|
-
}),
|
|
1178
|
-
);
|
|
1179
|
-
$("pbody")
|
|
1180
|
-
.querySelectorAll("[data-o]")
|
|
1181
|
-
.forEach((b) => (b.onclick = () => toggle(+b.dataset.o)));
|
|
1182
|
-
// Images from a source load only when asked: fetching one tells its host the item was opened.
|
|
1183
|
-
$("pbody")
|
|
1184
|
-
.querySelectorAll("details.ice-imgs")
|
|
1185
|
-
.forEach((d) => (d.ontoggle = () => d.open && d.querySelectorAll("img[data-src]").forEach((i) => (i.src = i.dataset.src))));
|
|
1186
|
-
$("pbody")
|
|
1187
|
-
.querySelectorAll("[data-pr]")
|
|
1188
|
-
.forEach(
|
|
1189
|
-
(b) =>
|
|
1190
|
-
(b.onclick = () => {
|
|
1191
|
-
const it = ice[+b.dataset.pr],
|
|
1192
|
-
k = iceKey(it);
|
|
1193
|
-
iceCur = iceForm = icePro = k;
|
|
1194
|
-
iceView = "sort";
|
|
1195
|
-
if (G.connected && !(iceTask && iceTask.k === k)) taskDraft(it);
|
|
1196
|
-
openSources().then(() => {
|
|
1197
|
-
$("ice-title")?.focus();
|
|
1198
|
-
$("ice-title")?.select();
|
|
1199
|
-
});
|
|
1200
|
-
}),
|
|
1201
|
-
);
|
|
1202
|
-
$("pbody")
|
|
1203
|
-
.querySelectorAll("[data-ds]")
|
|
1204
|
-
.forEach(
|
|
1205
|
-
(b) =>
|
|
1206
|
-
(b.onclick = () => {
|
|
1207
|
-
b.disabled = true;
|
|
1208
|
-
iceAct("dismiss", ice[+b.dataset.ds], "Dismissed");
|
|
1209
|
-
}),
|
|
1210
|
-
);
|
|
1211
|
-
$("pbody")
|
|
1212
|
-
.querySelectorAll("[data-rs]")
|
|
1213
|
-
.forEach(
|
|
1214
|
-
(b) =>
|
|
1215
|
-
(b.onclick = () => {
|
|
1216
|
-
b.disabled = true;
|
|
1217
|
-
iceAct("restore", ice[+b.dataset.rs], "Restored");
|
|
1218
|
-
}),
|
|
1219
|
-
);
|
|
1220
|
-
const open1 = ice.find((it) => iceKey(it) === iceForm);
|
|
1221
|
-
if ($("ice-rp"))
|
|
1222
|
-
$("ice-rp").onclick = async () => {
|
|
1223
|
-
const it = open1,
|
|
1224
|
-
k = iceKey(it);
|
|
1225
|
-
iceReply = { k, text: "", wait: true };
|
|
1226
|
-
openSources();
|
|
1227
|
-
const j = await post("/reply", { op: "draft", dir: it.dir, id: it.id, style: rStyle(it.dir) });
|
|
1228
|
-
if (!iceReply || iceReply.k !== k) return;
|
|
1229
|
-
iceReply = { k, text: j.text || "", note: j.ok ? j.note || "" : "", wait: false };
|
|
1230
|
-
openSources().then(() => $("ice-reply")?.focus());
|
|
1231
|
-
};
|
|
1232
|
-
if ($("ice-rst"))
|
|
1233
|
-
$("ice-rst").onchange = (e) => {
|
|
1234
|
-
const d = open1.dir;
|
|
1235
|
-
iceStyle[d] = e.target.value;
|
|
1236
|
-
try {
|
|
1237
|
-
localStorage.setItem("kz-reply-style:" + d, iceStyle[d]);
|
|
1238
|
-
} catch (e) {}
|
|
1239
|
-
};
|
|
1240
|
-
// Another draft in the picked style, told to differ from the one in the box; the box keeps its text until it lands.
|
|
1241
|
-
if ($("ice-rg"))
|
|
1242
|
-
$("ice-rg").onclick = async () => {
|
|
1243
|
-
const it = open1,
|
|
1244
|
-
r = iceReply;
|
|
1245
|
-
r.again = true;
|
|
1246
|
-
openSources();
|
|
1247
|
-
const j = await post("/reply", { op: "draft", dir: it.dir, id: it.id, style: rStyle(it.dir), avoid: r.text });
|
|
1248
|
-
if (iceReply !== r) return;
|
|
1249
|
-
r.again = false;
|
|
1250
|
-
if (j.text) r.text = j.text;
|
|
1251
|
-
r.note = j.ok ? j.note || "" : "";
|
|
1252
|
-
openSources().then(() => $("ice-reply")?.focus());
|
|
1253
|
-
};
|
|
1254
|
-
if ($("ice-reply")) {
|
|
1255
|
-
const ta = $("ice-reply");
|
|
1256
|
-
ta.oninput = () => {
|
|
1257
|
-
iceReply.text = ta.value;
|
|
1258
|
-
$("ice-rn").textContent = `${ta.value.length} chars`;
|
|
1259
|
-
$("ice-rs").disabled = !ta.value.trim();
|
|
1260
|
-
};
|
|
1261
|
-
ta.onkeydown = (e) => {
|
|
1262
|
-
if (e.key === "Escape") {
|
|
1263
|
-
e.stopPropagation();
|
|
1264
|
-
$("ice-rc").click();
|
|
1265
|
-
}
|
|
1266
|
-
};
|
|
1267
|
-
$("ice-rc").onclick = () => {
|
|
1268
|
-
iceReply = null;
|
|
1269
|
-
openSources();
|
|
1270
|
-
};
|
|
1271
|
-
$("ice-rs").onclick = async () => {
|
|
1272
|
-
const it = open1,
|
|
1273
|
-
r = iceReply;
|
|
1274
|
-
r.busy = true;
|
|
1275
|
-
openSources();
|
|
1276
|
-
const j = await post("/reply", { op: "send", dir: it.dir, id: it.id, text: r.text });
|
|
1277
|
-
if (j.ok) {
|
|
1278
|
-
iceReply = null;
|
|
1279
|
-
toast("Reply posted");
|
|
1280
|
-
} else if (j.sent) iceReply = null;
|
|
1281
|
-
else r.busy = false;
|
|
1282
|
-
load();
|
|
1283
|
-
if (srcOpen()) openSources();
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
// Ask for a draft; when it comes, fill the form only where the person has not typed.
|
|
1288
|
-
async function taskDraft(it) {
|
|
1289
|
-
const k = iceKey(it),
|
|
1290
|
-
before = { title: $("ice-title")?.dataset.k === k ? $("ice-title").value : it.text, details: $("ice-title")?.dataset.k === k ? $("ice-details").value : "" };
|
|
1291
|
-
iceTask = { k, wait: true, title: iceTask?.k === k ? iceTask.title : "", details: iceTask?.k === k ? iceTask.details : "" };
|
|
1292
|
-
const r = await fetch("/icebox", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ op: "task-draft", dir: it.dir, ids: [it.id] }) })
|
|
1293
|
-
.then((x) => x.json())
|
|
1294
|
-
.catch(() => ({ error: "kaizen did not answer" }));
|
|
1295
|
-
if (!iceTask || iceTask.k !== k) return;
|
|
1296
|
-
if (r.ok && r.title) {
|
|
1297
|
-
const ti = $("ice-title"), de = $("ice-details");
|
|
1298
|
-
const untouched = !ti || ti.dataset.k !== k || (ti.value === before.title && de.value === before.details);
|
|
1299
|
-
iceTask = { k, wait: false, title: r.title, details: r.details || "" };
|
|
1300
|
-
if (ti && ti.dataset.k === k && untouched) {
|
|
1301
|
-
ti.value = r.title;
|
|
1302
|
-
de.value = r.details || "";
|
|
1303
|
-
} else if (ti && ti.dataset.k === k) iceTask = { k, wait: false, title: ti.value, details: de.value, kept: true };
|
|
1304
|
-
} else iceTask = { k, wait: false, title: "", details: "", note: r.error || r.note || "ChatGPT did not answer" };
|
|
1305
|
-
if (srcOpen() && iceForm === k) openSources();
|
|
1306
|
-
}
|
|
1307
|
-
if ($("ice-td") && open1)
|
|
1308
|
-
$("ice-td").onclick = () => {
|
|
1309
|
-
iceTask = null;
|
|
1310
|
-
taskDraft(open1);
|
|
1311
|
-
openSources();
|
|
1312
|
-
};
|
|
1313
|
-
if ($("ice-ok")) {
|
|
1314
|
-
const ok = () => {
|
|
1315
|
-
const title = $("ice-title").value.trim();
|
|
1316
|
-
if (!title) {
|
|
1317
|
-
$("ice-title").focus();
|
|
1318
|
-
return;
|
|
1319
|
-
}
|
|
1320
|
-
$("ice-ok").disabled = true;
|
|
1321
|
-
iceAct("promote", open1, "Promoted to Tasks", { text: title, details: $("ice-details").value });
|
|
1322
|
-
};
|
|
1323
|
-
$("ice-ok").onclick = ok;
|
|
1324
|
-
$("ice-cancel").onclick = () => {
|
|
1325
|
-
icePro = null;
|
|
1326
|
-
openSources();
|
|
1327
|
-
};
|
|
1328
|
-
$("ice-title").onkeydown = (e) => {
|
|
1329
|
-
if (e.key === "Enter") ok();
|
|
1330
|
-
if (e.key === "Escape") $("ice-cancel").click();
|
|
1331
|
-
};
|
|
1332
|
-
$("ice-details").onkeydown = (e) => {
|
|
1333
|
-
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) ok();
|
|
1334
|
-
if (e.key === "Escape") $("ice-cancel").click();
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
// Swipe: a decision flies the card off, clicks (when the board's sound is on), then posts.
|
|
1338
|
-
const swGo = async (op) => {
|
|
1339
|
-
const S = iceSwipe,
|
|
1340
|
-
i = deck[0];
|
|
1341
|
-
if (!S || S.busy || i === undefined) return;
|
|
1342
|
-
const it = ice[i],
|
|
1343
|
-
k = iceKey(it);
|
|
1344
|
-
if (op === "skip") {
|
|
1345
|
-
if (deck.length < 2) return;
|
|
1346
|
-
S.skip.set(k, Math.max(...deck.map((x) => S.skip.get(iceKey(ice[x])) || 0)) + 1);
|
|
1347
|
-
return openSources();
|
|
1348
|
-
}
|
|
1349
|
-
S.busy = true;
|
|
1350
|
-
const c = $("sw-card");
|
|
1351
|
-
if (c && motion()) {
|
|
1352
|
-
lift(c);
|
|
1353
|
-
const dir = op === "promote" ? 1 : -1;
|
|
1354
|
-
await c
|
|
1355
|
-
.animate([{ transform: getComputedStyle(c).transform }, { transform: `translateX(${dir * innerWidth}px) rotate(${dir * 30}deg)`, opacity: 0 }], {
|
|
1356
|
-
duration: 320,
|
|
1357
|
-
easing: "cubic-bezier(.3,.6,.4,1)",
|
|
1358
|
-
fill: "forwards",
|
|
1359
|
-
})
|
|
1360
|
-
.finished.catch(() => {});
|
|
1361
|
-
}
|
|
1362
|
-
if (soundPick() !== "off") playSound("pop");
|
|
1363
|
-
const j = await post("/icebox", { op, dir: it.dir, ids: [it.id] });
|
|
1364
|
-
S.busy = false;
|
|
1365
|
-
if (j.ok) {
|
|
1366
|
-
S.n++;
|
|
1367
|
-
op === "promote" ? S.pro++ : S.dis++;
|
|
1368
|
-
// Only a dismiss can be undone here: a promote has already made a task card.
|
|
1369
|
-
S.last = op === "dismiss" ? it : null;
|
|
1370
|
-
S.pop = true;
|
|
1371
|
-
} else toast(`Could not ${op}: ${j.error || "kaizen did not answer"}`);
|
|
1372
|
-
load();
|
|
1373
|
-
if (srcOpen()) openSources();
|
|
1374
|
-
};
|
|
1375
|
-
const swUndo = async () => {
|
|
1376
|
-
const S = iceSwipe,
|
|
1377
|
-
it = S && S.last;
|
|
1378
|
-
if (!it || S.busy) return;
|
|
1379
|
-
S.busy = true;
|
|
1380
|
-
const j = await post("/icebox", { op: "restore", dir: it.dir, ids: [it.id] });
|
|
1381
|
-
S.busy = false;
|
|
1382
|
-
if (j.ok) {
|
|
1383
|
-
S.n--;
|
|
1384
|
-
S.dis--;
|
|
1385
|
-
S.last = null;
|
|
1386
|
-
S.skip.set(iceKey(it), -1);
|
|
1387
|
-
toast("Restored");
|
|
1388
|
-
}
|
|
1389
|
-
load();
|
|
1390
|
-
if (srcOpen()) openSources();
|
|
1391
|
-
};
|
|
1392
|
-
const swExit = () => {
|
|
1393
|
-
iceSwipe = null;
|
|
1394
|
-
openSources().then(focusCur);
|
|
1395
|
-
};
|
|
1396
|
-
// Phone rows: drag right to make a task, left to dismiss (Undo on the toast), hold to snooze.
|
|
1397
|
-
// The page keeps scrolling: a drag counts only once it is mostly sideways (touch-action: pan-y
|
|
1398
|
-
// hands every vertical move to the browser, which cancels the pointer).
|
|
1399
|
-
const undoDismiss = (it) => {
|
|
1400
|
-
const t = $("toast"),
|
|
1401
|
-
u = document.createElement("button");
|
|
1402
|
-
u.type = "button";
|
|
1403
|
-
u.className = "ice-undo";
|
|
1404
|
-
u.textContent = "Undo";
|
|
1405
|
-
u.onclick = async () => {
|
|
1406
|
-
t.classList.remove("on");
|
|
1407
|
-
if ((await post("/icebox", { op: "restore", dir: it.dir, ids: [it.id] })).ok) {
|
|
1408
|
-
iceCur = iceKey(it);
|
|
1409
|
-
toast("Back in the icebox");
|
|
1410
|
-
}
|
|
1411
|
-
load();
|
|
1412
|
-
if (srcOpen()) openSources();
|
|
1413
|
-
};
|
|
1414
|
-
t.classList.add("rep");
|
|
1415
|
-
t.append(" · ", u);
|
|
1416
|
-
};
|
|
1417
|
-
const rowGo = async (r, it, op) => {
|
|
1418
|
-
r.classList.add("gone");
|
|
1419
|
-
r.style.setProperty("--to", (op === "promote" ? 1 : -1) * r.offsetWidth + "px");
|
|
1420
|
-
if (motion()) await new Promise((ok) => setTimeout(ok, 180));
|
|
1421
|
-
if (soundPick() !== "off") playSound("pop");
|
|
1422
|
-
stepPast(new Set([iceKey(it)]));
|
|
1423
|
-
const j = await post("/icebox", { op, dir: it.dir, ids: [it.id] });
|
|
1424
|
-
if (j.ok) {
|
|
1425
|
-
toast(op === "promote" ? "Made a task" : "Dismissed");
|
|
1426
|
-
if (op === "dismiss") undoDismiss(it);
|
|
1427
|
-
}
|
|
1428
|
-
load();
|
|
1429
|
-
if (srcOpen()) openSources();
|
|
1430
|
-
};
|
|
1431
|
-
$("pbody")
|
|
1432
|
-
.querySelectorAll(".ice-prow[data-swipe]")
|
|
1433
|
-
.forEach((r) => {
|
|
1434
|
-
const f = r.querySelector(".ice-pf"),
|
|
1435
|
-
it = ice[+r.dataset.i];
|
|
1436
|
-
f.onpointerdown = (e) => {
|
|
1437
|
-
if (e.button || r.classList.contains("gone") || e.target.closest(".ice-ptask,.ice-kb,a,input,summary,.ice-mpop")) return;
|
|
1438
|
-
const x0 = e.clientX,
|
|
1439
|
-
y0 = e.clientY;
|
|
1440
|
-
let dx = 0,
|
|
1441
|
-
mode = "";
|
|
1442
|
-
// A tap after a drag or a hold must not also open the row.
|
|
1443
|
-
// A hold redraws the page under the finger, so the click that follows its release lands on
|
|
1444
|
-
// the new menu: it is eaten on the whole document until just after that release.
|
|
1445
|
-
const eat = () => {
|
|
1446
|
-
const k = (c) => {
|
|
1447
|
-
c.stopPropagation();
|
|
1448
|
-
c.preventDefault();
|
|
1449
|
-
};
|
|
1450
|
-
document.addEventListener("click", k, { capture: true, once: true });
|
|
1451
|
-
let gone = false;
|
|
1452
|
-
const off = () => {
|
|
1453
|
-
if (gone) return;
|
|
1454
|
-
gone = true;
|
|
1455
|
-
document.removeEventListener("pointerup", off, { capture: true });
|
|
1456
|
-
document.removeEventListener("pointercancel", off, { capture: true });
|
|
1457
|
-
setTimeout(() => document.removeEventListener("click", k, { capture: true }), 60);
|
|
1458
|
-
};
|
|
1459
|
-
if (mode === "hold") {
|
|
1460
|
-
// Released, cancelled by the browser, or left far too long: the blocker goes either way.
|
|
1461
|
-
document.addEventListener("pointerup", off, { capture: true });
|
|
1462
|
-
document.addEventListener("pointercancel", off, { capture: true });
|
|
1463
|
-
setTimeout(off, 5000);
|
|
1464
|
-
} else off();
|
|
1465
|
-
};
|
|
1466
|
-
const hold = setTimeout(() => {
|
|
1467
|
-
if (mode) return;
|
|
1468
|
-
mode = "hold";
|
|
1469
|
-
eat();
|
|
1470
|
-
iceCur = iceKey(it);
|
|
1471
|
-
iceMenu = iceKey(it) + " snooze";
|
|
1472
|
-
navigator.vibrate?.(10);
|
|
1473
|
-
openSources().then(() => $("pbody").querySelector(".ice-mpop button")?.focus());
|
|
1474
|
-
}, 500);
|
|
1475
|
-
const reset = () => {
|
|
1476
|
-
f.style.transform = "";
|
|
1477
|
-
r.style.removeProperty("--p");
|
|
1478
|
-
delete r.dataset.dir;
|
|
1479
|
-
};
|
|
1480
|
-
const end = (cancel) => {
|
|
1481
|
-
clearTimeout(hold);
|
|
1482
|
-
f.onpointermove = f.onpointerup = f.onpointercancel = null;
|
|
1483
|
-
if (mode !== "drag") return;
|
|
1484
|
-
r.classList.remove("drag");
|
|
1485
|
-
swHeld = false;
|
|
1486
|
-
const late = swLate;
|
|
1487
|
-
swLate = false;
|
|
1488
|
-
eat();
|
|
1489
|
-
if (!cancel && Math.abs(dx) > r.offsetWidth * 0.35) rowGo(r, it, dx > 0 ? "promote" : "dismiss");
|
|
1490
|
-
else {
|
|
1491
|
-
reset();
|
|
1492
|
-
if (late) openSources();
|
|
1493
|
-
}
|
|
1494
|
-
};
|
|
1495
|
-
f.onpointermove = (m) => {
|
|
1496
|
-
const mx = m.clientX - x0,
|
|
1497
|
-
my = m.clientY - y0;
|
|
1498
|
-
if (!mode) {
|
|
1499
|
-
if (Math.hypot(mx, my) > 8) clearTimeout(hold);
|
|
1500
|
-
if (Math.abs(mx) > 10 && Math.abs(mx) > Math.abs(my)) {
|
|
1501
|
-
mode = "drag";
|
|
1502
|
-
f.setPointerCapture(m.pointerId);
|
|
1503
|
-
r.classList.add("drag");
|
|
1504
|
-
swHeld = true;
|
|
1505
|
-
} else if (Math.abs(my) > 10) mode = "scroll";
|
|
1506
|
-
}
|
|
1507
|
-
if (mode !== "drag") return;
|
|
1508
|
-
dx = mx;
|
|
1509
|
-
f.style.transform = `translateX(${dx}px)`;
|
|
1510
|
-
r.dataset.dir = dx > 0 ? "pro" : "dis";
|
|
1511
|
-
r.style.setProperty("--p", String(Math.min(1, Math.abs(dx) / (r.offsetWidth * 0.35))));
|
|
1512
|
-
};
|
|
1513
|
-
f.onpointerup = () => end(false);
|
|
1514
|
-
f.onpointercancel = () => end(true);
|
|
1515
|
-
};
|
|
1516
|
-
});
|
|
1517
|
-
if ($("ice-sw"))
|
|
1518
|
-
$("ice-sw").onclick = () => {
|
|
1519
|
-
iceSwipe = { n: 0, pro: 0, dis: 0, t0: Date.now(), last: null, skip: new Map(), busy: false, pop: false };
|
|
1520
|
-
openSources().then(() => $("sw-card")?.focus());
|
|
1521
|
-
};
|
|
1522
|
-
if ($("sw-x")) $("sw-x").onclick = swExit;
|
|
1523
|
-
if ($("sw-back")) $("sw-back").onclick = swExit;
|
|
1524
|
-
if ($("sw-d")) $("sw-d").onclick = () => swGo("dismiss");
|
|
1525
|
-
if ($("sw-p")) $("sw-p").onclick = () => swGo("promote");
|
|
1526
|
-
if ($("sw-s")) $("sw-s").onclick = () => swGo("skip");
|
|
1527
|
-
if ($("sw-u")) $("sw-u").onclick = swUndo;
|
|
1528
|
-
// A held or flying card is fixed to the window where it sits, so the panel's scroll box
|
|
1529
|
-
// and the page's own overflow cannot crop it on the way out.
|
|
1530
|
-
const lift = (c) => {
|
|
1531
|
-
if (c.classList.contains("lift")) return;
|
|
1532
|
-
const r = c.getBoundingClientRect();
|
|
1533
|
-
Object.assign(c.style, { left: r.left + "px", top: r.top + "px", width: r.width + "px", height: r.height + "px" });
|
|
1534
|
-
c.classList.add("lift");
|
|
1535
|
-
};
|
|
1536
|
-
const drop = (c) => {
|
|
1537
|
-
c.classList.remove("lift");
|
|
1538
|
-
for (const k of ["left", "top", "width", "height", "transform"]) c.style.removeProperty(k);
|
|
1539
|
-
c.style.removeProperty("--p");
|
|
1540
|
-
};
|
|
1541
|
-
// Drag: the card follows the pointer and tilts; past 100 px it decides, short of that it
|
|
1542
|
-
// springs back. --p (-1..1) fades the stamp in. Controls inside the card still click.
|
|
1543
|
-
const card = $("sw-card");
|
|
1544
|
-
if (card)
|
|
1545
|
-
card.onpointerdown = (e) => {
|
|
1546
|
-
if (e.button || e.target.closest("a,button,summary,details")) return;
|
|
1547
|
-
const x0 = e.clientX;
|
|
1548
|
-
let dx = 0;
|
|
1549
|
-
card.setPointerCapture(e.pointerId);
|
|
1550
|
-
card.classList.add("drag");
|
|
1551
|
-
lift(card);
|
|
1552
|
-
swHeld = true;
|
|
1553
|
-
card.onpointermove = (m) => {
|
|
1554
|
-
dx = m.clientX - x0;
|
|
1555
|
-
// Tilt by share of the card's width: a wide desktop card leans as much as a phone one.
|
|
1556
|
-
card.style.transform = `translateX(${dx}px) rotate(${(dx / card.offsetWidth) * 18}deg)`;
|
|
1557
|
-
card.style.setProperty("--p", String(Math.max(-1, Math.min(1, dx / 100))));
|
|
1558
|
-
};
|
|
1559
|
-
card.onpointerup = card.onpointercancel = () => {
|
|
1560
|
-
card.onpointermove = card.onpointerup = card.onpointercancel = null;
|
|
1561
|
-
card.classList.remove("drag");
|
|
1562
|
-
swHeld = false;
|
|
1563
|
-
const late = swLate;
|
|
1564
|
-
swLate = false;
|
|
1565
|
-
if (Math.abs(dx) > 100) swGo(dx > 0 ? "promote" : "dismiss");
|
|
1566
|
-
else {
|
|
1567
|
-
const from = card.style.transform;
|
|
1568
|
-
card.style.removeProperty("--p");
|
|
1569
|
-
const a = motion() && from ? card.animate([{ transform: from }, { transform: "none" }], { duration: 260, easing: "cubic-bezier(.3,1.4,.5,1)" }) : null;
|
|
1570
|
-
card.style.transform = "";
|
|
1571
|
-
(a ? a.finished.catch(() => {}) : Promise.resolve()).then(() => {
|
|
1572
|
-
drop(card);
|
|
1573
|
-
if (late) openSources();
|
|
1574
|
-
});
|
|
1575
|
-
}
|
|
1576
|
-
};
|
|
1577
|
-
};
|
|
1578
|
-
// Keys, read by the page's keydown while the icebox shows. True when the key was used.
|
|
1579
|
-
iceNav = (e) => {
|
|
1580
|
-
if (e.altKey || e.ctrlKey || e.metaKey) return false;
|
|
1581
|
-
const k = e.key;
|
|
1582
|
-
if (iceSwipe) {
|
|
1583
|
-
if (k === "Escape" && $("src-sec")?.classList.contains("open")) {
|
|
1584
|
-
srcShut();
|
|
1585
|
-
return true;
|
|
1586
|
-
}
|
|
1587
|
-
const f = { ArrowLeft: () => swGo("dismiss"), ArrowRight: () => swGo("promote"), ArrowDown: () => swGo("skip"), z: swUndo, Escape: swExit }[k];
|
|
1588
|
-
if (!f) return false;
|
|
1589
|
-
e.preventDefault();
|
|
1590
|
-
f();
|
|
1591
|
-
return true;
|
|
1592
|
-
}
|
|
1593
|
-
const
|
|
1594
|
-
at = order.findIndex((i) => iceKey(ice[i]) === iceCur),
|
|
1595
|
-
i = order[at];
|
|
1596
|
-
if (k === "Escape") {
|
|
1597
|
-
if ($("src-sec")?.classList.contains("open")) {
|
|
1598
|
-
srcShut();
|
|
1599
|
-
return true;
|
|
1600
|
-
}
|
|
1601
|
-
if (iceMenu) {
|
|
1602
|
-
iceMenu = "";
|
|
1603
|
-
openSources().then(focusCur);
|
|
1604
|
-
return true;
|
|
1605
|
-
}
|
|
1606
|
-
if (iceForm) {
|
|
1607
|
-
if (icePro) icePro = null;
|
|
1608
|
-
else iceForm = null;
|
|
1609
|
-
openSources();
|
|
1610
|
-
return true;
|
|
1611
|
-
}
|
|
1612
|
-
if (iceSel.size) {
|
|
1613
|
-
iceSel.clear();
|
|
1614
|
-
openSources();
|
|
1615
|
-
return true;
|
|
1616
|
-
}
|
|
1617
|
-
return false;
|
|
1618
|
-
}
|
|
1619
|
-
if (at < 0) return false;
|
|
1620
|
-
if (k === "j" || k === "k") {
|
|
1621
|
-
e.preventDefault();
|
|
1622
|
-
const n = order[Math.max(0, Math.min(order.length - 1, at + (k === "j" ? 1 : -1)))];
|
|
1623
|
-
iceCur = iceKey(ice[n]);
|
|
1624
|
-
$("pbody")
|
|
1625
|
-
.querySelectorAll(".ice-row,.ice-card")
|
|
1626
|
-
.forEach((r) => r.classList.toggle("cur", +r.dataset.i === n));
|
|
1627
|
-
$("pbody").querySelector(`:is(.ice-row,.ice-card)[data-i="${n}"]`)?.scrollIntoView({ block: "nearest" });
|
|
1628
|
-
return true;
|
|
1629
|
-
}
|
|
1630
|
-
// h: snooze for a week, the selection when there is one.
|
|
1631
|
-
if (k === "h") {
|
|
1632
|
-
const its = iceSel.size ? ice.filter((it) => iceSel.has(iceKey(it)) && live(it)) : live(ice[i]) ? [ice[i]] : [];
|
|
1633
|
-
if (!its.length) return false;
|
|
1634
|
-
e.preventDefault();
|
|
1635
|
-
snoozeAll(its, "1w");
|
|
1636
|
-
return true;
|
|
1637
|
-
}
|
|
1638
|
-
const b =
|
|
1639
|
-
k === "o"
|
|
1640
|
-
? $("ice-o-" + i)
|
|
1641
|
-
: k === "x"
|
|
1642
|
-
? $("ice-ck-" + i)
|
|
1643
|
-
: k === "p"
|
|
1644
|
-
? iceSel.size
|
|
1645
|
-
? $("ice-bp")
|
|
1646
|
-
: $("ice-pr-" + i)
|
|
1647
|
-
: k === "d"
|
|
1648
|
-
? iceSel.size
|
|
1649
|
-
? $("ice-bd")
|
|
1650
|
-
: $("ice-ds-" + i)
|
|
1651
|
-
: null;
|
|
1652
|
-
if (!b || b.disabled) return false;
|
|
1653
|
-
e.preventDefault();
|
|
1654
|
-
b.click();
|
|
1655
|
-
return true;
|
|
1656
|
-
};
|
|
1657
|
-
$("pbody")
|
|
1658
|
-
.querySelectorAll("[data-chk]")
|
|
1659
|
-
.forEach((b) => {
|
|
1660
|
-
const s = list[+b.dataset.chk];
|
|
1661
|
-
b.onclick = () => {
|
|
1662
|
-
b.disabled = true;
|
|
1663
|
-
b.innerHTML = ico("refresh") + " Checking…";
|
|
1664
|
-
act({ op: "gather", dir: s.dir, url: s.url }, (j) => {
|
|
1665
|
-
const r = j.results && j.results[0];
|
|
1666
|
-
toast(
|
|
1667
|
-
r
|
|
1668
|
-
? r.ok
|
|
1669
|
-
? `${s.label || host(s.url)}: ${r.note}${r.added ? " in the icebox" : ""}`
|
|
1670
|
-
: `Failed: ${r.note}`
|
|
1671
|
-
: "Checked",
|
|
1672
|
-
);
|
|
1673
|
-
});
|
|
1674
|
-
};
|
|
1675
|
-
});
|
|
1676
|
-
// A social source is read by the agent, so Gather opens one on /kaizen gather.
|
|
1677
|
-
$("pbody")
|
|
1678
|
-
.querySelectorAll("[data-ag]")
|
|
1679
|
-
.forEach((b) => {
|
|
1680
|
-
const s = list[+b.dataset.ag];
|
|
1681
|
-
b.onclick = () => {
|
|
1682
|
-
b.disabled = true;
|
|
1683
|
-
if (chatOn) b.innerHTML = ico("refresh") + " Gathering…";
|
|
1684
|
-
act({ op: "agent", dir: s.dir, url: s.url }, (j) => {
|
|
1685
|
-
const r = j.results && j.results[0];
|
|
1686
|
-
toast(
|
|
1687
|
-
j.via === "chatgpt"
|
|
1688
|
-
? r && r.ok
|
|
1689
|
-
? `${s.label || host(s.url)}: ${r.note}${r.added ? " in the icebox" : ""}`
|
|
1690
|
-
: `Failed: ${r ? r.note : "no answer"}`
|
|
1691
|
-
: "/kaizen gather opened in your terminal: " + via(j.agent),
|
|
1692
|
-
);
|
|
1693
|
-
});
|
|
1694
|
-
};
|
|
1695
|
-
});
|
|
1696
|
-
$("pbody")
|
|
1697
|
-
.querySelectorAll("[data-rm]")
|
|
1698
|
-
.forEach((b) => {
|
|
1699
|
-
const s = list[+b.dataset.rm];
|
|
1700
|
-
b.onclick = () => {
|
|
1701
|
-
if (
|
|
1702
|
-
!confirm(
|
|
1703
|
-
`Remove ${s.label || host(s.url)}? What it gathered stays; added again later, it may bring back ones you deleted or dismissed.`,
|
|
1704
|
-
)
|
|
1705
|
-
)
|
|
1706
|
-
return;
|
|
1707
|
-
act({ op: "remove", dir: list[+b.dataset.rm].dir, url: list[+b.dataset.rm].url }, () =>
|
|
1708
|
-
toast("Source removed"),
|
|
1709
|
-
);
|
|
1710
|
-
};
|
|
1711
|
-
});
|
|
1712
|
-
// A row that went takes focus to the cursor row's title, never to whatever now holds its index.
|
|
1713
|
-
const ci = ice.findIndex((it) => iceKey(it) === iceCur);
|
|
1714
|
-
if (fPick) {
|
|
1715
|
-
const at = ice.findIndex((it) => iceKey(it) === fPick[0]);
|
|
1716
|
-
(at >= 0 ? $(fPick[1] + "-" + at) : ci >= 0 ? $("ice-o-" + ci) : null)?.focus();
|
|
1717
|
-
}
|
|
1718
|
-
const was = !fPick && typed[2] && $(typed[2]);
|
|
1719
|
-
if (was) (was.disabled ? $(was.id.replace("src-mb-", "src-mv-").replace("src-cs-", "src-ct-")) : was)?.focus();
|
|
1720
|
-
if ($("src-add")) {
|
|
1721
|
-
// A social source is a platform and what to follow; the server builds its link, and
|
|
1722
|
-
// nothing is gathered here: the agent reads it.
|
|
1723
|
-
$("src-add").onclick = () => {
|
|
1724
|
-
const social = srcKind === "social",
|
|
1725
|
-
url = $("src-url").value.trim(),
|
|
1726
|
-
q = $("src-q").value.trim(),
|
|
1727
|
-
plat = $("src-plat").value;
|
|
1728
|
-
if (social ? !q : !url) {
|
|
1729
|
-
$(social ? "src-q" : "src-url").focus();
|
|
1730
|
-
return;
|
|
1731
|
-
}
|
|
1732
|
-
const to = $("src-dir").value;
|
|
1733
|
-
if (!to) {
|
|
1734
|
-
$("src-dir").focus();
|
|
1735
|
-
return;
|
|
1736
|
-
}
|
|
1737
|
-
$("src-add").disabled = true;
|
|
1738
|
-
$("src-add").textContent = "Adding…";
|
|
1739
|
-
(async () => {
|
|
1740
|
-
const label = $("src-label").value.trim() || (social ? `${PLAT[plat]}: ${q}` : ""),
|
|
1741
|
-
category = $("src-cat").value.trim();
|
|
1742
|
-
const j = await post(
|
|
1743
|
-
"/sources",
|
|
1744
|
-
social
|
|
1745
|
-
? { op: "add", dir: to, platform: plat, query: q, label, category }
|
|
1746
|
-
: { op: "add", dir: to, url, label, category },
|
|
1747
|
-
);
|
|
1748
|
-
if (j.ok && social) {
|
|
1749
|
-
$("src-q").value = $("src-label").value = $("src-cat").value = "";
|
|
1750
|
-
toast("Source added");
|
|
1751
|
-
load();
|
|
1752
|
-
} else if (j.ok) {
|
|
1753
|
-
$("src-url").value = $("src-label").value = $("src-cat").value = "";
|
|
1754
|
-
const g = await post("/sources", { op: "gather", dir: to, url }),
|
|
1755
|
-
r = g.results && g.results[0];
|
|
1756
|
-
toast(r ? (r.ok ? `Source added: ${r.note} in the icebox` : `Source added, but: ${r.note}`) : "Source added");
|
|
1757
|
-
load();
|
|
1758
|
-
} else toast(j.error || "Could not add source");
|
|
1759
|
-
if (j.ok) srcAdd = false;
|
|
1760
|
-
if (srcOpen()) openSources();
|
|
1761
|
-
})();
|
|
1762
|
-
};
|
|
1763
|
-
$("src-url").onkeydown =
|
|
1764
|
-
$("src-q").onkeydown =
|
|
1765
|
-
$("src-label").onkeydown =
|
|
1766
|
-
$("src-cat").onkeydown =
|
|
1767
|
-
(e) => {
|
|
1768
|
-
if (e.key === "Enter") $("src-add").click();
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
if ($("src-go"))
|
|
1772
|
-
$("src-go").onclick = () => {
|
|
1773
|
-
$("src-go").disabled = true;
|
|
1774
|
-
$("src-go").innerHTML = ico("refresh") + " Gathering…";
|
|
1775
|
-
act({ op: "gather", dir: dir || undefined }, (j) => {
|
|
1776
|
-
const rs = j.results || [],
|
|
1777
|
-
soc = (r) => list.some((s) => s.url === r.url && s.social),
|
|
1778
|
-
n = rs.reduce((a, r) => a + r.added, 0),
|
|
1779
|
-
bad = rs.filter((r) => !r.ok && !soc(r)).length,
|
|
1780
|
-
ag = rs.filter(soc).length;
|
|
1781
|
-
toast(
|
|
1782
|
-
(n ? `${n} new in the icebox` : "Nothing new") +
|
|
1783
|
-
(bad ? `, ${bad} source${bad === 1 ? "" : "s"} could not be read` : "") +
|
|
1784
|
-
(ag ? `; ${ag} social for /kaizen gather` : ""),
|
|
1785
|
-
);
|
|
1786
|
-
});
|
|
1787
|
-
};
|
|
1788
|
-
}
|