Files
claude-pet/package.json
T
JianMiauandClaude Fable 5 7e2f689f26 修正開啟追視後 renderer 崩潰,追視改為只在待機時生效
摘要:
startAnim 對 look 會丟 TypeError 導致動畫迴圈整個死掉;另把追視改成只在 idle 時覆蓋。

根本原因:
1. 追視是單一靜態擺姿,TIMINGS 裡沒有 look 這個動作。但序列模型改寫後,
   tick 在動畫改變時無條件呼叫 startAnim(anim),傳入 "look" 時會走到
   cycleOf("look") → TIMINGS["look"].map → TypeError。
   例外從 requestAnimationFrame 的 callback 拋出,迴圈就此中止,
   整隻寵物凍結,也不再回應任何 hook 事件——就是使用者回報的「直接沒反應」。
2. 對照 Codex 時把 lookFrame 改成覆蓋所有狀態。但 Codex 的追視來源是 quick chat 的
   文字游標,只有使用者真的在打字時才存在;滑鼠卻是一直都在,照搬會讓工作中的
   running / waiting / review 動畫永遠被靜態擺姿蓋掉,寵物失去反映狀態的作用。

影響:
選單一勾「跟著游標看」,游標一動寵物就完全凍結,且不會恢復。

修法:
- startAnim 開頭對 look 早退,直接設成空的幀序列(靜態擺姿),
  不進入 cycleOf / baseSequence。draw 本來就單獨處理 look,tick 的推幀也已排除 look。
- resolveAnim 先取 baseState(),只有 base 為 idle 時才回傳 look;
  一併避免原本重複呼叫 baseState() 的副作用。
- README 的特色、行為對照表、與 Codex 的對照三處同步更新,
  對照表把「追視」拆成來源與優先序兩列並說明為何刻意不同。

不動的部分:
hover 跳躍維持進入時播 3 次、之後停住不再跳(使用者確認就是要這個行為)。
另已確認跳躍結束後會回到當下的基礎狀態而非一律 idle。

驗證:
- 單元測試(抽出實際程式碼執行):修正前 startAnim("look") 拋
  TypeError: Cannot read properties of undefined (reading 'map'),修正後回傳空序列;
  idle 6 幀、running 24 幀正常;resolveAnim 在追視開啟下
  idle→look、running→running、waiting→waiting、review→review,
  hover 跳躍優先於 look 與 running,跳躍結束回到 running 而非 idle,共 11 項全過。
- 實機開啟 followCursor 啟動:/state 持續回應且 anim 為 look(修正前此處即崩潰),
  log 無任何例外;灌入事件後 running / waiting 正確蓋過追視。
- 以 ELECTRON_RUN_AS_NODE 讀打包後 app.asar:版本 2.0.2、崩潰修正與追視優先序都在,
  hover 跳躍、矩形判定、右鍵選單未受影響;exe FileVersion 為 2.0.2。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 16:48:43 +08:00

90 lines
2.2 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"name": "claude-pet",
"version": "2.0.2",
"description": "Codex Pets 相容的 Claude Code 桌面寵物(spriteVersionNumber 29 個動作列 + 16 方向追視)",
"main": "main.js",
"private": true,
"scripts": {
"start": "electron .",
"hooks:install": "node scripts/install-hooks.js",
"hooks:uninstall": "node scripts/uninstall-hooks.js",
"autostart:install": "node scripts/autostart.js install",
"autostart:uninstall": "node scripts/autostart.js uninstall",
"autostart:status": "node scripts/autostart.js status",
"predist": "npm version patch --no-git-tag-version",
"dist": "electron-builder --win",
"pack": "electron-builder --win --dir",
"predist:portable": "npm version patch --no-git-tag-version",
"dist:portable": "electron-builder --win portable"
},
"devDependencies": {
"electron": "^43.4.1",
"electron-builder": "^26.0.12"
},
"author": "JianMiau",
"build": {
"appId": "com.jianmiau.claude-pet",
"productName": "Claude Pet",
"copyright": "JianMiau",
"directories": {
"output": "dist",
"buildResources": "build"
},
"files": [
"main.js",
"preload.js",
"renderer/**/*",
"lib/**/*",
"hook/**/*",
"package.json"
],
"asarUnpack": [
"hook/**/*"
],
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
},
{
"target": "portable",
"arch": [
"x64"
]
},
{
"target": "zip",
"arch": [
"x64"
]
}
],
"icon": "build/icon.ico"
},
"nsis": {
"oneClick": false,
"perMachine": false,
"allowToChangeInstallationDirectory": true,
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"shortcutName": "Claude Pet",
"deleteAppDataOnUninstall": false,
"artifactName": "${productName}-${version}-setup.${ext}"
},
"portable": {
"artifactName": "${productName}-${version}-portable.${ext}",
"unpackDirName": "ClaudePet",
"requestExecutionLevel": "user"
},
"extraFiles": [
{
"from": "pets",
"to": "pets"
}
]
}
}