diff --git a/packages/boot/config-editor/README.i18n.yaml b/packages/boot/config-editor/README.i18n.yaml
index 5727bdff08..a04b21d3e8 100644
--- a/packages/boot/config-editor/README.i18n.yaml
+++ b/packages/boot/config-editor/README.i18n.yaml
@@ -15,8 +15,8 @@
en: 23386452a66b2fbd
zh: 70bba862b949b652
/deepseek-ai-dsh-config-editor/use-this-package:
- en: 1eedaa5d72b48177
- zh: 39abc1d927a692d2
+ en: be26ec7aef6c7cb4
+ zh: 3ade4ba48cdf1fc1
/deepseek-ai-dsh-config-editor/understand-the-implementation:
en: baa887b5ecfa7001
zh: d3e03c2b1d10c67e
diff --git a/packages/boot/config-editor/README.md b/packages/boot/config-editor/README.md
index 17da6551f9..912413eebb 100644
--- a/packages/boot/config-editor/README.md
+++ b/packages/boot/config-editor/README.md
@@ -30,7 +30,7 @@ Mount this service in a profile application with Loader and `profileContext`. It
name: '@deepseek-ai/dsh-config-editor'
```
-Use [settings](../../settings/settings/README.md) for forms restricted to live fields. Callers that edit complete configuration can use `ctx.configEditor.edit()`; ordinary fields retain Loader’s normal lifecycle.
+Use [settings](../../settings/settings/README.md) for forms restricted to live fields. Callers that edit complete configuration can use `ctx.configEditor.edit()`; ordinary fields retain Loader’s normal lifecycle. The optional `signal` cancels a write waiting for HMR admission without changing the file; an admitted write finishes normally.
## Understand the implementation
diff --git a/packages/boot/config-editor/README.zh.md b/packages/boot/config-editor/README.zh.md
index d1ff18344f..cc66180ff6 100644
--- a/packages/boot/config-editor/README.zh.md
+++ b/packages/boot/config-editor/README.zh.md
@@ -30,7 +30,7 @@ kind: "package-reference"
name: '@deepseek-ai/dsh-config-editor'
```
-使用 [settings](../../settings/settings/README.zh.md) 提供只编辑即时字段的表单。编辑完整配置的调用方可使用 `ctx.configEditor.edit()`;普通字段保留 Loader 的正常生命周期。
+使用 [settings](../../settings/settings/README.zh.md) 提供只编辑即时字段的表单。编辑完整配置的调用方可使用 `ctx.configEditor.edit()`;普通字段保留 Loader 的正常生命周期。可选 `signal` 可取消等待 HMR 调度的写入,文件保持不变;已经开始的写入仍会完成。
## 理解实现
diff --git a/packages/boot/config-editor/src/index.ts b/packages/boot/config-editor/src/index.ts
index ffec879f40..fefc0503c1 100644
--- a/packages/boot/config-editor/src/index.ts
+++ b/packages/boot/config-editor/src/index.ts
@@ -82,13 +82,16 @@ export class ConfigEditor extends Service {
/** Validate, persist, and reconcile a plugin's next config; ordinary fields keep normal lifecycle rules.
* @param entry Current Loader entry, also used to detect replacement during the write.
* @param change Derive a raw config from the current entry and its inherited layer.
+ * @param signal Cancel while waiting for HMR admission; admitted writes finish normally.
* @returns Fulfillment after Loader reconciliation completes.
*/
async edit(
entry: Entry,
change: (current: Record, inherited: Record) => Record,
+ signal?: AbortSignal,
): Promise {
const run = async (): Promise => {
+ signal?.throwIfAborted()
const path = this.documentPath
await withFileLock(join(this.ownerContext.profileContext.dir, 'package.json'), async () => {
if (!this.entries().includes(entry) || entry.fiber === undefined) throw new Error('Configuration entry is no longer available')
@@ -150,7 +153,7 @@ export class ConfigEditor extends Service {
})
}
const hmr = this.ownerContext.get('hmr')
- await (hmr === undefined ? run() : hmr.runExclusive(run))
+ await (hmr === undefined ? run() : hmr.runExclusive(run, signal))
}
}
diff --git a/packages/boot/hmr/README.i18n.yaml b/packages/boot/hmr/README.i18n.yaml
index 776c0d0fe7..7480a8b3f7 100644
--- a/packages/boot/hmr/README.i18n.yaml
+++ b/packages/boot/hmr/README.i18n.yaml
@@ -21,8 +21,8 @@
en: 11ef18c6d08f39f3
zh: 2911cdd03ff3747d
/deepseek-ai-dsh-hmr/understand-the-implementation:
- en: bd608f418630317f
- zh: 053fa77a3fa571a9
+ en: 5ca2a7d68d7c189d
+ zh: 773ffb08d7cbfd0f
/deepseek-ai-dsh-hmr/model-experience:
en: 215e7ba838619b7b
zh: a311da3843709f90
diff --git a/packages/boot/hmr/README.md b/packages/boot/hmr/README.md
index 8d2270b4a1..9a2d9ccdc9 100644
--- a/packages/boot/hmr/README.md
+++ b/packages/boot/hmr/README.md
@@ -56,7 +56,7 @@ Profile recompositions run by HMR's profile watches and by Plugin Manager also r
Implementation internals — click to expand
-`watchConfig()` registers an awaited configuration handler and watches only its target path and required parent directories; sibling files, including temporary writer locks, are excluded before native watcher creation. `runExclusive()` serializes configuration changes and Loader updates with automatic reloads and rejects nested transactions. Package installation and removal run outside this queue. HMR does not acquire the package writer lock; manifest notifications reload only when the ordered `dsh.profile.bundles` list changes. Profile and home patch changes also trigger recomposition. File events received during a configuration transaction are processed afterward. Include refreshes and profile reconciliation reach plugins through ordinary Loader entry updates; Loader commits volatile-only changes in place.
+`watchConfig()` registers an awaited configuration handler and watches only its target path and required parent directories; sibling files, including temporary writer locks, are excluded before native watcher creation. `runExclusive()` serializes configuration changes and Loader updates with automatic reloads and rejects nested transactions. Its optional `signal` cancels a queued operation before admission; an admitted operation still completes before the queue advances. Package installation and removal run outside this queue. HMR does not acquire the package writer lock; manifest notifications reload only when the ordered `dsh.profile.bundles` list changes. Profile and home patch changes also trigger recomposition. File events received during a configuration transaction are processed afterward. Include refreshes and profile reconciliation reach plugins through ordinary Loader entry updates; Loader commits volatile-only changes in place.
App-boot owns profile parsing and patch precedence. HMR reads the launcher’s data-only `profileContext`, registers the profile manifest and both user patch watches during initialization, and waits for application readiness before processing changes. Its disposal closes the watchers and cancels reloads waiting for startup. Configuration watchers start outside the active transaction context so later notifications can enter the queue.
diff --git a/packages/boot/hmr/README.zh.md b/packages/boot/hmr/README.zh.md
index 21044fe7d1..9fb05b544e 100644
--- a/packages/boot/hmr/README.zh.md
+++ b/packages/boot/hmr/README.zh.md
@@ -56,7 +56,7 @@ HMR 的 profile 监听和 Plugin Manager 执行的 profile 重新组合,还会
实现细节——点击展开
-`watchConfig()` 注册会被等待的配置处理器,仅监听目标路径及必要的父目录;同级文件(包括临时写锁)在创建原生 watcher 前即被排除。`runExclusive()` 将配置变更、Loader 更新与自动重载串行化,并拒绝嵌套事务。包安装和删除在该队列之外执行。HMR 不获取包操作写锁;manifest 通知仅在有序的 `dsh.profile.bundles` 列表变化时触发重载。profile 与 home patch 变化也会触发重新组合。配置事务期间收到的文件事件在事务结束后处理。 Include 刷新和 profile 重载都通过普通的 Loader 条目更新到达插件;仅 volatile 变化由 Loader 就地提交。
+`watchConfig()` 注册会被等待的配置处理器,仅监听目标路径及必要的父目录;同级文件(包括临时写锁)在创建原生 watcher 前即被排除。`runExclusive()` 将配置变更、Loader 更新与自动重载串行化,并拒绝嵌套事务。可选 `signal` 只取消尚未开始的排队操作;已经开始的操作仍会执行完毕,队列才继续。包安装和删除在该队列之外执行。HMR 不获取包操作写锁;manifest 通知仅在有序的 `dsh.profile.bundles` 列表变化时触发重载。profile 与 home patch 变化也会触发重新组合。配置事务期间收到的文件事件在事务结束后处理。 Include 刷新和 profile 重载都通过普通的 Loader 条目更新到达插件;仅 volatile 变化由 Loader 就地提交。
App-boot 负责 profile 解析和 patch 优先级规则。HMR 读取启动器提供的纯数据 `profileContext`,在初始化时注册 profile manifest 和两份用户 patch 的监听,并等待应用就绪后处理更改。销毁 HMR 时会关闭监听器并取消等待启动的重载。配置监听器在当前事务上下文之外启动,使后续通知可以进入队列。
diff --git a/packages/boot/hmr/src/index.ts b/packages/boot/hmr/src/index.ts
index 47d71d9109..f494ce96ae 100644
--- a/packages/boot/hmr/src/index.ts
+++ b/packages/boot/hmr/src/index.ts
@@ -263,16 +263,24 @@ class Hmr extends Service {
/** Serialize a caller-owned mutation with all automatic reload paths.
* @param operation Work that must not overlap module or configuration replacement.
+ * @param signal Cancel admission while queued; an operation already running must finish.
* @returns The operation result after its asynchronous work completes.
*/
- runExclusive(operation: () => Promise): Promise {
+ runExclusive(operation: () => Promise, signal?: AbortSignal): Promise {
if (this.executing.getStore()) return Promise.reject(new Error('HMR transactions cannot be nested'))
+ if (signal?.aborted) return Promise.reject(signal.reason)
+ const result = Promise.withResolvers()
+ const cancel = () => { result.reject(signal?.reason) }
+ signal?.addEventListener('abort', cancel, { once: true })
const task = this.operations.then(async () => {
+ signal?.removeEventListener('abort', cancel)
+ signal?.throwIfAborted()
if (this.closing) throw new Error('HMR is disposed')
return this.executing.run(true, operation)
})
this.operations = task.catch(() => {})
- return task
+ void task.then(result.resolve, result.reject)
+ return result.promise
}
private runReload(operation: () => Promise): Promise {
diff --git a/packages/boot/hmr/tests/coordination.spec.ts b/packages/boot/hmr/tests/coordination.spec.ts
index b3660828e9..a3ade63286 100644
--- a/packages/boot/hmr/tests/coordination.spec.ts
+++ b/packages/boot/hmr/tests/coordination.spec.ts
@@ -59,6 +59,25 @@ it('serializes mutations, rejects nesting and keeps the queue usable after failu
expect(order).toEqual([1, 2])
})
+it('cancels queued mutations without cancelling an admitted transaction', async () => {
+ const { hmr } = await fixture()
+ const release = Promise.withResolvers(), entered = Promise.withResolvers()
+ onTestFinished(() => { release.resolve(undefined) })
+ const running = new AbortController(), waiting = new AbortController()
+ const first = hmr.runExclusive(async () => { entered.resolve(undefined); await release.promise; return 'committed' }, running.signal)
+ await entered.promise
+ const operation = vi.fn(async () => 'unwanted')
+ const cancelled = hmr.runExclusive(operation, waiting.signal)
+ waiting.abort(new Error('owner unloaded'))
+ running.abort(new Error('too late to cancel admission'))
+ await expect(cancelled).rejects.toThrow('owner unloaded')
+ await expect(hmr.runExclusive(operation, waiting.signal)).rejects.toThrow('owner unloaded')
+ release.resolve(undefined)
+ await expect(first).resolves.toBe('committed')
+ await hmr.runExclusive(async () => {})
+ expect(operation).not.toHaveBeenCalled()
+})
+
it('holds configuration handlers behind configuration mutations', async () => {
const { hmr, dir } = await fixture()
const filename = join(dir, 'package.json')
diff --git a/packages/settings/settings/README.i18n.yaml b/packages/settings/settings/README.i18n.yaml
index 46348fd8da..190c34df59 100644
--- a/packages/settings/settings/README.i18n.yaml
+++ b/packages/settings/settings/README.i18n.yaml
@@ -15,8 +15,8 @@
en: 23386452a66b2fbd
zh: 70bba862b949b652
/deepseek-ai-dsh-settings/use-this-package:
- en: e0f5e49cf8137839
- zh: bdd8aff9b7773e5a
+ en: ae4733d0b646cc71
+ zh: 86a1fa8d8d1fa077
/deepseek-ai-dsh-settings/understand-the-implementation:
en: d8eae17e891ff44e
zh: 05189989b2786002
diff --git a/packages/settings/settings/README.md b/packages/settings/settings/README.md
index 740996e34b..70e855128f 100644
--- a/packages/settings/settings/README.md
+++ b/packages/settings/settings/README.md
@@ -30,6 +30,8 @@ Mount this plugin with Loader and [config-editor](../../boot/config-editor/READM
name: '@deepseek-ai/dsh-settings'
```
+`mutate()` accepts an optional `signal` to cancel a write waiting for HMR admission. Admitted writes finish normally.
+
This plugin has no configuration fields. Forms expose only volatile fields from active, uniquely addressed profile entries. Ordinary configuration remains editable through Cordis configuration files.
Once the Loader has settled every entry after Settings starts, a `settings.yaml` left in the harness home by earlier releases is imported once: each section is written into the entry of the same id (`ui-developer-tools` → `ui-settings`, `ui-onboarding` → `ui-settings-general`, `shell` → the platform's shell executor entry), the file is renamed to `settings.yaml.imported` before the first write, and a section the running composition rejects is logged and stays only in the renamed file.
diff --git a/packages/settings/settings/README.zh.md b/packages/settings/settings/README.zh.md
index c8fae11993..ab1d6f73b1 100644
--- a/packages/settings/settings/README.zh.md
+++ b/packages/settings/settings/README.zh.md
@@ -30,6 +30,8 @@ kind: "package-reference"
name: '@deepseek-ai/dsh-settings'
```
+`mutate()` 接受可选 `signal`,用于取消等待 HMR 调度的写入。已经开始的写入仍会完成。
+
此插件没有配置字段。表单只展示活动且可唯一定位的 profile 条目中的 volatile 字段。普通配置仍通过 Cordis 配置文件编辑。
Settings 启动后、Loader 完成所有条目的加载时,早期版本留在 harness home 中的 `settings.yaml` 会被导入一次:每个 section 写入同名条目(`ui-developer-tools` → `ui-settings`、`ui-onboarding` → `ui-settings-general`、`shell` → 当前平台的 shell 执行器条目),文件在第一次写入前改名为 `settings.yaml.imported`,被当前组合拒绝的 section 会记录日志并只保留在改名后的文件中。
diff --git a/packages/settings/settings/src/index.ts b/packages/settings/settings/src/index.ts
index e0586ecb24..9dc30c54b6 100644
--- a/packages/settings/settings/src/index.ts
+++ b/packages/settings/settings/src/index.ts
@@ -363,21 +363,22 @@ export class SettingsForms extends Service {
* @param ns Profile entry id.
* @param ops Ordered form edits.
* @param expectedRevision Revision returned by describe.
+ * @param signal Cancel while waiting for HMR admission; admitted writes finish normally.
*/
- async mutate(ns: string, ops: readonly SettingsPathOp[], expectedRevision?: number): Promise {
+ async mutate(ns: string, ops: readonly SettingsPathOp[], expectedRevision?: number, signal?: AbortSignal): Promise {
await this.write(ns, (current, base, schema) => ops.reduce((value, op) => {
if (op.op === 'set') return applyPathOp(value, op, schema)
const parent = op.path.slice(0, -1).reduce((node, key) => member(node, key), value)
if (Array.isArray(parent)) return applyPathOp(value, op, schema)
const inherited = op.path.reduce((node, key) => member(node, key, true), base)
return applyPathOp(value, inherited === undefined ? op : { op: 'set', path: op.path, value: inherited }, schema)
- }, current), expectedRevision, ops.map(op => op.path))
+ }, current), expectedRevision, ops.map(op => op.path), signal)
}
private async write(
ns: string,
change: (current: Record, base: Record, schema: z) => Record,
- expected?: number, paths: readonly (readonly string[])[] = [],
+ expected?: number, paths: readonly (readonly string[])[] = [], signal?: AbortSignal,
): Promise {
const entry = this.ownerContext.configEditor.entries().find(row => row.options.id === ns)
const schema = entry === undefined ? undefined : this.schema(entry)
@@ -418,7 +419,7 @@ export class SettingsForms extends Service {
return result
}
return mergeLayers(strip(raw, form), next) as Record
- })
+ }, signal)
this.describe()
}