painapple-code 1.0.0__py3-none-any.whl
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.
- painapple_code/__init__.py +30 -0
- painapple_code/__main__.py +18 -0
- painapple_code/_version.py +24 -0
- painapple_code/auth_middleware.py +930 -0
- painapple_code/cli/__init__.py +204 -0
- painapple_code/cli/deploy/__init__.py +15 -0
- painapple_code/cli/deploy/claude_seed.py +41 -0
- painapple_code/cli/deploy/config.py +260 -0
- painapple_code/cli/deploy/container.py +715 -0
- painapple_code/cli/deploy/launch.py +163 -0
- painapple_code/cli/deploy/runtime.py +223 -0
- painapple_code/cli/lifecycle_cmd.py +443 -0
- painapple_code/cli/list_cmd.py +572 -0
- painapple_code/cli/manage_cmd.py +670 -0
- painapple_code/cli/netinfo.py +125 -0
- painapple_code/cli/profiles.py +390 -0
- painapple_code/cli/serve_args.py +163 -0
- painapple_code/cli/serve_config.py +256 -0
- painapple_code/cli/setup_cmd.py +664 -0
- painapple_code/cli/ui.py +438 -0
- painapple_code/cost_analytics.py +879 -0
- painapple_code/data/models.defaults.yaml +18 -0
- painapple_code/data/models.yaml +18 -0
- painapple_code/data/presets.defaults.json +32 -0
- painapple_code/data/strings.yaml +2269 -0
- painapple_code/helpers.py +406 -0
- painapple_code/paths.py +1514 -0
- painapple_code/prompt_explorer.py +984 -0
- painapple_code/providers/__init__.py +224 -0
- painapple_code/providers/base.py +710 -0
- painapple_code/providers/claude/__init__.py +74 -0
- painapple_code/providers/claude/capabilities.py +218 -0
- painapple_code/providers/claude/errors.py +79 -0
- painapple_code/providers/claude/launch.py +50 -0
- painapple_code/providers/claude/summary.py +89 -0
- painapple_code/providers/claude/translate.py +74 -0
- painapple_code/providers/claude_sdk/__init__.py +139 -0
- painapple_code/providers/claude_sdk/driver.py +412 -0
- painapple_code/providers/codex/__init__.py +87 -0
- painapple_code/providers/codex/capabilities.py +321 -0
- painapple_code/providers/codex/errors.py +70 -0
- painapple_code/providers/codex/launch.py +142 -0
- painapple_code/providers/codex/summary.py +196 -0
- painapple_code/providers/codex/translate.py +204 -0
- painapple_code/providers/codex_app_server/__init__.py +100 -0
- painapple_code/providers/codex_app_server/capabilities.py +41 -0
- painapple_code/providers/codex_app_server/launch.py +202 -0
- painapple_code/providers/codex_app_server/summary.py +291 -0
- painapple_code/providers/codex_app_server/translate.py +263 -0
- painapple_code/providers/codex_app_server/transport.py +238 -0
- painapple_code/routes/__init__.py +0 -0
- painapple_code/routes/api_agents.py +441 -0
- painapple_code/routes/api_app.py +368 -0
- painapple_code/routes/api_app_commit_sections.py +127 -0
- painapple_code/routes/api_app_config.py +997 -0
- painapple_code/routes/api_app_session_prefs.py +217 -0
- painapple_code/routes/api_browser.py +690 -0
- painapple_code/routes/api_commands.py +374 -0
- painapple_code/routes/api_costs.py +128 -0
- painapple_code/routes/api_drafts.py +139 -0
- painapple_code/routes/api_exec.py +149 -0
- painapple_code/routes/api_files.py +542 -0
- painapple_code/routes/api_git.py +657 -0
- painapple_code/routes/api_logs.py +649 -0
- painapple_code/routes/api_plugins.py +275 -0
- painapple_code/routes/api_project_config.py +418 -0
- painapple_code/routes/api_prompts.py +231 -0
- painapple_code/routes/api_providers.py +53 -0
- painapple_code/routes/api_search.py +411 -0
- painapple_code/routes/api_session_stash.py +234 -0
- painapple_code/routes/api_session_welcome.py +151 -0
- painapple_code/routes/api_sessions.py +742 -0
- painapple_code/routes/api_shadow.py +323 -0
- painapple_code/routes/api_shadow_db.py +512 -0
- painapple_code/routes/api_shadow_files.py +332 -0
- painapple_code/routes/api_shadow_search.py +476 -0
- painapple_code/routes/api_skills.py +610 -0
- painapple_code/routes/api_tasks.py +147 -0
- painapple_code/routes/api_terminal.py +540 -0
- painapple_code/routes/api_upload.py +293 -0
- painapple_code/routes/api_viewer.py +229 -0
- painapple_code/routes/dependencies.py +109 -0
- painapple_code/routes/ws_chat.py +837 -0
- painapple_code/server.py +2208 -0
- painapple_code/server_logging.py +263 -0
- painapple_code/services/__init__.py +0 -0
- painapple_code/services/agent_session.py +2738 -0
- painapple_code/session_store.py +253 -0
- painapple_code/session_store_core.py +879 -0
- painapple_code/shadow_db.py +830 -0
- painapple_code/shadow_db_plans.py +369 -0
- painapple_code/shadow_db_queries.py +595 -0
- painapple_code/shadow_db_schema.py +676 -0
- painapple_code/shadow_git.py +1296 -0
- painapple_code/shadow_git_frontmatter.py +314 -0
- painapple_code/shadow_git_sections.py +520 -0
- painapple_code/shadow_git_summary.py +462 -0
- painapple_code/shadow_parser.py +560 -0
- painapple_code/static/css/00-variables.css +276 -0
- painapple_code/static/css/01-base.css +245 -0
- painapple_code/static/css/02-tooltips.css +36 -0
- painapple_code/static/css/09-left-rail.css +448 -0
- painapple_code/static/css/10-header.css +777 -0
- painapple_code/static/css/11-connection-bar.css +120 -0
- painapple_code/static/css/20-messages.css +750 -0
- painapple_code/static/css/21-tool-blocks.css +2340 -0
- painapple_code/static/css/22-edit-diff.css +619 -0
- painapple_code/static/css/23-thinking.css +1584 -0
- painapple_code/static/css/24-background-tasks.css +359 -0
- painapple_code/static/css/25-context-block.css +252 -0
- painapple_code/static/css/26-session-setup.css +144 -0
- painapple_code/static/css/30-markdown.css +854 -0
- painapple_code/static/css/40-input.css +2418 -0
- painapple_code/static/css/41-autocomplete.css +127 -0
- painapple_code/static/css/42-activity-strip.css +97 -0
- painapple_code/static/css/43-file-autocomplete.css +121 -0
- painapple_code/static/css/44-snippets-autocomplete.css +224 -0
- painapple_code/static/css/45-selection-bar.css +433 -0
- painapple_code/static/css/46-keyboard-bar.css +119 -0
- painapple_code/static/css/47-keyboard-longpress.css +116 -0
- painapple_code/static/css/47-token-profile.css +106 -0
- painapple_code/static/css/50-welcome.css +3095 -0
- painapple_code/static/css/51-modals.css +301 -0
- painapple_code/static/css/52-utilities.css +77 -0
- painapple_code/static/css/53-image-upload.css +456 -0
- painapple_code/static/css/54-todo-list.css +102 -0
- painapple_code/static/css/55-file-upload.css +113 -0
- painapple_code/static/css/56-chat-navigator.css +218 -0
- painapple_code/static/css/56-permission-card.css +332 -0
- painapple_code/static/css/56-plan-approval.css +204 -0
- painapple_code/static/css/56-question-form.css +602 -0
- painapple_code/static/css/57-swipe-indicator.css +95 -0
- painapple_code/static/css/58-session-families.css +627 -0
- painapple_code/static/css/59-about.css +196 -0
- painapple_code/static/css/61-log-explorer.css +723 -0
- painapple_code/static/css/62-json-tree.css +489 -0
- painapple_code/static/css/62-skills-widget.css +650 -0
- painapple_code/static/css/63-commands-widget.css +30 -0
- painapple_code/static/css/63-plugins-widget.css +174 -0
- painapple_code/static/css/63-terminal.css +516 -0
- painapple_code/static/css/64-search-files-widget.css +448 -0
- painapple_code/static/css/65-snippets-widget.css +426 -0
- painapple_code/static/css/66-active-sessions.css +979 -0
- painapple_code/static/css/66-agents-widget.css +265 -0
- painapple_code/static/css/66-file-explorer-widget.css +855 -0
- painapple_code/static/css/66-git-panel.css +791 -0
- painapple_code/static/css/66-history-explorer.css +1496 -0
- painapple_code/static/css/67-diff-viewer.css +602 -0
- painapple_code/static/css/67-editor-view.css +748 -0
- painapple_code/static/css/67-file-preview-widget.css +1873 -0
- painapple_code/static/css/68-browser-widget.css +337 -0
- painapple_code/static/css/68-compare-wizard.css +355 -0
- painapple_code/static/css/68-csv-preview.css +106 -0
- painapple_code/static/css/68-diff-preview.css +103 -0
- painapple_code/static/css/68-helpers-install-widget.css +491 -0
- painapple_code/static/css/68-image-annotate.css +346 -0
- painapple_code/static/css/68-terminal-view.css +98 -0
- painapple_code/static/css/68-uploads-widget.css +229 -0
- painapple_code/static/css/69-cost-analytics.css +537 -0
- painapple_code/static/css/70-config-panel.css +3736 -0
- painapple_code/static/css/70-excalidraw.css +136 -0
- painapple_code/static/css/70-prompt-explorer.css +890 -0
- painapple_code/static/css/71-chart.css +111 -0
- painapple_code/static/css/72-discussion-sidebar.css +678 -0
- painapple_code/static/css/74-debug-logs.css +656 -0
- painapple_code/static/css/80-open-dialog.css +146 -0
- painapple_code/static/css/80-quick-switcher.css +383 -0
- painapple_code/static/css/80-widget-system.css +1763 -0
- painapple_code/static/css/81-quick-actions.css +1020 -0
- painapple_code/static/css/82-context-popover.css +1233 -0
- painapple_code/static/css/83-context-menu.css +339 -0
- painapple_code/static/css/85-lazy-loading.css +102 -0
- painapple_code/static/css/86-zen-mode.css +708 -0
- painapple_code/static/css/87-grid-switcher.css +346 -0
- painapple_code/static/css/login.css +198 -0
- painapple_code/static/dist/app.bundle.js +7177 -0
- painapple_code/static/feature-triage.html +446 -0
- painapple_code/static/icons/apple-touch-icon.png +0 -0
- painapple_code/static/icons/favicon-32.png +0 -0
- painapple_code/static/icons/favicon.ico +0 -0
- painapple_code/static/icons/icon-128.png +0 -0
- painapple_code/static/icons/icon-144.png +0 -0
- painapple_code/static/icons/icon-152.png +0 -0
- painapple_code/static/icons/icon-180.png +0 -0
- painapple_code/static/icons/icon-192.png +0 -0
- painapple_code/static/icons/icon-384.png +0 -0
- painapple_code/static/icons/icon-512.png +0 -0
- painapple_code/static/icons/icon-72.png +0 -0
- painapple_code/static/icons/icon-96.png +0 -0
- painapple_code/static/js/action-delegate.js +187 -0
- painapple_code/static/js/activity-strip.js +193 -0
- painapple_code/static/js/app/context-menus.js +619 -0
- painapple_code/static/js/app/file-preview.js +163 -0
- painapple_code/static/js/app/init-ui.js +574 -0
- painapple_code/static/js/app/input-events.js +561 -0
- painapple_code/static/js/app/input-resize.js +313 -0
- painapple_code/static/js/app/message-actions.js +419 -0
- painapple_code/static/js/app/panels.js +210 -0
- painapple_code/static/js/app/rendering-delegators.js +246 -0
- painapple_code/static/js/app/server-loading.js +365 -0
- painapple_code/static/js/app/session-ops.js +287 -0
- painapple_code/static/js/app/session-switch.js +443 -0
- painapple_code/static/js/app/settings-helpers.js +280 -0
- painapple_code/static/js/app/startup-welcome.js +290 -0
- painapple_code/static/js/app-context.js +157 -0
- painapple_code/static/js/app.js +2134 -0
- painapple_code/static/js/auth-fetch.js +46 -0
- painapple_code/static/js/background-tasks.js +274 -0
- painapple_code/static/js/boot.js +73 -0
- painapple_code/static/js/caret-position.js +171 -0
- painapple_code/static/js/chat-navigator.js +710 -0
- painapple_code/static/js/chat-search.js +323 -0
- painapple_code/static/js/command-executor.js +176 -0
- painapple_code/static/js/command-store.js +497 -0
- painapple_code/static/js/components.js +1414 -0
- painapple_code/static/js/config.js +218 -0
- painapple_code/static/js/context-menu.js +740 -0
- painapple_code/static/js/controllers/chat-controller.js +4252 -0
- painapple_code/static/js/controllers/dialog-controller.js +217 -0
- painapple_code/static/js/controllers/tab-controller.js +1828 -0
- painapple_code/static/js/controllers/thinking-controller.js +915 -0
- painapple_code/static/js/diff-utils.js +486 -0
- painapple_code/static/js/drafts-pill.js +95 -0
- painapple_code/static/js/editor-view.js +815 -0
- painapple_code/static/js/effort-settings.js +430 -0
- painapple_code/static/js/feature-triage.js +811 -0
- painapple_code/static/js/file-autocomplete.js +516 -0
- painapple_code/static/js/file-tabs.js +123 -0
- painapple_code/static/js/gestures.js +448 -0
- painapple_code/static/js/grid-switcher.js +334 -0
- painapple_code/static/js/input-handler.js +1472 -0
- painapple_code/static/js/keyboard-bar.js +495 -0
- painapple_code/static/js/layout-switcher.js +109 -0
- painapple_code/static/js/linkify-utils.js +200 -0
- painapple_code/static/js/login.js +141 -0
- painapple_code/static/js/open-dialog.js +879 -0
- painapple_code/static/js/orphan-terminals.js +373 -0
- painapple_code/static/js/path-utils.js +179 -0
- painapple_code/static/js/perf-marks.js +102 -0
- painapple_code/static/js/permission-settings.js +475 -0
- painapple_code/static/js/pointer-input.js +59 -0
- painapple_code/static/js/preview/json-tree-menu.js +226 -0
- painapple_code/static/js/preview/json-tree-toolbar.js +291 -0
- painapple_code/static/js/preview/json-tree.js +457 -0
- painapple_code/static/js/preview/preview-breadcrumb.js +387 -0
- painapple_code/static/js/preview/preview-edit.js +367 -0
- painapple_code/static/js/preview/preview-events.js +361 -0
- painapple_code/static/js/preview/preview-history.js +567 -0
- painapple_code/static/js/preview/preview-inline-edit.js +869 -0
- painapple_code/static/js/preview/preview-poll.js +108 -0
- painapple_code/static/js/preview/preview-render.js +572 -0
- painapple_code/static/js/preview/preview-search.js +421 -0
- painapple_code/static/js/preview/preview-state.js +256 -0
- painapple_code/static/js/preview/preview-utils.js +251 -0
- painapple_code/static/js/preview-plugins/chart-plugin.js +22 -0
- painapple_code/static/js/preview-plugins/csv-plugin.js +188 -0
- painapple_code/static/js/preview-plugins/diff-plugin.js +258 -0
- painapple_code/static/js/preview-plugins/excalidraw-plugin.js +25 -0
- painapple_code/static/js/preview-plugins/html-plugin.js +104 -0
- painapple_code/static/js/preview-plugins/image-plugin.js +20 -0
- painapple_code/static/js/preview-plugins/index.js +34 -0
- painapple_code/static/js/preview-plugins/json-plugin.js +99 -0
- painapple_code/static/js/preview-plugins/jsonl-plugin.js +152 -0
- painapple_code/static/js/preview-plugins/markdown-plugin.js +266 -0
- painapple_code/static/js/preview-plugins/panzoom-plugin.js +63 -0
- painapple_code/static/js/preview-plugins/plugin-helpers.js +282 -0
- painapple_code/static/js/project-color-picker.js +110 -0
- painapple_code/static/js/project-colors.js +163 -0
- painapple_code/static/js/prompt-favorites.js +187 -0
- painapple_code/static/js/quick-actions-menu.js +1736 -0
- painapple_code/static/js/quick-actions-registry.js +1239 -0
- painapple_code/static/js/quick-switcher/controller.js +294 -0
- painapple_code/static/js/quick-switcher/fuzzy-scorer.js +123 -0
- painapple_code/static/js/quick-switcher/index.js +30 -0
- painapple_code/static/js/quick-switcher/providers/base-provider.js +51 -0
- painapple_code/static/js/quick-switcher/providers/command-provider.js +56 -0
- painapple_code/static/js/quick-switcher/providers/file-provider.js +291 -0
- painapple_code/static/js/quick-switcher/providers/panel-provider.js +132 -0
- painapple_code/static/js/quick-switcher/providers/project-provider.js +361 -0
- painapple_code/static/js/quick-switcher/providers/read-files-provider.js +104 -0
- painapple_code/static/js/quick-switcher/providers/skills-provider.js +129 -0
- painapple_code/static/js/quick-switcher/registry.js +69 -0
- painapple_code/static/js/quick-switcher/ui/item.js +54 -0
- painapple_code/static/js/quick-switcher/ui/picker.js +464 -0
- painapple_code/static/js/recent-opens.js +40 -0
- painapple_code/static/js/scroll-manager.js +530 -0
- painapple_code/static/js/scroll-state-machine.js +359 -0
- painapple_code/static/js/selection/action-bar.js +793 -0
- painapple_code/static/js/selection/index.js +15 -0
- painapple_code/static/js/selection/selection-handler.js +877 -0
- painapple_code/static/js/selection/state.js +181 -0
- painapple_code/static/js/session/agent-progress.js +202 -0
- painapple_code/static/js/session/handle-agent-message.js +481 -0
- painapple_code/static/js/session/handle-message.js +550 -0
- painapple_code/static/js/session/interactive.js +587 -0
- painapple_code/static/js/session/message-store.js +271 -0
- painapple_code/static/js/session/messages.js +253 -0
- painapple_code/static/js/session/persistence.js +179 -0
- painapple_code/static/js/session/restore.js +136 -0
- painapple_code/static/js/session/sync.js +333 -0
- painapple_code/static/js/session-container-pool.js +371 -0
- painapple_code/static/js/session-setup-panel.js +274 -0
- painapple_code/static/js/session.js +1047 -0
- painapple_code/static/js/shortcut-hints.js +272 -0
- painapple_code/static/js/shortcuts.js +1146 -0
- painapple_code/static/js/skills-autocomplete.js +262 -0
- painapple_code/static/js/snippets-autocomplete.js +738 -0
- painapple_code/static/js/stash-refs-view.js +83 -0
- painapple_code/static/js/stash-ui.js +768 -0
- painapple_code/static/js/stash.js +785 -0
- painapple_code/static/js/status-bar.js +1184 -0
- painapple_code/static/js/token-profile.js +274 -0
- painapple_code/static/js/tool-renderer-blocks.js +1626 -0
- painapple_code/static/js/tool-renderer-thinking.js +813 -0
- painapple_code/static/js/tool-renderer.js +1500 -0
- painapple_code/static/js/tooltips.js +197 -0
- painapple_code/static/js/upload-manager.js +1019 -0
- painapple_code/static/js/utils.js +521 -0
- painapple_code/static/js/welcome/api.js +363 -0
- painapple_code/static/js/welcome/cards.js +626 -0
- painapple_code/static/js/welcome/context-menu.js +585 -0
- painapple_code/static/js/welcome/families.js +801 -0
- painapple_code/static/js/welcome/preview.js +234 -0
- painapple_code/static/js/welcome/state.js +129 -0
- painapple_code/static/js/welcome.js +1874 -0
- painapple_code/static/js/widget-system/base-widget.js +717 -0
- painapple_code/static/js/widget-system/device-manager.js +178 -0
- painapple_code/static/js/widget-system/event-bus.js +152 -0
- painapple_code/static/js/widget-system/icons.js +120 -0
- painapple_code/static/js/widget-system/index.js +49 -0
- painapple_code/static/js/widget-system/init.js +54 -0
- painapple_code/static/js/widget-system/types/bottom-sheet.js +307 -0
- painapple_code/static/js/widget-system/types/floating.js +915 -0
- painapple_code/static/js/widget-system/types/index.js +40 -0
- painapple_code/static/js/widget-system/types/modal.js +147 -0
- painapple_code/static/js/widget-system/types/sidebar.js +158 -0
- painapple_code/static/js/widget-system/types/tab.js +146 -0
- painapple_code/static/js/widget-system/types/top-sheet.js +203 -0
- painapple_code/static/js/widget-system/widget-manager.js +1187 -0
- painapple_code/static/js/widgets/about-widget.js +260 -0
- painapple_code/static/js/widgets/active-sessions-widget.js +760 -0
- painapple_code/static/js/widgets/agents-widget.js +897 -0
- painapple_code/static/js/widgets/browser-widget.js +579 -0
- painapple_code/static/js/widgets/commands-widget.js +694 -0
- painapple_code/static/js/widgets/config/commit-sections.js +449 -0
- painapple_code/static/js/widgets/config/dir-autocomplete.js +224 -0
- painapple_code/static/js/widgets/config/gestures.js +161 -0
- painapple_code/static/js/widgets/config/models-tab.js +988 -0
- painapple_code/static/js/widgets/config/quick-actions-tab.js +882 -0
- painapple_code/static/js/widgets/config/shortcut-editor.js +587 -0
- painapple_code/static/js/widgets/config/state.js +517 -0
- painapple_code/static/js/widgets/config/system-controls.js +90 -0
- painapple_code/static/js/widgets/config-widget.js +1535 -0
- painapple_code/static/js/widgets/cost-analytics-widget.js +621 -0
- painapple_code/static/js/widgets/debug-widget.js +693 -0
- painapple_code/static/js/widgets/diff-viewer-widget.js +1420 -0
- painapple_code/static/js/widgets/discussion-widget.js +1107 -0
- painapple_code/static/js/widgets/file-explorer-widget.js +2166 -0
- painapple_code/static/js/widgets/file-preview-widget.js +861 -0
- painapple_code/static/js/widgets/git-widget.js +794 -0
- painapple_code/static/js/widgets/helpers-install-widget.js +720 -0
- painapple_code/static/js/widgets/history-explorer-widget.js +1804 -0
- painapple_code/static/js/widgets/image-annotate-widget.js +951 -0
- painapple_code/static/js/widgets/image-preview-widget.js +692 -0
- painapple_code/static/js/widgets/index.js +176 -0
- painapple_code/static/js/widgets/log-explorer-widget.js +1057 -0
- painapple_code/static/js/widgets/plugins-widget.js +305 -0
- painapple_code/static/js/widgets/prompt-explorer-widget.js +1119 -0
- painapple_code/static/js/widgets/search-files-widget.js +529 -0
- painapple_code/static/js/widgets/skills-widget.js +843 -0
- painapple_code/static/js/widgets/snippets-widget.js +479 -0
- painapple_code/static/js/widgets/sub-agents-widget.js +333 -0
- painapple_code/static/js/widgets/tasks-widget.js +379 -0
- painapple_code/static/js/widgets/terminal/connection.js +283 -0
- painapple_code/static/js/widgets/terminal/gestures.js +357 -0
- painapple_code/static/js/widgets/terminal/init.js +642 -0
- painapple_code/static/js/widgets/terminal/link-providers.js +532 -0
- painapple_code/static/js/widgets/terminal/osc52.js +213 -0
- painapple_code/static/js/widgets/terminal/render.js +159 -0
- painapple_code/static/js/widgets/terminal/size.js +54 -0
- painapple_code/static/js/widgets/terminal/state.js +211 -0
- painapple_code/static/js/widgets/terminal/wrap-utils.js +101 -0
- painapple_code/static/js/widgets/terminal-widget.js +793 -0
- painapple_code/static/js/widgets/uploads-widget.js +461 -0
- painapple_code/static/js/widgets/zen-widget.js +1001 -0
- painapple_code/static/login.html +51 -0
- painapple_code/static/manifest.json +73 -0
- painapple_code/static/sw.js +293 -0
- painapple_code/static/vendor/LICENSES.txt +769 -0
- painapple_code/static/vendor/README.md +103 -0
- painapple_code/static/vendor/codemirror.js +35 -0
- painapple_code/static/vendor/codemirror.js.LEGAL.txt +304 -0
- painapple_code/static/vendor/github-markdown-dark.min.css +1124 -0
- painapple_code/static/vendor/highlight-github-dark.min.css +10 -0
- painapple_code/static/vendor/highlight-lang-dockerfile.min.js +8 -0
- painapple_code/static/vendor/highlight-lang-nginx.min.js +21 -0
- painapple_code/static/vendor/highlight-lang-properties.min.js +10 -0
- painapple_code/static/vendor/highlight-lang-scala.min.js +28 -0
- painapple_code/static/vendor/highlight.min.js +1213 -0
- painapple_code/static/vendor/marked.min.js +6 -0
- painapple_code/static/vendor/purify.min.js +3 -0
- painapple_code/static/vendor/xterm-addon-fit.js +2 -0
- painapple_code/static/vendor/xterm.css +209 -0
- painapple_code/static/vendor/xterm.js +2 -0
- painapple_code/static/web-client.html +635 -0
- painapple_code/subprocess_registry.py +535 -0
- painapple_code/tls_cert.py +79 -0
- painapple_code/tools/agents/shadow-git-helper.md +400 -0
- painapple_code/tools/excalidraw-to-svg.js +143 -0
- painapple_code/tools/install-helpers.sh +148 -0
- painapple_code/tools/shadow-git +320 -0
- painapple_code/tools/shadow-query +120 -0
- painapple_code/tools/vegalite-to-svg.js +79 -0
- painapple_code/turn_query.py +766 -0
- painapple_code/turn_tracker.py +221 -0
- painapple_code/utils/__init__.py +0 -0
- painapple_code/utils/agent_cli.py +306 -0
- painapple_code/utils/chart.py +103 -0
- painapple_code/utils/excalidraw.py +107 -0
- painapple_code/utils/file_lock.py +162 -0
- painapple_code/utils/file_paths.py +648 -0
- painapple_code/utils/generate_icons.py +251 -0
- painapple_code/utils/proc.py +205 -0
- painapple_code/utils/pty_backend.py +59 -0
- painapple_code/utils/pty_posix.py +160 -0
- painapple_code/utils/pty_windows.py +245 -0
- painapple_code/utils/token_profiles.py +91 -0
- painapple_code/viewer_templates.py +657 -0
- painapple_code/welcome_search.py +879 -0
- painapple_code-1.0.0.dist-info/METADATA +292 -0
- painapple_code-1.0.0.dist-info/RECORD +436 -0
- painapple_code-1.0.0.dist-info/WHEEL +5 -0
- painapple_code-1.0.0.dist-info/entry_points.txt +2 -0
- painapple_code-1.0.0.dist-info/licenses/LICENSE +661 -0
- painapple_code-1.0.0.dist-info/licenses/THIRD_PARTY_NOTICES.md +261 -0
- painapple_code-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1001 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zen Mode Widget — OLED-optimized focus view
|
|
3
|
+
*
|
|
4
|
+
* Fullscreen overlay with three views:
|
|
5
|
+
* Map — SVG mind map of session work (files, tools, prompts)
|
|
6
|
+
* Review — Clean text summary with stats
|
|
7
|
+
* Act — Decision buttons (continue, commit, new, exit)
|
|
8
|
+
*
|
|
9
|
+
* Designed for dark rooms with OLED displays. Pure black background,
|
|
10
|
+
* warm amber accents, minimal chrome.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import S from '../strings.js';
|
|
14
|
+
import { escapeHtml } from '../utils.js';
|
|
15
|
+
import { showToast } from '../context-menu.js';
|
|
16
|
+
import { engineAuthorLabel } from '../status-bar.js';
|
|
17
|
+
import { basename } from '../path-utils.js';
|
|
18
|
+
|
|
19
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
20
|
+
// SVG Icons (inline to avoid dependencies)
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
const ICONS = {
|
|
24
|
+
x: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',
|
|
25
|
+
moon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>',
|
|
26
|
+
play: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="5 3 19 12 5 21 5 3"/></svg>',
|
|
27
|
+
gitCommit: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="4"/><line x1="1.05" y1="12" x2="7" y2="12"/><line x1="17.01" y1="12" x2="22.96" y2="12"/></svg>',
|
|
28
|
+
plus: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>',
|
|
29
|
+
gitDiff: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 3v18M3 12h18"/><rect x="3" y="3" width="18" height="18" rx="2"/></svg>',
|
|
30
|
+
file: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',
|
|
31
|
+
compass: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76"/></svg>',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
35
|
+
// State
|
|
36
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
let overlayEl = null;
|
|
39
|
+
let activeTab = 'map';
|
|
40
|
+
let sessionData = null;
|
|
41
|
+
let selectedNode = null;
|
|
42
|
+
let detailCard = null;
|
|
43
|
+
|
|
44
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
45
|
+
// Data Extraction
|
|
46
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Extract structured session data from the active session's messages.
|
|
50
|
+
* Builds a graph of turns, files, and tools for the mind map.
|
|
51
|
+
*/
|
|
52
|
+
function extractSessionData(session) {
|
|
53
|
+
if (!session?.messages?.length) return null;
|
|
54
|
+
|
|
55
|
+
const turns = [];
|
|
56
|
+
const allFiles = new Map(); // path → {action, turns}
|
|
57
|
+
const allTools = new Map(); // name → count
|
|
58
|
+
let currentTurn = null;
|
|
59
|
+
|
|
60
|
+
for (const msg of session.messages) {
|
|
61
|
+
// User prompt starts a new turn
|
|
62
|
+
if (msg.role === 'user' && typeof msg.content === 'string' && msg.content.trim()) {
|
|
63
|
+
currentTurn = {
|
|
64
|
+
index: turns.length,
|
|
65
|
+
prompt: msg.content.trim(),
|
|
66
|
+
files: new Map(),
|
|
67
|
+
tools: new Map(),
|
|
68
|
+
summary: '',
|
|
69
|
+
};
|
|
70
|
+
turns.push(currentTurn);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Thinking blocks contain tool usage
|
|
74
|
+
if (msg.role === 'thinking' && msg.tools && currentTurn) {
|
|
75
|
+
for (const tool of msg.tools) {
|
|
76
|
+
const name = tool.toolName || tool.tool_name || '';
|
|
77
|
+
if (!name) continue;
|
|
78
|
+
currentTurn.tools.set(name, (currentTurn.tools.get(name) || 0) + 1);
|
|
79
|
+
allTools.set(name, (allTools.get(name) || 0) + 1);
|
|
80
|
+
|
|
81
|
+
const fp = tool.toolInput?.file_path || tool.tool_input?.file_path;
|
|
82
|
+
if (fp) {
|
|
83
|
+
const action = (name === 'Write' || name === 'Edit') ? 'edited'
|
|
84
|
+
: name === 'Read' ? 'read' : 'used';
|
|
85
|
+
currentTurn.files.set(fp, action);
|
|
86
|
+
if (!allFiles.has(fp) || action === 'edited') {
|
|
87
|
+
allFiles.set(fp, { action, turn: currentTurn.index });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Tool messages (standalone)
|
|
94
|
+
if (msg.role === 'tool' && currentTurn) {
|
|
95
|
+
const name = msg.toolName || msg.tool_name || '';
|
|
96
|
+
if (name) {
|
|
97
|
+
currentTurn.tools.set(name, (currentTurn.tools.get(name) || 0) + 1);
|
|
98
|
+
allTools.set(name, (allTools.get(name) || 0) + 1);
|
|
99
|
+
}
|
|
100
|
+
const fp = msg.toolInput?.file_path || msg.tool_input?.file_path;
|
|
101
|
+
if (fp) {
|
|
102
|
+
const action = (name === 'Write' || name === 'Edit') ? 'edited'
|
|
103
|
+
: name === 'Read' ? 'read' : 'used';
|
|
104
|
+
currentTurn.files.set(fp, action);
|
|
105
|
+
if (!allFiles.has(fp) || action === 'edited') {
|
|
106
|
+
allFiles.set(fp, { action, turn: currentTurn.index });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Turn summary messages
|
|
112
|
+
if (msg.role === 'turn_summary' && currentTurn) {
|
|
113
|
+
if (msg.changedFiles) {
|
|
114
|
+
for (const f of msg.changedFiles) {
|
|
115
|
+
const fp = typeof f === 'string' ? f : f.path || f.file;
|
|
116
|
+
if (fp) {
|
|
117
|
+
currentTurn.files.set(fp, 'edited');
|
|
118
|
+
allFiles.set(fp, { action: 'edited', turn: currentTurn.index });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Assistant text → turn summary
|
|
125
|
+
if (msg.role === 'assistant' && currentTurn && !currentTurn.summary) {
|
|
126
|
+
const text = typeof msg.content === 'string' ? msg.content
|
|
127
|
+
: Array.isArray(msg.content)
|
|
128
|
+
? msg.content.find(b => b.type === 'text')?.text || ''
|
|
129
|
+
: '';
|
|
130
|
+
if (text) {
|
|
131
|
+
currentTurn.summary = text.slice(0, 200).replace(/\n+/g, ' ').trim();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Session stats
|
|
137
|
+
const stats = {
|
|
138
|
+
turns: turns.length,
|
|
139
|
+
filesEdited: [...allFiles.values()].filter(f => f.action === 'edited').length,
|
|
140
|
+
filesRead: [...allFiles.values()].filter(f => f.action === 'read').length,
|
|
141
|
+
toolCalls: [...allTools.values()].reduce((a, b) => a + b, 0),
|
|
142
|
+
cost: session.totalCost || 0,
|
|
143
|
+
messages: session.messages.length,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
return { turns, allFiles, allTools, stats };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
150
|
+
// Mind Map — SVG radial layout
|
|
151
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
152
|
+
|
|
153
|
+
function computeLayout(data, width, height) {
|
|
154
|
+
const cx = width / 2;
|
|
155
|
+
const cy = height / 2;
|
|
156
|
+
const nodes = [];
|
|
157
|
+
const edges = [];
|
|
158
|
+
|
|
159
|
+
if (!data || !data.turns.length) return { nodes, edges };
|
|
160
|
+
|
|
161
|
+
// Center: session node
|
|
162
|
+
nodes.push({
|
|
163
|
+
id: 'session',
|
|
164
|
+
x: cx, y: cy,
|
|
165
|
+
type: 'session',
|
|
166
|
+
label: 'Session',
|
|
167
|
+
r: 22,
|
|
168
|
+
color: '#b8962f',
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const turnCount = data.turns.length;
|
|
172
|
+
const turnRadius = Math.min(width, height) * (turnCount <= 3 ? 0.22 : 0.28);
|
|
173
|
+
|
|
174
|
+
data.turns.forEach((turn, i) => {
|
|
175
|
+
const angle = (i / turnCount) * Math.PI * 2 - Math.PI / 2;
|
|
176
|
+
const tx = cx + Math.cos(angle) * turnRadius;
|
|
177
|
+
const ty = cy + Math.sin(angle) * turnRadius;
|
|
178
|
+
const turnId = `turn-${i}`;
|
|
179
|
+
const promptLabel = turn.prompt.length > 35
|
|
180
|
+
? turn.prompt.slice(0, 33) + '...'
|
|
181
|
+
: turn.prompt;
|
|
182
|
+
|
|
183
|
+
nodes.push({
|
|
184
|
+
id: turnId,
|
|
185
|
+
x: tx, y: ty,
|
|
186
|
+
type: 'turn',
|
|
187
|
+
label: promptLabel,
|
|
188
|
+
r: 14,
|
|
189
|
+
color: '#8a7a5a',
|
|
190
|
+
data: turn,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
edges.push({ from: 'session', to: turnId });
|
|
194
|
+
|
|
195
|
+
// File nodes branching off this turn
|
|
196
|
+
const files = [...turn.files.entries()];
|
|
197
|
+
const fileRadius = Math.min(turnRadius * 0.45, 80);
|
|
198
|
+
const maxFiles = 6;
|
|
199
|
+
const visibleFiles = files.slice(0, maxFiles);
|
|
200
|
+
const spread = visibleFiles.length > 1
|
|
201
|
+
? Math.min(0.35, Math.PI / (turnCount || 1)) : 0;
|
|
202
|
+
|
|
203
|
+
visibleFiles.forEach(([fp, action], j) => {
|
|
204
|
+
const mid = (visibleFiles.length - 1) / 2;
|
|
205
|
+
const fAngle = angle + (j - mid) * spread;
|
|
206
|
+
const fx = tx + Math.cos(fAngle) * fileRadius;
|
|
207
|
+
const fy = ty + Math.sin(fAngle) * fileRadius;
|
|
208
|
+
const fileId = `${turnId}-f-${j}`;
|
|
209
|
+
const fileName = basename(fp);
|
|
210
|
+
|
|
211
|
+
nodes.push({
|
|
212
|
+
id: fileId,
|
|
213
|
+
x: fx, y: fy,
|
|
214
|
+
type: 'file',
|
|
215
|
+
label: fileName,
|
|
216
|
+
r: 7,
|
|
217
|
+
color: action === 'edited' ? '#665530' : '#3a3a30',
|
|
218
|
+
data: { path: fp, action },
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
edges.push({ from: turnId, to: fileId });
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
if (files.length > maxFiles) {
|
|
225
|
+
const extraAngle = angle + ((visibleFiles.length - 0.5) - (visibleFiles.length - 1) / 2) * spread;
|
|
226
|
+
const ex = tx + Math.cos(extraAngle) * fileRadius;
|
|
227
|
+
const ey = ty + Math.sin(extraAngle) * fileRadius;
|
|
228
|
+
nodes.push({
|
|
229
|
+
id: `${turnId}-more`,
|
|
230
|
+
x: ex, y: ey,
|
|
231
|
+
type: 'file',
|
|
232
|
+
label: `+${files.length - maxFiles}`,
|
|
233
|
+
r: 7,
|
|
234
|
+
color: '#2a2218',
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
return { nodes, edges };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function buildBezier(n1, n2) {
|
|
243
|
+
const dx = n2.x - n1.x;
|
|
244
|
+
const dy = n2.y - n1.y;
|
|
245
|
+
const cx1 = n1.x + dx * 0.4;
|
|
246
|
+
const cy1 = n1.y + dy * 0.1;
|
|
247
|
+
const cx2 = n1.x + dx * 0.6;
|
|
248
|
+
const cy2 = n2.y - dy * 0.1;
|
|
249
|
+
return `M${n1.x},${n1.y} C${cx1},${cy1} ${cx2},${cy2} ${n2.x},${n2.y}`;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function renderMindMap(container, data) {
|
|
253
|
+
const rect = container.getBoundingClientRect();
|
|
254
|
+
const w = rect.width || 800;
|
|
255
|
+
const h = rect.height || 600;
|
|
256
|
+
const layout = computeLayout(data, w, h);
|
|
257
|
+
const nodeMap = new Map(layout.nodes.map(n => [n.id, n]));
|
|
258
|
+
|
|
259
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
260
|
+
svg.setAttribute('viewBox', `0 0 ${w} ${h}`);
|
|
261
|
+
svg.setAttribute('class', 'zen-map-svg');
|
|
262
|
+
|
|
263
|
+
// Defs: glow filter
|
|
264
|
+
svg.innerHTML = `
|
|
265
|
+
<defs>
|
|
266
|
+
<filter id="zen-glow" x="-50%" y="-50%" width="200%" height="200%">
|
|
267
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur"/>
|
|
268
|
+
<feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
269
|
+
</filter>
|
|
270
|
+
<radialGradient id="zen-center-glow">
|
|
271
|
+
<stop offset="0%" stop-color="rgba(184,150,47,0.15)"/>
|
|
272
|
+
<stop offset="100%" stop-color="rgba(184,150,47,0)"/>
|
|
273
|
+
</radialGradient>
|
|
274
|
+
</defs>
|
|
275
|
+
`;
|
|
276
|
+
|
|
277
|
+
// Center glow ring
|
|
278
|
+
const centerNode = nodeMap.get('session');
|
|
279
|
+
if (centerNode) {
|
|
280
|
+
const pulse = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
281
|
+
pulse.setAttribute('cx', centerNode.x);
|
|
282
|
+
pulse.setAttribute('cy', centerNode.y);
|
|
283
|
+
pulse.setAttribute('r', 60);
|
|
284
|
+
pulse.setAttribute('fill', 'url(#zen-center-glow)');
|
|
285
|
+
pulse.setAttribute('class', 'zen-pulse-ring');
|
|
286
|
+
svg.appendChild(pulse);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Edges
|
|
290
|
+
layout.edges.forEach((edge, i) => {
|
|
291
|
+
const n1 = nodeMap.get(edge.from);
|
|
292
|
+
const n2 = nodeMap.get(edge.to);
|
|
293
|
+
if (!n1 || !n2) return;
|
|
294
|
+
|
|
295
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
296
|
+
path.setAttribute('d', buildBezier(n1, n2));
|
|
297
|
+
path.setAttribute('class', 'zen-edge-path');
|
|
298
|
+
|
|
299
|
+
// Staggered entrance
|
|
300
|
+
setTimeout(() => {
|
|
301
|
+
const len = path.getTotalLength?.() || 100;
|
|
302
|
+
path.style.setProperty('--path-length', len);
|
|
303
|
+
path.classList.add('visible', 'animate');
|
|
304
|
+
}, 200 + i * 80);
|
|
305
|
+
|
|
306
|
+
svg.appendChild(path);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// Nodes
|
|
310
|
+
layout.nodes.forEach((node, i) => {
|
|
311
|
+
const g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
312
|
+
g.setAttribute('class', 'zen-node');
|
|
313
|
+
g.setAttribute('data-id', node.id);
|
|
314
|
+
|
|
315
|
+
const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
316
|
+
circle.setAttribute('cx', node.x);
|
|
317
|
+
circle.setAttribute('cy', node.y);
|
|
318
|
+
circle.setAttribute('r', node.r);
|
|
319
|
+
circle.setAttribute('fill', node.color);
|
|
320
|
+
circle.setAttribute('class', 'zen-node-circle');
|
|
321
|
+
|
|
322
|
+
if (node.type === 'session') {
|
|
323
|
+
circle.setAttribute('filter', 'url(#zen-glow)');
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
g.appendChild(circle);
|
|
327
|
+
|
|
328
|
+
// Label
|
|
329
|
+
const label = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
330
|
+
label.setAttribute('x', node.x);
|
|
331
|
+
label.setAttribute('y', node.y + node.r + 8);
|
|
332
|
+
label.setAttribute('class', 'zen-node-label');
|
|
333
|
+
label.textContent = node.label;
|
|
334
|
+
g.appendChild(label);
|
|
335
|
+
|
|
336
|
+
// Staggered entrance
|
|
337
|
+
setTimeout(() => g.classList.add('visible'), 100 + i * 60);
|
|
338
|
+
|
|
339
|
+
// Click handler
|
|
340
|
+
g.addEventListener('click', (e) => {
|
|
341
|
+
e.stopPropagation();
|
|
342
|
+
showNodeDetail(node, container);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
svg.appendChild(g);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// Click on background dismisses detail card
|
|
349
|
+
svg.addEventListener('click', () => hideNodeDetail());
|
|
350
|
+
|
|
351
|
+
container.innerHTML = '';
|
|
352
|
+
container.appendChild(svg);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function showNodeDetail(node, mapContainer) {
|
|
356
|
+
hideNodeDetail();
|
|
357
|
+
selectedNode = node.id;
|
|
358
|
+
|
|
359
|
+
// Highlight selected node in SVG
|
|
360
|
+
const svgNode = mapContainer.querySelector(`[data-id="${node.id}"]`);
|
|
361
|
+
if (svgNode) svgNode.classList.add('selected');
|
|
362
|
+
|
|
363
|
+
const card = document.createElement('div');
|
|
364
|
+
card.className = 'zen-detail-card';
|
|
365
|
+
|
|
366
|
+
let html = '';
|
|
367
|
+
|
|
368
|
+
if (node.type === 'session') {
|
|
369
|
+
const data = sessionData;
|
|
370
|
+
html = `
|
|
371
|
+
<div class="zen-detail-title">Session Overview</div>
|
|
372
|
+
<div class="zen-detail-meta">
|
|
373
|
+
${data?.stats?.turns || 0} turns ·
|
|
374
|
+
${data?.stats?.filesEdited || 0} files edited ·
|
|
375
|
+
${data?.stats?.toolCalls || 0} tool calls
|
|
376
|
+
${data?.stats?.cost ? ` · $${data.stats.cost.toFixed(3)}` : ''}
|
|
377
|
+
</div>
|
|
378
|
+
`;
|
|
379
|
+
} else if (node.type === 'turn' && node.data) {
|
|
380
|
+
const turn = node.data;
|
|
381
|
+
html = `
|
|
382
|
+
<div class="zen-detail-title">${escapeHtml(turn.prompt)}</div>
|
|
383
|
+
${turn.summary ? `<div class="zen-detail-meta" style="margin-top:6px">${escapeHtml(turn.summary)}</div>` : ''}
|
|
384
|
+
${turn.files.size ? `
|
|
385
|
+
<div class="zen-detail-files">
|
|
386
|
+
${[...turn.files.entries()].slice(0, 8).map(([fp, action]) =>
|
|
387
|
+
`<div class="zen-detail-file">${action === 'edited' ? '~' : action === 'read' ? '>' : '?'} ${basename(fp)}</div>`
|
|
388
|
+
).join('')}
|
|
389
|
+
</div>
|
|
390
|
+
` : ''}
|
|
391
|
+
`;
|
|
392
|
+
} else if (node.type === 'file' && node.data) {
|
|
393
|
+
html = `
|
|
394
|
+
<div class="zen-detail-title">${escapeHtml(basename(node.data.path))}</div>
|
|
395
|
+
<div class="zen-detail-meta">${escapeHtml(node.data.path)}</div>
|
|
396
|
+
<div class="zen-detail-meta" style="margin-top:4px;color:var(--zen-accent-dim)">${node.data.action}</div>
|
|
397
|
+
`;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
card.innerHTML = html;
|
|
401
|
+
|
|
402
|
+
// Position near the node
|
|
403
|
+
const rect = mapContainer.getBoundingClientRect();
|
|
404
|
+
const svgRect = mapContainer.querySelector('svg')?.getBoundingClientRect() || rect;
|
|
405
|
+
const scaleX = svgRect.width / (parseFloat(mapContainer.querySelector('svg')?.getAttribute('viewBox')?.split(' ')[2]) || svgRect.width);
|
|
406
|
+
const scaleY = svgRect.height / (parseFloat(mapContainer.querySelector('svg')?.getAttribute('viewBox')?.split(' ')[3]) || svgRect.height);
|
|
407
|
+
|
|
408
|
+
let left = svgRect.left - rect.left + node.x * scaleX + 16;
|
|
409
|
+
let top = svgRect.top - rect.top + node.y * scaleY - 20;
|
|
410
|
+
|
|
411
|
+
// Keep on screen
|
|
412
|
+
if (left + 320 > rect.width) left = left - 340;
|
|
413
|
+
if (top + 200 > rect.height) top = rect.height - 220;
|
|
414
|
+
if (top < 10) top = 10;
|
|
415
|
+
|
|
416
|
+
card.style.left = `${left}px`;
|
|
417
|
+
card.style.top = `${top}px`;
|
|
418
|
+
|
|
419
|
+
mapContainer.appendChild(card);
|
|
420
|
+
detailCard = card;
|
|
421
|
+
requestAnimationFrame(() => card.classList.add('visible'));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function hideNodeDetail() {
|
|
425
|
+
if (detailCard) {
|
|
426
|
+
detailCard.remove();
|
|
427
|
+
detailCard = null;
|
|
428
|
+
}
|
|
429
|
+
selectedNode = null;
|
|
430
|
+
// Remove selected class from all nodes
|
|
431
|
+
overlayEl?.querySelectorAll('.zen-node.selected').forEach(n => n.classList.remove('selected'));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
435
|
+
// Summary View
|
|
436
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
437
|
+
|
|
438
|
+
function renderSummary(container, data, session) {
|
|
439
|
+
if (!data) {
|
|
440
|
+
container.innerHTML = `<div class="zen-empty">${ICONS.compass}<div class="zen-empty-text">${S.zen_mode?.empty || 'No session data'}</div></div>`;
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const s = data.stats;
|
|
445
|
+
const sessionName = session?.name || 'Session';
|
|
446
|
+
|
|
447
|
+
// Build file list (edited files first, then read)
|
|
448
|
+
const editedFiles = [...data.allFiles.entries()]
|
|
449
|
+
.filter(([, v]) => v.action === 'edited')
|
|
450
|
+
.map(([path, v]) => ({ path, ...v }));
|
|
451
|
+
const readFiles = [...data.allFiles.entries()]
|
|
452
|
+
.filter(([, v]) => v.action === 'read')
|
|
453
|
+
.map(([path, v]) => ({ path, ...v }));
|
|
454
|
+
|
|
455
|
+
// Build turn timeline
|
|
456
|
+
const timeline = data.turns.map((t, i) => {
|
|
457
|
+
const filesCount = t.files.size;
|
|
458
|
+
const toolsCount = [...t.tools.values()].reduce((a, b) => a + b, 0);
|
|
459
|
+
return `<div class="zen-file-item" style="border-left:2px solid var(--zen-accent-dim);padding-left:12px">
|
|
460
|
+
<span style="color:var(--zen-text-dim);font-size:10px;min-width:20px">${i + 1}.</span>
|
|
461
|
+
<span style="flex:1">${escapeHtml(t.prompt.slice(0, 80))}${t.prompt.length > 80 ? '...' : ''}</span>
|
|
462
|
+
${filesCount ? `<span style="color:var(--zen-accent-dim);font-size:10px">${filesCount} files</span>` : ''}
|
|
463
|
+
</div>`;
|
|
464
|
+
}).join('');
|
|
465
|
+
|
|
466
|
+
container.innerHTML = `
|
|
467
|
+
<div class="zen-summary">
|
|
468
|
+
<div class="zen-summary-section">
|
|
469
|
+
<div class="zen-summary-heading">${S.zen_mode?.stats_heading || 'Session'}</div>
|
|
470
|
+
<div class="zen-stat-grid">
|
|
471
|
+
<div class="zen-stat">
|
|
472
|
+
<div class="zen-stat-value">${s.turns}</div>
|
|
473
|
+
<div class="zen-stat-label">${S.zen_mode?.stat_turns || 'Turns'}</div>
|
|
474
|
+
</div>
|
|
475
|
+
<div class="zen-stat">
|
|
476
|
+
<div class="zen-stat-value">${s.filesEdited}</div>
|
|
477
|
+
<div class="zen-stat-label">${S.zen_mode?.stat_files || 'Files Edited'}</div>
|
|
478
|
+
</div>
|
|
479
|
+
<div class="zen-stat">
|
|
480
|
+
<div class="zen-stat-value">${s.toolCalls}</div>
|
|
481
|
+
<div class="zen-stat-label">${S.zen_mode?.stat_tools || 'Tool Calls'}</div>
|
|
482
|
+
</div>
|
|
483
|
+
${s.cost ? `<div class="zen-stat">
|
|
484
|
+
<div class="zen-stat-value">$${s.cost.toFixed(2)}</div>
|
|
485
|
+
<div class="zen-stat-label">${S.zen_mode?.stat_cost || 'Cost'}</div>
|
|
486
|
+
</div>` : ''}
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
|
|
490
|
+
${timeline ? `
|
|
491
|
+
<div class="zen-summary-section">
|
|
492
|
+
<div class="zen-summary-heading">${S.zen_mode?.turns_heading || 'Conversation Flow'}</div>
|
|
493
|
+
<div class="zen-file-list">${timeline}</div>
|
|
494
|
+
</div>` : ''}
|
|
495
|
+
|
|
496
|
+
${editedFiles.length ? `
|
|
497
|
+
<div class="zen-summary-section">
|
|
498
|
+
<div class="zen-summary-heading">${S.zen_mode?.files_edited_heading || 'Files Changed'}</div>
|
|
499
|
+
<div class="zen-file-list">
|
|
500
|
+
${editedFiles.map(f => `
|
|
501
|
+
<div class="zen-file-item">
|
|
502
|
+
<span class="zen-file-action edited">edit</span>
|
|
503
|
+
<span class="zen-file-path">${escapeHtml(f.path)}</span>
|
|
504
|
+
</div>
|
|
505
|
+
`).join('')}
|
|
506
|
+
</div>
|
|
507
|
+
</div>` : ''}
|
|
508
|
+
|
|
509
|
+
${readFiles.length ? `
|
|
510
|
+
<div class="zen-summary-section">
|
|
511
|
+
<div class="zen-summary-heading">${S.zen_mode?.files_read_heading || 'Files Read'}</div>
|
|
512
|
+
<div class="zen-file-list">
|
|
513
|
+
${readFiles.slice(0, 20).map(f => `
|
|
514
|
+
<div class="zen-file-item">
|
|
515
|
+
<span class="zen-file-action read">read</span>
|
|
516
|
+
<span class="zen-file-path">${escapeHtml(f.path)}</span>
|
|
517
|
+
</div>
|
|
518
|
+
`).join('')}
|
|
519
|
+
${readFiles.length > 20 ? `<div class="zen-file-item" style="color:var(--zen-text-dim)">+${readFiles.length - 20} more</div>` : ''}
|
|
520
|
+
</div>
|
|
521
|
+
</div>` : ''}
|
|
522
|
+
</div>
|
|
523
|
+
`;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
527
|
+
// Actions View
|
|
528
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
529
|
+
|
|
530
|
+
function renderActions(container) {
|
|
531
|
+
container.innerHTML = `
|
|
532
|
+
<div class="zen-actions">
|
|
533
|
+
<div class="zen-actions-prompt">${S.zen_mode?.decide_prompt || 'What would you like to do next?'}</div>
|
|
534
|
+
<div class="zen-actions-grid">
|
|
535
|
+
<button class="zen-action-btn" data-action="continue">
|
|
536
|
+
${ICONS.play}
|
|
537
|
+
<span class="zen-action-label">${S.zen_mode?.action_continue || 'Continue'}</span>
|
|
538
|
+
<span class="zen-action-hint">${S.zen_mode?.action_continue_hint || 'Keep working in this session'}</span>
|
|
539
|
+
</button>
|
|
540
|
+
<button class="zen-action-btn" data-action="diff">
|
|
541
|
+
${ICONS.gitDiff}
|
|
542
|
+
<span class="zen-action-label">${S.zen_mode?.action_diff || 'View Diff'}</span>
|
|
543
|
+
<span class="zen-action-hint">${S.zen_mode?.action_diff_hint || 'See all changes made'}</span>
|
|
544
|
+
</button>
|
|
545
|
+
<button class="zen-action-btn" data-action="commit">
|
|
546
|
+
${ICONS.gitCommit}
|
|
547
|
+
<span class="zen-action-label">${S.zen_mode?.action_commit || 'Commit'}</span>
|
|
548
|
+
<span class="zen-action-hint">${S.zen_mode?.action_commit_hint || 'Ask Claude to commit changes'}</span>
|
|
549
|
+
</button>
|
|
550
|
+
<button class="zen-action-btn" data-action="new">
|
|
551
|
+
${ICONS.plus}
|
|
552
|
+
<span class="zen-action-label">${S.zen_mode?.action_new || 'New Session'}</span>
|
|
553
|
+
<span class="zen-action-hint">${S.zen_mode?.action_new_hint || 'Start fresh'}</span>
|
|
554
|
+
</button>
|
|
555
|
+
</div>
|
|
556
|
+
</div>
|
|
557
|
+
`;
|
|
558
|
+
|
|
559
|
+
// Action handlers
|
|
560
|
+
container.querySelectorAll('[data-action]').forEach(btn => {
|
|
561
|
+
btn.addEventListener('click', () => handleAction(btn.dataset.action));
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function handleAction(action) {
|
|
566
|
+
closeZen();
|
|
567
|
+
|
|
568
|
+
// Small delay to let the exit animation complete
|
|
569
|
+
setTimeout(() => {
|
|
570
|
+
switch (action) {
|
|
571
|
+
case 'continue':
|
|
572
|
+
// Focus the input
|
|
573
|
+
document.querySelector('#user-input')?.focus();
|
|
574
|
+
break;
|
|
575
|
+
case 'diff':
|
|
576
|
+
// Open git widget (contains diff view)
|
|
577
|
+
try {
|
|
578
|
+
window.app?.toggleGitPanel?.();
|
|
579
|
+
} catch { /* ignore */ }
|
|
580
|
+
break;
|
|
581
|
+
case 'commit':
|
|
582
|
+
// Send /commit command
|
|
583
|
+
if (window.app?.sendMessage) {
|
|
584
|
+
window.app.sendMessage('/commit');
|
|
585
|
+
}
|
|
586
|
+
break;
|
|
587
|
+
case 'new':
|
|
588
|
+
window.app?.createSession?.();
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}, 350);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
595
|
+
// Chat View — Clean conversation reader
|
|
596
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
597
|
+
|
|
598
|
+
function renderChat(container, session) {
|
|
599
|
+
if (!session?.messages?.length) {
|
|
600
|
+
container.innerHTML = `<div class="zen-empty">${ICONS.compass}<div class="zen-empty-text">${S.zen_mode?.empty_chat || 'No messages yet'}</div></div>`;
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const msgs = session.messages;
|
|
605
|
+
const blocks = [];
|
|
606
|
+
let pendingTools = [];
|
|
607
|
+
|
|
608
|
+
// Collapse messages into readable blocks:
|
|
609
|
+
// user text → show
|
|
610
|
+
// assistant text → show (rendered markdown-lite)
|
|
611
|
+
// tool_use/tool_result → collapse into one-liner group
|
|
612
|
+
// thinking → dim expandable block
|
|
613
|
+
for (const msg of msgs) {
|
|
614
|
+
const content = msg.content;
|
|
615
|
+
|
|
616
|
+
// User prompt
|
|
617
|
+
if (msg.role === 'user' && typeof content === 'string' && content.trim()) {
|
|
618
|
+
if (pendingTools.length) {
|
|
619
|
+
blocks.push({ type: 'tools', tools: [...pendingTools] });
|
|
620
|
+
pendingTools = [];
|
|
621
|
+
}
|
|
622
|
+
blocks.push({ type: 'user', text: content.trim() });
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// User with array content (tool results)
|
|
627
|
+
if (msg.role === 'user' && Array.isArray(content)) {
|
|
628
|
+
for (const part of content) {
|
|
629
|
+
if (part.type === 'tool_result') {
|
|
630
|
+
// Find matching tool_use
|
|
631
|
+
const existing = pendingTools.find(t => t.id === part.tool_use_id);
|
|
632
|
+
if (existing) {
|
|
633
|
+
existing.result = typeof part.content === 'string'
|
|
634
|
+
? part.content.slice(0, 200) : '(result)';
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Assistant
|
|
642
|
+
if (msg.role === 'assistant') {
|
|
643
|
+
const parts = Array.isArray(content) ? content : [{ type: 'text', text: content }];
|
|
644
|
+
|
|
645
|
+
for (const part of parts) {
|
|
646
|
+
if (part.type === 'text' && part.text?.trim()) {
|
|
647
|
+
if (pendingTools.length) {
|
|
648
|
+
blocks.push({ type: 'tools', tools: [...pendingTools] });
|
|
649
|
+
pendingTools = [];
|
|
650
|
+
}
|
|
651
|
+
blocks.push({ type: 'assistant', text: part.text.trim() });
|
|
652
|
+
} else if (part.type === 'tool_use') {
|
|
653
|
+
const toolName = part.name || 'Tool';
|
|
654
|
+
const filePath = part.input?.file_path || part.input?.command?.slice(0, 60) || '';
|
|
655
|
+
pendingTools.push({
|
|
656
|
+
id: part.id,
|
|
657
|
+
name: toolName,
|
|
658
|
+
detail: filePath,
|
|
659
|
+
});
|
|
660
|
+
} else if (part.type === 'thinking' && part.thinking) {
|
|
661
|
+
if (pendingTools.length) {
|
|
662
|
+
blocks.push({ type: 'tools', tools: [...pendingTools] });
|
|
663
|
+
pendingTools = [];
|
|
664
|
+
}
|
|
665
|
+
blocks.push({ type: 'thinking', text: part.thinking.slice(0, 500) });
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// Result/cost bars
|
|
672
|
+
if (msg.type === 'result' || msg.role === 'result') {
|
|
673
|
+
if (pendingTools.length) {
|
|
674
|
+
blocks.push({ type: 'tools', tools: [...pendingTools] });
|
|
675
|
+
pendingTools = [];
|
|
676
|
+
}
|
|
677
|
+
const cost = msg.cost_usd || msg.costUsd;
|
|
678
|
+
if (cost) {
|
|
679
|
+
blocks.push({ type: 'divider', cost });
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// Flush remaining tools
|
|
685
|
+
if (pendingTools.length) {
|
|
686
|
+
blocks.push({ type: 'tools', tools: [...pendingTools] });
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// Render blocks
|
|
690
|
+
let html = '<div class="zen-chat">';
|
|
691
|
+
|
|
692
|
+
for (const block of blocks) {
|
|
693
|
+
switch (block.type) {
|
|
694
|
+
case 'user':
|
|
695
|
+
html += `<div class="zen-chat-msg zen-chat-user">
|
|
696
|
+
<div class="zen-chat-role">you</div>
|
|
697
|
+
<div class="zen-chat-text">${escapeHtml(block.text)}</div>
|
|
698
|
+
</div>`;
|
|
699
|
+
break;
|
|
700
|
+
|
|
701
|
+
case 'assistant':
|
|
702
|
+
html += `<div class="zen-chat-msg zen-chat-assistant">
|
|
703
|
+
<div class="zen-chat-role">${escapeHtml(engineAuthorLabel(session))}</div>
|
|
704
|
+
<div class="zen-chat-text">${formatZenMarkdown(block.text)}</div>
|
|
705
|
+
</div>`;
|
|
706
|
+
break;
|
|
707
|
+
|
|
708
|
+
case 'tools':
|
|
709
|
+
html += `<div class="zen-chat-tools">`;
|
|
710
|
+
for (const tool of block.tools) {
|
|
711
|
+
const icon = tool.name === 'Read' ? '>' : tool.name === 'Edit' ? '~' : tool.name === 'Write' ? '+' : tool.name === 'Bash' ? '$' : '•';
|
|
712
|
+
const detail = tool.detail ? basename(tool.detail) : '';
|
|
713
|
+
html += `<div class="zen-chat-tool"><span class="zen-tool-icon">${icon}</span><span class="zen-tool-name">${escapeHtml(tool.name)}</span>${detail ? `<span class="zen-tool-detail">${escapeHtml(detail)}</span>` : ''}</div>`;
|
|
714
|
+
}
|
|
715
|
+
html += `</div>`;
|
|
716
|
+
break;
|
|
717
|
+
|
|
718
|
+
case 'thinking':
|
|
719
|
+
html += `<details class="zen-chat-thinking">
|
|
720
|
+
<summary>thinking...</summary>
|
|
721
|
+
<div class="zen-chat-thinking-text">${escapeHtml(block.text)}</div>
|
|
722
|
+
</details>`;
|
|
723
|
+
break;
|
|
724
|
+
|
|
725
|
+
case 'divider':
|
|
726
|
+
html += `<div class="zen-chat-divider"><span class="zen-chat-cost">$${block.cost.toFixed(3)}</span></div>`;
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
html += '</div>';
|
|
732
|
+
container.innerHTML = html;
|
|
733
|
+
|
|
734
|
+
// Scroll to bottom
|
|
735
|
+
const chatEl = container.querySelector('.zen-chat');
|
|
736
|
+
if (chatEl) chatEl.scrollTop = chatEl.scrollHeight;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Minimal markdown: **bold**, `code`, ```code blocks```, line breaks.
|
|
741
|
+
* Keeps it readable without pulling in the full markdown renderer.
|
|
742
|
+
*/
|
|
743
|
+
function formatZenMarkdown(text) {
|
|
744
|
+
return escapeHtml(text)
|
|
745
|
+
.replace(/```[\s\S]*?```/g, m => {
|
|
746
|
+
const inner = m.slice(3, -3).replace(/^\w*\n/, '');
|
|
747
|
+
return `<pre class="zen-code-block">${inner}</pre>`;
|
|
748
|
+
})
|
|
749
|
+
.replace(/`([^`]+)`/g, '<code class="zen-inline-code">$1</code>')
|
|
750
|
+
.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
|
|
751
|
+
.replace(/\n/g, '<br>');
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
755
|
+
// Main Render / Lifecycle
|
|
756
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
757
|
+
|
|
758
|
+
const TABS = [
|
|
759
|
+
{ id: 'chat', label: 'Chat' },
|
|
760
|
+
{ id: 'map', label: 'Map' },
|
|
761
|
+
{ id: 'review', label: 'Review' },
|
|
762
|
+
{ id: 'act', label: 'Act' },
|
|
763
|
+
];
|
|
764
|
+
|
|
765
|
+
function renderZen(session) {
|
|
766
|
+
// Extract data
|
|
767
|
+
sessionData = extractSessionData(session);
|
|
768
|
+
|
|
769
|
+
const overlay = document.createElement('div');
|
|
770
|
+
overlay.className = 'zen-overlay';
|
|
771
|
+
|
|
772
|
+
const sessionName = session?.name || 'Session';
|
|
773
|
+
|
|
774
|
+
// Top bar
|
|
775
|
+
overlay.innerHTML = `
|
|
776
|
+
<div class="zen-topbar">
|
|
777
|
+
<div class="zen-session-name">${escapeHtml(sessionName)}</div>
|
|
778
|
+
<div class="zen-tab-dots">
|
|
779
|
+
${TABS.map(t => `
|
|
780
|
+
<button class="zen-tab-dot ${t.id === activeTab ? 'active' : ''}"
|
|
781
|
+
data-tab="${t.id}" data-label="${t.label}"
|
|
782
|
+
data-tooltip="${t.label}"></button>
|
|
783
|
+
`).join('')}
|
|
784
|
+
</div>
|
|
785
|
+
<button class="zen-close-btn" data-tooltip="Exit Zen (Esc)">${ICONS.x}</button>
|
|
786
|
+
</div>
|
|
787
|
+
<div class="zen-content">
|
|
788
|
+
${TABS.map(t => `
|
|
789
|
+
<div class="zen-view ${t.id === activeTab ? 'active' : ''}" data-view="${t.id}">
|
|
790
|
+
${t.id === 'map' ? '<div class="zen-map-container"></div>' : ''}
|
|
791
|
+
</div>
|
|
792
|
+
`).join('')}
|
|
793
|
+
</div>
|
|
794
|
+
`;
|
|
795
|
+
|
|
796
|
+
// Event: tab switching
|
|
797
|
+
overlay.querySelectorAll('.zen-tab-dot').forEach(dot => {
|
|
798
|
+
dot.addEventListener('click', () => switchTab(dot.dataset.tab, overlay, session));
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
// Event: close
|
|
802
|
+
overlay.querySelector('.zen-close-btn').addEventListener('click', closeZen);
|
|
803
|
+
|
|
804
|
+
// Event: ESC key + arrow keys for tab nav
|
|
805
|
+
const keyHandler = (e) => {
|
|
806
|
+
if (e.key === 'Escape') {
|
|
807
|
+
e.preventDefault();
|
|
808
|
+
e.stopPropagation();
|
|
809
|
+
closeZen();
|
|
810
|
+
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
e.stopPropagation();
|
|
813
|
+
cycleZenTab(e.key === 'ArrowRight' ? 1 : -1, overlay, session);
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
overlay._keyHandler = keyHandler;
|
|
817
|
+
document.addEventListener('keydown', keyHandler, true);
|
|
818
|
+
|
|
819
|
+
// Gesture: trackpad two-finger swipe (wheel events)
|
|
820
|
+
let wheelAccum = 0;
|
|
821
|
+
let wheelTimer = null;
|
|
822
|
+
let wheelCooldown = false;
|
|
823
|
+
const WHEEL_THRESHOLD = 120;
|
|
824
|
+
const WHEEL_COOLDOWN = 400;
|
|
825
|
+
|
|
826
|
+
const wheelHandler = (e) => {
|
|
827
|
+
// Only handle horizontal scroll
|
|
828
|
+
if (Math.abs(e.deltaX) <= Math.abs(e.deltaY)) return;
|
|
829
|
+
e.preventDefault();
|
|
830
|
+
e.stopPropagation();
|
|
831
|
+
|
|
832
|
+
if (wheelCooldown) return;
|
|
833
|
+
|
|
834
|
+
wheelAccum += e.deltaX;
|
|
835
|
+
clearTimeout(wheelTimer);
|
|
836
|
+
wheelTimer = setTimeout(() => { wheelAccum = 0; }, 150);
|
|
837
|
+
|
|
838
|
+
if (Math.abs(wheelAccum) >= WHEEL_THRESHOLD) {
|
|
839
|
+
cycleZenTab(wheelAccum > 0 ? 1 : -1, overlay, session);
|
|
840
|
+
wheelAccum = 0;
|
|
841
|
+
wheelCooldown = true;
|
|
842
|
+
setTimeout(() => { wheelCooldown = false; }, WHEEL_COOLDOWN);
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
overlay.addEventListener('wheel', wheelHandler, { passive: false });
|
|
846
|
+
|
|
847
|
+
// Gesture: touch swipe (finger)
|
|
848
|
+
let touchStartX = 0;
|
|
849
|
+
let touchStartY = 0;
|
|
850
|
+
let touchStartTime = 0;
|
|
851
|
+
|
|
852
|
+
const touchStartHandler = (e) => {
|
|
853
|
+
if (e.touches.length !== 1) return;
|
|
854
|
+
touchStartX = e.touches[0].clientX;
|
|
855
|
+
touchStartY = e.touches[0].clientY;
|
|
856
|
+
touchStartTime = Date.now();
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
const touchEndHandler = (e) => {
|
|
860
|
+
if (!touchStartTime) return;
|
|
861
|
+
const dt = Date.now() - touchStartTime;
|
|
862
|
+
if (dt > 500) { touchStartTime = 0; return; }
|
|
863
|
+
|
|
864
|
+
const touch = e.changedTouches[0];
|
|
865
|
+
const dx = touch.clientX - touchStartX;
|
|
866
|
+
const dy = touch.clientY - touchStartY;
|
|
867
|
+
const absDx = Math.abs(dx);
|
|
868
|
+
const absDy = Math.abs(dy);
|
|
869
|
+
|
|
870
|
+
// Must be primarily horizontal, > 80px distance
|
|
871
|
+
if (absDx > 80 && absDx > absDy * 2) {
|
|
872
|
+
cycleZenTab(dx < 0 ? 1 : -1, overlay, session);
|
|
873
|
+
}
|
|
874
|
+
touchStartTime = 0;
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
overlay.addEventListener('touchstart', touchStartHandler, { passive: true });
|
|
878
|
+
overlay.addEventListener('touchend', touchEndHandler, { passive: true });
|
|
879
|
+
|
|
880
|
+
// Store handlers for cleanup
|
|
881
|
+
overlay._wheelHandler = wheelHandler;
|
|
882
|
+
overlay._touchStartHandler = touchStartHandler;
|
|
883
|
+
overlay._touchEndHandler = touchEndHandler;
|
|
884
|
+
|
|
885
|
+
document.body.appendChild(overlay);
|
|
886
|
+
overlayEl = overlay;
|
|
887
|
+
|
|
888
|
+
// Animate in
|
|
889
|
+
requestAnimationFrame(() => {
|
|
890
|
+
overlay.classList.add('zen-visible');
|
|
891
|
+
// Render initial view after fade-in starts
|
|
892
|
+
setTimeout(() => renderActiveView(overlay, session), 100);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
function cycleZenTab(direction, overlay, session) {
|
|
897
|
+
const currentIdx = TABS.findIndex(t => t.id === activeTab);
|
|
898
|
+
const newIdx = (currentIdx + direction + TABS.length) % TABS.length;
|
|
899
|
+
switchTab(TABS[newIdx].id, overlay, session);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
function switchTab(tabId, overlay, session) {
|
|
903
|
+
if (activeTab === tabId) return;
|
|
904
|
+
activeTab = tabId;
|
|
905
|
+
hideNodeDetail();
|
|
906
|
+
|
|
907
|
+
// Update dots
|
|
908
|
+
overlay.querySelectorAll('.zen-tab-dot').forEach(d => {
|
|
909
|
+
d.classList.toggle('active', d.dataset.tab === tabId);
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
// Update views
|
|
913
|
+
overlay.querySelectorAll('.zen-view').forEach(v => {
|
|
914
|
+
v.classList.toggle('active', v.dataset.view === tabId);
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
renderActiveView(overlay, session);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function renderActiveView(overlay, session) {
|
|
921
|
+
const view = overlay.querySelector(`.zen-view[data-view="${activeTab}"]`);
|
|
922
|
+
if (!view) return;
|
|
923
|
+
|
|
924
|
+
switch (activeTab) {
|
|
925
|
+
case 'chat':
|
|
926
|
+
renderChat(view, session);
|
|
927
|
+
break;
|
|
928
|
+
case 'map': {
|
|
929
|
+
const mapContainer = view.querySelector('.zen-map-container');
|
|
930
|
+
if (mapContainer) {
|
|
931
|
+
if (!sessionData || !sessionData.turns.length) {
|
|
932
|
+
mapContainer.innerHTML = `<div class="zen-empty">${ICONS.compass}<div class="zen-empty-text">${S.zen_mode?.empty_map || 'No turns yet. Start a conversation to see the map.'}</div></div>`;
|
|
933
|
+
} else {
|
|
934
|
+
renderMindMap(mapContainer, sessionData);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
case 'review':
|
|
940
|
+
renderSummary(view, sessionData, session);
|
|
941
|
+
break;
|
|
942
|
+
case 'act':
|
|
943
|
+
renderActions(view);
|
|
944
|
+
break;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
export function openZen() {
|
|
949
|
+
if (overlayEl) return; // Already open
|
|
950
|
+
activeTab = 'chat';
|
|
951
|
+
const session = window.app?.activeSession;
|
|
952
|
+
renderZen(session);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
export function closeZen() {
|
|
956
|
+
if (!overlayEl) return;
|
|
957
|
+
|
|
958
|
+
// Remove event handlers
|
|
959
|
+
if (overlayEl._keyHandler) {
|
|
960
|
+
document.removeEventListener('keydown', overlayEl._keyHandler, true);
|
|
961
|
+
}
|
|
962
|
+
if (overlayEl._wheelHandler) {
|
|
963
|
+
overlayEl.removeEventListener('wheel', overlayEl._wheelHandler);
|
|
964
|
+
}
|
|
965
|
+
if (overlayEl._touchStartHandler) {
|
|
966
|
+
overlayEl.removeEventListener('touchstart', overlayEl._touchStartHandler);
|
|
967
|
+
overlayEl.removeEventListener('touchend', overlayEl._touchEndHandler);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
overlayEl.classList.remove('zen-visible');
|
|
971
|
+
const el = overlayEl;
|
|
972
|
+
overlayEl = null;
|
|
973
|
+
sessionData = null;
|
|
974
|
+
selectedNode = null;
|
|
975
|
+
detailCard = null;
|
|
976
|
+
|
|
977
|
+
setTimeout(() => el.remove(), 600);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
export function toggleZen() {
|
|
981
|
+
if (overlayEl) closeZen();
|
|
982
|
+
else openZen();
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
export function isZenOpen() {
|
|
986
|
+
return !!overlayEl;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
990
|
+
// Widget Registration (for quick-actions & shortcuts integration)
|
|
991
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
992
|
+
|
|
993
|
+
export function registerZenWidget() {
|
|
994
|
+
// Zen mode is NOT a standard widget — it's a fullscreen overlay.
|
|
995
|
+
// We register it as a lightweight entry so quick-actions and shortcuts can find it.
|
|
996
|
+
// The actual rendering bypasses the widget system for true fullscreen control.
|
|
997
|
+
|
|
998
|
+
// Make toggle available globally for shortcuts
|
|
999
|
+
window.toggleZenMode = toggleZen;
|
|
1000
|
+
window.isZenModeOpen = isZenOpen;
|
|
1001
|
+
}
|