@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.
- package/lib/index.js +8 -1
- 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 (
|
|
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
|
}
|