mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-31 16:33:34 +08:00
* feat(desktop): add CodeMirror deps + bundle budget + encoding utils
Phase 2 foundation pieces (tasks 6-7 of editor-lsp-foundation):
- Add 9 @codemirror/* dependencies (state, view, commands, search, language,
autocomplete, lang-{javascript,json,markdown}). Tree-shaking keeps the
current bundle delta at +0.00 KB until WorkspaceEditor.tsx imports them
in task 8.
- Add scripts/check-bundle-budget.ts + bun script "check:bundle-budget".
Asserts dist/assets/*.js gzipped total <= baseline + 100 KB. Baseline
captured at origin/main @ 95931d49 (post-R5, pre-CodeMirror) = 3299.76 KB.
- Add encodingDetect.ts: detectEncoding(bytes) -> 'utf-8' | 'utf-8-bom' |
'unsupported' (uses TextDecoder fatal:true to map invalid UTF-8 to
unsupported); detectLineEnding(text) -> 'LF' | 'CRLF' | 'CR' (dominant
style with LF as fallback for empty/single-line buffers).
Tested:
- bun run test src/components/workspace/encodingDetect.test.ts -- --run (18/18 pass)
- bun run scripts/check-bundle-budget.ts (OK, +0.00 KB delta)
_Requirements: 1.3, 1.6, 1.7, 1.8_
* feat(server,desktop): workspace file save endpoint + buffer/conflict store
Phase 2 backend pieces (tasks 9-12 of editor-lsp-foundation):
Server:
- src/server/events/workspaceFileSaved.ts: shared emitter
emitWorkspaceFileSaved() so both write paths (user now, agent in PR-4)
funnel through one well-typed WS message shape.
- src/server/services/workspaceFileService.ts: WriteWorkspaceFileSchema
(Zod), atomic write (temp file + fsync + rename, Windows EBUSY/EPERM
retry 3x50ms), realpath-based symlink containment, BOM/CRLF/CR
round-trip, sha256 stale-base check (409 on hash mismatch), structured
400/404/409/500 error bodies, post-write workspace.file.saved emit.
- src/server/api/sessions.ts: POST /api/sessions/:id/workspace/file
routes through new handleSessionWorkspacePost; GET path unchanged.
- src/server/services/workspaceFileService.test.ts: 17 tests covering
200 / 400 (bad request, path-escape, parent-missing, absolute-path) /
404 session-missing / 409 stale-base / BOM round-trip / CRLF round-trip /
CR round-trip / temp-file-not-leaked / 10 MiB content cap. Includes
symlink-escape coverage on POSIX (skipped on Windows where symlink
creation needs elevation).
Desktop store:
- desktop/src/stores/workspacePanelStore.ts: bufferStateByTabId record,
WorkspaceBufferState/Conflict types, initBuffer / setBufferState /
applyExternalSave / acknowledgeConflict / clearBuffer actions.
applyExternalSave is the WS-driven entry point — clean buffers rebase
silently when content is supplied; dirty buffers raise a conflict
banner. acknowledgeConflict('reload') resets to base, 'keepMine' /
'openConflict' just dismiss the banner. closePreviewTabs and
clearSession now drop matching buffer state to prevent leaks.
Tested:
- bun test src/server/services/workspaceFileService.test.ts (17/17 pass)
- bun run lint (server tsc clean)
- bun run test src/stores/workspacePanelStore.test.ts (24/24 pass — store
extension is purely additive, R5 tests still green)
Note: pre-existing e2e/business-flow failures in src/server/__tests__/e2e
remain untouched by this change (44 fails on baseline, no new fails
introduced).
_Requirements: 1.5, 2.1-2.9, 3.1-3.3_
* feat(desktop): WorkspaceEditor + ConflictBanner + UnsavedChangesModal
Phase 2 UI pieces (tasks 8, 13, 14, 15 of editor-lsp-foundation):
- desktop/src/components/workspace/WorkspaceEditor.tsx: CodeMirror 6
editor wrapping the workspace panel buffer state. Hooks
EditorView.updateListener -> setBufferState for live dirty tracking,
picks language by extension (ts/tsx/js/jsx/json/md), wires Save to
sessionsApi.saveWorkspaceFile (R2 atomic write endpoint), refreshes
base hash on success, falls back to a read-only message when
detectEncoding returns 'unsupported'. External rebases (e.g. clean
buffer applyExternalSave) are pushed back into the EditorView via
dispatch.
- desktop/src/components/workspace/ConflictBanner.tsx: clean buffer ->
single Reload button; dirty buffer -> three buttons (Reload (discard),
Keep mine, Open conflict view). Renders workspace-relative path,
hash first 8 hex, relative timestamp refreshing every 60 s.
- desktop/src/components/workspace/UnsavedChangesModal.tsx: Discard /
Save / Cancel modal. Cancel is the default focus, Esc triggers it.
While saving, all three buttons disable and the host calls onSave
which only resolves close on success. 30 s in-prompt timeout fires
onTimeout (host owns the toast).
- desktop/src/components/workspace/WorkspaceEditor.test.tsx: 8 RTL
tests covering buffer init / encoding detection / unsupported
fallback / dirty marker / unsaved-changes modal flows / conflict
banner clean-vs-dirty layouts.
- desktop/src/api/sessions.ts: SaveWorkspaceFileInput +
SaveWorkspaceFileResult types and sessionsApi.saveWorkspaceFile
POST helper.
Bundle delta: +0.28 KB gz (CodeMirror 6 + 3 lang packs imported but
WorkspaceEditor is not yet wired into WorkspacePanel — that integration
ships in a follow-up PR alongside Phase 3 LSP work, keeping this PR
focused on the foundation).
Tested:
- bun run lint (tsc --noEmit clean)
- bun run test (workspacePanelStore 24/24, encodingDetect 18/18,
WorkspaceEditor 8/8, WorkspacePanel 27/27 — 77/77 across 4 files)
- bun run check:bundle-budget (delta +0.28 KB gz, 99.72 KB headroom)
- bun run build (clean, 1.20s)
_Requirements: 1.1-1.8, 3.2-3.5, 4.1-4.6_
---------
Co-authored-by: 你的姓名 <you@example.com>
153 lines
5.4 KiB
JSON
153 lines
5.4 KiB
JSON
{
|
|
"name": "claude-code-desktop",
|
|
"private": true,
|
|
"version": "0.5.10",
|
|
"description": "Desktop coding agent workbench for Claude Code Haha.",
|
|
"homepage": "https://github.com/706412584/cc-haha",
|
|
"author": {
|
|
"name": "NanmiCoder",
|
|
"email": "relakkes@gmail.com"
|
|
},
|
|
"type": "module",
|
|
"main": "electron-dist/main.cjs",
|
|
"build": {
|
|
"appId": "com.claude-code-haha.desktop",
|
|
"productName": "Claude Code Haha",
|
|
"asar": true,
|
|
"asarUnpack": [
|
|
"dist/**",
|
|
"node_modules/node-pty/**",
|
|
"src-tauri/binaries/**"
|
|
],
|
|
"artifactName": "Claude-Code-Haha-${version}-${os}-${arch}.${ext}",
|
|
"npmRebuild": false,
|
|
"directories": {
|
|
"output": "build-artifacts/electron"
|
|
},
|
|
"files": [
|
|
"dist/**",
|
|
"electron-dist/**",
|
|
"node_modules/node-pty/**",
|
|
"src-tauri/binaries/**",
|
|
"src-tauri/icons/**",
|
|
"src-tauri/resources/preview-agent.js",
|
|
"package.json"
|
|
],
|
|
"mac": {
|
|
"category": "public.app-category.developer-tools",
|
|
"target": [
|
|
"dmg",
|
|
"zip"
|
|
],
|
|
"icon": "src-tauri/icons/icon.icns",
|
|
"hardenedRuntime": true,
|
|
"gatekeeperAssess": false,
|
|
"entitlements": "build/entitlements.mac.plist",
|
|
"entitlementsInherit": "build/entitlements.mac.inherit.plist",
|
|
"notarize": true
|
|
},
|
|
"win": {
|
|
"target": "nsis",
|
|
"icon": "src-tauri/icons/icon.ico"
|
|
},
|
|
"nsis": {
|
|
"oneClick": false,
|
|
"allowElevation": true,
|
|
"allowToChangeInstallationDirectory": true,
|
|
"perMachine": false,
|
|
"deleteAppDataOnUninstall": false,
|
|
"createDesktopShortcut": true,
|
|
"createStartMenuShortcut": true,
|
|
"license": "build/license.txt"
|
|
},
|
|
"linux": {
|
|
"target": [
|
|
"AppImage",
|
|
"deb"
|
|
],
|
|
"icon": "src-tauri/icons",
|
|
"category": "Development",
|
|
"maintainer": "NanmiCoder <relakkes@gmail.com>"
|
|
},
|
|
"publish": [
|
|
{
|
|
"provider": "github",
|
|
"owner": "706412584",
|
|
"repo": "cc-haha"
|
|
}
|
|
]
|
|
},
|
|
"scripts": {
|
|
"dev": "vite",
|
|
"build": "bun run build:preview-agent && node ./node_modules/typescript/bin/tsc -b && node ./node_modules/vite/bin/vite.js build",
|
|
"prepare:node-pty": "bun run ./scripts/prepare-node-pty.ts",
|
|
"build:electron": "bun run prepare:node-pty && bun build ./electron/main.ts --outfile ./electron-dist/main.cjs --target node --format cjs --external electron --external node-pty && bun build ./electron/preload.ts --outfile ./electron-dist/preload.cjs --target node --format cjs --external electron && bun build ./electron/preview-preload.ts --outfile ./electron-dist/preview-preload.cjs --target node --format cjs --external electron",
|
|
"build:preview-agent": "bun run ./scripts/build-preview-agent.ts",
|
|
"build:sidecars": "bun run ./scripts/build-sidecars.ts",
|
|
"clean:electron-output": "bun run ./scripts/clean-electron-output.ts",
|
|
"build:macos-arm64": "bash ./scripts/build-macos-arm64.sh",
|
|
"build:windows-x64": "powershell -ExecutionPolicy Bypass -File ./scripts/build-windows-x64.ps1",
|
|
"build:linux-x64": "bash ./scripts/build-linux.sh",
|
|
"build:linux-arm64": "LINUX_ARCH=arm64 bash ./scripts/build-linux.sh",
|
|
"electron:dev": "bun run build:electron && bun run ./scripts/electron-dev.ts",
|
|
"electron:build": "bun run build:sidecars && bun run build && bun run build:electron",
|
|
"electron:package": "bun run clean:electron-output && bun run electron:build && bunx electron-builder --publish never",
|
|
"electron:package:dir": "bun run clean:electron-output && bun run electron:build && bunx electron-builder --dir --publish never",
|
|
"check:electron": "node ./node_modules/typescript/bin/tsc -p electron/tsconfig.json && bun test electron && bun run build:electron",
|
|
"preview": "vite preview",
|
|
"test": "vitest",
|
|
"test:ui": "vitest --ui",
|
|
"lint": "node ./node_modules/typescript/bin/tsc --noEmit",
|
|
"check:bundle-budget": "bun run scripts/check-bundle-budget.ts"
|
|
},
|
|
"dependencies": {
|
|
"@codemirror/autocomplete": "^6.20.3",
|
|
"@codemirror/commands": "^6.10.3",
|
|
"@codemirror/lang-javascript": "^6.2.5",
|
|
"@codemirror/lang-json": "^6.0.2",
|
|
"@codemirror/lang-markdown": "^6.5.0",
|
|
"@codemirror/language": "^6.12.3",
|
|
"@codemirror/search": "^6.7.0",
|
|
"@codemirror/state": "^6.6.0",
|
|
"@codemirror/view": "^6.43.1",
|
|
"@tailwindcss/typography": "^0.5.19",
|
|
"@types/dompurify": "^3.2.0",
|
|
"@xterm/addon-fit": "^0.11.0",
|
|
"@xterm/xterm": "^6.0.0",
|
|
"dompurify": "^3.3.3",
|
|
"electron-updater": "^6.8.3",
|
|
"html2canvas": "^1.4.1",
|
|
"katex": "^0.16.45",
|
|
"lucide-react": "^0.469.0",
|
|
"marked": "^15.0.7",
|
|
"mermaid": "^11.14.0",
|
|
"node-pty": "^1.1.0",
|
|
"prism-react-renderer": "^2.4.1",
|
|
"qrcode": "^1.5.4",
|
|
"react": "^18.3.1",
|
|
"react-diff-viewer-continued": "^4.2.0",
|
|
"react-dom": "^18.3.1",
|
|
"react-shiki": "^0.9.2",
|
|
"shiki": "^4.0.2",
|
|
"zustand": "^5.0.3"
|
|
},
|
|
"devDependencies": {
|
|
"@tailwindcss/vite": "^4.0.0",
|
|
"@testing-library/dom": "^10.4.1",
|
|
"@testing-library/jest-dom": "^6.6.3",
|
|
"@testing-library/react": "^16.1.0",
|
|
"@types/node": "^25.9.1",
|
|
"@types/react": "^18.3.18",
|
|
"@types/react-dom": "^18.3.5",
|
|
"@vitejs/plugin-react": "^6.0.1",
|
|
"@vitest/coverage-v8": "3.2.4",
|
|
"electron": "^42.3.0",
|
|
"electron-builder": "^26.8.1",
|
|
"jsdom": "^25.0.1",
|
|
"tailwindcss": "^4.0.0",
|
|
"typescript": "^5.9.3",
|
|
"vite": "^8.0.10",
|
|
"vitest": "^3.0.4"
|
|
}
|
|
}
|