@claude-sessions/core 0.4.8-beta.0 → 0.4.8

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as Project, M as MessagePayload$1, a as Message, T as TitleDisplayMode, S as SummaryInfo, b as SessionTodos, c as MoveSessionResult, A as AgentInfo, d as SessionSortOptions, e as ProjectTreeData, C as CompressSessionOptions, f as SummarizeSessionOptions, g as ConversationLine, h as SearchResult, F as FileChange, i as SessionsIndex, j as SessionIndexEntry } from './types-CsXAWb1Q.js';
2
- export { q as CleanupPreview, p as ClearSessionsResult, w as CompressSessionResult, k as ContentItem, D as DeleteSessionResult, x as ProjectKnowledge, R as RenameSessionResult, s as ResumeSessionOptions, t as ResumeSessionResult, v as SessionAnalysis, n as SessionFilesSummary, l as SessionMeta, z as SessionSortField, B as SessionSortOrder, r as SessionTreeData, o as SplitSessionResult, y as SummarizeSessionResult, m as TodoItem, u as ToolUsageStats } from './types-CsXAWb1Q.js';
1
+ import { P as Project, M as MessagePayload$1, a as Message, T as TitleDisplayMode, S as SummaryInfo, b as SessionSortField, c as SessionTodos, d as MoveSessionResult, A as AgentInfo, e as SessionSortOptions, f as ProjectTreeData, C as CompressSessionOptions, g as SummarizeSessionOptions, h as ConversationLine, i as SearchResult, F as FileChange, j as SessionsIndex, k as SessionIndexEntry } from './types-AvikAHId.js';
2
+ export { r as CleanupPreview, q as ClearSessionsResult, x as CompressSessionResult, l as ContentItem, D as DeleteSessionResult, y as ProjectKnowledge, R as RenameSessionResult, t as ResumeSessionOptions, u as ResumeSessionResult, w as SessionAnalysis, o as SessionFilesSummary, m as SessionMeta, B as SessionSortOrder, s as SessionTreeData, p as SplitSessionResult, z as SummarizeSessionResult, n as TodoItem, v as ToolUsageStats } from './types-AvikAHId.js';
3
3
  import * as effect_Cause from 'effect/Cause';
4
4
  import { Effect } from 'effect';
5
5
 
@@ -126,13 +126,28 @@ declare function getDisplayTitle(customTitle: string | undefined, currentSummary
126
126
  */
127
127
  declare const maskHomePath: (text: string, homeDir: string) => string;
128
128
  /**
129
- * Get sort timestamp for session (Unix timestamp ms)
130
- * Priority: summaries[0].timestamp > createdAt > 0
129
+ * Get summary-based sort timestamp for session (Unix timestamp ms)
130
+ * Used for 'summary' sort field. Priority: summaries[0].timestamp > createdAt > 0
131
131
  */
132
+ declare const getSummarySortTimestamp: (session: {
133
+ summaries?: SummaryInfo[];
134
+ createdAt?: string;
135
+ }) => number;
136
+ /** @deprecated Use getSummarySortTimestamp instead */
132
137
  declare const getSessionSortTimestamp: (session: {
133
138
  summaries?: SummaryInfo[];
134
139
  createdAt?: string;
135
140
  }) => number;
141
+ /**
142
+ * Get display-ready sort timestamp based on active sort field.
143
+ * Returns the timestamp matching what the user sees as the sort order.
144
+ */
145
+ declare const getDisplaySortTimestamp: (session: {
146
+ summaries?: SummaryInfo[];
147
+ createdAt?: string;
148
+ updatedAt?: string;
149
+ fileMtime?: number;
150
+ }, sortField: SessionSortField) => number;
136
151
  /**
137
152
  * Try to parse a single JSON line, returning null on failure with optional warning log
138
153
  * Use this when you want to skip invalid lines instead of throwing
@@ -690,4 +705,4 @@ declare const getLogger: () => Logger;
690
705
  */
691
706
  declare const createLogger: (namespace: string) => Logger;
692
707
 
693
- export { AgentInfo, type ChainError, CompressSessionOptions, ConversationLine, type DisplayTitleOptions, FileChange, type GenericMessage, type Logger, Message, MessagePayload$1 as MessagePayload, MoveSessionResult, type ProgressError, Project, ProjectTreeData, SearchResult, SessionIndexEntry, SessionSortOptions, SessionTodos, SessionsIndex, SummarizeSessionOptions, SummaryInfo, TREE_ICONS, TitleDisplayMode, type ToolUseResultError, type TreeItemType, type ValidationResult, analyzeSession, autoRepairChain, canMoveSession, clearSessions, compressSession, createLogger, deleteLinkedTodos, deleteMessage, deleteMessageWithChainRepair, deleteOrphanAgents, deleteOrphanTodos, deleteSession, expandHomePath, extractProjectKnowledge, extractTextContent, extractTitle, findLinkedAgents, findLinkedTodos, findOrphanAgents, findOrphanTodos, findProjectByWorkspacePath, folderNameToDisplayPath, folderNameToPath, formatRelativeTime, generateTreeNodeId, getCachePath, getDisplayTitle, getIndexEntryDisplayTitle, getLogger, getRealPathFromSession, getSessionFiles, getSessionSortTimestamp, getSessionTooltip, getSessionsDir, getTodoIcon, getTodosDir, getTotalTodoCount, hasSessionsIndex, isContinuationSummary, isInvalidApiKeyMessage, listProjects, listSessions, loadAgentMessages, loadProjectTreeData, loadSessionTreeData, loadSessionsIndex, maskHomePath, moveSession, parseCommandMessage, parseJsonlLines, parseTreeNodeId, pathToFolderName, previewCleanup, readJsonlFile, readSession, renameSession, repairChain, repairParentUuidChain, restoreMessage, searchSessions, sessionHasSubItems, sessionHasTodos, setLogger, sortIndexEntriesByModified, sortProjects, splitSession, summarizeSession, tryParseJsonLine, updateSessionSummary, validateChain, validateProgressMessages, validateToolUseResult };
708
+ export { AgentInfo, type ChainError, CompressSessionOptions, ConversationLine, type DisplayTitleOptions, FileChange, type GenericMessage, type Logger, Message, MessagePayload$1 as MessagePayload, MoveSessionResult, type ProgressError, Project, ProjectTreeData, SearchResult, SessionIndexEntry, SessionSortField, SessionSortOptions, SessionTodos, SessionsIndex, SummarizeSessionOptions, SummaryInfo, TREE_ICONS, TitleDisplayMode, type ToolUseResultError, type TreeItemType, type ValidationResult, analyzeSession, autoRepairChain, canMoveSession, clearSessions, compressSession, createLogger, deleteLinkedTodos, deleteMessage, deleteMessageWithChainRepair, deleteOrphanAgents, deleteOrphanTodos, deleteSession, expandHomePath, extractProjectKnowledge, extractTextContent, extractTitle, findLinkedAgents, findLinkedTodos, findOrphanAgents, findOrphanTodos, findProjectByWorkspacePath, folderNameToDisplayPath, folderNameToPath, formatRelativeTime, generateTreeNodeId, getCachePath, getDisplaySortTimestamp, getDisplayTitle, getIndexEntryDisplayTitle, getLogger, getRealPathFromSession, getSessionFiles, getSessionSortTimestamp, getSessionTooltip, getSessionsDir, getSummarySortTimestamp, getTodoIcon, getTodosDir, getTotalTodoCount, hasSessionsIndex, isContinuationSummary, isInvalidApiKeyMessage, listProjects, listSessions, loadAgentMessages, loadProjectTreeData, loadSessionTreeData, loadSessionsIndex, maskHomePath, moveSession, parseCommandMessage, parseJsonlLines, parseTreeNodeId, pathToFolderName, previewCleanup, readJsonlFile, readSession, renameSession, repairChain, repairParentUuidChain, restoreMessage, searchSessions, sessionHasSubItems, sessionHasTodos, setLogger, sortIndexEntriesByModified, sortProjects, splitSession, summarizeSession, tryParseJsonLine, updateSessionSummary, validateChain, validateProgressMessages, validateToolUseResult };
package/dist/index.js CHANGED
@@ -163,10 +163,27 @@ var maskHomePath = (text, homeDir) => {
163
163
  const regex = new RegExp(`${escapedHome}(?=[/\\\\]|$)`, "g");
164
164
  return text.replace(regex, "~");
165
165
  };
166
- var getSessionSortTimestamp = (session) => {
166
+ var getSummarySortTimestamp = (session) => {
167
167
  const timestampStr = session.summaries?.[0]?.timestamp ?? session.createdAt;
168
168
  return timestampStr ? new Date(timestampStr).getTime() : 0;
169
169
  };
170
+ var getSessionSortTimestamp = getSummarySortTimestamp;
171
+ var getDisplaySortTimestamp = (session, sortField) => {
172
+ switch (sortField) {
173
+ case "updated": {
174
+ if (session.updatedAt) return new Date(session.updatedAt).getTime();
175
+ return getSummarySortTimestamp(session);
176
+ }
177
+ case "created": {
178
+ if (session.createdAt) return new Date(session.createdAt).getTime();
179
+ return getSummarySortTimestamp(session);
180
+ }
181
+ case "modified":
182
+ return session.fileMtime ?? getSummarySortTimestamp(session);
183
+ default:
184
+ return getSummarySortTimestamp(session);
185
+ }
186
+ };
170
187
  var tryParseJsonLine = (line, lineNumber, filePath) => {
171
188
  try {
172
189
  return JSON.parse(line);
@@ -1610,7 +1627,7 @@ var loadSessionTreeDataInternal = (projectName, sessionId, summariesByTargetSess
1610
1627
  }
1611
1628
  const todos = yield* findLinkedTodos(sessionId, linkedAgentIds);
1612
1629
  const createdAt = firstMessage?.timestamp ?? void 0;
1613
- const sortTimestamp = getSessionSortTimestamp({ summaries, createdAt });
1630
+ const sortTimestamp = getSummarySortTimestamp({ summaries, createdAt });
1614
1631
  return {
1615
1632
  id: sessionId,
1616
1633
  projectName,
@@ -1709,12 +1726,16 @@ var buildProjectTreeResult = (project, sessions, sort) => {
1709
1726
  if (isErrorSessionTitle(s.currentSummary)) return false;
1710
1727
  return true;
1711
1728
  });
1729
+ const displaySessions = filteredSessions.map((s) => ({
1730
+ ...s,
1731
+ sortTimestamp: getDisplaySortTimestamp(s, sort.field)
1732
+ }));
1712
1733
  return {
1713
1734
  name: project.name,
1714
1735
  displayName: project.displayName,
1715
1736
  path: project.path,
1716
- sessionCount: filteredSessions.length,
1717
- sessions: filteredSessions
1737
+ sessionCount: displaySessions.length,
1738
+ sessions: displaySessions
1718
1739
  };
1719
1740
  };
1720
1741
  var buildTreeCache = (globalUuidMap, allSummaries, sessions, fileMtimes) => {
@@ -1741,7 +1762,7 @@ var updateSessionSummaries = (cached, summariesByTargetSession) => {
1741
1762
  const oldJson = JSON.stringify(cached.summaries);
1742
1763
  const newJson = JSON.stringify(newSummaries);
1743
1764
  if (oldJson === newJson) return cached;
1744
- const newSortTimestamp = getSessionSortTimestamp({
1765
+ const newSortTimestamp = getSummarySortTimestamp({
1745
1766
  summaries: newSummaries,
1746
1767
  createdAt: cached.createdAt
1747
1768
  });
@@ -2595,6 +2616,7 @@ export {
2595
2616
  formatRelativeTime,
2596
2617
  generateTreeNodeId,
2597
2618
  getCachePath,
2619
+ getDisplaySortTimestamp,
2598
2620
  getDisplayTitle,
2599
2621
  getIndexEntryDisplayTitle,
2600
2622
  getLogger,
@@ -2603,6 +2625,7 @@ export {
2603
2625
  getSessionSortTimestamp,
2604
2626
  getSessionTooltip,
2605
2627
  getSessionsDir,
2628
+ getSummarySortTimestamp,
2606
2629
  getTodoIcon,
2607
2630
  getTodosDir,
2608
2631
  getTotalTodoCount,