dsh-session-title-stamp 0.5.0 → 0.6.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 +8 -4
- package/README.zh.md +7 -4
- package/client.js +65 -0
- package/lib/format.js +29 -0
- package/lib/index.js +3 -1
- package/market/index.json +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,9 @@ title. Beyond automatic naming:
|
|
|
13
13
|
100-message freeze; forks and user-pinned titles are skipped.
|
|
14
14
|
- **Generate title** — the conversation-header ↻ button, the session row's
|
|
15
15
|
**Generate title** menu item, or `/retitle`.
|
|
16
|
+
- **Copy title** — an extra item in the session `···` menu copies the full title.
|
|
17
|
+
- **Optional category emoji** — `categoryEmoji: true` renders titles such as
|
|
18
|
+
`1027 | ⚡ 优化 | ...`.
|
|
16
19
|
- **Hover stats** — elapsed time, estimated CNY cost, and token count on the
|
|
17
20
|
session hover card.
|
|
18
21
|
- **Category language** — `categoryPreset: zh | en`, or your own `categories`.
|
|
@@ -60,7 +63,7 @@ and mirrors conventions used by other coding agents.
|
|
|
60
63
|
Add this market index source in **Plugins → Discover → Index sources**:
|
|
61
64
|
|
|
62
65
|
```text
|
|
63
|
-
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.
|
|
66
|
+
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.6.0/market/index.json
|
|
64
67
|
```
|
|
65
68
|
|
|
66
69
|
Then install **Session title stamp** from the list. The plugin installs as a
|
|
@@ -130,14 +133,14 @@ mode using `retitleEvery`.
|
|
|
130
133
|
|
|
131
134
|
### Header button and hover stats
|
|
132
135
|
|
|
133
|
-
0.
|
|
136
|
+
0.6.0 adds a small browser half:
|
|
134
137
|
|
|
135
138
|
- a **refresh icon** in the conversation header; it runs the same `/retitle`
|
|
136
139
|
command as typing it, and is disabled while the session is running.
|
|
137
140
|
- a **hover-card line** under the native relative time, for example
|
|
138
141
|
`Duration 1h 51m · est. ≈¥4.11 · 131.7M tokens`;
|
|
139
|
-
- a **Generate title** item at the top of the session row's `···` menu
|
|
140
|
-
|
|
142
|
+
- a **Generate title** item at the top of the session row's `···` menu, plus a
|
|
143
|
+
**Copy title** item below the native Copy Session ID. Neither adds a dialog.
|
|
141
144
|
|
|
142
145
|
The hover line is derived from the `sessionStats` and `tokenUsage` projections,
|
|
143
146
|
priced with the current DeepSeek CNY rate table, and labelled as an estimate.
|
|
@@ -188,6 +191,7 @@ Override the row in the profile's `cordis.patch.yml`:
|
|
|
188
191
|
| `timeZone` | host local | IANA zone used for date/time placeholders |
|
|
189
192
|
| `categoryPreset` | `zh` | Built-in category language: `zh` or `en` |
|
|
190
193
|
| `categories` | preset | Explicit category list; overrides `categoryPreset` |
|
|
194
|
+
| `categoryEmoji` | `false` | Prefix the category with its emoji (⚡ 优化, 🐛 修复, ...) |
|
|
191
195
|
| `maxNameChars` | `20` | Character cap before the byte cap applies |
|
|
192
196
|
| `maxTitleBytes` | service cap (`80`) | Effective cap is the smaller of this and `session-title`'s cap |
|
|
193
197
|
| `recentMessages` | `8` | First message plus this many recent messages are sent |
|
package/README.zh.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
- **自动重算**:回答完成后更新,2 分钟冷却,超过 100 条消息后冻结;fork、子代理和手动固定的标题跳过。
|
|
8
8
|
- **生成标题**:会话头 ↻ 按钮、会话行 `···` 菜单「自动生成标题」、或 `/retitle`。
|
|
9
|
+
- **复制标题**:会话行 `···` 菜单多一项复制完整标题。
|
|
10
|
+
- **可选 emoji 分类**:`categoryEmoji: true` 后标题形如 `1027 | ⚡ 优化 | ...`。
|
|
9
11
|
- **悬停统计**:会话行悬停显示耗时、估算 CNY 成本、token 数。
|
|
10
12
|
- **分类语言**:`categoryPreset: zh | en`,也可以用 `categories` 自定义。
|
|
11
13
|
- **失败保护**:重算失败保留当前标题,不被兜底标题覆盖。
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
在 **插件 → 发现(Discover)→ 索引源** 添加:
|
|
45
47
|
|
|
46
48
|
```text
|
|
47
|
-
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.
|
|
49
|
+
https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.6.0/market/index.json
|
|
48
50
|
```
|
|
49
51
|
|
|
50
52
|
然后在列表里安装 **Session title stamp / 会话标题印章**。插件以 profile bundle 的形式安装,之后可在插件页启停。
|
|
@@ -94,13 +96,13 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
|
|
|
94
96
|
|
|
95
97
|
### 会话头按钮与悬停统计
|
|
96
98
|
|
|
97
|
-
0.
|
|
99
|
+
0.6.0 增加了一个很小的浏览器半边:
|
|
98
100
|
|
|
99
101
|
- 会话头有一个**刷新图标**,效果等同输入 `/retitle`,会话运行中禁用;
|
|
100
102
|
- 鼠标悬停会话行时,在原生相对时间下面多一行:
|
|
101
103
|
`耗时 1h 51m · 估算 ≈¥4.11 · 131.7M tokens`;
|
|
102
|
-
- 会话行 `···`
|
|
103
|
-
|
|
104
|
+
- 会话行 `···` 菜单最上面多一项「自动生成标题」,下面多一项「复制标题」;
|
|
105
|
+
两者都不新开弹窗。
|
|
104
106
|
|
|
105
107
|
数字来自 `sessionStats` / `tokenUsage` 投影,按 DeepSeek 当前 CNY 价格估算,并标注「估算」。只在悬停时向宿主请求,不会为了显示数字去恢复未加载的会话。DSH 原生已经有运行中/待交互/完成未读的状态点与 loader,所以本插件**不再加一层状态颜色**。
|
|
106
108
|
|
|
@@ -142,6 +144,7 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
|
|
|
142
144
|
| `timeZone` | 本机时区 | 日期/时间占位符使用的 IANA 时区 |
|
|
143
145
|
| `categoryPreset` | `zh` | 内置分类语言:`zh` 或 `en` |
|
|
144
146
|
| `categories` | 预设 | 显式分类词表,优先级高于 `categoryPreset` |
|
|
147
|
+
| `categoryEmoji` | `false` | 给分类加 emoji 前缀(⚡ 优化、🐛 修复……) |
|
|
145
148
|
| `maxNameChars` | `20` | 名称字符上限(最终还受字节上限约束) |
|
|
146
149
|
| `maxTitleBytes` | 标题服务上限(`80`) | 实际取它与 `session-title` 的较小值 |
|
|
147
150
|
| `recentMessages` | `8` | 发送首条消息 + 最近 N 条消息 |
|
package/client.js
CHANGED
|
@@ -27,6 +27,8 @@ window.__ModuleLoader__.load({
|
|
|
27
27
|
running: '会话运行中,稍后再试',
|
|
28
28
|
duration: '耗时',
|
|
29
29
|
estimate: '估算',
|
|
30
|
+
copyTitle: '复制标题',
|
|
31
|
+
copyHint: '复制完整会话标题',
|
|
30
32
|
},
|
|
31
33
|
en: {
|
|
32
34
|
menu: 'Generate title',
|
|
@@ -34,6 +36,8 @@ window.__ModuleLoader__.load({
|
|
|
34
36
|
running: 'Session is running; try again later',
|
|
35
37
|
duration: 'Duration',
|
|
36
38
|
estimate: 'est.',
|
|
39
|
+
copyTitle: 'Copy title',
|
|
40
|
+
copyHint: 'Copy the full session title',
|
|
37
41
|
},
|
|
38
42
|
}
|
|
39
43
|
|
|
@@ -205,8 +209,57 @@ window.__ModuleLoader__.load({
|
|
|
205
209
|
)
|
|
206
210
|
}
|
|
207
211
|
|
|
212
|
+
function CopyIcon() {
|
|
213
|
+
return h(
|
|
214
|
+
'svg',
|
|
215
|
+
{
|
|
216
|
+
width: 14,
|
|
217
|
+
height: 14,
|
|
218
|
+
viewBox: '0 0 16 16',
|
|
219
|
+
fill: 'none',
|
|
220
|
+
stroke: 'currentColor',
|
|
221
|
+
strokeWidth: 1.5,
|
|
222
|
+
strokeLinecap: 'round',
|
|
223
|
+
strokeLinejoin: 'round',
|
|
224
|
+
'aria-hidden': 'true',
|
|
225
|
+
},
|
|
226
|
+
h('rect', { x: 5, y: 4, width: 8, height: 9, rx: 1.5 }),
|
|
227
|
+
h('path', { d: 'M11 4V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v7A1.5 1.5 0 0 0 3.5 12H5' }),
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function CopyTitleMenuItem({ displayTitle, useMenuOpenState, t }) {
|
|
232
|
+
const menuState =
|
|
233
|
+
typeof useMenuOpenState === 'function' ? useMenuOpenState() : null
|
|
234
|
+
const disabled = typeof displayTitle !== 'string' || displayTitle === ''
|
|
235
|
+
return h(
|
|
236
|
+
'button',
|
|
237
|
+
{
|
|
238
|
+
type: 'button',
|
|
239
|
+
role: 'menuitem',
|
|
240
|
+
className: 'dsh-title-menu-item',
|
|
241
|
+
disabled,
|
|
242
|
+
title: t('copyHint'),
|
|
243
|
+
onClick: async () => {
|
|
244
|
+
if (disabled) return
|
|
245
|
+
if (Array.isArray(menuState) && typeof menuState[1] === 'function') {
|
|
246
|
+
menuState[1](false)
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
await navigator.clipboard.writeText(displayTitle)
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.warn('session-title-stamp: copy title failed', error)
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
h('span', { className: 'dsh-title-menu-icon', 'aria-hidden': 'true' }, h(CopyIcon)),
|
|
256
|
+
h('span', null, t('copyTitle')),
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
208
260
|
const STYLE_ID = 'dsh-session-title-stamp-style'
|
|
209
261
|
|
|
262
|
+
|
|
210
263
|
function installStyle(ctx) {
|
|
211
264
|
const style = document.createElement('style')
|
|
212
265
|
style.id = STYLE_ID
|
|
@@ -261,6 +314,18 @@ window.__ModuleLoader__.load({
|
|
|
261
314
|
),
|
|
262
315
|
)
|
|
263
316
|
|
|
317
|
+
ctx.slots.inject('sidebar.workspaces.session.menu.item', () =>
|
|
318
|
+
ctx.slots.register(
|
|
319
|
+
{
|
|
320
|
+
name: 'sidebar.workspaces.session.menu.item',
|
|
321
|
+
id: 'session-title-stamp-copy',
|
|
322
|
+
order: 460,
|
|
323
|
+
inject: () => ({ t }),
|
|
324
|
+
},
|
|
325
|
+
CopyTitleMenuItem,
|
|
326
|
+
),
|
|
327
|
+
)
|
|
328
|
+
|
|
264
329
|
ctx.slots.inject('sidebar.session.row.hover', () =>
|
|
265
330
|
ctx.slots.register(
|
|
266
331
|
{
|
package/lib/format.js
CHANGED
|
@@ -13,6 +13,34 @@ export const CATEGORY_PRESETS = Object.freeze({
|
|
|
13
13
|
|
|
14
14
|
export const DEFAULT_CATEGORIES = [...CATEGORY_PRESETS.zh]
|
|
15
15
|
|
|
16
|
+
/** Opt-in emoji prefixes; titles stay plain unless `categoryEmoji: true`. */
|
|
17
|
+
export const CATEGORY_EMOJI = Object.freeze({
|
|
18
|
+
分析: '🔍',
|
|
19
|
+
实现: '✨',
|
|
20
|
+
修复: '🐛',
|
|
21
|
+
优化: '⚡',
|
|
22
|
+
排查: '🔎',
|
|
23
|
+
验收: '✅',
|
|
24
|
+
发布: '🚀',
|
|
25
|
+
文档: '📝',
|
|
26
|
+
其他: '📌',
|
|
27
|
+
Analysis: '🔍',
|
|
28
|
+
Build: '✨',
|
|
29
|
+
Fix: '🐛',
|
|
30
|
+
Optimize: '⚡',
|
|
31
|
+
Debug: '🔎',
|
|
32
|
+
QA: '✅',
|
|
33
|
+
Release: '🚀',
|
|
34
|
+
Docs: '📝',
|
|
35
|
+
Other: '📌',
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
/** Prefix a configured category with its emoji when one exists. */
|
|
39
|
+
export function categoryWithEmoji(category) {
|
|
40
|
+
const emoji = CATEGORY_EMOJI[category]
|
|
41
|
+
return emoji === undefined ? category : `${emoji} ${category}`
|
|
42
|
+
}
|
|
43
|
+
|
|
16
44
|
/** Default template: `1028 | 分析 | 登录超时`. `{date}` honours `dateFormat`. */
|
|
17
45
|
export const DEFAULT_TEMPLATE = '{date} | {type} | {topic}'
|
|
18
46
|
|
|
@@ -196,6 +224,7 @@ export function resolveSettings(raw, serviceMaxBytes) {
|
|
|
196
224
|
? config.timeZone.trim()
|
|
197
225
|
: undefined,
|
|
198
226
|
categories,
|
|
227
|
+
categoryEmoji: config.categoryEmoji === true,
|
|
199
228
|
maxTitleBytes,
|
|
200
229
|
maxNameChars: Math.min(40, Math.max(4, positiveInteger(config.maxNameChars, 20))),
|
|
201
230
|
recentMessages: Math.min(20, Math.max(2, positiveInteger(config.recentMessages, 8))),
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { join } from 'node:path'
|
|
|
19
19
|
import {
|
|
20
20
|
buildInput,
|
|
21
21
|
buildSystemPrompt,
|
|
22
|
+
categoryWithEmoji,
|
|
22
23
|
cleanName,
|
|
23
24
|
composeTitle,
|
|
24
25
|
inferCategory,
|
|
@@ -454,7 +455,8 @@ export function apply(ctx, config) {
|
|
|
454
455
|
name = cleanName(undefined, settings, sourceText)
|
|
455
456
|
}
|
|
456
457
|
|
|
457
|
-
const
|
|
458
|
+
const displayCategory = settings.categoryEmoji ? categoryWithEmoji(category) : category
|
|
459
|
+
const title = composeTitle(timestamp, displayCategory, name, settings)
|
|
458
460
|
if (previousTitle !== undefined && normalizeTitle(previousTitle) === normalizeTitle(title)) {
|
|
459
461
|
logger?.info?.('session-title-stamp: title unchanged after retitle')
|
|
460
462
|
}
|
package/market/index.json
CHANGED
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
},
|
|
58
58
|
"versions": [
|
|
59
59
|
{
|
|
60
|
-
"version": "0.
|
|
61
|
-
"publishTimestamp":
|
|
60
|
+
"version": "0.6.0",
|
|
61
|
+
"publishTimestamp": 1793714709,
|
|
62
62
|
"source": {
|
|
63
63
|
"type": "git",
|
|
64
64
|
"url": "https://github.com/xuedipiaofei/dsh-session-title-stamp",
|
|
65
|
-
"commit": "
|
|
65
|
+
"commit": "cfe08afebb3fd605cdb0af44acf22d8906bba400"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"dsh": ">=0.2.1-rc.3 <0.3.0"
|
package/package.json
CHANGED