@dyyz1993/create-agent 2.1.0 → 2.1.2
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/package.json +5 -4
- package/src/__tests__/cli.test.ts +2 -0
- package/src/__tests__/copy.test.ts +110 -122
- package/src/__tests__/create-args.test.ts +113 -0
- package/src/__tests__/templates.test.ts +29 -3
- package/src/__tests__/update.test.ts +129 -0
- package/src/cli.ts +30 -32
- package/src/commands/create.ts +83 -24
- package/src/commands/update.ts +174 -0
- package/src/commands/workspace.ts +26 -6
- package/src/lib/copy.ts +233 -93
- package/src/lib/templates.ts +12 -0
- package/templates/agent/.husky/commit-msg +4 -0
- package/templates/agent/.husky/pre-commit +11 -0
- package/templates/agent/.husky/pre-push +6 -0
- package/templates/agent/.prettierignore +6 -0
- package/templates/agent/.prettierrc +9 -0
- package/templates/agent/CHANGELOG.md +15 -0
- package/templates/agent/commitlint.config.js +8 -0
- package/templates/agent/package.json +19 -4
- package/templates/agent/src/gateway/__tests__/ws-handler-token.test.ts +53 -39
- package/templates/agent/src/mainview/App.tsx +14 -12
- package/templates/agent/src/mainview/__tests__/hooks/use-rpc-init.test.ts +194 -190
- package/templates/agent/src/mainview/components/bash/BashPanel.tsx +210 -189
- package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +45 -20
- package/templates/agent/src/mainview/components/common/ThemeToggle.tsx +41 -21
- package/templates/agent/src/mainview/components/debug/DebugPanel.tsx +181 -114
- package/templates/agent/src/mainview/components/debug/__tests__/DebugPanel.test.tsx +80 -80
- package/templates/agent/src/mainview/components/diff/__tests__/DiffViewerPanel.test.tsx +61 -58
- package/templates/agent/src/mainview/components/feed/FeedPanel.tsx +43 -41
- package/templates/agent/src/mainview/components/file-preview/FilePreviewOverlay.tsx +69 -50
- package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +31 -18
- package/templates/agent/src/mainview/components/git/GitPanel.tsx +731 -490
- package/templates/agent/src/mainview/components/git/__tests__/GitPanel.test.tsx +157 -139
- package/templates/agent/src/mainview/components/layout/AppLayout.tsx +210 -161
- package/templates/agent/src/mainview/components/layout/__tests__/AppLayout.test.tsx +130 -122
- package/templates/agent/src/mainview/components/rules/RulesPanel.tsx +119 -109
- package/templates/agent/src/mainview/components/search/SearchPanel.tsx +123 -117
- package/templates/agent/src/mainview/components/search/__tests__/SearchPanel.test.tsx +64 -44
- package/templates/agent/src/mainview/components/sidebar/__tests__/PinButton.test.tsx +38 -38
- package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +40 -38
- package/templates/agent/src/mainview/components/todo/__tests__/TodoPanel.test.tsx +72 -72
- package/templates/agent/src/mainview/lib/i18n/locales/en.json +175 -155
- package/templates/agent/src/mainview/lib/i18n/locales/zh.json +173 -155
- package/templates/agent/src/mainview/stores/use-app-store.ts +96 -86
- package/templates/agent/src/mainview/stores/use-explorer-store.ts +292 -275
- package/templates/agent/src/mainview/types/index.ts +23 -22
- package/templates/agent/src/mainview/utils/file-icon.tsx +17 -21
- package/templates/agent/src/shared/handlers/chat.ts +53 -53
- package/templates/agent/src/shared/handlers/debug.ts +13 -3
- package/templates/browser-agent/.env.example +19 -0
- package/templates/browser-agent/.husky/commit-msg +4 -0
- package/templates/browser-agent/.husky/pre-commit +11 -0
- package/templates/browser-agent/.husky/pre-push +6 -0
- package/templates/browser-agent/.prettierignore +6 -0
- package/templates/browser-agent/.prettierrc +9 -0
- package/templates/browser-agent/AGENTS.md +396 -0
- package/templates/browser-agent/CHANGELOG.md +15 -0
- package/templates/browser-agent/LICENSE +21 -0
- package/templates/browser-agent/README.md +103 -0
- package/templates/browser-agent/commitlint.config.js +8 -0
- package/templates/browser-agent/electrobun.config.ts +27 -0
- package/templates/browser-agent/electron/main.js +46 -0
- package/templates/browser-agent/electron/preload.js +5 -0
- package/templates/browser-agent/electron-builder.json +40 -0
- package/templates/browser-agent/eslint.config.mjs +79 -0
- package/templates/browser-agent/llms.txt +24 -0
- package/templates/browser-agent/package.json +140 -0
- package/templates/browser-agent/postcss.config.js +6 -0
- package/templates/browser-agent/scripts/dev.ts +138 -0
- package/templates/browser-agent/src/__tests__/hybrid-mode.test.ts +126 -0
- package/templates/browser-agent/src/__tests__/server-config-security.test.ts +55 -0
- package/templates/browser-agent/src/__tests__/server-config.test.ts +59 -0
- package/templates/browser-agent/src/bun/index.ts +130 -0
- package/templates/browser-agent/src/bun/three.d.ts +1 -0
- package/templates/browser-agent/src/gateway/http-routes.ts +1 -0
- package/templates/browser-agent/src/gateway/ipc-transport.ts +68 -0
- package/templates/browser-agent/src/gateway/sse-transport.ts +221 -0
- package/templates/browser-agent/src/mainview/App.tsx +45 -0
- package/templates/browser-agent/src/mainview/__tests__/hooks/use-rpc-init.test.ts +202 -0
- package/templates/browser-agent/src/mainview/__tests__/hooks/use-sidebar-resize.test.ts +127 -0
- package/templates/browser-agent/src/mainview/__tests__/i18n/i18n.test.ts +49 -0
- package/templates/browser-agent/src/mainview/__tests__/setup.ts +40 -0
- package/templates/browser-agent/src/mainview/__tests__/stores/use-chat-store.test.ts +73 -0
- package/templates/browser-agent/src/mainview/__tests__/stores/use-sidebar-store.test.ts +61 -0
- package/templates/browser-agent/src/mainview/__tests__/theme-variables.test.ts +36 -0
- package/templates/browser-agent/src/mainview/components/assets/AssetsPanel.tsx +139 -0
- package/templates/browser-agent/src/mainview/components/chat/ChatPanel.tsx +219 -0
- package/templates/browser-agent/src/mainview/components/chat/CommandBar.tsx +184 -0
- package/templates/browser-agent/src/mainview/components/chat/MessageBubble.tsx +249 -0
- package/templates/browser-agent/src/mainview/components/chat/ToolPicker.tsx +115 -0
- package/templates/browser-agent/src/mainview/components/common/ErrorBoundary.tsx +1 -0
- package/templates/browser-agent/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
- package/templates/browser-agent/src/mainview/components/common/ThemeToggle.tsx +45 -0
- package/templates/browser-agent/src/mainview/components/common/__tests__/ErrorBoundary.test.tsx +74 -0
- package/templates/browser-agent/src/mainview/components/common/__tests__/LanguageSwitcher.test.tsx +44 -0
- package/templates/browser-agent/src/mainview/components/common/__tests__/ThemeToggle.test.tsx +41 -0
- package/templates/browser-agent/src/mainview/components/dev/NetworkPanel.tsx +155 -0
- package/templates/browser-agent/src/mainview/components/layout/AppLayout.tsx +311 -0
- package/templates/browser-agent/src/mainview/components/onboarding/SetupWizard.tsx +310 -0
- package/templates/browser-agent/src/mainview/components/process/ProcessPanel.tsx +329 -0
- package/templates/browser-agent/src/mainview/components/sidebar/SessionSidebar.tsx +122 -0
- package/templates/browser-agent/src/mainview/components/sidebar/SkillSidebar.tsx +115 -0
- package/templates/browser-agent/src/mainview/components/topbar/TopBar.tsx +350 -0
- package/templates/browser-agent/src/mainview/global.d.ts +13 -0
- package/templates/browser-agent/src/mainview/hooks/__tests__/use-breakpoint.test.ts +151 -0
- package/templates/browser-agent/src/mainview/hooks/use-agent-chat.ts +157 -0
- package/templates/browser-agent/src/mainview/hooks/use-breakpoint.ts +68 -0
- package/templates/browser-agent/src/mainview/hooks/use-rpc-init.ts +71 -0
- package/templates/browser-agent/src/mainview/hooks/use-sidebar-resize.ts +40 -0
- package/templates/browser-agent/src/mainview/index.css +71 -0
- package/templates/browser-agent/src/mainview/index.html +12 -0
- package/templates/browser-agent/src/mainview/lib/api-client.ts +397 -0
- package/templates/browser-agent/src/mainview/lib/i18n/index.ts +30 -0
- package/templates/browser-agent/src/mainview/lib/i18n/locales/en.json +130 -0
- package/templates/browser-agent/src/mainview/lib/i18n/locales/zh.json +128 -0
- package/templates/browser-agent/src/mainview/lib/network-bus.ts +92 -0
- package/templates/browser-agent/src/mainview/lib/rpc-cache.ts +94 -0
- package/templates/browser-agent/src/mainview/main.tsx +18 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-connection-store.test.ts +26 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-log-store.test.ts +28 -0
- package/templates/browser-agent/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
- package/templates/browser-agent/src/mainview/stores/message-batcher.ts +25 -0
- package/templates/browser-agent/src/mainview/stores/use-asset-store.ts +65 -0
- package/templates/browser-agent/src/mainview/stores/use-chat-store.ts +200 -0
- package/templates/browser-agent/src/mainview/stores/use-connection-store.ts +173 -0
- package/templates/browser-agent/src/mainview/stores/use-locale-store.ts +27 -0
- package/templates/browser-agent/src/mainview/stores/use-log-store.ts +16 -0
- package/templates/browser-agent/src/mainview/stores/use-network-panel-store.ts +18 -0
- package/templates/browser-agent/src/mainview/stores/use-record-store.ts +147 -0
- package/templates/browser-agent/src/mainview/stores/use-session-store.ts +151 -0
- package/templates/browser-agent/src/mainview/stores/use-sidebar-store.ts +161 -0
- package/templates/browser-agent/src/mainview/stores/use-theme-store.ts +46 -0
- package/templates/browser-agent/src/mainview/stores/use-view-store.ts +20 -0
- package/templates/browser-agent/src/mainview/types/index.ts +6 -0
- package/templates/browser-agent/src/server-config.ts +45 -0
- package/templates/browser-agent/src/server.ts +78 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/chat-handler.test.ts +77 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/file-handler.test.ts +100 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/system-handler.test.ts +55 -0
- package/templates/browser-agent/src/shared/handlers/__tests__/timer-handler.test.ts +77 -0
- package/templates/browser-agent/src/shared/handlers/browser.ts +596 -0
- package/templates/browser-agent/src/shared/handlers/chat.ts +213 -0
- package/templates/browser-agent/src/shared/handlers/file.ts +99 -0
- package/templates/browser-agent/src/shared/handlers/index.ts +7 -0
- package/templates/browser-agent/src/shared/handlers/session.ts +167 -0
- package/templates/browser-agent/src/shared/handlers/system.ts +27 -0
- package/templates/browser-agent/src/shared/handlers/timer.ts +34 -0
- package/templates/browser-agent/src/shared/http-routes.ts +437 -0
- package/templates/browser-agent/src/shared/lib/__tests__/logger.test.ts +92 -0
- package/templates/browser-agent/src/shared/lib/__tests__/path-security.test.ts +77 -0
- package/templates/browser-agent/src/shared/lib/__tests__/web-server.test.ts +203 -0
- package/templates/browser-agent/src/shared/lib/agent.ts +384 -0
- package/templates/browser-agent/src/shared/lib/cdp.ts +448 -0
- package/templates/browser-agent/src/shared/lib/generate.ts +111 -0
- package/templates/browser-agent/src/shared/lib/logger.ts +152 -0
- package/templates/browser-agent/src/shared/lib/mock-stream.ts +147 -0
- package/templates/browser-agent/src/shared/lib/path-security.ts +38 -0
- package/templates/browser-agent/src/shared/lib/port-registry.ts +103 -0
- package/templates/browser-agent/src/shared/lib/web-server.ts +127 -0
- package/templates/browser-agent/src/shared/lib/xhs-extract.ts +71 -0
- package/templates/browser-agent/src/shared/modules/browser.ts +86 -0
- package/templates/browser-agent/src/shared/modules/chat.ts +20 -0
- package/templates/browser-agent/src/shared/modules/file.ts +40 -0
- package/templates/browser-agent/src/shared/modules/session.ts +55 -0
- package/templates/browser-agent/src/shared/modules/system.ts +8 -0
- package/templates/browser-agent/src/shared/modules/timer.ts +11 -0
- package/templates/browser-agent/src/shared/register-all-handlers.ts +36 -0
- package/templates/browser-agent/src/shared/rpc-schema.ts +34 -0
- package/templates/browser-agent/tailwind.config.js +15 -0
- package/templates/browser-agent/tsconfig.ipc.json +14 -0
- package/templates/browser-agent/tsconfig.json +36 -0
- package/templates/browser-agent/vite.config.ts +3 -0
- package/templates/browser-agent/vitest.config.ts +3 -0
- package/templates/chat/.husky/commit-msg +4 -0
- package/templates/chat/.husky/pre-commit +11 -0
- package/templates/chat/.husky/pre-push +6 -0
- package/templates/chat/CHANGELOG.md +15 -0
- package/templates/chat/commitlint.config.js +8 -0
- package/templates/chat/package.json +19 -4
- package/templates/chat/src/mainview/__tests__/hooks/use-input-history.test.ts +125 -0
- package/templates/chat/src/mainview/__tests__/setup.ts +32 -29
- package/templates/chat/src/mainview/components/chat/ChatPanel.tsx +80 -55
- package/templates/chat/src/mainview/components/common/ThemeToggle.tsx +40 -20
- package/templates/chat/src/mainview/lib/i18n/locales/en.json +175 -155
- package/templates/chat/src/mainview/lib/i18n/locales/zh.json +173 -155
- package/templates/chat/src/shared/handlers/chat.ts +17 -19
- package/templates/chat/src/shared/handlers/debug.ts +12 -2
- package/templates/cowork/.env.example +8 -0
- package/templates/cowork/.prettierignore +6 -0
- package/templates/cowork/.prettierrc +9 -0
- package/templates/cowork/AGENTS.md +236 -0
- package/templates/cowork/CHANGELOG.md +15 -0
- package/templates/cowork/LICENSE +21 -0
- package/templates/cowork/README.md +103 -0
- package/templates/cowork/commitlint.config.js +8 -0
- package/templates/cowork/docs/CODE-VIEW-PLAN.md +637 -0
- package/templates/cowork/docs/CODE-VIEW-V2.md +196 -0
- package/templates/cowork/docs/CODE-VIEW-V4.md +150 -0
- package/templates/cowork/electrobun.config.ts +27 -0
- package/templates/cowork/eslint.config.mjs +79 -0
- package/templates/cowork/llms.txt +24 -0
- package/templates/cowork/package.json +87 -0
- package/templates/cowork/postcss.config.js +6 -0
- package/templates/cowork/scripts/dev.ts +138 -0
- package/templates/cowork/src/__tests__/hybrid-mode.test.ts +126 -0
- package/templates/cowork/src/__tests__/server-config-security.test.ts +55 -0
- package/templates/cowork/src/__tests__/server-config.test.ts +59 -0
- package/templates/cowork/src/bun/index.ts +130 -0
- package/templates/cowork/src/bun/three.d.ts +1 -0
- package/templates/cowork/src/gateway/http-routes.ts +1 -0
- package/templates/cowork/src/gateway/ipc-transport.ts +68 -0
- package/templates/cowork/src/gateway/sse-transport.ts +231 -0
- package/templates/cowork/src/mainview/App.tsx +45 -0
- package/templates/cowork/src/mainview/__tests__/hooks/use-rpc-init.test.ts +202 -0
- package/templates/cowork/src/mainview/__tests__/hooks/use-sidebar-resize.test.ts +127 -0
- package/templates/cowork/src/mainview/__tests__/i18n/i18n.test.ts +49 -0
- package/templates/cowork/src/mainview/__tests__/setup.ts +40 -0
- package/templates/cowork/src/mainview/__tests__/stores/use-chat-store.test.ts +73 -0
- package/templates/cowork/src/mainview/__tests__/stores/use-sidebar-store.test.ts +61 -0
- package/templates/cowork/src/mainview/__tests__/theme-variables.test.ts +36 -0
- package/templates/cowork/src/mainview/components/chat/TaskChat.tsx +311 -0
- package/templates/cowork/src/mainview/components/chat/__tests__/localhost-links.test.ts +76 -0
- package/templates/cowork/src/mainview/components/common/ErrorBoundary.tsx +1 -0
- package/templates/cowork/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
- package/templates/cowork/src/mainview/components/common/ThemeToggle.tsx +45 -0
- package/templates/cowork/src/mainview/components/common/__tests__/ErrorBoundary.test.tsx +74 -0
- package/templates/cowork/src/mainview/components/common/__tests__/LanguageSwitcher.test.tsx +44 -0
- package/templates/cowork/src/mainview/components/common/__tests__/ThemeToggle.test.tsx +41 -0
- package/templates/cowork/src/mainview/components/dev/NetworkPanel.tsx +155 -0
- package/templates/cowork/src/mainview/components/layout/AppLayout.tsx +216 -0
- package/templates/cowork/src/mainview/components/right/ArtifactsPanel.tsx +54 -0
- package/templates/cowork/src/mainview/components/right/ContextPanel.tsx +133 -0
- package/templates/cowork/src/mainview/components/right/ElementPicker.tsx +206 -0
- package/templates/cowork/src/mainview/components/right/PreviewBlock.tsx +155 -0
- package/templates/cowork/src/mainview/components/right/ProgressPanel.tsx +85 -0
- package/templates/cowork/src/mainview/components/sidebar/TaskSidebar.tsx +211 -0
- package/templates/cowork/src/mainview/components/topbar/TopBar.tsx +86 -0
- package/templates/cowork/src/mainview/global.d.ts +13 -0
- package/templates/cowork/src/mainview/hooks/__tests__/use-breakpoint.test.ts +123 -0
- package/templates/cowork/src/mainview/hooks/use-breakpoint.ts +53 -0
- package/templates/cowork/src/mainview/hooks/use-rpc-init.ts +26 -0
- package/templates/cowork/src/mainview/hooks/use-sidebar-resize.ts +40 -0
- package/templates/cowork/src/mainview/index.css +89 -0
- package/templates/cowork/src/mainview/index.html +12 -0
- package/templates/cowork/src/mainview/lib/api-client.ts +404 -0
- package/templates/cowork/src/mainview/lib/i18n/index.ts +30 -0
- package/templates/cowork/src/mainview/lib/i18n/locales/en.json +130 -0
- package/templates/cowork/src/mainview/lib/i18n/locales/zh.json +128 -0
- package/templates/cowork/src/mainview/lib/network-bus.ts +92 -0
- package/templates/cowork/src/mainview/lib/rpc-cache.ts +94 -0
- package/templates/cowork/src/mainview/main.tsx +18 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-connection-store.test.ts +26 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-log-store.test.ts +28 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-preview-store.test.ts +193 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-sidebar-store.test.ts +81 -0
- package/templates/cowork/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
- package/templates/cowork/src/mainview/stores/message-batcher.ts +25 -0
- package/templates/cowork/src/mainview/stores/use-chat-store.ts +198 -0
- package/templates/cowork/src/mainview/stores/use-connection-store.ts +168 -0
- package/templates/cowork/src/mainview/stores/use-context-store.ts +68 -0
- package/templates/cowork/src/mainview/stores/use-locale-store.ts +27 -0
- package/templates/cowork/src/mainview/stores/use-log-store.ts +16 -0
- package/templates/cowork/src/mainview/stores/use-network-panel-store.ts +18 -0
- package/templates/cowork/src/mainview/stores/use-output-store.ts +47 -0
- package/templates/cowork/src/mainview/stores/use-preview-store.ts +97 -0
- package/templates/cowork/src/mainview/stores/use-sidebar-store.ts +272 -0
- package/templates/cowork/src/mainview/stores/use-task-store.ts +86 -0
- package/templates/cowork/src/mainview/stores/use-theme-store.ts +46 -0
- package/templates/cowork/src/mainview/stores/use-view-store.ts +29 -0
- package/templates/cowork/src/mainview/types/index.ts +6 -0
- package/templates/cowork/src/server-config.ts +44 -0
- package/templates/cowork/src/server.ts +78 -0
- package/templates/cowork/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
- package/templates/cowork/src/shared/handlers/__tests__/chat-handler.test.ts +77 -0
- package/templates/cowork/src/shared/handlers/__tests__/file-handler.test.ts +100 -0
- package/templates/cowork/src/shared/handlers/__tests__/preview-handler.test.ts +172 -0
- package/templates/cowork/src/shared/handlers/__tests__/system-handler.test.ts +55 -0
- package/templates/cowork/src/shared/handlers/__tests__/timer-handler.test.ts +77 -0
- package/templates/cowork/src/shared/handlers/chat.ts +213 -0
- package/templates/cowork/src/shared/handlers/context.ts +72 -0
- package/templates/cowork/src/shared/handlers/file.ts +99 -0
- package/templates/cowork/src/shared/handlers/index.ts +9 -0
- package/templates/cowork/src/shared/handlers/output.ts +59 -0
- package/templates/cowork/src/shared/handlers/preview.ts +81 -0
- package/templates/cowork/src/shared/handlers/system.ts +27 -0
- package/templates/cowork/src/shared/handlers/task.ts +101 -0
- package/templates/cowork/src/shared/handlers/timer.ts +34 -0
- package/templates/cowork/src/shared/http-routes.ts +444 -0
- package/templates/cowork/src/shared/lib/__tests__/logger.test.ts +92 -0
- package/templates/cowork/src/shared/lib/__tests__/path-security.test.ts +77 -0
- package/templates/cowork/src/shared/lib/__tests__/web-server.test.ts +203 -0
- package/templates/cowork/src/shared/lib/logger.ts +152 -0
- package/templates/cowork/src/shared/lib/path-security.ts +38 -0
- package/templates/cowork/src/shared/lib/port-registry.ts +103 -0
- package/templates/cowork/src/shared/lib/web-server.ts +127 -0
- package/templates/cowork/src/shared/modules/chat.ts +20 -0
- package/templates/cowork/src/shared/modules/context.ts +32 -0
- package/templates/cowork/src/shared/modules/file.ts +40 -0
- package/templates/cowork/src/shared/modules/output.ts +20 -0
- package/templates/cowork/src/shared/modules/preview.ts +44 -0
- package/templates/cowork/src/shared/modules/system.ts +8 -0
- package/templates/cowork/src/shared/modules/task.ts +31 -0
- package/templates/cowork/src/shared/modules/timer.ts +11 -0
- package/templates/cowork/src/shared/register-all-handlers.ts +36 -0
- package/templates/cowork/src/shared/rpc-schema.ts +38 -0
- package/templates/cowork/tailwind.config.js +15 -0
- package/templates/cowork/test-upload.txt +0 -0
- package/templates/cowork/tsconfig.ipc.json +14 -0
- package/templates/cowork/tsconfig.json +36 -0
- package/templates/cowork/vite.config.ts +3 -0
- package/templates/cowork/vitest.config.ts +3 -0
- package/templates/general/.husky/commit-msg +4 -0
- package/templates/general/.husky/pre-commit +11 -0
- package/templates/general/.husky/pre-push +6 -0
- package/templates/general/CHANGELOG.md +15 -0
- package/templates/general/commitlint.config.js +8 -0
- package/templates/general/package.json +19 -4
- package/templates/general/src/mainview/__tests__/hooks/use-input-history.test.ts +125 -0
- package/templates/general/src/mainview/__tests__/setup.ts +32 -29
- package/templates/general/src/mainview/components/chat/ChatPanel.tsx +80 -55
- package/templates/general/src/mainview/components/common/ThemeToggle.tsx +40 -20
- package/templates/general/src/mainview/components/debug/DebugPanel.tsx +170 -156
- package/templates/general/src/mainview/components/debug/__tests__/DebugPanel.test.tsx +169 -0
- package/templates/general/src/mainview/components/explorer/ConfirmDialog.tsx +42 -42
- package/templates/general/src/mainview/components/explorer/ContextMenu.tsx +72 -67
- package/templates/general/src/mainview/components/feed/FeedPanel.tsx +7 -5
- package/templates/general/src/mainview/components/file-preview/FilePreviewOverlay.tsx +64 -45
- package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +24 -7
- package/templates/general/src/mainview/components/git/GitPanel.tsx +700 -473
- package/templates/general/src/mainview/components/layout/AppLayout.tsx +123 -114
- package/templates/general/src/mainview/components/search/SearchPanel.tsx +15 -19
- package/templates/general/src/mainview/lib/i18n/locales/en.json +175 -155
- package/templates/general/src/mainview/lib/i18n/locales/zh.json +173 -155
- package/templates/general/src/mainview/stores/__tests__/use-explorer-store.test.ts +259 -0
- package/templates/general/src/mainview/stores/__tests__/use-feed-store.test.ts +160 -0
- package/templates/general/src/mainview/stores/__tests__/use-git-store.test.ts +313 -0
- package/templates/general/src/mainview/stores/__tests__/use-notification-store.test.ts +115 -0
- package/templates/general/src/mainview/stores/__tests__/use-sidebar-store.test.ts +120 -0
- package/templates/general/src/mainview/stores/use-explorer-store.ts +277 -260
- package/templates/general/src/mainview/types/index.ts +21 -20
- package/templates/general/src/shared/handlers/chat.ts +1 -1
- package/templates/general/src/shared/handlers/debug.ts +12 -2
- package/templates/shared/components/ErrorBoundary.tsx +0 -1
- package/templates/shared/vite-base.config.ts +8 -7
- /package/templates/{shared → browser-agent}/test-upload.txt +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
vi.mock("../../../lib/i18n", () => ({
|
|
6
|
+
default: {
|
|
7
|
+
isInitialized: true,
|
|
8
|
+
language: "en",
|
|
9
|
+
changeLanguage: vi.fn(),
|
|
10
|
+
t: (key: string) => key,
|
|
11
|
+
getResource: vi.fn(),
|
|
12
|
+
},
|
|
13
|
+
supportedLocales: ["en", "zh"],
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
vi.mock("react-i18next", () => ({
|
|
17
|
+
useTranslation: () => ({
|
|
18
|
+
t: (key: string) => key,
|
|
19
|
+
i18n: { language: "en", changeLanguage: vi.fn() },
|
|
20
|
+
}),
|
|
21
|
+
initReactI18next: { type: "3rdParty", init: vi.fn() },
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
describe("ErrorBoundary", () => {
|
|
25
|
+
it("should render children when no error", async () => {
|
|
26
|
+
const { ErrorBoundary } = await import("../ErrorBoundary");
|
|
27
|
+
render(
|
|
28
|
+
<ErrorBoundary>
|
|
29
|
+
<div>Normal content</div>
|
|
30
|
+
</ErrorBoundary>
|
|
31
|
+
);
|
|
32
|
+
expect(screen.getByText("Normal content")).toBeDefined();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should render fallback UI when child throws", async () => {
|
|
36
|
+
const { ErrorBoundary } = await import("../ErrorBoundary");
|
|
37
|
+
|
|
38
|
+
const ThrowingComponent = () => {
|
|
39
|
+
throw new Error("Test error");
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const spy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
43
|
+
|
|
44
|
+
render(
|
|
45
|
+
<ErrorBoundary>
|
|
46
|
+
<ThrowingComponent />
|
|
47
|
+
</ErrorBoundary>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(screen.getByText(/something went wrong/i)).toBeDefined();
|
|
51
|
+
|
|
52
|
+
spy.mockRestore();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should show retry button in error state", async () => {
|
|
56
|
+
const { ErrorBoundary } = await import("../ErrorBoundary");
|
|
57
|
+
|
|
58
|
+
const ThrowingComponent = () => {
|
|
59
|
+
throw new Error("Test error");
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const spy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
63
|
+
|
|
64
|
+
render(
|
|
65
|
+
<ErrorBoundary>
|
|
66
|
+
<ThrowingComponent />
|
|
67
|
+
</ErrorBoundary>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(screen.getByRole("button", { name: /retry/i })).toBeDefined();
|
|
71
|
+
|
|
72
|
+
spy.mockRestore();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import { render, screen, cleanup } from "@testing-library/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
const mockSetLocale = vi.fn();
|
|
6
|
+
|
|
7
|
+
vi.mock("../../stores/use-locale-store", () => ({
|
|
8
|
+
useLocaleStore: (selector: (s: any) => any) =>
|
|
9
|
+
selector({ locale: "en", setLocale: mockSetLocale }),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock("react-i18next", () => ({
|
|
13
|
+
useTranslation: () => ({ t: (key: string) => key }),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
describe("LanguageSwitcher", () => {
|
|
17
|
+
afterEach(cleanup);
|
|
18
|
+
|
|
19
|
+
it("should render a button", async () => {
|
|
20
|
+
const { LanguageSwitcher } = await import("../LanguageSwitcher");
|
|
21
|
+
render(<LanguageSwitcher />);
|
|
22
|
+
expect(screen.getByRole("button")).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should show '中' when locale is en", async () => {
|
|
26
|
+
const { LanguageSwitcher } = await import("../LanguageSwitcher");
|
|
27
|
+
render(<LanguageSwitcher />);
|
|
28
|
+
expect(screen.getByText("中")).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should have title 切换到中文 for en locale", async () => {
|
|
32
|
+
const { LanguageSwitcher } = await import("../LanguageSwitcher");
|
|
33
|
+
render(<LanguageSwitcher />);
|
|
34
|
+
expect(screen.getByRole("button")).toHaveAttribute("title", "切换到中文");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should display locale-specific text content", async () => {
|
|
38
|
+
const { LanguageSwitcher } = await import("../LanguageSwitcher");
|
|
39
|
+
render(<LanguageSwitcher />);
|
|
40
|
+
const button = screen.getByRole("button");
|
|
41
|
+
expect(button.textContent).toBe("中");
|
|
42
|
+
expect(button.className).toContain("rounded");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import { render, screen, cleanup } from "@testing-library/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
const mockToggle = vi.fn();
|
|
6
|
+
|
|
7
|
+
vi.mock("../../stores/use-theme-store", () => ({
|
|
8
|
+
useThemeStore: (selector: (s: any) => any) =>
|
|
9
|
+
selector({ theme: "dark", toggleTheme: mockToggle }),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
describe("ThemeToggle", () => {
|
|
13
|
+
afterEach(cleanup);
|
|
14
|
+
|
|
15
|
+
it("should render a button", async () => {
|
|
16
|
+
const { ThemeToggle } = await import("../ThemeToggle");
|
|
17
|
+
render(<ThemeToggle />);
|
|
18
|
+
expect(screen.getByRole("button")).toBeInTheDocument();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should show sun icon for dark theme", async () => {
|
|
22
|
+
const { ThemeToggle } = await import("../ThemeToggle");
|
|
23
|
+
const { container } = render(<ThemeToggle />);
|
|
24
|
+
const svg = container.querySelector("svg");
|
|
25
|
+
expect(svg).toBeInTheDocument();
|
|
26
|
+
expect(svg!.getAttribute("class")).toContain("text-yellow-400");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should have title Switch to light mode for dark theme", async () => {
|
|
30
|
+
const { ThemeToggle } = await import("../ThemeToggle");
|
|
31
|
+
render(<ThemeToggle />);
|
|
32
|
+
expect(screen.getByRole("button")).toHaveAttribute("title", "Switch to light mode");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should render SVG element inside button", async () => {
|
|
36
|
+
const { ThemeToggle } = await import("../ThemeToggle");
|
|
37
|
+
const { container } = render(<ThemeToggle />);
|
|
38
|
+
const button = container.querySelector("button");
|
|
39
|
+
expect(button!.querySelector("svg")).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Panel — live RPC/SSE communication feed.
|
|
3
|
+
*
|
|
4
|
+
* - NetworkToggleButton: goes in the TopBar (icon with activity badge).
|
|
5
|
+
* - NetworkDrawer: rendered in AppLayout, shows the live log feed.
|
|
6
|
+
*
|
|
7
|
+
* Data comes from the networkBus (populated by api-client). Solves the
|
|
8
|
+
* "I can't see any network activity" problem with the old silent WebSocket.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useState, useEffect, useRef } from "react";
|
|
12
|
+
import { Activity, ChevronDown, Trash2 } from "lucide-react";
|
|
13
|
+
import { networkBus, type NetworkLogEntry } from "../../lib/network-bus";
|
|
14
|
+
import { useNetworkPanelStore } from "../../stores/use-network-panel-store";
|
|
15
|
+
|
|
16
|
+
const KIND_STYLES: Record<NetworkLogEntry["kind"], { color: string; icon: string }> = {
|
|
17
|
+
request: { color: "var(--color-text-accent)", icon: "→" },
|
|
18
|
+
response: { color: "var(--color-text-success)", icon: "←" },
|
|
19
|
+
event: { color: "var(--color-text-secondary)", icon: "⚡" },
|
|
20
|
+
status: { color: "var(--color-text-tertiary)", icon: "•" },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function formatTime(ts: number): string {
|
|
24
|
+
const d = new Date(ts);
|
|
25
|
+
return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}:${String(d.getSeconds()).padStart(2, "0")}.${String(d.getMilliseconds()).padStart(3, "0").slice(0, 2)}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Toggle button — place in TopBar */
|
|
29
|
+
export function NetworkToggleButton() {
|
|
30
|
+
const open = useNetworkPanelStore((s) => s.open);
|
|
31
|
+
const toggle = useNetworkPanelStore((s) => s.toggle);
|
|
32
|
+
const [count, setCount] = useState(0);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setCount(networkBus.getEntries().length);
|
|
36
|
+
const unsub = networkBus.subscribe(() => {
|
|
37
|
+
setCount((c) => c + 1);
|
|
38
|
+
});
|
|
39
|
+
return unsub;
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<button
|
|
44
|
+
onClick={toggle}
|
|
45
|
+
title="网络通讯面板"
|
|
46
|
+
className={`relative text-[var(--color-text-placeholder)] hover:text-[var(--color-text-primary)] transition-colors p-1 rounded hover:bg-[var(--color-bg-hover)] ${
|
|
47
|
+
open ? "text-[var(--color-text-accent)] bg-[var(--color-bg-hover)]" : ""
|
|
48
|
+
}`}
|
|
49
|
+
>
|
|
50
|
+
<Activity className="w-4 h-4" />
|
|
51
|
+
{count > 0 && !open && (
|
|
52
|
+
<span className="absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-[var(--color-accent)] animate-pulse" />
|
|
53
|
+
)}
|
|
54
|
+
</button>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Drawer — place in AppLayout bottom */
|
|
59
|
+
export function NetworkDrawer() {
|
|
60
|
+
const open = useNetworkPanelStore((s) => s.open);
|
|
61
|
+
const setOpen = useNetworkPanelStore((s) => s.setOpen);
|
|
62
|
+
const [entries, setEntries] = useState<NetworkLogEntry[]>([]);
|
|
63
|
+
const scrollRef = useRef<HTMLDivElement>(null);
|
|
64
|
+
const autoScroll = useRef(true);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
setEntries(networkBus.getEntries());
|
|
68
|
+
const unsub = networkBus.subscribe((entry) => {
|
|
69
|
+
setEntries((prev) => [...prev.slice(-199), entry]);
|
|
70
|
+
});
|
|
71
|
+
return unsub;
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!open || !autoScroll.current || !scrollRef.current) return;
|
|
76
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
77
|
+
}, [entries, open]);
|
|
78
|
+
|
|
79
|
+
const handleScroll = (): void => {
|
|
80
|
+
if (!scrollRef.current) return;
|
|
81
|
+
const el = scrollRef.current;
|
|
82
|
+
autoScroll.current = el.scrollHeight - el.scrollTop - el.clientHeight < 40;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (!open) return null;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="h-56 bg-[var(--color-bg-sidebar)] border-t border-[var(--color-border-primary)] flex flex-col z-30 shadow-lg flex-shrink-0">
|
|
89
|
+
{/* Header */}
|
|
90
|
+
<div className="flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-border-primary)] bg-[var(--color-bg-secondary)]">
|
|
91
|
+
<div className="flex items-center gap-2 text-xs font-medium">
|
|
92
|
+
<Activity className="w-3 h-3 text-[var(--color-text-accent)]" />
|
|
93
|
+
<span>网络通讯 ({entries.length})</span>
|
|
94
|
+
<span className="text-[var(--color-text-tertiary)] font-normal ml-2">
|
|
95
|
+
POST /api/rpc · SSE /api/events
|
|
96
|
+
</span>
|
|
97
|
+
</div>
|
|
98
|
+
<div className="flex items-center gap-1">
|
|
99
|
+
<button
|
|
100
|
+
onClick={() => setEntries([])}
|
|
101
|
+
title="清空"
|
|
102
|
+
className="text-[var(--color-text-placeholder)] hover:text-[var(--color-text-error)] p-1"
|
|
103
|
+
>
|
|
104
|
+
<Trash2 className="w-3 h-3" />
|
|
105
|
+
</button>
|
|
106
|
+
<button
|
|
107
|
+
onClick={() => setOpen(false)}
|
|
108
|
+
title="收起"
|
|
109
|
+
className="text-[var(--color-text-placeholder)] hover:text-[var(--color-text-primary)] p-1"
|
|
110
|
+
>
|
|
111
|
+
<ChevronDown className="w-3 h-3" />
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
{/* Entries */}
|
|
117
|
+
<div
|
|
118
|
+
ref={scrollRef}
|
|
119
|
+
onScroll={handleScroll}
|
|
120
|
+
className="flex-1 overflow-auto font-mono text-[11px] leading-relaxed"
|
|
121
|
+
>
|
|
122
|
+
{entries.length === 0 ? (
|
|
123
|
+
<div className="text-center text-[var(--color-text-tertiary)] py-8">
|
|
124
|
+
等待通讯…发送消息后会在这里看到 RPC 请求和 SSE 事件
|
|
125
|
+
</div>
|
|
126
|
+
) : (
|
|
127
|
+
entries.map((entry) => {
|
|
128
|
+
const style = KIND_STYLES[entry.kind];
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
key={entry.id}
|
|
132
|
+
className="flex items-start gap-2 px-3 py-0.5 hover:bg-[var(--color-bg-hover)] border-b border-[var(--color-border-secondary)]"
|
|
133
|
+
>
|
|
134
|
+
<span className="text-[var(--color-text-tertiary)] flex-shrink-0">
|
|
135
|
+
{formatTime(entry.time)}
|
|
136
|
+
</span>
|
|
137
|
+
<span style={{ color: style.color }} className="flex-shrink-0 w-4">
|
|
138
|
+
{style.icon}
|
|
139
|
+
</span>
|
|
140
|
+
<span className="text-[var(--color-text-primary)] break-all">
|
|
141
|
+
{entry.label}
|
|
142
|
+
{entry.detail && (
|
|
143
|
+
<span className="text-[var(--color-text-tertiary)] ml-1">
|
|
144
|
+
{entry.detail}
|
|
145
|
+
</span>
|
|
146
|
+
)}
|
|
147
|
+
</span>
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
})
|
|
151
|
+
)}
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cowork — 响应式三栏布局
|
|
3
|
+
*
|
|
4
|
+
* 核心设计:
|
|
5
|
+
* - 中间区域永远是聊天内容(所有 Tab 共享)
|
|
6
|
+
* - 左栏:任务列表(三态折叠 full/icon/hidden)
|
|
7
|
+
* - 右栏:点击聊天中的 localhost 链接后自动展开浏览器预览(~40%);
|
|
8
|
+
* 未预览时,按 Tab 切换内容(Cowork=Progress+Artifacts+Context / Code=Preview)
|
|
9
|
+
*/
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import { PanelLeftClose } from 'lucide-react';
|
|
12
|
+
import { TopBar } from '../topbar/TopBar';
|
|
13
|
+
import { TaskSidebar } from '../sidebar/TaskSidebar';
|
|
14
|
+
import { TaskChat } from '../chat/TaskChat';
|
|
15
|
+
import { ProgressPanel } from '../right/ProgressPanel';
|
|
16
|
+
import { ArtifactsPanel } from '../right/ArtifactsPanel';
|
|
17
|
+
import { ContextPanel } from '../right/ContextPanel';
|
|
18
|
+
import { PreviewBlock } from '../right/PreviewBlock';
|
|
19
|
+
import { NetworkDrawer } from '../dev/NetworkPanel';
|
|
20
|
+
import { useSidebarStore, SIDEBAR_ICON_WIDTH } from '../../stores/use-sidebar-store';
|
|
21
|
+
import { useRightPanelStore } from '../../stores/use-sidebar-store';
|
|
22
|
+
import { useViewStore } from '../../stores/use-view-store';
|
|
23
|
+
|
|
24
|
+
interface AppLayoutProps {
|
|
25
|
+
sidebarWidth: number;
|
|
26
|
+
handleResizeStart: (e: React.MouseEvent) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function AppLayout({ sidebarWidth, handleResizeStart }: AppLayoutProps) {
|
|
30
|
+
useTranslation();
|
|
31
|
+
|
|
32
|
+
// 左栏状态
|
|
33
|
+
const sbBreakpoint = useSidebarStore((s) => s.breakpoint);
|
|
34
|
+
const sbSidebarMode = useSidebarStore((s) => s.sidebarMode);
|
|
35
|
+
const sbDrawerOpen = useSidebarStore((s) => s.drawerOpen);
|
|
36
|
+
const sbSetDrawerOpen = useSidebarStore((s) => s.setDrawerOpen);
|
|
37
|
+
|
|
38
|
+
// 右栏状态
|
|
39
|
+
const rpWidth = useRightPanelStore((s) => s.width);
|
|
40
|
+
const rpMode = useRightPanelStore((s) => s.mode);
|
|
41
|
+
const rpSetWidth = useRightPanelStore((s) => s.setWidth);
|
|
42
|
+
const rpExpandedForPreview = useRightPanelStore((s) => s.expandedForPreview);
|
|
43
|
+
const rpClosePreview = useRightPanelStore((s) => s.closePreview);
|
|
44
|
+
|
|
45
|
+
// 视图 Tab
|
|
46
|
+
const centerTab = useViewStore((s) => s.centerTab);
|
|
47
|
+
|
|
48
|
+
// 左栏派生
|
|
49
|
+
const sidebarInLayout =
|
|
50
|
+
(sbSidebarMode === 'full' || sbSidebarMode === 'icon') && sbBreakpoint !== 'mobile';
|
|
51
|
+
const sidebarDrawer = sbDrawerOpen && !sidebarInLayout;
|
|
52
|
+
const effectiveSidebarWidth = sbSidebarMode === 'icon' ? SIDEBAR_ICON_WIDTH : sidebarWidth;
|
|
53
|
+
const isSidebarCollapsed = sbSidebarMode === 'icon';
|
|
54
|
+
|
|
55
|
+
// 右栏可见性:
|
|
56
|
+
// - 预览态(点击聊天链接)优先级最高,所有 Tab 下都展开
|
|
57
|
+
// - 否则 Chat 自动隐藏,其他 Tab 看 rpMode
|
|
58
|
+
const rightPanelVisible =
|
|
59
|
+
rpExpandedForPreview ||
|
|
60
|
+
(rpMode === 'full' && centerTab !== 'chat' && sbBreakpoint !== 'mobile');
|
|
61
|
+
|
|
62
|
+
// 右栏拖拽
|
|
63
|
+
const handleRightResizeStart = (e: React.MouseEvent) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
const startX = e.clientX;
|
|
66
|
+
const startWidth = rpWidth;
|
|
67
|
+
document.body.style.cursor = 'col-resize';
|
|
68
|
+
document.body.style.userSelect = 'none';
|
|
69
|
+
|
|
70
|
+
const onMove = (ev: MouseEvent) => {
|
|
71
|
+
// 右栏在右侧,拖拽方向相反(往左拖 = 加宽)
|
|
72
|
+
const delta = startX - ev.clientX;
|
|
73
|
+
rpSetWidth(startWidth + delta);
|
|
74
|
+
};
|
|
75
|
+
const onUp = () => {
|
|
76
|
+
document.body.style.cursor = '';
|
|
77
|
+
document.body.style.userSelect = '';
|
|
78
|
+
window.removeEventListener('mousemove', onMove);
|
|
79
|
+
window.removeEventListener('mouseup', onUp);
|
|
80
|
+
};
|
|
81
|
+
window.addEventListener('mousemove', onMove);
|
|
82
|
+
window.addEventListener('mouseup', onUp);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="h-screen bg-[var(--color-bg-primary)] text-[var(--color-text-primary)] flex flex-col overflow-hidden">
|
|
87
|
+
<TopBar />
|
|
88
|
+
|
|
89
|
+
<div className="flex-1 flex overflow-hidden relative">
|
|
90
|
+
{/* ── 左:任务侧栏 ── */}
|
|
91
|
+
{sidebarInLayout ? (
|
|
92
|
+
<div
|
|
93
|
+
className="sidebar-container bg-[var(--color-bg-sidebar)] border-r border-[var(--color-border-primary)] flex flex-col flex-shrink-0 overflow-hidden relative"
|
|
94
|
+
style={{ width: effectiveSidebarWidth }}
|
|
95
|
+
>
|
|
96
|
+
<SidebarInner handleResizeStart={handleResizeStart} isCollapsed={isSidebarCollapsed} />
|
|
97
|
+
</div>
|
|
98
|
+
) : sidebarDrawer ? (
|
|
99
|
+
<>
|
|
100
|
+
<div
|
|
101
|
+
className="absolute inset-0 bg-black/40 z-20"
|
|
102
|
+
onClick={() => sbSetDrawerOpen(false)}
|
|
103
|
+
/>
|
|
104
|
+
<div
|
|
105
|
+
className="absolute top-0 left-0 bottom-0 bg-[var(--color-bg-sidebar)] border-r border-[var(--color-border-primary)] flex flex-col z-30 shadow-xl"
|
|
106
|
+
style={{ width: sidebarWidth }}
|
|
107
|
+
>
|
|
108
|
+
<SidebarInner isCollapsed={false} showClose onClose={() => sbSetDrawerOpen(false)} />
|
|
109
|
+
</div>
|
|
110
|
+
</>
|
|
111
|
+
) : null}
|
|
112
|
+
|
|
113
|
+
{/* ── 中:聊天(所有 Tab 共享) ── */}
|
|
114
|
+
<div className="flex-1 flex flex-col overflow-hidden min-w-0">
|
|
115
|
+
<TaskChat />
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
{/* ── 右:预览态优先,否则按 Tab 切换 ── */}
|
|
119
|
+
{rightPanelVisible && (
|
|
120
|
+
<div
|
|
121
|
+
className="bg-[var(--color-bg-panel)] border-l border-[var(--color-border-primary)] flex flex-col flex-shrink-0 overflow-hidden relative"
|
|
122
|
+
style={{ width: rpWidth }}
|
|
123
|
+
>
|
|
124
|
+
{/* 预览态:点击聊天链接触发,PreviewBlock 自带标题栏+关闭(onClose=closePreview) */}
|
|
125
|
+
{rpExpandedForPreview ? (
|
|
126
|
+
<div className="flex-1 flex flex-col overflow-hidden">
|
|
127
|
+
<PreviewBlock onClose={rpClosePreview} />
|
|
128
|
+
</div>
|
|
129
|
+
) : (
|
|
130
|
+
<>
|
|
131
|
+
{centerTab === 'cowork' && (
|
|
132
|
+
<div className="flex-1 overflow-auto">
|
|
133
|
+
<ProgressPanel />
|
|
134
|
+
<ArtifactsPanel />
|
|
135
|
+
<ContextPanel />
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
138
|
+
{centerTab === 'code' && (
|
|
139
|
+
<div className="flex-1 flex flex-col overflow-hidden">
|
|
140
|
+
<PreviewBlock />
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
143
|
+
</>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
{/* 右栏拖拽条 */}
|
|
147
|
+
<div
|
|
148
|
+
className="absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-[var(--color-accent)]/50 active:bg-[var(--color-accent)] transition-colors z-10 group"
|
|
149
|
+
onMouseDown={handleRightResizeStart}
|
|
150
|
+
style={{ width: 4, marginLeft: -4 }}
|
|
151
|
+
>
|
|
152
|
+
<div className="absolute inset-y-0 left-1/2 w-0.5 bg-[var(--color-border-primary)] group-hover:bg-[var(--color-text-accent)] transition-colors -translate-x-1/2" />
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
{/* 右栏收起时的展开按钮(预览态不显示) */}
|
|
158
|
+
{!rightPanelVisible &&
|
|
159
|
+
!rpExpandedForPreview &&
|
|
160
|
+
centerTab !== 'chat' &&
|
|
161
|
+
sbBreakpoint !== 'mobile' && (
|
|
162
|
+
<button
|
|
163
|
+
onClick={() => useRightPanelStore.getState().setMode('full')}
|
|
164
|
+
title="展开右侧面板"
|
|
165
|
+
className="absolute top-1/2 right-0 -translate-y-1/2 z-10 px-1 py-4 bg-[var(--color-bg-panel)] border border-r-0 border-[var(--color-border-primary)] rounded-l-lg hover:bg-[var(--color-bg-hover)] transition-colors"
|
|
166
|
+
>
|
|
167
|
+
<span className="text-[var(--color-text-tertiary)] text-xs">◀</span>
|
|
168
|
+
</button>
|
|
169
|
+
)}
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<NetworkDrawer />
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ===== 侧栏内容 =====
|
|
178
|
+
function SidebarInner({
|
|
179
|
+
handleResizeStart,
|
|
180
|
+
isCollapsed,
|
|
181
|
+
showClose,
|
|
182
|
+
onClose,
|
|
183
|
+
}: {
|
|
184
|
+
handleResizeStart?: (e: React.MouseEvent) => void;
|
|
185
|
+
isCollapsed: boolean;
|
|
186
|
+
showClose?: boolean;
|
|
187
|
+
onClose?: () => void;
|
|
188
|
+
}) {
|
|
189
|
+
return (
|
|
190
|
+
<>
|
|
191
|
+
{showClose && (
|
|
192
|
+
<div className="flex items-center justify-end px-2 py-1.5 border-b border-[var(--color-border-secondary)]">
|
|
193
|
+
<button
|
|
194
|
+
onClick={onClose}
|
|
195
|
+
title="关闭"
|
|
196
|
+
className="text-[var(--color-text-tertiary)] hover:text-[var(--color-text-primary)] p-1"
|
|
197
|
+
>
|
|
198
|
+
<PanelLeftClose className="w-4 h-4" />
|
|
199
|
+
</button>
|
|
200
|
+
</div>
|
|
201
|
+
)}
|
|
202
|
+
|
|
203
|
+
{isCollapsed ? <TaskSidebar collapsed /> : <TaskSidebar />}
|
|
204
|
+
|
|
205
|
+
{!showClose && !isCollapsed && handleResizeStart && (
|
|
206
|
+
<div
|
|
207
|
+
className="absolute right-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-[var(--color-accent)]/50 active:bg-[var(--color-accent)] transition-colors z-10 group"
|
|
208
|
+
onMouseDown={handleResizeStart}
|
|
209
|
+
style={{ width: 4, marginRight: -4 }}
|
|
210
|
+
>
|
|
211
|
+
<div className="absolute inset-y-0 left-1/2 w-0.5 bg-[var(--color-border-primary)] group-hover:bg-[var(--color-text-accent)] transition-colors -translate-x-1/2" />
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 产出物面板 — Artifacts 列表
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { FileText, ChevronDown, ChevronRight } from 'lucide-react';
|
|
6
|
+
import { useOutputStore } from '../../stores/use-output-store';
|
|
7
|
+
import { useViewStore } from '../../stores/use-view-store';
|
|
8
|
+
|
|
9
|
+
export function ArtifactsPanel() {
|
|
10
|
+
const outputs = useOutputStore((s) => s.outputs);
|
|
11
|
+
const fetchOutputs = useOutputStore((s) => s.fetchOutputs);
|
|
12
|
+
|
|
13
|
+
const collapsed = useViewStore((s) => s.rightPanelCollapsed['artifacts']);
|
|
14
|
+
const toggle = useViewStore((s) => s.toggleRightPanel);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
fetchOutputs();
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="border-b border-[var(--color-border-secondary)]">
|
|
22
|
+
<button
|
|
23
|
+
onClick={() => toggle('artifacts')}
|
|
24
|
+
className="w-full flex items-center gap-1.5 px-4 py-3 text-sm font-semibold text-[var(--color-text-primary)] hover:bg-[var(--color-bg-hover)] transition-colors"
|
|
25
|
+
>
|
|
26
|
+
{collapsed ? <ChevronRight className="w-4 h-4" /> : <ChevronDown className="w-4 h-4" />}
|
|
27
|
+
Artifacts
|
|
28
|
+
</button>
|
|
29
|
+
{!collapsed && (
|
|
30
|
+
<div className="px-3 pb-3 space-y-0.5">
|
|
31
|
+
{outputs.length === 0 ? (
|
|
32
|
+
<p className="text-xs text-[var(--color-text-tertiary)] px-3">No artifacts yet.</p>
|
|
33
|
+
) : (
|
|
34
|
+
outputs.map((output) => (
|
|
35
|
+
<div
|
|
36
|
+
key={output.id}
|
|
37
|
+
className="flex items-center gap-2 px-2.5 py-2 rounded-lg hover:bg-[var(--color-bg-hover)] transition-colors cursor-pointer"
|
|
38
|
+
>
|
|
39
|
+
<div className="w-7 h-7 rounded-md bg-[var(--color-bg-tertiary)] flex items-center justify-center flex-shrink-0">
|
|
40
|
+
<FileText className="w-3.5 h-3.5 text-[var(--color-text-tertiary)]" />
|
|
41
|
+
</div>
|
|
42
|
+
<div className="flex-1 min-w-0">
|
|
43
|
+
<div className="text-sm text-[var(--color-text-secondary)] truncate">
|
|
44
|
+
{output.name}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
))
|
|
49
|
+
)}
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|