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,1804 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History Explorer Widget - Development Archaeology Tool
|
|
3
|
+
*
|
|
4
|
+
* Browse, search, and understand shadow git history:
|
|
5
|
+
* - Timeline: Commits grouped by session
|
|
6
|
+
* - Decisions: All architectural decisions made
|
|
7
|
+
* - Problems: Bugs fixed and their solutions
|
|
8
|
+
* - Learnings: Gotchas and discoveries
|
|
9
|
+
* - Files: Per-file history and diffs
|
|
10
|
+
*
|
|
11
|
+
* Phase 1: Read-only exploration (no undo/revert)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import S from '../strings.js';
|
|
15
|
+
import { escapeHtml, formatRelativeTime } from '../utils.js';
|
|
16
|
+
import { CONFIG } from '../config.js';
|
|
17
|
+
import { WidgetManager, ICONS } from '../widget-system/index.js';
|
|
18
|
+
import { FilePreviewWidget } from './file-preview-widget.js';
|
|
19
|
+
import { ContextMenu } from '../context-menu.js';
|
|
20
|
+
import { basename, isAbsolutePath, joinPath } from '../path-utils.js';
|
|
21
|
+
|
|
22
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
23
|
+
// State
|
|
24
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
25
|
+
|
|
26
|
+
const state = {
|
|
27
|
+
cwd: null,
|
|
28
|
+
sessionId: null,
|
|
29
|
+
activeTab: 'timeline',
|
|
30
|
+
loading: false,
|
|
31
|
+
error: null,
|
|
32
|
+
|
|
33
|
+
// Search
|
|
34
|
+
searchQuery: '',
|
|
35
|
+
searchTags: [],
|
|
36
|
+
searchFiles: [],
|
|
37
|
+
currentSessionOnly: localStorage.getItem('he-current-session-only') === 'true',
|
|
38
|
+
|
|
39
|
+
// Data
|
|
40
|
+
timeline: { sessions: [], totalCommits: 0 },
|
|
41
|
+
decisions: [],
|
|
42
|
+
problems: [],
|
|
43
|
+
learnings: [],
|
|
44
|
+
tags: { tags: [], recentTags: [], total: 0 },
|
|
45
|
+
tagCommits: [], // commits for selected tag
|
|
46
|
+
selectedTag: null,
|
|
47
|
+
facets: { tags: [], files: [] },
|
|
48
|
+
allFiles: [], // All files from shadow git
|
|
49
|
+
|
|
50
|
+
// Expanded items
|
|
51
|
+
expandedSessions: new Set(),
|
|
52
|
+
expandedCommits: new Set(),
|
|
53
|
+
loadedDiffs: {}, // commitHash -> diff data
|
|
54
|
+
|
|
55
|
+
// Files view
|
|
56
|
+
selectedFile: null,
|
|
57
|
+
fileHistory: [],
|
|
58
|
+
fileCompare: { from: null, to: 'HEAD' },
|
|
59
|
+
filesSearchQuery: '',
|
|
60
|
+
filesViewMode: localStorage.getItem('he-files-view-mode') || 'tree', // default to tree
|
|
61
|
+
expandedDirs: new Set(), // For tree view
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// Container ref
|
|
65
|
+
container: null,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
69
|
+
// Helpers
|
|
70
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get current session ID for filtering.
|
|
74
|
+
* Uses storeId (session ID like "K_6Mc0diEz8") which matches shadow git.
|
|
75
|
+
* Returns null if no active session or filter is disabled.
|
|
76
|
+
*/
|
|
77
|
+
function getCurrentSessionId() {
|
|
78
|
+
if (!state.currentSessionOnly) return null;
|
|
79
|
+
// Use storeId (session ID), NOT providerSessionId (Claude's UUID)
|
|
80
|
+
// Shadow git stores session IDs in commits
|
|
81
|
+
return window.app?.activeSession?.storeId || null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Check if a session ID matches the current session.
|
|
86
|
+
* Handles backwards compatibility with old truncated 8-char IDs.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} sessionId - The session ID from shadow git (may be 8 or 11 chars)
|
|
89
|
+
* @param {string} currentId - The current session ID (always 11 chars)
|
|
90
|
+
*/
|
|
91
|
+
function sessionIdsMatch(sessionId, currentId) {
|
|
92
|
+
if (!sessionId || !currentId) return false;
|
|
93
|
+
// Exact match (both full IDs)
|
|
94
|
+
if (sessionId === currentId) return true;
|
|
95
|
+
// Old truncated ID is prefix of current full ID
|
|
96
|
+
if (currentId.startsWith(sessionId)) return true;
|
|
97
|
+
// Current ID is prefix of timeline ID (shouldn't happen, but safe)
|
|
98
|
+
if (sessionId.startsWith(currentId)) return true;
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// File-type → icon mapping. Mirrors file-explorer-widget so tree styling stays
|
|
103
|
+
// consistent across both widgets.
|
|
104
|
+
const FILE_TYPES = {
|
|
105
|
+
code: {
|
|
106
|
+
extensions: ['.js', '.ts', '.jsx', '.tsx', '.py', '.rb', '.go', '.rs', '.java', '.c', '.cpp', '.h', '.hpp', '.cs', '.php', '.swift', '.kt', '.scala', '.vue', '.svelte', '.css', '.scss', '.sass', '.less', '.html', '.xml', '.json', '.yaml', '.yml', '.toml', '.sh', '.bash', '.zsh', '.fish', '.sql', '.graphql', '.proto'],
|
|
107
|
+
icon: 'code',
|
|
108
|
+
color: 'var(--accent-blue)',
|
|
109
|
+
},
|
|
110
|
+
images: {
|
|
111
|
+
extensions: ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.ico', '.bmp', '.tiff', '.heic', '.avif'],
|
|
112
|
+
icon: 'image',
|
|
113
|
+
color: 'var(--accent-purple)',
|
|
114
|
+
},
|
|
115
|
+
docs: {
|
|
116
|
+
extensions: ['.md', '.markdown', '.mdx', '.txt', '.doc', '.docx', '.pdf', '.rtf', '.tex', '.org', '.rst'],
|
|
117
|
+
icon: 'file-text',
|
|
118
|
+
color: 'var(--accent-green)',
|
|
119
|
+
},
|
|
120
|
+
data: {
|
|
121
|
+
extensions: ['.csv', '.tsv', '.xls', '.xlsx', '.db', '.sqlite', '.parquet', '.arrow'],
|
|
122
|
+
icon: 'table',
|
|
123
|
+
color: 'var(--accent-orange)',
|
|
124
|
+
},
|
|
125
|
+
config: {
|
|
126
|
+
extensions: ['.env', '.gitignore', '.dockerignore', '.editorconfig', '.eslintrc', '.prettierrc', '.babelrc', 'Makefile', 'Dockerfile', '.npmrc', '.nvmrc'],
|
|
127
|
+
icon: 'settings',
|
|
128
|
+
color: 'var(--text-tertiary)',
|
|
129
|
+
},
|
|
130
|
+
archive: {
|
|
131
|
+
extensions: ['.zip', '.tar', '.gz', '.bz2', '.xz', '.7z', '.rar'],
|
|
132
|
+
icon: 'archive',
|
|
133
|
+
color: 'var(--accent-yellow)',
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
function getFileType(filename) {
|
|
138
|
+
const lower = filename.toLowerCase();
|
|
139
|
+
for (const config of Object.values(FILE_TYPES)) {
|
|
140
|
+
if (config.extensions.some(ext => lower.endsWith(ext) || lower === ext.slice(1))) {
|
|
141
|
+
return config;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return { icon: 'file', color: 'var(--text-secondary)' };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function fileIconHtml(filename) {
|
|
148
|
+
const t = getFileType(filename);
|
|
149
|
+
return `<span class="he-file-icon" style="color: ${t.color}">${ICONS[t.icon] || ICONS.file}</span>`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function treeFileIconHtml(filename) {
|
|
153
|
+
const t = getFileType(filename);
|
|
154
|
+
return `<span class="he-tree-icon" style="color: ${t.color}">${ICONS[t.icon] || ICONS.file}</span>`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const TREE_CHEVRON_SVG = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 6 15 12 9 18"/></svg>';
|
|
158
|
+
|
|
159
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
160
|
+
// API Calls
|
|
161
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
162
|
+
|
|
163
|
+
async function fetchTimeline() {
|
|
164
|
+
if (!state.cwd) return;
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const url = `${CONFIG.API_BASE}/api/shadow/timeline?cwd=${encodeURIComponent(state.cwd)}&limit=100`;
|
|
168
|
+
const res = await fetch(url);
|
|
169
|
+
const data = await res.json();
|
|
170
|
+
|
|
171
|
+
state.timeline = {
|
|
172
|
+
sessions: data.sessions || [],
|
|
173
|
+
totalCommits: data.totalCommits || 0,
|
|
174
|
+
};
|
|
175
|
+
} catch (err) {
|
|
176
|
+
console.error('Timeline fetch error:', err);
|
|
177
|
+
state.error = err.message;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function fetchDecisions() {
|
|
182
|
+
if (!state.cwd) return;
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
const url = `${CONFIG.API_BASE}/api/shadow/decisions?cwd=${encodeURIComponent(state.cwd)}&limit=100`;
|
|
186
|
+
const res = await fetch(url);
|
|
187
|
+
const data = await res.json();
|
|
188
|
+
state.decisions = data.decisions || [];
|
|
189
|
+
} catch (err) {
|
|
190
|
+
console.error('Decisions fetch error:', err);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function fetchProblems() {
|
|
195
|
+
if (!state.cwd) return;
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
const url = `${CONFIG.API_BASE}/api/shadow/problems?cwd=${encodeURIComponent(state.cwd)}&limit=100`;
|
|
199
|
+
const res = await fetch(url);
|
|
200
|
+
const data = await res.json();
|
|
201
|
+
state.problems = data.problems || [];
|
|
202
|
+
} catch (err) {
|
|
203
|
+
console.error('Problems fetch error:', err);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function fetchLearnings() {
|
|
208
|
+
if (!state.cwd) return;
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
const url = `${CONFIG.API_BASE}/api/shadow/learnings?cwd=${encodeURIComponent(state.cwd)}&limit=100`;
|
|
212
|
+
const res = await fetch(url);
|
|
213
|
+
const data = await res.json();
|
|
214
|
+
state.learnings = data.learnings || [];
|
|
215
|
+
} catch (err) {
|
|
216
|
+
console.error('Learnings fetch error:', err);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function fetchAllFiles() {
|
|
221
|
+
if (!state.cwd) return;
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
const url = `${CONFIG.API_BASE}/api/shadow/files?cwd=${encodeURIComponent(state.cwd)}`;
|
|
225
|
+
const res = await fetch(url);
|
|
226
|
+
const data = await res.json();
|
|
227
|
+
state.allFiles = data.files || [];
|
|
228
|
+
} catch (err) {
|
|
229
|
+
console.error('Files fetch error:', err);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async function fetchCommitDiff(hash) {
|
|
234
|
+
if (!state.cwd || state.loadedDiffs[hash]) return state.loadedDiffs[hash];
|
|
235
|
+
|
|
236
|
+
try {
|
|
237
|
+
const url = `${CONFIG.API_BASE}/api/shadow/commits/${hash}/diff?cwd=${encodeURIComponent(state.cwd)}`;
|
|
238
|
+
const res = await fetch(url);
|
|
239
|
+
const data = await res.json();
|
|
240
|
+
state.loadedDiffs[hash] = data;
|
|
241
|
+
return data;
|
|
242
|
+
} catch (err) {
|
|
243
|
+
console.error('Diff fetch error:', err);
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function openInDiffTool(commitHash, filePath) {
|
|
249
|
+
if (!commitHash || !filePath || !state.cwd) return;
|
|
250
|
+
const fullPath = isAbsolutePath(filePath) ? filePath : joinPath(state.cwd, filePath);
|
|
251
|
+
await window.app?.previewFileWithHistory(fullPath, {
|
|
252
|
+
cwd: state.cwd,
|
|
253
|
+
seed: { toKind: 'snapshot', toHash: commitHash, fromKind: 'auto' }
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async function previewFileAtHead(relPath) {
|
|
258
|
+
if (!state.cwd || !relPath) return;
|
|
259
|
+
const fullPath = isAbsolutePath(relPath) ? relPath : joinPath(state.cwd, relPath);
|
|
260
|
+
FilePreviewWidget.setCwd(state.cwd);
|
|
261
|
+
await FilePreviewWidget.preview(fullPath);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async function fetchTags() {
|
|
265
|
+
if (!state.cwd) return;
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
const url = `${CONFIG.API_BASE}/api/shadow/tags?cwd=${encodeURIComponent(state.cwd)}&limit=100`;
|
|
269
|
+
const res = await fetch(url);
|
|
270
|
+
const data = await res.json();
|
|
271
|
+
state.tags = {
|
|
272
|
+
tags: data.tags || [],
|
|
273
|
+
recentTags: data.recentTags || [],
|
|
274
|
+
total: data.total || 0
|
|
275
|
+
};
|
|
276
|
+
} catch (err) {
|
|
277
|
+
console.error('Tags fetch error:', err);
|
|
278
|
+
state.error = err.message;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async function fetchTagCommits(tag) {
|
|
283
|
+
if (!state.cwd) return;
|
|
284
|
+
|
|
285
|
+
try {
|
|
286
|
+
const url = `${CONFIG.API_BASE}/api/shadow/tags/${encodeURIComponent(tag)}/commits?cwd=${encodeURIComponent(state.cwd)}&limit=50`;
|
|
287
|
+
const res = await fetch(url);
|
|
288
|
+
const data = await res.json();
|
|
289
|
+
state.tagCommits = data.commits || [];
|
|
290
|
+
state.selectedTag = tag;
|
|
291
|
+
} catch (err) {
|
|
292
|
+
console.error('Tag commits fetch error:', err);
|
|
293
|
+
state.tagCommits = [];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function fetchFileHistory(filePath) {
|
|
298
|
+
if (!state.cwd) return;
|
|
299
|
+
|
|
300
|
+
try {
|
|
301
|
+
const url = `${CONFIG.API_BASE}/api/shadow/files/${encodeURIComponent(filePath)}/history?cwd=${encodeURIComponent(state.cwd)}`;
|
|
302
|
+
const res = await fetch(url);
|
|
303
|
+
const data = await res.json();
|
|
304
|
+
state.fileHistory = data.commits || [];
|
|
305
|
+
} catch (err) {
|
|
306
|
+
console.error('File history error:', err);
|
|
307
|
+
state.fileHistory = [];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
312
|
+
// Rendering
|
|
313
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
314
|
+
|
|
315
|
+
function render() {
|
|
316
|
+
if (!state.container) return;
|
|
317
|
+
|
|
318
|
+
// Preserve scroll position
|
|
319
|
+
const content = state.container.querySelector('.he-content');
|
|
320
|
+
const scrollTop = content?.scrollTop || 0;
|
|
321
|
+
|
|
322
|
+
const html = `
|
|
323
|
+
<div class="he-container">
|
|
324
|
+
${renderSearchBar()}
|
|
325
|
+
${renderTabs()}
|
|
326
|
+
<div class="he-content">
|
|
327
|
+
${state.loading ? renderLoading() : renderActiveTab()}
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
`;
|
|
331
|
+
|
|
332
|
+
state.container.innerHTML = html;
|
|
333
|
+
attachEventListeners();
|
|
334
|
+
|
|
335
|
+
// Restore scroll position
|
|
336
|
+
const newContent = state.container.querySelector('.he-content');
|
|
337
|
+
if (newContent && scrollTop > 0) {
|
|
338
|
+
newContent.scrollTop = scrollTop;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function renderSearchBar() {
|
|
343
|
+
// Get session ID (storeId) for filtering - this matches shadow git
|
|
344
|
+
const currentStoreId = window.app?.activeSession?.storeId;
|
|
345
|
+
// Show filter on all content tabs
|
|
346
|
+
const canFilterBySession = currentStoreId && state.activeTab !== 'search';
|
|
347
|
+
|
|
348
|
+
return `
|
|
349
|
+
<div class="he-search-bar">
|
|
350
|
+
<input type="text"
|
|
351
|
+
class="he-search-input"
|
|
352
|
+
placeholder="Search history... (tags: #feature, #bugfix)"
|
|
353
|
+
value="${escapeHtml(state.searchQuery)}"
|
|
354
|
+
data-action="search">
|
|
355
|
+
${canFilterBySession ? `
|
|
356
|
+
<label class="he-session-filter">
|
|
357
|
+
<input type="checkbox"
|
|
358
|
+
class="he-session-checkbox"
|
|
359
|
+
data-action="toggle-session-filter"
|
|
360
|
+
${state.currentSessionOnly ? 'checked' : ''}>
|
|
361
|
+
<span>Current session only</span>
|
|
362
|
+
</label>
|
|
363
|
+
` : ''}
|
|
364
|
+
${state.searchTags.length ? `
|
|
365
|
+
<div class="he-filter-pills">
|
|
366
|
+
${state.searchTags.map(tag => `
|
|
367
|
+
<span class="he-pill" data-action="remove-tag" data-tag="${escapeHtml(tag)}">
|
|
368
|
+
${escapeHtml(tag)} ×
|
|
369
|
+
</span>
|
|
370
|
+
`).join('')}
|
|
371
|
+
<span class="he-pill he-pill-clear" data-action="clear-filters">Clear</span>
|
|
372
|
+
</div>
|
|
373
|
+
` : ''}
|
|
374
|
+
</div>
|
|
375
|
+
`;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function renderTabs() {
|
|
379
|
+
const _ht = S.widgets.history_explorer.tabs;
|
|
380
|
+
const tabs = [
|
|
381
|
+
{ id: 'timeline', label: _ht.timeline, icon: 'history' },
|
|
382
|
+
{ id: 'files', label: _ht.files, icon: 'file' },
|
|
383
|
+
{ id: 'tags', label: _ht.tags, icon: 'tag' },
|
|
384
|
+
{ id: 'decisions', label: _ht.decisions, icon: 'lightbulb' },
|
|
385
|
+
{ id: 'problems', label: _ht.problems, icon: 'bug' },
|
|
386
|
+
{ id: 'learnings', label: _ht.learnings, icon: 'book' },
|
|
387
|
+
];
|
|
388
|
+
|
|
389
|
+
return `
|
|
390
|
+
<div class="he-tabs">
|
|
391
|
+
${tabs.map(tab => `
|
|
392
|
+
<button class="he-tab ${state.activeTab === tab.id ? 'active' : ''}"
|
|
393
|
+
data-action="switch-tab"
|
|
394
|
+
data-tab="${tab.id}">
|
|
395
|
+
${tab.label}
|
|
396
|
+
</button>
|
|
397
|
+
`).join('')}
|
|
398
|
+
</div>
|
|
399
|
+
`;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function renderLoading() {
|
|
403
|
+
return `
|
|
404
|
+
<div class="he-loading">
|
|
405
|
+
<div class="he-spinner"></div>
|
|
406
|
+
<span>Loading...</span>
|
|
407
|
+
</div>
|
|
408
|
+
`;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function renderActiveTab() {
|
|
412
|
+
switch (state.activeTab) {
|
|
413
|
+
case 'timeline': return renderTimeline();
|
|
414
|
+
case 'tags': return renderTags();
|
|
415
|
+
case 'decisions': return renderDecisions();
|
|
416
|
+
case 'problems': return renderProblems();
|
|
417
|
+
case 'learnings': return renderLearnings();
|
|
418
|
+
case 'files': return renderFiles();
|
|
419
|
+
default: return renderTimeline();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
424
|
+
// Timeline View
|
|
425
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
426
|
+
|
|
427
|
+
function renderTimeline() {
|
|
428
|
+
if (state.timeline.sessions.length === 0) {
|
|
429
|
+
return renderEmpty('No commits yet', 'Shadow git will track your changes as you work.');
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Filter by current session if enabled
|
|
433
|
+
let sessions = state.timeline.sessions;
|
|
434
|
+
let totalCommits = state.timeline.totalCommits;
|
|
435
|
+
const filterSession = getCurrentSessionId();
|
|
436
|
+
|
|
437
|
+
if (filterSession) {
|
|
438
|
+
sessions = sessions.filter(s => sessionIdsMatch(s.sessionId, filterSession));
|
|
439
|
+
totalCommits = sessions.reduce((sum, s) => sum + (s.commits?.length || s.turnCount || 0), 0);
|
|
440
|
+
|
|
441
|
+
if (sessions.length === 0) {
|
|
442
|
+
return renderEmpty('No history for this session', 'This session has no shadow git commits yet.');
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Group sessions by date
|
|
447
|
+
const sessionsByDate = groupSessionsByDate(sessions);
|
|
448
|
+
|
|
449
|
+
const filterNote = filterSession
|
|
450
|
+
? ` <span class="he-filter-active">(current session)</span>`
|
|
451
|
+
: '';
|
|
452
|
+
|
|
453
|
+
return `
|
|
454
|
+
<div class="he-timeline">
|
|
455
|
+
<div class="he-stats">
|
|
456
|
+
${totalCommits} commits across ${sessions.length} session${sessions.length !== 1 ? 's' : ''}${filterNote}
|
|
457
|
+
</div>
|
|
458
|
+
${Object.entries(sessionsByDate).map(([date, dateSessions]) => `
|
|
459
|
+
<div class="he-date-group">
|
|
460
|
+
<div class="he-date-header">${escapeHtml(date)}</div>
|
|
461
|
+
${dateSessions.map(renderSessionGroup).join('')}
|
|
462
|
+
</div>
|
|
463
|
+
`).join('')}
|
|
464
|
+
</div>
|
|
465
|
+
`;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function groupSessionsByDate(sessions) {
|
|
469
|
+
const groups = {};
|
|
470
|
+
const today = new Date().toDateString();
|
|
471
|
+
const yesterday = new Date(Date.now() - 86400000).toDateString();
|
|
472
|
+
|
|
473
|
+
for (const session of sessions) {
|
|
474
|
+
// Use lastTimestamp or firstTimestamp
|
|
475
|
+
const timestamp = session.lastTimestamp || session.firstTimestamp;
|
|
476
|
+
if (!timestamp) {
|
|
477
|
+
// No timestamp, group under "Unknown"
|
|
478
|
+
if (!groups['Unknown']) groups['Unknown'] = [];
|
|
479
|
+
groups['Unknown'].push(session);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const date = new Date(timestamp);
|
|
484
|
+
const dateStr = date.toDateString();
|
|
485
|
+
let label;
|
|
486
|
+
|
|
487
|
+
if (dateStr === today) {
|
|
488
|
+
label = 'Today';
|
|
489
|
+
} else if (dateStr === yesterday) {
|
|
490
|
+
label = 'Yesterday';
|
|
491
|
+
} else {
|
|
492
|
+
label = date.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (!groups[label]) groups[label] = [];
|
|
496
|
+
groups[label].push(session);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return groups;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function renderSessionGroup(session) {
|
|
503
|
+
const isExpanded = state.expandedSessions.has(session.sessionId);
|
|
504
|
+
const title = session.title || `Session ${session.sessionId}`;
|
|
505
|
+
const cost = session.totalCost?.toFixed(3) || '0.000';
|
|
506
|
+
|
|
507
|
+
// Format time from timestamp
|
|
508
|
+
const timestamp = session.lastTimestamp || session.firstTimestamp;
|
|
509
|
+
const timeStr = timestamp ? formatSessionTime(timestamp) : '';
|
|
510
|
+
|
|
511
|
+
return `
|
|
512
|
+
<div class="he-session ${isExpanded ? 'expanded' : ''}">
|
|
513
|
+
<div class="he-session-header" data-action="toggle-session" data-session="${escapeHtml(session.sessionId)}">
|
|
514
|
+
<span class="he-session-toggle">${isExpanded ? '▼' : '▶'}</span>
|
|
515
|
+
<div class="he-session-info">
|
|
516
|
+
<div class="he-session-title-row">
|
|
517
|
+
<span class="he-session-title">${escapeHtml(title.split('\n')[0])}</span>
|
|
518
|
+
${timeStr ? `<span class="he-session-time">${timeStr}</span>` : ''}
|
|
519
|
+
</div>
|
|
520
|
+
<div class="he-session-meta">
|
|
521
|
+
${session.turnCount} turns
|
|
522
|
+
${session.files?.length ? ` • ${session.files.length} ${session.files.length === 1 ? 'file' : 'files'}` : ''}
|
|
523
|
+
• $${cost}
|
|
524
|
+
${session.tags?.slice(0, 3).map(t => `<span class="he-tag">${escapeHtml(t)}</span>`).join('') || ''}
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
</div>
|
|
528
|
+
${isExpanded ? `
|
|
529
|
+
<div class="he-session-commits">
|
|
530
|
+
${session.commits.map(renderCommitCard).join('')}
|
|
531
|
+
</div>
|
|
532
|
+
` : ''}
|
|
533
|
+
</div>
|
|
534
|
+
`;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function formatSessionTime(timestamp) {
|
|
538
|
+
const date = new Date(timestamp);
|
|
539
|
+
return date.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true });
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function formatCommitTime(timestamp) {
|
|
543
|
+
if (!timestamp) return '';
|
|
544
|
+
const date = new Date(timestamp);
|
|
545
|
+
return date.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true });
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function renderCommitCard(commit) {
|
|
549
|
+
const isExpanded = state.expandedCommits.has(commit.hashShort);
|
|
550
|
+
const diff = state.loadedDiffs[commit.hashShort];
|
|
551
|
+
const timeStr = formatCommitTime(commit.timestamp);
|
|
552
|
+
|
|
553
|
+
return `
|
|
554
|
+
<div class="he-commit ${isExpanded ? 'expanded' : ''}">
|
|
555
|
+
<div class="he-commit-header" data-action="toggle-commit" data-hash="${escapeHtml(commit.hashShort)}">
|
|
556
|
+
<div class="he-commit-turn">T${commit.turn || '?'}</div>
|
|
557
|
+
<div class="he-commit-info">
|
|
558
|
+
<div class="he-commit-summary">${escapeHtml(commit.sections?.Summary || commit.summary || commit.subject || 'No summary')}</div>
|
|
559
|
+
<div class="he-commit-meta">
|
|
560
|
+
${commit.tags?.slice(0, 3).map(t => `<span class="he-tag">${escapeHtml(t)}</span>`).join('') || ''}
|
|
561
|
+
${commit.files?.length ? `<span class="he-file-count">${commit.files.length} files</span>` : ''}
|
|
562
|
+
${commit.cost ? `<span class="he-cost">$${commit.cost.toFixed(4)}</span>` : ''}
|
|
563
|
+
</div>
|
|
564
|
+
</div>
|
|
565
|
+
${timeStr ? `<span class="he-commit-time">${timeStr}</span>` : ''}
|
|
566
|
+
<span class="he-expand-icon">${isExpanded ? '▲' : '▼'}</span>
|
|
567
|
+
</div>
|
|
568
|
+
${isExpanded ? renderCommitDetails(commit, diff) : ''}
|
|
569
|
+
</div>
|
|
570
|
+
`;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function renderCommitDetails(commit, diff) {
|
|
574
|
+
return `
|
|
575
|
+
<div class="he-commit-details">
|
|
576
|
+
${diff?.files?.length ? `
|
|
577
|
+
<div class="he-files-changed">
|
|
578
|
+
<div class="he-section-title">Files Changed</div>
|
|
579
|
+
${diff.files.map(file => renderFileDiff(file, commit.hashShort)).join('')}
|
|
580
|
+
</div>
|
|
581
|
+
` : (commit.files?.length ? `
|
|
582
|
+
<div class="he-files-list">
|
|
583
|
+
<div class="he-section-title">Files Changed</div>
|
|
584
|
+
${commit.files.map(f => `<div class="he-file-item">${escapeHtml(f)}</div>`).join('')}
|
|
585
|
+
</div>
|
|
586
|
+
` : '')}
|
|
587
|
+
|
|
588
|
+
<div class="he-commit-footer">
|
|
589
|
+
<span class="he-hash" data-action="copy-hash" data-hash="${escapeHtml(commit.hash || commit.hashShort)}">${escapeHtml(commit.hashShort)}</span>
|
|
590
|
+
${commit.tokensIn ? `<span class="he-tokens">↓${(commit.tokensIn/1000).toFixed(1)}k ↑${(commit.tokensOut/1000).toFixed(1)}k</span>` : ''}
|
|
591
|
+
</div>
|
|
592
|
+
</div>
|
|
593
|
+
`;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function renderFileDiff(file, commitHash) {
|
|
597
|
+
return `
|
|
598
|
+
<div class="he-file-diff he-file-diff-clickable"
|
|
599
|
+
data-action="open-diff-tool"
|
|
600
|
+
data-hash="${escapeHtml(commitHash)}"
|
|
601
|
+
data-path="${escapeHtml(file.path)}"
|
|
602
|
+
data-tooltip="${escapeHtml(S.history_explorer?.open_in_diff_tool || 'Open in diff tool')}">
|
|
603
|
+
${fileIconHtml(basename(file.path))}
|
|
604
|
+
<span class="he-file-path">${escapeHtml(file.path)}</span>
|
|
605
|
+
<span class="he-file-stats">
|
|
606
|
+
<span class="he-additions">+${file.additions}</span>
|
|
607
|
+
<span class="he-deletions">-${file.deletions}</span>
|
|
608
|
+
</span>
|
|
609
|
+
<span class="he-diff-tool-icon">${ICONS.changes}</span>
|
|
610
|
+
</div>
|
|
611
|
+
`;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
615
|
+
// Tags View
|
|
616
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
617
|
+
|
|
618
|
+
function renderTags() {
|
|
619
|
+
// If a tag is selected, show its commits
|
|
620
|
+
if (state.selectedTag) {
|
|
621
|
+
return renderTagCommits();
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
const filterSession = getCurrentSessionId();
|
|
625
|
+
let tags = state.tags.tags;
|
|
626
|
+
let recentTags = state.tags.recentTags;
|
|
627
|
+
|
|
628
|
+
// Filter to tags from current session
|
|
629
|
+
if (filterSession) {
|
|
630
|
+
const sessionData = state.timeline.sessions.find(s => sessionIdsMatch(s.sessionId, filterSession));
|
|
631
|
+
if (sessionData?.tags) {
|
|
632
|
+
const sessionTags = new Set(sessionData.tags);
|
|
633
|
+
tags = tags.filter(t => sessionTags.has(t.name));
|
|
634
|
+
recentTags = recentTags.filter(t => sessionTags.has(t));
|
|
635
|
+
} else {
|
|
636
|
+
tags = [];
|
|
637
|
+
recentTags = [];
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
if (tags.length === 0 && !filterSession) {
|
|
642
|
+
return renderEmpty('No tags found', 'Tags are extracted from commits. Rich commits include auto-generated tags like #feature, #bugfix, etc.');
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (tags.length === 0 && filterSession) {
|
|
646
|
+
return renderEmpty('No tags in this session', 'This session has no tagged commits yet.');
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
const filterNote = filterSession ? ' <span class="he-filter-active">(current session)</span>' : '';
|
|
650
|
+
|
|
651
|
+
return `
|
|
652
|
+
<div class="he-tags-view">
|
|
653
|
+
${recentTags.length > 0 ? `
|
|
654
|
+
<div class="he-tags-section">
|
|
655
|
+
<div class="he-section-header">
|
|
656
|
+
<span class="he-section-icon">🔥</span>
|
|
657
|
+
<span>Recent Activity</span>
|
|
658
|
+
</div>
|
|
659
|
+
<div class="he-tag-cloud">
|
|
660
|
+
${recentTags.map(tagName => {
|
|
661
|
+
const tag = tags.find(t => t.name === tagName);
|
|
662
|
+
return tag ? renderTagPill(tag, true) : '';
|
|
663
|
+
}).join('')}
|
|
664
|
+
</div>
|
|
665
|
+
</div>
|
|
666
|
+
` : ''}
|
|
667
|
+
|
|
668
|
+
<div class="he-tags-section">
|
|
669
|
+
<div class="he-section-header">
|
|
670
|
+
<span class="he-section-icon">🏷️</span>
|
|
671
|
+
<span>All Tags (${tags.length})${filterNote}</span>
|
|
672
|
+
</div>
|
|
673
|
+
<div class="he-tag-list">
|
|
674
|
+
${tags.map(tag => renderTagRow(tag)).join('')}
|
|
675
|
+
</div>
|
|
676
|
+
</div>
|
|
677
|
+
</div>
|
|
678
|
+
`;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function renderTagPill(tag, highlight = false) {
|
|
682
|
+
return `
|
|
683
|
+
<button class="he-tag-pill ${highlight ? 'recent' : ''}"
|
|
684
|
+
data-action="select-tag"
|
|
685
|
+
data-tag="${escapeHtml(tag.name)}"
|
|
686
|
+
data-tooltip="${tag.count} commits">
|
|
687
|
+
<span class="he-tag-name">${escapeHtml(tag.name)}</span>
|
|
688
|
+
<span class="he-tag-count">${tag.count}</span>
|
|
689
|
+
</button>
|
|
690
|
+
`;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
function renderTagRow(tag) {
|
|
694
|
+
const lastSeen = tag.lastSeen ? formatRelativeTime(new Date(tag.lastSeen * 1000)) : 'unknown';
|
|
695
|
+
const firstSeen = tag.firstSeen ? formatRelativeTime(new Date(tag.firstSeen * 1000)) : 'unknown';
|
|
696
|
+
|
|
697
|
+
// Visual bar showing relative usage
|
|
698
|
+
const maxCount = state.tags.tags[0]?.count || 1;
|
|
699
|
+
const barWidth = Math.max(5, Math.round((tag.count / maxCount) * 100));
|
|
700
|
+
|
|
701
|
+
return `
|
|
702
|
+
<div class="he-tag-row" data-action="select-tag" data-tag="${escapeHtml(tag.name)}">
|
|
703
|
+
<div class="he-tag-row-main">
|
|
704
|
+
<span class="he-tag-name-lg">${escapeHtml(tag.name)}</span>
|
|
705
|
+
<span class="he-tag-count-lg">${tag.count}</span>
|
|
706
|
+
</div>
|
|
707
|
+
<div class="he-tag-bar-container">
|
|
708
|
+
<div class="he-tag-bar" style="width: ${barWidth}%"></div>
|
|
709
|
+
</div>
|
|
710
|
+
<div class="he-tag-meta">
|
|
711
|
+
${tag.recentCount > 0 ? `<span class="he-tag-recent">🔥 ${tag.recentCount} recent</span>` : ''}
|
|
712
|
+
<span class="he-tag-timespan">Last: ${lastSeen}</span>
|
|
713
|
+
</div>
|
|
714
|
+
</div>
|
|
715
|
+
`;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function renderTagCommits() {
|
|
719
|
+
const tag = state.selectedTag;
|
|
720
|
+
|
|
721
|
+
return `
|
|
722
|
+
<div class="he-tag-commits">
|
|
723
|
+
<div class="he-tag-commits-header">
|
|
724
|
+
<button class="he-back-btn" data-action="clear-tag">
|
|
725
|
+
← Back to tags
|
|
726
|
+
</button>
|
|
727
|
+
<div class="he-tag-title">
|
|
728
|
+
<span class="he-tag-pill selected">${escapeHtml(tag)}</span>
|
|
729
|
+
<span class="he-tag-commit-count">${state.tagCommits.length} commits</span>
|
|
730
|
+
</div>
|
|
731
|
+
</div>
|
|
732
|
+
<div class="he-tag-commits-list">
|
|
733
|
+
${state.tagCommits.length === 0
|
|
734
|
+
? '<div class="he-empty-small">No commits found with this tag</div>'
|
|
735
|
+
: state.tagCommits.map(commit => renderTagCommitCard(commit)).join('')
|
|
736
|
+
}
|
|
737
|
+
</div>
|
|
738
|
+
</div>
|
|
739
|
+
`;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function renderTagCommitCard(commit) {
|
|
743
|
+
const isExpanded = state.expandedCommits.has(commit.hash);
|
|
744
|
+
const summary = commit.summary || commit.subject || 'No summary';
|
|
745
|
+
const timestamp = commit.timestamp ? formatRelativeTime(new Date(commit.timestamp)) : '';
|
|
746
|
+
|
|
747
|
+
return `
|
|
748
|
+
<div class="he-commit-card ${isExpanded ? 'expanded' : ''}">
|
|
749
|
+
<div class="he-commit-header" data-action="toggle-commit" data-hash="${commit.hash}">
|
|
750
|
+
<span class="he-commit-toggle">${isExpanded ? '▼' : '▶'}</span>
|
|
751
|
+
<div class="he-commit-info">
|
|
752
|
+
<div class="he-commit-summary">${escapeHtml(summary.slice(0, 100))}</div>
|
|
753
|
+
<div class="he-commit-meta">
|
|
754
|
+
<span class="he-commit-hash">${commit.hashShort}</span>
|
|
755
|
+
<span class="he-commit-time">${timestamp}</span>
|
|
756
|
+
${commit.cost ? `<span class="he-commit-cost">$${commit.cost.toFixed(3)}</span>` : ''}
|
|
757
|
+
</div>
|
|
758
|
+
</div>
|
|
759
|
+
</div>
|
|
760
|
+
${isExpanded ? `
|
|
761
|
+
<div class="he-commit-body">
|
|
762
|
+
<div class="he-commit-tags">
|
|
763
|
+
${(commit.tags || []).map(t => `
|
|
764
|
+
<span class="he-tag ${t === state.selectedTag ? 'current' : ''}"
|
|
765
|
+
data-action="select-tag"
|
|
766
|
+
data-tag="${escapeHtml(t)}">${escapeHtml(t)}</span>
|
|
767
|
+
`).join('')}
|
|
768
|
+
</div>
|
|
769
|
+
${commit.sections?.Summary ? `
|
|
770
|
+
<div class="he-commit-section">
|
|
771
|
+
<div class="he-section-title">Summary</div>
|
|
772
|
+
<div class="he-section-content">${escapeHtml(commit.sections.Summary)}</div>
|
|
773
|
+
</div>
|
|
774
|
+
` : ''}
|
|
775
|
+
${commit.files?.length ? `
|
|
776
|
+
<div class="he-commit-section">
|
|
777
|
+
<div class="he-section-title">Files Changed</div>
|
|
778
|
+
<div class="he-file-list">
|
|
779
|
+
${commit.files.map(f => `
|
|
780
|
+
<span class="he-file he-file-clickable"
|
|
781
|
+
data-action="open-diff-tool"
|
|
782
|
+
data-hash="${escapeHtml(commit.hash)}"
|
|
783
|
+
data-path="${escapeHtml(f)}"
|
|
784
|
+
data-tooltip="${escapeHtml(S.history_explorer?.open_in_diff_tool || 'Open in diff tool')}">
|
|
785
|
+
${escapeHtml(f)}
|
|
786
|
+
<span class="he-file-chip-icon">${ICONS.changes}</span>
|
|
787
|
+
</span>
|
|
788
|
+
`).join('')}
|
|
789
|
+
</div>
|
|
790
|
+
</div>
|
|
791
|
+
` : ''}
|
|
792
|
+
</div>
|
|
793
|
+
` : ''}
|
|
794
|
+
</div>
|
|
795
|
+
`;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
799
|
+
// Decisions View
|
|
800
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
801
|
+
|
|
802
|
+
function renderDecisions() {
|
|
803
|
+
const filterSession = getCurrentSessionId();
|
|
804
|
+
let decisions = state.decisions;
|
|
805
|
+
|
|
806
|
+
if (filterSession) {
|
|
807
|
+
decisions = decisions.filter(d => sessionIdsMatch(d.sessionId, filterSession));
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if (decisions.length === 0 && !filterSession) {
|
|
811
|
+
return renderEmpty('No decisions recorded', 'Decisions are extracted from "## Decisions" sections in rich commits.');
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
if (decisions.length === 0 && filterSession) {
|
|
815
|
+
return renderEmpty('No decisions in this session', 'This session has no recorded decisions.');
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const filterNote = filterSession ? ' <span class="he-filter-active">(current session)</span>' : '';
|
|
819
|
+
|
|
820
|
+
return `
|
|
821
|
+
<div class="he-decisions">
|
|
822
|
+
<div class="he-stats">${decisions.length} decisions recorded${filterNote}</div>
|
|
823
|
+
${decisions.map(renderDecisionCard).join('')}
|
|
824
|
+
</div>
|
|
825
|
+
`;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
function renderDecisionCard(decision) {
|
|
829
|
+
return `
|
|
830
|
+
<div class="he-decision-card">
|
|
831
|
+
<div class="he-decision-header">
|
|
832
|
+
<span class="he-decision-icon">🔷</span>
|
|
833
|
+
<span class="he-decision-summary">${escapeHtml(decision.summary || 'Decision')}</span>
|
|
834
|
+
<span class="he-decision-turn">T${decision.turn}</span>
|
|
835
|
+
</div>
|
|
836
|
+
<div class="he-decision-content">${formatMarkdown(decision.content)}</div>
|
|
837
|
+
<div class="he-decision-meta">
|
|
838
|
+
${decision.tags?.map(t => `<span class="he-tag">${escapeHtml(t)}</span>`).join('') || ''}
|
|
839
|
+
<span class="he-hash" data-action="copy-hash" data-hash="${escapeHtml(decision.commitHash)}">${escapeHtml(decision.commitHash)}</span>
|
|
840
|
+
</div>
|
|
841
|
+
</div>
|
|
842
|
+
`;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
846
|
+
// Problems View
|
|
847
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
848
|
+
|
|
849
|
+
function renderProblems() {
|
|
850
|
+
const filterSession = getCurrentSessionId();
|
|
851
|
+
let problems = state.problems;
|
|
852
|
+
|
|
853
|
+
if (filterSession) {
|
|
854
|
+
problems = problems.filter(p => sessionIdsMatch(p.sessionId, filterSession));
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
if (problems.length === 0 && !filterSession) {
|
|
858
|
+
return renderEmpty('No problems recorded', 'Problems are extracted from "## Problems Solved" sections in rich commits.');
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
if (problems.length === 0 && filterSession) {
|
|
862
|
+
return renderEmpty('No problems in this session', 'This session has no recorded problems.');
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
const filterNote = filterSession ? ' <span class="he-filter-active">(current session)</span>' : '';
|
|
866
|
+
|
|
867
|
+
return `
|
|
868
|
+
<div class="he-problems">
|
|
869
|
+
<div class="he-stats">${problems.length} problems solved${filterNote}</div>
|
|
870
|
+
${problems.map(renderProblemCard).join('')}
|
|
871
|
+
</div>
|
|
872
|
+
`;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function renderProblemCard(problem) {
|
|
876
|
+
return `
|
|
877
|
+
<div class="he-problem-card">
|
|
878
|
+
<div class="he-problem-header">
|
|
879
|
+
<span class="he-problem-icon">🐛</span>
|
|
880
|
+
<span class="he-problem-summary">${escapeHtml(problem.summary || 'Bug fix')}</span>
|
|
881
|
+
<span class="he-problem-turn">T${problem.turn}</span>
|
|
882
|
+
</div>
|
|
883
|
+
<div class="he-problem-content">${formatMarkdown(problem.content)}</div>
|
|
884
|
+
<div class="he-problem-meta">
|
|
885
|
+
${problem.files?.slice(0, 3).map(f => `<span class="he-file-chip">${escapeHtml(f)}</span>`).join('') || ''}
|
|
886
|
+
${problem.tags?.map(t => `<span class="he-tag">${escapeHtml(t)}</span>`).join('') || ''}
|
|
887
|
+
</div>
|
|
888
|
+
</div>
|
|
889
|
+
`;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
893
|
+
// Learnings View
|
|
894
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
895
|
+
|
|
896
|
+
function renderLearnings() {
|
|
897
|
+
const filterSession = getCurrentSessionId();
|
|
898
|
+
let learnings = state.learnings;
|
|
899
|
+
|
|
900
|
+
if (filterSession) {
|
|
901
|
+
learnings = learnings.filter(l => sessionIdsMatch(l.sessionId, filterSession));
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
if (learnings.length === 0 && !filterSession) {
|
|
905
|
+
return renderEmpty('No learnings recorded', 'Learnings are extracted from "## Learnings" sections in rich commits.');
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
if (learnings.length === 0 && filterSession) {
|
|
909
|
+
return renderEmpty('No learnings in this session', 'This session has no recorded learnings.');
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
const filterNote = filterSession ? ' <span class="he-filter-active">(current session)</span>' : '';
|
|
913
|
+
|
|
914
|
+
return `
|
|
915
|
+
<div class="he-learnings">
|
|
916
|
+
<div class="he-stats">${learnings.length} learnings captured${filterNote}</div>
|
|
917
|
+
${learnings.map(renderLearningCard).join('')}
|
|
918
|
+
</div>
|
|
919
|
+
`;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
function renderLearningCard(learning) {
|
|
923
|
+
return `
|
|
924
|
+
<div class="he-learning-card">
|
|
925
|
+
<div class="he-learning-header">
|
|
926
|
+
<span class="he-learning-icon">💡</span>
|
|
927
|
+
<span class="he-learning-summary">${escapeHtml(learning.summary || 'Learning')}</span>
|
|
928
|
+
</div>
|
|
929
|
+
<div class="he-learning-content">${formatMarkdown(learning.content)}</div>
|
|
930
|
+
<div class="he-learning-meta">
|
|
931
|
+
${learning.tags?.map(t => `<span class="he-tag">${escapeHtml(t)}</span>`).join('') || ''}
|
|
932
|
+
</div>
|
|
933
|
+
</div>
|
|
934
|
+
`;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
938
|
+
// Files View
|
|
939
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
940
|
+
|
|
941
|
+
function renderFiles() {
|
|
942
|
+
// Use pre-fetched file list from /api/shadow/files
|
|
943
|
+
let allFiles = state.allFiles;
|
|
944
|
+
const filterSession = getCurrentSessionId();
|
|
945
|
+
|
|
946
|
+
// Filter to files touched by current session
|
|
947
|
+
if (filterSession) {
|
|
948
|
+
const sessionData = state.timeline.sessions.find(s => sessionIdsMatch(s.sessionId, filterSession));
|
|
949
|
+
if (sessionData?.files) {
|
|
950
|
+
// files is an array of files touched by this session
|
|
951
|
+
const sessionFiles = new Set(sessionData.files);
|
|
952
|
+
allFiles = allFiles.filter(f => sessionFiles.has(f));
|
|
953
|
+
} else {
|
|
954
|
+
allFiles = [];
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
if (allFiles.length === 0 && !filterSession) {
|
|
959
|
+
return renderEmpty('No files tracked', 'Files will appear here as they are modified.');
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
if (allFiles.length === 0 && filterSession) {
|
|
963
|
+
return renderEmpty('No files in this session', 'This session has not modified any files yet.');
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
if (state.selectedFile) {
|
|
967
|
+
return renderFileHistory();
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
// Filter files by search query
|
|
971
|
+
let filteredFiles = allFiles;
|
|
972
|
+
if (state.filesSearchQuery) {
|
|
973
|
+
const query = state.filesSearchQuery.toLowerCase();
|
|
974
|
+
filteredFiles = allFiles.filter(f => f.toLowerCase().includes(query));
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
return `
|
|
978
|
+
<div class="he-files">
|
|
979
|
+
<div class="he-files-toolbar">
|
|
980
|
+
<div class="he-files-search">
|
|
981
|
+
<input type="text"
|
|
982
|
+
class="he-files-search-input"
|
|
983
|
+
placeholder="Search files..."
|
|
984
|
+
value="${escapeHtml(state.filesSearchQuery)}"
|
|
985
|
+
data-action="files-search">
|
|
986
|
+
${state.filesSearchQuery ? `
|
|
987
|
+
<button class="he-files-search-clear" data-action="clear-files-search">×</button>
|
|
988
|
+
` : ''}
|
|
989
|
+
</div>
|
|
990
|
+
<div class="he-files-view-toggle">
|
|
991
|
+
<button class="he-view-btn ${state.filesViewMode === 'list' ? 'active' : ''}"
|
|
992
|
+
data-action="set-files-view" data-view="list" data-tooltip="List view">
|
|
993
|
+
☰
|
|
994
|
+
</button>
|
|
995
|
+
<button class="he-view-btn ${state.filesViewMode === 'tree' ? 'active' : ''}"
|
|
996
|
+
data-action="set-files-view" data-view="tree" data-tooltip="Tree view">
|
|
997
|
+
🌲
|
|
998
|
+
</button>
|
|
999
|
+
</div>
|
|
1000
|
+
</div>
|
|
1001
|
+
<div class="he-stats">
|
|
1002
|
+
${filteredFiles.length}${state.filesSearchQuery ? ` of ${allFiles.length}` : ''} files${filterSession ? ' <span class="he-filter-active">(current session)</span>' : ''}
|
|
1003
|
+
</div>
|
|
1004
|
+
${state.filesViewMode === 'tree'
|
|
1005
|
+
? renderFileTree(filteredFiles)
|
|
1006
|
+
: renderFileList(filteredFiles)
|
|
1007
|
+
}
|
|
1008
|
+
</div>
|
|
1009
|
+
`;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function renderFileList(files) {
|
|
1013
|
+
const previewLabel = S.history_explorer?.preview_file || 'Preview file';
|
|
1014
|
+
return `
|
|
1015
|
+
<div class="he-file-list">
|
|
1016
|
+
${files.map(f => `
|
|
1017
|
+
<div class="he-file-row" data-action="select-file" data-path="${escapeHtml(f)}">
|
|
1018
|
+
${fileIconHtml(basename(f))}
|
|
1019
|
+
<span class="he-file-name">${escapeHtml(f)}</span>
|
|
1020
|
+
<span class="he-file-preview-icon"
|
|
1021
|
+
data-action="preview-file"
|
|
1022
|
+
data-path="${escapeHtml(f)}"
|
|
1023
|
+
data-tooltip="${escapeHtml(previewLabel)}">
|
|
1024
|
+
${ICONS.eye}
|
|
1025
|
+
</span>
|
|
1026
|
+
</div>
|
|
1027
|
+
`).join('')}
|
|
1028
|
+
</div>
|
|
1029
|
+
`;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
function renderFileTree(files) {
|
|
1033
|
+
// Build tree structure from file paths
|
|
1034
|
+
const tree = {};
|
|
1035
|
+
files.forEach(filePath => {
|
|
1036
|
+
const parts = filePath.split('/');
|
|
1037
|
+
let node = tree;
|
|
1038
|
+
parts.forEach((part, i) => {
|
|
1039
|
+
if (i === parts.length - 1) {
|
|
1040
|
+
// File
|
|
1041
|
+
node[part] = { __isFile: true, __path: filePath };
|
|
1042
|
+
} else {
|
|
1043
|
+
// Directory
|
|
1044
|
+
if (!node[part]) {
|
|
1045
|
+
node[part] = { __isDir: true };
|
|
1046
|
+
}
|
|
1047
|
+
node = node[part];
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
return `<div class="he-file-tree">${renderTreeNode(tree, '')}</div>`;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
function renderTreeNode(node, path) {
|
|
1056
|
+
const entries = Object.entries(node)
|
|
1057
|
+
.filter(([k]) => !k.startsWith('__'))
|
|
1058
|
+
.sort((a, b) => {
|
|
1059
|
+
// Directories first, then files
|
|
1060
|
+
const aIsDir = a[1].__isDir;
|
|
1061
|
+
const bIsDir = b[1].__isDir;
|
|
1062
|
+
if (aIsDir && !bIsDir) return -1;
|
|
1063
|
+
if (!aIsDir && bIsDir) return 1;
|
|
1064
|
+
return a[0].localeCompare(b[0]);
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
const previewLabel = S.history_explorer?.preview_file || 'Preview file';
|
|
1068
|
+
return entries.map(([name, child]) => {
|
|
1069
|
+
if (child.__isFile) {
|
|
1070
|
+
return `
|
|
1071
|
+
<div class="he-tree-file" data-action="select-file" data-path="${escapeHtml(child.__path)}">
|
|
1072
|
+
<span class="he-tree-spacer"></span>
|
|
1073
|
+
${treeFileIconHtml(name)}
|
|
1074
|
+
<span class="he-tree-name">${escapeHtml(name)}</span>
|
|
1075
|
+
<span class="he-file-preview-icon"
|
|
1076
|
+
data-action="preview-file"
|
|
1077
|
+
data-path="${escapeHtml(child.__path)}"
|
|
1078
|
+
data-tooltip="${escapeHtml(previewLabel)}">
|
|
1079
|
+
${ICONS.eye}
|
|
1080
|
+
</span>
|
|
1081
|
+
</div>
|
|
1082
|
+
`;
|
|
1083
|
+
} else {
|
|
1084
|
+
const dirPath = path ? joinPath(path, name) : name;
|
|
1085
|
+
const isExpanded = state.expandedDirs.has(dirPath);
|
|
1086
|
+
return `
|
|
1087
|
+
<div class="he-tree-dir ${isExpanded ? 'expanded' : ''}">
|
|
1088
|
+
<div class="he-tree-dir-header" data-action="toggle-dir" data-path="${escapeHtml(dirPath)}">
|
|
1089
|
+
<span class="he-tree-chevron ${isExpanded ? 'expanded' : ''}">${TREE_CHEVRON_SVG}</span>
|
|
1090
|
+
<span class="he-tree-icon" style="color: var(--accent-yellow)">${ICONS.folder}</span>
|
|
1091
|
+
<span class="he-tree-name">${escapeHtml(name)}</span>
|
|
1092
|
+
</div>
|
|
1093
|
+
${isExpanded ? `
|
|
1094
|
+
<div class="he-tree-children">
|
|
1095
|
+
${renderTreeNode(child, dirPath)}
|
|
1096
|
+
</div>
|
|
1097
|
+
` : ''}
|
|
1098
|
+
</div>
|
|
1099
|
+
`;
|
|
1100
|
+
}
|
|
1101
|
+
}).join('');
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
function renderFileHistory() {
|
|
1105
|
+
const history = state.fileHistory;
|
|
1106
|
+
const totalAdditions = history.reduce((sum, c) => sum + (c.additions || 0), 0);
|
|
1107
|
+
const totalDeletions = history.reduce((sum, c) => sum + (c.deletions || 0), 0);
|
|
1108
|
+
|
|
1109
|
+
const commitsByDate = groupCommitsByDate(history);
|
|
1110
|
+
|
|
1111
|
+
return `
|
|
1112
|
+
<div class="he-file-history">
|
|
1113
|
+
${renderFileHistoryHeader(totalAdditions, totalDeletions)}
|
|
1114
|
+
<div class="he-file-commits">
|
|
1115
|
+
${history.length === 0 ? '<div class="he-empty-text">No history found for this file</div>' :
|
|
1116
|
+
Object.entries(commitsByDate).map(([date, commits]) => `
|
|
1117
|
+
<div class="he-date-group">
|
|
1118
|
+
<div class="he-date-header">${escapeHtml(date)}</div>
|
|
1119
|
+
${commits.map(renderFileCommitCard).join('')}
|
|
1120
|
+
</div>
|
|
1121
|
+
`).join('')
|
|
1122
|
+
}
|
|
1123
|
+
</div>
|
|
1124
|
+
</div>
|
|
1125
|
+
`;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
function renderFileHistoryHeader(totalAdditions, totalDeletions) {
|
|
1129
|
+
const fileName = basename(state.selectedFile);
|
|
1130
|
+
const dirPath = state.selectedFile.includes('/')
|
|
1131
|
+
? state.selectedFile.slice(0, state.selectedFile.lastIndexOf('/'))
|
|
1132
|
+
: '';
|
|
1133
|
+
const previewLabel = S.history_explorer?.preview_file || 'Preview file';
|
|
1134
|
+
|
|
1135
|
+
return `
|
|
1136
|
+
<div class="he-file-history-header">
|
|
1137
|
+
<button class="he-back-btn" data-action="clear-file" data-tooltip="Back to files">←</button>
|
|
1138
|
+
<div class="he-file-path-info">
|
|
1139
|
+
${dirPath ? `<span class="he-file-dir">${escapeHtml(dirPath)}/</span>` : ''}
|
|
1140
|
+
<span class="he-file-name-main">${escapeHtml(fileName)}</span>
|
|
1141
|
+
</div>
|
|
1142
|
+
<span class="he-stat-item">${state.fileHistory.length} commits</span>
|
|
1143
|
+
<span class="he-stat-sep">·</span>
|
|
1144
|
+
<span class="he-stat-additions">+${totalAdditions}</span>
|
|
1145
|
+
<span class="he-stat-deletions">−${totalDeletions}</span>
|
|
1146
|
+
<button class="he-icon-btn"
|
|
1147
|
+
data-action="preview-file"
|
|
1148
|
+
data-path="${escapeHtml(state.selectedFile)}"
|
|
1149
|
+
data-tooltip="${escapeHtml(previewLabel)}">
|
|
1150
|
+
${ICONS.eye}
|
|
1151
|
+
</button>
|
|
1152
|
+
</div>
|
|
1153
|
+
`;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
function renderFileCommitCard(commit) {
|
|
1157
|
+
const parsed = parseCommitSubject(commit.subject);
|
|
1158
|
+
// API returns sessionId/turn parsed server-side; frontmatter parse is the fallback
|
|
1159
|
+
const sessionId = commit.sessionId || parsed.session || null;
|
|
1160
|
+
const relTime = formatRelativeTime(new Date(commit.timestamp * 1000));
|
|
1161
|
+
const absTime = new Date(commit.timestamp * 1000).toLocaleString();
|
|
1162
|
+
const TA = S.widgets.history_explorer.turn_actions;
|
|
1163
|
+
|
|
1164
|
+
const maxChanges = Math.max(...state.fileHistory.map(c => (c.additions || 0) + (c.deletions || 0)), 1);
|
|
1165
|
+
const thisChanges = (commit.additions || 0) + (commit.deletions || 0);
|
|
1166
|
+
const changePercent = Math.round((thisChanges / maxChanges) * 100);
|
|
1167
|
+
const addPercent = thisChanges > 0 ? Math.round((commit.additions / thisChanges) * changePercent) : 0;
|
|
1168
|
+
const delPercent = changePercent - addPercent;
|
|
1169
|
+
|
|
1170
|
+
const tooltip = S.history_explorer?.open_in_diff_tool || 'Open in diff tool';
|
|
1171
|
+
|
|
1172
|
+
return `
|
|
1173
|
+
<div class="he-file-commit-card" data-hash="${commit.hash}"${sessionId ? ` data-session="${escapeHtml(sessionId)}"` : ''}>
|
|
1174
|
+
<div class="he-file-commit-main"
|
|
1175
|
+
data-action="show-file-commit-diff"
|
|
1176
|
+
data-hash="${commit.hash}"
|
|
1177
|
+
data-tooltip="${escapeHtml(tooltip)}">
|
|
1178
|
+
<div class="he-file-commit-content">
|
|
1179
|
+
<div class="he-file-commit-header">
|
|
1180
|
+
<span class="he-commit-time" data-tooltip="${absTime}">${relTime}</span>
|
|
1181
|
+
<span class="he-commit-hash">${commit.hash}</span>
|
|
1182
|
+
${sessionId ? `
|
|
1183
|
+
<span class="he-commit-session"
|
|
1184
|
+
data-action="fh-go-session"
|
|
1185
|
+
data-session="${escapeHtml(sessionId)}"
|
|
1186
|
+
data-tooltip="${escapeHtml(TA.go_to_session)}">
|
|
1187
|
+
${escapeHtml(sessionId.slice(0, 8))}
|
|
1188
|
+
</span>
|
|
1189
|
+
` : ''}
|
|
1190
|
+
</div>
|
|
1191
|
+
<div class="he-file-commit-summary">
|
|
1192
|
+
${escapeHtml(parsed.summary || 'No summary')}
|
|
1193
|
+
</div>
|
|
1194
|
+
${parsed.tags.length > 0 ? `
|
|
1195
|
+
<div class="he-file-commit-tags">
|
|
1196
|
+
${parsed.tags.slice(0, 4).map(tag => `
|
|
1197
|
+
<span class="he-mini-tag">${escapeHtml(tag)}</span>
|
|
1198
|
+
`).join('')}
|
|
1199
|
+
${parsed.tags.length > 4 ? `<span class="he-mini-tag">+${parsed.tags.length - 4}</span>` : ''}
|
|
1200
|
+
</div>
|
|
1201
|
+
` : ''}
|
|
1202
|
+
</div>
|
|
1203
|
+
<div class="he-file-commit-stats">
|
|
1204
|
+
<div class="he-change-bar" data-tooltip="+${commit.additions} -${commit.deletions}">
|
|
1205
|
+
<div class="he-change-bar-add" style="width: ${addPercent}%"></div>
|
|
1206
|
+
<div class="he-change-bar-del" style="width: ${delPercent}%"></div>
|
|
1207
|
+
</div>
|
|
1208
|
+
<div class="he-change-numbers">
|
|
1209
|
+
<span class="he-additions">+${commit.additions || 0}</span>
|
|
1210
|
+
<span class="he-deletions">-${commit.deletions || 0}</span>
|
|
1211
|
+
</div>
|
|
1212
|
+
</div>
|
|
1213
|
+
<span class="he-diff-tool-icon">${ICONS.changes}</span>
|
|
1214
|
+
</div>
|
|
1215
|
+
<div class="he-file-commit-actions">
|
|
1216
|
+
${sessionId ? `
|
|
1217
|
+
<button class="he-icon-btn"
|
|
1218
|
+
data-action="fh-go-session"
|
|
1219
|
+
data-session="${escapeHtml(sessionId)}"
|
|
1220
|
+
data-tooltip="${escapeHtml(TA.go_to_session)}">${ICONS.openInTab}</button>
|
|
1221
|
+
<button class="he-icon-btn"
|
|
1222
|
+
data-action="fh-go-session-bg"
|
|
1223
|
+
data-session="${escapeHtml(sessionId)}"
|
|
1224
|
+
data-tooltip="${escapeHtml(TA.open_session_new_tab)}">${ICONS.external}</button>
|
|
1225
|
+
` : ''}
|
|
1226
|
+
<button class="he-icon-btn"
|
|
1227
|
+
data-action="fh-turn-menu"
|
|
1228
|
+
data-tooltip="${escapeHtml(TA.more_actions)}">${ICONS.ellipsis}</button>
|
|
1229
|
+
</div>
|
|
1230
|
+
</div>
|
|
1231
|
+
`;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
function groupCommitsByDate(commits) {
|
|
1235
|
+
const groups = {};
|
|
1236
|
+
const today = new Date().toDateString();
|
|
1237
|
+
const yesterday = new Date(Date.now() - 86400000).toDateString();
|
|
1238
|
+
|
|
1239
|
+
for (const commit of commits) {
|
|
1240
|
+
const date = new Date(commit.timestamp * 1000);
|
|
1241
|
+
const dateStr = date.toDateString();
|
|
1242
|
+
let label;
|
|
1243
|
+
|
|
1244
|
+
if (dateStr === today) {
|
|
1245
|
+
label = 'Today';
|
|
1246
|
+
} else if (dateStr === yesterday) {
|
|
1247
|
+
label = 'Yesterday';
|
|
1248
|
+
} else {
|
|
1249
|
+
label = date.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
if (!groups[label]) groups[label] = [];
|
|
1253
|
+
groups[label].push(commit);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
return groups;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
function parseCommitSubject(subject) {
|
|
1260
|
+
// Parse YAML frontmatter from commit message
|
|
1261
|
+
const result = { tags: [], session: null, summary: '', turn: null };
|
|
1262
|
+
|
|
1263
|
+
if (!subject) return result;
|
|
1264
|
+
|
|
1265
|
+
// Extract tags
|
|
1266
|
+
const tagsMatch = subject.match(/tags:\s*\[([^\]]+)\]/);
|
|
1267
|
+
if (tagsMatch) {
|
|
1268
|
+
result.tags = tagsMatch[1].split(',').map(t => t.trim().replace(/^#/, ''));
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// Extract session
|
|
1272
|
+
const sessionMatch = subject.match(/session:\s*(\S+)/);
|
|
1273
|
+
if (sessionMatch) {
|
|
1274
|
+
result.session = sessionMatch[1];
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// Extract turn
|
|
1278
|
+
const turnMatch = subject.match(/turn:\s*(\d+)/);
|
|
1279
|
+
if (turnMatch) {
|
|
1280
|
+
result.turn = parseInt(turnMatch[1]);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
// Extract summary - look for summary: field or last line after ---
|
|
1284
|
+
const summaryMatch = subject.match(/summary:\s*"([^"]+)"/);
|
|
1285
|
+
if (summaryMatch) {
|
|
1286
|
+
result.summary = summaryMatch[1];
|
|
1287
|
+
} else {
|
|
1288
|
+
// Fallback: use the part after the last ---
|
|
1289
|
+
const parts = subject.split('---');
|
|
1290
|
+
if (parts.length > 1) {
|
|
1291
|
+
const lastPart = parts[parts.length - 1].trim();
|
|
1292
|
+
// Remove [sessionId] Turn X: prefix
|
|
1293
|
+
result.summary = lastPart.replace(/^\[[^\]]+\]\s*Turn\s*\d+:\s*/, '').slice(0, 150);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
return result;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1301
|
+
// Helpers
|
|
1302
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1303
|
+
|
|
1304
|
+
function renderEmpty(title, message) {
|
|
1305
|
+
return `
|
|
1306
|
+
<div class="he-empty">
|
|
1307
|
+
<div class="he-empty-title">${escapeHtml(title)}</div>
|
|
1308
|
+
<div class="he-empty-message">${escapeHtml(message)}</div>
|
|
1309
|
+
</div>
|
|
1310
|
+
`;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
function formatMarkdown(text) {
|
|
1314
|
+
if (!text) return '';
|
|
1315
|
+
// Simple markdown: bullets, bold
|
|
1316
|
+
return escapeHtml(text)
|
|
1317
|
+
.replace(/^- /gm, '• ')
|
|
1318
|
+
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
|
1319
|
+
.replace(/\n/g, '<br>');
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1323
|
+
// Event Handlers
|
|
1324
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1325
|
+
|
|
1326
|
+
function attachEventListeners() {
|
|
1327
|
+
if (!state.container) return;
|
|
1328
|
+
|
|
1329
|
+
// Prevent duplicate listeners by checking if already attached
|
|
1330
|
+
if (state.container._heListenersAttached) return;
|
|
1331
|
+
state.container._heListenersAttached = true;
|
|
1332
|
+
|
|
1333
|
+
state.container.addEventListener('click', handleClick);
|
|
1334
|
+
state.container.addEventListener('input', handleInput);
|
|
1335
|
+
state.container.addEventListener('change', handleChange);
|
|
1336
|
+
state.container.addEventListener('keydown', handleKeydown);
|
|
1337
|
+
state.container.addEventListener('contextmenu', handleContextMenu);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
function handleContextMenu(e) {
|
|
1341
|
+
const card = e.target.closest('.he-file-commit-card');
|
|
1342
|
+
if (!card) return;
|
|
1343
|
+
e.preventDefault();
|
|
1344
|
+
showTurnMenu(card, e.clientX, e.clientY);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
function handleChange(e) {
|
|
1348
|
+
// Handle checkbox changes
|
|
1349
|
+
if (e.target.classList.contains('he-session-checkbox')) {
|
|
1350
|
+
state.currentSessionOnly = e.target.checked;
|
|
1351
|
+
localStorage.setItem('he-current-session-only', state.currentSessionOnly);
|
|
1352
|
+
render();
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
function handleClick(e) {
|
|
1357
|
+
const target = e.target.closest('[data-action]');
|
|
1358
|
+
if (!target) return;
|
|
1359
|
+
|
|
1360
|
+
const action = target.dataset.action;
|
|
1361
|
+
|
|
1362
|
+
switch (action) {
|
|
1363
|
+
case 'switch-tab':
|
|
1364
|
+
switchTab(target.dataset.tab);
|
|
1365
|
+
break;
|
|
1366
|
+
case 'toggle-session':
|
|
1367
|
+
toggleSession(target.dataset.session);
|
|
1368
|
+
break;
|
|
1369
|
+
case 'toggle-commit':
|
|
1370
|
+
toggleCommit(target.dataset.hash);
|
|
1371
|
+
break;
|
|
1372
|
+
case 'open-diff-tool':
|
|
1373
|
+
openInDiffTool(target.dataset.hash, target.dataset.path);
|
|
1374
|
+
break;
|
|
1375
|
+
case 'preview-file':
|
|
1376
|
+
previewFileAtHead(target.dataset.path);
|
|
1377
|
+
break;
|
|
1378
|
+
case 'copy-hash':
|
|
1379
|
+
copyToClipboard(target.dataset.hash);
|
|
1380
|
+
break;
|
|
1381
|
+
case 'remove-tag':
|
|
1382
|
+
removeTag(target.dataset.tag);
|
|
1383
|
+
break;
|
|
1384
|
+
case 'clear-filters':
|
|
1385
|
+
clearFilters();
|
|
1386
|
+
break;
|
|
1387
|
+
case 'select-file':
|
|
1388
|
+
selectFile(target.dataset.path);
|
|
1389
|
+
break;
|
|
1390
|
+
case 'clear-file':
|
|
1391
|
+
state.selectedFile = null;
|
|
1392
|
+
state.fileHistory = [];
|
|
1393
|
+
render();
|
|
1394
|
+
break;
|
|
1395
|
+
case 'select-tag':
|
|
1396
|
+
selectTag(target.dataset.tag);
|
|
1397
|
+
break;
|
|
1398
|
+
case 'clear-tag':
|
|
1399
|
+
state.selectedTag = null;
|
|
1400
|
+
state.tagCommits = [];
|
|
1401
|
+
render();
|
|
1402
|
+
break;
|
|
1403
|
+
case 'clear-files-search':
|
|
1404
|
+
state.filesSearchQuery = '';
|
|
1405
|
+
render();
|
|
1406
|
+
break;
|
|
1407
|
+
case 'set-files-view':
|
|
1408
|
+
state.filesViewMode = target.dataset.view;
|
|
1409
|
+
localStorage.setItem('he-files-view-mode', target.dataset.view);
|
|
1410
|
+
// Auto-expand first level dirs in tree view
|
|
1411
|
+
if (target.dataset.view === 'tree' && state.expandedDirs.size === 0) {
|
|
1412
|
+
expandFirstLevelDirs();
|
|
1413
|
+
}
|
|
1414
|
+
render();
|
|
1415
|
+
break;
|
|
1416
|
+
case 'toggle-dir':
|
|
1417
|
+
toggleDir(target.dataset.path);
|
|
1418
|
+
break;
|
|
1419
|
+
|
|
1420
|
+
// File history actions
|
|
1421
|
+
case 'show-file-commit-diff':
|
|
1422
|
+
if (state.selectedFile) openInDiffTool(target.dataset.hash, state.selectedFile);
|
|
1423
|
+
break;
|
|
1424
|
+
case 'fh-go-session':
|
|
1425
|
+
goToSession(target.dataset.session);
|
|
1426
|
+
break;
|
|
1427
|
+
case 'fh-go-session-bg':
|
|
1428
|
+
goToSession(target.dataset.session, { background: true });
|
|
1429
|
+
break;
|
|
1430
|
+
case 'fh-turn-menu': {
|
|
1431
|
+
const card = target.closest('.he-file-commit-card');
|
|
1432
|
+
if (!card) break;
|
|
1433
|
+
const rect = target.getBoundingClientRect();
|
|
1434
|
+
showTurnMenu(card, rect.left, rect.bottom + 4);
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
function handleInput(e) {
|
|
1441
|
+
if (e.target.dataset.action === 'search') {
|
|
1442
|
+
state.searchQuery = e.target.value;
|
|
1443
|
+
// Debounce search
|
|
1444
|
+
clearTimeout(state.searchTimeout);
|
|
1445
|
+
state.searchTimeout = setTimeout(() => {
|
|
1446
|
+
loadTabData();
|
|
1447
|
+
}, 300);
|
|
1448
|
+
}
|
|
1449
|
+
if (e.target.dataset.action === 'files-search') {
|
|
1450
|
+
state.filesSearchQuery = e.target.value;
|
|
1451
|
+
render();
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
function handleKeydown(e) {
|
|
1456
|
+
if (e.key === '/' && !e.target.matches('input, textarea')) {
|
|
1457
|
+
e.preventDefault();
|
|
1458
|
+
const input = state.container?.querySelector('.he-search-input');
|
|
1459
|
+
input?.focus();
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
async function switchTab(tab) {
|
|
1464
|
+
state.activeTab = tab;
|
|
1465
|
+
state.loading = true;
|
|
1466
|
+
render();
|
|
1467
|
+
|
|
1468
|
+
await loadTabData();
|
|
1469
|
+
|
|
1470
|
+
state.loading = false;
|
|
1471
|
+
render();
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
async function loadTabData() {
|
|
1475
|
+
switch (state.activeTab) {
|
|
1476
|
+
case 'timeline':
|
|
1477
|
+
await fetchTimeline();
|
|
1478
|
+
break;
|
|
1479
|
+
case 'decisions':
|
|
1480
|
+
await fetchDecisions();
|
|
1481
|
+
break;
|
|
1482
|
+
case 'problems':
|
|
1483
|
+
await fetchProblems();
|
|
1484
|
+
break;
|
|
1485
|
+
case 'learnings':
|
|
1486
|
+
await fetchLearnings();
|
|
1487
|
+
break;
|
|
1488
|
+
case 'tags':
|
|
1489
|
+
await fetchTags();
|
|
1490
|
+
break;
|
|
1491
|
+
case 'files':
|
|
1492
|
+
await fetchAllFiles();
|
|
1493
|
+
break;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
function toggleSession(sessionId) {
|
|
1498
|
+
if (state.expandedSessions.has(sessionId)) {
|
|
1499
|
+
state.expandedSessions.delete(sessionId);
|
|
1500
|
+
} else {
|
|
1501
|
+
state.expandedSessions.add(sessionId);
|
|
1502
|
+
}
|
|
1503
|
+
render();
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
async function toggleCommit(hash) {
|
|
1507
|
+
if (state.expandedCommits.has(hash)) {
|
|
1508
|
+
state.expandedCommits.delete(hash);
|
|
1509
|
+
} else {
|
|
1510
|
+
state.expandedCommits.add(hash);
|
|
1511
|
+
// Load diff if not already loaded
|
|
1512
|
+
if (!state.loadedDiffs[hash]) {
|
|
1513
|
+
await fetchCommitDiff(hash);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
render();
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
async function selectFile(path) {
|
|
1520
|
+
state.selectedFile = path;
|
|
1521
|
+
state.loading = true;
|
|
1522
|
+
render();
|
|
1523
|
+
|
|
1524
|
+
await fetchFileHistory(path);
|
|
1525
|
+
|
|
1526
|
+
state.loading = false;
|
|
1527
|
+
render();
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1531
|
+
// File History Helpers
|
|
1532
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
async function selectTag(tag) {
|
|
1536
|
+
state.loading = true;
|
|
1537
|
+
render();
|
|
1538
|
+
|
|
1539
|
+
await fetchTagCommits(tag);
|
|
1540
|
+
|
|
1541
|
+
state.loading = false;
|
|
1542
|
+
render();
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
function toggleDir(dirPath) {
|
|
1546
|
+
if (state.expandedDirs.has(dirPath)) {
|
|
1547
|
+
state.expandedDirs.delete(dirPath);
|
|
1548
|
+
} else {
|
|
1549
|
+
state.expandedDirs.add(dirPath);
|
|
1550
|
+
}
|
|
1551
|
+
render();
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
function expandFirstLevelDirs() {
|
|
1555
|
+
// Find first-level directories from allFiles
|
|
1556
|
+
const firstLevelDirs = new Set();
|
|
1557
|
+
state.allFiles.forEach(f => {
|
|
1558
|
+
const firstPart = f.split('/')[0];
|
|
1559
|
+
if (f.includes('/')) {
|
|
1560
|
+
firstLevelDirs.add(firstPart);
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
// Expand first level dirs
|
|
1565
|
+
firstLevelDirs.forEach(d => state.expandedDirs.add(d));
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
function removeTag(tag) {
|
|
1569
|
+
state.searchTags = state.searchTags.filter(t => t !== tag);
|
|
1570
|
+
loadTabData().then(() => render());
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
function clearFilters() {
|
|
1574
|
+
state.searchQuery = '';
|
|
1575
|
+
state.searchTags = [];
|
|
1576
|
+
state.searchFiles = [];
|
|
1577
|
+
loadTabData().then(() => render());
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
function copyToClipboard(text) {
|
|
1581
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
1582
|
+
showToast(`Copied: ${text}`);
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1587
|
+
// Turn actions (file history cards): context menu + session navigation
|
|
1588
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1589
|
+
|
|
1590
|
+
function showTurnMenu(card, x, y) {
|
|
1591
|
+
const TA = S.widgets.history_explorer.turn_actions;
|
|
1592
|
+
const sessionId = card.dataset.session || null;
|
|
1593
|
+
const hash = card.dataset.hash;
|
|
1594
|
+
|
|
1595
|
+
const items = [];
|
|
1596
|
+
if (sessionId) {
|
|
1597
|
+
items.push(
|
|
1598
|
+
{ label: TA.go_to_session, action: () => goToSession(sessionId) },
|
|
1599
|
+
{ label: TA.open_session_new_tab, action: () => goToSession(sessionId, { background: true }) },
|
|
1600
|
+
{ label: TA.view_session_log, action: () => openSessionLog(sessionId) },
|
|
1601
|
+
);
|
|
1602
|
+
} else {
|
|
1603
|
+
items.push({ label: TA.no_session, disabled: true });
|
|
1604
|
+
}
|
|
1605
|
+
items.push({ type: 'separator' });
|
|
1606
|
+
if (state.selectedFile) {
|
|
1607
|
+
items.push({
|
|
1608
|
+
label: S.widgets.history_explorer.open_in_diff_tool,
|
|
1609
|
+
action: () => openInDiffTool(hash, state.selectedFile),
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
items.push({ label: TA.copy_commit_hash, action: () => copyToClipboard(hash) });
|
|
1613
|
+
if (sessionId) {
|
|
1614
|
+
items.push({ label: TA.copy_session_id, action: () => copyToClipboard(sessionId) });
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
const menu = window.app?.contextMenu || (window._heCtxMenu ||= new ContextMenu());
|
|
1618
|
+
menu.show(x, y, items);
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
async function goToSession(sessionId, { background = false } = {}) {
|
|
1622
|
+
const app = window.app;
|
|
1623
|
+
if (!app || !sessionId) return;
|
|
1624
|
+
|
|
1625
|
+
// Prefix-tolerant match: old shadow commits carry truncated 8-char IDs
|
|
1626
|
+
const existing = app.sessionManager?.sessions.find(s => sessionIdsMatch(sessionId, s.storeId));
|
|
1627
|
+
if (existing) {
|
|
1628
|
+
if (!background) app.switchToSession(existing);
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
const loaded = await app.loadSessionFromServer(sessionId, 50, false, { background });
|
|
1633
|
+
if (!loaded) {
|
|
1634
|
+
const TA = S.widgets.history_explorer.turn_actions;
|
|
1635
|
+
showToast(TA.session_not_found.replace('{id}', sessionId));
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
function openSessionLog(sessionId) {
|
|
1640
|
+
if (!sessionId) return;
|
|
1641
|
+
WidgetManager.open('log-explorer', { sessionId });
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
function showToast(message) {
|
|
1645
|
+
const toast = document.createElement('div');
|
|
1646
|
+
toast.className = 'he-toast';
|
|
1647
|
+
toast.textContent = message;
|
|
1648
|
+
document.body.appendChild(toast);
|
|
1649
|
+
setTimeout(() => toast.remove(), 2000);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1653
|
+
// Widget Registration
|
|
1654
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1655
|
+
|
|
1656
|
+
export function registerHistoryExplorerWidget() {
|
|
1657
|
+
WidgetManager.register('history-explorer', {
|
|
1658
|
+
type: 'bottom-sheet',
|
|
1659
|
+
title: S.widgets.titles.history_explorer,
|
|
1660
|
+
icon: 'history',
|
|
1661
|
+
scope: 'global',
|
|
1662
|
+
shortcut: 'Alt+H',
|
|
1663
|
+
|
|
1664
|
+
deviceTypes: {
|
|
1665
|
+
default: 'bottom-sheet',
|
|
1666
|
+
phone: 'bottom-sheet',
|
|
1667
|
+
tablet: 'bottom-sheet',
|
|
1668
|
+
desktop: 'sidebar-right'
|
|
1669
|
+
},
|
|
1670
|
+
|
|
1671
|
+
heights: {
|
|
1672
|
+
half: '50vh',
|
|
1673
|
+
full: '85vh'
|
|
1674
|
+
},
|
|
1675
|
+
|
|
1676
|
+
width: '500px',
|
|
1677
|
+
minWidth: '350px',
|
|
1678
|
+
maxWidth: '700px',
|
|
1679
|
+
|
|
1680
|
+
allowedTypes: ['bottom-sheet', 'sidebar-right', 'floating', 'tab'],
|
|
1681
|
+
|
|
1682
|
+
headerActions: [
|
|
1683
|
+
{
|
|
1684
|
+
icon: 'tool',
|
|
1685
|
+
title: S.widgets.header_actions.open_auto_journal,
|
|
1686
|
+
onClick: () => {
|
|
1687
|
+
WidgetManager.open('helpers-install');
|
|
1688
|
+
}
|
|
1689
|
+
},
|
|
1690
|
+
{
|
|
1691
|
+
icon: 'refresh',
|
|
1692
|
+
title: S.widgets.header_actions.refresh,
|
|
1693
|
+
onClick: async () => {
|
|
1694
|
+
state.loading = true;
|
|
1695
|
+
render();
|
|
1696
|
+
await loadTabData();
|
|
1697
|
+
state.loading = false;
|
|
1698
|
+
render();
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
],
|
|
1702
|
+
|
|
1703
|
+
render: (container, ctx) => {
|
|
1704
|
+
state.container = container;
|
|
1705
|
+
|
|
1706
|
+
// Get CWD
|
|
1707
|
+
const cwd = ctx.cwd || WidgetManager.currentCwd || window.app?.activeSession?.cwd;
|
|
1708
|
+
if (cwd && cwd !== state.cwd) {
|
|
1709
|
+
state.cwd = cwd;
|
|
1710
|
+
// Reset data
|
|
1711
|
+
state.timeline = { sessions: [], totalCommits: 0 };
|
|
1712
|
+
state.decisions = [];
|
|
1713
|
+
state.problems = [];
|
|
1714
|
+
state.learnings = [];
|
|
1715
|
+
state.expandedSessions.clear();
|
|
1716
|
+
state.expandedCommits.clear();
|
|
1717
|
+
state.loadedDiffs = {};
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
// Initial render
|
|
1721
|
+
render();
|
|
1722
|
+
|
|
1723
|
+
// Load data if needed
|
|
1724
|
+
if (state.timeline.sessions.length === 0 && state.cwd) {
|
|
1725
|
+
state.loading = true;
|
|
1726
|
+
render();
|
|
1727
|
+
loadTabData().then(() => {
|
|
1728
|
+
state.loading = false;
|
|
1729
|
+
render();
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
},
|
|
1733
|
+
|
|
1734
|
+
onOpen: () => {
|
|
1735
|
+
if (!state.cwd) {
|
|
1736
|
+
state.cwd = WidgetManager.currentCwd || window.app?.activeSession?.cwd;
|
|
1737
|
+
}
|
|
1738
|
+
if (state.cwd && state.timeline.sessions.length === 0) {
|
|
1739
|
+
state.loading = true;
|
|
1740
|
+
render();
|
|
1741
|
+
loadTabData().then(() => {
|
|
1742
|
+
state.loading = false;
|
|
1743
|
+
render();
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
},
|
|
1747
|
+
|
|
1748
|
+
onCwdChange: (cwd) => {
|
|
1749
|
+
if (cwd !== state.cwd) {
|
|
1750
|
+
state.cwd = cwd;
|
|
1751
|
+
state.timeline = { sessions: [], totalCommits: 0 };
|
|
1752
|
+
state.expandedSessions.clear();
|
|
1753
|
+
state.expandedCommits.clear();
|
|
1754
|
+
state.loadedDiffs = {};
|
|
1755
|
+
|
|
1756
|
+
const widget = WidgetManager.widgets.get('history-explorer');
|
|
1757
|
+
if (widget?.isVisible) {
|
|
1758
|
+
state.loading = true;
|
|
1759
|
+
render();
|
|
1760
|
+
loadTabData().then(() => {
|
|
1761
|
+
state.loading = false;
|
|
1762
|
+
render();
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
// Export for widget registration
|
|
1771
|
+
export const HistoryExplorerWidget = {
|
|
1772
|
+
register: registerHistoryExplorerWidget,
|
|
1773
|
+
refresh: async () => {
|
|
1774
|
+
state.loading = true;
|
|
1775
|
+
render();
|
|
1776
|
+
await loadTabData();
|
|
1777
|
+
state.loading = false;
|
|
1778
|
+
render();
|
|
1779
|
+
},
|
|
1780
|
+
/**
|
|
1781
|
+
* Open History Explorer to show history for a specific file
|
|
1782
|
+
* @param {string} filePath - The file path to show history for
|
|
1783
|
+
* @param {string} cwd - The working directory (project)
|
|
1784
|
+
*/
|
|
1785
|
+
openToFile: async (filePath, cwd) => {
|
|
1786
|
+
// Update state
|
|
1787
|
+
state.cwd = cwd;
|
|
1788
|
+
state.activeTab = 'files';
|
|
1789
|
+
state.selectedFile = filePath;
|
|
1790
|
+
state.loading = true;
|
|
1791
|
+
|
|
1792
|
+
// Open the widget
|
|
1793
|
+
WidgetManager.open('history-explorer');
|
|
1794
|
+
|
|
1795
|
+
// Fetch file list and file history in parallel
|
|
1796
|
+
await Promise.all([
|
|
1797
|
+
fetchAllFiles(),
|
|
1798
|
+
fetchFileHistory(filePath)
|
|
1799
|
+
]);
|
|
1800
|
+
|
|
1801
|
+
state.loading = false;
|
|
1802
|
+
render();
|
|
1803
|
+
}
|
|
1804
|
+
};
|