Files
arcrun-collector/cmd/arcrun-app/build-dmg.sh
T
Leo 6bf0daa786 修首頁狀態說謊+DMG 補上拖曳版面(leo 08-05 封測回報 ①②)
## ② 首頁狀態是壞的
leo:「拖新的檔案進資料夾,完成本地萃取、上傳,但自始至終 daemon 的首頁都顯示
『有變動就自動開始』『等待中』,都顯示綠燈沒動,實際上已經做完了。」

兩個獨立的真兇:

**A. 「同步中」判斷用錯依據(回歸)**
t191 早就做好機制:collector 開工印 phase:"start"、跑完印 "done",
supervisor 據此維護 StateSyncing。**換 Wails 時 App 沒接這條線**,改看 sync-now 訊號檔:
  ① 訊號檔只有手動按「立刻同步」才產生 ⇒ 拖檔進資料夾(自動觸發)整輪不亮燈
  ② 就算手動按,collector 是**先刪檔再跑**(consumeSyncNowSignal)⇒ 真正在跑時檔早沒了
⇒ 改讀 sup.Status().State == StateSyncing。**接回既有機制,不發明第三種判斷法。**

**B. 做完的證據被下一輪抹掉**
ExtractedOK/ExtractFailed 是**本輪**計數、每輪覆寫整份 status.json
⇒ 有產出那輪寫下 N,十幾秒後空轉的一輪把它蓋成 0
⇒ 「上一輪 N 份」永遠空白、四步時間軸的綠燈只靠「跑過任何一輪」判斷=與實際進度脫鉤。
⇒ 新增 last_activity_{at,ok,failed}:有產出記本輪、空轉沿用上一輪(CarryForwardActivity)。
   首頁改顯示「幾點整理了幾份」,綠燈只在真的整理過東西時才亮。

## ① Mac DMG 少了「看得出要拖」的版面
leo:「要跳出虛擬隨身碟,打開一個 finder 的視窗,**顯示 Arcrun 和 Application 的捷徑**,
用戶把 App 拖進 Application」。
原本 DMG 內容是對的(Arcrun.app+Applications 捷徑),但**沒設版面**
⇒ 預設清單視圖、位置隨機,看不出「要往右拖」。
⇒ build-dmg.sh 改走 UDRW → Finder AppleScript 設大圖示/視窗大小/左右並排 → 轉 UDZO。
   best-effort:無桌面工作階段時只警告不中止(版面是加分,不該讓打包掛掉)。

⚠️ 真正讓 leo 拿到 zip 的原因不在這裡——是**線上 portal 還沒出貨**(見下)。

## 驗(實測輸出)
· collector 全測綠;新增 TestCarryForwardActivity 四子測(含「空轉不該抹掉上次成果」)
· 掛載 dist/Arcrun-v0.18.5.dmg 實查:
    內容剛好兩項(Arcrun.app + Applications→/Applications 捷徑)
    .DS_Store 6148 bytes(版面已存進去)
    Contents/MacOS/ 有 arcrun-app **和 arcrun-collector**
    CFBundleShortVersionString = 0.18.5(不是 1.0.0)/LSUIElement = true/codesign -v 通過
· 三支機械閘 check-cis/check-render/check-tray 全 PASS

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 18:01:17 +08:00

73 lines
3.2 KiB
Bash
Executable File
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.
#!/usr/bin/env bash
# build-dmg.sh — 打包成 Mac 標準安裝檔(t194,leo:「你應該包成 Mac 安裝檔,我完整做一次」)
#
# DMG 裡放 Arcrun.app Applications 捷徑 ⇒ 開啟就是「把 App 拖進去」的標準畫面。
# 為什麼一定要:使用者若直接在下載資料夾裡跑,自更新會蓋錯位置(t184 Oscar 的病);
# 而且 macOS 對「不在 /Applications 的常駐程式」權限行為也不一致。
set -euo pipefail
cd "$(dirname "$0")"
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
echo "① 先確保 .app 是最新的"
VERSION="$VERSION" bash build-mac.sh >/dev/null
APP="build/bin/Arcrun.app"
[ -d "$APP" ] || { echo "❌ 找不到 $APP" >&2; exit 1; }
OUT="dist"; DMG="$OUT/Arcrun-${VERSION}.dmg"
STAGE="$(mktemp -d)/Arcrun"
mkdir -p "$OUT" "$STAGE"
echo "② 放 app Applications 捷徑"
ditto "$APP" "$STAGE/Arcrun.app"
ln -s /Applications "$STAGE/Applications"
echo "③ 產可寫 DMG-fs HFS+:否則含空格/中文的名稱會被截斷)"
rm -f "$DMG"
RW="$(mktemp -d)/rw.dmg"
hdiutil create -volname "Arcrun" -srcfolder "$STAGE" -fs HFS+ -ov -format UDRW "$RW" >/dev/null
rm -rf "$(dirname "$STAGE")"
# ── ④ 排版面:讓「拖進去」這件事一眼可見 ────────────────────────────────────
# 🔴 leo 2026-08-05:「要跳出虛擬隨身碟,打開一個 finder 的視窗,**顯示 Arcrun 和
# Application 的捷徑**,用戶把 App 拖進 Application」。
# 光是「裡面有兩個項目」不夠——預設是清單視圖、位置隨機,使用者看不出「要往右拖」。
# ⇒ 設成大圖示、固定視窗大小、兩個 icon 左右並排。
# best-effortFinder 自動化在沒有桌面工作階段時(ssh/CI)會失敗,
# 失敗只警告不中止——版面是加分,DMG 本身照樣可用,不該讓打包整個掛掉。
hdiutil attach "$RW" -noautoopen -quiet
if osascript <<'APPLESCRIPT' >/dev/null 2>&1
tell application "Finder"
tell disk "Arcrun"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {200, 160, 800, 560}
set vopts to the icon view options of container window
set arrangement of vopts to not arranged
set icon size of vopts to 128
set position of item "Arcrun.app" of container window to {150, 190}
set position of item "Applications" of container window to {450, 190}
update without registering applications
close
end tell
end tell
APPLESCRIPT
then
echo " ✅ 版面已設定(大圖示,Arcrun 在左、Applications 在右)"
else
echo " ⚠️ Finder 版面設定失敗(多半是沒有桌面工作階段)——DMG 仍可用,只是視圖是預設值" >&2
fi
sync
hdiutil detach "/Volumes/Arcrun" -quiet
echo "⑤ 壓成唯讀發佈檔"
hdiutil convert "$RW" -format UDZO -o "$DMG" >/dev/null
rm -rf "$(dirname "$RW")"
SIZE=$(ls -lh "$DMG" | awk '{print $5}')
echo "✅ 完成:${DMG}${SIZE}"
echo
echo "🔬 使用者流程:開 DMG → 把 Arcrun 拖到 Applications → 退出這個虛擬磁碟 → 從啟動台開啟"