visionA/local-tool
jim800121chen 06ff2fe987 feat(local-tool): M9-4 — Frontend FW badge + 升級 modal + WS hot-fix
A 階段第四個 milestone、完整 Frontend FW UI(badge / modal / 8 種 reason 復原)+ backend WS hot-fix(補對稱於 flash 的 firmware WS endpoint)。

Frontend(13 修改 / 7 新檔):
- 新 firmware/ component group (badge / upgrade-button / upgrade-dialog 4-phase / progress-view / error-view 8-reason / index)
- Zustand store (firmware-store.ts) + WS hook (use-firmware-progress.ts) 對齊既有 useFlashProgress pattern
- DeviceCard 整合 FirmwareBadge + FirmwareUpgradeButton
- i18n: settings.firmware.* namespace (對齊 Design Spec §9 SoT) + devices.card.fwBadge.* (zh-TW + en, 57 leaf keys × 2 lang = 114 strings)
- toast.ts ToastOptions interface (duration param)
- types/device.ts: FW 衍生欄位 + FirmwareStage/Reason/ProgressEvent/ActiveTask types

Backend WS hot-fix (3 檔):
- ws/firmware_ws.go (50 行、純對稱 flash_ws.go)
- ws/firmware_ws_test.go (165 行、2 smoke tests: broadcast + room isolation)
- router.go: GET /ws/devices/:id/firmware-progress

關鍵設計:
- R-FW-11 緩解: upgrading phase modal 不可關 (onInteractOutside/onEscapeKeyDown preventDefault + 隱藏 X)
- 多裝置隔離 defense in depth: store handleEvent activeDeviceId mismatch 直接 return
- 8 種 reason → 4 種 UX (recoverable/destructive/brick 警告/contactSupport)
- ContactSupport mailto handler (RFC 6068 + encodeURIComponent)

Reviewer 兩輪審查:
- Round 1: 0 Critical / 3 Major / 8 Minor / 5 Suggestion
- Round 2: 0 Critical / 0 Major / 0 Minor / 2 Suggestion(接受方案 A、不需 frontend 第 3 輪)
- MJ1 i18n namespace 採方案 A (settings.firmware.*)、Design SoT 優先、Reviewer 同意

測試:
- pnpm test --run: 60 tests pass (32 firmware: 22 store + 10 badge + 新 9 error-view + 19 既有)
- npx tsc --noEmit: 0 error
- pnpm build: production build 成功
- go test ./internal/api/ws/... -race: 1.964s 全綠
- pnpm lint firmware/: 0 hit (17 既有 lint 問題不屬 M9-4、follow-up)

未做(範圍外):
- Settings 韌體面板 (M9-12 B 階段)
- 手動降版 UI (M9-12)
- 版本切換 dropdown (B 階段)
- Wails 控制台 force-quit modal (M9-4.5)

A 階段 MVP 後端 + 前端開發全部完成、剩 M9-4.5 (SIGTERM + Wails OnBeforeClose) + M9-5 (三平台實機驗證)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 12:57:21 +08:00
..

visionA-local

裝起來像一般 app離線也能跑接上 Kneron 就推論。edge-ai-platform 的 Kneron AI 邊緣推論能力,打包成單機桌面應用。

macOS x86_64 Windows x86_64 Linux x86_64 License


這是什麼

visionA-local 是 edge-ai-platform(原本要部署到 EC2 + Docker 的 Kneron 邊緣推論平台)的單機桌面衍生版本。為「帶著筆電做 Kneron demo 的人」而生 —— 主要服務 Innovedus 內部 FAE 與外部 Kneron 開發者。

三個核心承諾:

  • 🎒 零依賴Python runtime、KneronPLUS SDK、ffmpeg、預置 .nef 模型全部內嵌
  • ✈️ 零網路:下載一次後完全離線可用(適合客戶現場 IT 鎖得死緊的場景)
  • 🖱️ 零學習成本:雙擊安裝 → 開啟 → 插上 Kneron 裝置 30 秒內跑出第一幀推論

對標產品Docker Desktop、Ollama。


安裝(使用者)

macOSx86_64beta

  1. 從內部 Gitea Releases 下載 visiona-local.dmg
  2. 雙擊開啟 dmg → 把 visionA-local.app 拖到 Applications/
  3. 第一次啟動因為未做程式碼簽章Gatekeeper 會警告「來自未識別開發者」
    • 在 Finder 中右鍵點 visionA-local.app → 選「開啟」(不是雙擊)
    • 對話框出現「仍要開啟」時點確認
    • 往後直接雙擊即可
  4. 首次啟動會花 3060 秒解壓內嵌的 Python runtime 並離線安裝 wheels 這是預期行為,不是卡住。之後啟動只要幾秒

📁 資料目錄:~/Library/Application Support/visiona-local/ 包含 log、lock、ipc-port、自上傳模型

Windows / Linux

Coming soon — build script 已經寫好,等 CI runner 齊備後就會釋出。

  • WindowsInno Setup .exe installer
  • Linux.AppImage + udev rules需 root 裝 99-kneron.rules

系統需求

平台 最低版本 架構
macOS 14 Sonoma x86_64 ¹
Windows 10 1809 x86_64
Ubuntu 22.04 x86_64

¹ Apple Silicon 理論上可透過 Rosetta 2 執行,但未經測試

離線可用:安裝後所有核心功能(包含 Python sidecar、推論、模型管理、攝影機、影片解碼完全不需要網路。


功能總覽

有的功能

  • 裝置管理USB 自動偵測 Kneron KL520 / KL72010 秒內連線
  • 攝影機推論MJPEG 串流 + 即時 overlay首次延遲 ≤ 250ms穩定後 ≤ 150ms
  • 模型管理8 個預置 .nef 模型(分類 / 偵測 / 臉辨)+ 自上傳切換
  • 核心推論引擎image classification、object detection、face recognition
  • 媒體推論支援圖片與影片檔本機上傳R5 決策後不支援 URL 推論)
  • 中英雙語,跟隨系統 Dark Mode

不做的事(明確排除)

為了聚焦「個人工具」,以下功能從 edge-ai-platform 全數砍掉:

  • Cluster多裝置叢集
  • Relay / Tunnel遠端連線、反向代理
  • 韌體燒錄firmware flash
  • 系統列 Tray 常駐
  • Auto-update
  • Telemetry / 崩潰回報
  • License 啟用、憑證簽章
  • Mac App Store / Microsoft Store / Snap Store 上架

開發者區

專案結構

local-tool/
├── .autoflow/        PRD / 設計 / 架構 / 進度文件
├── server/           Go 1.26 後端Gin + go:embed
├── frontend/         Next.js 16 + React 19 + shadcn
├── visiona-local/    Wails 應用殼installer
├── payload/          打包暫存區
├── vendor/           第三方依賴make vendor-sync 下載,不進 git
├── dist/             最終安裝檔(.dmg / .exe / .AppImage
├── installer/        Inno Setup / AppImage script
├── scripts/          build 與維運腳本
└── Makefile

開發流程

# 1. 下載全部第三方依賴到 vendor/
make vendor-sync

# 2. 本機 build 並產出 dmgmacOS
make dmg

# 查看所有可用 targets
make help

主要 make targets

Target 作用
vendor-sync 下載 python-build-standalone、wheels、ffmpeg
build-server 編譯 Go server binary先 build frontend + embed
build-frontend pnpm build Next.js 靜態產物
payload-macos 準備 macOS payloadbinary + python + wheels + ffmpeg + 模型)
wails-macos Wails build + ad-hoc codesign
dmg 產出 dist/visiona-local.dmg
exe Windows installer需在 Windows runner 執行)
appimage Linux AppImage需在 Linux runner 執行)

三方平台 build

平台 指令 執行環境
macOS make dmg 本機Intel Mac
Windows make exe Windows runner + Inno Setup 6
Linux make appimage Ubuntu 22.04+ runner + appimagetool

vendor-*-windows / vendor-*-linux 可在 macOS 上跑通(只有 wails-* 和最後一步 installer 需要對應平台)。

文件位置

所有設計與架構文件在 .autoflow/

類型 路徑
產品需求PRD .autoflow/02-prd/PRD.md
設計規格 .autoflow/03-design/
架構設計 .autoflow/04-architecture/design-doc.md
TDD .autoflow/04-architecture/TDD.md
進度 .autoflow/progress.md

已知限制與 TODO

  • 🟡 Kneron 預置模型 re-distribution 授權:開發階段假設可用,正式發佈前需與 Kneron 官方確認
  • 🟡 Windows / Linux 安裝檔build script 就緒,等 CI runner 齊備
  • 🟡 Apple Silicon 未經測試(理論上 Rosetta 2 可跑)
  • 🟡 Linux Kneron USB vendor IDinstaller/linux/99-kneron.rules 需最終確認
  • 🟡 程式碼簽章Developer ID / EV cert不做,使用者需手動繞過 Gatekeeper / SmartScreen
  • 🟡 無 auto-update:新版需手動從 Gitea 下載

授權

License: TBD(內部工具 / MIT / proprietary 待定,發佈前確認)

第三方元件授權

元件 授權 備註
ffmpeg LGPL v3(方案 B 混合macOS 自 build decoder-only / Windows & Linux 用 BtbN n7.1 LGPL v2 TDD §2.2
KneronPLUS SDK Kneron 商用條款 再次確認 re-distribution 權利
python-build-standalone MPL 2.0 / PSFL
Python 標準函式庫 PSFL
shadcn/ui MIT
Next.js / React MIT
Wails MIT
Gin MIT

完整第三方授權清單於 .autoflow/02-prd/PRD.md §4.8。


致謝 / 起源

visionA-local 衍生自 Innovedus 內部專案 edge-ai-platform(原為部署於 EC2 + Docker 的多人共享平台)。本專案將其改造為單機桌面版本,聚焦「一個人帶一台筆電」的使用場景。

感謝 Kneron、python-build-standaloneastral-sh、shadcn 等開源社群。