[Feature] 统一 Viva 应用偏好所有权与多窗口发布,避免独立快照继续使用或覆盖旧设置

Open
#1,851 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
go, typescript
Domain
desktop, devtools

Research direction

Start with desktop/internal/workbench/app.go (New, saveSettings) and the setters in fonts.go, vim_mode.go and settings.go, then read window_sessions.go and settings_publication.go to see how cross-window publication works today. The issue asks for a single persistence owner with versioned publication and merging, which is a design change across Core and the native layer, not a local edit. Done would mean a design agreed by maintainers before any code, since the proposal is marked P2 and has no assignee or discussion yet.

Written by the indexing model from the issue text.

Description

area:settings enhancement P2 platform:cross-platform refactor review: high
Problem to solve / 要解决的问题

Viva 的应用偏好分别保存在每个 workbench.App.settings 快照中。已打开多个项目标签或原生窗口时,在其中一个实例修改字体、Vim 或快捷键后,其他已打开实例没有通用的应用偏好失效/重新读取入口,因而可能继续显示、分发旧设置;从旧快照再次保存还可能覆盖其他窗口刚改过的无关字段。

这是本次六项编辑器能力开发时发现的既有设置归属债务,按 develop-lithe 第九节单独登记,不在功能 PR 顺手重构。依据为 preview 基线 82fbb8aa5 的代码调用关系,尚未作原生多窗口复现,不将 Windows 运行时验收写成已完成。

可复核位置与搜索依据:

  • desktop/internal/workbench/app.go:New 从同一 settings.json 载入每个 App 的独立值;saveSettings 直接保存整个当前快照。
  • desktop/internal/workbench/fonts.go:setFonts、vim_mode.go:setVimMode、settings.go:SetKeymap:只修改接收 App 的值并保存。
  • desktop/internal/workbench/window_sessions.go:新项目标签创建新 App;activate 不重新读取应用偏好。
  • 全仓库检索 saveSettings、setFonts、setVimMode、drainSettings、publishSettings 后,现有 settings_publication.go 的跨窗口传递只覆盖插件设置,不是应用偏好通用通知。

保留这种结构会让每个新增偏好都重复处理跨窗口通知和旧快照覆盖,增加设置不一致风险。

Proposed solution / 建议方案

给共享应用偏好建立单一的持久化所有者和版本化发布流程。由 Core 处理字段合并、版本冲突与生效值规则;原生层读取真实设置源、原子写入并按配置目录身份通知所有活动实例,各实例在自己所属线程刷新。不要在绘制/激活热路径同步读文件,也不要用周期性轮询。

同时覆盖同窗口项目标签、独立窗口、并发修改不同字段、关闭后的通知丢弃及写入失败。迁移时保持已有 JSON 字段和默认值兼容,不改变插件设置已经独立建立的生命周期。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Settings / 设置

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

Alternatives considered / 已考虑的替代方案

重新打开目标窗口可重新读取已保存值,但不能避免并发快照覆盖。为每个 setter 单独遍历窗口会重复规则并容易漏掉新字段;窗口绘制时读磁盘会增加界面延迟,均不作为长期方案。

Additional context / 补充信息

源代码分析,未采集用户日志或私人项目内容,不需要发布包环境。跨平台范围来自两端共用的 desktop/internal/workbench,不是两端原生复现声明。

已查重中文“设置 多窗口 同步”、英文“settings window global”和 refactor/全局设置检索。#1493 讨论工具真实配置来源的迁移,#1662 讨论领域规则迁入 Core,均不是应用偏好快照的多窗口发布问题。关联 #1794;不关闭上述已有问题。

Checklist / 提交前检查
  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
3h 48m
Merged PRs (30d)
571

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.