dsh-session-title-stamp 0.6.0 → 0.7.1
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 +43 -5
- package/README.zh.md +35 -4
- package/client.js +369 -0
- package/docs/0.7.0-hover-card-mock.png +0 -0
- package/docs/0.7.0-settings-mock.png +0 -0
- package/lib/index.js +82 -1
- package/market/index.json +5 -5
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -14,14 +14,18 @@ title. Beyond automatic naming:
|
|
|
14
14
|
- **Generate title** — the conversation-header ↻ button, the session row's
|
|
15
15
|
**Generate title** menu item, or `/retitle`.
|
|
16
16
|
- **Copy title** — an extra item in the session `···` menu copies the full title.
|
|
17
|
+
- **Settings page** — preview and change format, emoji, and refresh cadence without editing YAML.
|
|
17
18
|
- **Optional category emoji** — `categoryEmoji: true` renders titles such as
|
|
18
19
|
`1027 | ⚡ 优化 | ...`.
|
|
19
|
-
- **Hover stats** —
|
|
20
|
-
|
|
20
|
+
- **Hover stats** — see duration, estimated CNY cost, and token count at a glance,
|
|
21
|
+
without opening a dashboard.
|
|
21
22
|
- **Category language** — `categoryPreset: zh | en`, or your own `categories`.
|
|
22
23
|
- **Failure-safe** — a failed retitle keeps the current title.
|
|
23
24
|
- **Zero build** — pure Host logic plus a small hand-written browser half.
|
|
24
25
|
|
|
26
|
+
> **The title tells you what the session was about; the hover card tells you what it cost.**
|
|
27
|
+
> Duration, estimated CNY, and tokens are one hover away — no dashboard.
|
|
28
|
+
|
|
25
29
|
Default format:
|
|
26
30
|
|
|
27
31
|
```text
|
|
@@ -63,7 +67,7 @@ and mirrors conventions used by other coding agents.
|
|
|
63
67
|
Add this market index source in **Plugins → Discover → Index sources**:
|
|
64
68
|
|
|
65
69
|
```text
|
|
66
|
-
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.
|
|
70
|
+
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.7.1/market/index.json
|
|
67
71
|
```
|
|
68
72
|
|
|
69
73
|
Then install **Session title stamp** from the list. The plugin installs as a
|
|
@@ -133,10 +137,13 @@ mode using `retitleEvery`.
|
|
|
133
137
|
|
|
134
138
|
### Header button and hover stats
|
|
135
139
|
|
|
136
|
-
0.
|
|
140
|
+
0.7.0 adds a small browser half:
|
|
137
141
|
|
|
138
142
|
- a **refresh icon** in the conversation header; it runs the same `/retitle`
|
|
139
143
|
command as typing it, and is disabled while the session is running.
|
|
144
|
+
|
|
145
|
+

|
|
146
|
+
|
|
140
147
|
- a **hover-card line** under the native relative time, for example
|
|
141
148
|
`Duration 1h 51m · est. ≈¥4.11 · 131.7M tokens`;
|
|
142
149
|
- a **Generate title** item at the top of the session row's `···` menu, plus a
|
|
@@ -149,9 +156,39 @@ never loaded is not resumed just to show the numbers. Native DSH already shows
|
|
|
149
156
|
running / pending / completed-unread status (spinner, warning dot, idle line),
|
|
150
157
|
so this plugin does **not** add a second status-color layer.
|
|
151
158
|
|
|
159
|
+
#### Hover-card field guide
|
|
160
|
+
|
|
161
|
+
| Field | Meaning |
|
|
162
|
+
|---|---|
|
|
163
|
+
| `Duration 1h 51m` | Cumulative model + tool execution time from `sessionStats`; not wall-clock elapsed time |
|
|
164
|
+
| `est. ≈¥4.11` | `tokenUsage` × the current DeepSeek CNY rate table; a rough estimate, not an invoice |
|
|
165
|
+
| `131.7M tokens` | Input, output, cache-read and cache-write tokens combined |
|
|
166
|
+
| `Idle` / scheduled-task line | Native DSH status content; this plugin does not add or replace it |
|
|
167
|
+
|
|
168
|
+
Mixed-model sessions are estimated with the session's last-used model, so the
|
|
169
|
+
cost can differ from the actual bill. The line is intentionally omitted when the
|
|
170
|
+
host has no stats for that session.
|
|
171
|
+
|
|
152
172
|
If the hover line is missing, the browser half could not reach the host stats
|
|
153
173
|
route; the refresh button and automatic titles are unaffected.
|
|
154
174
|
|
|
175
|
+
### Settings page
|
|
176
|
+
|
|
177
|
+

|
|
178
|
+
|
|
179
|
+
0.7.0 adds **Settings → Plugins → Session titles**:
|
|
180
|
+
|
|
181
|
+
- a live preview of the exact title the current template will produce;
|
|
182
|
+
- category language (Chinese/English), optional category emoji, date format,
|
|
183
|
+
and the title template;
|
|
184
|
+
- the auto-refresh switch, minimum interval, message freeze, and opt-in startup
|
|
185
|
+
backfill, with the cost trade-off stated in place;
|
|
186
|
+
- advanced name-length and recent-message controls; timeouts, budgets, and
|
|
187
|
+
model routing stay in the profile configuration.
|
|
188
|
+
|
|
189
|
+
Saving writes the current profile's plugin config, so it applies to the next
|
|
190
|
+
generated title without a restart. Existing titles are never rewritten.
|
|
191
|
+
|
|
155
192
|
### Failures
|
|
156
193
|
|
|
157
194
|
- A failed retitle **keeps the existing title**: the provider throws, which is
|
|
@@ -213,7 +250,8 @@ An unknown placeholder is left verbatim (`{MMDD} {bogus}` keeps `{bogus}`), so a
|
|
|
213
250
|
typo is visible instead of silently disappearing. The template owns the final
|
|
214
251
|
format; `maxTitleBytes` still clips the result.
|
|
215
252
|
|
|
216
|
-
The
|
|
253
|
+
The Settings page covers the common fields; the YAML table below remains the
|
|
254
|
+
automation/advanced source. The default taxonomy is Chinese. `categoryPreset: en` switches it to
|
|
217
255
|
`Analysis / Build / Fix / Optimize / Debug / QA / Release / Docs / Other`; `categories`
|
|
218
256
|
overrides either preset with any labels you want. The prompt lists the configured
|
|
219
257
|
labels and the local fallback maps common keywords onto them.
|
package/README.zh.md
CHANGED
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
- **自动重算**:回答完成后更新,2 分钟冷却,超过 100 条消息后冻结;fork、子代理和手动固定的标题跳过。
|
|
8
8
|
- **生成标题**:会话头 ↻ 按钮、会话行 `···` 菜单「自动生成标题」、或 `/retitle`。
|
|
9
9
|
- **复制标题**:会话行 `···` 菜单多一项复制完整标题。
|
|
10
|
+
- **设置页**:可视化调整格式、emoji 和重算节奏,带实时预览,不用改 YAML。
|
|
10
11
|
- **可选 emoji 分类**:`categoryEmoji: true` 后标题形如 `1027 | ⚡ 优化 | ...`。
|
|
11
|
-
-
|
|
12
|
+
- **悬停统计**:不打开面板,一眼看到耗时、估算 CNY 成本、token 数。
|
|
12
13
|
- **分类语言**:`categoryPreset: zh | en`,也可以用 `categories` 自定义。
|
|
13
14
|
- **失败保护**:重算失败保留当前标题,不被兜底标题覆盖。
|
|
14
15
|
- **零构建**:纯 Host 逻辑 + 小型手写浏览器半边。
|
|
15
16
|
|
|
17
|
+
> **标题告诉你这个会话在做什么,悬停卡片告诉你它花了多少。**
|
|
18
|
+
> 耗时、估算 CNY 成本和 token 数,悬停即见,不需要打开面板。
|
|
19
|
+
|
|
16
20
|
默认格式:
|
|
17
21
|
|
|
18
22
|
```text
|
|
@@ -46,7 +50,7 @@
|
|
|
46
50
|
在 **插件 → 发现(Discover)→ 索引源** 添加:
|
|
47
51
|
|
|
48
52
|
```text
|
|
49
|
-
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.
|
|
53
|
+
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.7.1/market/index.json
|
|
50
54
|
```
|
|
51
55
|
|
|
52
56
|
然后在列表里安装 **Session title stamp / 会话标题印章**。插件以 profile bundle 的形式安装,之后可在插件页启停。
|
|
@@ -96,9 +100,12 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
|
|
|
96
100
|
|
|
97
101
|
### 会话头按钮与悬停统计
|
|
98
102
|
|
|
99
|
-
0.
|
|
103
|
+
0.7.0 增加了一个很小的浏览器半边:
|
|
100
104
|
|
|
101
105
|
- 会话头有一个**刷新图标**,效果等同输入 `/retitle`,会话运行中禁用;
|
|
106
|
+
|
|
107
|
+

|
|
108
|
+
|
|
102
109
|
- 鼠标悬停会话行时,在原生相对时间下面多一行:
|
|
103
110
|
`耗时 1h 51m · 估算 ≈¥4.11 · 131.7M tokens`;
|
|
104
111
|
- 会话行 `···` 菜单最上面多一项「自动生成标题」,下面多一项「复制标题」;
|
|
@@ -106,8 +113,32 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
|
|
|
106
113
|
|
|
107
114
|
数字来自 `sessionStats` / `tokenUsage` 投影,按 DeepSeek 当前 CNY 价格估算,并标注「估算」。只在悬停时向宿主请求,不会为了显示数字去恢复未加载的会话。DSH 原生已经有运行中/待交互/完成未读的状态点与 loader,所以本插件**不再加一层状态颜色**。
|
|
108
115
|
|
|
116
|
+
#### 悬停卡片字段说明
|
|
117
|
+
|
|
118
|
+
| 字段 | 含义 |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `耗时 1h 51m` | 来自 `sessionStats` 的模型 + 工具累计执行时间,不是墙钟耗时 |
|
|
121
|
+
| `估算 ≈¥4.11` | `tokenUsage` × DeepSeek 当前 CNY 价格表,是粗略估算,不是账单 |
|
|
122
|
+
| `131.7M tokens` | 输入、输出、缓存读、缓存写的 token 合计 |
|
|
123
|
+
| `空闲` / 定时任务行 | DSH 原生状态内容,本插件不添加或替换 |
|
|
124
|
+
|
|
125
|
+
混合模型的会话按“最近使用的模型”估算,成本可能和实际账单不同。宿主没有该会话统计时,这一行会刻意不显示。
|
|
126
|
+
|
|
109
127
|
如果悬停行不显示,说明浏览器半边没连上宿主统计路由;刷新按钮和自动标题不受影响。
|
|
110
128
|
|
|
129
|
+
### 设置页
|
|
130
|
+
|
|
131
|
+

|
|
132
|
+
|
|
133
|
+
0.7.0 增加 **设置 → 插件设置 → 会话标题**:
|
|
134
|
+
|
|
135
|
+
- 顶部实时预览当前模板会生成的标题;
|
|
136
|
+
- 分类语言(中文/English)、可选分类 emoji、日期格式、标题模板;
|
|
137
|
+
- 自动重算开关、最小间隔、消息数冻结、启动补刷,并把额外模型成本写在说明里;
|
|
138
|
+
- 高级项只放名称长度和最近消息数;超时、预算、模型路由仍在配置文件里。
|
|
139
|
+
|
|
140
|
+
保存会写入当前 profile 的插件配置,对下一次生成的标题生效,不需要重启;已有标题不会被改写。
|
|
141
|
+
|
|
111
142
|
### 失败时
|
|
112
143
|
|
|
113
144
|
- 已经有标题时,重算失败会**保留旧标题**:provider 抛错,标题服务据此不提交新修订。
|
|
@@ -164,7 +195,7 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
|
|
|
164
195
|
|
|
165
196
|
不认识的占位符会**原样保留**(`{MMDD} {bogus}` 会保留 `{bogus}`),方便一眼看出模板写错,而不是悄悄消失。最终仍受 `maxTitleBytes` 截断。
|
|
166
197
|
|
|
167
|
-
|
|
198
|
+
设置页覆盖常用字段;下面的 YAML 表仍用于自动化和高级配置。默认分类是中文。`categoryPreset: en` 可切到
|
|
168
199
|
`Analysis / Build / Fix / Optimize / Debug / QA / Release / Docs / Other`;`categories`
|
|
169
200
|
可以覆盖任意预设。提示词使用配置的标签,本地兜底也会把常见中英文关键词映射过去。
|
|
170
201
|
|
package/client.js
CHANGED
|
@@ -18,6 +18,7 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
const h = React.createElement
|
|
19
19
|
|
|
20
20
|
const NS = 'dsh-session-title-stamp'
|
|
21
|
+
const SETTINGS_NAMESPACE = 'session-title-stamp'
|
|
21
22
|
const STATS_PATH = '/api/session-title-stamp/stats'
|
|
22
23
|
const inject = ['slots', 'remote', 'remote.commands', 'locale']
|
|
23
24
|
const DICT = {
|
|
@@ -29,6 +30,48 @@ window.__ModuleLoader__.load({
|
|
|
29
30
|
estimate: '估算',
|
|
30
31
|
copyTitle: '复制标题',
|
|
31
32
|
copyHint: '复制完整会话标题',
|
|
33
|
+
'settings.nav': '会话标题',
|
|
34
|
+
'settings.title': '会话标题',
|
|
35
|
+
'settings.intro': '让侧栏里的每个会话都有一个稳定、可扫读的名字。修改后立即对新生成的标题生效。',
|
|
36
|
+
'settings.preview': '实时预览',
|
|
37
|
+
'settings.previewHint': '开启 emoji 后',
|
|
38
|
+
'settings.format': '标题格式',
|
|
39
|
+
'settings.categoryLanguage': '分类语言',
|
|
40
|
+
'settings.categoryLanguageHint': '中文使用「分析 / 实现 / 修复 / 优化…」,英文使用 Analysis / Build / Fix / Optimize…',
|
|
41
|
+
'settings.categoryEmoji': '分类 emoji 前缀',
|
|
42
|
+
'settings.categoryEmojiHint': '为分类增加视觉标记;默认关闭,开启后会占用少量标题字节。',
|
|
43
|
+
'settings.dateFormat': '日期格式',
|
|
44
|
+
'settings.dateFormatHint': '日期由本地时间计算,不交给模型。',
|
|
45
|
+
'settings.template': '标题模板',
|
|
46
|
+
'settings.templateHint': '支持 {date}、{type}、{topic},也可用 {YYYYMMDD}、{HHmm} 等。',
|
|
47
|
+
'settings.auto': '自动重算',
|
|
48
|
+
'settings.autoBadge': '默认开启',
|
|
49
|
+
'settings.autoRefresh': '回答完成后自动重算',
|
|
50
|
+
'settings.autoRefreshHint': '每个完成的 turn 结束后更新标题;fork、子代理和手动固定的标题会跳过。',
|
|
51
|
+
'settings.minInterval': '最小刷新间隔',
|
|
52
|
+
'settings.minIntervalHint': '避免首轮刚生成又再次调用模型。',
|
|
53
|
+
'settings.minutes': '分钟',
|
|
54
|
+
'settings.freeze': '消息数冻结',
|
|
55
|
+
'settings.freezeHint': '超过该用户消息数后停止自动重算,0 表示不冻结。',
|
|
56
|
+
'settings.messages': '条',
|
|
57
|
+
'settings.backfill': '启动时补刷旧标题',
|
|
58
|
+
'settings.backfillHint': '启动后修复仍是兜底标题的 live 会话;会额外调用模型,默认关闭。',
|
|
59
|
+
'settings.advanced': '高级',
|
|
60
|
+
'settings.advancedHint': '名称长度、最近消息数;其它参数请用设置右上角的「打开配置文件」。',
|
|
61
|
+
'settings.nameLimit': '名称最大字符数',
|
|
62
|
+
'settings.nameLimitHint': '标题名称部分的上限,最终还受标题字节上限约束。',
|
|
63
|
+
'settings.recentMessages': '最近消息数',
|
|
64
|
+
'settings.recentMessagesHint': '生成标题时包含最近多少条消息。',
|
|
65
|
+
'settings.chars': '字符',
|
|
66
|
+
'settings.restore': '恢复默认',
|
|
67
|
+
'settings.dirty': '有未保存的修改',
|
|
68
|
+
'settings.save': '保存',
|
|
69
|
+
'settings.saving': '保存中…',
|
|
70
|
+
'settings.saved': '已保存',
|
|
71
|
+
'settings.failed': '保存失败',
|
|
72
|
+
'settings.readOnly': '当前 profile 不接受配置写入。',
|
|
73
|
+
'settings.loading': '正在读取配置…',
|
|
74
|
+
'settings.unavailable': '当前 profile 里没有这个插件的配置项,这里没有可编辑的内容。请在插件页启用后重开。',
|
|
32
75
|
},
|
|
33
76
|
en: {
|
|
34
77
|
menu: 'Generate title',
|
|
@@ -38,6 +81,48 @@ window.__ModuleLoader__.load({
|
|
|
38
81
|
estimate: 'est.',
|
|
39
82
|
copyTitle: 'Copy title',
|
|
40
83
|
copyHint: 'Copy the full session title',
|
|
84
|
+
'settings.nav': 'Session titles',
|
|
85
|
+
'settings.title': 'Session titles',
|
|
86
|
+
'settings.intro': 'Give every row a stable, scannable name. Changes apply to titles generated after saving.',
|
|
87
|
+
'settings.preview': 'Live preview',
|
|
88
|
+
'settings.previewHint': 'With emoji',
|
|
89
|
+
'settings.format': 'Title format',
|
|
90
|
+
'settings.categoryLanguage': 'Category language',
|
|
91
|
+
'settings.categoryLanguageHint': 'Chinese uses 分析 / 实现 / 修复 / 优化…; English uses Analysis / Build / Fix / Optimize…',
|
|
92
|
+
'settings.categoryEmoji': 'Category emoji prefix',
|
|
93
|
+
'settings.categoryEmojiHint': 'Adds a visual marker and a few title bytes. Off by default.',
|
|
94
|
+
'settings.dateFormat': 'Date format',
|
|
95
|
+
'settings.dateFormatHint': 'The date is computed locally, never by the model.',
|
|
96
|
+
'settings.template': 'Title template',
|
|
97
|
+
'settings.templateHint': 'Supports {date}, {type}, {topic}, plus {YYYYMMDD}, {HHmm}, and more.',
|
|
98
|
+
'settings.auto': 'Auto refresh',
|
|
99
|
+
'settings.autoBadge': 'on by default',
|
|
100
|
+
'settings.autoRefresh': 'Refresh after a completed turn',
|
|
101
|
+
'settings.autoRefreshHint': 'Updates the title after each completed turn; forks, subagents, and manually pinned titles are skipped.',
|
|
102
|
+
'settings.minInterval': 'Minimum interval',
|
|
103
|
+
'settings.minIntervalHint': 'Avoids a second request right after the first title.',
|
|
104
|
+
'settings.minutes': 'minutes',
|
|
105
|
+
'settings.freeze': 'Freeze after',
|
|
106
|
+
'settings.freezeHint': 'Stop automatic refreshes after this many user messages; 0 disables the freeze.',
|
|
107
|
+
'settings.messages': 'messages',
|
|
108
|
+
'settings.backfill': 'Backfill old titles on startup',
|
|
109
|
+
'settings.backfillHint': 'Repairs live sessions still using a fallback title; calls the model extra. Off by default.',
|
|
110
|
+
'settings.advanced': 'Advanced',
|
|
111
|
+
'settings.advancedHint': 'Name length and recent messages; use “Open config file” in the top-right for everything else.',
|
|
112
|
+
'settings.nameLimit': 'Maximum name characters',
|
|
113
|
+
'settings.nameLimitHint': 'Caps the name before the title byte budget applies.',
|
|
114
|
+
'settings.recentMessages': 'Recent messages',
|
|
115
|
+
'settings.recentMessagesHint': 'How many recent messages are sent with the title request.',
|
|
116
|
+
'settings.chars': 'chars',
|
|
117
|
+
'settings.restore': 'Restore defaults',
|
|
118
|
+
'settings.dirty': 'Unsaved changes',
|
|
119
|
+
'settings.save': 'Save',
|
|
120
|
+
'settings.saving': 'Saving…',
|
|
121
|
+
'settings.saved': 'Saved',
|
|
122
|
+
'settings.failed': 'Not saved',
|
|
123
|
+
'settings.readOnly': 'This profile does not accept configuration writes.',
|
|
124
|
+
'settings.loading': 'Reading configuration…',
|
|
125
|
+
'settings.unavailable': 'This profile has no configuration entry for the plugin. Enable it and reopen this page.',
|
|
41
126
|
},
|
|
42
127
|
}
|
|
43
128
|
|
|
@@ -257,6 +342,289 @@ window.__ModuleLoader__.load({
|
|
|
257
342
|
)
|
|
258
343
|
}
|
|
259
344
|
|
|
345
|
+
function useLocaleRevision(ctx) {
|
|
346
|
+
const [, force] = React.useState(0)
|
|
347
|
+
React.useEffect(() => {
|
|
348
|
+
if (typeof ctx?.locale?.subscribe !== 'function') return undefined
|
|
349
|
+
return ctx.locale.subscribe(() => force((value) => value + 1))
|
|
350
|
+
}, [ctx])
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const SETTINGS_STYLE = {
|
|
354
|
+
page: { display: 'flex', flexDirection: 'column', maxWidth: '720px', color: 'var(--dsw-alias-label-primary, #e8e8ea)' },
|
|
355
|
+
h2: { margin: '0 0 6px', fontSize: '18px', lineHeight: '26px', fontWeight: 600 },
|
|
356
|
+
intro: { margin: '0 0 20px', fontSize: '13px', lineHeight: '20px', color: 'var(--dsw-alias-label-tertiary, #8b8d94)' },
|
|
357
|
+
preview: { border: '1px solid var(--dsw-alias-border-l2, #33363d)', background: 'var(--dsw-alias-bg-layer-2, #15171b)', borderRadius: '12px', padding: '14px 16px', marginBottom: '20px' },
|
|
358
|
+
previewLabel: { fontSize: '11px', color: 'var(--dsw-alias-label-caption, #737985)', letterSpacing: '.06em', marginBottom: '6px' },
|
|
359
|
+
previewTitle: { fontSize: '15px', lineHeight: '23px', color: 'var(--dsw-alias-label-primary, #fff)', fontWeight: 500, wordBreak: 'break-word' },
|
|
360
|
+
section: { marginTop: '18px' },
|
|
361
|
+
sectionTitle: { display: 'flex', alignItems: 'center', gap: '8px', fontSize: '12px', color: 'var(--dsw-alias-label-caption, #737985)', letterSpacing: '.06em', textTransform: 'uppercase', margin: '0 0 2px' },
|
|
362
|
+
badge: { fontSize: '10px', lineHeight: '16px', fontWeight: 400, color: 'var(--dsw-alias-state-success-primary, #65d39a)', border: '.5px solid var(--dsw-alias-state-success-primary, #65d39a)', borderRadius: '99px', padding: '1px 7px', letterSpacing: 0, textTransform: 'none' },
|
|
363
|
+
previewRow: { display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', gap: '16px' },
|
|
364
|
+
previewGhost: { fontSize: '12px', lineHeight: '18px', color: 'var(--dsw-alias-label-caption, #737985)', whiteSpace: 'nowrap' },
|
|
365
|
+
row: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '24px', padding: '15px 0', borderBottom: '.5px solid var(--dsw-alias-border-l2, #2b2e35)' },
|
|
366
|
+
rowColumn: { display: 'flex', flexDirection: 'column', alignItems: 'stretch', gap: '10px', padding: '15px 0', borderBottom: '.5px solid var(--dsw-alias-border-l2, #2b2e35)' },
|
|
367
|
+
text: { minWidth: 0 },
|
|
368
|
+
label: { fontSize: '13px', fontWeight: 500, lineHeight: '20px' },
|
|
369
|
+
desc: { marginTop: '4px', fontSize: '12px', lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary, #8b8d94)' },
|
|
370
|
+
seg: { display: 'inline-flex', padding: '2px', border: '1px solid var(--dsw-alias-border-l2, #343842)', borderRadius: '9px', background: 'var(--dsw-alias-bg-layer-1, #191b20)', flex: 'none' },
|
|
371
|
+
segButton: { border: 0, background: 'transparent', color: 'var(--dsw-alias-label-secondary, #9a9da6)', font: 'inherit', fontSize: '12px', padding: '5px 11px', borderRadius: '7px', cursor: 'pointer' },
|
|
372
|
+
segButtonOn: { background: 'var(--dsw-alias-interactive-bg-hover, #2d3340)', color: 'var(--dsw-alias-label-primary, #fff)' },
|
|
373
|
+
switch: (on) => ({ width: '40px', height: '23px', borderRadius: '999px', background: on ? 'var(--dsw-alias-brand-primary, #6f96ff)' : 'var(--dsw-alias-border-l2, #3a3f49)', position: 'relative', flex: 'none', border: 0, cursor: 'pointer', padding: 0 }),
|
|
374
|
+
thumb: (on) => ({ position: 'absolute', top: '2px', left: on ? '19px' : '2px', width: '19px', height: '19px', borderRadius: '50%', background: '#fff', transition: 'left 120ms ease' }),
|
|
375
|
+
input: { background: 'var(--dsw-alias-bg-layer-1, #17191e)', border: '1px solid var(--dsw-alias-border-l2, #383c46)', borderRadius: '7px', color: 'var(--dsw-alias-label-primary, #eceef2)', font: 'inherit', fontSize: '12px', padding: '6px 9px' },
|
|
376
|
+
number: { width: '64px', textAlign: 'right' },
|
|
377
|
+
fullInput: { width: '100%', boxSizing: 'border-box', fontFamily: '"SF Mono", ui-monospace, monospace' },
|
|
378
|
+
unit: { fontSize: '12px', color: 'var(--dsw-alias-label-caption, #737985)' },
|
|
379
|
+
num: { display: 'flex', alignItems: 'center', gap: '7px', flex: 'none' },
|
|
380
|
+
advanced: { display: 'flex', alignItems: 'center', gap: '7px', border: 0, background: 'transparent', color: 'var(--dsw-alias-label-caption, #737985)', font: 'inherit', fontSize: '12px', padding: '14px 0 0', cursor: 'pointer', textAlign: 'left' },
|
|
381
|
+
footer: { display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: '12px', paddingTop: '20px' },
|
|
382
|
+
restore: { border: 0, background: 'transparent', color: 'var(--dsw-alias-label-secondary, #9a9da6)', font: 'inherit', fontSize: '12px', marginRight: 'auto', padding: 0, cursor: 'pointer' },
|
|
383
|
+
save: { border: '1px solid transparent', background: 'var(--dsw-alias-label-primary, #e8e8ea)', color: 'var(--dsw-alias-bg-layer-3, #15171b)', borderRadius: '8px', font: 'inherit', fontSize: '13px', fontWeight: 600, padding: '7px 18px', cursor: 'pointer' },
|
|
384
|
+
status: { fontSize: '12px', lineHeight: '18px' },
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function buildSettingsSection(React, configForms, t, ctx) {
|
|
388
|
+
const h = React.createElement
|
|
389
|
+
const DEFAULT_TEMPLATE = '{date} | {type} | {topic}'
|
|
390
|
+
const readText = (key) => t(`settings.${key}`)
|
|
391
|
+
const sample = (preset, emoji, dateFormat, template) => {
|
|
392
|
+
const base = preset === 'en' ? 'Optimize' : '优化'
|
|
393
|
+
const type = emoji ? `⚡ ${base}` : base
|
|
394
|
+
const topic = preset === 'en' ? 'Reduce renderer memory usage' : '降低渲染器内存占用'
|
|
395
|
+
const date = dateFormat === 'YYMM' ? '2610' : dateFormat === 'YYYYMMDD' ? '20261027' : '1027'
|
|
396
|
+
const values = { date, type, topic, MMDD: '1027', YYMM: '2610', YYYYMMDD: '20261027', HHmm: '1230', YYYY: '2026', YY: '26', MM: '10', DD: '27', HH: '12', mm: '30', ss: '00' }
|
|
397
|
+
return (template || DEFAULT_TEMPLATE).replace(/\{([A-Za-z]+)\}/g, (match, key) => values[key] ?? match)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return function SessionTitleSettings() {
|
|
401
|
+
const form = React.useMemo(() => configForms.get(SETTINGS_NAMESPACE), [])
|
|
402
|
+
const [snapshot, setSnapshot] = React.useState(() => form.getSnapshot())
|
|
403
|
+
React.useEffect(() => form.subscribe(() => setSnapshot(form.getSnapshot())), [form])
|
|
404
|
+
useLocaleRevision(ctx)
|
|
405
|
+
|
|
406
|
+
const stored = snapshot.value ?? {}
|
|
407
|
+
const storedPreset = stored.categoryPreset === 'en' ? 'en' : 'zh'
|
|
408
|
+
const storedEmoji = stored.categoryEmoji === true
|
|
409
|
+
const storedDateFormat = ['MMDD', 'YYMM', 'YYYYMMDD'].includes(stored.dateFormat) ? stored.dateFormat : 'MMDD'
|
|
410
|
+
const storedTemplate = typeof stored.template === 'string' && stored.template.trim() !== '' ? stored.template.trim() : DEFAULT_TEMPLATE
|
|
411
|
+
const storedAuto = stored.refreshOnTurnEnd !== false
|
|
412
|
+
const storedMinutes = String(Math.max(0, Math.round((Number(stored.refreshMinIntervalMs) || 120000) / 60000)))
|
|
413
|
+
const storedFreeze = String(Number.isFinite(stored.refreshMaxTurns) ? stored.refreshMaxTurns : 100)
|
|
414
|
+
const storedBackfill = stored.backfillOnStart === true
|
|
415
|
+
const storedNameChars = String(Number.isFinite(stored.maxNameChars) ? stored.maxNameChars : 20)
|
|
416
|
+
const storedRecent = String(Number.isFinite(stored.recentMessages) ? stored.recentMessages : 8)
|
|
417
|
+
|
|
418
|
+
const [categoryPreset, setCategoryPreset] = React.useState(storedPreset)
|
|
419
|
+
const [categoryEmoji, setCategoryEmoji] = React.useState(storedEmoji)
|
|
420
|
+
const [dateFormat, setDateFormat] = React.useState(storedDateFormat)
|
|
421
|
+
const [template, setTemplate] = React.useState(storedTemplate)
|
|
422
|
+
const [autoRefresh, setAutoRefresh] = React.useState(storedAuto)
|
|
423
|
+
const [minutes, setMinutes] = React.useState(storedMinutes)
|
|
424
|
+
const [freeze, setFreeze] = React.useState(storedFreeze)
|
|
425
|
+
const [backfill, setBackfill] = React.useState(storedBackfill)
|
|
426
|
+
const [nameChars, setNameChars] = React.useState(storedNameChars)
|
|
427
|
+
const [recentMessages, setRecentMessages] = React.useState(storedRecent)
|
|
428
|
+
const [advancedOpen, setAdvancedOpen] = React.useState(false)
|
|
429
|
+
const [saveState, setSaveState] = React.useState('idle')
|
|
430
|
+
|
|
431
|
+
React.useEffect(() => {
|
|
432
|
+
setCategoryPreset(storedPreset)
|
|
433
|
+
setCategoryEmoji(storedEmoji)
|
|
434
|
+
setDateFormat(storedDateFormat)
|
|
435
|
+
setTemplate(storedTemplate)
|
|
436
|
+
setAutoRefresh(storedAuto)
|
|
437
|
+
setMinutes(storedMinutes)
|
|
438
|
+
setFreeze(storedFreeze)
|
|
439
|
+
setBackfill(storedBackfill)
|
|
440
|
+
setNameChars(storedNameChars)
|
|
441
|
+
setRecentMessages(storedRecent)
|
|
442
|
+
}, [snapshot.revision])
|
|
443
|
+
|
|
444
|
+
const busy = saveState === 'saving'
|
|
445
|
+
const writable = snapshot.writable !== false
|
|
446
|
+
const dirty =
|
|
447
|
+
categoryPreset !== storedPreset ||
|
|
448
|
+
categoryEmoji !== storedEmoji ||
|
|
449
|
+
dateFormat !== storedDateFormat ||
|
|
450
|
+
template !== storedTemplate ||
|
|
451
|
+
autoRefresh !== storedAuto ||
|
|
452
|
+
minutes !== storedMinutes ||
|
|
453
|
+
freeze !== storedFreeze ||
|
|
454
|
+
backfill !== storedBackfill ||
|
|
455
|
+
nameChars !== storedNameChars ||
|
|
456
|
+
recentMessages !== storedRecent
|
|
457
|
+
|
|
458
|
+
const row = (key, title, desc, control, column = false) =>
|
|
459
|
+
h(
|
|
460
|
+
'div',
|
|
461
|
+
{ key, style: column ? SETTINGS_STYLE.rowColumn : SETTINGS_STYLE.row },
|
|
462
|
+
h('div', { style: SETTINGS_STYLE.text }, h('div', { style: SETTINGS_STYLE.label }, title), desc ? h('div', { style: SETTINGS_STYLE.desc }, desc) : null),
|
|
463
|
+
control,
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
const segment = (options, value, onChange) =>
|
|
467
|
+
h(
|
|
468
|
+
'div',
|
|
469
|
+
{ style: SETTINGS_STYLE.seg, role: 'radiogroup' },
|
|
470
|
+
options.map((option) =>
|
|
471
|
+
h(
|
|
472
|
+
'button',
|
|
473
|
+
{
|
|
474
|
+
key: option.value,
|
|
475
|
+
type: 'button',
|
|
476
|
+
role: 'radio',
|
|
477
|
+
'aria-checked': value === option.value,
|
|
478
|
+
disabled: !writable || busy,
|
|
479
|
+
onClick: () => onChange(option.value),
|
|
480
|
+
style: { ...SETTINGS_STYLE.segButton, ...(value === option.value ? SETTINGS_STYLE.segButtonOn : {}) },
|
|
481
|
+
},
|
|
482
|
+
option.label,
|
|
483
|
+
),
|
|
484
|
+
),
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
const toggle = (checked, onChange, label) =>
|
|
488
|
+
h(
|
|
489
|
+
'button',
|
|
490
|
+
{ type: 'button', role: 'switch', 'aria-checked': checked, 'aria-label': label, disabled: !writable || busy, onClick: () => onChange(!checked), style: SETTINGS_STYLE.switch(checked) },
|
|
491
|
+
h('span', { style: SETTINGS_STYLE.thumb(checked) }),
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
const number = (value, onChange, min, max, unit) =>
|
|
495
|
+
h(
|
|
496
|
+
'div',
|
|
497
|
+
{ style: SETTINGS_STYLE.num },
|
|
498
|
+
h('input', { type: 'number', min, max, value, disabled: !writable || busy, onChange: (event) => onChange(event.target.value), style: { ...SETTINGS_STYLE.input, ...SETTINGS_STYLE.number } }),
|
|
499
|
+
unit === undefined ? null : h('span', { style: SETTINGS_STYLE.unit }, unit),
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
const save = async () => {
|
|
503
|
+
if (busy) return
|
|
504
|
+
setSaveState('saving')
|
|
505
|
+
const parsedMinutes = Math.max(0, Math.min(3600000, Math.round(Number.parseInt(minutes, 10) || 0) * 60000))
|
|
506
|
+
const parsedFreeze = Math.max(0, Math.min(100000, Number.parseInt(freeze, 10) || 0))
|
|
507
|
+
const parsedName = Math.max(4, Math.min(40, Number.parseInt(nameChars, 10) || 20))
|
|
508
|
+
const parsedRecent = Math.max(2, Math.min(20, Number.parseInt(recentMessages, 10) || 8))
|
|
509
|
+
const nextTemplate = template.trim() === '' ? DEFAULT_TEMPLATE : template.trim()
|
|
510
|
+
try {
|
|
511
|
+
const ok = await form.mutate(
|
|
512
|
+
[
|
|
513
|
+
{ op: 'set', path: ['categoryPreset'], value: categoryPreset },
|
|
514
|
+
{ op: 'set', path: ['categoryEmoji'], value: categoryEmoji },
|
|
515
|
+
{ op: 'set', path: ['dateFormat'], value: dateFormat },
|
|
516
|
+
{ op: 'set', path: ['template'], value: nextTemplate },
|
|
517
|
+
{ op: 'set', path: ['refreshOnTurnEnd'], value: autoRefresh },
|
|
518
|
+
{ op: 'set', path: ['refreshMinIntervalMs'], value: parsedMinutes },
|
|
519
|
+
{ op: 'set', path: ['refreshMaxTurns'], value: parsedFreeze },
|
|
520
|
+
{ op: 'set', path: ['backfillOnStart'], value: backfill },
|
|
521
|
+
{ op: 'set', path: ['maxNameChars'], value: parsedName },
|
|
522
|
+
{ op: 'set', path: ['recentMessages'], value: parsedRecent },
|
|
523
|
+
],
|
|
524
|
+
snapshot.revision,
|
|
525
|
+
)
|
|
526
|
+
setSaveState(ok === false ? 'failed' : 'saved')
|
|
527
|
+
} catch {
|
|
528
|
+
setSaveState('failed')
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const restore = () => {
|
|
533
|
+
setCategoryPreset('zh')
|
|
534
|
+
setCategoryEmoji(false)
|
|
535
|
+
setDateFormat('MMDD')
|
|
536
|
+
setTemplate(DEFAULT_TEMPLATE)
|
|
537
|
+
setAutoRefresh(true)
|
|
538
|
+
setMinutes('2')
|
|
539
|
+
setFreeze('100')
|
|
540
|
+
setBackfill(false)
|
|
541
|
+
setNameChars('20')
|
|
542
|
+
setRecentMessages('8')
|
|
543
|
+
setSaveState('idle')
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (snapshot.status === 'loading') return h('div', { style: SETTINGS_STYLE.desc }, readText('loading'))
|
|
547
|
+
if (snapshot.status === 'unavailable') return h('div', { style: SETTINGS_STYLE.desc }, readText('unavailable'))
|
|
548
|
+
|
|
549
|
+
const preview = sample(categoryPreset, categoryEmoji, dateFormat, template)
|
|
550
|
+
return h(
|
|
551
|
+
'div',
|
|
552
|
+
{ style: SETTINGS_STYLE.page },
|
|
553
|
+
h('h2', { style: SETTINGS_STYLE.h2 }, readText('title')),
|
|
554
|
+
h('p', { style: SETTINGS_STYLE.intro }, readText('intro')),
|
|
555
|
+
h(
|
|
556
|
+
'div',
|
|
557
|
+
{ style: SETTINGS_STYLE.preview },
|
|
558
|
+
h('div', { style: SETTINGS_STYLE.previewLabel }, readText('preview')),
|
|
559
|
+
h(
|
|
560
|
+
'div',
|
|
561
|
+
{ style: SETTINGS_STYLE.previewRow },
|
|
562
|
+
h('div', { style: SETTINGS_STYLE.previewTitle }, preview),
|
|
563
|
+
categoryEmoji
|
|
564
|
+
? null
|
|
565
|
+
: h('span', { style: SETTINGS_STYLE.previewGhost }, `${readText('previewHint')}:⚡ ${categoryPreset === 'en' ? 'Optimize' : '优化'}`),
|
|
566
|
+
),
|
|
567
|
+
),
|
|
568
|
+
h('div', { style: SETTINGS_STYLE.sectionTitle }, readText('format')),
|
|
569
|
+
row('preset', readText('categoryLanguage'), readText('categoryLanguageHint'),
|
|
570
|
+
segment([{ value: 'zh', label: '中文' }, { value: 'en', label: 'English' }], categoryPreset, setCategoryPreset)),
|
|
571
|
+
row('emoji', readText('categoryEmoji'), readText('categoryEmojiHint'), toggle(categoryEmoji, setCategoryEmoji, readText('categoryEmoji'))),
|
|
572
|
+
row('date', readText('dateFormat'), readText('dateFormatHint'),
|
|
573
|
+
segment([{ value: 'MMDD', label: 'MMDD' }, { value: 'YYMM', label: 'YYMM' }, { value: 'YYYYMMDD', label: 'YYYYMMDD' }], dateFormat, setDateFormat)),
|
|
574
|
+
row('template', readText('template'), readText('templateHint'),
|
|
575
|
+
h('input', { value: template, disabled: !writable || busy, onChange: (event) => setTemplate(event.target.value), spellCheck: false, style: { ...SETTINGS_STYLE.input, ...SETTINGS_STYLE.fullInput } }), true),
|
|
576
|
+
h('div', { style: SETTINGS_STYLE.sectionTitle }, readText('auto'), h('span', { style: SETTINGS_STYLE.badge }, readText('autoBadge'))),
|
|
577
|
+
row('auto', readText('autoRefresh'), readText('autoRefreshHint'), toggle(autoRefresh, setAutoRefresh, readText('autoRefresh'))),
|
|
578
|
+
row('minutes', readText('minInterval'), readText('minIntervalHint'), number(minutes, setMinutes, 0, 60, readText('minutes'))),
|
|
579
|
+
row('freeze', readText('freeze'), readText('freezeHint'), number(freeze, setFreeze, 0, 100000, readText('messages'))),
|
|
580
|
+
row('backfill', readText('backfill'), readText('backfillHint'), toggle(backfill, setBackfill, readText('backfill'))),
|
|
581
|
+
h(
|
|
582
|
+
'button',
|
|
583
|
+
{ type: 'button', style: SETTINGS_STYLE.advanced, onClick: () => setAdvancedOpen((value) => !value) },
|
|
584
|
+
h('span', { style: { fontSize: 10, transform: advancedOpen ? 'rotate(90deg)' : 'rotate(-90deg)', display: 'inline-block' } }, '▼'),
|
|
585
|
+
readText('advanced'),
|
|
586
|
+
),
|
|
587
|
+
advancedOpen
|
|
588
|
+
? h('div', null,
|
|
589
|
+
row('nameChars', readText('nameLimit'), readText('nameLimitHint'), number(nameChars, setNameChars, 4, 40, readText('chars'))),
|
|
590
|
+
row('recent', readText('recentMessages'), readText('recentMessagesHint'), number(recentMessages, setRecentMessages, 2, 20, readText('messages'))),
|
|
591
|
+
h('div', { style: { ...SETTINGS_STYLE.desc, marginTop: '8px' } }, readText('advancedHint')),
|
|
592
|
+
)
|
|
593
|
+
: null,
|
|
594
|
+
h(
|
|
595
|
+
'div',
|
|
596
|
+
{ style: SETTINGS_STYLE.footer },
|
|
597
|
+
h('button', { type: 'button', style: SETTINGS_STYLE.restore, disabled: !writable || busy, onClick: restore }, readText('restore')),
|
|
598
|
+
h('span', { style: { ...SETTINGS_STYLE.status, color: saveState === 'failed' ? 'var(--dsw-alias-state-error-primary, #f87171)' : 'var(--dsw-alias-state-success-primary, #65d39a)' } }, saveState === 'saved' ? readText('saved') : saveState === 'failed' ? readText('failed') : ''),
|
|
599
|
+
dirty && saveState !== 'saved' ? h('span', { style: { ...SETTINGS_STYLE.desc, marginTop: 0 } }, readText('dirty')) : null,
|
|
600
|
+
writable ? null : h('span', { style: { ...SETTINGS_STYLE.desc, marginTop: 0 } }, readText('readOnly')),
|
|
601
|
+
h('button', { type: 'button', style: { ...SETTINGS_STYLE.save, opacity: writable && !busy ? 1 : 0.4, cursor: writable && !busy ? 'pointer' : 'default' }, disabled: !writable || busy, onClick: () => void save() }, busy ? readText('saving') : readText('save')),
|
|
602
|
+
),
|
|
603
|
+
)
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function registerSettingsPage(ctx, t) {
|
|
608
|
+
try {
|
|
609
|
+
if (typeof ctx.inject !== 'function') return
|
|
610
|
+
ctx.inject(['configForms', 'slots'], (scope) => {
|
|
611
|
+
try {
|
|
612
|
+
const Section = buildSettingsSection(React, scope.configForms, t, ctx)
|
|
613
|
+
scope.slots.inject('settings.section', () => scope.slots.register({
|
|
614
|
+
name: 'settings.section',
|
|
615
|
+
id: NS,
|
|
616
|
+
order: 60,
|
|
617
|
+
label: () => t('settings.nav'),
|
|
618
|
+
}, Section))
|
|
619
|
+
} catch (error) {
|
|
620
|
+
console.warn('session-title-stamp: settings page unavailable', error)
|
|
621
|
+
}
|
|
622
|
+
})
|
|
623
|
+
} catch (error) {
|
|
624
|
+
console.warn('session-title-stamp: settings page unavailable', error)
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
260
628
|
const STYLE_ID = 'dsh-session-title-stamp-style'
|
|
261
629
|
|
|
262
630
|
|
|
@@ -278,6 +646,7 @@ window.__ModuleLoader__.load({
|
|
|
278
646
|
installStyle(ctx)
|
|
279
647
|
ctx.effect?.(() => ctx.locale.register(NS, DICT))
|
|
280
648
|
const t = ctx.locale.bind(NS)
|
|
649
|
+
registerSettingsPage(ctx, t)
|
|
281
650
|
const run = async (sessionId) => {
|
|
282
651
|
const response = await ctx.remote.commands.execute(sessionId, '/retitle', [])
|
|
283
652
|
if (!response?.ok) {
|
|
Binary file
|
|
Binary file
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* without one cannot leave this entry pending and hold up startup.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import Schema from '@deepseek-ai/schemastery'
|
|
15
16
|
import { readFile } from 'node:fs/promises'
|
|
16
17
|
import { homedir } from 'node:os'
|
|
17
18
|
import { join } from 'node:path'
|
|
@@ -30,6 +31,83 @@ import {
|
|
|
30
31
|
textFromResponse,
|
|
31
32
|
} from './format.js'
|
|
32
33
|
|
|
34
|
+
const PrefsSchema = Schema.object({
|
|
35
|
+
categoryPreset: Schema.union([Schema.const('zh'), Schema.const('en')])
|
|
36
|
+
.default('zh')
|
|
37
|
+
.description('分类词表语言:zh 中文 / en English'),
|
|
38
|
+
categoryEmoji: Schema.boolean()
|
|
39
|
+
.default(false)
|
|
40
|
+
.description('给分类加 emoji 前缀,例如 ⚡ 优化'),
|
|
41
|
+
dateFormat: Schema.union([Schema.const('MMDD'), Schema.const('YYMM'), Schema.const('YYYYMMDD')])
|
|
42
|
+
.default('MMDD')
|
|
43
|
+
.description('{date} 使用日期格式'),
|
|
44
|
+
template: Schema.string()
|
|
45
|
+
.default('{date} | {type} | {topic}')
|
|
46
|
+
.description('标题模板'),
|
|
47
|
+
refreshOnTurnEnd: Schema.boolean()
|
|
48
|
+
.default(true)
|
|
49
|
+
.description('回答完成后自动重算标题'),
|
|
50
|
+
refreshMinIntervalMs: Schema.natural()
|
|
51
|
+
.default(120000)
|
|
52
|
+
.description('自动重算最小间隔(毫秒)'),
|
|
53
|
+
refreshMaxTurns: Schema.natural()
|
|
54
|
+
.default(100)
|
|
55
|
+
.description('超过多少条用户消息后停止自动重算,0 表示不冻结'),
|
|
56
|
+
backfillOnStart: Schema.boolean()
|
|
57
|
+
.default(false)
|
|
58
|
+
.description('启动时补刷仍为兜底标题的 live 会话'),
|
|
59
|
+
maxNameChars: Schema.natural()
|
|
60
|
+
.default(20)
|
|
61
|
+
.description('名称最大字符数'),
|
|
62
|
+
recentMessages: Schema.natural()
|
|
63
|
+
.default(8)
|
|
64
|
+
.description('标题请求包含的最近消息数'),
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const LimitsSchema = Schema.object({
|
|
68
|
+
categories: Schema.array(Schema.string())
|
|
69
|
+
.default([])
|
|
70
|
+
.hidden(true)
|
|
71
|
+
.description('自定义分类词表,覆盖 categoryPreset'),
|
|
72
|
+
maxTitleBytes: Schema.natural().default(80).hidden(true),
|
|
73
|
+
maxInputBytes: Schema.natural().default(4096).hidden(true),
|
|
74
|
+
maxOutputTokens: Schema.natural().default(4096).hidden(true),
|
|
75
|
+
timeoutMs: Schema.natural().default(90000).hidden(true),
|
|
76
|
+
provider: Schema.string().default('').hidden(true),
|
|
77
|
+
model: Schema.string().default('').hidden(true),
|
|
78
|
+
timeZone: Schema.string().default('').hidden(true),
|
|
79
|
+
backfillMaxSessions: Schema.natural().default(30).hidden(true),
|
|
80
|
+
backfillIntervalMs: Schema.natural().default(2000).hidden(true),
|
|
81
|
+
retitleEvery: Schema.natural().default(10).hidden(true),
|
|
82
|
+
cadence: Schema.union([Schema.const('first-prompt'), Schema.const('all-prompts')]).hidden(true),
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
/** Every preference is live-editable from the settings page. */
|
|
86
|
+
const volatilePrefs = Object.fromEntries(
|
|
87
|
+
Object.entries(PrefsSchema.dict ?? {}).map(([key, field]) => [key, field.volatile()]),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
/** Config schema: live preferences plus the deployment limits the form hides. */
|
|
91
|
+
export const Config = Schema.object({
|
|
92
|
+
...volatilePrefs,
|
|
93
|
+
...LimitsSchema.dict,
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
/** The protocol symbol a parsed volatile field carries. */
|
|
97
|
+
const VOLATILE_WRITE = Symbol.for('cosmokit.volatile.write')
|
|
98
|
+
|
|
99
|
+
function readField(value) {
|
|
100
|
+
if (value !== null && typeof value === 'object' && VOLATILE_WRITE in value && typeof value.get === 'function') {
|
|
101
|
+
return value.get()
|
|
102
|
+
}
|
|
103
|
+
return value
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function readConfig(config) {
|
|
107
|
+
const source = config !== null && typeof config === 'object' ? config : {}
|
|
108
|
+
return Object.fromEntries(Object.entries(source).map(([key, value]) => [key, readField(value)]))
|
|
109
|
+
}
|
|
110
|
+
|
|
33
111
|
const PROVIDER_ID = 'title-stamp'
|
|
34
112
|
const EXECUTOR_SPECIFIER = '@deepseek-ai/dsh-session-title-llm'
|
|
35
113
|
const MAX_TRACKED_SESSIONS = 64
|
|
@@ -357,7 +435,8 @@ function scheduleBackfill(ctx, settings, logger, shouldStop) {
|
|
|
357
435
|
*/
|
|
358
436
|
export function apply(ctx, config) {
|
|
359
437
|
const serviceMaxBytes = Number(ctx.sessionTitle?.config?.maxTitleBytes)
|
|
360
|
-
const
|
|
438
|
+
const settingsNow = () => resolveSettings(readConfig(config), serviceMaxBytes)
|
|
439
|
+
const settings = settingsNow()
|
|
361
440
|
const logger = ctx.logger
|
|
362
441
|
let stopped = false
|
|
363
442
|
|
|
@@ -384,6 +463,7 @@ export function apply(ctx, config) {
|
|
|
384
463
|
// duplicate title event on every single user message.
|
|
385
464
|
automatic: 'first-prompt',
|
|
386
465
|
async generate(request) {
|
|
466
|
+
const settings = settingsNow()
|
|
387
467
|
const startedAt = Date.now()
|
|
388
468
|
const used = selectMessages(request?.messages, settings)
|
|
389
469
|
if (used.length === 0) {
|
|
@@ -520,6 +600,7 @@ export function apply(ctx, config) {
|
|
|
520
600
|
if (reasonKind(event.data?.reason) !== 'completed') return
|
|
521
601
|
if (isExcluded(session)) return
|
|
522
602
|
|
|
603
|
+
const settings = settingsNow()
|
|
523
604
|
const count = counts.get(session.id) ?? countUserMessages(session)
|
|
524
605
|
if (count <= 0) return
|
|
525
606
|
if (settings.refreshMaxTurns > 0 && count > settings.refreshMaxTurns) return
|
package/market/index.json
CHANGED
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"zh": "会话标题印章"
|
|
35
35
|
},
|
|
36
36
|
"description": {
|
|
37
|
-
"en": "Keeps DSH session titles in DATE | CATEGORY | NAME with turn-aware auto-retitle, a
|
|
38
|
-
"zh": "把 DSH 会话标题固定为「日期 | 分类 |
|
|
37
|
+
"en": "Keeps DSH session titles in DATE | CATEGORY | NAME with turn-aware auto-retitle, a settings page, and hover duration/cost/token stats.",
|
|
38
|
+
"zh": "把 DSH 会话标题固定为「日期 | 分类 | 名称」,支持自动重算、设置页,以及悬停查看耗时/估算成本/token。"
|
|
39
39
|
},
|
|
40
40
|
"author": "xuedipiaofei",
|
|
41
41
|
"icon": "../icon.svg",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
},
|
|
58
58
|
"versions": [
|
|
59
59
|
{
|
|
60
|
-
"version": "0.
|
|
61
|
-
"publishTimestamp":
|
|
60
|
+
"version": "0.7.1",
|
|
61
|
+
"publishTimestamp": 1793723566,
|
|
62
62
|
"source": {
|
|
63
63
|
"type": "git",
|
|
64
64
|
"url": "https://github.com/xuedipiaofei/dsh-session-title-stamp",
|
|
65
|
-
"commit": "
|
|
65
|
+
"commit": "a8b0c59662e0fe464f5bc5bf11ca2155a7fbe0e1"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"dsh": ">=0.2.1-rc.3 <0.3.0"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-title-stamp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DSH session titles in a DATE | CATEGORY | NAME template, with turn-aware auto-generation, a
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "DSH session titles in a DATE | CATEGORY | NAME template, with turn-aware auto-generation, a settings page, and hover duration/cost/token stats.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
7
7
|
"dsh-plugin",
|
|
@@ -34,13 +34,16 @@
|
|
|
34
34
|
"market/index.json",
|
|
35
35
|
"icon.svg",
|
|
36
36
|
"README.md",
|
|
37
|
-
"README.zh.md"
|
|
37
|
+
"README.zh.md",
|
|
38
|
+
"docs/0.7.0-settings-mock.png",
|
|
39
|
+
"docs/0.7.0-hover-card-mock.png"
|
|
38
40
|
],
|
|
39
41
|
"engines": {
|
|
40
42
|
"dsh": ">=0.2.1-rc.3 <0.3.0"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
|
-
"@deepseek-ai/dsh-session-title-llm": "^0.2.1-rc.3"
|
|
45
|
+
"@deepseek-ai/dsh-session-title-llm": "^0.2.1-rc.3",
|
|
46
|
+
"@deepseek-ai/schemastery": "^3.18.5"
|
|
44
47
|
},
|
|
45
48
|
"dsh": {
|
|
46
49
|
"bundle": {
|
|
@@ -62,9 +65,12 @@
|
|
|
62
65
|
"access": "public"
|
|
63
66
|
},
|
|
64
67
|
"scripts": {
|
|
65
|
-
"test": "node --check client.js && node test/format.test.mjs && node test/provider.test.mjs && node test/client.test.mjs && node scripts/check.mjs",
|
|
68
|
+
"test": "node --check client.js && node test/format.test.mjs && node test/provider.test.mjs && node test/client.test.mjs && node test/config.test.mjs && node scripts/check.mjs",
|
|
66
69
|
"check": "node scripts/check.mjs",
|
|
67
70
|
"validate:index": "node scripts/validate-index.mjs",
|
|
68
71
|
"pack:check": "npm pack --dry-run"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@deepseek-ai/schemastery": "^3.18.5"
|
|
69
75
|
}
|
|
70
76
|
}
|