dsh-session-title-stamp 0.7.0 → 0.8.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 CHANGED
@@ -14,15 +14,19 @@ 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
+ - **Settings page** — preview and change format, emoji, title language, and refresh cadence without editing YAML.
18
18
  - **Optional category emoji** — `categoryEmoji: true` renders titles such as
19
19
  `1027 | ⚡ 优化 | ...`.
20
- - **Hover stats** — elapsed time, estimated CNY cost, and token count on the
21
- session hover card.
20
+ - **Hover stats** — see duration, estimated CNY cost, and token count at a glance,
21
+ without opening a dashboard.
22
22
  - **Category language** — `categoryPreset: zh | en`, or your own `categories`.
23
+ - **Title language** — names can follow the conversation, or be forced to Chinese/English.
23
24
  - **Failure-safe** — a failed retitle keeps the current title.
24
25
  - **Zero build** — pure Host logic plus a small hand-written browser half.
25
26
 
27
+ > **The title tells you what the session was about; the hover card tells you what it cost.**
28
+ > Duration, estimated CNY, and tokens are one hover away — no dashboard.
29
+
26
30
  Default format:
27
31
 
28
32
  ```text
@@ -64,7 +68,7 @@ and mirrors conventions used by other coding agents.
64
68
  Add this market index source in **Plugins → Discover → Index sources**:
65
69
 
66
70
  ```text
67
- https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.7.0/market/index.json
71
+ https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.8.0/market/index.json
68
72
  ```
69
73
 
70
74
  Then install **Session title stamp** from the list. The plugin installs as a
@@ -138,6 +142,9 @@ mode using `retitleEvery`.
138
142
 
139
143
  - a **refresh icon** in the conversation header; it runs the same `/retitle`
140
144
  command as typing it, and is disabled while the session is running.
145
+
146
+ ![Session hover card](docs/0.7.0-hover-card-mock.png)
147
+
141
148
  - a **hover-card line** under the native relative time, for example
142
149
  `Duration 1h 51m · est. ≈¥4.11 · 131.7M tokens`;
143
150
  - a **Generate title** item at the top of the session row's `···` menu, plus a
@@ -150,6 +157,19 @@ never loaded is not resumed just to show the numbers. Native DSH already shows
150
157
  running / pending / completed-unread status (spinner, warning dot, idle line),
151
158
  so this plugin does **not** add a second status-color layer.
152
159
 
160
+ #### Hover-card field guide
161
+
162
+ | Field | Meaning |
163
+ |---|---|
164
+ | `Duration 1h 51m` | Cumulative model + tool execution time from `sessionStats`; not wall-clock elapsed time |
165
+ | `est. ≈¥4.11` | `tokenUsage` × the current DeepSeek CNY rate table; a rough estimate, not an invoice |
166
+ | `131.7M tokens` | Input, output, cache-read and cache-write tokens combined |
167
+ | `Idle` / scheduled-task line | Native DSH status content; this plugin does not add or replace it |
168
+
169
+ Mixed-model sessions are estimated with the session's last-used model, so the
170
+ cost can differ from the actual bill. The line is intentionally omitted when the
171
+ host has no stats for that session.
172
+
153
173
  If the hover line is missing, the browser half could not reach the host stats
154
174
  route; the refresh button and automatic titles are unaffected.
155
175
 
@@ -160,12 +180,14 @@ route; the refresh button and automatic titles are unaffected.
160
180
  0.7.0 adds **Settings → Plugins → Session titles**:
161
181
 
162
182
  - a live preview of the exact title the current template will produce;
163
- - category language (Chinese/English), optional category emoji, date format,
164
- and the title template;
183
+ - category language (Chinese/English), title language, optional category emoji,
184
+ date format, and the title template;
165
185
  - the auto-refresh switch, minimum interval, message freeze, and opt-in startup
166
186
  backfill, with the cost trade-off stated in place;
167
- - advanced name-length and recent-message controls; timeouts, budgets, and
168
- model routing stay in the profile configuration.
187
+ - advanced name-length, recent-message, and title-byte controls; timeouts,
188
+ budgets, and model routing stay in the profile configuration.
189
+
190
+ 0.8.0 adds the title-language choice and the advanced byte limit.
169
191
 
170
192
  Saving writes the current profile's plugin config, so it applies to the next
171
193
  generated title without a restart. Existing titles are never rewritten.
@@ -208,6 +230,7 @@ Override the row in the profile's `cordis.patch.yml`:
208
230
  | `dateFormat` | `MMDD` | Used by `{date}`: `MMDD` (`1028`), `YYMM` (`2610`), or `YYYYMMDD` |
209
231
  | `timeZone` | host local | IANA zone used for date/time placeholders |
210
232
  | `categoryPreset` | `zh` | Built-in category language: `zh` or `en` |
233
+ | `titleLanguage` | `auto` | Name language: `auto`, `zh`, or `en` |
211
234
  | `categories` | preset | Explicit category list; overrides `categoryPreset` |
212
235
  | `categoryEmoji` | `false` | Prefix the category with its emoji (⚡ 优化, 🐛 修复, ...) |
213
236
  | `maxNameChars` | `20` | Character cap before the byte cap applies |
package/README.zh.md CHANGED
@@ -7,13 +7,17 @@
7
7
  - **自动重算**:回答完成后更新,2 分钟冷却,超过 100 条消息后冻结;fork、子代理和手动固定的标题跳过。
8
8
  - **生成标题**:会话头 ↻ 按钮、会话行 `···` 菜单「自动生成标题」、或 `/retitle`。
9
9
  - **复制标题**:会话行 `···` 菜单多一项复制完整标题。
10
- - **设置页**:可视化调整格式、emoji 和重算节奏,带实时预览,不用改 YAML。
10
+ - **设置页**:可视化调整格式、emoji、标题语言和重算节奏,带实时预览,不用改 YAML。
11
11
  - **可选 emoji 分类**:`categoryEmoji: true` 后标题形如 `1027 | ⚡ 优化 | ...`。
12
- - **悬停统计**:会话行悬停显示耗时、估算 CNY 成本、token 数。
12
+ - **悬停统计**:不打开面板,一眼看到耗时、估算 CNY 成本、token 数。
13
13
  - **分类语言**:`categoryPreset: zh | en`,也可以用 `categories` 自定义。
14
+ - **标题语言**:名称可跟随对话,也可强制中文/English。
14
15
  - **失败保护**:重算失败保留当前标题,不被兜底标题覆盖。
15
16
  - **零构建**:纯 Host 逻辑 + 小型手写浏览器半边。
16
17
 
18
+ > **标题告诉你这个会话在做什么,悬停卡片告诉你它花了多少。**
19
+ > 耗时、估算 CNY 成本和 token 数,悬停即见,不需要打开面板。
20
+
17
21
  默认格式:
18
22
 
19
23
  ```text
@@ -47,7 +51,7 @@
47
51
  在 **插件 → 发现(Discover)→ 索引源** 添加:
48
52
 
49
53
  ```text
50
- https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.7.0/market/index.json
54
+ https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.8.0/market/index.json
51
55
  ```
52
56
 
53
57
  然后在列表里安装 **Session title stamp / 会话标题印章**。插件以 profile bundle 的形式安装,之后可在插件页启停。
@@ -100,6 +104,9 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
100
104
  0.7.0 增加了一个很小的浏览器半边:
101
105
 
102
106
  - 会话头有一个**刷新图标**,效果等同输入 `/retitle`,会话运行中禁用;
107
+
108
+ ![悬停卡片统计](docs/0.7.0-hover-card-mock.png)
109
+
103
110
  - 鼠标悬停会话行时,在原生相对时间下面多一行:
104
111
  `耗时 1h 51m · 估算 ≈¥4.11 · 131.7M tokens`;
105
112
  - 会话行 `···` 菜单最上面多一项「自动生成标题」,下面多一项「复制标题」;
@@ -107,6 +114,17 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
107
114
 
108
115
  数字来自 `sessionStats` / `tokenUsage` 投影,按 DeepSeek 当前 CNY 价格估算,并标注「估算」。只在悬停时向宿主请求,不会为了显示数字去恢复未加载的会话。DSH 原生已经有运行中/待交互/完成未读的状态点与 loader,所以本插件**不再加一层状态颜色**。
109
116
 
117
+ #### 悬停卡片字段说明
118
+
119
+ | 字段 | 含义 |
120
+ |---|---|
121
+ | `耗时 1h 51m` | 来自 `sessionStats` 的模型 + 工具累计执行时间,不是墙钟耗时 |
122
+ | `估算 ≈¥4.11` | `tokenUsage` × DeepSeek 当前 CNY 价格表,是粗略估算,不是账单 |
123
+ | `131.7M tokens` | 输入、输出、缓存读、缓存写的 token 合计 |
124
+ | `空闲` / 定时任务行 | DSH 原生状态内容,本插件不添加或替换 |
125
+
126
+ 混合模型的会话按“最近使用的模型”估算,成本可能和实际账单不同。宿主没有该会话统计时,这一行会刻意不显示。
127
+
110
128
  如果悬停行不显示,说明浏览器半边没连上宿主统计路由;刷新按钮和自动标题不受影响。
111
129
 
112
130
  ### 设置页
@@ -116,9 +134,11 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
116
134
  0.7.0 增加 **设置 → 插件设置 → 会话标题**:
117
135
 
118
136
  - 顶部实时预览当前模板会生成的标题;
119
- - 分类语言(中文/English)、可选分类 emoji、日期格式、标题模板;
137
+ - 分类语言(中文/English)、标题语言、可选分类 emoji、日期格式、标题模板;
120
138
  - 自动重算开关、最小间隔、消息数冻结、启动补刷,并把额外模型成本写在说明里;
121
- - 高级项只放名称长度和最近消息数;超时、预算、模型路由仍在配置文件里。
139
+ - 高级项放名称长度、最近消息数和标题字节上限;超时、预算、模型路由仍在配置文件里。
140
+
141
+ 0.8.0 增加标题语言选择与高级字节上限。
122
142
 
123
143
  保存会写入当前 profile 的插件配置,对下一次生成的标题生效,不需要重启;已有标题不会被改写。
124
144
 
@@ -157,6 +177,7 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
157
177
  | `dateFormat` | `MMDD` | `{date}` 使用:`MMDD`(`1028`)/ `YYMM`(`2610`)/ `YYYYMMDD` |
158
178
  | `timeZone` | 本机时区 | 日期/时间占位符使用的 IANA 时区 |
159
179
  | `categoryPreset` | `zh` | 内置分类语言:`zh` 或 `en` |
180
+ | `titleLanguage` | `auto` | 名称语言:`auto`、`zh` 或 `en` |
160
181
  | `categories` | 预设 | 显式分类词表,优先级高于 `categoryPreset` |
161
182
  | `categoryEmoji` | `false` | 给分类加 emoji 前缀(⚡ 优化、🐛 修复……) |
162
183
  | `maxNameChars` | `20` | 名称字符上限(最终还受字节上限约束) |
package/client.js CHANGED
@@ -38,6 +38,14 @@ window.__ModuleLoader__.load({
38
38
  'settings.format': '标题格式',
39
39
  'settings.categoryLanguage': '分类语言',
40
40
  'settings.categoryLanguageHint': '中文使用「分析 / 实现 / 修复 / 优化…」,英文使用 Analysis / Build / Fix / Optimize…',
41
+ 'settings.titleLanguage': '标题语言',
42
+ 'settings.titleLanguageHint': '名称使用哪种语言;分类标签仍由上面的分类语言决定。',
43
+ 'settings.langAuto': '跟随对话',
44
+ 'settings.langZh': '中文',
45
+ 'settings.langEn': 'English',
46
+ 'settings.maxBytes': '标题最大字节数',
47
+ 'settings.maxBytesHint': '1–80,最终还受标题服务上限约束。',
48
+ 'settings.bytes': '字节',
41
49
  'settings.categoryEmoji': '分类 emoji 前缀',
42
50
  'settings.categoryEmojiHint': '为分类增加视觉标记;默认关闭,开启后会占用少量标题字节。',
43
51
  'settings.dateFormat': '日期格式',
@@ -89,6 +97,14 @@ window.__ModuleLoader__.load({
89
97
  'settings.format': 'Title format',
90
98
  'settings.categoryLanguage': 'Category language',
91
99
  'settings.categoryLanguageHint': 'Chinese uses 分析 / 实现 / 修复 / 优化…; English uses Analysis / Build / Fix / Optimize…',
100
+ 'settings.titleLanguage': 'Title language',
101
+ 'settings.titleLanguageHint': 'Language for the name; category labels still follow the category language above.',
102
+ 'settings.langAuto': 'Follow chat',
103
+ 'settings.langZh': 'Chinese',
104
+ 'settings.langEn': 'English',
105
+ 'settings.maxBytes': 'Maximum title bytes',
106
+ 'settings.maxBytesHint': '1–80, still capped by the title service limit.',
107
+ 'settings.bytes': 'bytes',
92
108
  'settings.categoryEmoji': 'Category emoji prefix',
93
109
  'settings.categoryEmojiHint': 'Adds a visual marker and a few title bytes. Off by default.',
94
110
  'settings.dateFormat': 'Date format',
@@ -359,6 +375,9 @@ window.__ModuleLoader__.load({
359
375
  previewTitle: { fontSize: '15px', lineHeight: '23px', color: 'var(--dsw-alias-label-primary, #fff)', fontWeight: 500, wordBreak: 'break-word' },
360
376
  section: { marginTop: '18px' },
361
377
  sectionTitle: { display: 'flex', alignItems: 'center', gap: '8px', fontSize: '12px', color: 'var(--dsw-alias-label-caption, #737985)', letterSpacing: '.06em', textTransform: 'uppercase', margin: '0 0 2px' },
378
+ 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' },
379
+ previewRow: { display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', gap: '16px' },
380
+ previewGhost: { fontSize: '12px', lineHeight: '18px', color: 'var(--dsw-alias-label-caption, #737985)', whiteSpace: 'nowrap' },
362
381
  row: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '24px', padding: '15px 0', borderBottom: '.5px solid var(--dsw-alias-border-l2, #2b2e35)' },
363
382
  rowColumn: { display: 'flex', flexDirection: 'column', alignItems: 'stretch', gap: '10px', padding: '15px 0', borderBottom: '.5px solid var(--dsw-alias-border-l2, #2b2e35)' },
364
383
  text: { minWidth: 0 },
@@ -385,12 +404,13 @@ window.__ModuleLoader__.load({
385
404
  const h = React.createElement
386
405
  const DEFAULT_TEMPLATE = '{date} | {type} | {topic}'
387
406
  const readText = (key) => t(`settings.${key}`)
388
- const sample = (preset, emoji, dateFormat, template) => {
407
+ const sample = (preset, emoji, dateFormat, template, titleLanguage) => {
389
408
  const base = preset === 'en' ? 'Optimize' : '优化'
390
409
  const type = emoji ? `⚡ ${base}` : base
391
- const topic = preset === 'en' ? 'Reduce renderer memory usage' : '降低渲染器内存占用'
410
+ const topicLanguage = titleLanguage === 'auto' ? (preset === 'en' ? 'en' : 'zh') : titleLanguage
411
+ const topic = topicLanguage === 'en' ? 'Reduce renderer memory usage' : '降低渲染器内存占用'
392
412
  const date = dateFormat === 'YYMM' ? '2610' : dateFormat === 'YYYYMMDD' ? '20261027' : '1027'
393
- const values = { date, type, topic, YYYY: '2026', YY: '26', MM: '10', DD: '27', HH: '12', mm: '30', ss: '00' }
413
+ 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' }
394
414
  return (template || DEFAULT_TEMPLATE).replace(/\{([A-Za-z]+)\}/g, (match, key) => values[key] ?? match)
395
415
  }
396
416
 
@@ -403,6 +423,7 @@ window.__ModuleLoader__.load({
403
423
  const stored = snapshot.value ?? {}
404
424
  const storedPreset = stored.categoryPreset === 'en' ? 'en' : 'zh'
405
425
  const storedEmoji = stored.categoryEmoji === true
426
+ const storedTitleLanguage = ['zh', 'en'].includes(stored.titleLanguage) ? stored.titleLanguage : 'auto'
406
427
  const storedDateFormat = ['MMDD', 'YYMM', 'YYYYMMDD'].includes(stored.dateFormat) ? stored.dateFormat : 'MMDD'
407
428
  const storedTemplate = typeof stored.template === 'string' && stored.template.trim() !== '' ? stored.template.trim() : DEFAULT_TEMPLATE
408
429
  const storedAuto = stored.refreshOnTurnEnd !== false
@@ -411,9 +432,11 @@ window.__ModuleLoader__.load({
411
432
  const storedBackfill = stored.backfillOnStart === true
412
433
  const storedNameChars = String(Number.isFinite(stored.maxNameChars) ? stored.maxNameChars : 20)
413
434
  const storedRecent = String(Number.isFinite(stored.recentMessages) ? stored.recentMessages : 8)
435
+ const storedMaxTitleBytes = String(Number.isFinite(stored.maxTitleBytes) ? stored.maxTitleBytes : 80)
414
436
 
415
437
  const [categoryPreset, setCategoryPreset] = React.useState(storedPreset)
416
438
  const [categoryEmoji, setCategoryEmoji] = React.useState(storedEmoji)
439
+ const [titleLanguage, setTitleLanguage] = React.useState(storedTitleLanguage)
417
440
  const [dateFormat, setDateFormat] = React.useState(storedDateFormat)
418
441
  const [template, setTemplate] = React.useState(storedTemplate)
419
442
  const [autoRefresh, setAutoRefresh] = React.useState(storedAuto)
@@ -422,12 +445,14 @@ window.__ModuleLoader__.load({
422
445
  const [backfill, setBackfill] = React.useState(storedBackfill)
423
446
  const [nameChars, setNameChars] = React.useState(storedNameChars)
424
447
  const [recentMessages, setRecentMessages] = React.useState(storedRecent)
448
+ const [maxTitleBytes, setMaxTitleBytes] = React.useState(storedMaxTitleBytes)
425
449
  const [advancedOpen, setAdvancedOpen] = React.useState(false)
426
450
  const [saveState, setSaveState] = React.useState('idle')
427
451
 
428
452
  React.useEffect(() => {
429
453
  setCategoryPreset(storedPreset)
430
454
  setCategoryEmoji(storedEmoji)
455
+ setTitleLanguage(storedTitleLanguage)
431
456
  setDateFormat(storedDateFormat)
432
457
  setTemplate(storedTemplate)
433
458
  setAutoRefresh(storedAuto)
@@ -436,6 +461,7 @@ window.__ModuleLoader__.load({
436
461
  setBackfill(storedBackfill)
437
462
  setNameChars(storedNameChars)
438
463
  setRecentMessages(storedRecent)
464
+ setMaxTitleBytes(storedMaxTitleBytes)
439
465
  }, [snapshot.revision])
440
466
 
441
467
  const busy = saveState === 'saving'
@@ -443,6 +469,7 @@ window.__ModuleLoader__.load({
443
469
  const dirty =
444
470
  categoryPreset !== storedPreset ||
445
471
  categoryEmoji !== storedEmoji ||
472
+ titleLanguage !== storedTitleLanguage ||
446
473
  dateFormat !== storedDateFormat ||
447
474
  template !== storedTemplate ||
448
475
  autoRefresh !== storedAuto ||
@@ -450,7 +477,8 @@ window.__ModuleLoader__.load({
450
477
  freeze !== storedFreeze ||
451
478
  backfill !== storedBackfill ||
452
479
  nameChars !== storedNameChars ||
453
- recentMessages !== storedRecent
480
+ recentMessages !== storedRecent ||
481
+ maxTitleBytes !== storedMaxTitleBytes
454
482
 
455
483
  const row = (key, title, desc, control, column = false) =>
456
484
  h(
@@ -488,11 +516,12 @@ window.__ModuleLoader__.load({
488
516
  h('span', { style: SETTINGS_STYLE.thumb(checked) }),
489
517
  )
490
518
 
491
- const number = (value, onChange, min, max) =>
519
+ const number = (value, onChange, min, max, unit) =>
492
520
  h(
493
521
  'div',
494
522
  { style: SETTINGS_STYLE.num },
495
523
  h('input', { type: 'number', min, max, value, disabled: !writable || busy, onChange: (event) => onChange(event.target.value), style: { ...SETTINGS_STYLE.input, ...SETTINGS_STYLE.number } }),
524
+ unit === undefined ? null : h('span', { style: SETTINGS_STYLE.unit }, unit),
496
525
  )
497
526
 
498
527
  const save = async () => {
@@ -502,12 +531,14 @@ window.__ModuleLoader__.load({
502
531
  const parsedFreeze = Math.max(0, Math.min(100000, Number.parseInt(freeze, 10) || 0))
503
532
  const parsedName = Math.max(4, Math.min(40, Number.parseInt(nameChars, 10) || 20))
504
533
  const parsedRecent = Math.max(2, Math.min(20, Number.parseInt(recentMessages, 10) || 8))
534
+ const parsedMaxTitleBytes = Math.max(1, Math.min(80, Number.parseInt(maxTitleBytes, 10) || 80))
505
535
  const nextTemplate = template.trim() === '' ? DEFAULT_TEMPLATE : template.trim()
506
536
  try {
507
537
  const ok = await form.mutate(
508
538
  [
509
539
  { op: 'set', path: ['categoryPreset'], value: categoryPreset },
510
540
  { op: 'set', path: ['categoryEmoji'], value: categoryEmoji },
541
+ { op: 'set', path: ['titleLanguage'], value: titleLanguage },
511
542
  { op: 'set', path: ['dateFormat'], value: dateFormat },
512
543
  { op: 'set', path: ['template'], value: nextTemplate },
513
544
  { op: 'set', path: ['refreshOnTurnEnd'], value: autoRefresh },
@@ -516,6 +547,7 @@ window.__ModuleLoader__.load({
516
547
  { op: 'set', path: ['backfillOnStart'], value: backfill },
517
548
  { op: 'set', path: ['maxNameChars'], value: parsedName },
518
549
  { op: 'set', path: ['recentMessages'], value: parsedRecent },
550
+ { op: 'set', path: ['maxTitleBytes'], value: parsedMaxTitleBytes },
519
551
  ],
520
552
  snapshot.revision,
521
553
  )
@@ -528,6 +560,7 @@ window.__ModuleLoader__.load({
528
560
  const restore = () => {
529
561
  setCategoryPreset('zh')
530
562
  setCategoryEmoji(false)
563
+ setTitleLanguage('auto')
531
564
  setDateFormat('MMDD')
532
565
  setTemplate(DEFAULT_TEMPLATE)
533
566
  setAutoRefresh(true)
@@ -536,13 +569,14 @@ window.__ModuleLoader__.load({
536
569
  setBackfill(false)
537
570
  setNameChars('20')
538
571
  setRecentMessages('8')
572
+ setMaxTitleBytes('80')
539
573
  setSaveState('idle')
540
574
  }
541
575
 
542
576
  if (snapshot.status === 'loading') return h('div', { style: SETTINGS_STYLE.desc }, readText('loading'))
543
577
  if (snapshot.status === 'unavailable') return h('div', { style: SETTINGS_STYLE.desc }, readText('unavailable'))
544
578
 
545
- const preview = sample(categoryPreset, categoryEmoji, dateFormat, template)
579
+ const preview = sample(categoryPreset, categoryEmoji, dateFormat, template, titleLanguage)
546
580
  return h(
547
581
  'div',
548
582
  { style: SETTINGS_STYLE.page },
@@ -552,20 +586,29 @@ window.__ModuleLoader__.load({
552
586
  'div',
553
587
  { style: SETTINGS_STYLE.preview },
554
588
  h('div', { style: SETTINGS_STYLE.previewLabel }, readText('preview')),
555
- h('div', { style: SETTINGS_STYLE.previewTitle }, preview),
589
+ h(
590
+ 'div',
591
+ { style: SETTINGS_STYLE.previewRow },
592
+ h('div', { style: SETTINGS_STYLE.previewTitle }, preview),
593
+ categoryEmoji
594
+ ? null
595
+ : h('span', { style: SETTINGS_STYLE.previewGhost }, `${readText('previewHint')}:⚡ ${categoryPreset === 'en' ? 'Optimize' : '优化'}`),
596
+ ),
556
597
  ),
557
598
  h('div', { style: SETTINGS_STYLE.sectionTitle }, readText('format')),
558
599
  row('preset', readText('categoryLanguage'), readText('categoryLanguageHint'),
559
600
  segment([{ value: 'zh', label: '中文' }, { value: 'en', label: 'English' }], categoryPreset, setCategoryPreset)),
601
+ row('language', readText('titleLanguage'), readText('titleLanguageHint'),
602
+ segment([{ value: 'auto', label: readText('langAuto') }, { value: 'zh', label: readText('langZh') }, { value: 'en', label: readText('langEn') }], titleLanguage, setTitleLanguage)),
560
603
  row('emoji', readText('categoryEmoji'), readText('categoryEmojiHint'), toggle(categoryEmoji, setCategoryEmoji, readText('categoryEmoji'))),
561
604
  row('date', readText('dateFormat'), readText('dateFormatHint'),
562
605
  segment([{ value: 'MMDD', label: 'MMDD' }, { value: 'YYMM', label: 'YYMM' }, { value: 'YYYYMMDD', label: 'YYYYMMDD' }], dateFormat, setDateFormat)),
563
606
  row('template', readText('template'), readText('templateHint'),
564
607
  h('input', { value: template, disabled: !writable || busy, onChange: (event) => setTemplate(event.target.value), spellCheck: false, style: { ...SETTINGS_STYLE.input, ...SETTINGS_STYLE.fullInput } }), true),
565
- h('div', { style: SETTINGS_STYLE.sectionTitle }, readText('auto')),
608
+ h('div', { style: SETTINGS_STYLE.sectionTitle }, readText('auto'), h('span', { style: SETTINGS_STYLE.badge }, readText('autoBadge'))),
566
609
  row('auto', readText('autoRefresh'), readText('autoRefreshHint'), toggle(autoRefresh, setAutoRefresh, readText('autoRefresh'))),
567
- row('minutes', readText('minInterval'), readText('minIntervalHint'), number(minutes, setMinutes, 0, 60)),
568
- row('freeze', readText('freeze'), readText('freezeHint'), number(freeze, setFreeze, 0, 100000)),
610
+ row('minutes', readText('minInterval'), readText('minIntervalHint'), number(minutes, setMinutes, 0, 60, readText('minutes'))),
611
+ row('freeze', readText('freeze'), readText('freezeHint'), number(freeze, setFreeze, 0, 100000, readText('messages'))),
569
612
  row('backfill', readText('backfill'), readText('backfillHint'), toggle(backfill, setBackfill, readText('backfill'))),
570
613
  h(
571
614
  'button',
@@ -575,8 +618,9 @@ window.__ModuleLoader__.load({
575
618
  ),
576
619
  advancedOpen
577
620
  ? h('div', null,
578
- row('nameChars', readText('nameLimit'), readText('nameLimitHint'), number(nameChars, setNameChars, 4, 40)),
579
- row('recent', readText('recentMessages'), readText('recentMessagesHint'), number(recentMessages, setRecentMessages, 2, 20)),
621
+ row('nameChars', readText('nameLimit'), readText('nameLimitHint'), number(nameChars, setNameChars, 4, 40, readText('chars'))),
622
+ row('recent', readText('recentMessages'), readText('recentMessagesHint'), number(recentMessages, setRecentMessages, 2, 20, readText('messages'))),
623
+ row('bytes', readText('maxBytes'), readText('maxBytesHint'), number(maxTitleBytes, setMaxTitleBytes, 1, 80, readText('bytes'))),
580
624
  h('div', { style: { ...SETTINGS_STYLE.desc, marginTop: '8px' } }, readText('advancedHint')),
581
625
  )
582
626
  : null,
Binary file
Binary file
package/lib/format.js CHANGED
@@ -177,6 +177,7 @@ export function resolveSettings(raw, serviceMaxBytes) {
177
177
  ? [...new Set(config.categories.map((item) => String(item).trim()).filter(Boolean))]
178
178
  : []
179
179
  const categoryPreset = config.categoryPreset === 'en' ? 'en' : 'zh'
180
+ const titleLanguage = config.titleLanguage === 'zh' || config.titleLanguage === 'en' ? config.titleLanguage : 'auto'
180
181
  const categories =
181
182
  configured.length > 0
182
183
  ? configured.slice(0, 24)
@@ -205,6 +206,7 @@ export function resolveSettings(raw, serviceMaxBytes) {
205
206
 
206
207
  return Object.freeze({
207
208
  categoryPreset,
209
+ titleLanguage,
208
210
  // Legacy message-count cadence. The turn/end listener uses it only when
209
211
  // refreshOnTurnEnd is explicitly false.
210
212
  retitleEvery,
@@ -601,7 +603,11 @@ export function buildSystemPrompt(settings, hasPreviousTitle) {
601
603
  hints,
602
604
  '',
603
605
  '名称规则:',
604
- '- 与对话主要语言一致;中文 6-18 个汉字,非中文不超过 10 个词;',
606
+ settings.titleLanguage === 'zh'
607
+ ? '- 名称必须使用中文(必要的英文技术名词可以保留);6-18 个汉字;'
608
+ : settings.titleLanguage === 'en'
609
+ ? '- 名称必须使用英文(必要的专有名词可以保留);不超过 10 个词;'
610
+ : '- 与对话主要语言一致;中文 6-18 个汉字,非中文不超过 10 个词;',
605
611
  '- 概括会话的主要主题或任务,不要只复述问候、客套或「继续」;',
606
612
  '- 不要包含日期、分类名、竖线 |、引号、换行、Markdown、文件路径或命令;',
607
613
  '- 信息不足时,按用户输入的主题起一个简短名称,不要解释。',
package/lib/index.js CHANGED
@@ -38,6 +38,9 @@ const PrefsSchema = Schema.object({
38
38
  categoryEmoji: Schema.boolean()
39
39
  .default(false)
40
40
  .description('给分类加 emoji 前缀,例如 ⚡ 优化'),
41
+ titleLanguage: Schema.union([Schema.const('auto'), Schema.const('zh'), Schema.const('en')])
42
+ .default('auto')
43
+ .description('标题名称语言:auto 跟随对话 / zh 中文 / en English'),
41
44
  dateFormat: Schema.union([Schema.const('MMDD'), Schema.const('YYMM'), Schema.const('YYYYMMDD')])
42
45
  .default('MMDD')
43
46
  .description('{date} 使用日期格式'),
@@ -59,6 +62,9 @@ const PrefsSchema = Schema.object({
59
62
  maxNameChars: Schema.natural()
60
63
  .default(20)
61
64
  .description('名称最大字符数'),
65
+ maxTitleBytes: Schema.natural()
66
+ .default(80)
67
+ .description('标题最大字节数'),
62
68
  recentMessages: Schema.natural()
63
69
  .default(8)
64
70
  .description('标题请求包含的最近消息数'),
@@ -69,7 +75,6 @@ const LimitsSchema = Schema.object({
69
75
  .default([])
70
76
  .hidden(true)
71
77
  .description('自定义分类词表,覆盖 categoryPreset'),
72
- maxTitleBytes: Schema.natural().default(80).hidden(true),
73
78
  maxInputBytes: Schema.natural().default(4096).hidden(true),
74
79
  maxOutputTokens: Schema.natural().default(4096).hidden(true),
75
80
  timeoutMs: Schema.natural().default(90000).hidden(true),
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 settings page, manual generation, and hover cost/duration.",
38
- "zh": "把 DSH 会话标题固定为「日期 | 分类 | 名称」,支持回答后自动重算、设置页、手动生成和悬停成本/耗时。"
37
+ "en": "Keeps DSH session titles in DATE | CATEGORY | NAME with turn-aware auto-retitle, a settings page, title-language control, 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.7.0",
61
- "publishTimestamp": 1793721856,
60
+ "version": "0.8.0",
61
+ "publishTimestamp": 1794063249,
62
62
  "source": {
63
63
  "type": "git",
64
64
  "url": "https://github.com/xuedipiaofei/dsh-session-title-stamp",
65
- "commit": "e46d3544174626f922a2c1749bb300db93d01d04"
65
+ "commit": "d77389f8dfd7ec63d7ed6cb84d709230cb1bf93f"
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.7.0",
4
- "description": "DSH session titles in a DATE | CATEGORY | NAME template, with turn-aware auto-generation, a settings page, a Generate title button, and hover cost/duration.",
3
+ "version": "0.8.0",
4
+ "description": "DSH session titles in a DATE | CATEGORY | NAME template, with turn-aware auto-generation, a settings page, title-language control, and hover duration/cost/token stats.",
5
5
  "keywords": [
6
6
  "dsh",
7
7
  "dsh-plugin",
@@ -35,7 +35,8 @@
35
35
  "icon.svg",
36
36
  "README.md",
37
37
  "README.zh.md",
38
- "docs/0.7.0-settings-mock.png"
38
+ "docs/0.7.0-settings-mock.png",
39
+ "docs/0.7.0-hover-card-mock.png"
39
40
  ],
40
41
  "engines": {
41
42
  "dsh": ">=0.2.1-rc.3 <0.3.0"