✨ feat(client): 清理入口移到插件页,不再藏在组件行里

This commit is contained in:
pyh
2026-09-30 17:26:31 +08:00
parent b977f57fa4
commit 7b29e900f7
3 changed files with 35 additions and 27 deletions
+8 -2
View File
@@ -30,7 +30,7 @@ DSH 原本只能归档会话——归档只是把会话从列表里移开,日
### 2. 清理临时文件 ### 2. 清理临时文件
**设置 → 插件 → 会话彻底删除**(点会话彻底删除那一行右侧的配置按钮),清理 spill 后端留下的**孤儿**目录。判定偏保守: **设置 → 插件 → 会话彻底删除**(打开插件页就能看到,不必再点进「包含的组件」里那一行),清理 spill 后端留下的**孤儿**目录。判定偏保守:
1. 目录名必须精确等于 `session-<sha256(会话 id) 前 12 位>`——这是 spill 后端唯一会生成的形状; 1. 目录名必须精确等于 `session-<sha256(会话 id) 前 12 位>`——这是 spill 后端唯一会生成的形状;
2. 该名字不属于任何已知会话(`sessionQuery.listSessions()` 已经把存量会话与内存中正在运行的会话合并成同一份语料,所以「已知」只需要一个来源); 2. 该名字不属于任何已知会话(`sessionQuery.listSessions()` 已经把存量会话与内存中正在运行的会话合并成同一份语料,所以「已知」只需要一个来源);
@@ -39,7 +39,13 @@ DSH 原本只能归档会话——归档只是把会话从列表里移开,日
结果直接显示在该页(清理了几个目录、几个文件、释放多少空间),可反复点击。 结果直接显示在该页(清理了几个目录、几个文件、释放多少空间),可反复点击。
这个页面占的是 `plugins.row.config` 槽位——和官方插件「终端」的配置页是同一个位置。注册了这个槽位的 key(`<包名>#<行 id>`)之后,插件行就会长出配置入口,所以本插件不声明 `Config` 也能有自己的页面。 这块清理占的是 `plugins.bundle.config` 槽位,key 就是本包的**包名**(`@dsh-plugin/session-delete`)。它渲染在插件页的**描述与「包含的组件」之间**,所以打开插件页即可看到,不用再点一次。
没有用行级槽位 `plugins.row.config`(key 形如 `<包名>#<行 id>`):它只会在「包含的组件」那一行上多长出一个「配置」入口,把本插件唯一的控件藏到二级页面里。本插件页顶部是 DSH 自己渲染的插件标题与描述,所以这块配置不再重复标题,直接讲清理这件事本身。
### 关于「包含的组件」
插件页下方的「包含的组件 / 组件」是 **DSH 插件页固定渲染**的:`ui-plugin-manager` 无条件列出这个 bundle 在 `cordis.patch.yml` 里声明的**每一行**(行 id、运行状态、单独开关),没有"跳过"的口子。任何 bundle 都至少要声明一行才能挂上宿主半,所以这一节必然出现——本插件就是这一行。它也不是纯冗余:它标出运行状态、允许单独关掉这个组件。插件侧没法隐藏它,但插件的功能不再挂在它下面——清理入口已经在页面本身上了。
## 行为与边界 ## 行为与边界
+26 -24
View File
@@ -8,11 +8,14 @@
* *
* The temporary-file sweep is the plugin's other operation, and it lives on * The temporary-file sweep is the plugin's other operation, and it lives on
* this plugin's own page under Settings → Plugins: the entry registers into * this plugin's own page under Settings → Plugins: the entry registers into
* `plugins.row.config` under the `<package name>#<row id>` key the manager * `plugins.bundle.config` under this package's name, the page-level seat the
* dispatches, which also gives the row its configure control. That is the same * manager renders on a bundle's page between its description and its rows.
* seat a bundled plugin's configuration form occupies, so the plugin's only *
* control sits beside everything else the manager says about it instead of * That page-level seat is deliberate, not the row-level `plugins.row.config`
* taking a row in General settings. * one. The row seat grows a configure control on the row listed under
* 「包含的组件」 and nothing else, so it parks this plugin's one and only control
* one click deeper than the page the user just opened; the page seat puts it
* where the page is read.
* *
* Two client-authoring rules shape this file: * Two client-authoring rules shape this file:
* *
@@ -44,15 +47,13 @@ window.__ModuleLoader__.load({
/** Between the shipped `archive` (100) and `pin` (200) hover buttons. */ /** Between the shipped `archive` (100) and `pin` (200) hover buttons. */
const ROW_ACTION_ORDER = 150 const ROW_ACTION_ORDER = 150
/** /**
* The key `plugins.row.config` is dispatched under: the manager composes it * The key `plugins.bundle.config` is dispatched under: the manager keys a
* as `<package name>#<row id>`, with the row id read from this bundle's own * bundle's own configuration by its npm package name and renders the entry
* patch. Both halves are literals from `package.json` and * on that bundle's page, between the description and the rows. The value is
* `cordis.patch.yml`; a typo costs the configure control silently, so they * the literal from `package.json` — a typo costs the section silently, so
* are the only two places renaming has to reach. * it is the only place renaming has to reach.
*/ */
const PACKAGE = '@dsh-plugin/session-delete' const PACKAGE = '@dsh-plugin/session-delete'
const ROW_ID = 'session-delete'
const CONFIG_KEY = `${PACKAGE}#${ROW_ID}`
const TOOLTIP_DELAY_MS = 500 const TOOLTIP_DELAY_MS = 500
const TOOLTIP_GAP = 8 const TOOLTIP_GAP = 8
/** Document base captured at bundle registration, before any routing. */ /** Document base captured at bundle registration, before any routing. */
@@ -331,12 +332,12 @@ window.__ModuleLoader__.load({
* This plugin's page under Settings → Plugins: sweep spilled tool output * This plugin's page under Settings → Plugins: sweep spilled tool output
* whose conversation no longer exists. * whose conversation no longer exists.
* *
* The owner asks every `plugins.row.config` entry for two views. `summary` * The owner dispatches the `page` view only: a bundle's configuration has
* is the one-liner on the row, and this plugin's manifest description * no one-line form, because the page header already prints this package's
* already fills that seat, so `summary` renders nothing and the page keeps * title and description from the manifest. So the section opens with the
* the text the manager read from `locale/*.json`. `page` is the section the * operation's own name and the rule it applies — what the header cannot say
* manager renders with its own heading, breadcrumb, and title; copy, * — and the guard below keeps rendering nothing if a `summary` view ever
* control, and result belong to this entry. * arrives.
*/ */
function TempCleanupPanel(props) { function TempCleanupPanel(props) {
const t = translate(props.t) const t = translate(props.t)
@@ -650,12 +651,13 @@ window.__ModuleLoader__.load({
}), }),
}, DeleteSessionDialog)) }, DeleteSessionDialog))
// The cleanup control belongs on this plugin's own page: registering // The cleanup control belongs on this plugin's own page itself, not
// this cell key is what makes the row grow a configure control, and the // behind the component row listed under 「包含的组件」:
// manager renders the entry for both its summary and page views. // `plugins.bundle.config` keyed by this package's name is the seat the
ctx.slots.inject('plugins.row.config', () => ctx.slots.register({ // manager renders between the page's description and its rows.
name: 'plugins.row.config', ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
key: CONFIG_KEY, name: 'plugins.bundle.config',
key: PACKAGE,
locale: NS, locale: NS,
inject: () => ({ cleanOrphans }), inject: () => ({ cleanOrphans }),
}, TempCleanupPanel)) }, TempCleanupPanel))
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@dsh-plugin/session-delete", "name": "@dsh-plugin/session-delete",
"version": "2.0.1", "version": "2.0.2",
"private": true, "private": true,
"type": "module", "type": "module",
"description": "Permanently delete a conversation: stop it, remove its session log, subagent logs, and spilled tool output, and drop every registry reference. The plugin's own page under Settings → Plugins can sweep orphaned temporary files.", "description": "Permanently delete a conversation: stop it, remove its session log, subagent logs, and spilled tool output, and drop every registry reference. The plugin's own page under Settings → Plugins can sweep orphaned temporary files.",