@threadbase-sh/scanner 0.11.5 → 0.12.1

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.cjs CHANGED
@@ -460,7 +460,7 @@ function finalizeMeta(state, filePath, account, tier) {
460
460
  filePath,
461
461
  provider: CLAUDE_CODE_PROVIDER,
462
462
  sessionId: state.sessionId || (0, import_path2.basename)(filePath, ".jsonl"),
463
- sessionName: state.sessionName,
463
+ sessionName: state.sessionName || deriveSessionNameFromFirstMessage(state.firstMessage),
464
464
  projectPath,
465
465
  projectName: getShortProjectName(projectPath),
466
466
  account,
@@ -481,6 +481,10 @@ function finalizeMeta(state, filePath, account, tier) {
481
481
  lastPrompt: state.lastPrompt || void 0
482
482
  };
483
483
  }
484
+ function deriveSessionNameFromFirstMessage(firstMessage) {
485
+ const firstLine = firstMessage?.text.split("\n", 1)[0]?.trim() ?? "";
486
+ return firstLine.slice(0, 80);
487
+ }
484
488
  function getShortProjectName(fullPath) {
485
489
  const parts = fullPath.split("/").filter(Boolean);
486
490
  return parts.slice(-3).join("/");
@@ -600,7 +604,7 @@ async function parseConversation(filePath, account) {
600
604
  projectPath: state.cwd,
601
605
  projectName: getShortProjectName2(state.cwd),
602
606
  sessionId: state.sessionId || (0, import_path3.basename)(filePath, ".jsonl"),
603
- sessionName: state.sessionName,
607
+ sessionName: state.sessionName || deriveSessionNameFromFirstMessage(messages.find((m) => m.role === "user" && m.text) ?? null),
604
608
  messages,
605
609
  fullText: textParts.join(" "),
606
610
  timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
@@ -1435,7 +1439,7 @@ function assemble(filePath, account, messages, fullText, turnDurations, state) {
1435
1439
  projectPath: state.cwd,
1436
1440
  projectName: getShortProjectName2(state.cwd),
1437
1441
  sessionId: state.sessionId || (0, import_path7.basename)(filePath, ".jsonl"),
1438
- sessionName: state.sessionName,
1442
+ sessionName: state.sessionName || deriveSessionNameFromFirstMessage(messages.find((m) => m.role === "user" && m.text) ?? null),
1439
1443
  messages,
1440
1444
  fullText,
1441
1445
  timestamp: state.latestTimestamp || (/* @__PURE__ */ new Date()).toISOString(),