DSH / Atlas
2026-11-15proposedarchitecture

Migrate existing browser configuration reads to configuration sync

现有前端配置读取迁移到配置同步

Before [browser plugin configuration sync](../../implemented/architecture/2026-11-15-client-config-sync.md), every package whose browser face needs Host configuration implemented its own read. These reads take effect only at page load, duplicate injection code, or use the settings editing channel as a runtime read channel. This Note inventories them and plans their migration; nothing runs before the architecture land

English

Problem

Before browser plugin configuration sync, every package whose browser face needs Host configuration implemented its own read. These reads take effect only at page load, duplicate injection code, or use the settings editing channel as a runtime read channel. This Note inventories them and plans their migration; nothing runs before the architecture lands.

Proposal

Inventory

CategoryUsePackages
A. Page globals carry Host configurationwebserver/index-inject writes window.__DSH_*__, read once when the browser loadsshortcuts, ui-sidebar-documentpreview, ui-account-notifications, ui-settings-models (onboarding), ui-settings-account (contact details), connection (recovery parameters)
B. Runtime values read through configFormsThe browser subscribes to accepted values of its own or another entry through the settings mirrorui-chat, ui-conversation, locale, ui-theme, ui-settings-account, ui-settings-general, ui-agent-preset, experimental timeline, client-ui-cot-translation, client-ui-forge, cua
C. Config declared only on the Client faceThe browser exports a schema, but the entry never receives configurationDone in the architecture PR: ui-context-menu resolutionTimeoutMs and ui-conversation maxConcurrentFileUploads are top-level volatile fields of their Host schemas, and the Client schemas are removed
D. First-paint pre-injectionThe page HTML pre-injects values to avoid a first-paint flashui-theme palette and font sizes
E. Settings editingSettings pages edit inherited values, overrides, revisions, and writabilityevery ui-settings-* card

Migration rules

CategoryHandling
AMake the fields volatile and move the Config type to src/types.ts; the browser reads SyncedConfig; remove the matching index-inject row and global. Confirm per field that its meaning can become "changes at runtime"; connection needs its recovery parameters before Connection itself activates and is assessed separately
BPlugins reading their own entry read SyncedConfig; configForms keeps only writes and settings presentation. Reads of another entry's values (for example ui-agent-preset reading ui-settings) can use the read-only ctx.config.resolveConfigByPackage(packageName)
CRemove the browser schema and Config export, move the type to src/types.ts, and declare a volatile schema on the Host face
DUnchanged; the runtime part can be migrated separately
EOutside this migration; adjusting the settings package and configForms is discussed separately once the configuration sync architecture is stable

Order

  1. The architecture Note is implemented and merged.
  2. Category C (no behavior dependency; exercises the mechanism).
  3. Category A, one package at a time.
  4. Category B, own reads first, then cross-plugin reads.
  5. A separate Note for the overall adjustment of settings and configForms.

Open questions

  • Which fields each package makes volatile.
  • Whether cross-plugin reads move to types inferred per package name through declaration merging.
  • The first-render timing of connection recovery parameters and bootstrap rows.

Alternatives considered

RejectedReason
Migrating in the architecture PRWidens the review and mixes mechanism questions with per-package semantics
Keeping page globals as a long-term parallel channelKeeps two configuration sources and duplicated injection code

Acceptance criteria

  • Category A and C packages no longer export a browser Config schema or read Host configuration globals.
  • Category B plugins that read their own configuration no longer rely on configForms for runtime reads.
  • After migration, a Host change to the matching volatile field takes effect without a page reload.

Risks

RiskDescription
Changed meaningValues that took effect only at load become runtime-changeable, and plugins must support live updates
Pinned configurationMaking a field volatile brings it into the settings form's profile row, subject to the pinning rules in profile-owned live configuration
First-render timingconnection needs its recovery parameters before it activates, earlier than synced configuration can take part

中文

Problem

前端插件配置同步落地前,浏览器需要 Host 配置的包各自实现了读取方式。这些方式只在页面加载时生效、复制注入代码,或把设置编辑通道当成运行时读取通道。本 Note 盘点这些用法并规划收编;架构落地前不执行。

Proposal

盘点

类别用法包
A. 页面全局变量下发 Host 配置webserver/index-inject 写 window.__DSH_*__,前端加载时读一次shortcuts、ui-sidebar-documentpreview、ui-account-notifications、ui-settings-models(引导)、ui-settings-account(联系方式)、connection(恢复参数)
B. 以 configForms 读取运行时值前端经设置镜像订阅自身或他人条目的已接受值ui-chat、ui-conversation、locale、ui-theme、ui-settings-account、ui-settings-general、ui-agent-preset、实验包 timeline、client-ui-cot-translation、client-ui-forge、cua
C. 只在前端声明的 Config前端导出 schema,但条目从不收到配置已在架构 PR 中完成:ui-context-menu 的 resolutionTimeoutMs 与 ui-conversation 的 maxConcurrentFileUploads 已改为 Host 顶层 volatile 字段,前端 schema 已删除
D. 首屏预注入页面 HTML 预注入以避免首屏闪烁ui-theme 调色板与字号
E. 设置编辑设置页编辑继承值、覆盖值、修订号、可写性各 ui-settings-* 卡片

收编规则

类别处理
A字段改为 volatile,Config 类型移入 src/types.ts;前端改读 SyncedConfig;删除对应 index-inject 与全局变量。需逐字段确认语义可以变为「运行时可变」;connection 恢复参数在 connection 自身激活前就需要,须单独评估
B读取自身条目的插件改读 SyncedConfig;configForms 只保留写入与设置页呈现。读取他人条目的值(例如 ui-agent-preset 读 ui-settings)可改用只读的 ctx.config.resolveConfigByPackage(packageName)
C前端删除 schema 与 Config 导出,类型移入 src/types.ts,Host 面声明 volatile schema
D保持不变;运行时变化部分可另行收编
E不在本迁移范围;settings 包与 configForms 的调整在配置同步架构稳定后另行讨论

顺序

  1. 架构 Note 实现完成并合入。
  2. 类别 C(无行为依赖,验证机制)。
  3. 类别 A,逐包进行。
  4. 类别 B,先自身读取、后跨插件读取。
  5. settings 与 configForms 的整体调整另起 Note。

未决

  • 每个包选择哪些字段改为 volatile。
  • 跨插件读取是否升级为按包名声明合并推导类型。
  • connection 恢复参数与 bootstrap 行的首屏时序。

Alternatives considered

Rejected理由
与架构同一 PR 迁移扩大评审面,机制问题与逐包语义问题混在一起
保留页面全局变量作为长期并行通道维持两套配置来源与重复注入代码

Acceptance criteria

  • 类别 A、C 的包不再导出前端 Config schema 或读取 Host 配置全局变量。
  • 类别 B 中读取自身配置的插件不再依赖 configForms 做运行时读取。
  • 迁移后 Host 修改对应 volatile 字段无需刷新页面即生效。

Risks

风险说明
语义变化原本只在加载时生效的值变为运行时可变,插件需支持热更新
配置钉住字段改为 volatile 会使设置表单把它纳入 profile 行,受实时配置中的钉住规则影响
首屏时序connection 在自身激活前就需要恢复参数,早于同步配置能参与的时间点