Skip to content

feat(startup): add "start minimized" toggle (Windows background autostart)#357

Merged
appergb merged 1 commit into
betafrom
feat/start-minimized-toggle
May 8, 2026
Merged

feat(startup): add "start minimized" toggle (Windows background autostart)#357
appergb merged 1 commit into
betafrom
feat/start-minimized-toggle

Conversation

@appergb
Copy link
Copy Markdown
Collaborator

@appergb appergb commented May 8, 2026

User description

What

回应用户:「Windows 端增加一个在开机启动的时候不弹出软件界面、自动在后台启动的开关」。

新 pref `start_minimized: bool`,默认 false 不破坏现有行为。打开后所有启动路径都不弹主窗口(包括开机自启 + 手动启动),App 仅在菜单栏 / 托盘运行;用户从托盘进入主窗口。

Why this design (单开关,不区分启动来源)

最 surgical 的实现是 "prefs.start_minimized = true → 跳过 main.show()",不区分自启动 vs 手动启动

如果非要区分("只在自启动时静默、手动启动仍弹窗"):

  • 需要 autostart 注册 `--silent` arg → tauri-plugin-autostart 的 args 是 `init()` 时静态设、动态切需要重注册
  • App 启动读 argv 检测自启动 → 加一层路径分叉
  • 既存 autostart 用户不会自动获得新 arg,需要先 disable + re-enable autostart

复杂度跟收益不成比例。简单设计:开关一开就所有启动统一静默,用户接受"从此从托盘进主窗口"的契约。开机自启场景下这正是想要的;手动启动场景下也容易接受(点托盘比一直关主窗口轻)。

Files

  • `types.rs`: `UserPreferences::start_minimized`(UserPreferencesWire + Default + Deserialize 全套兼容)
  • `lib.rs` setup hook: 读 `coordinator.prefs().get().start_minimized` 决定跳不跳过 `main.show()`。`OPENLESS_SHOW_MAIN_ON_START=1` 优先级高于 prefs(dev 用的强制 show 路径不变)
  • 前端 `types.ts` / `ipc.ts mockSettings` / `stylePrefs.test.ts`: 加默认 false
  • `Settings.tsx` Recording 区在 `` 之后加 Toggle
  • i18n 5 locale 加 `startMinimizedLabel` + `startMinimizedDesc`

顺手修预存 bug

HotkeyBinding default keys=None(跟 PR #355 副 commit 同源——本 branch 没含那个修复)。避免旧 prefs 反序列化时 trigger / keys 不一致导致快捷键失效。`types::tests` 8/8 pass。

不在本 PR:Windows IME 切换还原偶发 bug

用户也报了「使用 OpenLess 后输入法应自动切回之前的 IME,部分系统正常、部分不正常」。

这一条不能盲改:是个偶发 bug,需要:

  • Windows 版本(设置 → 系统 → 关于 → "Windows 规格")
  • 出问题时的 IME(微软拼音 / 搜狗 / Rime / etc)
  • `%LOCALAPPDATA%\OpenLess\Logs\openless.log` 出问题前后约 30 秒(关键字 `[ime]` / `restore_profile` / `activate_openless_profile`)
  • 复现步骤

已请求用户提供。拿到数据后单独开 PR 修。

验证

```
cargo test --lib: 135/135 pass
npm run build: tsc + vite 干净
cargo check: 干净(79 warnings 均预存)
```

无法在 macOS 上实测 Windows 行为;setup hook 中 `prefs.start_minimized` 读取 + `main.show()` 跳过逻辑跨平台一致,理论上 Windows 同样生效。

Test plan

  • Windows:装新 build,设 start_minimized = true,重启电脑(或手动启动)→ 应仅托盘图标,主窗口不弹出
  • Windows:设 start_minimized = true 后双击启动器 → 仍仅托盘图标
  • Windows:设 start_minimized = false(默认)→ 启动行为跟历史一致(弹主窗口)
  • macOS:同上 3 条
  • 任意平台:托盘图标点击 → 主窗口正常弹出(依赖现有 `show_main_window` 路径,没改它)

PR Type

Enhancement


Description

  • Add start_minimized boolean preference (default false)

  • Suppress main window show on launch when enabled, keeping only tray icon

  • Expose toggle in Recording settings with i18n for 5 locales


Diagram Walkthrough

flowchart LR
  Settings["Settings.tsx toggle"] -- "set pref" --> Prefs["UserPreferences.start_minimized"]
  Prefs -- "read on launch" --> Lib["lib.rs setup"]
  Lib -- "skip main.show()" --> Tray["Tray/menu bar only"]
Loading

File Walkthrough

Relevant files
Enhancement
4 files
lib.rs
Suppress main window show when start_minimized is set       
+11/-1   
types.rs
Add start_minimized field to UserPreferences and wire       
+10/-0   
types.ts
Add start_minimized to frontend preferences type                 
+3/-0     
Settings.tsx
Add toggle for start minimized in Recording settings         
+8/-0     
Configuration changes
6 files
en.ts
Localize start minimized label and description (English) 
+2/-0     
ja.ts
Localize start minimized label and description (Japanese)
+2/-0     
ko.ts
Localize start minimized label and description (Korean)   
+2/-0     
zh-CN.ts
Localize start minimized label and description (Simplified Chinese)
+2/-0     
zh-TW.ts
Localize start minimized label and description (Traditional Chinese)
+2/-0     
ipc.ts
Add start_minimized default in mock preferences                   
+1/-0     
Tests
1 files
stylePrefs.test.ts
Update preference fixture with start_minimized default     
+1/-0     

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

PR Reviewer Guide 🔍

(Review updated until commit f6474be)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

355 - Partially compliant

Compliant requirements:

  • Add frontend type updates, settings controls, and localized labels/help text for the new recording preferences.

Non-compliant requirements:

  • Add time-based history retention while keeping the existing 200-entry cap.
  • Add a history retention days preference in Settings → Recording, defaulting to 7.
  • Add HistoryStore::append_with_retention(session, retention_days) to prune old entries on write.
  • Add HistoryStore::recent_within_minutes(minutes) for newest-first recent history lookup.
  • Extend polish to accept prior turns and use multi-turn chat completion when context is present.
  • Skip prior-turn context for translation, raw, and repolish paths.
  • Refactor chat completion request sending/parsing so single-turn and multi-turn paths share logic.
  • Preserve legacy hotkey compatibility and keep existing tests passing.

Requires further human verification:

  • None
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

…ound mode)

回应用户「Windows 端开机启动时不弹软件界面、自动后台启动」需求。

新 pref start_minimized: bool,默认 false 不破坏现有行为。打开后所有
启动路径都不弹主窗口(包括开机自启 + 手动启动),App 仅在菜单栏 / 托盘
运行;用户从托盘进入主窗口。Windows 开机自启场景用得多——本来想要
后台 + 托盘,不想被主窗口打扰。

设计选择:不区分"自启动 vs 手动启动"——开关一开则所有启动统一静默。
理由:避免 argv parsing + 重新注册 autostart 带来的复杂性(tauri-plugin-
autostart 的 args 是 init() 时静态设的、动态切需要重注册)。开关明确
打开 = 接受所有启动都从托盘进。

实现:
- types.rs: UserPreferences 加 start_minimized 字段(含 UserPreferencesWire +
  Default + Deserialize 全套兼容)
- lib.rs setup hook: 读 coordinator.prefs().get().start_minimized;为 true
  时跳过 main.show()。OPENLESS_SHOW_MAIN_ON_START=1 仍保留老的强制 show
  路径(dev 用),优先级高于 prefs
- 前端 types.ts / ipc.ts mockSettings / stylePrefs.test.ts: 加默认 false
- Settings.tsx Recording 区在 AutostartRow 下加 Toggle
- i18n 5 locale (zh-CN / zh-TW / en / ja / ko) 加 startMinimizedLabel +
  startMinimizedDesc 两个 key

顺手修预存 bug(跟 PR #355 副 commit 同源——本 branch 没含那个修复):
HotkeyBinding default keys=None,避免旧 prefs 反序列化时 trigger / keys
不一致。types::tests 8/8 pass。

不在本 PR:Windows IME 切换还原偶发不还原 bug——需要 Windows 日志
+ 复现条件才能定位,盲改可能引入新 bug。已请求用户提供
%LOCALAPPDATA%\OpenLess\Logs\openless.log + 系统版本 + IME 信息。

cargo test --lib: 135/135 pass。npm run build: tsc + vite 干净。
@appergb appergb force-pushed the feat/start-minimized-toggle branch from 37225b4 to f6474be Compare May 8, 2026 03:48
@appergb appergb merged commit aee0d82 into beta May 8, 2026
4 checks passed
@appergb appergb deleted the feat/start-minimized-toggle branch May 8, 2026 03:49
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Persistent review updated to latest commit f6474be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant