@threadbase-sh/scanner 0.11.5 → 0.12.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/dist/index.js CHANGED
@@ -394,7 +394,7 @@ function finalizeMeta(state, filePath, account, tier) {
394
394
  filePath,
395
395
  provider: CLAUDE_CODE_PROVIDER,
396
396
  sessionId: state.sessionId || basename(filePath, ".jsonl"),
397
- sessionName: state.sessionName,
397
+ sessionName: state.sessionName || deriveSessionNameFromFirstMessage(state.firstMessage),
398
398
  projectPath,
399
399
  projectName: getShortProjectName(projectPath),
400
400
  account,
@@ -415,6 +415,10 @@ function finalizeMeta(state, filePath, account, tier) {
415
415
  lastPrompt: state.lastPrompt || void 0
416
416
  };
417
417
  }
418
+ function deriveSessionNameFromFirstMessage(firstMessage) {
419
+ const firstLine = firstMessage?.text.split("\n", 1)[0]?.trim() ?? "";
420
+ return firstLine.slice(0, 80);
421
+ }
418
422
  function getShortProjectName(fullPath) {
419
423
  const parts = fullPath.split("/").filter(Boolean);
420
424
  return parts.slice(-3).join("/");
@@ -534,7 +538,7 @@ async function parseConversation(filePath, account) {
534
538
  projectPath: state.cwd,
535
539
  projectName: getShortProjectName2(state.cwd),
536
540
  sessionId: state.sessionId || basename2(filePath, ".jsonl"),
537
- sessionName: state.sessionName,
541
+ sessionName: state.sessionName || deriveSessionNameFromFirstMessage(messages.find((m) => m.role === "user" && m.text) ?? null),
538
542
  messages,
539
543
  fullText: textParts.join(" "),
540
544
  timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
@@ -1369,7 +1373,7 @@ function assemble(filePath, account, messages, fullText, turnDurations, state) {
1369
1373
  projectPath: state.cwd,
1370
1374
  projectName: getShortProjectName2(state.cwd),
1371
1375
  sessionId: state.sessionId || basename4(filePath, ".jsonl"),
1372
- sessionName: state.sessionName,
1376
+ sessionName: state.sessionName || deriveSessionNameFromFirstMessage(messages.find((m) => m.role === "user" && m.text) ?? null),
1373
1377
  messages,
1374
1378
  fullText,
1375
1379
  timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),