From 8270c4fb0eca48b11d14461c2cac16b1483a228c Mon Sep 17 00:00:00 2001 From: jim800121chen Date: Mon, 3 Aug 2026 12:35:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(local-agent):=20AutoOpenBrowser=20=E9=A0=90?= =?UTF-8?q?=E8=A8=AD=E6=94=B9=20false=EF=BC=8C=E5=95=9F=E5=8B=95=E4=B8=8D?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E9=96=8B=E7=80=8F=E8=A6=BD=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用者:local-agent 啟動不需自動開網頁、桌面 GUI 為主。DefaultPreferences 的 AutoOpenBrowser 從 runtime.GOOS!="linux"(mac/win=true)改為所有平台 false。 只影響全新安裝(既有 preferences.json 有明確 autoOpenBrowser 值、Unmarshal 保留,尊重既有設定)。false 分支既有邏輯(SkipStage5 / 不檢查 timeout)未動。 codebase 本就無桌面「Open in Browser」按鈕(DEPRECATED、雲端 UI 遠端設計), 改預設沒弄丟任何手動能力。 reviewer 通過(0C/0M)。build/vet/test 全綠。 Co-Authored-By: Claude Opus 4.8 (1M context) --- local-agent/visiona-agent/preferences.go | 17 ++++++++++------- local-agent/visiona-agent/preferences_test.go | 6 +++--- .../visiona-agent/startup_pipeline_test.go | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/local-agent/visiona-agent/preferences.go b/local-agent/visiona-agent/preferences.go index 52c5b3f..6a22229 100644 --- a/local-agent/visiona-agent/preferences.go +++ b/local-agent/visiona-agent/preferences.go @@ -15,16 +15,17 @@ import ( "fmt" "os" "path/filepath" - "runtime" ) // Preferences 定義控制台偏好。 // 對應 TDD v2/control-panel.md §4.3 的 Preferences struct。 type Preferences struct { // AutoOpenBrowser — StartServer 成功後是否自動開瀏覽器。 - // 預設值由 DefaultPreferences() 依 runtime.GOOS 決定: - // macOS / Windows → true - // Linux → false (R5-D2:Linux 桌面環境差異大,預設關) + // 預設值由 DefaultPreferences() 決定:所有平台一律 false。 + // 桌面 GUI 本身就是主要操作介面,不需要啟動時自動彈瀏覽器分頁; + // 使用者若要用雲端 Web UI,自行前往雲端網頁即可。 + // (改預設 false 只影響全新安裝 / 無 preferences.json 的使用者; + // 既有使用者的 preferences.json 已明確存有此欄位,Load 時尊重既有值。) AutoOpenBrowser bool `json:"autoOpenBrowser"` // Locale — 控制台 UI 的語系覆寫;空字串 → 自動偵測(navigator.language) @@ -34,12 +35,14 @@ type Preferences struct { LogRingSize int `json:"logRingSize,omitempty"` } -// DefaultPreferences 回傳平台相關的預設值。 +// DefaultPreferences 回傳預設值。 // -// R5-D2:Linux 預設關 AutoOpenBrowser;macOS/Windows 預設開。 +// AutoOpenBrowser 一律預設 false:桌面 GUI 為主要介面,啟動時不自動開瀏覽器; +// 使用者若要用雲端 Web UI 自行前往雲端網頁。 +// (原本 macOS/Windows 預設 true、Linux 預設 false;現統一為 false。) func DefaultPreferences() Preferences { return Preferences{ - AutoOpenBrowser: runtime.GOOS != "linux", + AutoOpenBrowser: false, Locale: "", LogRingSize: 0, } diff --git a/local-agent/visiona-agent/preferences_test.go b/local-agent/visiona-agent/preferences_test.go index 6221d9d..b74a0b7 100644 --- a/local-agent/visiona-agent/preferences_test.go +++ b/local-agent/visiona-agent/preferences_test.go @@ -12,9 +12,9 @@ import ( func TestDefaultPreferences_PlatformSpecific(t *testing.T) { p := DefaultPreferences() - wantOpen := runtime.GOOS != "linux" - if p.AutoOpenBrowser != wantOpen { - t.Fatalf("DefaultPreferences.AutoOpenBrowser=%v on %s, want %v", p.AutoOpenBrowser, runtime.GOOS, wantOpen) + // 桌面 GUI 為主要介面,所有平台一律預設不自動開瀏覽器。 + if p.AutoOpenBrowser != false { + t.Fatalf("DefaultPreferences.AutoOpenBrowser=%v on %s, want false", p.AutoOpenBrowser, runtime.GOOS) } if p.Locale != "" { t.Fatalf("default Locale=%q, want empty", p.Locale) diff --git a/local-agent/visiona-agent/startup_pipeline_test.go b/local-agent/visiona-agent/startup_pipeline_test.go index b03b329..a16e216 100644 --- a/local-agent/visiona-agent/startup_pipeline_test.go +++ b/local-agent/visiona-agent/startup_pipeline_test.go @@ -35,7 +35,7 @@ func newPipelineTestApp(t *testing.T) (*App, string) { } t.Cleanup(func() { _ = os.RemoveAll(dir) }) a.dataDir = dir - a.prefs = DefaultPreferences() // macOS/Windows: AutoOpenBrowser=true + a.prefs = DefaultPreferences() // 所有平台 AutoOpenBrowser=false(測試各自需要 true 時自行覆寫) return a, dir }