@dyyz1993/create-agent 2.1.1 → 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 +127 -91
- 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/CHANGELOG.md +15 -0
- package/templates/agent/package.json +3 -3
- 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
|
@@ -1,528 +1,769 @@
|
|
|
1
|
-
import { memo, useEffect, useCallback, useState, useRef } from
|
|
2
|
-
import { useTranslation } from
|
|
3
|
-
import { useShallow } from
|
|
1
|
+
import { memo, useEffect, useCallback, useState, useRef } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useShallow } from 'zustand/react/shallow';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
GitBranch,
|
|
6
|
+
RefreshCw,
|
|
7
|
+
FileQuestion,
|
|
8
|
+
Plus,
|
|
9
|
+
Minus,
|
|
10
|
+
Pencil,
|
|
11
|
+
ChevronRight,
|
|
12
|
+
ChevronDown,
|
|
13
|
+
Eye,
|
|
14
|
+
FileText,
|
|
15
|
+
Copy,
|
|
16
|
+
Upload,
|
|
17
|
+
Download,
|
|
18
|
+
ChevronUp,
|
|
19
|
+
ChevronDown as BranchChevron,
|
|
20
|
+
FolderTree,
|
|
21
|
+
} from 'lucide-react';
|
|
22
|
+
import { useGitStore, type GitFileChange, type GitCommit } from '../../stores/use-git-store';
|
|
23
|
+
import { useExplorerStore } from '../../stores/use-explorer-store';
|
|
24
|
+
import { ContextMenu, type MenuItem } from '../explorer/ContextMenu';
|
|
25
|
+
import { GitCommitInput } from './GitCommitInput';
|
|
26
|
+
import { GitBranchSelector } from './GitBranchSelector';
|
|
27
|
+
import { PinButton } from '../sidebar/PinButton';
|
|
28
|
+
|
|
29
|
+
function statusIcon(status: GitFileChange['status']) {
|
|
30
|
+
switch (status) {
|
|
31
|
+
case 'added':
|
|
32
|
+
return <Plus className="w-3 h-3 text-[var(--color-text-success)]" />;
|
|
33
|
+
case 'deleted':
|
|
34
|
+
return <Minus className="w-3 h-3 text-[var(--color-text-error)]" />;
|
|
35
|
+
case 'modified':
|
|
36
|
+
return <Pencil className="w-3 h-3 text-[var(--color-text-warning)]" />;
|
|
37
|
+
default:
|
|
38
|
+
return <FileQuestion className="w-3 h-3 text-[var(--color-text-tertiary)]" />;
|
|
39
|
+
}
|
|
24
40
|
}
|
|
25
41
|
|
|
26
|
-
function statusLabel(status: GitFileChange[
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
function statusLabel(status: GitFileChange['status']) {
|
|
43
|
+
switch (status) {
|
|
44
|
+
case 'added':
|
|
45
|
+
return 'A';
|
|
46
|
+
case 'deleted':
|
|
47
|
+
return 'D';
|
|
48
|
+
case 'modified':
|
|
49
|
+
return 'M';
|
|
50
|
+
case 'renamed':
|
|
51
|
+
return 'R';
|
|
52
|
+
case 'copied':
|
|
53
|
+
return 'C';
|
|
54
|
+
}
|
|
34
55
|
}
|
|
35
56
|
|
|
36
57
|
interface FileItemProps {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
path: string;
|
|
59
|
+
status: GitFileChange['status'];
|
|
60
|
+
isSelected: boolean;
|
|
61
|
+
isStaged?: boolean;
|
|
62
|
+
onClick: (filePath: string, staged?: boolean) => void;
|
|
63
|
+
onContextMenu: (e: React.MouseEvent, filePath: string, isStaged?: boolean) => void;
|
|
64
|
+
onStageToggle: (filePath: string, isStaged?: boolean) => void;
|
|
65
|
+
stageTitle: string;
|
|
66
|
+
unstageTitle: string;
|
|
46
67
|
}
|
|
47
68
|
|
|
48
69
|
const FileItem = memo(function FileItem({
|
|
49
|
-
|
|
70
|
+
path,
|
|
71
|
+
status,
|
|
72
|
+
isSelected,
|
|
73
|
+
isStaged,
|
|
74
|
+
onClick,
|
|
75
|
+
onContextMenu,
|
|
76
|
+
onStageToggle,
|
|
77
|
+
stageTitle,
|
|
78
|
+
unstageTitle,
|
|
50
79
|
}: FileItemProps) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
className={`group flex items-center gap-1.5 px-2 py-0.5 text-xs rounded cursor-pointer transition-colors ${
|
|
83
|
+
isSelected
|
|
84
|
+
? 'bg-[var(--color-accent)]/30 text-[var(--color-text-primary)]'
|
|
85
|
+
: 'hover:bg-[var(--color-bg-hover)] text-[var(--color-text-secondary)]'
|
|
86
|
+
}`}
|
|
87
|
+
onClick={() => onClick(path, isStaged)}
|
|
88
|
+
onContextMenu={(e) => {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
onContextMenu(e, path, isStaged);
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
{statusIcon(status)}
|
|
94
|
+
<span className="truncate flex-1">{path.split('/').pop()}</span>
|
|
95
|
+
<span className="text-[var(--color-text-placeholder)] text-[10px]">
|
|
96
|
+
{statusLabel(status)}
|
|
97
|
+
</span>
|
|
98
|
+
<button
|
|
99
|
+
className={`opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-[var(--color-bg-active)] ${
|
|
100
|
+
isStaged
|
|
101
|
+
? 'text-[var(--color-text-warning)] hover:text-[var(--color-text-warning)]'
|
|
102
|
+
: 'text-[var(--color-text-success)] hover:text-[var(--color-text-success)]'
|
|
103
|
+
}`}
|
|
104
|
+
onClick={(e) => {
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
onStageToggle(path, isStaged);
|
|
107
|
+
}}
|
|
108
|
+
title={isStaged ? unstageTitle : stageTitle}
|
|
109
|
+
>
|
|
110
|
+
{isStaged ? <ChevronUp className="w-3 h-3" /> : <Plus className="w-3 h-3" />}
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
73
114
|
});
|
|
74
115
|
|
|
75
116
|
interface UntrackedItemProps {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
path: string;
|
|
118
|
+
isSelected: boolean;
|
|
119
|
+
onClick: (filePath: string) => void;
|
|
120
|
+
onContextMenu: (e: React.MouseEvent, filePath: string) => void;
|
|
121
|
+
onStage: (filePath: string) => void;
|
|
122
|
+
stageTitle: string;
|
|
82
123
|
}
|
|
83
124
|
|
|
84
125
|
const UntrackedItem = memo(function UntrackedItem({
|
|
85
|
-
|
|
126
|
+
path,
|
|
127
|
+
isSelected,
|
|
128
|
+
onClick,
|
|
129
|
+
onContextMenu,
|
|
130
|
+
onStage,
|
|
131
|
+
stageTitle,
|
|
86
132
|
}: UntrackedItemProps) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
133
|
+
return (
|
|
134
|
+
<div
|
|
135
|
+
className={`group flex items-center gap-1.5 px-2 py-0.5 text-xs rounded cursor-pointer transition-colors ${
|
|
136
|
+
isSelected
|
|
137
|
+
? 'bg-[var(--color-accent)]/30 text-[var(--color-text-primary)]'
|
|
138
|
+
: 'hover:bg-[var(--color-bg-hover)] text-[var(--color-text-tertiary)]'
|
|
139
|
+
}`}
|
|
140
|
+
onClick={() => onClick(path)}
|
|
141
|
+
onContextMenu={(e) => {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
onContextMenu(e, path);
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<FileQuestion className="w-3 h-3 text-[var(--color-text-placeholder)]" />
|
|
147
|
+
<span className="truncate flex-1">{path.split('/').pop()}</span>
|
|
148
|
+
<span className="text-[var(--color-text-tertiary)] text-[10px]">U</span>
|
|
149
|
+
<button
|
|
150
|
+
className="opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded text-[var(--color-text-success)] hover:text-[var(--color-text-success)] hover:bg-[var(--color-bg-active)]"
|
|
151
|
+
onClick={(e) => {
|
|
152
|
+
e.stopPropagation();
|
|
153
|
+
onStage(path);
|
|
154
|
+
}}
|
|
155
|
+
title={stageTitle}
|
|
156
|
+
>
|
|
157
|
+
<Plus className="w-3 h-3" />
|
|
158
|
+
</button>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
107
161
|
});
|
|
108
162
|
|
|
109
163
|
interface CommitFileItemProps {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
164
|
+
path: string;
|
|
165
|
+
status: GitFileChange['status'];
|
|
166
|
+
isSelected: boolean;
|
|
167
|
+
onClick: () => void;
|
|
114
168
|
}
|
|
115
169
|
|
|
116
|
-
const CommitFileItem = memo(function CommitFileItem({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
170
|
+
const CommitFileItem = memo(function CommitFileItem({
|
|
171
|
+
path,
|
|
172
|
+
status,
|
|
173
|
+
isSelected,
|
|
174
|
+
onClick,
|
|
175
|
+
}: CommitFileItemProps) {
|
|
176
|
+
return (
|
|
177
|
+
<div
|
|
178
|
+
className={`flex items-center gap-1.5 pl-7 pr-2 py-0.5 text-xs rounded cursor-pointer transition-colors ${
|
|
179
|
+
isSelected
|
|
180
|
+
? 'bg-[var(--color-accent)]/30 text-[var(--color-text-primary)]'
|
|
181
|
+
: 'hover:bg-[var(--color-bg-hover)] text-[var(--color-text-tertiary)]'
|
|
182
|
+
}`}
|
|
183
|
+
onClick={onClick}
|
|
184
|
+
>
|
|
185
|
+
{statusIcon(status)}
|
|
186
|
+
<span className="truncate flex-1">{path.split('/').pop()}</span>
|
|
187
|
+
<span className="text-[var(--color-text-tertiary)] text-[10px]">{statusLabel(status)}</span>
|
|
188
|
+
</div>
|
|
189
|
+
);
|
|
129
190
|
});
|
|
130
191
|
|
|
131
192
|
interface CommitItemProps {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
193
|
+
commit: GitCommit;
|
|
194
|
+
expanded: boolean;
|
|
195
|
+
files: GitFileChange[] | undefined;
|
|
196
|
+
loading: boolean;
|
|
197
|
+
selectedFilePath: string | null;
|
|
198
|
+
onToggle: () => void;
|
|
199
|
+
onFileClick: (filePath: string) => void;
|
|
200
|
+
onContextMenu: (e: React.MouseEvent, commit: GitCommit) => void;
|
|
201
|
+
t: (key: string) => string;
|
|
141
202
|
}
|
|
142
203
|
|
|
143
|
-
function relativeTime(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
204
|
+
function relativeTime(
|
|
205
|
+
dateStr: string,
|
|
206
|
+
t: (key: string, options?: Record<string, unknown>) => string,
|
|
207
|
+
): string {
|
|
208
|
+
const d = new Date(dateStr);
|
|
209
|
+
const now = new Date();
|
|
210
|
+
const diff = now.getTime() - d.getTime();
|
|
211
|
+
const mins = Math.floor(diff / 60000);
|
|
212
|
+
if (mins < 1) return t('git.justNow');
|
|
213
|
+
if (mins < 60) return t('git.minutesAgo', { count: mins });
|
|
214
|
+
const hours = Math.floor(mins / 60);
|
|
215
|
+
if (hours < 24) return t('git.hoursAgo', { count: hours });
|
|
216
|
+
const days = Math.floor(hours / 24);
|
|
217
|
+
if (days < 30) return t('git.daysAgo', { count: days });
|
|
218
|
+
return d.toLocaleDateString();
|
|
155
219
|
}
|
|
156
220
|
|
|
157
221
|
const CommitItem = memo(function CommitItem({
|
|
158
|
-
|
|
222
|
+
commit,
|
|
223
|
+
expanded,
|
|
224
|
+
files,
|
|
225
|
+
loading,
|
|
226
|
+
selectedFilePath,
|
|
227
|
+
onToggle,
|
|
228
|
+
onFileClick,
|
|
229
|
+
onContextMenu,
|
|
230
|
+
t,
|
|
159
231
|
}: CommitItemProps) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
232
|
+
return (
|
|
233
|
+
<div>
|
|
234
|
+
<div
|
|
235
|
+
className="flex items-start gap-1.5 px-2 py-1 text-xs hover:bg-[var(--color-bg-hover)]/50 rounded cursor-pointer"
|
|
236
|
+
onClick={onToggle}
|
|
237
|
+
onContextMenu={(e) => {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
onContextMenu(e, commit);
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
{expanded ? (
|
|
243
|
+
<ChevronDown className="w-3 h-3 text-[var(--color-text-placeholder)] mt-0.5 shrink-0" />
|
|
244
|
+
) : (
|
|
245
|
+
<ChevronRight className="w-3 h-3 text-[var(--color-text-placeholder)] mt-0.5 shrink-0" />
|
|
246
|
+
)}
|
|
247
|
+
<div className="flex-1 min-w-0">
|
|
248
|
+
<div className="text-[var(--color-text-secondary)] truncate">{commit.message}</div>
|
|
249
|
+
<div className="text-[var(--color-text-placeholder)] text-[10px] flex items-center gap-1.5 mt-0.5">
|
|
250
|
+
<span className="text-[var(--color-text-accent)] font-mono">{commit.shortHash}</span>
|
|
251
|
+
<span>{commit.author}</span>
|
|
252
|
+
<span>{relativeTime(commit.date, t)}</span>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
{expanded && (
|
|
257
|
+
<div className="ml-1">
|
|
258
|
+
{loading ? (
|
|
259
|
+
<div className="text-[var(--color-text-tertiary)] text-[10px] pl-7 py-1">
|
|
260
|
+
{t('git.loadingFiles')}
|
|
261
|
+
</div>
|
|
262
|
+
) : files && files.length > 0 ? (
|
|
263
|
+
files.map((f) => (
|
|
264
|
+
<CommitFileItem
|
|
265
|
+
key={f.path}
|
|
266
|
+
path={f.path}
|
|
267
|
+
status={f.status}
|
|
268
|
+
isSelected={selectedFilePath === f.path}
|
|
269
|
+
onClick={() => onFileClick(f.path)}
|
|
270
|
+
/>
|
|
271
|
+
))
|
|
272
|
+
) : (
|
|
273
|
+
<div className="text-[var(--color-text-tertiary)] text-[10px] pl-7 py-1">
|
|
274
|
+
{t('git.noFiles')}
|
|
275
|
+
</div>
|
|
276
|
+
)}
|
|
277
|
+
</div>
|
|
278
|
+
)}
|
|
279
|
+
</div>
|
|
280
|
+
);
|
|
200
281
|
});
|
|
201
282
|
|
|
202
283
|
interface GitPanelProps {
|
|
203
|
-
|
|
284
|
+
hideOuterShell?: boolean;
|
|
204
285
|
}
|
|
205
286
|
|
|
206
287
|
export function GitPanel({ hideOuterShell }: GitPanelProps) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
288
|
+
const { t } = useTranslation();
|
|
289
|
+
|
|
290
|
+
const { branch, ahead, behind } = useGitStore(
|
|
291
|
+
useShallow((s) => ({
|
|
292
|
+
branch: s.branch,
|
|
293
|
+
ahead: s.ahead,
|
|
294
|
+
behind: s.behind,
|
|
295
|
+
})),
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
const { staged, changed, untracked } = useGitStore(
|
|
299
|
+
useShallow((s) => ({
|
|
300
|
+
staged: s.staged,
|
|
301
|
+
changed: s.changed,
|
|
302
|
+
untracked: s.untracked,
|
|
303
|
+
})),
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const {
|
|
307
|
+
commits,
|
|
308
|
+
loadingCommits,
|
|
309
|
+
currentDiff,
|
|
310
|
+
expandedCommits,
|
|
311
|
+
commitFiles,
|
|
312
|
+
loadingCommitFiles,
|
|
313
|
+
loadingAction,
|
|
314
|
+
worktrees,
|
|
315
|
+
} = useGitStore(
|
|
316
|
+
useShallow((s) => ({
|
|
317
|
+
commits: s.commits,
|
|
318
|
+
loadingCommits: s.loadingCommits,
|
|
319
|
+
currentDiff: s.currentDiff,
|
|
320
|
+
expandedCommits: s.expandedCommits,
|
|
321
|
+
commitFiles: s.commitFiles,
|
|
322
|
+
loadingCommitFiles: s.loadingCommitFiles,
|
|
323
|
+
loadingAction: s.loadingAction,
|
|
324
|
+
worktrees: s.worktrees,
|
|
325
|
+
})),
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const fetchStatus = useGitStore((s) => s.fetchStatus);
|
|
329
|
+
const fetchDiff = useGitStore((s) => s.fetchDiff);
|
|
330
|
+
const fetchLog = useGitStore((s) => s.fetchLog);
|
|
331
|
+
const toggleCommitExpand = useGitStore((s) => s.toggleCommitExpand);
|
|
332
|
+
const fetchCommitFileDiff = useGitStore((s) => s.fetchCommitFileDiff);
|
|
333
|
+
const stageFiles = useGitStore((s) => s.stageFiles);
|
|
334
|
+
const unstageFiles = useGitStore((s) => s.unstageFiles);
|
|
335
|
+
const push = useGitStore((s) => s.push);
|
|
336
|
+
const pull = useGitStore((s) => s.pull);
|
|
337
|
+
const fetchWorktrees = useGitStore((s) => s.fetchWorktrees);
|
|
338
|
+
|
|
339
|
+
const currentPath = useExplorerStore((s) => s.currentPath);
|
|
340
|
+
const openFile = useExplorerStore((s) => s.openFile);
|
|
341
|
+
|
|
342
|
+
const [commitsExpanded, setCommitsExpanded] = useState(false);
|
|
343
|
+
const [showBranches, setShowBranches] = useState(false);
|
|
344
|
+
const [showWorktrees, setShowWorktrees] = useState(false);
|
|
345
|
+
const [ctxMenu, setCtxMenu] = useState<{
|
|
346
|
+
x: number;
|
|
347
|
+
y: number;
|
|
348
|
+
filePath: string;
|
|
349
|
+
isStaged?: boolean;
|
|
350
|
+
} | null>(null);
|
|
351
|
+
const [commitCtxMenu, setCommitCtxMenu] = useState<{
|
|
352
|
+
x: number;
|
|
353
|
+
y: number;
|
|
354
|
+
commit: GitCommit;
|
|
355
|
+
} | null>(null);
|
|
356
|
+
|
|
357
|
+
const branchBtnRef = useRef<HTMLButtonElement>(null);
|
|
358
|
+
|
|
359
|
+
const refresh = useCallback(() => {
|
|
360
|
+
fetchStatus(currentPath);
|
|
361
|
+
fetchWorktrees(currentPath);
|
|
362
|
+
if (commitsExpanded) fetchLog(currentPath);
|
|
363
|
+
}, [fetchStatus, fetchWorktrees, fetchLog, currentPath, commitsExpanded]);
|
|
364
|
+
|
|
365
|
+
useEffect(() => {
|
|
366
|
+
refresh();
|
|
367
|
+
}, [refresh]);
|
|
368
|
+
|
|
369
|
+
const handleFileClick = useCallback(
|
|
370
|
+
(filePath: string, staged?: boolean) => {
|
|
371
|
+
fetchDiff(currentPath, filePath, staged);
|
|
372
|
+
},
|
|
373
|
+
[fetchDiff, currentPath],
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
const handleContextMenu = useCallback(
|
|
377
|
+
(e: React.MouseEvent, filePath: string, isStaged?: boolean) => {
|
|
378
|
+
setCtxMenu({ x: e.clientX, y: e.clientY, filePath, isStaged });
|
|
379
|
+
},
|
|
380
|
+
[],
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
const handleOpenFile = useCallback(
|
|
384
|
+
(filePath: string) => {
|
|
385
|
+
const fullPath = `${currentPath}/${filePath}`;
|
|
386
|
+
openFile({
|
|
387
|
+
name: filePath.split('/').pop() || filePath,
|
|
388
|
+
path: fullPath,
|
|
389
|
+
type: 'file' as const,
|
|
390
|
+
});
|
|
391
|
+
},
|
|
392
|
+
[openFile, currentPath],
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
const handleCopyPath = useCallback(
|
|
396
|
+
async (filePath: string) => {
|
|
397
|
+
await navigator.clipboard.writeText(`${currentPath}/${filePath}`);
|
|
398
|
+
},
|
|
399
|
+
[currentPath],
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
const getContextMenuItems = useCallback(
|
|
403
|
+
(filePath: string, isStaged?: boolean): MenuItem[] => [
|
|
404
|
+
{
|
|
405
|
+
label: t('git.openDiff'),
|
|
406
|
+
icon: <Eye className="w-3 h-3" />,
|
|
407
|
+
onClick: () => fetchDiff(currentPath, filePath, isStaged),
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
label: t('git.openFile'),
|
|
411
|
+
icon: <FileText className="w-3 h-3" />,
|
|
412
|
+
onClick: () => handleOpenFile(filePath),
|
|
413
|
+
},
|
|
414
|
+
{ label: '', onClick: () => {}, divider: true },
|
|
415
|
+
{
|
|
416
|
+
label: t('git.copyPath'),
|
|
417
|
+
icon: <Copy className="w-3 h-3" />,
|
|
418
|
+
onClick: () => handleCopyPath(filePath),
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
[fetchDiff, currentPath, handleOpenFile, handleCopyPath, t],
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
const handleCommitContextMenu = useCallback((e: React.MouseEvent, commit: GitCommit) => {
|
|
425
|
+
setCommitCtxMenu({ x: e.clientX, y: e.clientY, commit });
|
|
426
|
+
}, []);
|
|
427
|
+
|
|
428
|
+
const getCommitContextMenuItems = useCallback(
|
|
429
|
+
(commit: GitCommit): MenuItem[] => [
|
|
430
|
+
{
|
|
431
|
+
label: t('git.copyHash'),
|
|
432
|
+
icon: <Copy className="w-3 h-3" />,
|
|
433
|
+
onClick: () => navigator.clipboard.writeText(commit.hash),
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
label: t('git.copyMessage'),
|
|
437
|
+
icon: <Copy className="w-3 h-3" />,
|
|
438
|
+
onClick: () => navigator.clipboard.writeText(commit.message),
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
[t],
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
const handleCommitFileClick = useCallback(
|
|
445
|
+
(hash: string, filePath: string) => {
|
|
446
|
+
fetchCommitFileDiff(currentPath, hash, filePath);
|
|
447
|
+
},
|
|
448
|
+
[fetchCommitFileDiff, currentPath],
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
const handleStageToggle = useCallback(
|
|
452
|
+
(filePath: string, isStaged?: boolean) => {
|
|
453
|
+
if (isStaged) {
|
|
454
|
+
unstageFiles(currentPath, [filePath]);
|
|
455
|
+
} else {
|
|
456
|
+
stageFiles(currentPath, [filePath]);
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
[stageFiles, unstageFiles, currentPath],
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
const handleStageAll = useCallback(() => {
|
|
463
|
+
const paths = [...changed.map((f) => f.path), ...untracked];
|
|
464
|
+
if (paths.length > 0) stageFiles(currentPath, paths);
|
|
465
|
+
}, [changed, untracked, stageFiles, currentPath]);
|
|
466
|
+
|
|
467
|
+
const handleUnstageAll = useCallback(() => {
|
|
468
|
+
const paths = staged.map((f) => f.path);
|
|
469
|
+
if (paths.length > 0) unstageFiles(currentPath, paths);
|
|
470
|
+
}, [staged, unstageFiles, currentPath]);
|
|
471
|
+
|
|
472
|
+
const handleUntrackedStage = useCallback(
|
|
473
|
+
(filePath: string) => {
|
|
474
|
+
stageFiles(currentPath, [filePath]);
|
|
475
|
+
},
|
|
476
|
+
[stageFiles, currentPath],
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
const toggleCommits = useCallback(() => {
|
|
480
|
+
const next = !commitsExpanded;
|
|
481
|
+
setCommitsExpanded(next);
|
|
482
|
+
if (next && commits.length === 0) fetchLog(currentPath);
|
|
483
|
+
}, [commitsExpanded, commits.length, fetchLog, currentPath]);
|
|
484
|
+
|
|
485
|
+
const handlePush = useCallback(() => push(currentPath), [push, currentPath]);
|
|
486
|
+
const handlePull = useCallback(() => pull(currentPath), [pull, currentPath]);
|
|
487
|
+
|
|
488
|
+
const totalChanges = staged.length + changed.length + untracked.length;
|
|
489
|
+
const selectedFilePath = currentDiff?.filePath ?? null;
|
|
490
|
+
const hasMultipleWorktrees = worktrees.length > 1;
|
|
491
|
+
|
|
492
|
+
const pinButton = <PinButton />;
|
|
493
|
+
|
|
494
|
+
const panelContent = (
|
|
495
|
+
<>
|
|
496
|
+
<div className="px-3 py-2 text-xs font-semibold text-[var(--color-text-tertiary)] uppercase tracking-wide border-b border-[var(--color-border-primary)] flex items-center gap-1.5">
|
|
497
|
+
<GitBranch className="w-3.5 h-3.5" />
|
|
498
|
+
{t('git.title')}
|
|
499
|
+
<span className="ml-auto flex items-center gap-1">
|
|
500
|
+
{totalChanges > 0 && (
|
|
501
|
+
<span className="bg-[var(--color-accent)] text-[var(--color-text-primary)] px-1.5 py-0.5 rounded-full text-[10px] leading-none">
|
|
502
|
+
{totalChanges}
|
|
503
|
+
</span>
|
|
504
|
+
)}
|
|
505
|
+
{pinButton}
|
|
506
|
+
<button
|
|
507
|
+
onClick={handlePull}
|
|
508
|
+
className="text-[var(--color-text-placeholder)] hover:text-[var(--color-text-primary)]"
|
|
509
|
+
disabled={loadingAction === 'pull'}
|
|
510
|
+
title={t('git.pull')}
|
|
511
|
+
>
|
|
512
|
+
<Download className="w-3 h-3" />
|
|
513
|
+
</button>
|
|
514
|
+
<button
|
|
515
|
+
onClick={handlePush}
|
|
516
|
+
className="text-[var(--color-text-placeholder)] hover:text-[var(--color-text-primary)]"
|
|
517
|
+
disabled={loadingAction === 'push'}
|
|
518
|
+
title={t('git.push')}
|
|
519
|
+
>
|
|
520
|
+
<Upload className="w-3 h-3" />
|
|
521
|
+
</button>
|
|
522
|
+
<button
|
|
523
|
+
onClick={refresh}
|
|
524
|
+
className="text-[var(--color-text-placeholder)] hover:text-[var(--color-text-primary)]"
|
|
525
|
+
title={t('git.refresh')}
|
|
526
|
+
>
|
|
527
|
+
<RefreshCw className="w-3 h-3" />
|
|
528
|
+
</button>
|
|
529
|
+
</span>
|
|
530
|
+
</div>
|
|
531
|
+
|
|
532
|
+
<div className="px-2 py-1.5 text-xs text-[var(--color-text-tertiary)] flex items-center gap-1.5 border-b border-[var(--color-border-primary)]/50">
|
|
533
|
+
<button
|
|
534
|
+
ref={branchBtnRef}
|
|
535
|
+
className="flex items-center gap-1 hover:text-[var(--color-text-primary)] transition-colors"
|
|
536
|
+
onClick={() => setShowBranches(!showBranches)}
|
|
537
|
+
>
|
|
538
|
+
<GitBranch className="w-3 h-3" />
|
|
539
|
+
<span className="font-medium">{branch}</span>
|
|
540
|
+
{ahead > 0 && <span className="text-[var(--color-text-success)]">↑{ahead}</span>}
|
|
541
|
+
{behind > 0 && <span className="text-[var(--color-text-warning)]">↓{behind}</span>}
|
|
542
|
+
<BranchChevron className="w-3 h-3 text-[var(--color-text-placeholder)]" />
|
|
543
|
+
</button>
|
|
544
|
+
|
|
545
|
+
{hasMultipleWorktrees && (
|
|
546
|
+
<button
|
|
547
|
+
className="ml-auto text-[var(--color-text-placeholder)] hover:text-[var(--color-text-primary)] transition-colors"
|
|
548
|
+
onClick={() => setShowWorktrees(!showWorktrees)}
|
|
549
|
+
title={`${worktrees.length} worktrees`}
|
|
550
|
+
>
|
|
551
|
+
<FolderTree className="w-3 h-3" />
|
|
552
|
+
</button>
|
|
553
|
+
)}
|
|
554
|
+
</div>
|
|
555
|
+
|
|
556
|
+
<GitCommitInput />
|
|
557
|
+
|
|
558
|
+
<div className="flex-1 overflow-y-auto p-1">
|
|
559
|
+
{staged.length > 0 && (
|
|
560
|
+
<div className="mt-1">
|
|
561
|
+
<div className="px-2 py-1 text-[10px] uppercase tracking-wide text-[var(--color-text-placeholder)] font-semibold flex items-center">
|
|
562
|
+
<span>
|
|
563
|
+
{t('git.staged')} ({staged.length})
|
|
564
|
+
</span>
|
|
565
|
+
<button
|
|
566
|
+
className="ml-auto text-[var(--color-text-warning)] hover:text-[var(--color-text-warning)]"
|
|
567
|
+
onClick={handleUnstageAll}
|
|
568
|
+
title={t('git.unstageAll')}
|
|
569
|
+
>
|
|
570
|
+
<ChevronUp className="w-3 h-3" />
|
|
571
|
+
</button>
|
|
572
|
+
</div>
|
|
573
|
+
{staged.map((f) => (
|
|
574
|
+
<FileItem
|
|
575
|
+
key={f.path}
|
|
576
|
+
path={f.path}
|
|
577
|
+
status={f.status}
|
|
578
|
+
isSelected={selectedFilePath === f.path}
|
|
579
|
+
isStaged
|
|
580
|
+
onClick={handleFileClick}
|
|
581
|
+
onContextMenu={handleContextMenu}
|
|
582
|
+
onStageToggle={handleStageToggle}
|
|
583
|
+
stageTitle={t('git.stage')}
|
|
584
|
+
unstageTitle={t('git.unstage')}
|
|
585
|
+
/>
|
|
586
|
+
))}
|
|
587
|
+
</div>
|
|
588
|
+
)}
|
|
589
|
+
|
|
590
|
+
{changed.length > 0 && (
|
|
591
|
+
<div className="mt-2">
|
|
592
|
+
<div className="px-2 py-1 text-[10px] uppercase tracking-wide text-[var(--color-text-placeholder)] font-semibold flex items-center">
|
|
593
|
+
<span>
|
|
594
|
+
{t('git.changes')} ({changed.length})
|
|
595
|
+
</span>
|
|
596
|
+
<button
|
|
597
|
+
className="ml-auto text-[var(--color-text-success)] hover:text-[var(--color-text-success)]"
|
|
598
|
+
onClick={handleStageAll}
|
|
599
|
+
title={t('git.stageAll')}
|
|
600
|
+
>
|
|
601
|
+
<Plus className="w-3 h-3" />
|
|
602
|
+
</button>
|
|
603
|
+
</div>
|
|
604
|
+
{changed.map((f) => (
|
|
605
|
+
<FileItem
|
|
606
|
+
key={f.path}
|
|
607
|
+
path={f.path}
|
|
608
|
+
status={f.status}
|
|
609
|
+
isSelected={selectedFilePath === f.path}
|
|
610
|
+
onClick={handleFileClick}
|
|
611
|
+
onContextMenu={handleContextMenu}
|
|
612
|
+
onStageToggle={handleStageToggle}
|
|
613
|
+
stageTitle={t('git.stage')}
|
|
614
|
+
unstageTitle={t('git.unstage')}
|
|
615
|
+
/>
|
|
616
|
+
))}
|
|
617
|
+
</div>
|
|
618
|
+
)}
|
|
619
|
+
|
|
620
|
+
{untracked.length > 0 && (
|
|
621
|
+
<div className="mt-2">
|
|
622
|
+
<div className="px-2 py-1 text-[10px] uppercase tracking-wide text-[var(--color-text-placeholder)] font-semibold">
|
|
623
|
+
{t('git.untracked')} ({untracked.length})
|
|
624
|
+
</div>
|
|
625
|
+
{untracked.map((f) => (
|
|
626
|
+
<UntrackedItem
|
|
627
|
+
key={f}
|
|
628
|
+
path={f}
|
|
629
|
+
isSelected={selectedFilePath === f}
|
|
630
|
+
onClick={handleFileClick}
|
|
631
|
+
onContextMenu={handleContextMenu}
|
|
632
|
+
onStage={handleUntrackedStage}
|
|
633
|
+
stageTitle={t('git.stage')}
|
|
634
|
+
/>
|
|
635
|
+
))}
|
|
636
|
+
</div>
|
|
637
|
+
)}
|
|
638
|
+
|
|
639
|
+
{totalChanges === 0 && !commitsExpanded && (
|
|
640
|
+
<div className="text-[var(--color-text-placeholder)] text-xs text-center py-8">
|
|
641
|
+
{t('git.noChanges')}
|
|
642
|
+
</div>
|
|
643
|
+
)}
|
|
644
|
+
|
|
645
|
+
<div className="mt-2 border-t border-[var(--color-border-primary)] pt-1">
|
|
646
|
+
<button
|
|
647
|
+
className="w-full px-2 py-1 text-[10px] uppercase tracking-wide text-[var(--color-text-placeholder)] font-semibold flex items-center gap-1 hover:text-[var(--color-text-secondary)] transition-colors"
|
|
648
|
+
onClick={toggleCommits}
|
|
649
|
+
>
|
|
650
|
+
{commitsExpanded ? (
|
|
651
|
+
<ChevronDown className="w-3 h-3" />
|
|
652
|
+
) : (
|
|
653
|
+
<ChevronRight className="w-3 h-3" />
|
|
654
|
+
)}
|
|
655
|
+
{t('git.commits')}
|
|
656
|
+
{commits.length > 0 && (
|
|
657
|
+
<span className="text-[var(--color-text-tertiary)] ml-auto">{commits.length}</span>
|
|
658
|
+
)}
|
|
659
|
+
</button>
|
|
660
|
+
{commitsExpanded && (
|
|
661
|
+
<div className="mt-0.5">
|
|
662
|
+
{loadingCommits ? (
|
|
663
|
+
<div className="text-[var(--color-text-placeholder)] text-xs text-center py-4">
|
|
664
|
+
{t('common.loading')}
|
|
665
|
+
</div>
|
|
666
|
+
) : commits.length === 0 ? (
|
|
667
|
+
<div className="text-[var(--color-text-tertiary)] text-xs text-center py-4">
|
|
668
|
+
{t('git.noCommits')}
|
|
669
|
+
</div>
|
|
670
|
+
) : (
|
|
671
|
+
commits.map((c) => (
|
|
672
|
+
<CommitItem
|
|
673
|
+
key={c.hash}
|
|
674
|
+
commit={c}
|
|
675
|
+
expanded={expandedCommits.has(c.hash)}
|
|
676
|
+
files={commitFiles[c.hash]}
|
|
677
|
+
loading={loadingCommitFiles.has(c.hash)}
|
|
678
|
+
selectedFilePath={selectedFilePath}
|
|
679
|
+
onToggle={() => toggleCommitExpand(currentPath, c.hash)}
|
|
680
|
+
onFileClick={(fp) => handleCommitFileClick(c.hash, fp)}
|
|
681
|
+
onContextMenu={handleCommitContextMenu}
|
|
682
|
+
t={t}
|
|
683
|
+
/>
|
|
684
|
+
))
|
|
685
|
+
)}
|
|
686
|
+
</div>
|
|
687
|
+
)}
|
|
688
|
+
</div>
|
|
689
|
+
</div>
|
|
690
|
+
|
|
691
|
+
{showBranches && branchBtnRef.current && (
|
|
692
|
+
<div
|
|
693
|
+
className="absolute z-50"
|
|
694
|
+
style={{
|
|
695
|
+
top: branchBtnRef.current.getBoundingClientRect().bottom + 4,
|
|
696
|
+
left: branchBtnRef.current.getBoundingClientRect().left,
|
|
697
|
+
}}
|
|
698
|
+
>
|
|
699
|
+
<GitBranchSelector onClose={() => setShowBranches(false)} />
|
|
700
|
+
</div>
|
|
701
|
+
)}
|
|
702
|
+
|
|
703
|
+
{showWorktrees && worktrees.length > 1 && (
|
|
704
|
+
<div
|
|
705
|
+
className="fixed z-50 min-w-[200px] bg-[var(--color-bg-secondary)] border border-[var(--color-border-secondary)] rounded-md shadow-xl py-1"
|
|
706
|
+
style={{ top: 80, left: 48 }}
|
|
707
|
+
>
|
|
708
|
+
<div className="px-3 py-1 text-[10px] uppercase tracking-wide text-[var(--color-text-placeholder)] font-semibold">
|
|
709
|
+
{t('git.worktrees')}
|
|
710
|
+
</div>
|
|
711
|
+
{worktrees.map((wt) => (
|
|
712
|
+
<div
|
|
713
|
+
key={wt.path}
|
|
714
|
+
className={`px-3 py-1.5 text-xs flex items-center gap-2 ${
|
|
715
|
+
wt.path === currentPath
|
|
716
|
+
? 'text-[var(--color-text-accent)]'
|
|
717
|
+
: 'text-[var(--color-text-secondary)]'
|
|
718
|
+
}`}
|
|
719
|
+
>
|
|
720
|
+
<FolderTree className="w-3 h-3 shrink-0" />
|
|
721
|
+
<div className="min-w-0 flex-1">
|
|
722
|
+
<div className="truncate">{wt.branch}</div>
|
|
723
|
+
<div className="text-[var(--color-text-placeholder)] text-[10px] truncate">
|
|
724
|
+
{wt.path}
|
|
725
|
+
</div>
|
|
726
|
+
</div>
|
|
727
|
+
{wt.isMain && (
|
|
728
|
+
<span className="text-[var(--color-text-tertiary)] text-[10px]">main</span>
|
|
729
|
+
)}
|
|
730
|
+
</div>
|
|
731
|
+
))}
|
|
732
|
+
<button
|
|
733
|
+
className="w-full text-left px-3 py-1 text-[10px] text-[var(--color-text-placeholder)] hover:text-[var(--color-text-secondary)] border-t border-[var(--color-border-primary)] mt-1 pt-1"
|
|
734
|
+
onClick={() => setShowWorktrees(false)}
|
|
735
|
+
>
|
|
736
|
+
{t('git.close')}
|
|
737
|
+
</button>
|
|
738
|
+
</div>
|
|
739
|
+
)}
|
|
740
|
+
|
|
741
|
+
{ctxMenu && (
|
|
742
|
+
<ContextMenu
|
|
743
|
+
x={ctxMenu.x}
|
|
744
|
+
y={ctxMenu.y}
|
|
745
|
+
items={getContextMenuItems(ctxMenu.filePath, ctxMenu.isStaged)}
|
|
746
|
+
onClose={() => setCtxMenu(null)}
|
|
747
|
+
/>
|
|
748
|
+
)}
|
|
749
|
+
{commitCtxMenu && (
|
|
750
|
+
<ContextMenu
|
|
751
|
+
x={commitCtxMenu.x}
|
|
752
|
+
y={commitCtxMenu.y}
|
|
753
|
+
items={getCommitContextMenuItems(commitCtxMenu.commit)}
|
|
754
|
+
onClose={() => setCommitCtxMenu(null)}
|
|
755
|
+
/>
|
|
756
|
+
)}
|
|
757
|
+
</>
|
|
758
|
+
);
|
|
759
|
+
|
|
760
|
+
if (hideOuterShell) {
|
|
761
|
+
return <div className="flex flex-col flex-1 overflow-hidden">{panelContent}</div>;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
return (
|
|
765
|
+
<div className="w-60 bg-[var(--color-bg-primary)] flex flex-col flex-shrink-0 overflow-hidden">
|
|
766
|
+
{panelContent}
|
|
767
|
+
</div>
|
|
768
|
+
);
|
|
528
769
|
}
|