fix(cua): use effective PTC state retention

This commit is contained in:
_Kerman committed 2026-10-21 00:37:56 +08:00
1 parent e82dddc45c
commit cb6dcaedb0
5 files changed
+9 -9

No files matched your search

+2 -2
View File
@@ -21,8 +21,8 @@
en: 47018e805bc81fb7
zh: 15949a4fdc7dd3cf
/deepseek-ai-dsh-cua/understand-the-implementation:
en: 9ad273f3690d0c5b
zh: d81f36976629afe5
en: ce6355abc13cb9f2
zh: 43d542b65b95df4a
/deepseek-ai-dsh-cua/further-exploration:
en: b8b0aece886fadaa
zh: ecd8c88d601f2179
+1 -1
View File
@@ -74,7 +74,7 @@ The root Host entry exports `installCua`, `CuaConfig`, and the Typert-discovered
The optional browser contribution mounts the native provider's permission Remote and reuses the Plugins activation and configuration slots. The four setup rows remain visible while unknown fields use placeholders; the same permission-management guidance remains visible while queries settle and after access is granted, including when the text wraps. The default-mode form, runtime configuration, system checks, application decisions, and application icons fill in as each query completes. Application names and actions do not wait for icons; icon positions retain their space. User actions run in order without waiting for pending observation queries. Disposal waits for both actions and queries to settle before releasing the separately owned Remote mount. Known query errors and read-only settings stay visible while management operations or retries run, with their actions disabled. Query errors stay with the affected section, and activation guidance depends only on system checks. The injection layer observes Plugin Manager operations independently of the page. Bundle and row changes pause all four queries and invalidate in-flight results; settlement refreshes observations even after the page closes. Last known errors remain until a successful read. Disposal discards late results. The controller consumes the generated `ctx.remote.cuaAccess` namespace directly and handles unsuccessful Remote results in its existing query and action paths. It projects queries into the page and setup dialog; reconnects and updates to the Host-reported settings namespace refresh it. Operation notices live in the shell overlay, so closing the page does not remove them. The provider owns permission checks, persisted decisions, and cancellation; the browser owns no authorization state.
The detail page reads the effective default (`selectedDefault ?? default`) from the existing `configForms` service. The default button writes only `selectedDefault` through the form's revision-checked settings path. The execution-mode row uses CUA's `ptcConfiguration()` and `enablePersistentPtc()` controls: the Host edits the selected evaluator’s persistence configuration through the existing configuration editor, preserving its ordinary Loader reload lifecycle. Permission checks and runtime state settle independently. Loading, read-only and unavailable settings cannot submit a change; a failed write remains beside the setting for retry.
The detail page reads the effective default (`selectedDefault ?? default`) from the existing `configForms` service. The default button writes only `selectedDefault` through the form's revision-checked settings path. The execution-mode row uses CUA's `ptcConfiguration()` and `enablePersistentPtc()` controls: persistence follows the loaded runtime's `retainsState`. Enabling persistence preserves an active Script evaluator and writes `executionMode` and `scriptPersistence` together through the configuration editor; other modes select the retained REPL with Script persistence disabled. The ordinary Loader reload lifecycle applies. Permission checks and runtime state settle independently. Loading, read-only and unavailable settings cannot submit a change; a failed write remains beside the setting for retry.
</details>
-----
+1 -1
View File
@@ -74,7 +74,7 @@ kind: "package-reference"
可选浏览器插件挂载原生 provider 的权限 Remote,复用插件页的启用引导和配置插槽。四排使用条件始终可见,未加载的字段保留占位;查询期间和权限已允许时显示相同的权限管理说明,换行也不会改变内容。默认模式、执行方式、系统权限、应用列表和应用图标分别查询,结果返回后各自显示。应用名称和操作按钮不等待图标,图标位置保留空位。用户操作按顺序执行,不等待尚未完成的查询;卸载时等待操作和查询全部结束,再释放独立持有的 Remote 挂载。已知查询错误和只读设置提示在管理操作或重试期间保持可见,操作按钮禁用。查询错误只显示在对应部分,启用引导只等待系统权限结果。注入层独立于页面观察插件管理操作。组合包和组件行变更会暂停四项查询,并使进行中的结果失效;操作结束后即使页面已关闭,也会重新查询。已知错误保留至读取成功;卸载后的迟到结果会被丢弃。控制器直接接收生成的 `ctx.remote.cuaAccess`,在现有查询和操作流程中处理失败响应,并把查询结果投影到页面和设置弹窗;重新连接或 Host 返回的配置 namespace 更新时刷新状态。操作提示挂载到 shell overlay,关闭页面后仍可显示。provider 负责权限检查、持久授权和取消;浏览器不保存授权决定。
详情页通过现有 `configForms` 服务读取实际默认值(`selectedDefault ?? default`)。默认模式按钮仅写入 `selectedDefault`,沿用表单带版本检查的设置写入流程。执行方式一行调用 CUA 的 `ptcConfiguration()` 和 `enablePersistentPtc()`:Host 通过现有配置编辑器修改当前求值器的状态保留配置,保留普通 Loader 重载规则。权限检查和执行方式状态独立返回。设置仍在加载、只读或不可用时不能提交;写入失败时在设置旁显示错误,供用户重试。
详情页通过现有 `configForms` 服务读取实际默认值(`selectedDefault ?? default`)。默认模式按钮仅写入 `selectedDefault`,沿用表单带版本检查的设置写入流程。执行方式一行调用 CUA 的 `ptcConfiguration()` 和 `enablePersistentPtc()`,根据已加载运行时的 `retainsState` 判断状态保留。启用持久化时保留正在使用的 Script 求值器,并通过配置编辑器同时写入 `executionMode` 和 `scriptPersistence`;其他模式选择保留状态的 REPL,并关闭 Script 状态保留。操作沿用普通 Loader 重载规则。权限检查和执行方式状态独立返回。设置仍在加载、只读或不可用时不能提交;写入失败时在设置旁显示错误,供用户重试。
</details>
-----
+4 -4
View File
@@ -49,7 +49,7 @@ export class CuaAccess extends TypertRemoteService {
ptcConfiguration(): { persistent: boolean; writable: boolean } {
const runtime = this.ctx.get('ptcRuntime')
return {
persistent: runtime?.programFormat === 'repl' || runtime?.retainsState === true,
persistent: runtime?.retainsState === true,
writable: this.ctx.get('configEditor')?.entries().some(entry => entry.options.id === 'ptc-runtime') ?? false,
}
}
@@ -63,9 +63,9 @@ export class CuaAccess extends TypertRemoteService {
const editor = this.ctx.get('configEditor')
const entry = editor?.entries().find(entry => entry.options.id === 'ptc-runtime')
if (editor === undefined || entry === undefined) throw new Error('PTC runtime has no editable profile entry')
await editor.edit(entry, current => current.executionMode === 'vm-script'
? { ...current, scriptPersistence: true }
: { ...current, executionMode: 'persistent-in-memory' })
await editor.edit(entry, current => this.ctx.get('ptcRuntime')?.programFormat === 'script'
? { ...current, executionMode: 'vm-script', scriptPersistence: true }
: { ...current, executionMode: 'persistent-in-memory', scriptPersistence: false })
}
/**
+1 -1
View File
@@ -336,7 +336,7 @@ export function installCua(ctx: Context, config: CuaConfig, backend: CuaBackend)
name: 'computer-use:dsh-cua', order: ctx.systemPrompt.getSectionOrder('TOOL_COMPUTER_USE'),
text: () => {
const runtime = ctx.get('ptcRuntime')
return runtime?.programFormat !== 'repl' && !runtime?.retainsState ? guidance : `${guidance}
return !runtime?.retainsState ? guidance : `${guidance}
Persistent PTC initialization:
var { connectCua } = await import(${JSON.stringify(new URL('../lib/bridge.js', import.meta.url).href)});