dsh-session-title-stamp 0.4.2 → 0.4.4

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
@@ -59,7 +59,7 @@ and mirrors conventions used by other coding agents.
59
59
  Add this market index source in **Plugins → Discover → Index sources**:
60
60
 
61
61
  ```text
62
- https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.4.2/market/index.json
62
+ https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.4.4/market/index.json
63
63
  ```
64
64
 
65
65
  Then install **Session title stamp** from the list. The plugin installs as a
@@ -129,7 +129,7 @@ mode using `retitleEvery`.
129
129
 
130
130
  ### Header button and hover stats
131
131
 
132
- 0.4.2 adds a small browser half:
132
+ 0.4.4 adds a small browser half:
133
133
 
134
134
  - a **refresh icon** in the conversation header; it runs the same `/retitle`
135
135
  command as typing it, and is disabled while the session is running.
package/README.zh.md CHANGED
@@ -43,7 +43,7 @@
43
43
  在 **插件 → 发现(Discover)→ 索引源** 添加:
44
44
 
45
45
  ```text
46
- https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.4.2/market/index.json
46
+ https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.4.4/market/index.json
47
47
  ```
48
48
 
49
49
  然后在列表里安装 **Session title stamp / 会话标题印章**。插件以 profile bundle 的形式安装,之后可在插件页启停。
@@ -93,7 +93,7 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
93
93
 
94
94
  ### 会话头按钮与悬停统计
95
95
 
96
- 0.4.2 增加了一个很小的浏览器半边:
96
+ 0.4.4 增加了一个很小的浏览器半边:
97
97
 
98
98
  - 会话头有一个**刷新图标**,效果等同输入 `/retitle`,会话运行中禁用;
99
99
  - 鼠标悬停会话行时,在原生相对时间下面多一行:
package/client.js CHANGED
@@ -136,6 +136,7 @@ window.__ModuleLoader__.load({
136
136
  const [data, setData] = useState(null)
137
137
  useEffect(() => {
138
138
  let cancelled = false
139
+ setData(null)
139
140
  if (typeof sessionId !== 'string' || sessionId === '') return undefined
140
141
  const url = `${STATS_PATH}?sessionId=${encodeURIComponent(sessionId)}`
141
142
  fetch(url, { headers: { accept: 'application/json' } })
package/lib/index.js CHANGED
@@ -212,7 +212,14 @@ async function readCachedProjection(sessionId) {
212
212
  }
213
213
  }
214
214
 
215
+ function normalizeSessionId(sessionId) {
216
+ return typeof sessionId === 'string' && sessionId.startsWith('session-')
217
+ ? sessionId.slice('session-'.length)
218
+ : sessionId
219
+ }
220
+
215
221
  async function statsFor(scope, sessionId) {
222
+ sessionId = normalizeSessionId(sessionId)
216
223
  let tokenUsage
217
224
  let sessionStats
218
225
  let modelSelection
@@ -255,10 +262,11 @@ function registerStatsRoute(ctx, logger) {
255
262
  requestBody: 'buffered',
256
263
  fetch: async (request) => {
257
264
  const url = new URL(request.url)
258
- const sessionId = url.searchParams.get('sessionId') ?? ''
259
- if (!/^[A-Za-z0-9._-]{1,128}$/u.test(sessionId)) {
265
+ const rawSessionId = url.searchParams.get('sessionId') ?? ''
266
+ if (!/^[A-Za-z0-9._-]{1,128}$/u.test(rawSessionId)) {
260
267
  return jsonResponse({ ok: false, error: 'invalid sessionId' }, 400)
261
268
  }
269
+ const sessionId = normalizeSessionId(rawSessionId)
262
270
  const now = Date.now()
263
271
  const hit = cache.get(sessionId)
264
272
  if (hit !== undefined && now - hit.at < STATS_TTL_MS) return jsonResponse(hit.data)
package/market/index.json CHANGED
@@ -57,12 +57,12 @@
57
57
  },
58
58
  "versions": [
59
59
  {
60
- "version": "0.4.2",
61
- "publishTimestamp": 1793415126,
60
+ "version": "0.4.4",
61
+ "publishTimestamp": 1793459953,
62
62
  "source": {
63
63
  "type": "git",
64
64
  "url": "https://github.com/xuedipiaofei/dsh-session-title-stamp",
65
- "commit": "17e5986625ebae50c9db3772d6b484d652175ca6"
65
+ "commit": "ab95b6ce864fcf608c4479173d620b0c78d89686"
66
66
  },
67
67
  "engines": {
68
68
  "dsh": ">=0.2.1-rc.3 <0.3.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-title-stamp",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "DSH session titles in a DATE | CATEGORY | NAME template, with turn-aware auto-generation, a Generate title button, and hover cost/duration.",
5
5
  "keywords": [
6
6
  "dsh",