@waq666/pneuma 0.0.0-stage → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +144 -2
- package/bin/dsc.js +91 -0
- package/bin/headless.cjs +40 -0
- package/lib/adapter/core-runtime.d.ts +11 -0
- package/lib/adapter/core-runtime.js +259 -0
- package/lib/adapter/host.d.ts +18 -0
- package/lib/adapter/host.js +14 -0
- package/lib/adapter/runtime.d.ts +15 -0
- package/lib/adapter/runtime.js +290 -0
- package/lib/adapter/transcript.d.ts +184 -0
- package/lib/adapter/transcript.js +605 -0
- package/lib/app/AgentsOverlay.d.ts +18 -0
- package/lib/app/AgentsOverlay.js +63 -0
- package/lib/app/App.d.ts +13 -0
- package/lib/app/App.js +1498 -0
- package/lib/app/ApprovalCard.d.ts +12 -0
- package/lib/app/ApprovalCard.js +76 -0
- package/lib/app/AskCard.d.ts +20 -0
- package/lib/app/AskCard.js +45 -0
- package/lib/app/ChatView.d.ts +32 -0
- package/lib/app/ChatView.js +198 -0
- package/lib/app/Composer.d.ts +50 -0
- package/lib/app/Composer.js +282 -0
- package/lib/app/DiffBlock.d.ts +6 -0
- package/lib/app/DiffBlock.js +37 -0
- package/lib/app/MarkdownView.d.ts +6 -0
- package/lib/app/MarkdownView.js +99 -0
- package/lib/app/ModelPicker.d.ts +7 -0
- package/lib/app/ModelPicker.js +18 -0
- package/lib/app/PlanReviewCard.d.ts +13 -0
- package/lib/app/PlanReviewCard.js +54 -0
- package/lib/app/PresetPicker.d.ts +11 -0
- package/lib/app/PresetPicker.js +19 -0
- package/lib/app/PreviewOverlay.d.ts +14 -0
- package/lib/app/PreviewOverlay.js +22 -0
- package/lib/app/SessionPicker.d.ts +43 -0
- package/lib/app/SessionPicker.js +56 -0
- package/lib/app/SettingsOverlay.d.ts +32 -0
- package/lib/app/SettingsOverlay.js +157 -0
- package/lib/app/SkillsPicker.d.ts +7 -0
- package/lib/app/SkillsPicker.js +19 -0
- package/lib/app/StatusBar.d.ts +22 -0
- package/lib/app/StatusBar.js +272 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/ToolCard.d.ts +5 -0
- package/lib/app/ToolCard.js +40 -0
- package/lib/app/TranscriptOverlay.d.ts +12 -0
- package/lib/app/TranscriptOverlay.js +17 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +66 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +27 -0
- package/lib/app/click.js +89 -0
- package/lib/app/clipboard-image.d.ts +11 -0
- package/lib/app/clipboard-image.js +66 -0
- package/lib/app/cursor.d.ts +4 -0
- package/lib/app/cursor.js +24 -0
- package/lib/app/hello.d.ts +11 -0
- package/lib/app/hello.js +8 -0
- package/lib/app/history-store.d.ts +4 -0
- package/lib/app/history-store.js +41 -0
- package/lib/app/image-blocks.d.ts +12 -0
- package/lib/app/image-blocks.js +125 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/theme.d.ts +166 -0
- package/lib/app/theme.js +141 -0
- package/lib/boot.d.ts +1 -0
- package/lib/boot.js +34 -0
- package/lib/commands.d.ts +49 -0
- package/lib/commands.js +115 -0
- package/lib/contract.d.ts +1973 -0
- package/lib/contract.js +36 -0
- package/lib/core/agent-roles.d.ts +52 -0
- package/lib/core/agent-roles.js +274 -0
- package/lib/core/approval-floor.d.ts +183 -0
- package/lib/core/approval-floor.js +679 -0
- package/lib/core/approval.d.ts +42 -0
- package/lib/core/approval.js +8 -0
- package/lib/core/audit.d.ts +61 -0
- package/lib/core/audit.js +59 -0
- package/lib/core/boot-notices.d.ts +6 -0
- package/lib/core/boot-notices.js +61 -0
- package/lib/core/cdp/actions.d.ts +182 -0
- package/lib/core/cdp/actions.js +649 -0
- package/lib/core/cdp/launch.d.ts +192 -0
- package/lib/core/cdp/launch.js +491 -0
- package/lib/core/cdp/snapshot.d.ts +139 -0
- package/lib/core/cdp/snapshot.js +316 -0
- package/lib/core/cdp/transport.d.ts +160 -0
- package/lib/core/cdp/transport.js +359 -0
- package/lib/core/command-policy.d.ts +108 -0
- package/lib/core/command-policy.js +580 -0
- package/lib/core/commands-completion.d.ts +78 -0
- package/lib/core/commands-completion.js +167 -0
- package/lib/core/compact-anchors.d.ts +76 -0
- package/lib/core/compact-anchors.js +284 -0
- package/lib/core/compact.d.ts +110 -0
- package/lib/core/compact.js +210 -0
- package/lib/core/config-store.d.ts +38 -0
- package/lib/core/config-store.js +307 -0
- package/lib/core/config.d.ts +36 -0
- package/lib/core/config.js +124 -0
- package/lib/core/connection-test.d.ts +60 -0
- package/lib/core/connection-test.js +84 -0
- package/lib/core/desktop-control.d.ts +298 -0
- package/lib/core/desktop-control.js +1311 -0
- package/lib/core/diff-text.d.ts +74 -0
- package/lib/core/diff-text.js +257 -0
- package/lib/core/dock-browser.d.ts +137 -0
- package/lib/core/dock-browser.js +146 -0
- package/lib/core/dock-ops.d.ts +59 -0
- package/lib/core/dock-ops.js +104 -0
- package/lib/core/dock-session.d.ts +39 -0
- package/lib/core/dock-session.js +28 -0
- package/lib/core/dsh-compat/hook.d.ts +18 -0
- package/lib/core/dsh-compat/hook.js +52 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
- package/lib/core/dsh-compat/resolve-hook.js +59 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
- package/lib/core/dsh-compat/tools-facade.js +108 -0
- package/lib/core/err-text.d.ts +13 -0
- package/lib/core/err-text.js +15 -0
- package/lib/core/events.d.ts +149 -0
- package/lib/core/events.js +1 -0
- package/lib/core/git-exec.d.ts +23 -0
- package/lib/core/git-exec.js +72 -0
- package/lib/core/git-info.d.ts +47 -0
- package/lib/core/git-info.js +157 -0
- package/lib/core/goal.d.ts +89 -0
- package/lib/core/goal.js +189 -0
- package/lib/core/hooks.d.ts +272 -0
- package/lib/core/hooks.js +818 -0
- package/lib/core/host-browser-link.d.ts +59 -0
- package/lib/core/host-browser-link.js +9 -0
- package/lib/core/host-methods.d.ts +25 -0
- package/lib/core/host-methods.js +103 -0
- package/lib/core/image-diet.d.ts +77 -0
- package/lib/core/image-diet.js +127 -0
- package/lib/core/learnings/ledger.d.ts +73 -0
- package/lib/core/learnings/ledger.js +273 -0
- package/lib/core/learnings/skill-write.d.ts +250 -0
- package/lib/core/learnings/skill-write.js +854 -0
- package/lib/core/learnings/store.d.ts +102 -0
- package/lib/core/learnings/store.js +266 -0
- package/lib/core/lifecycle-hooks.d.ts +189 -0
- package/lib/core/lifecycle-hooks.js +576 -0
- package/lib/core/llm.d.ts +272 -0
- package/lib/core/llm.js +548 -0
- package/lib/core/lockfile.d.ts +17 -0
- package/lib/core/lockfile.js +110 -0
- package/lib/core/loop.d.ts +185 -0
- package/lib/core/loop.js +587 -0
- package/lib/core/lsp/client.d.ts +189 -0
- package/lib/core/lsp/client.js +690 -0
- package/lib/core/lsp/framing.d.ts +84 -0
- package/lib/core/lsp/framing.js +181 -0
- package/lib/core/lsp/line-shift.d.ts +28 -0
- package/lib/core/lsp/line-shift.js +127 -0
- package/lib/core/lsp/manager.d.ts +93 -0
- package/lib/core/lsp/manager.js +418 -0
- package/lib/core/lsp/normalize.d.ts +32 -0
- package/lib/core/lsp/normalize.js +139 -0
- package/lib/core/lsp/servers.d.ts +106 -0
- package/lib/core/lsp/servers.js +352 -0
- package/lib/core/lsp/uri.d.ts +76 -0
- package/lib/core/lsp/uri.js +179 -0
- package/lib/core/market.d.ts +51 -0
- package/lib/core/market.js +358 -0
- package/lib/core/mcp.d.ts +201 -0
- package/lib/core/mcp.js +836 -0
- package/lib/core/memory-eval.d.ts +158 -0
- package/lib/core/memory-eval.js +215 -0
- package/lib/core/memory.d.ts +266 -0
- package/lib/core/memory.js +703 -0
- package/lib/core/mention.d.ts +57 -0
- package/lib/core/mention.js +129 -0
- package/lib/core/microcompact.d.ts +48 -0
- package/lib/core/microcompact.js +79 -0
- package/lib/core/migrate.d.ts +56 -0
- package/lib/core/migrate.js +134 -0
- package/lib/core/model-caps.d.ts +83 -0
- package/lib/core/model-caps.js +150 -0
- package/lib/core/model-discovery.d.ts +19 -0
- package/lib/core/model-discovery.js +69 -0
- package/lib/core/modes.d.ts +72 -0
- package/lib/core/modes.js +152 -0
- package/lib/core/native-bridge.d.ts +135 -0
- package/lib/core/native-bridge.js +563 -0
- package/lib/core/path-policy.d.ts +32 -0
- package/lib/core/path-policy.js +248 -0
- package/lib/core/permission-presets.d.ts +67 -0
- package/lib/core/permission-presets.js +75 -0
- package/lib/core/plugin-loader.d.ts +36 -0
- package/lib/core/plugin-loader.js +294 -0
- package/lib/core/plugin-registry.d.ts +113 -0
- package/lib/core/plugin-registry.js +256 -0
- package/lib/core/prefs.d.ts +82 -0
- package/lib/core/prefs.js +372 -0
- package/lib/core/presets.d.ts +80 -0
- package/lib/core/presets.js +373 -0
- package/lib/core/pricing.d.ts +90 -0
- package/lib/core/pricing.js +126 -0
- package/lib/core/prompt.d.ts +92 -0
- package/lib/core/prompt.js +339 -0
- package/lib/core/ptc.d.ts +66 -0
- package/lib/core/ptc.js +70 -0
- package/lib/core/remote/frames.d.ts +91 -0
- package/lib/core/remote/frames.js +174 -0
- package/lib/core/remote/notify.d.ts +54 -0
- package/lib/core/remote/notify.js +77 -0
- package/lib/core/remote/owner.d.ts +32 -0
- package/lib/core/remote/owner.js +75 -0
- package/lib/core/remote/pairing.d.ts +104 -0
- package/lib/core/remote/pairing.js +261 -0
- package/lib/core/remote/push.d.ts +80 -0
- package/lib/core/remote/push.js +222 -0
- package/lib/core/remote/store.d.ts +18 -0
- package/lib/core/remote/store.js +59 -0
- package/lib/core/remote/tickets.d.ts +20 -0
- package/lib/core/remote/tickets.js +49 -0
- package/lib/core/remote/uploads.d.ts +63 -0
- package/lib/core/remote/uploads.js +161 -0
- package/lib/core/request-attribution.d.ts +26 -0
- package/lib/core/request-attribution.js +86 -0
- package/lib/core/request-invariant.d.ts +61 -0
- package/lib/core/request-invariant.js +199 -0
- package/lib/core/sandbox/backends.d.ts +64 -0
- package/lib/core/sandbox/backends.js +194 -0
- package/lib/core/sandbox/execpolicy.d.ts +93 -0
- package/lib/core/sandbox/execpolicy.js +452 -0
- package/lib/core/sandbox/net-proxy.d.ts +31 -0
- package/lib/core/sandbox/net-proxy.js +162 -0
- package/lib/core/sandbox/policy.d.ts +211 -0
- package/lib/core/sandbox/policy.js +559 -0
- package/lib/core/sandbox/win/abi.d.ts +161 -0
- package/lib/core/sandbox/win/abi.js +169 -0
- package/lib/core/sandbox/win/account.d.ts +71 -0
- package/lib/core/sandbox/win/account.js +206 -0
- package/lib/core/sandbox/win/acl.d.ts +54 -0
- package/lib/core/sandbox/win/acl.js +339 -0
- package/lib/core/sandbox/win/backend.d.ts +61 -0
- package/lib/core/sandbox/win/backend.js +249 -0
- package/lib/core/sandbox/win/doctor.d.ts +24 -0
- package/lib/core/sandbox/win/doctor.js +272 -0
- package/lib/core/sandbox/win/ffi.d.ts +107 -0
- package/lib/core/sandbox/win/ffi.js +166 -0
- package/lib/core/sandbox/win/net-abi.d.ts +154 -0
- package/lib/core/sandbox/win/net-abi.js +316 -0
- package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
- package/lib/core/sandbox/win/runner-entry.js +391 -0
- package/lib/core/sandbox/win/setup.d.ts +60 -0
- package/lib/core/sandbox/win/setup.js +986 -0
- package/lib/core/sandbox/win/token.d.ts +35 -0
- package/lib/core/sandbox/win/token.js +238 -0
- package/lib/core/sandbox/win/wfp.d.ts +41 -0
- package/lib/core/sandbox/win/wfp.js +200 -0
- package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
- package/lib/core/sandbox/win/workspace-sid.js +45 -0
- package/lib/core/schedule/rule.d.ts +184 -0
- package/lib/core/schedule/rule.js +745 -0
- package/lib/core/schedule/runner.d.ts +185 -0
- package/lib/core/schedule/runner.js +678 -0
- package/lib/core/schedule/store.d.ts +182 -0
- package/lib/core/schedule/store.js +455 -0
- package/lib/core/secrets.d.ts +41 -0
- package/lib/core/secrets.js +150 -0
- package/lib/core/session-export.d.ts +18 -0
- package/lib/core/session-export.js +73 -0
- package/lib/core/session-index.d.ts +159 -0
- package/lib/core/session-index.js +683 -0
- package/lib/core/session-meta.d.ts +41 -0
- package/lib/core/session-meta.js +97 -0
- package/lib/core/session.d.ts +356 -0
- package/lib/core/session.js +998 -0
- package/lib/core/skills.d.ts +60 -0
- package/lib/core/skills.js +171 -0
- package/lib/core/spill.d.ts +159 -0
- package/lib/core/spill.js +329 -0
- package/lib/core/surface-registry.d.ts +45 -0
- package/lib/core/surface-registry.js +67 -0
- package/lib/core/team-board.d.ts +95 -0
- package/lib/core/team-board.js +316 -0
- package/lib/core/throughput.d.ts +46 -0
- package/lib/core/throughput.js +40 -0
- package/lib/core/todo-reminder.d.ts +44 -0
- package/lib/core/todo-reminder.js +55 -0
- package/lib/core/todo.d.ts +81 -0
- package/lib/core/todo.js +222 -0
- package/lib/core/token-estimate.d.ts +55 -0
- package/lib/core/token-estimate.js +82 -0
- package/lib/core/tool-guards.d.ts +103 -0
- package/lib/core/tool-guards.js +77 -0
- package/lib/core/tool-search.d.ts +152 -0
- package/lib/core/tool-search.js +311 -0
- package/lib/core/tools/bash.d.ts +281 -0
- package/lib/core/tools/bash.js +871 -0
- package/lib/core/tools/command-runner.d.ts +84 -0
- package/lib/core/tools/command-runner.js +68 -0
- package/lib/core/tools/fs-tools.d.ts +23 -0
- package/lib/core/tools/fs-tools.js +247 -0
- package/lib/core/tools/index.d.ts +8 -0
- package/lib/core/tools/index.js +4 -0
- package/lib/core/tools/sandbox-args.d.ts +51 -0
- package/lib/core/tools/sandbox-args.js +90 -0
- package/lib/core/tools/search-tools.d.ts +3 -0
- package/lib/core/tools/search-tools.js +153 -0
- package/lib/core/tools.d.ts +96 -0
- package/lib/core/tools.js +53 -0
- package/lib/core/ui-boot-source.d.ts +71 -0
- package/lib/core/ui-boot-source.js +121 -0
- package/lib/core/ui-bundles.d.ts +249 -0
- package/lib/core/ui-bundles.js +830 -0
- package/lib/core/ui-combo.d.ts +49 -0
- package/lib/core/ui-combo.js +55 -0
- package/lib/core/ui-events.d.ts +81 -0
- package/lib/core/ui-events.js +364 -0
- package/lib/core/ui-hmr.d.ts +36 -0
- package/lib/core/ui-hmr.js +128 -0
- package/lib/core/ui-methods.d.ts +69 -0
- package/lib/core/ui-methods.js +341 -0
- package/lib/core/ui-route.d.ts +69 -0
- package/lib/core/ui-route.js +122 -0
- package/lib/core/ui-server.d.ts +75 -0
- package/lib/core/ui-server.js +369 -0
- package/lib/core/ui-trust.d.ts +47 -0
- package/lib/core/ui-trust.js +164 -0
- package/lib/core/untrusted.d.ts +30 -0
- package/lib/core/untrusted.js +48 -0
- package/lib/core/update-check.d.ts +81 -0
- package/lib/core/update-check.js +177 -0
- package/lib/core/usage-log.d.ts +82 -0
- package/lib/core/usage-log.js +306 -0
- package/lib/core/version.d.ts +1 -0
- package/lib/core/version.js +37 -0
- package/lib/core/web-http.d.ts +57 -0
- package/lib/core/web-http.js +137 -0
- package/lib/core/web-static.d.ts +31 -0
- package/lib/core/web-static.js +75 -0
- package/lib/headless.d.ts +1 -0
- package/lib/headless.js +31 -0
- package/lib/host/kernel.d.ts +33 -0
- package/lib/host/kernel.js +451 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +35 -0
- package/lib/plugins/agent.d.ts +2 -0
- package/lib/plugins/agent.js +274 -0
- package/lib/plugins/approval-floor.d.ts +2 -0
- package/lib/plugins/approval-floor.js +223 -0
- package/lib/plugins/approval.d.ts +16 -0
- package/lib/plugins/approval.js +674 -0
- package/lib/plugins/ask.d.ts +2 -0
- package/lib/plugins/ask.js +245 -0
- package/lib/plugins/browser.d.ts +68 -0
- package/lib/plugins/browser.js +1341 -0
- package/lib/plugins/commands.d.ts +23 -0
- package/lib/plugins/commands.js +498 -0
- package/lib/plugins/compact.d.ts +21 -0
- package/lib/plugins/compact.js +274 -0
- package/lib/plugins/computer-use.d.ts +47 -0
- package/lib/plugins/computer-use.js +539 -0
- package/lib/plugins/desktop-dock.d.ts +2 -0
- package/lib/plugins/desktop-dock.js +626 -0
- package/lib/plugins/dock-browser.d.ts +34 -0
- package/lib/plugins/dock-browser.js +765 -0
- package/lib/plugins/dsh-compat.d.ts +25 -0
- package/lib/plugins/dsh-compat.js +37 -0
- package/lib/plugins/file-review.d.ts +108 -0
- package/lib/plugins/file-review.js +393 -0
- package/lib/plugins/git.d.ts +26 -0
- package/lib/plugins/git.js +132 -0
- package/lib/plugins/goal.d.ts +20 -0
- package/lib/plugins/goal.js +245 -0
- package/lib/plugins/guards.d.ts +14 -0
- package/lib/plugins/guards.js +18 -0
- package/lib/plugins/hooks.d.ts +19 -0
- package/lib/plugins/hooks.js +583 -0
- package/lib/plugins/host-stdio.d.ts +88 -0
- package/lib/plugins/host-stdio.js +317 -0
- package/lib/plugins/image-diet.d.ts +17 -0
- package/lib/plugins/image-diet.js +85 -0
- package/lib/plugins/lifecycle-hooks.d.ts +26 -0
- package/lib/plugins/lifecycle-hooks.js +338 -0
- package/lib/plugins/llm.d.ts +13 -0
- package/lib/plugins/llm.js +215 -0
- package/lib/plugins/lsp.d.ts +54 -0
- package/lib/plugins/lsp.js +608 -0
- package/lib/plugins/mcp.d.ts +16 -0
- package/lib/plugins/mcp.js +673 -0
- package/lib/plugins/memory.d.ts +17 -0
- package/lib/plugins/memory.js +858 -0
- package/lib/plugins/microcompact.d.ts +18 -0
- package/lib/plugins/microcompact.js +119 -0
- package/lib/plugins/mode.d.ts +18 -0
- package/lib/plugins/mode.js +115 -0
- package/lib/plugins/permission-presets.d.ts +18 -0
- package/lib/plugins/permission-presets.js +135 -0
- package/lib/plugins/plan.d.ts +2 -0
- package/lib/plugins/plan.js +192 -0
- package/lib/plugins/plugin-manager.d.ts +2 -0
- package/lib/plugins/plugin-manager.js +165 -0
- package/lib/plugins/presets.d.ts +2 -0
- package/lib/plugins/presets.js +182 -0
- package/lib/plugins/prompt.d.ts +2 -0
- package/lib/plugins/prompt.js +264 -0
- package/lib/plugins/ptc.d.ts +2 -0
- package/lib/plugins/ptc.js +272 -0
- package/lib/plugins/remote/http.d.ts +11 -0
- package/lib/plugins/remote/http.js +11 -0
- package/lib/plugins/remote/routes.d.ts +24 -0
- package/lib/plugins/remote/routes.js +384 -0
- package/lib/plugins/remote/types.d.ts +135 -0
- package/lib/plugins/remote/types.js +87 -0
- package/lib/plugins/remote.d.ts +17 -0
- package/lib/plugins/remote.js +1028 -0
- package/lib/plugins/runtime-api.d.ts +16 -0
- package/lib/plugins/runtime-api.js +99 -0
- package/lib/plugins/runtime.d.ts +10 -0
- package/lib/plugins/runtime.js +451 -0
- package/lib/plugins/sandbox.d.ts +2 -0
- package/lib/plugins/sandbox.js +761 -0
- package/lib/plugins/schedule.d.ts +26 -0
- package/lib/plugins/schedule.js +538 -0
- package/lib/plugins/self-improve.d.ts +61 -0
- package/lib/plugins/self-improve.js +953 -0
- package/lib/plugins/session-search.d.ts +16 -0
- package/lib/plugins/session-search.js +308 -0
- package/lib/plugins/session-title.d.ts +19 -0
- package/lib/plugins/session-title.js +109 -0
- package/lib/plugins/session.d.ts +7 -0
- package/lib/plugins/session.js +296 -0
- package/lib/plugins/settings.d.ts +3 -0
- package/lib/plugins/settings.js +705 -0
- package/lib/plugins/skills.d.ts +2 -0
- package/lib/plugins/skills.js +360 -0
- package/lib/plugins/spill.d.ts +16 -0
- package/lib/plugins/spill.js +200 -0
- package/lib/plugins/subagent.d.ts +2 -0
- package/lib/plugins/subagent.js +862 -0
- package/lib/plugins/surfaces.d.ts +11 -0
- package/lib/plugins/surfaces.js +20 -0
- package/lib/plugins/team.d.ts +16 -0
- package/lib/plugins/team.js +149 -0
- package/lib/plugins/todo.d.ts +19 -0
- package/lib/plugins/todo.js +188 -0
- package/lib/plugins/tool-search.d.ts +2 -0
- package/lib/plugins/tool-search.js +425 -0
- package/lib/plugins/tools-default.d.ts +12 -0
- package/lib/plugins/tools-default.js +275 -0
- package/lib/plugins/tools.d.ts +16 -0
- package/lib/plugins/tools.js +62 -0
- package/lib/plugins/transcript.d.ts +15 -0
- package/lib/plugins/transcript.js +311 -0
- package/lib/plugins/tui.d.ts +2 -0
- package/lib/plugins/tui.js +98 -0
- package/lib/plugins/waiting.d.ts +12 -0
- package/lib/plugins/waiting.js +34 -0
- package/lib/plugins/web-search.d.ts +14 -0
- package/lib/plugins/web-search.js +263 -0
- package/lib/plugins/webserver.d.ts +48 -0
- package/lib/plugins/webserver.js +228 -0
- package/lib/remote/assets/app-DAcUCOEn.js +14 -0
- package/lib/remote/assets/icon-192.png +0 -0
- package/lib/remote/assets/icon-512.png +0 -0
- package/lib/remote/assets/index.html +34 -0
- package/lib/remote/assets/manifest.json +27 -0
- package/lib/remote/assets/style-DIB6729x.css +1 -0
- package/lib/remote/assets/sw.js +66 -0
- package/lib/services/types.d.ts +1228 -0
- package/lib/services/types.js +1 -0
- package/lib/tools/config-cli.d.ts +1 -0
- package/lib/tools/config-cli.js +89 -0
- package/lib/ui/arrival.d.ts +72 -0
- package/lib/ui/arrival.js +105 -0
- package/lib/ui/assets/app-B70nVIKd.js +69 -0
- package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
- package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
- package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
- package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
- package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
- package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
- package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
- package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
- package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
- package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
- package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
- package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
- package/lib/ui/assets/chunk-BajyYBss.js +10 -0
- package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
- package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
- package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
- package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
- package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
- package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
- package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
- package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
- package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
- package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
- package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
- package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
- package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
- package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
- package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
- package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
- package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
- package/lib/ui/assets/chunk-CickPsom.js +1 -0
- package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
- package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
- package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
- package/lib/ui/assets/chunk-CqE71os6.js +1 -0
- package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
- package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
- package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
- package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
- package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
- package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
- package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
- package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
- package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
- package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
- package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
- package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
- package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
- package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
- package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
- package/lib/ui/assets/chunk-De0Btta0.js +1 -0
- package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
- package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
- package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
- package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
- package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
- package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
- package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
- package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
- package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
- package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
- package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
- package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
- package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
- package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
- package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
- package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
- package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
- package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
- package/lib/ui/assets/icon.png +0 -0
- package/lib/ui/assets/index.html +14 -0
- package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/lib/ui/assets/style-Bq01xH_b.css +1 -0
- package/lib/ui/frames.d.ts +67 -0
- package/lib/ui/frames.js +146 -0
- package/lib/ui/index.d.ts +59 -0
- package/lib/ui/index.js +50 -0
- package/lib/ui/manifest.d.ts +172 -0
- package/lib/ui/manifest.js +158 -0
- package/lib/ui/plugin.d.ts +161 -0
- package/lib/ui/plugin.js +7 -0
- package/lib/ui/plugins/browser/client.js +290 -0
- package/lib/ui/plugins/browser/icon.png +0 -0
- package/lib/ui/plugins/composer/client.js +1843 -0
- package/lib/ui/plugins/composer/icon.png +0 -0
- package/lib/ui/plugins/files/client.js +646 -0
- package/lib/ui/plugins/files/icon.png +0 -0
- package/lib/ui/plugins/manifest.json +107 -0
- package/lib/ui/plugins/plugins/client.js +682 -0
- package/lib/ui/plugins/plugins/icon.png +0 -0
- package/lib/ui/plugins/preview/client.js +197 -0
- package/lib/ui/plugins/preview/icon.png +0 -0
- package/lib/ui/plugins/prompt/client.js +653 -0
- package/lib/ui/plugins/prompt/icon.png +0 -0
- package/lib/ui/plugins/sessions/client.js +1577 -0
- package/lib/ui/plugins/sessions/icon.png +0 -0
- package/lib/ui/plugins/settings/client.js +5470 -0
- package/lib/ui/plugins/settings/icon.png +0 -0
- package/lib/ui/plugins/skills/client.js +485 -0
- package/lib/ui/plugins/skills/icon.png +0 -0
- package/lib/ui/plugins/status/client.js +1420 -0
- package/lib/ui/plugins/status/icon.png +0 -0
- package/lib/ui/plugins/statusbar/client.js +504 -0
- package/lib/ui/plugins/statusbar/icon.png +0 -0
- package/lib/ui/plugins/tasks/client.js +52 -0
- package/lib/ui/plugins/tasks/icon.png +0 -0
- package/lib/ui/plugins/team/client.js +527 -0
- package/lib/ui/plugins/team/icon.png +0 -0
- package/lib/ui/plugins/terminal/client.js +232 -0
- package/lib/ui/plugins/terminal/icon.png +0 -0
- package/lib/ui/plugins/trace/client.js +1376 -0
- package/lib/ui/plugins/trace/icon.png +0 -0
- package/lib/ui/plugins/transcript/client.js +2661 -0
- package/lib/ui/plugins/transcript/icon.png +0 -0
- package/lib/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/scoped-slots.js +21 -0
- package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
- package/lib/ui/sdk/@dsc/ui/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
- package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
- package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
- package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
- package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
- package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
- package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
- package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
- package/lib/ui/services-react.d.ts +27 -0
- package/lib/ui/services-react.js +32 -0
- package/lib/ui/services.d.ts +63 -0
- package/lib/ui/services.js +121 -0
- package/lib/ui/slots-ink.d.ts +26 -0
- package/lib/ui/slots-ink.js +78 -0
- package/lib/ui/slots-react.d.ts +28 -0
- package/lib/ui/slots-react.js +88 -0
- package/lib/ui/slots.d.ts +481 -0
- package/lib/ui/slots.js +550 -0
- package/lib/ui/store.d.ts +89 -0
- package/lib/ui/store.js +62 -0
- package/lib/ui/tui-plugin-api.d.ts +23 -0
- package/lib/ui/tui-plugin-api.js +23 -0
- package/lib/ui/tui-plugins.d.ts +47 -0
- package/lib/ui/tui-plugins.js +220 -0
- package/package.json +58 -6
|
@@ -0,0 +1,1577 @@
|
|
|
1
|
+
(globalThis.__DSC_UI_FACTORIES__ ??= {})["sessions"] = function (require, module, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const react = require("react");
|
|
6
|
+
const ui$1 = require("@dsc/ui");
|
|
7
|
+
const uiPrimitives = require("@dsc/ui-primitives");
|
|
8
|
+
function displayName(cwd, aliases) {
|
|
9
|
+
const alias = aliases[cwd];
|
|
10
|
+
if (alias !== void 0 && alias !== "") return alias;
|
|
11
|
+
const tail = lastSegment(cwd);
|
|
12
|
+
return tail === "" ? cwd : tail;
|
|
13
|
+
}
|
|
14
|
+
function lastSegment(path) {
|
|
15
|
+
const trimmed = path.replace(/[\\/]+$/, "");
|
|
16
|
+
const at = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
|
|
17
|
+
return at < 0 ? trimmed : trimmed.slice(at + 1);
|
|
18
|
+
}
|
|
19
|
+
function orderedSessions(cwd, list, sort, sessionOrder) {
|
|
20
|
+
const sorted = [...list].sort((left, right) => {
|
|
21
|
+
if ((left.pinnedAt ?? 0) !== (right.pinnedAt ?? 0)) return (right.pinnedAt ?? 0) - (left.pinnedAt ?? 0);
|
|
22
|
+
return sort === "created" ? right.createdAt - left.createdAt : right.updatedAt - left.updatedAt;
|
|
23
|
+
});
|
|
24
|
+
if (sort !== "manual" || cwd === void 0) return sorted;
|
|
25
|
+
const saved = sessionOrder[cwd];
|
|
26
|
+
if (saved === void 0 || saved.length === 0) return sorted;
|
|
27
|
+
const rank = new Map(saved.map((id, index) => [id, index]));
|
|
28
|
+
const weave = (part) => [...part].sort((a, b) => {
|
|
29
|
+
const ra = rank.get(a.id);
|
|
30
|
+
const rb = rank.get(b.id);
|
|
31
|
+
if (ra !== void 0 && rb !== void 0) return ra - rb;
|
|
32
|
+
if (ra !== void 0) return -1;
|
|
33
|
+
if (rb !== void 0) return 1;
|
|
34
|
+
return 0;
|
|
35
|
+
});
|
|
36
|
+
return [
|
|
37
|
+
...weave(sorted.filter((session) => session.pinnedAt !== void 0)),
|
|
38
|
+
...weave(sorted.filter((session) => session.pinnedAt === void 0))
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
function moveWithin(order, source, target, after) {
|
|
42
|
+
if (source === target) return order;
|
|
43
|
+
const rest = order.filter((item) => item !== source);
|
|
44
|
+
let at = rest.indexOf(target);
|
|
45
|
+
if (at < 0) return order;
|
|
46
|
+
if (after) at += 1;
|
|
47
|
+
return [...rest.slice(0, at), source, ...rest.slice(at)];
|
|
48
|
+
}
|
|
49
|
+
function moveToEnd(order, source) {
|
|
50
|
+
return [...order.filter((item) => item !== source), source];
|
|
51
|
+
}
|
|
52
|
+
function keepArchived(session, archived) {
|
|
53
|
+
if (archived === "hide") return session.archivedAt === void 0;
|
|
54
|
+
if (archived === "only") return session.archivedAt !== void 0;
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
function buildWorkGroups(input) {
|
|
58
|
+
const { sessions, recentCwds, cwd, sort, group, archived, trimmed, aliases, order, sessionOrder } = input;
|
|
59
|
+
const map = /* @__PURE__ */ new Map();
|
|
60
|
+
if (archived !== "only") for (const dir of recentCwds) map.set(dir, []);
|
|
61
|
+
for (const session of sessions) {
|
|
62
|
+
if (!keepArchived(session, archived)) continue;
|
|
63
|
+
const key = session.cwd || "(未指定)";
|
|
64
|
+
const list = map.get(key) ?? [];
|
|
65
|
+
list.push(session);
|
|
66
|
+
map.set(key, list);
|
|
67
|
+
}
|
|
68
|
+
const match = (dir, list) => trimmed === "" || displayName(dir, aliases).toLowerCase().includes(trimmed) || dir.toLowerCase().includes(trimmed) || list.some((session) => (session.title ?? "新会话").toLowerCase().includes(trimmed));
|
|
69
|
+
const visible = [...map.entries()].filter(([dir, list]) => match(dir, list));
|
|
70
|
+
const rank = (dir) => order.indexOf(dir);
|
|
71
|
+
const lastUsed = (list) => list.reduce((max, s) => Math.max(max, s.updatedAt), 0);
|
|
72
|
+
const lastCreated = (list) => list.reduce((max, s) => Math.max(max, s.createdAt), 0);
|
|
73
|
+
const sorted = visible.map(([dir, list]) => [dir, orderedSessions(dir, list, sort, sessionOrder)]).sort((a, b) => {
|
|
74
|
+
if (sort === "manual") {
|
|
75
|
+
if (order.length > 0) {
|
|
76
|
+
const ra = rank(a[0]);
|
|
77
|
+
const rb = rank(b[0]);
|
|
78
|
+
if (ra !== rb) {
|
|
79
|
+
if (ra < 0) return 1;
|
|
80
|
+
if (rb < 0) return -1;
|
|
81
|
+
return ra - rb;
|
|
82
|
+
}
|
|
83
|
+
} else if (a[0] === cwd !== (b[0] === cwd)) {
|
|
84
|
+
return a[0] === cwd ? -1 : 1;
|
|
85
|
+
}
|
|
86
|
+
return lastUsed(b[1]) - lastUsed(a[1]);
|
|
87
|
+
}
|
|
88
|
+
return sort === "created" ? lastCreated(b[1]) - lastCreated(a[1]) : lastUsed(b[1]) - lastUsed(a[1]);
|
|
89
|
+
});
|
|
90
|
+
if (group !== "tree") {
|
|
91
|
+
return sorted.map(
|
|
92
|
+
([dir, list]) => ({ cwd: dir, sessions: list, depth: 0, parent: null, ancestors: [], hasChildren: false })
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const lists = new Map(sorted);
|
|
96
|
+
return nestByPath(sorted.map(([dir]) => dir)).map((node) => ({ ...node, sessions: lists.get(node.cwd) ?? [] }));
|
|
97
|
+
}
|
|
98
|
+
function nestByPath(dirs) {
|
|
99
|
+
const norm = (dir) => dir.replace(/[\\/]+/g, "/").replace(/\/$/, "").toLowerCase();
|
|
100
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
101
|
+
for (const dir of dirs) {
|
|
102
|
+
nodes.set(norm(dir), { cwd: dir, depth: 0, parent: null, ancestors: [dir], hasChildren: false });
|
|
103
|
+
}
|
|
104
|
+
for (const dir of dirs) {
|
|
105
|
+
const key = norm(dir);
|
|
106
|
+
const self = nodes.get(key);
|
|
107
|
+
if (self === void 0) continue;
|
|
108
|
+
let best = null;
|
|
109
|
+
for (const [otherKey, other] of nodes) {
|
|
110
|
+
if (otherKey === key) continue;
|
|
111
|
+
if (!key.startsWith(`${otherKey}/`)) continue;
|
|
112
|
+
if (best === null || otherKey.length > norm(best.cwd).length) best = other;
|
|
113
|
+
}
|
|
114
|
+
if (best !== null) {
|
|
115
|
+
self.parent = best.cwd;
|
|
116
|
+
self.depth = best.depth + 1;
|
|
117
|
+
self.ancestors = [...best.ancestors, self.cwd];
|
|
118
|
+
best.hasChildren = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const out = [];
|
|
122
|
+
const walk = (parent) => {
|
|
123
|
+
for (const node of nodes.values()) {
|
|
124
|
+
if (node.parent !== parent) continue;
|
|
125
|
+
out.push(node);
|
|
126
|
+
walk(node.cwd);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
walk(null);
|
|
130
|
+
for (const node of nodes.values()) if (!out.includes(node)) out.push(node);
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
const NO_SESSIONS = Object.freeze([]);
|
|
134
|
+
const PREVIEW_COUNT = 5;
|
|
135
|
+
const ARCHIVE_DETAIL_ONE = "会话会离开侧边栏,移进「设置 → 归档」的归档区;消息一个字不删,想回来去归档里点「恢复会话」。";
|
|
136
|
+
const ui = ui$1.defineUiPlugin({
|
|
137
|
+
name: "会话列表",
|
|
138
|
+
apply(ui2) {
|
|
139
|
+
ui2.slots.register("shell.header", { id: "sessions.workspace-open", order: 10 }, WorkspaceOpenGroup);
|
|
140
|
+
ui2.slots.register("shell.sidebar", { id: "sessions.list", order: 1 }, SessionList);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
function relativeTime(at) {
|
|
144
|
+
const delta = Date.now() - at;
|
|
145
|
+
if (!Number.isFinite(delta) || delta < 0) return "";
|
|
146
|
+
const minutes = Math.floor(delta / 6e4);
|
|
147
|
+
if (minutes < 1) return "刚刚";
|
|
148
|
+
if (minutes < 60) return `${String(minutes)}分钟`;
|
|
149
|
+
const hours = Math.floor(minutes / 60);
|
|
150
|
+
if (hours < 24) return `${String(hours)}小时`;
|
|
151
|
+
return `${String(Math.floor(hours / 24))}天`;
|
|
152
|
+
}
|
|
153
|
+
const DOT_CLASS = {
|
|
154
|
+
working: "working",
|
|
155
|
+
"awaiting-approval": "awaiting-approval",
|
|
156
|
+
"just-finished": "just-finished"
|
|
157
|
+
};
|
|
158
|
+
const DOT_LABEL = {
|
|
159
|
+
working: "这个会话正在跑",
|
|
160
|
+
"awaiting-approval": "挂着等你审批",
|
|
161
|
+
"just-finished": "后台已完成(点开查看)"
|
|
162
|
+
};
|
|
163
|
+
const DEFAULT_PREFS = {
|
|
164
|
+
group: "workspace",
|
|
165
|
+
sort: "manual",
|
|
166
|
+
archived: "hide",
|
|
167
|
+
aliases: {},
|
|
168
|
+
expansion: {},
|
|
169
|
+
order: [],
|
|
170
|
+
sessionOrder: {}
|
|
171
|
+
};
|
|
172
|
+
function SessionList() {
|
|
173
|
+
const channel = ui$1.useHostChannel();
|
|
174
|
+
const sessions = ui$1.useHostSelector(readSessions);
|
|
175
|
+
const states = ui$1.useHostSelector(readStates);
|
|
176
|
+
const currentPath = ui$1.useHostSelector(readCurrentPath);
|
|
177
|
+
const loading = ui$1.useHostSelector(readLoading);
|
|
178
|
+
const cwd = ui$1.useHostSelector(readCwd);
|
|
179
|
+
const page = ui$1.useShellPage();
|
|
180
|
+
const [fault, setFault] = react.useState(null);
|
|
181
|
+
const [forking, setForking] = react.useState(null);
|
|
182
|
+
const [prefs, setPrefs] = react.useState(DEFAULT_PREFS);
|
|
183
|
+
const [searching, setSearching] = react.useState(false);
|
|
184
|
+
const [query, setQuery] = react.useState("");
|
|
185
|
+
const [viewMenu, setViewMenu] = react.useState(null);
|
|
186
|
+
const [menu, setMenu] = react.useState(null);
|
|
187
|
+
const [limits, setLimits] = react.useState({});
|
|
188
|
+
const [recentCwds, setRecentCwds] = react.useState([]);
|
|
189
|
+
const [groupRenaming, setGroupRenaming] = react.useState(null);
|
|
190
|
+
const [renaming, setRenaming] = react.useState(null);
|
|
191
|
+
const [dragCwd, setDragCwd] = react.useState(null);
|
|
192
|
+
const [dropAt, setDropAt] = react.useState(null);
|
|
193
|
+
const [sessDrag, setSessDrag] = react.useState(null);
|
|
194
|
+
const justDragged = react.useRef(false);
|
|
195
|
+
react.useEffect(() => {
|
|
196
|
+
void channel.invoke("refreshSessions").catch((reason) => {
|
|
197
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
198
|
+
});
|
|
199
|
+
void channel.invoke("getUiPrefs", []).then((value) => {
|
|
200
|
+
setPrefs({
|
|
201
|
+
group: readEnum(value["sessionGroup"], ["workspace", "tree", "flat"], "workspace"),
|
|
202
|
+
// 缺省档对齐宿主与旧界面:`manual`(宿主 prefs 的出厂值就是它)。
|
|
203
|
+
sort: readEnum(value["sessionSort"], ["manual", "recent", "created"], "manual"),
|
|
204
|
+
archived: readEnum(value["archivedFilter"], ["hide", "show", "only"], "hide"),
|
|
205
|
+
aliases: readStringRecord(value["workspaceAliases"]),
|
|
206
|
+
expansion: readRecord(value["sessionExpansion"]),
|
|
207
|
+
order: readStringList(value["workspaceOrder"]),
|
|
208
|
+
sessionOrder: readStringListRecord(value["sessionOrder"])
|
|
209
|
+
});
|
|
210
|
+
}).catch(() => void 0);
|
|
211
|
+
const native = ui$1.getHostNative();
|
|
212
|
+
if (native.available) {
|
|
213
|
+
void native.invoke("recentCwds").then((list) => {
|
|
214
|
+
setRecentCwds(Array.isArray(list) ? list : []);
|
|
215
|
+
}).catch(() => void 0);
|
|
216
|
+
}
|
|
217
|
+
}, [channel]);
|
|
218
|
+
const run = async (method, args, then) => {
|
|
219
|
+
setFault(null);
|
|
220
|
+
try {
|
|
221
|
+
const result = await channel.invoke(method, args);
|
|
222
|
+
if (result !== null && typeof result === "object" && typeof result.ok === "boolean") {
|
|
223
|
+
const reply = result;
|
|
224
|
+
if (!reply.ok) {
|
|
225
|
+
ui$1.toastErr(`操作失败:${typeof reply.error === "string" ? reply.error : "宿主没说什么原因"}`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
ui$1.toastOk(typeof reply.notice === "string" && reply.notice !== "" ? reply.notice : "已完成");
|
|
229
|
+
await channel.invoke("refreshSessions", []);
|
|
230
|
+
then?.();
|
|
231
|
+
}
|
|
232
|
+
} catch (reason) {
|
|
233
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const patchPrefs = (patch) => {
|
|
237
|
+
setPrefs((current) => ({ ...current, ...patch }));
|
|
238
|
+
void (async () => {
|
|
239
|
+
try {
|
|
240
|
+
const body = {};
|
|
241
|
+
if (patch.group !== void 0) body["sessionGroup"] = patch.group;
|
|
242
|
+
if (patch.sort !== void 0) body["sessionSort"] = patch.sort;
|
|
243
|
+
if (patch.archived !== void 0) body["archivedFilter"] = patch.archived;
|
|
244
|
+
if (patch.aliases !== void 0) body["workspaceAliases"] = patch.aliases;
|
|
245
|
+
if (patch.expansion !== void 0) body["sessionExpansion"] = patch.expansion;
|
|
246
|
+
if (patch.order !== void 0) body["workspaceOrder"] = patch.order;
|
|
247
|
+
if (patch.sessionOrder !== void 0) body["sessionOrder"] = patch.sessionOrder;
|
|
248
|
+
await channel.invoke("setUiPrefs", [body]);
|
|
249
|
+
} catch (reason) {
|
|
250
|
+
setPrefs((current) => ({ ...current, ...patchOfUndo(patch) }));
|
|
251
|
+
ui$1.toastErr(`界面偏好没写成功:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
252
|
+
}
|
|
253
|
+
})();
|
|
254
|
+
};
|
|
255
|
+
const open = (id) => {
|
|
256
|
+
ui$1.setShellPage(null);
|
|
257
|
+
void (async () => {
|
|
258
|
+
await run("openSession", id === void 0 ? [] : [id]);
|
|
259
|
+
await run("refreshSessions", []);
|
|
260
|
+
})();
|
|
261
|
+
};
|
|
262
|
+
const showTrace = (id) => {
|
|
263
|
+
ui$1.openTrace();
|
|
264
|
+
open(id);
|
|
265
|
+
};
|
|
266
|
+
const newSessionIn = (target) => {
|
|
267
|
+
if (prefs.expansion[target] === false) {
|
|
268
|
+
patchPrefs({ expansion: { ...prefs.expansion, [target]: true } });
|
|
269
|
+
}
|
|
270
|
+
ui$1.setShellPage(null);
|
|
271
|
+
void (async () => {
|
|
272
|
+
setFault(null);
|
|
273
|
+
try {
|
|
274
|
+
await channel.invoke("newSessionIn", [target]);
|
|
275
|
+
void ui$1.getHostNative().invoke("rememberCwd", [target]).catch(() => void 0);
|
|
276
|
+
await run("refreshSessions", []);
|
|
277
|
+
} catch (reason) {
|
|
278
|
+
ui$1.toastErr(`新建会话失败:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
279
|
+
}
|
|
280
|
+
})();
|
|
281
|
+
};
|
|
282
|
+
const rename = (id, name) => {
|
|
283
|
+
void run("renameSession", [id, name]);
|
|
284
|
+
};
|
|
285
|
+
const deleteWorkspace = (target, sessionsOfGroup) => {
|
|
286
|
+
void (async () => {
|
|
287
|
+
const count = sessionsOfGroup.length;
|
|
288
|
+
const detail = count > 0 ? `其下 ${String(count)} 个会话会全部归档(移进「设置 → 归档」,消息一个字不删,可恢复),工作区从侧边栏移除。` : "该工作区还没有会话,将从侧边栏移除。";
|
|
289
|
+
const current = target === (cwd ?? "") ? "它仍是当前目录,新建会话后会重新出现在侧边栏。" : "";
|
|
290
|
+
const ok = await ui$1.confirmAction({
|
|
291
|
+
title: `删除工作区「${displayName(target, prefs.aliases)}」?`,
|
|
292
|
+
detail: detail + current,
|
|
293
|
+
confirmLabel: "删除"
|
|
294
|
+
});
|
|
295
|
+
if (!ok) return;
|
|
296
|
+
setRecentCwds((list) => list.filter((item) => item !== target));
|
|
297
|
+
const native = ui$1.getHostNative();
|
|
298
|
+
if (native.available) {
|
|
299
|
+
void native.invoke("removeRecentCwd", [target]).catch(() => void 0);
|
|
300
|
+
}
|
|
301
|
+
if (count === 0) {
|
|
302
|
+
ui$1.toastOk("已从侧边栏移除该工作区");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
await channel.invoke("archiveSessions", [sessionsOfGroup.map((session) => session.id)]);
|
|
307
|
+
await run("refreshSessions", []);
|
|
308
|
+
ui$1.toastOk(`工作区已删除,${String(count)} 个会话已归档`);
|
|
309
|
+
} catch {
|
|
310
|
+
ui$1.toastErr("会话归档失败,工作区随会话保留在侧边栏");
|
|
311
|
+
}
|
|
312
|
+
})();
|
|
313
|
+
};
|
|
314
|
+
const newRef = react.useRef(() => void 0);
|
|
315
|
+
newRef.current = (dir) => {
|
|
316
|
+
if (dir === void 0 || dir === "") open();
|
|
317
|
+
else newSessionIn(dir);
|
|
318
|
+
};
|
|
319
|
+
react.useEffect(() => {
|
|
320
|
+
const onNew = (event) => {
|
|
321
|
+
const dir = event.detail?.cwd;
|
|
322
|
+
newRef.current(typeof dir === "string" && dir !== "" ? dir : void 0);
|
|
323
|
+
};
|
|
324
|
+
window.addEventListener("shell.session.new", onNew);
|
|
325
|
+
return () => window.removeEventListener("shell.session.new", onNew);
|
|
326
|
+
}, []);
|
|
327
|
+
const startFork = (id) => {
|
|
328
|
+
void (async () => {
|
|
329
|
+
setFault(null);
|
|
330
|
+
try {
|
|
331
|
+
const messages = await channel.invoke("listUserMessages", [id]);
|
|
332
|
+
if (messages.length < 2) {
|
|
333
|
+
ui$1.toastErr("可分叉的位置不足,至少需要两条用户消息");
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
setForking({ id, messages });
|
|
337
|
+
} catch (reason) {
|
|
338
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
339
|
+
}
|
|
340
|
+
})();
|
|
341
|
+
};
|
|
342
|
+
const doFork = (id, index) => {
|
|
343
|
+
setForking(null);
|
|
344
|
+
void (async () => {
|
|
345
|
+
setFault(null);
|
|
346
|
+
try {
|
|
347
|
+
const result = await channel.invoke("forkSession", [id, index]);
|
|
348
|
+
if (result.ok !== true) {
|
|
349
|
+
setFault(result.error ?? "分叉失败");
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
await run("openSession", result.path === void 0 ? [] : [result.path]);
|
|
353
|
+
await run("refreshSessions", []);
|
|
354
|
+
ui$1.toastOk(`已分叉出新会话,包含第 ${String(index + 1)} 条消息之前的内容`);
|
|
355
|
+
} catch (reason) {
|
|
356
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
357
|
+
}
|
|
358
|
+
})();
|
|
359
|
+
};
|
|
360
|
+
const archive = (id, title) => {
|
|
361
|
+
void (async () => {
|
|
362
|
+
const ok = await ui$1.confirmAction({
|
|
363
|
+
title: `归档会话「${title}」?`,
|
|
364
|
+
detail: ARCHIVE_DETAIL_ONE,
|
|
365
|
+
confirmLabel: "归档"
|
|
366
|
+
});
|
|
367
|
+
if (!ok) return;
|
|
368
|
+
await run("archiveSessions", [[id]]);
|
|
369
|
+
})();
|
|
370
|
+
};
|
|
371
|
+
const restore = (path) => {
|
|
372
|
+
void run("restoreSessions", [[path]]);
|
|
373
|
+
};
|
|
374
|
+
const copyId = (id) => {
|
|
375
|
+
const uuid = lastSegment(id).replace(/\.jsonl$/, "");
|
|
376
|
+
void navigator.clipboard.writeText(uuid).then(() => ui$1.toastOk("已复制会话 ID")).catch((reason) => ui$1.toastErr(`复制失败:${reason instanceof Error ? reason.message : String(reason)}`));
|
|
377
|
+
};
|
|
378
|
+
const renameGroup = (cwd2, name) => {
|
|
379
|
+
const aliases = { ...prefs.aliases };
|
|
380
|
+
if (name.trim() === "") delete aliases[cwd2];
|
|
381
|
+
else aliases[cwd2] = name.trim();
|
|
382
|
+
patchPrefs({ aliases });
|
|
383
|
+
setGroupRenaming(null);
|
|
384
|
+
};
|
|
385
|
+
const toggleGroup = (key) => {
|
|
386
|
+
patchPrefs({ expansion: { ...prefs.expansion, [key]: !isExpandedGroup(key) } });
|
|
387
|
+
setLimits((current) => {
|
|
388
|
+
if (current[key] === void 0) return current;
|
|
389
|
+
const next = { ...current };
|
|
390
|
+
delete next[key];
|
|
391
|
+
return next;
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
const trimmed = query.trim().toLowerCase();
|
|
395
|
+
const groups = react.useMemo(
|
|
396
|
+
() => buildWorkGroups({
|
|
397
|
+
sessions: [...sessions],
|
|
398
|
+
recentCwds,
|
|
399
|
+
cwd: cwd ?? "",
|
|
400
|
+
sort: prefs.sort,
|
|
401
|
+
group: prefs.group,
|
|
402
|
+
archived: prefs.archived,
|
|
403
|
+
trimmed,
|
|
404
|
+
aliases: prefs.aliases,
|
|
405
|
+
order: prefs.order,
|
|
406
|
+
sessionOrder: prefs.sessionOrder
|
|
407
|
+
}),
|
|
408
|
+
[sessions, recentCwds, cwd, prefs.sort, prefs.group, prefs.archived, trimmed, prefs.aliases, prefs.order, prefs.sessionOrder]
|
|
409
|
+
);
|
|
410
|
+
const flatSessions = react.useMemo(() => groups.flatMap((group) => group.sessions), [groups]);
|
|
411
|
+
const parents = react.useMemo(() => new Set(groups.filter((item) => item.hasChildren).map((item) => item.cwd)), [groups]);
|
|
412
|
+
const activeCwd = react.useMemo(() => {
|
|
413
|
+
if (currentPath !== null) {
|
|
414
|
+
const owner = sessions.find((session) => session.id === currentPath);
|
|
415
|
+
if (owner !== void 0) return owner.cwd;
|
|
416
|
+
}
|
|
417
|
+
return cwd;
|
|
418
|
+
}, [sessions, currentPath, cwd]);
|
|
419
|
+
react.useEffect(() => {
|
|
420
|
+
if (cwd === null || cwd === "") return;
|
|
421
|
+
const chain = [cwd];
|
|
422
|
+
if (prefs.group === "tree") {
|
|
423
|
+
for (const item of groups) {
|
|
424
|
+
if (item.cwd === cwd) chain.push(...item.ancestors);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const patch = {};
|
|
428
|
+
for (const key of chain) {
|
|
429
|
+
if (prefs.expansion[key] === void 0) patch[key] = true;
|
|
430
|
+
}
|
|
431
|
+
if (Object.keys(patch).length === 0) return;
|
|
432
|
+
patchPrefs({ expansion: { ...prefs.expansion, ...patch } });
|
|
433
|
+
}, [cwd, prefs.group, groups]);
|
|
434
|
+
const isExpandedGroup = (cwdOf) => {
|
|
435
|
+
if (trimmed !== "") return true;
|
|
436
|
+
return prefs.expansion[cwdOf] ?? isDefaultExpanded(cwdOf, cwd, prefs.group, parents);
|
|
437
|
+
};
|
|
438
|
+
const hiddenByAncestor = (item) => item.ancestors.slice(0, -1).some((ancestor) => !isExpandedGroup(ancestor));
|
|
439
|
+
const reorder = (source, target, after) => {
|
|
440
|
+
const current = groups.map((item) => item.cwd);
|
|
441
|
+
const next = moveWithin(current, source, target, after);
|
|
442
|
+
if (next.join("\n") === current.join("\n")) return;
|
|
443
|
+
patchPrefs({ order: next });
|
|
444
|
+
};
|
|
445
|
+
const dropAtEnd = (source) => {
|
|
446
|
+
const current = groups.map((item) => item.cwd);
|
|
447
|
+
const next = moveToEnd(current, source);
|
|
448
|
+
if (next.join("\n") === current.join("\n")) return;
|
|
449
|
+
patchPrefs({ order: next });
|
|
450
|
+
};
|
|
451
|
+
const endDrag = () => {
|
|
452
|
+
setDragCwd(null);
|
|
453
|
+
setDropAt(null);
|
|
454
|
+
justDragged.current = true;
|
|
455
|
+
setTimeout(() => {
|
|
456
|
+
justDragged.current = false;
|
|
457
|
+
}, 150);
|
|
458
|
+
};
|
|
459
|
+
const clickGroup = (key) => {
|
|
460
|
+
if (justDragged.current) return;
|
|
461
|
+
toggleGroup(key);
|
|
462
|
+
};
|
|
463
|
+
const sessRowHalf = (event) => {
|
|
464
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
465
|
+
return event.clientY < rect.top + rect.height / 2 ? "before" : "after";
|
|
466
|
+
};
|
|
467
|
+
const commitSessDrag = () => {
|
|
468
|
+
const current = sessDrag;
|
|
469
|
+
setSessDrag(null);
|
|
470
|
+
if (current === null || current.over === null) return;
|
|
471
|
+
const { cwd: groupCwd, id: sourceId, pinned, over } = current;
|
|
472
|
+
if (over.id === sourceId) return;
|
|
473
|
+
const group = groups.find((item) => item.cwd === groupCwd);
|
|
474
|
+
if (group === void 0) return;
|
|
475
|
+
const ordered = orderedSessions(groupCwd, group.sessions, prefs.sort, prefs.sessionOrder);
|
|
476
|
+
const full = ordered.map((session) => session.id);
|
|
477
|
+
const section = ordered.filter((session) => session.pinnedAt !== void 0 === pinned);
|
|
478
|
+
const sourceIndex = section.findIndex((session) => session.id === sourceId);
|
|
479
|
+
if (sourceIndex === -1) return;
|
|
480
|
+
const withoutSource = section.filter((session) => session.id !== sourceId);
|
|
481
|
+
const insertAt = withoutSource.findIndex((session) => session.id === over.id) + (over.half === "after" ? 1 : 0);
|
|
482
|
+
if (insertAt === sourceIndex) return;
|
|
483
|
+
const next = full.filter((id) => id !== sourceId);
|
|
484
|
+
const targetIndex = next.indexOf(over.id);
|
|
485
|
+
if (targetIndex === -1) return;
|
|
486
|
+
next.splice(targetIndex + (over.half === "after" ? 1 : 0), 0, sourceId);
|
|
487
|
+
patchPrefs({ sessionOrder: { ...prefs.sessionOrder, [groupCwd]: next } });
|
|
488
|
+
};
|
|
489
|
+
const dragFor = (groupCwd, session) => {
|
|
490
|
+
const compatible = sessDrag !== null && sessDrag.cwd === groupCwd && sessDrag.pinned === (session.pinnedAt !== void 0);
|
|
491
|
+
return {
|
|
492
|
+
enabled: prefs.sort === "manual" && session.archivedAt === void 0,
|
|
493
|
+
mark: sessDrag !== null && sessDrag.over !== null && sessDrag.over.id === session.id ? sessDrag.over.half : null,
|
|
494
|
+
onStart: (event) => {
|
|
495
|
+
event.dataTransfer.effectAllowed = "move";
|
|
496
|
+
event.dataTransfer.setData("text/plain", session.id);
|
|
497
|
+
setSessDrag({ cwd: groupCwd, id: session.id, pinned: session.pinnedAt !== void 0, over: null });
|
|
498
|
+
},
|
|
499
|
+
onOver: compatible ? (event) => {
|
|
500
|
+
event.preventDefault();
|
|
501
|
+
event.dataTransfer.dropEffect = "move";
|
|
502
|
+
const half = sessRowHalf(event);
|
|
503
|
+
setSessDrag(
|
|
504
|
+
(current) => current === null || current.over?.id === session.id && current.over.half === half ? current : { ...current, over: { id: session.id, half } }
|
|
505
|
+
);
|
|
506
|
+
} : void 0,
|
|
507
|
+
onDrop: compatible ? (event) => {
|
|
508
|
+
event.preventDefault();
|
|
509
|
+
commitSessDrag();
|
|
510
|
+
} : void 0,
|
|
511
|
+
onEnd: commitSessDrag
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
515
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "btn-new", "data-action": "new-session", onClick: () => open(), children: [
|
|
516
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconPlus, { size: 15 }),
|
|
517
|
+
"新会话"
|
|
518
|
+
] }),
|
|
519
|
+
/* @__PURE__ */ jsxRuntime.jsxs("nav", { className: "sidebar-nav", children: [
|
|
520
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
521
|
+
"button",
|
|
522
|
+
{
|
|
523
|
+
type: "button",
|
|
524
|
+
className: `nav-item${page === "skills" ? " on" : ""}`,
|
|
525
|
+
"aria-pressed": page === "skills",
|
|
526
|
+
onClick: () => {
|
|
527
|
+
ui$1.setShellPage(page === "skills" ? null : "skills");
|
|
528
|
+
},
|
|
529
|
+
children: [
|
|
530
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconBolt, { size: 15 }),
|
|
531
|
+
" 技能"
|
|
532
|
+
]
|
|
533
|
+
}
|
|
534
|
+
),
|
|
535
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
536
|
+
"button",
|
|
537
|
+
{
|
|
538
|
+
type: "button",
|
|
539
|
+
className: `nav-item${page === "plugins" ? " on" : ""}`,
|
|
540
|
+
"aria-pressed": page === "plugins",
|
|
541
|
+
onClick: () => {
|
|
542
|
+
ui$1.setShellPage(page === "plugins" ? null : "plugins");
|
|
543
|
+
},
|
|
544
|
+
children: [
|
|
545
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconPuzzle, { size: 15 }),
|
|
546
|
+
" 插件"
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
] }),
|
|
551
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sidebar-scroll", children: [
|
|
552
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "section-head", children: [
|
|
553
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "side-title", children: prefs.group === "flat" ? "会话" : "工作区" }),
|
|
554
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "head-actions", children: [
|
|
555
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
556
|
+
"button",
|
|
557
|
+
{
|
|
558
|
+
type: "button",
|
|
559
|
+
className: `icon-btn${searching ? " on" : ""}`,
|
|
560
|
+
"data-tip": "搜索会话",
|
|
561
|
+
"aria-label": "搜索会话",
|
|
562
|
+
onClick: () => {
|
|
563
|
+
setSearching((current) => !current);
|
|
564
|
+
setQuery("");
|
|
565
|
+
},
|
|
566
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSearch, { size: 15 })
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
"button",
|
|
571
|
+
{
|
|
572
|
+
type: "button",
|
|
573
|
+
className: `icon-btn${viewMenu !== null ? " on" : ""}`,
|
|
574
|
+
"data-tip": "视图选项:分组方式、排序方式、筛选会话",
|
|
575
|
+
"aria-label": "视图选项",
|
|
576
|
+
onClick: (event) => {
|
|
577
|
+
if (viewMenu !== null) {
|
|
578
|
+
setViewMenu(null);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
582
|
+
const rail = event.currentTarget.closest(".sidebar");
|
|
583
|
+
const edge = rail === null ? rect.right : rail.getBoundingClientRect().right - 6;
|
|
584
|
+
setViewMenu({ top: rect.bottom + 6, right: window.innerWidth - edge });
|
|
585
|
+
},
|
|
586
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSort, { size: 15 })
|
|
587
|
+
}
|
|
588
|
+
),
|
|
589
|
+
/* @__PURE__ */ jsxRuntime.jsx(AddWorkspaceButton, { onCreated: newSessionIn })
|
|
590
|
+
] })
|
|
591
|
+
] }),
|
|
592
|
+
searching ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "side-search", children: [
|
|
593
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSearch, { size: 14 }),
|
|
594
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
595
|
+
"input",
|
|
596
|
+
{
|
|
597
|
+
autoFocus: true,
|
|
598
|
+
placeholder: "按会话名或目录名过滤",
|
|
599
|
+
value: query,
|
|
600
|
+
onChange: (event) => {
|
|
601
|
+
setQuery(event.target.value);
|
|
602
|
+
},
|
|
603
|
+
onKeyDown: (event) => {
|
|
604
|
+
if (event.key === "Escape") {
|
|
605
|
+
setSearching(false);
|
|
606
|
+
setQuery("");
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
),
|
|
611
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
612
|
+
"button",
|
|
613
|
+
{
|
|
614
|
+
type: "button",
|
|
615
|
+
className: "icon-btn",
|
|
616
|
+
"data-tip": "清除搜索",
|
|
617
|
+
"aria-label": "清除搜索",
|
|
618
|
+
onClick: () => setSearching(false),
|
|
619
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 14 })
|
|
620
|
+
}
|
|
621
|
+
)
|
|
622
|
+
] }) : null,
|
|
623
|
+
fault === null ? null : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sidebar-empty", children: [
|
|
624
|
+
"列表没读出来:",
|
|
625
|
+
fault
|
|
626
|
+
] }),
|
|
627
|
+
sessions.length === 0 && recentCwds.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sidebar-empty", children: [
|
|
628
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconQueue, { size: 24 }),
|
|
629
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: loading ? "正在读会话列表…" : "还没有历史会话。" }),
|
|
630
|
+
loading ? null : /* @__PURE__ */ jsxRuntime.jsx("div", { children: "发送第一条消息开始。" })
|
|
631
|
+
] }) : groups.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sidebar-empty", children: [
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconQueue, { size: 24 }),
|
|
633
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: trimmed !== "" ? `没有匹配「${query.trim()}」的会话。` : prefs.archived === "only" ? "还没有已归档的会话。" : "活动区没有会话了:归档的那些在「视图选项 → 仅显示已归档」里。" })
|
|
634
|
+
] }) : prefs.group === "flat" ? flatSessions.map((session) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
635
|
+
SessionRow,
|
|
636
|
+
{
|
|
637
|
+
session,
|
|
638
|
+
state: states[session.id],
|
|
639
|
+
current: currentPath !== null && session.id === currentPath,
|
|
640
|
+
sort: prefs.sort,
|
|
641
|
+
renameRequest: renaming === session.id,
|
|
642
|
+
onOpen: open,
|
|
643
|
+
onPin: (pinned) => run("setSessionPinned", [session.id, pinned]),
|
|
644
|
+
onArchive: () => archive(session.id, session.title ?? "新会话"),
|
|
645
|
+
onRename: (name) => rename(session.id, name),
|
|
646
|
+
onRenameDone: () => setRenaming(null),
|
|
647
|
+
onFork: () => startFork(session.id),
|
|
648
|
+
onRestore: () => restore(session.id),
|
|
649
|
+
onMenu: (x, y) => setMenu({ kind: "session", id: session.id, x, y })
|
|
650
|
+
},
|
|
651
|
+
session.id
|
|
652
|
+
)) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
653
|
+
groups.filter((group) => !hiddenByAncestor(group)).map((group) => {
|
|
654
|
+
const key = group.cwd;
|
|
655
|
+
const expanded = isExpandedGroup(key);
|
|
656
|
+
const limit = trimmed !== "" ? Number.MAX_SAFE_INTEGER : limits[key] ?? PREVIEW_COUNT;
|
|
657
|
+
const visible = expanded ? group.sessions.slice(0, limit) : [];
|
|
658
|
+
const rest = group.sessions.length - visible.length;
|
|
659
|
+
const sortable = prefs.group === "workspace" && groupRenaming === null;
|
|
660
|
+
const drop = dropAt !== null && dropAt.cwd === group.cwd && dragCwd !== group.cwd ? dropAt.after ? " drop-below" : " drop-above" : "";
|
|
661
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `group depth-${Math.min(group.depth, 4)}${drop}`, children: [
|
|
662
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
663
|
+
"div",
|
|
664
|
+
{
|
|
665
|
+
className: `group-row${group.cwd === activeCwd ? " active" : ""}${dragCwd === group.cwd ? " dragging" : ""}`,
|
|
666
|
+
role: "button",
|
|
667
|
+
tabIndex: 0,
|
|
668
|
+
"aria-expanded": expanded,
|
|
669
|
+
"data-tip": `${group.cwd} · ${group.sessions.length} 个会话,展开/收起${sortable ? ",拖动排序" : ""}`,
|
|
670
|
+
draggable: sortable,
|
|
671
|
+
onClick: () => clickGroup(key),
|
|
672
|
+
onKeyDown: (event) => {
|
|
673
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
674
|
+
event.preventDefault();
|
|
675
|
+
toggleGroup(key);
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
if (event.ctrlKey && event.altKey && event.key.toLowerCase() === "r") {
|
|
679
|
+
event.preventDefault();
|
|
680
|
+
setGroupRenaming({ cwd: group.cwd, value: displayName(group.cwd, prefs.aliases) });
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
onDragStart: (event) => {
|
|
684
|
+
event.dataTransfer.effectAllowed = "move";
|
|
685
|
+
event.dataTransfer.setData("text/plain", group.cwd);
|
|
686
|
+
setDragCwd(group.cwd);
|
|
687
|
+
},
|
|
688
|
+
onDragOver: (event) => {
|
|
689
|
+
if (dragCwd === null || dragCwd === group.cwd) return;
|
|
690
|
+
event.preventDefault();
|
|
691
|
+
event.dataTransfer.dropEffect = "move";
|
|
692
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
693
|
+
const after = event.clientY > rect.top + rect.height / 2;
|
|
694
|
+
if (dropAt === null || dropAt.cwd !== group.cwd || dropAt.after !== after) {
|
|
695
|
+
setDropAt({ cwd: group.cwd, after });
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
onDrop: (event) => {
|
|
699
|
+
event.preventDefault();
|
|
700
|
+
const source = event.dataTransfer.getData("text/plain") || dragCwd;
|
|
701
|
+
const after = dropAt !== null && dropAt.cwd === group.cwd ? dropAt.after : false;
|
|
702
|
+
if (source !== null && source !== "") reorder(source, group.cwd, after);
|
|
703
|
+
endDrag();
|
|
704
|
+
},
|
|
705
|
+
onDragEnd: endDrag,
|
|
706
|
+
children: [
|
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "folder-icon", children: expanded ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconFolderOpen, { size: 15 }) : /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconFolder, { size: 15 }) }),
|
|
708
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "folder-chevron", children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconTriangleRightFill, { size: 14, className: expanded ? "arrow-open" : void 0 }) }),
|
|
709
|
+
groupRenaming?.cwd === group.cwd ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
710
|
+
"input",
|
|
711
|
+
{
|
|
712
|
+
className: "row-rename",
|
|
713
|
+
autoFocus: true,
|
|
714
|
+
value: groupRenaming.value,
|
|
715
|
+
onClick: (event) => event.stopPropagation(),
|
|
716
|
+
onChange: (event) => setGroupRenaming({ cwd: group.cwd, value: event.target.value }),
|
|
717
|
+
onBlur: () => renameGroup(group.cwd, groupRenaming.value),
|
|
718
|
+
onKeyDown: (event) => {
|
|
719
|
+
event.stopPropagation();
|
|
720
|
+
if (event.key === "Enter") renameGroup(group.cwd, groupRenaming.value);
|
|
721
|
+
if (event.key === "Escape") setGroupRenaming(null);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dir", children: displayName(group.cwd, prefs.aliases) }),
|
|
725
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
726
|
+
"span",
|
|
727
|
+
{
|
|
728
|
+
className: "row-actions",
|
|
729
|
+
onClick: (event) => {
|
|
730
|
+
event.stopPropagation();
|
|
731
|
+
},
|
|
732
|
+
children: [
|
|
733
|
+
prefs.archived === "only" && group.sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
734
|
+
"button",
|
|
735
|
+
{
|
|
736
|
+
type: "button",
|
|
737
|
+
className: "icon-btn",
|
|
738
|
+
"data-tip": "把这个工作区的会话全部恢复",
|
|
739
|
+
"aria-label": "全部恢复",
|
|
740
|
+
onClick: () => {
|
|
741
|
+
void run("restoreSessions", [group.sessions.map((session) => session.id)]);
|
|
742
|
+
},
|
|
743
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconRefresh, { size: 14 })
|
|
744
|
+
}
|
|
745
|
+
) : null,
|
|
746
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
747
|
+
"button",
|
|
748
|
+
{
|
|
749
|
+
type: "button",
|
|
750
|
+
className: `icon-btn${menu?.kind === "group" && menu.id === key ? " on" : ""}`,
|
|
751
|
+
"data-tip": "更多操作",
|
|
752
|
+
"aria-label": "工作区更多操作",
|
|
753
|
+
onClick: (event) => {
|
|
754
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
755
|
+
const y = window.innerHeight - rect.bottom >= 240 ? rect.bottom + 6 : rect.top - 200;
|
|
756
|
+
setMenu({ kind: "group", id: key, x: Math.max(8, rect.right - 200), y: Math.max(8, y) });
|
|
757
|
+
},
|
|
758
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconMore, { size: 15 })
|
|
759
|
+
}
|
|
760
|
+
),
|
|
761
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
762
|
+
"button",
|
|
763
|
+
{
|
|
764
|
+
type: "button",
|
|
765
|
+
className: "icon-btn",
|
|
766
|
+
"data-tip": `在 ${displayName(group.cwd, prefs.aliases)} 新建会话`,
|
|
767
|
+
"aria-label": "在此工作区新建会话",
|
|
768
|
+
onClick: () => {
|
|
769
|
+
newSessionIn(group.cwd);
|
|
770
|
+
},
|
|
771
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconNewChat, { size: 15 })
|
|
772
|
+
}
|
|
773
|
+
)
|
|
774
|
+
]
|
|
775
|
+
}
|
|
776
|
+
)
|
|
777
|
+
]
|
|
778
|
+
}
|
|
779
|
+
),
|
|
780
|
+
expanded ? visible.map((session) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
781
|
+
SessionRow,
|
|
782
|
+
{
|
|
783
|
+
session,
|
|
784
|
+
state: states[session.id],
|
|
785
|
+
current: currentPath !== null && session.id === currentPath,
|
|
786
|
+
sort: prefs.sort,
|
|
787
|
+
renameRequest: renaming === session.id,
|
|
788
|
+
drag: dragFor(group.cwd, session),
|
|
789
|
+
onOpen: open,
|
|
790
|
+
onPin: (pinned) => run("setSessionPinned", [session.id, pinned]),
|
|
791
|
+
onArchive: () => archive(session.id, session.title ?? "新会话"),
|
|
792
|
+
onRename: (name) => rename(session.id, name),
|
|
793
|
+
onRenameDone: () => setRenaming(null),
|
|
794
|
+
onFork: () => startFork(session.id),
|
|
795
|
+
onRestore: () => restore(session.id),
|
|
796
|
+
onMenu: (x, y) => setMenu({ kind: "session", id: session.id, x, y })
|
|
797
|
+
},
|
|
798
|
+
session.id
|
|
799
|
+
)) : null,
|
|
800
|
+
expanded && trimmed === "" && group.sessions.length > PREVIEW_COUNT ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
801
|
+
"button",
|
|
802
|
+
{
|
|
803
|
+
type: "button",
|
|
804
|
+
className: "session-overflow",
|
|
805
|
+
"aria-expanded": rest === 0,
|
|
806
|
+
onClick: () => {
|
|
807
|
+
setLimits((current) => ({
|
|
808
|
+
...current,
|
|
809
|
+
[key]: rest === 0 ? PREVIEW_COUNT : rest <= PREVIEW_COUNT ? Number.MAX_SAFE_INTEGER : (current[key] ?? PREVIEW_COUNT) + PREVIEW_COUNT
|
|
810
|
+
}));
|
|
811
|
+
},
|
|
812
|
+
children: rest === 0 ? "收起" : `展开剩余 ${String(rest)} 个会话`
|
|
813
|
+
}
|
|
814
|
+
) : null
|
|
815
|
+
] }, group.cwd);
|
|
816
|
+
}),
|
|
817
|
+
dragCwd !== null && prefs.group === "workspace" && groups.length > 1 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
818
|
+
"div",
|
|
819
|
+
{
|
|
820
|
+
className: "drop-tail",
|
|
821
|
+
onDragOver: (event) => {
|
|
822
|
+
event.preventDefault();
|
|
823
|
+
event.dataTransfer.dropEffect = "move";
|
|
824
|
+
setDropAt(null);
|
|
825
|
+
},
|
|
826
|
+
onDrop: (event) => {
|
|
827
|
+
event.preventDefault();
|
|
828
|
+
const source = event.dataTransfer.getData("text/plain") || dragCwd;
|
|
829
|
+
if (source !== null && source !== "") dropAtEnd(source);
|
|
830
|
+
endDrag();
|
|
831
|
+
},
|
|
832
|
+
children: "放到最后"
|
|
833
|
+
}
|
|
834
|
+
) : null
|
|
835
|
+
] })
|
|
836
|
+
] }),
|
|
837
|
+
viewMenu === null ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
838
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-backdrop", onClick: () => setViewMenu(null) }),
|
|
839
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
840
|
+
"div",
|
|
841
|
+
{
|
|
842
|
+
className: "row-menu view-menu",
|
|
843
|
+
role: "menu",
|
|
844
|
+
style: { position: "fixed", top: `${String(viewMenu.top)}px`, right: `${String(viewMenu.right)}px` },
|
|
845
|
+
children: [
|
|
846
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-label", children: "分组方式" }),
|
|
847
|
+
[
|
|
848
|
+
["workspace", "按工作区", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconFolder, { size: 15 }, "i")],
|
|
849
|
+
["tree", "按工作区树", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconTree, { size: 15 }, "i")],
|
|
850
|
+
["flat", "单列表", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconFlatList, { size: 15 }, "i")]
|
|
851
|
+
].map(([id, text, icon]) => /* @__PURE__ */ jsxRuntime.jsx(MenuRadio, { active: prefs.group === id, text, icon, onPick: () => patchPrefs({ group: id }) }, id)),
|
|
852
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-sep" }),
|
|
853
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-label", children: "排序方式" }),
|
|
854
|
+
[
|
|
855
|
+
["manual", "手动排序", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSwap, { size: 15 }, "i")],
|
|
856
|
+
["recent", "最近更新", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClock, { size: 15 }, "i")],
|
|
857
|
+
["created", "创建时间", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCalendar, { size: 15 }, "i")]
|
|
858
|
+
].map(([id, text, icon]) => /* @__PURE__ */ jsxRuntime.jsx(MenuRadio, { active: prefs.sort === id, text, icon, onPick: () => patchPrefs({ sort: id }) }, id)),
|
|
859
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-sep" }),
|
|
860
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-label", children: "筛选会话" }),
|
|
861
|
+
[
|
|
862
|
+
["hide", "隐藏已归档", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconArchiveOff, { size: 15 }, "i")],
|
|
863
|
+
["show", "全部对话(显示已归档)", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconQueue, { size: 15 }, "i")],
|
|
864
|
+
["only", "仅显示已归档", /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconArchive, { size: 15 }, "i")]
|
|
865
|
+
].map(([id, text, icon]) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
866
|
+
MenuRadio,
|
|
867
|
+
{
|
|
868
|
+
active: prefs.archived === id,
|
|
869
|
+
text,
|
|
870
|
+
icon,
|
|
871
|
+
onPick: () => patchPrefs({ archived: id })
|
|
872
|
+
},
|
|
873
|
+
id
|
|
874
|
+
))
|
|
875
|
+
]
|
|
876
|
+
}
|
|
877
|
+
)
|
|
878
|
+
] }),
|
|
879
|
+
menu === null ? null : menu.kind === "session" ? (() => {
|
|
880
|
+
const session = sessions.find((item) => item.id === menu.id);
|
|
881
|
+
if (session === void 0) return null;
|
|
882
|
+
const archived = session.archivedAt !== void 0;
|
|
883
|
+
const stoppable = states[session.id] === "working" || states[session.id] === "awaiting-approval";
|
|
884
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
885
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-backdrop", onClick: () => setMenu(null) }),
|
|
886
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
887
|
+
"div",
|
|
888
|
+
{
|
|
889
|
+
className: "row-menu",
|
|
890
|
+
style: {
|
|
891
|
+
position: "fixed",
|
|
892
|
+
left: Math.min(menu.x, window.innerWidth - 220),
|
|
893
|
+
top: Math.min(menu.y, window.innerHeight - 240)
|
|
894
|
+
},
|
|
895
|
+
onClick: (event) => event.stopPropagation(),
|
|
896
|
+
children: [
|
|
897
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
898
|
+
MenuItem,
|
|
899
|
+
{
|
|
900
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconPin, { size: 15 }),
|
|
901
|
+
text: session.pinnedAt !== void 0 ? "取消置顶" : "置顶会话",
|
|
902
|
+
onClick: () => {
|
|
903
|
+
setMenu(null);
|
|
904
|
+
void run("setSessionPinned", [session.id, session.pinnedAt === void 0]);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
),
|
|
908
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
909
|
+
MenuItem,
|
|
910
|
+
{
|
|
911
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconEdit, { size: 15 }),
|
|
912
|
+
text: "重命名",
|
|
913
|
+
hint: "Ctrl+Alt+R",
|
|
914
|
+
onClick: () => {
|
|
915
|
+
setMenu(null);
|
|
916
|
+
setRenaming(session.id);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
),
|
|
920
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
921
|
+
MenuItem,
|
|
922
|
+
{
|
|
923
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSwap, { size: 15 }),
|
|
924
|
+
text: "分叉会话",
|
|
925
|
+
hint: "Ctrl+Alt+F",
|
|
926
|
+
onClick: () => {
|
|
927
|
+
setMenu(null);
|
|
928
|
+
startFork(session.id);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
),
|
|
932
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
933
|
+
MenuItem,
|
|
934
|
+
{
|
|
935
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCopy, { size: 15 }),
|
|
936
|
+
text: "复制会话 ID",
|
|
937
|
+
onClick: () => {
|
|
938
|
+
setMenu(null);
|
|
939
|
+
copyId(session.id);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
),
|
|
943
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
944
|
+
MenuItem,
|
|
945
|
+
{
|
|
946
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconActivity, { size: 15 }),
|
|
947
|
+
text: "查看轨迹",
|
|
948
|
+
hint: "执行过程与耗时",
|
|
949
|
+
onClick: () => {
|
|
950
|
+
setMenu(null);
|
|
951
|
+
showTrace(session.id);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
),
|
|
955
|
+
!archived && stoppable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
956
|
+
MenuItem,
|
|
957
|
+
{
|
|
958
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconStop, { size: 15 }),
|
|
959
|
+
text: "停止运行",
|
|
960
|
+
onClick: () => {
|
|
961
|
+
setMenu(null);
|
|
962
|
+
void run("interrupt", [session.id]);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
) : null,
|
|
966
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-sep" }),
|
|
967
|
+
archived ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
968
|
+
MenuItem,
|
|
969
|
+
{
|
|
970
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconRefresh, { size: 15 }),
|
|
971
|
+
text: "恢复会话",
|
|
972
|
+
onClick: () => {
|
|
973
|
+
setMenu(null);
|
|
974
|
+
restore(session.id);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
978
|
+
MenuItem,
|
|
979
|
+
{
|
|
980
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconArchive, { size: 15 }),
|
|
981
|
+
text: "归档会话",
|
|
982
|
+
hint: "Ctrl+Shift+A",
|
|
983
|
+
danger: true,
|
|
984
|
+
onClick: () => {
|
|
985
|
+
setMenu(null);
|
|
986
|
+
archive(session.id, session.title ?? "新会话");
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
)
|
|
990
|
+
]
|
|
991
|
+
}
|
|
992
|
+
)
|
|
993
|
+
] });
|
|
994
|
+
})() : (() => {
|
|
995
|
+
const cwdOf = menu.id;
|
|
996
|
+
const group = groups.find((item) => item.cwd === cwdOf);
|
|
997
|
+
if (group === void 0) return null;
|
|
998
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
999
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-backdrop", onClick: () => setMenu(null) }),
|
|
1000
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1001
|
+
"div",
|
|
1002
|
+
{
|
|
1003
|
+
className: "row-menu",
|
|
1004
|
+
style: { position: "fixed", left: menu.x, top: menu.y },
|
|
1005
|
+
onClick: (event) => event.stopPropagation(),
|
|
1006
|
+
children: [
|
|
1007
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1008
|
+
MenuItem,
|
|
1009
|
+
{
|
|
1010
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconFolderOpen, { size: 15 }),
|
|
1011
|
+
text: "在资源管理器中打开",
|
|
1012
|
+
onClick: () => {
|
|
1013
|
+
setMenu(null);
|
|
1014
|
+
const native = ui$1.getHostNative();
|
|
1015
|
+
if (!native.available) {
|
|
1016
|
+
ui$1.toastErr("在资源管理器中打开要用桌面版(浏览器里没有原生桥)");
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
void native.invoke("openPath", [cwdOf]).catch((reason) => {
|
|
1020
|
+
ui$1.toastErr(`打开失败:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
),
|
|
1025
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1026
|
+
MenuItem,
|
|
1027
|
+
{
|
|
1028
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconEdit, { size: 15 }),
|
|
1029
|
+
text: "重命名显示名",
|
|
1030
|
+
onClick: () => {
|
|
1031
|
+
setMenu(null);
|
|
1032
|
+
setGroupRenaming({ cwd: cwdOf, value: displayName(cwdOf, prefs.aliases) });
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
),
|
|
1036
|
+
prefs.aliases[cwdOf] !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1037
|
+
MenuItem,
|
|
1038
|
+
{
|
|
1039
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 15 }),
|
|
1040
|
+
text: "恢复真实目录名",
|
|
1041
|
+
onClick: () => {
|
|
1042
|
+
setMenu(null);
|
|
1043
|
+
renameGroup(cwdOf, "");
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
) : null,
|
|
1047
|
+
prefs.archived === "only" ? group.sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1048
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-sep" }),
|
|
1049
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1050
|
+
MenuItem,
|
|
1051
|
+
{
|
|
1052
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconRefresh, { size: 15 }),
|
|
1053
|
+
text: `恢复这 ${String(group.sessions.length)} 个会话`,
|
|
1054
|
+
onClick: () => {
|
|
1055
|
+
setMenu(null);
|
|
1056
|
+
void run("restoreSessions", [group.sessions.map((session) => session.id)]);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
)
|
|
1060
|
+
] }) : null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1061
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-sep" }),
|
|
1062
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1063
|
+
MenuItem,
|
|
1064
|
+
{
|
|
1065
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconTrash, { size: 15 }),
|
|
1066
|
+
text: "删除工作区",
|
|
1067
|
+
danger: true,
|
|
1068
|
+
onClick: () => {
|
|
1069
|
+
setMenu(null);
|
|
1070
|
+
deleteWorkspace(cwdOf, group.sessions);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
] })
|
|
1075
|
+
]
|
|
1076
|
+
}
|
|
1077
|
+
)
|
|
1078
|
+
] });
|
|
1079
|
+
})(),
|
|
1080
|
+
forking === null ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1081
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1082
|
+
"div",
|
|
1083
|
+
{
|
|
1084
|
+
className: "menu-backdrop",
|
|
1085
|
+
onClick: () => {
|
|
1086
|
+
setForking(null);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
),
|
|
1090
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fork-picker", children: [
|
|
1091
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "fork-head", children: "分叉到第几条消息之前?" }),
|
|
1092
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "fork-list", children: forking.messages.map((text, index) => /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "fork-item", onClick: () => doFork(forking.id, index), children: [
|
|
1093
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "no", children: index + 1 }),
|
|
1094
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "txt", children: oneLine(text) })
|
|
1095
|
+
] }, `${String(index)}-${text}`)) }),
|
|
1096
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "fork-note", children: "新会话包含这个位置之前的全部消息,原会话不变。" })
|
|
1097
|
+
] })
|
|
1098
|
+
] }),
|
|
1099
|
+
/* @__PURE__ */ jsxRuntime.jsx(SidebarFooter, {})
|
|
1100
|
+
] });
|
|
1101
|
+
}
|
|
1102
|
+
function MenuRadio({
|
|
1103
|
+
active,
|
|
1104
|
+
text,
|
|
1105
|
+
icon,
|
|
1106
|
+
onPick
|
|
1107
|
+
}) {
|
|
1108
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: `menu-item${active ? " on" : ""}`, role: "menuitemradio", "aria-checked": active, onClick: onPick, children: [
|
|
1109
|
+
icon,
|
|
1110
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "menu-text", children: text }),
|
|
1111
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "menu-check", children: active ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 14 }) : null })
|
|
1112
|
+
] });
|
|
1113
|
+
}
|
|
1114
|
+
function MenuItem({
|
|
1115
|
+
icon,
|
|
1116
|
+
text,
|
|
1117
|
+
hint,
|
|
1118
|
+
danger,
|
|
1119
|
+
onClick
|
|
1120
|
+
}) {
|
|
1121
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: `menu-item${danger === true ? " danger" : ""}`, onClick, children: [
|
|
1122
|
+
icon,
|
|
1123
|
+
" ",
|
|
1124
|
+
text,
|
|
1125
|
+
hint === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "menu-key", children: hint })
|
|
1126
|
+
] });
|
|
1127
|
+
}
|
|
1128
|
+
const FOOTER_USAGE_TIP = "今天所有会话累计用量(输入 + 输出),每分钟自动刷新";
|
|
1129
|
+
function SidebarFooter() {
|
|
1130
|
+
const channel = ui$1.useHostChannel();
|
|
1131
|
+
const usage = ui$1.useHostSelector(readUsageTokens);
|
|
1132
|
+
const [today, setToday] = react.useState(0);
|
|
1133
|
+
react.useEffect(() => {
|
|
1134
|
+
let active = true;
|
|
1135
|
+
const load = () => {
|
|
1136
|
+
void channel.invoke("usageStats").then((stats) => {
|
|
1137
|
+
if (!active) return;
|
|
1138
|
+
const day = stats.days[stats.days.length - 1];
|
|
1139
|
+
setToday(day === void 0 ? 0 : day.inputTokens + day.outputTokens);
|
|
1140
|
+
}).catch(() => {
|
|
1141
|
+
});
|
|
1142
|
+
};
|
|
1143
|
+
load();
|
|
1144
|
+
const timer = window.setInterval(load, 6e4);
|
|
1145
|
+
return () => {
|
|
1146
|
+
active = false;
|
|
1147
|
+
window.clearInterval(timer);
|
|
1148
|
+
};
|
|
1149
|
+
}, [channel, usage]);
|
|
1150
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sidebar-footer", children: [
|
|
1151
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "row", "data-tip": FOOTER_USAGE_TIP, title: FOOTER_USAGE_TIP, children: [
|
|
1152
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCoins, { size: 14 }),
|
|
1153
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "今日总用量" }),
|
|
1154
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "num", children: [
|
|
1155
|
+
uiPrimitives.formatTokens(today),
|
|
1156
|
+
" tok"
|
|
1157
|
+
] })
|
|
1158
|
+
] }),
|
|
1159
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1160
|
+
"button",
|
|
1161
|
+
{
|
|
1162
|
+
type: "button",
|
|
1163
|
+
className: "row row-btn",
|
|
1164
|
+
"data-tip": "设置:模型、权限、技能源",
|
|
1165
|
+
onClick: () => window.dispatchEvent(new CustomEvent("shell.settings.open")),
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconGear, { size: 14 }),
|
|
1168
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "设置" })
|
|
1169
|
+
]
|
|
1170
|
+
}
|
|
1171
|
+
)
|
|
1172
|
+
] });
|
|
1173
|
+
}
|
|
1174
|
+
function readEnum(value, values, fallback) {
|
|
1175
|
+
return typeof value === "string" && values.includes(value) ? value : fallback;
|
|
1176
|
+
}
|
|
1177
|
+
function readStringRecord(value) {
|
|
1178
|
+
if (typeof value !== "object" || value === null) return {};
|
|
1179
|
+
const out = {};
|
|
1180
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1181
|
+
if (typeof item === "string") out[key] = item;
|
|
1182
|
+
}
|
|
1183
|
+
return out;
|
|
1184
|
+
}
|
|
1185
|
+
function readRecord(value) {
|
|
1186
|
+
if (typeof value !== "object" || value === null) return {};
|
|
1187
|
+
const out = {};
|
|
1188
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1189
|
+
if (typeof item === "boolean") out[key] = item;
|
|
1190
|
+
}
|
|
1191
|
+
return out;
|
|
1192
|
+
}
|
|
1193
|
+
function readStringList(value) {
|
|
1194
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
1195
|
+
}
|
|
1196
|
+
function readStringListRecord(value) {
|
|
1197
|
+
if (typeof value !== "object" || value === null) return {};
|
|
1198
|
+
const out = {};
|
|
1199
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1200
|
+
if (Array.isArray(item)) out[key] = readStringList(item);
|
|
1201
|
+
}
|
|
1202
|
+
return out;
|
|
1203
|
+
}
|
|
1204
|
+
function isDefaultExpanded(cwdOf, cwd, group, parents) {
|
|
1205
|
+
if (group === "tree") return parents.has(cwdOf);
|
|
1206
|
+
return cwd !== null && cwdOf === cwd;
|
|
1207
|
+
}
|
|
1208
|
+
function patchOfUndo(patch) {
|
|
1209
|
+
const undo = {};
|
|
1210
|
+
if (patch.group !== void 0) undo.group = DEFAULT_PREFS.group;
|
|
1211
|
+
if (patch.sort !== void 0) undo.sort = DEFAULT_PREFS.sort;
|
|
1212
|
+
if (patch.archived !== void 0) undo.archived = DEFAULT_PREFS.archived;
|
|
1213
|
+
if (patch.aliases !== void 0) undo.aliases = DEFAULT_PREFS.aliases;
|
|
1214
|
+
if (patch.expansion !== void 0) undo.expansion = DEFAULT_PREFS.expansion;
|
|
1215
|
+
if (patch.order !== void 0) undo.order = DEFAULT_PREFS.order;
|
|
1216
|
+
if (patch.sessionOrder !== void 0) undo.sessionOrder = DEFAULT_PREFS.sessionOrder;
|
|
1217
|
+
return undo;
|
|
1218
|
+
}
|
|
1219
|
+
function SessionRow({
|
|
1220
|
+
session,
|
|
1221
|
+
state,
|
|
1222
|
+
current,
|
|
1223
|
+
sort,
|
|
1224
|
+
renameRequest,
|
|
1225
|
+
drag,
|
|
1226
|
+
onOpen,
|
|
1227
|
+
onPin,
|
|
1228
|
+
onArchive,
|
|
1229
|
+
onRename,
|
|
1230
|
+
onRenameDone,
|
|
1231
|
+
onFork,
|
|
1232
|
+
onRestore,
|
|
1233
|
+
onMenu
|
|
1234
|
+
}) {
|
|
1235
|
+
const [draft, setDraft] = react.useState(null);
|
|
1236
|
+
const pinned = session.pinnedAt !== void 0;
|
|
1237
|
+
const archived = session.archivedAt !== void 0;
|
|
1238
|
+
const title = session.title ?? "新会话";
|
|
1239
|
+
const dot = state === void 0 ? void 0 : DOT_CLASS[state];
|
|
1240
|
+
const dotLabel = state === void 0 ? "" : DOT_LABEL[state];
|
|
1241
|
+
const openRow = () => {
|
|
1242
|
+
if (archived) {
|
|
1243
|
+
ui$1.toastErr("这个会话已归档:先点行尾的「恢复」再打开");
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
onOpen(session.id);
|
|
1247
|
+
};
|
|
1248
|
+
react.useEffect(() => {
|
|
1249
|
+
if (renameRequest) {
|
|
1250
|
+
setDraft(session.title ?? "");
|
|
1251
|
+
onRenameDone();
|
|
1252
|
+
}
|
|
1253
|
+
}, [renameRequest, session.title, onRenameDone]);
|
|
1254
|
+
const rowKeys = (event) => {
|
|
1255
|
+
if (event.key === "Enter") {
|
|
1256
|
+
event.preventDefault();
|
|
1257
|
+
openRow();
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
if (!event.ctrlKey && !event.metaKey) return;
|
|
1261
|
+
const lower = event.key.toLowerCase();
|
|
1262
|
+
if (event.ctrlKey && event.altKey && lower === "r") {
|
|
1263
|
+
event.preventDefault();
|
|
1264
|
+
if (!archived) {
|
|
1265
|
+
setDraft(session.title ?? "");
|
|
1266
|
+
}
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
if (event.ctrlKey && event.altKey && lower === "f") {
|
|
1270
|
+
event.preventDefault();
|
|
1271
|
+
onFork();
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
if (event.ctrlKey && event.shiftKey && lower === "a") {
|
|
1275
|
+
event.preventDefault();
|
|
1276
|
+
if (!archived) onArchive();
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
const stop = (event) => {
|
|
1280
|
+
event.stopPropagation();
|
|
1281
|
+
};
|
|
1282
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1283
|
+
"div",
|
|
1284
|
+
{
|
|
1285
|
+
className: `sess-item${current ? " active" : ""}${archived ? " archived" : ""}${drag?.mark === "before" ? " drop-above" : ""}${drag?.mark === "after" ? " drop-below" : ""}`,
|
|
1286
|
+
role: "button",
|
|
1287
|
+
tabIndex: 0,
|
|
1288
|
+
"data-tip": archived ? `${title}(已归档);恢复后才能在对话里打开` : `${title};双击标题改名 · Ctrl+Alt+F 分叉 · Ctrl+Shift+A 归档`,
|
|
1289
|
+
draggable: drag?.enabled === true && draft === null,
|
|
1290
|
+
onDragStart: drag?.enabled === true && draft === null ? drag.onStart : void 0,
|
|
1291
|
+
onDragOver: drag?.enabled === true && draft === null ? drag.onOver : void 0,
|
|
1292
|
+
onDrop: drag?.enabled === true && draft === null ? drag.onDrop : void 0,
|
|
1293
|
+
onDragEnd: drag?.enabled === true && draft === null ? drag.onEnd : void 0,
|
|
1294
|
+
onClick: openRow,
|
|
1295
|
+
onKeyDown: (event) => {
|
|
1296
|
+
rowKeys(event);
|
|
1297
|
+
},
|
|
1298
|
+
onContextMenu: (event) => {
|
|
1299
|
+
event.preventDefault();
|
|
1300
|
+
onMenu(event.clientX, event.clientY);
|
|
1301
|
+
},
|
|
1302
|
+
children: [
|
|
1303
|
+
dot === void 0 ? (
|
|
1304
|
+
// 没有运行状态时才给图钉:旧界面里这一格是「状态点 / 图钉」二选一,
|
|
1305
|
+
// 两样同时画会把行首撑宽。
|
|
1306
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "row-slot", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1307
|
+
"button",
|
|
1308
|
+
{
|
|
1309
|
+
type: "button",
|
|
1310
|
+
className: `lead-pin${pinned ? " pinned" : ""}`,
|
|
1311
|
+
"data-tip": pinned ? "取消置顶" : "置顶会话",
|
|
1312
|
+
"aria-label": pinned ? "取消置顶" : "置顶会话",
|
|
1313
|
+
onClick: (event) => {
|
|
1314
|
+
stop(event);
|
|
1315
|
+
onPin(!pinned);
|
|
1316
|
+
},
|
|
1317
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconPin, { size: 13 })
|
|
1318
|
+
}
|
|
1319
|
+
) })
|
|
1320
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: `row-slot session-dot ${dot}`, "data-tip": dotLabel, "aria-label": dotLabel, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dot" }) }),
|
|
1321
|
+
draft === null ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1322
|
+
"span",
|
|
1323
|
+
{
|
|
1324
|
+
className: "title",
|
|
1325
|
+
onDoubleClick: (event) => {
|
|
1326
|
+
event.stopPropagation();
|
|
1327
|
+
if (!archived) setDraft(session.title ?? "");
|
|
1328
|
+
},
|
|
1329
|
+
children: title
|
|
1330
|
+
}
|
|
1331
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1332
|
+
"input",
|
|
1333
|
+
{
|
|
1334
|
+
className: "row-rename",
|
|
1335
|
+
autoFocus: true,
|
|
1336
|
+
value: draft,
|
|
1337
|
+
"aria-label": "会话名",
|
|
1338
|
+
onClick: stop,
|
|
1339
|
+
onChange: (event) => {
|
|
1340
|
+
setDraft(event.target.value);
|
|
1341
|
+
},
|
|
1342
|
+
onKeyDown: (event) => {
|
|
1343
|
+
event.stopPropagation();
|
|
1344
|
+
if (event.key === "Enter") {
|
|
1345
|
+
onRename(draft.trim());
|
|
1346
|
+
setDraft(null);
|
|
1347
|
+
} else if (event.key === "Escape") {
|
|
1348
|
+
setDraft(null);
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
onBlur: () => {
|
|
1352
|
+
if (draft !== null) {
|
|
1353
|
+
onRename(draft.trim());
|
|
1354
|
+
setDraft(null);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
),
|
|
1359
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "when", children: relativeTime(sort === "created" ? session.createdAt : session.archivedAt ?? session.updatedAt) }),
|
|
1360
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "row-actions", onClick: stop, children: archived ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1361
|
+
"button",
|
|
1362
|
+
{
|
|
1363
|
+
type: "button",
|
|
1364
|
+
className: "icon-btn",
|
|
1365
|
+
"data-tip": "恢复会话(移回活动区)",
|
|
1366
|
+
"aria-label": "恢复会话",
|
|
1367
|
+
onClick: () => onRestore(),
|
|
1368
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconRefresh, { size: 14 })
|
|
1369
|
+
}
|
|
1370
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1371
|
+
"button",
|
|
1372
|
+
{
|
|
1373
|
+
type: "button",
|
|
1374
|
+
className: "icon-btn",
|
|
1375
|
+
"data-tip": "归档会话",
|
|
1376
|
+
"aria-label": "归档会话",
|
|
1377
|
+
onClick: onArchive,
|
|
1378
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconArchive, { size: 14 })
|
|
1379
|
+
}
|
|
1380
|
+
) })
|
|
1381
|
+
]
|
|
1382
|
+
}
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
function oneLine(text) {
|
|
1386
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
1387
|
+
const chars = Array.from(flat);
|
|
1388
|
+
return chars.length > 60 ? `${chars.slice(0, 60).join("")}…` : flat;
|
|
1389
|
+
}
|
|
1390
|
+
function readSessions(snapshot) {
|
|
1391
|
+
const value = snapshot?.["sessions"];
|
|
1392
|
+
return Array.isArray(value) ? value : NO_SESSIONS;
|
|
1393
|
+
}
|
|
1394
|
+
function readStates(snapshot) {
|
|
1395
|
+
const value = snapshot?.["sessionStates"];
|
|
1396
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
1397
|
+
}
|
|
1398
|
+
function readCurrentPath(snapshot) {
|
|
1399
|
+
const status = snapshot?.["status"];
|
|
1400
|
+
if (typeof status !== "object" || status === null) return null;
|
|
1401
|
+
const path = status["sessionPath"];
|
|
1402
|
+
return typeof path === "string" ? path : null;
|
|
1403
|
+
}
|
|
1404
|
+
function readLoading(snapshot) {
|
|
1405
|
+
return snapshot?.["sessionsLoading"] === true;
|
|
1406
|
+
}
|
|
1407
|
+
function readCwd(snapshot) {
|
|
1408
|
+
const status = snapshot?.["status"];
|
|
1409
|
+
if (typeof status !== "object" || status === null) return null;
|
|
1410
|
+
const value = status["cwd"];
|
|
1411
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
1412
|
+
}
|
|
1413
|
+
function readUsageTokens(snapshot) {
|
|
1414
|
+
const status = snapshot?.["status"];
|
|
1415
|
+
if (typeof status !== "object" || status === null) return null;
|
|
1416
|
+
const usage = status["usage"];
|
|
1417
|
+
if (typeof usage !== "object" || usage === null) return null;
|
|
1418
|
+
const input = usage["inputTokens"];
|
|
1419
|
+
const output = usage["outputTokens"];
|
|
1420
|
+
if (typeof input !== "number" || typeof output !== "number") return null;
|
|
1421
|
+
return input + output;
|
|
1422
|
+
}
|
|
1423
|
+
function AddWorkspaceButton({ onCreated }) {
|
|
1424
|
+
const native = ui$1.getHostNative();
|
|
1425
|
+
const pick = () => {
|
|
1426
|
+
if (!native.available) {
|
|
1427
|
+
ui$1.toastErr("添加工作区要用桌面版(浏览器里没有选目录的原生桥)");
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
void (async () => {
|
|
1431
|
+
try {
|
|
1432
|
+
const dir = await native.invoke("pickDirectory");
|
|
1433
|
+
if (typeof dir !== "string" || dir === "") return;
|
|
1434
|
+
onCreated(dir);
|
|
1435
|
+
} catch (reason) {
|
|
1436
|
+
ui$1.toastErr(`打开工作区失败:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
1437
|
+
}
|
|
1438
|
+
})();
|
|
1439
|
+
};
|
|
1440
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1441
|
+
"button",
|
|
1442
|
+
{
|
|
1443
|
+
type: "button",
|
|
1444
|
+
className: "icon-btn",
|
|
1445
|
+
"data-tip": "添加工作区(选择目录)",
|
|
1446
|
+
"aria-label": "添加工作区",
|
|
1447
|
+
onClick: pick,
|
|
1448
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconPlus, { size: 15 })
|
|
1449
|
+
}
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
function WorkspaceOpenGroup() {
|
|
1453
|
+
const cwd = ui$1.useHostSelector(readCwd);
|
|
1454
|
+
const native = ui$1.getHostNative();
|
|
1455
|
+
const [menuOpen, setMenuOpen] = react.useState(false);
|
|
1456
|
+
const open = (kind) => {
|
|
1457
|
+
setMenuOpen(false);
|
|
1458
|
+
if (cwd === null) {
|
|
1459
|
+
ui$1.toastErr("还没有工作目录(先开一个会话或添加工作区)");
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
if (!native.available) {
|
|
1463
|
+
ui$1.toastErr("这条能力来自桌面外壳的原生桥,浏览器里没有它");
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
void native.invoke("openWorkspace", [kind, cwd]).then((result) => {
|
|
1467
|
+
if (result !== null && typeof result === "object" && result.ok === false) {
|
|
1468
|
+
ui$1.toastErr(`打开失败:${result.error ?? "宿主没说什么原因"}`);
|
|
1469
|
+
}
|
|
1470
|
+
}).catch((reason) => {
|
|
1471
|
+
ui$1.toastErr(`打开失败:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
1472
|
+
});
|
|
1473
|
+
};
|
|
1474
|
+
const copyPath = () => {
|
|
1475
|
+
setMenuOpen(false);
|
|
1476
|
+
if (cwd === null) return;
|
|
1477
|
+
void navigator.clipboard.writeText(cwd).then(
|
|
1478
|
+
() => {
|
|
1479
|
+
ui$1.toastOk("工作区路径已复制");
|
|
1480
|
+
},
|
|
1481
|
+
() => {
|
|
1482
|
+
ui$1.toastErr("复制失败,请手动选中");
|
|
1483
|
+
}
|
|
1484
|
+
);
|
|
1485
|
+
};
|
|
1486
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ws-open", children: [
|
|
1487
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1488
|
+
"button",
|
|
1489
|
+
{
|
|
1490
|
+
type: "button",
|
|
1491
|
+
className: "ws-open-main",
|
|
1492
|
+
"data-tip": "在文件管理器中打开",
|
|
1493
|
+
"aria-label": "在文件管理器中打开",
|
|
1494
|
+
onClick: () => {
|
|
1495
|
+
open("explorer");
|
|
1496
|
+
},
|
|
1497
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconFolderOpen, { size: 15 })
|
|
1498
|
+
}
|
|
1499
|
+
),
|
|
1500
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1501
|
+
"button",
|
|
1502
|
+
{
|
|
1503
|
+
type: "button",
|
|
1504
|
+
className: `ws-open-caret${menuOpen ? " on" : ""}`,
|
|
1505
|
+
"data-tip": "更多打开方式",
|
|
1506
|
+
"aria-label": "更多打开方式",
|
|
1507
|
+
"aria-expanded": menuOpen,
|
|
1508
|
+
onClick: () => {
|
|
1509
|
+
setMenuOpen((current) => !current);
|
|
1510
|
+
},
|
|
1511
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 13 })
|
|
1512
|
+
}
|
|
1513
|
+
),
|
|
1514
|
+
menuOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1515
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1516
|
+
"div",
|
|
1517
|
+
{
|
|
1518
|
+
className: "menu-backdrop",
|
|
1519
|
+
onClick: () => {
|
|
1520
|
+
setMenuOpen(false);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
),
|
|
1524
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "row-menu ws-open-menu", role: "menu", children: [
|
|
1525
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1526
|
+
"button",
|
|
1527
|
+
{
|
|
1528
|
+
type: "button",
|
|
1529
|
+
className: "menu-item",
|
|
1530
|
+
onClick: () => {
|
|
1531
|
+
open("terminal");
|
|
1532
|
+
},
|
|
1533
|
+
children: [
|
|
1534
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconTerminal, { size: 14 }),
|
|
1535
|
+
" 在终端中打开"
|
|
1536
|
+
]
|
|
1537
|
+
}
|
|
1538
|
+
),
|
|
1539
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1540
|
+
"button",
|
|
1541
|
+
{
|
|
1542
|
+
type: "button",
|
|
1543
|
+
className: "menu-item",
|
|
1544
|
+
onClick: () => {
|
|
1545
|
+
open("explorer");
|
|
1546
|
+
},
|
|
1547
|
+
children: [
|
|
1548
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconFolderOpen, { size: 14 }),
|
|
1549
|
+
" 在文件管理器中打开"
|
|
1550
|
+
]
|
|
1551
|
+
}
|
|
1552
|
+
),
|
|
1553
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1554
|
+
"button",
|
|
1555
|
+
{
|
|
1556
|
+
type: "button",
|
|
1557
|
+
className: "menu-item",
|
|
1558
|
+
onClick: () => {
|
|
1559
|
+
open("vscode");
|
|
1560
|
+
},
|
|
1561
|
+
children: [
|
|
1562
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCode, { size: 14 }),
|
|
1563
|
+
" 在 VS Code 中打开"
|
|
1564
|
+
]
|
|
1565
|
+
}
|
|
1566
|
+
),
|
|
1567
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-sep" }),
|
|
1568
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "menu-item", onClick: copyPath, children: [
|
|
1569
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCopy, { size: 14 }),
|
|
1570
|
+
" 复制工作区路径"
|
|
1571
|
+
] })
|
|
1572
|
+
] })
|
|
1573
|
+
] }) : null
|
|
1574
|
+
] });
|
|
1575
|
+
}
|
|
1576
|
+
exports.default = ui;
|
|
1577
|
+
};
|