@lingda-ai/dsh-plugin-ledger 0.1.11 → 0.1.12

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.
Files changed (2) hide show
  1. package/lib/index.js +8 -1
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -173,7 +173,14 @@ export function apply(ctx, rawConfig) {
173
173
  if (typeof sid === 'string' && !sessionRoots.has(sid) && typeof session?.header?.cwd === 'string') {
174
174
  sessionRoots.set(sid, session.header.cwd)
175
175
  }
176
- if (event?.type === 'session/title' && typeof sid === 'string') {
176
+ if (typeof sid === 'string' && !titles.has(sid)) {
177
+ // 两条来源都试:标题事件(新会话)、会话对象上的现成标题(老会话,插件启动前就有标题的)
178
+ const fromEvent = event?.type === 'session/title' ? (event?.data ?? event)?.title : null
179
+ const fromSession = session?.title ?? session?.header?.title
180
+ const title = typeof fromEvent === 'string' && fromEvent.length > 0 ? fromEvent : fromSession
181
+ if (typeof title === 'string' && title.length > 0) titles.set(sid, title)
182
+ } else if (event?.type === 'session/title' && typeof sid === 'string') {
183
+ // 标题会被重新生成(例如更好的一条),已存在时也要更新
177
184
  const payload = event?.data ?? event
178
185
  if (typeof payload?.title === 'string' && payload.title.length > 0) titles.set(sid, payload.title)
179
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingda-ai/dsh-plugin-ledger",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "DSH 插件搜索入口:运行时账本(成本/用量观测)。自包含单包,不依赖其他 npm 包,便于从镜像源安装。",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [