feat: sync provider config to tray surfaces - #164
Open
JaminYe wants to merge 5 commits into
Open
Conversation
抽出可测试的主托盘投影,按顺序/禁用/隐藏/加星/置顶决定图标与 tooltip;配置入口统一走最新状态胜出的同步队列,tooltip 按 UTF-16 容量整行截断并本地化。
错误回退 3 分钟内不标 stale;patchConfig 按未改字段合并 set_config 返回值,避免覆盖更新的内存配置。
先应用 strip,再按真实结果投影主图标;失败时拆掉残留 icon,last_main_tray 仅在原生成功后写入。
clear 成功才清空 last_strip,同序重试走右到左全量重建;clear 失败则保留缓存,错误仍返回调用方。
Comment on lines
+522
to
+528
| Object.assign(config, patch); | ||
| // Send a full current snapshot. If an earlier serialized write failed, | ||
| // the next save retries that still-live in-memory state as well. | ||
| const payload = JSON.parse(JSON.stringify(config)) as Config; | ||
| const save = configSaveQueue.then(async () => { | ||
| const echoed = await invoke<Config>("set_config", { patch: payload }); | ||
| applyConfigEcho(payload, echoed); |
Contributor
There was a problem hiding this comment.
🔴 Start with Windows toggle silently reverts
patchConfig now serializes the whole in-memory config as the save payload, which absorbs a backend-only autostart value the Start-with-Windows checkbox never writes back into config (its handler calls only set_autostart). After the user flips that toggle, the next unrelated save re-persists the stale value, and setup() re-applies it on the next launch, undoing the user's choice.
Prompt for agents
patchConfig now sends the full in-memory config as the set_config patch. The Config object ends up carrying the backend-only key `autostart` (config_with_defaults never seeds it, but set_config_inner echoes it once config.json contains it, and applyConfigEcho copies it into the live config object because both sent and current values were previously undefined). The Start-with-Windows checkbox handler in initSettings only calls set_autostart and never updates config.autostart, so config.autostart diverges from the real persisted value after a toggle. On the next patchConfig for any unrelated setting, the stale autostart is re-written to config.json, and setup() re-applies it at launch, reverting the user's autostart choice. Fix by not sending keys the frontend does not own: exclude autostart (and any other non-Config keys) from the serialized payload in patchConfig, or have applyConfigEcho ignore keys absent from the frontend Config, or keep config.autostart in sync in the checkbox handler. Restricting the payload to the known frontend Config keys is the most robust option.
Was this helpful? React with 👍 or 👎 to provide feedback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
src-tauri/src/tray_projection.rscover order/disable/pin/star/hidden, tooltip capacity, stale multi-account lines, and locale selection.