fix(local-agent): AutoOpenBrowser 預設改 false,啟動不自動開瀏覽器
使用者: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) <noreply@anthropic.com>
This commit is contained in:
parent
df082ed308
commit
8270c4fb0e
@ -15,16 +15,17 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preferences 定義控制台偏好。
|
// Preferences 定義控制台偏好。
|
||||||
// 對應 TDD v2/control-panel.md §4.3 的 Preferences struct。
|
// 對應 TDD v2/control-panel.md §4.3 的 Preferences struct。
|
||||||
type Preferences struct {
|
type Preferences struct {
|
||||||
// AutoOpenBrowser — StartServer 成功後是否自動開瀏覽器。
|
// AutoOpenBrowser — StartServer 成功後是否自動開瀏覽器。
|
||||||
// 預設值由 DefaultPreferences() 依 runtime.GOOS 決定:
|
// 預設值由 DefaultPreferences() 決定:所有平台一律 false。
|
||||||
// macOS / Windows → true
|
// 桌面 GUI 本身就是主要操作介面,不需要啟動時自動彈瀏覽器分頁;
|
||||||
// Linux → false (R5-D2:Linux 桌面環境差異大,預設關)
|
// 使用者若要用雲端 Web UI,自行前往雲端網頁即可。
|
||||||
|
// (改預設 false 只影響全新安裝 / 無 preferences.json 的使用者;
|
||||||
|
// 既有使用者的 preferences.json 已明確存有此欄位,Load 時尊重既有值。)
|
||||||
AutoOpenBrowser bool `json:"autoOpenBrowser"`
|
AutoOpenBrowser bool `json:"autoOpenBrowser"`
|
||||||
|
|
||||||
// Locale — 控制台 UI 的語系覆寫;空字串 → 自動偵測(navigator.language)
|
// Locale — 控制台 UI 的語系覆寫;空字串 → 自動偵測(navigator.language)
|
||||||
@ -34,12 +35,14 @@ type Preferences struct {
|
|||||||
LogRingSize int `json:"logRingSize,omitempty"`
|
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 {
|
func DefaultPreferences() Preferences {
|
||||||
return Preferences{
|
return Preferences{
|
||||||
AutoOpenBrowser: runtime.GOOS != "linux",
|
AutoOpenBrowser: false,
|
||||||
Locale: "",
|
Locale: "",
|
||||||
LogRingSize: 0,
|
LogRingSize: 0,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,9 +12,9 @@ import (
|
|||||||
|
|
||||||
func TestDefaultPreferences_PlatformSpecific(t *testing.T) {
|
func TestDefaultPreferences_PlatformSpecific(t *testing.T) {
|
||||||
p := DefaultPreferences()
|
p := DefaultPreferences()
|
||||||
wantOpen := runtime.GOOS != "linux"
|
// 桌面 GUI 為主要介面,所有平台一律預設不自動開瀏覽器。
|
||||||
if p.AutoOpenBrowser != wantOpen {
|
if p.AutoOpenBrowser != false {
|
||||||
t.Fatalf("DefaultPreferences.AutoOpenBrowser=%v on %s, want %v", p.AutoOpenBrowser, runtime.GOOS, wantOpen)
|
t.Fatalf("DefaultPreferences.AutoOpenBrowser=%v on %s, want false", p.AutoOpenBrowser, runtime.GOOS)
|
||||||
}
|
}
|
||||||
if p.Locale != "" {
|
if p.Locale != "" {
|
||||||
t.Fatalf("default Locale=%q, want empty", p.Locale)
|
t.Fatalf("default Locale=%q, want empty", p.Locale)
|
||||||
|
|||||||
@ -35,7 +35,7 @@ func newPipelineTestApp(t *testing.T) (*App, string) {
|
|||||||
}
|
}
|
||||||
t.Cleanup(func() { _ = os.RemoveAll(dir) })
|
t.Cleanup(func() { _ = os.RemoveAll(dir) })
|
||||||
a.dataDir = dir
|
a.dataDir = dir
|
||||||
a.prefs = DefaultPreferences() // macOS/Windows: AutoOpenBrowser=true
|
a.prefs = DefaultPreferences() // 所有平台 AutoOpenBrowser=false(測試各自需要 true 時自行覆寫)
|
||||||
return a, dir
|
return a, dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user