@leiyi-works/dsh-feature-tweaks 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -35
- package/client.js +357 -46
- package/cordis.patch.yml +33 -11
- package/index.js +279 -70
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,58 +1,111 @@
|
|
|
1
1
|
# @leiyi-works/dsh-feature-tweaks · 功能微调
|
|
2
2
|
|
|
3
|
-
> DeepSeek Harness(DSH)plugin:
|
|
3
|
+
> DeepSeek Harness(DSH)plugin: the single home for DSH tweaks — cross-version behaviour/default overrides plus the minimal UI compensations that used to live in a separate package. Since 0.4.0 it also contains the former **界面微调 (dsh-ui-tweaks 1.2.5)**: hide the conversation header's right-sidebar expand button, expand the left sidebar's session list by default. It also starts new root sessions with Agent Teams enabled, provides a Reload page shortcut (F5 on desktop), and stops the desktop app from asking about armed scheduled tasks on quit. Never touches a core package.
|
|
4
4
|
|
|
5
|
-
DSH
|
|
5
|
+
DSH 每次版本变化都会带来或多或少的官方行为差异、默认值不合意的地方。本包是这些**微调**的固定落点:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
| 包 | 管什么 | 例子 |
|
|
7
|
+
| 类别 | 管什么 | 例子 |
|
|
10
8
|
|---|---|---|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
9
|
+
| 功能微调 | Host 侧功能与**默认值** | 新会话默认开智能体团队协作、刷新快捷键、退出确认 |
|
|
10
|
+
| 界面微调 | 浏览器界面与 DOM 行为(0.4.0 起并入本包) | 隐藏右栏展开按钮、会话列表默认展开 |
|
|
11
|
+
|
|
12
|
+
> 0.3.x 及以前,「界面微调」是单独的 `@leiyi-works/dsh-ui-tweaks` 包;**0.4.0 起合并到这里**,旧包卸载即可,配置字段名与行为不变。
|
|
13
13
|
|
|
14
14
|
## 现有微调
|
|
15
15
|
|
|
16
|
-
| # |
|
|
16
|
+
| # | 微调 | 官方默认 | 本包值 | 开关 |
|
|
17
17
|
|---|---|---|---|---|
|
|
18
|
-
| 1 |
|
|
19
|
-
| 2 |
|
|
20
|
-
| 3 |
|
|
18
|
+
| 1 | 新会话「智能体团队协作」 | 默认关闭 | 新根会话默认开启 | patch:`agent-team.defaultEnabled` |
|
|
19
|
+
| 2 | 「刷新页面」快捷键 | 桌面壳不绑刷新键 | 桌面端 <kbd>F5</kbd> / 网页端 <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd> | 设置 → 快捷键 |
|
|
20
|
+
| 3 | 桌面端退出确认 | 有已排期的定时任务就弹确认 | 定时任务不触发确认(确实有任务在跑仍确认) | 代码侧,删本包即恢复 |
|
|
21
|
+
| 4 | 会话右上角「右侧栏展开」按钮 | 显示 | 隐藏 | `hideRightSidebarToggle`(默认 `true`) |
|
|
22
|
+
| 5 | 左侧会话列表 | 每个工作区只显示前 5 条,其余折叠成「展开其余 N 个会话」 | 默认展开全部会话(尊重手动「收起」) | `expandWorkspaceSessions`(默认 `true`) |
|
|
23
|
+
| 6 | 会话标题栏「⋯」导出菜单 | 显示 | 显示(可选隐藏) | `hideSessionLogExportMenu`(默认 `false`) |
|
|
21
24
|
|
|
22
25
|
团队模式会往上下文注入协作提示词和 `team_task_*` 工具,**token 开销更高**;简单任务随手关掉即可。
|
|
23
26
|
|
|
24
|
-
###
|
|
27
|
+
### 1. 新会话默认开启智能体团队协作
|
|
28
|
+
|
|
29
|
+
- 官方 `agent-team.defaultEnabled = false`:每个新会话默认关闭团队,要在「模型与推理等级」菜单里手动打开。
|
|
30
|
+
- 本包在 `cordis.patch.yml` 里把该行覆盖为 `defaultEnabled: true`(同时重述 `maxTasks: 256`):新根会话(含普通 fork)在第一次模型步之前就默认开启;已保存过选择的会话不受影响,单会话仍可随时关掉。
|
|
31
|
+
|
|
32
|
+
### 2. 刷新页面快捷键
|
|
33
|
+
|
|
34
|
+
- 键位:桌面端 <kbd>F5</kbd>,网页端 <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd>;快捷键服务要求同一个组合只能有一个注册者,所以 F5 只在本包注册(0.2.0 起从 `dsh-sidebar-folders` 0.13.4 迁移过来)。
|
|
35
|
+
- 改键/清除:设置 → <kbd>Ctrl</kbd>+<kbd>/</kbd>「快捷键」,搜「刷新页面 / Reload page」;桌面端覆盖保存在 `userData/keybindings.json`,网页端在该源站 localStorage 的 `dsh.keybindings.v1`。
|
|
36
|
+
- 安全刷新:刷新前先问 Host `GET /__dsh-feature-tweaks/reload-safe`。若本次启动后有任何 Client bundle 被重建(例如刚装了新插件),直接刷新会因桌面壳仍用启动时的 boot manifest 而弹「应用无法启动」;此时只在页面提示「请完全退出 DSH 再打开一次」,不刷新。
|
|
37
|
+
- 兜底:桌面壳的按键桥接可能晚到,所以另有 document 级 F5 监听;桥接先处理时该监听不会重复触发。
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- **代价**:应用关闭期间定时任务不会触发,错过的会在下次启动后补发最近一次(这是 DSH 本来的行为,只是不再每次退出都提示)。介意就把本包整体移除。
|
|
39
|
+
### 3. 桌面端退出不再因定时任务确认
|
|
40
|
+
|
|
41
|
+
- **改了什么**:桌面端(托盘「退出」、菜单退出、关闭窗口后托盘退出都算)退出前会问 Host 两件事——有没有任务正在跑、有没有已排期的定时任务;官方只要有任一项就弹原生确认框。本包拦下 Host 的这条应答,把「有定时任务」恒置为否。
|
|
42
|
+
- **新行为**:只有定时任务、没有任务在跑 → 直接退出,不再弹框;确有任务在跑 → 仍然确认,文案落到官方的「当前正在运行的任务将会中断」,不再附带「且应用关闭期间,定时任务不会运行」。
|
|
31
43
|
- **不影响**:定时任务本身照常创建/触发;`workspace/session-activity` 里的 `schedule` 族照常上报,所以「归档有定时任务的会话」仍会被拒绝;`dsh web` / headless 没有这条 IPC,补丁自动跳过。
|
|
32
|
-
- **诊断**:插件启动时
|
|
44
|
+
- **诊断**:插件启动时 `<DSH_HOME>/data/feature-tweaks-diag.log` 会记一行 `quit-inspection-patch-ready`;每次真的拦下定时任务再记一行 `quit-inspection-scheduled-tasks-ignored`。
|
|
45
|
+
|
|
46
|
+
### 4. 隐藏右栏展开按钮(原界面微调)
|
|
47
|
+
|
|
48
|
+
- 提供者:`@deepseek-ai/dsh-client-ui-sidebar-right` 的 `ExpandButton`,标记是稳定属性 `data-sidebar-right-expand`;隐藏规则只用这一个选择器,不会误伤其它按钮。
|
|
49
|
+
- **右栏功能本身不受影响**:左栏各类入口、右栏面板自身的折叠/全屏/关闭、快捷键 `sidebar.right.toggle` 都照常可用;隐藏的只是右侧栏收起时出现在会话头部右上角的「重新打开」按钮。
|
|
50
|
+
- 生效时机:先注入规则避免按钮闪一下,宿主配置通过 SSE 推送后按最终值校正。
|
|
51
|
+
- 上游若改了属性名:按钮会保持可见,控制台给出一次提示;在 `extraSelectors` 里追加新选择器即可,不必改插件代码。
|
|
52
|
+
|
|
53
|
+
### 5. 会话列表默认展开(原界面微调)
|
|
33
54
|
|
|
34
|
-
|
|
55
|
+
- 来源:核心 `@deepseek-ai/dsh-client-ui-workspace` 的 `SESSION_WATERMARK_BASE = 5`:每个工作区只渲染前 5 条会话,其余折叠在 `data-row-key="overflow:<workspaceKey>"` 的按钮后面,文案「展开其余 {n} 个会话」。核心没把这个阈值做成设置项。
|
|
56
|
+
- 做法:`MutationObserver`(节流 600ms)在列表渲染后自动点开该按钮,每轮最多补点 12 次(每轮 +5 条),直到该分组全部展开。
|
|
57
|
+
- **尊重手动收起**:只认 `event.isTrusted === true` 的点击——你手动点「收起」的分组按 workspace key 记住,本次页面会话内不再自动展开;再点「展开其余」即解除。插件自己的模拟点击是 `isTrusted === false`,不会误判。
|
|
58
|
+
- 刷新页面后回到默认全展开。
|
|
35
59
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
## Config
|
|
61
|
+
|
|
62
|
+
| 字段 | 类型 | 默认 | 说明 |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `hideRightSidebarToggle` | boolean | `true` | 隐藏右上角右栏开关;`false` 恢复原按钮 |
|
|
65
|
+
| `hideSessionLogExportMenu` | boolean | `false` | `true` 隐藏会话标题栏「⋯」导出菜单 |
|
|
66
|
+
| `expandWorkspaceSessions` | boolean | `true` | 左侧会话列表默认展开全部会话;`false` 恢复 DSH 原生折叠 |
|
|
67
|
+
| `extraSelectors` | string[] | `[]` | 追加隐藏的 CSS 选择器(上游改属性名时兜底) |
|
|
68
|
+
| `pollIntervalMs` | number | `30000` | SSE 不可用时的浏览器兜底轮询间隔(毫秒,最小 2000) |
|
|
69
|
+
| `debug` | boolean | `false` | 浏览器控制台输出诊断日志 |
|
|
70
|
+
|
|
71
|
+
- 改法(任选):在 profile 的 `cordis.patch.yml` 里覆盖本行 config;或通过 DSH 设置层修改该 Config 字段。
|
|
72
|
+
- 前三个布尔字段是 **volatile** 的:改动后宿主立即通过 SSE 推给页面,无需刷新。
|
|
73
|
+
|
|
74
|
+
## 接口(本机回环)
|
|
75
|
+
|
|
76
|
+
| 路由 | 返回 |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `GET /__dsh-feature-tweaks/config` | 当前配置快照(`selectors` 是最终生效的选择器列表) |
|
|
79
|
+
| `GET /__dsh-feature-tweaks/status` | `{ version, uptimeMs, connectedClients, config }` |
|
|
80
|
+
| `GET /__dsh-feature-tweaks/events` | SSE:`event: config` 推送配置;25 秒心跳顺带当前值,丢事件也能自愈 |
|
|
81
|
+
| `GET /__dsh-feature-tweaks/reload-safe` | `{ ok, revs, changed }`:刷新前安全探针 |
|
|
82
|
+
| `POST /__dsh-feature-tweaks/diag` | Client 半边写一行诊断日志,返回 `{ ok: true }` |
|
|
83
|
+
|
|
84
|
+
> 原 `dsh-ui-tweaks` 的 `/ui-tweaks/*` 路由已并入本前缀,旧前缀不再提供。
|
|
40
85
|
|
|
41
86
|
## 安装
|
|
42
87
|
|
|
43
88
|
```powershell
|
|
44
|
-
dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.
|
|
89
|
+
dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.4.0
|
|
45
90
|
```
|
|
46
91
|
|
|
47
92
|
装完后确认 profile 的 `dsh.profile.bundles` 含 `@leiyi-works/dsh-feature-tweaks`,且排在 `@deepseek-ai/dsh-base` 之后。**重启 DSH** 生效(配置在启动时合成)。
|
|
48
93
|
|
|
94
|
+
## 从 0.3.x + dsh-ui-tweaks 迁移(0.4.0)
|
|
95
|
+
|
|
96
|
+
1. 从 profile 的依赖与 `dsh.profile.bundles` 里移除 `@leiyi-works/dsh-ui-tweaks`(或 `dsh plugin remove`),把 `@leiyi-works/dsh-feature-tweaks` 升到 0.4.0;
|
|
97
|
+
2. 不需要迁移任何配置:界面微调的 Config 字段名与原 `dsh-ui-tweaks` 完全一致,`agent-team` 覆盖不变;
|
|
98
|
+
3. 旧界面微调的路由 `/ui-tweaks/*` 不再提供,新路由统一在 `/__dsh-feature-tweaks/*`;
|
|
99
|
+
4. `dsh-ui-tweaks` 在 npm 上仍可安装,但不再更新。
|
|
100
|
+
|
|
49
101
|
## 实现机制
|
|
50
102
|
|
|
51
|
-
|
|
103
|
+
本包以配置为主,界面与需要运行时代码的功能项落在 JS 里:
|
|
52
104
|
|
|
53
|
-
- `cordis.patch.yml` —— bundle patch
|
|
54
|
-
- `index.js` —— Host 行 `feature-tweaks
|
|
55
|
-
- `client.js` —— Web
|
|
105
|
+
- `cordis.patch.yml` —— bundle patch:插入本包 Host 行(含界面微调默认值),并按官方行 id 覆盖 `agent-team`。效果与手改 profile 的 `cordis.patch.yml` 完全一致,但能整体启停、单独删除、换机/重装后随插件恢复。
|
|
106
|
+
- `index.js` —— Host 行 `feature-tweaks`:界面侧提供配置/状态/SSE 路由;功能侧提供刷新安全探针、诊断路由,并包装 `process.send` 改写桌面壳 `quit-inspection` 应答里的 `scheduledTasks`。
|
|
107
|
+
- `client.js` —— Web 侧半边:隐藏 CSS、会话列表自动展开、SSE 订阅 + 兜底轮询 + 失效诊断、刷新快捷键(含 F5 DOM 兜底)。
|
|
108
|
+
- `locale/{zh,en}.json` —— 插件页显示名与介绍。
|
|
56
109
|
|
|
57
110
|
**关键坑**:loader 的 patch 会**整段替换**目标行的 `config`(不是深合并)。覆盖时必须把该行原本的其它字段一起重述——例如 `agent-team` 要带上 `maxTasks: 256`,否则会退回 schema 默认值。
|
|
58
111
|
|
|
@@ -68,20 +121,29 @@ dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.3.0
|
|
|
68
121
|
## 验证
|
|
69
122
|
|
|
70
123
|
- 重启后新建一个会话,打开「模型与推理等级」菜单,底部「启用智能体团队协作」应为开;该会话应带 `team_task_*` 工具;
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
124
|
+
- 已存在的会话(保存过选择)行为不变;手动关掉某一会话的开关后,该会话保持关闭。
|
|
125
|
+
- 打开会话:右上角右栏展开按钮应不可见;右栏仍可通过左侧入口/快捷键打开。
|
|
126
|
+
- 左侧会话列表中每个工作区应直接显示全部会话;手动点「收起」后该分组保持收起,刷新页面后回到全展开。
|
|
127
|
+
- 桌面端按 <kbd>F5</kbd> 应刷新页面;设置 → 快捷键里能看到「刷新页面」并改了生效。刚装/更新过插件时按 F5 应提示「请完全退出 DSH 再打开一次」(这是保护,不是故障)。
|
|
75
128
|
- 退出确认:先建一个有定时任务的会话(让它处于已排期状态),再点托盘「退出」——应直接退出、不再弹「应用关闭期间,定时任务不会运行」。若有任务正在跑,仍会弹确认,但文案只有「当前正在运行的任务将会中断」。
|
|
76
|
-
-
|
|
129
|
+
- 日志佐证:`<DSH_HOME>/data/feature-tweaks-diag.log` 里有 `quit-inspection-patch-ready`、`reload-shortcut-ready`。
|
|
77
130
|
|
|
78
131
|
## 撤回
|
|
79
132
|
|
|
80
133
|
- **整体**:从 profile 的 `dsh.profile.bundles` 移除 `@leiyi-works/dsh-feature-tweaks`,一步回到官方默认;
|
|
81
134
|
- **单项(配置类)**:在 profile 的 `cordis.patch.yml`(更晚应用)里把对应行覆盖回去;
|
|
82
|
-
-
|
|
135
|
+
- **界面类**:把对应 Config 字段改成 `false`,几秒内生效;
|
|
83
136
|
- **刷新快捷键**:设置 → 快捷键里清除「刷新页面」绑定即可,不影响本包其它微调;
|
|
84
|
-
-
|
|
137
|
+
- **退出确认**:删掉 `index.js` 里对 `installQuitInspectionTweak(ctx)` 的调用后重启;
|
|
138
|
+
- **单会话团队**:直接在「模型与推理等级」菜单里关(仅本会话生效)。
|
|
139
|
+
|
|
140
|
+
## 已知限制
|
|
141
|
+
|
|
142
|
+
- 右栏隐藏依赖 DSH 自带 `ui-sidebar-right` 的 `data-sidebar-right-expand` 属性;上游大版本若改属性名,用 `extraSelectors` 兜底(控制台会提示),或更新默认选择器。
|
|
143
|
+
- 会话列表展开依赖核心的 overflow 按钮(`data-row-key^="overflow:"` / `class*=sessionOverflowButton`)与每次 +5 条的递增逻辑;上游若改了这两项,改插件常量。
|
|
144
|
+
- 会话列表是「自动点开」而不是改核心状态:工作区会话特别多(>60 条折叠)时可能需要多轮补点。
|
|
145
|
+
- 手动「收起」的分组在当前页面会话内不会被再次自动展开;刷新页面后回到默认全展开。
|
|
146
|
+
- SSE 断线时退回轮询,最长延迟一个轮询周期(默认 30 秒);宿主不可达时保持最后一次已知状态(默认隐藏)。
|
|
85
147
|
|
|
86
148
|
## License
|
|
87
149
|
|
package/client.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Client half of dsh-feature-tweaks.
|
|
2
|
+
* Client half of @leiyi-works/dsh-feature-tweaks.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Ctrl+Shift+R in a browser), moved here from
|
|
6
|
-
* @leiyi-works/dsh-sidebar-folders 0.13.4 so functional tweaks live in one
|
|
7
|
-
* bundle. The core shortcut service rejects overlapping default combinations,
|
|
8
|
-
* so the key exists in exactly one plugin.
|
|
4
|
+
* 合并自 dsh-ui-tweaks 1.2.5 与 dsh-feature-tweaks 0.3.0:
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
6
|
+
* 界面侧(原 dsh-ui-tweaks):
|
|
7
|
+
* 1) 隐藏会话头部右上角的右侧栏展开按钮(「打开右侧边栏」控件)。选择器只用
|
|
8
|
+
* `@deepseek-ai/dsh-client-ui-sidebar-right` 写在 ExpandButton 上的稳定属性
|
|
9
|
+
* `data-sidebar-right-expand`,不会误伤别的按钮。
|
|
10
|
+
* 2) 左侧会话列表默认展开全部会话。DSH 核心(`@deepseek-ai/dsh-client-ui-workspace`,
|
|
11
|
+
* `SESSION_WATERMARK_BASE = 5`)每个工作区只显示前 5 条,其余折叠成
|
|
12
|
+
* 「展开其余 N 个会话」按钮;这里在列表渲染后自动点开,直到全部分组展开。
|
|
13
|
+
* 用户手动点「收起」的分组会被记住,本次页面会话内不再自动展开。
|
|
14
|
+
*
|
|
15
|
+
* 功能侧(原 dsh-feature-tweaks):
|
|
16
|
+
* 3) 注册「刷新页面」快捷键(桌面端 F5 / 网页端 Ctrl+Shift+R)。按 F5 前先问
|
|
17
|
+
* Host `GET /__dsh-feature-tweaks/reload-safe`;若本次启动后有 Client bundle 被重建,
|
|
18
|
+
* 刷新会因桌面壳的旧 boot manifest 弹「应用无法启动」,此时只在页面提示
|
|
19
|
+
* 「请完全退出 DSH 再打开一次」,不刷新。
|
|
20
|
+
*
|
|
21
|
+
* 配置通过 SSE(`/__dsh-feature-tweaks/events`)热更新,SSE 不可用时退回慢轮询
|
|
22
|
+
* (`/__dsh-feature-tweaks/config`)。上游若改了属性名,按钮会保持可见并在控制台提示
|
|
23
|
+
* 用 `extraSelectors` 兜底,不必改插件代码。
|
|
14
24
|
*/
|
|
15
25
|
window.__ModuleLoader__.load({
|
|
16
26
|
id: '@leiyi-works/dsh-feature-tweaks',
|
|
@@ -18,9 +28,47 @@ window.__ModuleLoader__.load({
|
|
|
18
28
|
/** Locale namespace owned by this bundle. */
|
|
19
29
|
const NS = 'featureTweaks'
|
|
20
30
|
/** Host route prefix owned by the Host half. */
|
|
21
|
-
const
|
|
31
|
+
const API = '/__dsh-feature-tweaks/'
|
|
32
|
+
/** Style element that carries the hide rule. */
|
|
33
|
+
const STYLE_ID = 'dsh-feature-tweaks-hide-right-sidebar-toggle'
|
|
34
|
+
/** Stable attribute written by ui-sidebar-right's ExpandButton. */
|
|
35
|
+
const DEFAULT_SELECTORS = ['button[data-sidebar-right-expand]']
|
|
36
|
+
/**
|
|
37
|
+
* 会话标题栏右侧「⋯」导出菜单(session-log-export)的隐藏选择器。
|
|
38
|
+
* CSS Module 类名会随 DSH 构建变化(不同构建里见过 K0RNnq_ / nL4_yW_ 前缀),
|
|
39
|
+
* 所以同时用 aria-label 兜底;aria-label 跟随界面语言变化,中英文都列上。
|
|
40
|
+
*/
|
|
41
|
+
const EXPORT_MENU_SELECTORS = [
|
|
42
|
+
'[class*="K0RNnq_moreButton"]',
|
|
43
|
+
'[class*="nL4_yW_moreButton"]',
|
|
44
|
+
'button[aria-label="更多操作"]',
|
|
45
|
+
'button[aria-label="More actions"]',
|
|
46
|
+
]
|
|
47
|
+
const POLL_FALLBACK_MS = 30000
|
|
48
|
+
const DIAGNOSTIC_DELAY_MS = 6000
|
|
49
|
+
/**
|
|
50
|
+
* 左侧会话列表里「展开其余 N 个会话」按钮的选择器:
|
|
51
|
+
* `data-row-key="overflow:<workspaceKey>"` 是 workspace 组件写的稳定锚点,
|
|
52
|
+
* class 里的 `sessionOverflowButton` 作为兜底(上游若改了 data 属性)。
|
|
53
|
+
*/
|
|
54
|
+
const SESSION_OVERFLOW_SELECTOR = 'button[data-row-key^="overflow:"], button[class*="sessionOverflowButton"]'
|
|
55
|
+
/** 自动展开的最小重跑间隔(页面渲染很快,节流一下避免和流式输出抢帧)。 */
|
|
56
|
+
const EXPAND_MIN_INTERVAL_MS = 600
|
|
57
|
+
/** 单个 workspace 分组最多连续补点轮数(每轮 +5 条,足够覆盖极端数量)。 */
|
|
58
|
+
const EXPAND_MAX_ROUNDS = 12
|
|
59
|
+
|
|
60
|
+
let selectors = DEFAULT_SELECTORS.slice()
|
|
61
|
+
let hidden = true
|
|
62
|
+
// 与 Host Config 的默认值对齐:导出菜单默认显示,只有明确配置为 true 才隐藏。
|
|
63
|
+
let hideExportMenu = false
|
|
64
|
+
let debug = false
|
|
65
|
+
let diagnosticTimer = null
|
|
66
|
+
let diagnosed = false
|
|
67
|
+
let expandSessions = true
|
|
68
|
+
/** 会话列表自动展开实例(配置热更新时可立即触发一次)。 */
|
|
69
|
+
let sessionExpander = null
|
|
22
70
|
|
|
23
|
-
/**
|
|
71
|
+
/** 中文词条(快捷键标签与「先别刷新」提示)。 */
|
|
24
72
|
const zh = {
|
|
25
73
|
'reload.label': '刷新页面',
|
|
26
74
|
'reload.blocked': '插件代码在本次启动后更新过({names}),现在刷新会弹启动报错。请完全退出 DSH 再打开一次。',
|
|
@@ -31,6 +79,233 @@ window.__ModuleLoader__.load({
|
|
|
31
79
|
'reload.blocked': 'Plugin code changed after this app started ({names}); reloading now would fail with a startup error. Quit DSH completely and open it again.',
|
|
32
80
|
}
|
|
33
81
|
|
|
82
|
+
/** Fallback translator used until the locale service hands over its bound one. */
|
|
83
|
+
let t = (key, vars) => {
|
|
84
|
+
const template = (navigator?.language ?? '').startsWith('zh') ? zh[key] : en[key]
|
|
85
|
+
const text = template ?? key
|
|
86
|
+
if (vars === undefined) return text
|
|
87
|
+
return text.replace(/\{(\w+)\}/g, (match, name) => (vars[name] === undefined ? match : String(vars[name])))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function log(...args) {
|
|
91
|
+
if (debug) console.info('[dsh-feature-tweaks]', ...args)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Build the CSS text for the current selector list. */
|
|
95
|
+
function buildCss() {
|
|
96
|
+
const list = hideExportMenu ? selectors.concat(EXPORT_MENU_SELECTORS) : selectors
|
|
97
|
+
return list.map((selector) => `${selector}{display:none !important}`).join('\n')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Insert or remove the hide rule. */
|
|
101
|
+
function ensureStyle() {
|
|
102
|
+
const existing = document.getElementById(STYLE_ID)
|
|
103
|
+
if (!hidden) {
|
|
104
|
+
if (existing !== null) existing.remove()
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
if (existing !== null) {
|
|
108
|
+
const css = buildCss()
|
|
109
|
+
if (existing.textContent !== css) existing.textContent = css
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
if (document.head === null) return
|
|
113
|
+
const style = document.createElement('style')
|
|
114
|
+
style.id = STYLE_ID
|
|
115
|
+
style.setAttribute('data-dsh-feature-tweaks', 'hide-right-sidebar-toggle')
|
|
116
|
+
style.textContent = buildCss()
|
|
117
|
+
document.head.appendChild(style)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Warn once when the hide rule is active but nothing matches (upstream changed). */
|
|
121
|
+
function scheduleDiagnostic() {
|
|
122
|
+
if (diagnosticTimer !== null) clearTimeout(diagnosticTimer)
|
|
123
|
+
diagnosticTimer = null
|
|
124
|
+
if (!hidden || diagnosed) return
|
|
125
|
+
diagnosticTimer = setTimeout(() => {
|
|
126
|
+
diagnosticTimer = null
|
|
127
|
+
if (!hidden || diagnosed) return
|
|
128
|
+
let matched = false
|
|
129
|
+
for (const selector of selectors) {
|
|
130
|
+
try {
|
|
131
|
+
if (document.querySelector(selector) !== null) {
|
|
132
|
+
matched = true
|
|
133
|
+
break
|
|
134
|
+
}
|
|
135
|
+
} catch {
|
|
136
|
+
log('invalid selector', selector)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (!matched) {
|
|
140
|
+
diagnosed = true
|
|
141
|
+
console.warn(
|
|
142
|
+
'[dsh-feature-tweaks] 隐藏已启用,但没有找到目标按钮。上游可能改了 data 属性名;' +
|
|
143
|
+
'可在插件 Config 的 extraSelectors 里追加新的选择器(无需改插件代码)。',
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
}, DIAGNOSTIC_DELAY_MS)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 会话列表「展开其余 N 个会话」兜底。
|
|
151
|
+
*
|
|
152
|
+
* DSH 核心每个 workspace 只渲染前 5 条会话(SESSION_WATERMARK_BASE),其余折叠在一个
|
|
153
|
+
* overflow 按钮后面。这里在列表渲染后自动点开该按钮,让列表默认显示全部会话;
|
|
154
|
+
* 用户手动点「收起」的分组会被记住,本次页面会话内不再自动展开。
|
|
155
|
+
*
|
|
156
|
+
* @returns 展开器(expandNow / dispose);环境不支持时返回 null。
|
|
157
|
+
*/
|
|
158
|
+
function installSessionListExpander() {
|
|
159
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') return null
|
|
160
|
+
if (typeof MutationObserver !== 'function') return null
|
|
161
|
+
const userCollapsed = new Set()
|
|
162
|
+
let disposed = false
|
|
163
|
+
let timer = null
|
|
164
|
+
let lastRun = 0
|
|
165
|
+
let rounds = 0
|
|
166
|
+
let observer = null
|
|
167
|
+
|
|
168
|
+
const overflowButtons = () => {
|
|
169
|
+
try {
|
|
170
|
+
return Array.from(document.querySelectorAll(SESSION_OVERFLOW_SELECTOR))
|
|
171
|
+
} catch {
|
|
172
|
+
return []
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const groupKeyOf = (button) => {
|
|
176
|
+
const rowKey = button.getAttribute('data-row-key')
|
|
177
|
+
if (typeof rowKey === 'string' && rowKey.startsWith('overflow:')) return rowKey.slice(9)
|
|
178
|
+
return null
|
|
179
|
+
}
|
|
180
|
+
const isCollapsed = (button) => button.getAttribute('aria-expanded') === 'false'
|
|
181
|
+
|
|
182
|
+
const schedule = (delay) => {
|
|
183
|
+
if (disposed || timer !== null) return
|
|
184
|
+
timer = window.setTimeout(() => {
|
|
185
|
+
timer = null
|
|
186
|
+
run()
|
|
187
|
+
}, Math.max(0, delay))
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const run = () => {
|
|
191
|
+
if (disposed || !expandSessions) return
|
|
192
|
+
const now = Date.now()
|
|
193
|
+
if (now - lastRun < EXPAND_MIN_INTERVAL_MS) {
|
|
194
|
+
schedule(EXPAND_MIN_INTERVAL_MS - (now - lastRun))
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
lastRun = now
|
|
198
|
+
if (rounds >= EXPAND_MAX_ROUNDS) return
|
|
199
|
+
let clicked = 0
|
|
200
|
+
for (const button of overflowButtons()) {
|
|
201
|
+
if (!isCollapsed(button)) continue
|
|
202
|
+
const key = groupKeyOf(button)
|
|
203
|
+
if (key !== null && userCollapsed.has(key)) continue
|
|
204
|
+
try {
|
|
205
|
+
button.click()
|
|
206
|
+
clicked += 1
|
|
207
|
+
} catch {
|
|
208
|
+
/* 忽略单次点击失败,下一轮再试 */
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (clicked > 0) {
|
|
212
|
+
rounds += 1
|
|
213
|
+
log('session list expanded', clicked)
|
|
214
|
+
schedule(160)
|
|
215
|
+
} else {
|
|
216
|
+
rounds = 0
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 尊重用户手动「收起」:按 workspace 分组记住,本次页面会话内不再自动展开该分组。
|
|
221
|
+
const onClick = (event) => {
|
|
222
|
+
if (event.isTrusted !== true) return
|
|
223
|
+
const target = event.target
|
|
224
|
+
if (!(target instanceof Element)) return
|
|
225
|
+
const button = target.closest(SESSION_OVERFLOW_SELECTOR)
|
|
226
|
+
if (button === null) return
|
|
227
|
+
const key = groupKeyOf(button)
|
|
228
|
+
if (key === null) return
|
|
229
|
+
if (button.getAttribute('aria-expanded') === 'true') userCollapsed.add(key)
|
|
230
|
+
else userCollapsed.delete(key)
|
|
231
|
+
}
|
|
232
|
+
document.addEventListener('click', onClick, true)
|
|
233
|
+
|
|
234
|
+
observer = new MutationObserver(() => {
|
|
235
|
+
schedule(EXPAND_MIN_INTERVAL_MS)
|
|
236
|
+
})
|
|
237
|
+
observer.observe(document.body, {
|
|
238
|
+
childList: true,
|
|
239
|
+
subtree: true,
|
|
240
|
+
attributes: true,
|
|
241
|
+
attributeFilter: ['aria-expanded'],
|
|
242
|
+
})
|
|
243
|
+
// 首屏布局可能晚于插件加载,先排一轮,后面的 MutationObserver 会继续兜底。
|
|
244
|
+
schedule(200)
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
expandNow() {
|
|
248
|
+
rounds = 0
|
|
249
|
+
schedule(60)
|
|
250
|
+
},
|
|
251
|
+
dispose() {
|
|
252
|
+
disposed = true
|
|
253
|
+
document.removeEventListener('click', onClick, true)
|
|
254
|
+
if (observer !== null) observer.disconnect()
|
|
255
|
+
if (timer !== null) window.clearTimeout(timer)
|
|
256
|
+
},
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Apply one config payload from the host. */
|
|
261
|
+
function applyConfig(data) {
|
|
262
|
+
if (data === null || typeof data !== 'object') return
|
|
263
|
+
hidden = data.hideRightSidebarToggle !== false
|
|
264
|
+
hideExportMenu = data.hideSessionLogExportMenu === true
|
|
265
|
+
expandSessions = data.expandWorkspaceSessions !== false
|
|
266
|
+
const extra = Array.isArray(data.extraSelectors)
|
|
267
|
+
? data.extraSelectors.filter((item) => typeof item === 'string' && item.trim() !== '')
|
|
268
|
+
: []
|
|
269
|
+
selectors = DEFAULT_SELECTORS.concat(extra)
|
|
270
|
+
debug = data.debug === true
|
|
271
|
+
log('config applied', { hidden, hideExportMenu, selectors, expandSessions })
|
|
272
|
+
ensureStyle()
|
|
273
|
+
scheduleDiagnostic()
|
|
274
|
+
if (expandSessions && sessionExpander !== null) sessionExpander.expandNow()
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Read the config once over plain HTTP (fallback / startup). */
|
|
278
|
+
async function syncOnce() {
|
|
279
|
+
try {
|
|
280
|
+
const response = await fetch(API + 'config', { headers: { accept: 'application/json' } })
|
|
281
|
+
if (!response.ok) return
|
|
282
|
+
const data = await response.json()
|
|
283
|
+
if (data !== null && typeof data === 'object') applyConfig(data)
|
|
284
|
+
} catch {
|
|
285
|
+
/* host not ready yet: keep the default */
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Subscribe to host pushes; returns the EventSource or null when unsupported. */
|
|
290
|
+
function connectEvents() {
|
|
291
|
+
if (typeof EventSource !== 'function') return null
|
|
292
|
+
try {
|
|
293
|
+
const source = new EventSource(API + 'events')
|
|
294
|
+
source.addEventListener('config', (event) => {
|
|
295
|
+
try {
|
|
296
|
+
applyConfig(JSON.parse(event.data))
|
|
297
|
+
} catch {
|
|
298
|
+
log('bad config payload')
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
source.addEventListener('open', () => log('SSE connected'))
|
|
302
|
+
source.addEventListener('error', () => log('SSE unavailable, relying on fallback polling'))
|
|
303
|
+
return source
|
|
304
|
+
} catch {
|
|
305
|
+
return null
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
34
309
|
/** Page base that keeps requests on the page's own origin. */
|
|
35
310
|
function pageBase() {
|
|
36
311
|
if (typeof document !== 'undefined' && typeof document.baseURI === 'string' && document.baseURI !== '') return document.baseURI
|
|
@@ -41,9 +316,9 @@ window.__ModuleLoader__.load({
|
|
|
41
316
|
/** Resolve one Host route against the page base. */
|
|
42
317
|
function apiUrl(suffix) {
|
|
43
318
|
try {
|
|
44
|
-
return new URL(
|
|
319
|
+
return new URL(API + suffix, pageBase()).href
|
|
45
320
|
} catch {
|
|
46
|
-
return
|
|
321
|
+
return API + suffix
|
|
47
322
|
}
|
|
48
323
|
}
|
|
49
324
|
|
|
@@ -101,12 +376,10 @@ window.__ModuleLoader__.load({
|
|
|
101
376
|
|
|
102
377
|
return {
|
|
103
378
|
name: '@leiyi-works/dsh-feature-tweaks',
|
|
104
|
-
inject: ['locale'],
|
|
105
379
|
apply(ctx) {
|
|
106
|
-
|
|
107
|
-
const t = ctx.locale.bind(NS)
|
|
108
|
-
|
|
380
|
+
let stopped = false
|
|
109
381
|
let reloading = false
|
|
382
|
+
|
|
110
383
|
/** Probe the Host, then reload only when no Client bundle is stale. */
|
|
111
384
|
const scheduleReload = async () => {
|
|
112
385
|
if (reloading) return
|
|
@@ -139,34 +412,58 @@ window.__ModuleLoader__.load({
|
|
|
139
412
|
}, 120)
|
|
140
413
|
}
|
|
141
414
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
415
|
+
// 界面侧:先注入隐藏规则(避免按钮闪一下),再装会话列表展开与配置订阅。
|
|
416
|
+
ensureStyle()
|
|
417
|
+
sessionExpander = installSessionListExpander()
|
|
418
|
+
const source = connectEvents()
|
|
419
|
+
void syncOnce()
|
|
420
|
+
const poll = setInterval(() => {
|
|
421
|
+
if (!stopped) void syncOnce()
|
|
422
|
+
}, POLL_FALLBACK_MS)
|
|
423
|
+
|
|
424
|
+
// 局部化:只接管快捷键标签与提示文案,不阻断界面微调。
|
|
425
|
+
try {
|
|
426
|
+
ctx.inject(['locale'], (scope) => {
|
|
427
|
+
scope.effect(() => scope.locale.register(NS, { zh, en }), 'feature-tweaks: dictionaries')
|
|
428
|
+
t = scope.locale.bind(NS)
|
|
429
|
+
})
|
|
430
|
+
} catch (error) {
|
|
431
|
+
reportDiag('locale-inject-failed: ' + errorText(error))
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// 功能侧:「刷新页面」快捷键(桌面端 F5 / 网页端 Ctrl+Shift+R)。
|
|
435
|
+
try {
|
|
436
|
+
ctx.inject(['shortcuts'], (scope) => {
|
|
437
|
+
scope.effect(() => {
|
|
438
|
+
try {
|
|
439
|
+
const dispose = scope.shortcuts.register({
|
|
440
|
+
id: 'feature-tweaks.reload',
|
|
441
|
+
label: () => t('reload.label'),
|
|
442
|
+
aliases: ['reload', 'refresh', '刷新'],
|
|
443
|
+
defaults: {
|
|
444
|
+
'desktop:windows': { code: 'F5', modifiers: [] },
|
|
445
|
+
'desktop:macos': { code: 'F5', modifiers: [] },
|
|
446
|
+
'web:windows': { code: 'KeyR', modifiers: ['primary', 'shift'] },
|
|
447
|
+
'web:macos': { code: 'KeyR', modifiers: ['primary', 'shift'] },
|
|
448
|
+
},
|
|
449
|
+
regions: ['page', 'editable', 'terminal'],
|
|
450
|
+
modals: [],
|
|
451
|
+
resolve: () => ({
|
|
452
|
+
status: 'handled',
|
|
453
|
+
run: () => { void scheduleReload() },
|
|
454
|
+
}),
|
|
455
|
+
})
|
|
456
|
+
reportDiag('reload-shortcut-ready')
|
|
457
|
+
return dispose
|
|
458
|
+
} catch (error) {
|
|
459
|
+
reportDiag('reload-shortcut-failed: ' + errorText(error))
|
|
460
|
+
return () => {}
|
|
461
|
+
}
|
|
462
|
+
}, 'feature-tweaks: reload shortcut')
|
|
463
|
+
})
|
|
464
|
+
} catch (error) {
|
|
465
|
+
reportDiag('shortcuts-inject-failed: ' + errorText(error))
|
|
466
|
+
}
|
|
170
467
|
|
|
171
468
|
// Fallback for the desktop shell: its native shortcut bridge only
|
|
172
469
|
// forwards a key once the shell has received this command's definition,
|
|
@@ -184,6 +481,20 @@ window.__ModuleLoader__.load({
|
|
|
184
481
|
document.addEventListener('keydown', onKeyDown, true)
|
|
185
482
|
return () => document.removeEventListener('keydown', onKeyDown, true)
|
|
186
483
|
}, 'feature-tweaks: reload key fallback')
|
|
484
|
+
|
|
485
|
+
// Cleanup: timers, SSE, expander, style — unload must restore the page.
|
|
486
|
+
ctx.effect(() => () => {
|
|
487
|
+
stopped = true
|
|
488
|
+
clearInterval(poll)
|
|
489
|
+
if (diagnosticTimer !== null) clearTimeout(diagnosticTimer)
|
|
490
|
+
if (source !== null) source.close()
|
|
491
|
+
if (sessionExpander !== null) {
|
|
492
|
+
sessionExpander.dispose()
|
|
493
|
+
sessionExpander = null
|
|
494
|
+
}
|
|
495
|
+
const style = document.getElementById(STYLE_ID)
|
|
496
|
+
if (style !== null) style.remove()
|
|
497
|
+
}, 'feature-tweaks: cleanup')
|
|
187
498
|
},
|
|
188
499
|
}
|
|
189
500
|
},
|
package/cordis.patch.yml
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
# dsh-feature-tweaks — 功能微调(bundle
|
|
1
|
+
# dsh-feature-tweaks — 功能微调(bundle patch)
|
|
2
2
|
#
|
|
3
3
|
# 定位:DSH 每次版本变化都会带来或多或少的官方行为差异、默认值不合意的地方。
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
4
|
+
# 本包是这些「微调」的固定落点——功能/默认值按官方行 id 覆盖,界面/DOM 由
|
|
5
|
+
# index.js + client.js 做最小侵入补偿;不改任何核心包。
|
|
6
|
+
#
|
|
7
|
+
# 0.4.0 起并入原「界面微调」@leiyi-works/dsh-ui-tweaks 1.2.5:
|
|
8
|
+
# · 界面类(隐藏右栏展开按钮、会话列表默认展开)→ 本包 Host 行的 Config + client.js;
|
|
9
|
+
# · 功能类(默认值覆盖、刷新快捷键、退出确认)→ 本 patch 覆盖 + index.js/client.js。
|
|
10
|
+
# 旧的 dsh-ui-tweaks 包不再需要,卸载即可。
|
|
7
11
|
#
|
|
8
12
|
# 机制:本包以 bundle patch 为主——只提供一份在 dsh-base 之后叠加的 bundle
|
|
9
13
|
# patch,效果与手改 profile 的 cordis.patch.yml 相同,但能整体启停、单独删除,
|
|
@@ -11,8 +15,8 @@
|
|
|
11
15
|
# 「代码侧微调」)落在 index.js / client.js。
|
|
12
16
|
#
|
|
13
17
|
# 维护约定:
|
|
14
|
-
# 1. 一项微调 = 一个 patch
|
|
15
|
-
#
|
|
18
|
+
# 1. 一项微调 = 一个 patch 条目(或一段代码)+ 注释(官方默认是什么、本包改成
|
|
19
|
+
# 什么、为什么、怎么撤);升级 DSH 后按注释逐条核对是否还成立。
|
|
16
20
|
# 2. loader 的 patch 是「整段替换」目标行的 config(不是深合并),覆盖时必须把
|
|
17
21
|
# 该行原本的其它字段一并重述,否则会退回 schema 默认值。
|
|
18
22
|
# 3. 每一条都独立,能单独删掉而不影响其它条目。
|
|
@@ -20,10 +24,26 @@
|
|
|
20
24
|
# 整体撤回:从 profile 的 dsh.profile.bundles 里移除本 bundle,即回到官方默认。
|
|
21
25
|
# 只撤某一项:在 profile 的 cordis.patch.yml(比本 bundle 更晚应用)里覆盖回去。
|
|
22
26
|
|
|
23
|
-
#
|
|
27
|
+
# ── 0. 本包 Host 行(界面微调默认值 + 插件页标记)──────────────────────────
|
|
28
|
+
# hideRightSidebarToggle: true → 隐藏会话右上角的右侧栏展开按钮(默认)
|
|
29
|
+
# hideRightSidebarToggle: false → 保留原按钮
|
|
30
|
+
# hideSessionLogExportMenu: false → 保留会话标题栏「⋯」导出菜单(默认)
|
|
31
|
+
# hideSessionLogExportMenu: true → 隐藏该菜单
|
|
32
|
+
# expandWorkspaceSessions: true → 会话列表默认展开全部会话(默认)
|
|
33
|
+
# expandWorkspaceSessions: false → 保留 DSH 原生「展开其余 N 个会话」折叠
|
|
34
|
+
# extraSelectors: [] → 隐藏规则的额外选择器(上游改属性名时兜底)
|
|
35
|
+
# pollIntervalMs: 30000 → SSE 不可用时的浏览器兜底轮询间隔
|
|
36
|
+
# debug: false → 浏览器控制台诊断日志
|
|
24
37
|
- insert:
|
|
25
38
|
- id: feature-tweaks
|
|
26
39
|
name: '@leiyi-works/dsh-feature-tweaks'
|
|
40
|
+
config:
|
|
41
|
+
hideRightSidebarToggle: true
|
|
42
|
+
hideSessionLogExportMenu: false
|
|
43
|
+
expandWorkspaceSessions: true
|
|
44
|
+
extraSelectors: []
|
|
45
|
+
pollIntervalMs: 30000
|
|
46
|
+
debug: false
|
|
27
47
|
|
|
28
48
|
# ── 1. 新会话默认开启「智能体团队协作」────────────────────────────────────────
|
|
29
49
|
# 官方默认:agent-team.defaultEnabled = false —— 每个新会话默认关闭团队,要在
|
|
@@ -40,13 +60,15 @@
|
|
|
40
60
|
defaultEnabled: true
|
|
41
61
|
|
|
42
62
|
# ── 代码侧微调(不落在 patch 里,见 index.js / client.js)───────────────────
|
|
43
|
-
#
|
|
44
|
-
#
|
|
63
|
+
# 下面几项改的是运行时行为,不是某一行配置,所以在包里用代码实现:
|
|
64
|
+
#
|
|
65
|
+
# a. 界面侧:隐藏右栏展开按钮(CSS 注入 + 失效自诊断)、左侧会话列表默认展开
|
|
66
|
+
# (MutationObserver 点开核心的 overflow 按钮,尊重手动「收起」),见 client.js。
|
|
45
67
|
#
|
|
46
|
-
#
|
|
68
|
+
# b. 「刷新页面」快捷键:桌面端 F5 / 网页端 Ctrl+Shift+R,由 client.js 注册,
|
|
47
69
|
# index.js 提供 /__dsh-feature-tweaks/reload-safe 探针。
|
|
48
70
|
#
|
|
49
|
-
#
|
|
71
|
+
# c. 桌面端退出不再因定时任务弹确认:Electron 壳退出前会向 Host 发
|
|
50
72
|
# `quit-inspection` 询问「有任务在跑吗 / 有已排期的定时任务吗」,只有其中
|
|
51
73
|
# 任一项为真就弹原生确认框。index.js 拦截这条应答,把 scheduledTasks 恒
|
|
52
74
|
# 置为 false:只有定时任务时直接静默退出;确有任务在跑时仍确认,文案自动
|
package/index.js
CHANGED
|
@@ -1,39 +1,102 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-feature-tweaks — Host half.
|
|
2
|
+
* @leiyi-works/dsh-feature-tweaks — Host half.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* need runtime code:
|
|
4
|
+
* 合并自 dsh-ui-tweaks 1.2.5(界面/DOM 微调)与 dsh-feature-tweaks 0.3.0
|
|
5
|
+
* (功能/默认值微调),一个 Host 行同时承担两半的宿主职责:
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* so the Client half explains the restart instead of reloading blindly.
|
|
7
|
+
* 界面侧(原 dsh-ui-tweaks):
|
|
8
|
+
* GET /__dsh-feature-tweaks/config → { hideRightSidebarToggle, hideSessionLogExportMenu,
|
|
9
|
+
* expandWorkspaceSessions, extraSelectors,
|
|
10
|
+
* pollIntervalMs, debug, selectors }
|
|
11
|
+
* GET /__dsh-feature-tweaks/status → 诊断:version / uptimeMs / connectedClients / config
|
|
12
|
+
* GET /__dsh-feature-tweaks/events → Server-Sent Events;连接时推一次配置,配置相关事件
|
|
13
|
+
* 再推,25 秒心跳顺带当前值(丢事件也能自愈)
|
|
14
|
+
* Config 的字段是 volatile 的:设置/补丁层一改,宿主立即通过 SSE 推给页面。
|
|
17
15
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* 功能侧(原 dsh-feature-tweaks):
|
|
17
|
+
* GET /__dsh-feature-tweaks/reload-safe → { ok, revs, changed }:页面刷新前的安全探针
|
|
18
|
+
* (桌面壳保留启动时的 boot manifest,本次启动后
|
|
19
|
+
* 重建过的 Client bundle 会让刷新弹「应用无法启动」)
|
|
20
|
+
* POST /__dsh-feature-tweaks/diag → Client 半边写一行诊断日志
|
|
21
|
+
* 包装 process.send:桌面壳退出前的 quit-inspection 应答里 scheduledTasks 恒为
|
|
22
|
+
* false(定时任务不再单独触发退出确认;确实有任务在跑仍然确认)。
|
|
20
23
|
*
|
|
21
24
|
* Diagnostics: <DSH_HOME>/data/feature-tweaks-diag.log
|
|
22
25
|
*/
|
|
23
26
|
import fsp from 'node:fs/promises'
|
|
24
27
|
import os from 'node:os'
|
|
25
28
|
import path from 'node:path'
|
|
29
|
+
import z from '@deepseek-ai/schemastery'
|
|
26
30
|
|
|
31
|
+
/** Loader entry module name. */
|
|
27
32
|
export const name = 'feature-tweaks'
|
|
28
33
|
|
|
34
|
+
/** Reported by /__dsh-feature-tweaks/status; keep in sync with package.json. */
|
|
35
|
+
const VERSION = '0.4.0'
|
|
36
|
+
const LOG_TAG = 'dsh-feature-tweaks'
|
|
29
37
|
/** Route prefix claimed on the Web carrier. */
|
|
30
38
|
const ROUTE_PREFIX = '/__dsh-feature-tweaks'
|
|
39
|
+
/** Upstream attribute written by @deepseek-ai/dsh-client-ui-sidebar-right's ExpandButton. */
|
|
40
|
+
const DEFAULT_SELECTOR = 'button[data-sidebar-right-expand]'
|
|
41
|
+
/** SSE heartbeat: also re-sends the current config so a missed event self-heals. */
|
|
42
|
+
const HEARTBEAT_MS = 25_000
|
|
31
43
|
/** Upper bound for one diagnostic body, in bytes. */
|
|
32
44
|
const MAX_BODY_BYTES = 64 * 1024
|
|
33
45
|
/** Marks an already wrapped `process.send`, so re-applying the plugin cannot stack wrappers. */
|
|
34
46
|
const QUIT_INSPECTION_PATCH = Symbol.for('dsh-feature-tweaks.quit-inspection')
|
|
35
47
|
|
|
36
|
-
|
|
48
|
+
export const Config = z.object({
|
|
49
|
+
hideRightSidebarToggle: z
|
|
50
|
+
.boolean()
|
|
51
|
+
.default(true)
|
|
52
|
+
.description('隐藏会话右上角的右侧栏开关按钮(默认隐藏;关闭后按钮恢复)。保存后浏览器端数秒内热更新,无需刷新页面。')
|
|
53
|
+
.volatile(),
|
|
54
|
+
hideSessionLogExportMenu: z
|
|
55
|
+
.boolean()
|
|
56
|
+
.default(false)
|
|
57
|
+
.description('隐藏会话标题栏右上角的「⋯」导出菜单(session-log-export);默认显示,设为 true 才隐藏。保存后浏览器端数秒内热更新,无需刷新页面。')
|
|
58
|
+
.volatile(),
|
|
59
|
+
expandWorkspaceSessions: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.default(true)
|
|
62
|
+
.description('左侧会话列表默认展开全部会话(DSH 核心每个工作区只显示前 5 条,其余折叠成「展开其余 N 个会话」)。手动点「收起」的分组仍会保持收起。保存后即时生效。')
|
|
63
|
+
.volatile(),
|
|
64
|
+
extraSelectors: z
|
|
65
|
+
.array(z.string())
|
|
66
|
+
.default([])
|
|
67
|
+
.description('额外隐藏的 CSS 选择器。上游若改了按钮属性名,把新选择器填在这里即可兜底,不必改插件代码。'),
|
|
68
|
+
pollIntervalMs: z
|
|
69
|
+
.number()
|
|
70
|
+
.step(1)
|
|
71
|
+
.min(2_000)
|
|
72
|
+
.default(30_000)
|
|
73
|
+
.description('浏览器端兜底轮询间隔(毫秒)。正常情况走 SSE 推送,只有 SSE 不可用时才按这个间隔轮询。'),
|
|
74
|
+
debug: z.boolean().default(false).description('在浏览器控制台输出诊断日志(匹配诊断、SSE 重连等)。'),
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
/** Read a Config field that may be a plain value or a volatile reference. */
|
|
78
|
+
function readValue(value, fallback) {
|
|
79
|
+
if (value === undefined || value === null) return fallback
|
|
80
|
+
if (typeof value.get === 'function') {
|
|
81
|
+
const current = value.get()
|
|
82
|
+
return current === undefined || current === null ? fallback : current
|
|
83
|
+
}
|
|
84
|
+
return value
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Read the flag from a plain boolean or a volatile Config reference. */
|
|
88
|
+
function readFlag(value, fallback) {
|
|
89
|
+
const current = readValue(value, fallback)
|
|
90
|
+
return typeof current === 'boolean' ? current : fallback
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function readSelectors(value) {
|
|
94
|
+
const current = readValue(value, [])
|
|
95
|
+
if (!Array.isArray(current)) return []
|
|
96
|
+
return current.filter((item) => typeof item === 'string' && item.trim() !== '').map((item) => item.trim())
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Absolute path of the diagnostics log written by the Client half. */
|
|
37
100
|
function diagFile() {
|
|
38
101
|
const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
39
102
|
return path.join(home, 'data', 'feature-tweaks-diag.log')
|
|
@@ -50,31 +113,33 @@ async function appendDiag(message) {
|
|
|
50
113
|
}
|
|
51
114
|
}
|
|
52
115
|
|
|
53
|
-
/**
|
|
54
|
-
function sendJson(
|
|
116
|
+
/** Send one JSON payload without leaking connection state. */
|
|
117
|
+
function sendJson(response, status, payload) {
|
|
55
118
|
const body = JSON.stringify(payload)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
119
|
+
response.writeHead(status, {
|
|
120
|
+
'content-type': 'application/json; charset=utf-8',
|
|
121
|
+
'cache-control': 'no-store',
|
|
122
|
+
'content-length': Buffer.byteLength(body),
|
|
123
|
+
})
|
|
124
|
+
response.end(body)
|
|
60
125
|
}
|
|
61
126
|
|
|
62
127
|
/** Read a bounded request body as UTF-8 text. */
|
|
63
|
-
function readBody(
|
|
128
|
+
function readBody(request) {
|
|
64
129
|
return new Promise((resolve, reject) => {
|
|
65
130
|
const chunks = []
|
|
66
131
|
let size = 0
|
|
67
|
-
|
|
132
|
+
request.on('data', (chunk) => {
|
|
68
133
|
size += chunk.length
|
|
69
134
|
if (size > MAX_BODY_BYTES) {
|
|
70
135
|
reject(new Error('request body too large'))
|
|
71
|
-
|
|
136
|
+
request.destroy()
|
|
72
137
|
return
|
|
73
138
|
}
|
|
74
139
|
chunks.push(chunk)
|
|
75
140
|
})
|
|
76
|
-
|
|
77
|
-
|
|
141
|
+
request.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
|
|
142
|
+
request.on('error', reject)
|
|
78
143
|
})
|
|
79
144
|
}
|
|
80
145
|
|
|
@@ -125,21 +190,46 @@ function installQuitInspectionTweak(ctx) {
|
|
|
125
190
|
}
|
|
126
191
|
|
|
127
192
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
193
|
+
* Plugin activation: register the tweak routes (UI config + SSE, reload-safety
|
|
194
|
+
* probe, diagnostics), wire the quit-inspection tweak, and expose the config
|
|
195
|
+
* through the Host Settings layer when available.
|
|
196
|
+
* @param {import('@deepseek-ai/cordis').Context} ctx - plugin context.
|
|
197
|
+
* @param {object} config - validated Config value (fields may be volatile refs).
|
|
131
198
|
*/
|
|
132
|
-
export function apply(ctx) {
|
|
199
|
+
export function apply(ctx, config) {
|
|
200
|
+
const startedAt = Date.now()
|
|
201
|
+
const clients = new Set()
|
|
202
|
+
const source = config === undefined || config === null ? {} : config
|
|
203
|
+
|
|
204
|
+
const snapshot = () => ({
|
|
205
|
+
hideRightSidebarToggle: readFlag(source.hideRightSidebarToggle, true),
|
|
206
|
+
hideSessionLogExportMenu: readFlag(source.hideSessionLogExportMenu, false),
|
|
207
|
+
expandWorkspaceSessions: readFlag(source.expandWorkspaceSessions, true),
|
|
208
|
+
extraSelectors: readSelectors(source.extraSelectors),
|
|
209
|
+
pollIntervalMs: readValue(source.pollIntervalMs, 30_000),
|
|
210
|
+
debug: readFlag(source.debug, false),
|
|
211
|
+
selectors: [DEFAULT_SELECTOR, ...readSelectors(source.extraSelectors)],
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
const broadcast = () => {
|
|
215
|
+
const payload = snapshot()
|
|
216
|
+
for (const response of clients) {
|
|
217
|
+
try {
|
|
218
|
+
response.write(`event: config\ndata: ${JSON.stringify(payload)}\n\n`)
|
|
219
|
+
} catch {
|
|
220
|
+
clients.delete(response)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ── 代码侧功能微调:退出确认 ───────────────────────────────────────────────
|
|
133
226
|
try {
|
|
134
227
|
installQuitInspectionTweak(ctx)
|
|
135
228
|
} catch (error) {
|
|
136
229
|
void appendDiag('quit-inspection-patch-failed: ' + String(error?.message ?? error))
|
|
137
230
|
}
|
|
138
231
|
|
|
139
|
-
//
|
|
140
|
-
// boot manifest captured at startup, so a page reload after a rebuild asks
|
|
141
|
-
// for a stale artifact and fails the boot audit; the reload key asks this
|
|
142
|
-
// list first instead of reloading blindly.
|
|
232
|
+
// ── 代码侧功能微调:刷新前的安全探针需要知道哪些 Client bundle 重建过 ──────
|
|
143
233
|
const rebuiltClientIds = new Set()
|
|
144
234
|
try {
|
|
145
235
|
ctx.inject(['clientModules'], (scope) => {
|
|
@@ -154,51 +244,170 @@ export function apply(ctx) {
|
|
|
154
244
|
void appendDiag('rebuild-listener-failed: ' + String(error?.message ?? error))
|
|
155
245
|
}
|
|
156
246
|
|
|
247
|
+
// ── 界面微调:SSE 心跳与配置广播 ───────────────────────────────────────────
|
|
248
|
+
ctx.effect(() => {
|
|
249
|
+
const heartbeat = setInterval(() => {
|
|
250
|
+
for (const response of clients) {
|
|
251
|
+
try {
|
|
252
|
+
response.write(`event: config\ndata: ${JSON.stringify(snapshot())}\n\n`)
|
|
253
|
+
response.write(': ping\n\n')
|
|
254
|
+
} catch {
|
|
255
|
+
clients.delete(response)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}, HEARTBEAT_MS)
|
|
259
|
+
return () => clearInterval(heartbeat)
|
|
260
|
+
}, 'feature-tweaks: heartbeat')
|
|
261
|
+
|
|
262
|
+
ctx.effect(
|
|
263
|
+
() => ctx.on('settings/document-updated', () => broadcast()) ?? (() => {}),
|
|
264
|
+
'feature-tweaks: broadcast on settings change',
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
ctx.effect(
|
|
268
|
+
() => ctx.on('app-boot/config-reload', () => broadcast()) ?? (() => {}),
|
|
269
|
+
'feature-tweaks: broadcast on config reload',
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
// ── Web 路由(界面配置 + 功能探针 + 诊断)─────────────────────────────────
|
|
157
273
|
try {
|
|
158
274
|
ctx.inject(['webServer'], (scope) => {
|
|
159
|
-
scope.effect(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (graph !== null && Array.isArray(graph.entries)) {
|
|
172
|
-
for (const row of graph.entries) {
|
|
173
|
-
if (row !== null && typeof row === 'object' && typeof row.id === 'string') revs[row.id] = String(row.rev)
|
|
275
|
+
scope.effect(
|
|
276
|
+
() => scope.webServer.register({
|
|
277
|
+
kind: 'prefix',
|
|
278
|
+
path: ROUTE_PREFIX,
|
|
279
|
+
handler: async (request, response) => {
|
|
280
|
+
const pathname = String(request.url ?? '').split('?')[0]
|
|
281
|
+
const route = pathname.slice(ROUTE_PREFIX.length)
|
|
282
|
+
try {
|
|
283
|
+
if (route === '/config') {
|
|
284
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
285
|
+
sendJson(response, 405, { error: 'method not allowed' })
|
|
286
|
+
return
|
|
174
287
|
}
|
|
288
|
+
if (request.method === 'HEAD') {
|
|
289
|
+
response.writeHead(200, { 'content-type': 'application/json; charset=utf-8' })
|
|
290
|
+
response.end()
|
|
291
|
+
return
|
|
292
|
+
}
|
|
293
|
+
sendJson(response, 200, snapshot())
|
|
294
|
+
return
|
|
175
295
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
296
|
+
if (route === '/status') {
|
|
297
|
+
if (request.method !== 'GET') {
|
|
298
|
+
sendJson(response, 405, { error: 'method not allowed' })
|
|
299
|
+
return
|
|
300
|
+
}
|
|
301
|
+
sendJson(response, 200, {
|
|
302
|
+
version: VERSION,
|
|
303
|
+
uptimeMs: Date.now() - startedAt,
|
|
304
|
+
connectedClients: clients.size,
|
|
305
|
+
config: snapshot(),
|
|
306
|
+
})
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
if (route === '/events') {
|
|
310
|
+
if (request.method !== 'GET') {
|
|
311
|
+
sendJson(response, 405, { error: 'method not allowed' })
|
|
312
|
+
return
|
|
313
|
+
}
|
|
314
|
+
response.writeHead(200, {
|
|
315
|
+
'content-type': 'text/event-stream; charset=utf-8',
|
|
316
|
+
'cache-control': 'no-store',
|
|
317
|
+
connection: 'keep-alive',
|
|
318
|
+
'x-accel-buffering': 'no',
|
|
319
|
+
})
|
|
320
|
+
response.write('retry: 3000\n\n')
|
|
321
|
+
response.write(`event: config\ndata: ${JSON.stringify(snapshot())}\n\n`)
|
|
322
|
+
clients.add(response)
|
|
323
|
+
const cleanup = () => clients.delete(response)
|
|
324
|
+
request.on('close', cleanup)
|
|
325
|
+
request.on('aborted', cleanup)
|
|
326
|
+
response.on('close', cleanup)
|
|
327
|
+
response.on('error', cleanup)
|
|
328
|
+
return
|
|
329
|
+
}
|
|
330
|
+
if (route === '/reload-safe') {
|
|
331
|
+
if (request.method !== 'GET') {
|
|
332
|
+
sendJson(response, 405, { ok: false, error: 'method not allowed' })
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
const clientModules = ctx.get('clientModules')
|
|
336
|
+
const graph = clientModules !== undefined && typeof clientModules.graph === 'function'
|
|
337
|
+
? clientModules.graph()
|
|
338
|
+
: null
|
|
339
|
+
const revs = {}
|
|
340
|
+
if (graph !== null && Array.isArray(graph.entries)) {
|
|
341
|
+
for (const row of graph.entries) {
|
|
342
|
+
if (row !== null && typeof row === 'object' && typeof row.id === 'string') revs[row.id] = String(row.rev)
|
|
343
|
+
}
|
|
186
344
|
}
|
|
345
|
+
sendJson(response, 200, { ok: true, revs, changed: [...rebuiltClientIds] })
|
|
346
|
+
return
|
|
347
|
+
}
|
|
348
|
+
if (route === '/diag') {
|
|
349
|
+
if (request.method !== 'POST') {
|
|
350
|
+
sendJson(response, 405, { ok: false, error: 'method not allowed' })
|
|
351
|
+
return
|
|
352
|
+
}
|
|
353
|
+
const body = await readBody(request)
|
|
354
|
+
let message = body.slice(0, 4000)
|
|
355
|
+
try {
|
|
356
|
+
const parsed = JSON.parse(body)
|
|
357
|
+
if (parsed !== null && typeof parsed === 'object' && typeof parsed.message === 'string') {
|
|
358
|
+
message = `${String(parsed.time ?? '')} ${parsed.message}`.trim()
|
|
359
|
+
}
|
|
360
|
+
} catch {
|
|
361
|
+
// A plain text body is still worth recording.
|
|
362
|
+
}
|
|
363
|
+
await appendDiag(message)
|
|
364
|
+
sendJson(response, 200, { ok: true })
|
|
365
|
+
return
|
|
366
|
+
}
|
|
367
|
+
sendJson(response, 404, { ok: false, error: 'unknown tweaks route' })
|
|
368
|
+
} catch (error) {
|
|
369
|
+
try {
|
|
370
|
+
sendJson(response, 500, { ok: false, error: String(error?.message ?? error) })
|
|
187
371
|
} catch {
|
|
188
|
-
//
|
|
372
|
+
// The response may already be committed (SSE); never rethrow from a route.
|
|
189
373
|
}
|
|
190
|
-
await appendDiag(message)
|
|
191
|
-
sendJson(res, 200, { ok: true })
|
|
192
|
-
return
|
|
193
374
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
}), 'feature-tweaks: reload-safe route')
|
|
375
|
+
},
|
|
376
|
+
}),
|
|
377
|
+
'feature-tweaks: routes',
|
|
378
|
+
)
|
|
200
379
|
})
|
|
201
380
|
} catch (error) {
|
|
202
381
|
void appendDiag('route-failed: ' + String(error?.message ?? error))
|
|
203
382
|
}
|
|
383
|
+
|
|
384
|
+
// Close any SSE clients when the plugin unloads.
|
|
385
|
+
ctx.effect(
|
|
386
|
+
() => () => {
|
|
387
|
+
for (const response of clients) {
|
|
388
|
+
try {
|
|
389
|
+
response.end()
|
|
390
|
+
} catch {
|
|
391
|
+
/* already gone */
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
clients.clear()
|
|
395
|
+
},
|
|
396
|
+
'feature-tweaks: close SSE clients',
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
// Make volatile fields editable through the Host Settings layer when available;
|
|
400
|
+
// the routes above still work without it.
|
|
401
|
+
try {
|
|
402
|
+
ctx.inject(['settings'], (settingsCtx) => {
|
|
403
|
+
if (typeof settingsCtx.settings?.configure !== 'function') return
|
|
404
|
+
settingsCtx.effect(() => settingsCtx.settings.configure({ auto: false }, ctx.fiber), 'feature-tweaks: settings')
|
|
405
|
+
})
|
|
406
|
+
} catch (error) {
|
|
407
|
+
try {
|
|
408
|
+
console.warn(`[${LOG_TAG}] settings.configure unavailable: ${error instanceof Error ? error.message : String(error)}`)
|
|
409
|
+
} catch {
|
|
410
|
+
/* logging must never throw */
|
|
411
|
+
}
|
|
412
|
+
}
|
|
204
413
|
}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Feature tweaks",
|
|
4
|
-
"description": "Cross-version fixes for DSH behaviour and
|
|
4
|
+
"description": "Cross-version fixes for DSH behaviour, defaults and UI in one bundle, without touching any core package. Since 0.4.0 it also contains the former UI tweaks (dsh-ui-tweaks 1.2.5): the conversation header's right-sidebar expand button is hidden and the left sidebar's session list is expanded by default, applied live over SSE with selector fallbacks and a self-diagnostic. Behaviour: new root sessions start with Agent Teams enabled; a Reload page shortcut (F5 on desktop, Ctrl+Shift+R on the web); quitting the desktop app no longer asks just because scheduled tasks are armed."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "功能微调",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "DSH 跨版本的功能/默认值与界面微调合集,不改任何核心包。0.4.0 起并入原「界面微调」dsh-ui-tweaks 1.2.5:默认隐藏会话右上角的右侧栏展开按钮、左侧会话列表默认展开全部会话(SSE 热更新、选择器兜底、失效自诊断)。功能侧:新根会话默认开启「智能体团队协作」;「刷新页面」快捷键(桌面端 F5、网页端 Ctrl+Shift+R);桌面端退出不再因定时任务弹确认。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leiyi-works/dsh-feature-tweaks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"title": "功能微调",
|
|
6
|
-
"description": "功能微调:DSH
|
|
6
|
+
"description": "功能微调:DSH 跨版本的功能/默认值与界面微调合集,一个包管两类最小侵入调整,不改任何核心包。0.4.0 起并入原「界面微调」dsh-ui-tweaks 1.2.5——默认隐藏会话右上角的右侧栏展开按钮;左侧会话列表默认展开全部会话(SSE 热更新、选择器兜底、失效自诊断)。功能侧:新根会话默认开启「智能体团队协作」;「刷新页面」快捷键(桌面端 F5、网页端 Ctrl+Shift+R);桌面端退出不再因定时任务弹确认。",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|
|
9
9
|
"./client": "./client.js",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"dsh",
|
|
40
40
|
"dsh-harmonyos",
|
|
41
41
|
"dsh-plugin",
|
|
42
|
-
"tweaks"
|
|
42
|
+
"tweaks",
|
|
43
|
+
"ui"
|
|
43
44
|
]
|
|
44
45
|
}
|