Skip to content

feat: sync provider config to tray surfaces - #164

Open
JaminYe wants to merge 5 commits into
ItsJazii:mainfrom
JaminYe:codex/provider-config-tray-sync
Open

feat: sync provider config to tray surfaces#164
JaminYe wants to merge 5 commits into
ItsJazii:mainfrom
JaminYe:codex/provider-config-tray-sync

Conversation

@JaminYe

@JaminYe JaminYe commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract a testable main-tray projection so provider order, disable, hidden, starred, and pinned metrics drive the icon and tooltip.
  • Route every config entrypoint through a latest-state-wins tray sync queue, and keep newly enabled providers off the tray until a forced usage refresh finishes.
  • Truncate tray tooltips on complete UTF-16 lines within Windows capacity and localize them.
  • Surface config-save and tray-sync failures in the footer instead of failing silently.

Testing

  • Unit tests in src-tauri/src/tray_projection.rs cover order/disable/pin/star/hidden, tooltip capacity, stale multi-account lines, and locale selection.

Open in Devin Review

抽出可测试的主托盘投影,按顺序/禁用/隐藏/加星/置顶决定图标与 tooltip;配置入口统一走最新状态胜出的同步队列,tooltip 按 UTF-16 容量整行截断并本地化。
devin-ai-integration[bot]

This comment was marked as resolved.

错误回退 3 分钟内不标 stale;patchConfig 按未改字段合并 set_config 返回值,避免覆盖更新的内存配置。
devin-ai-integration[bot]

This comment was marked as resolved.

先应用 strip,再按真实结果投影主图标;失败时拆掉残留 icon,last_main_tray 仅在原生成功后写入。
devin-ai-integration[bot]

This comment was marked as resolved.

clear 成功才清空 last_strip,同序重试走右到左全量重建;clear 失败则保留缓存,错误仍返回调用方。

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread src/main.ts
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant