refactor: name sqlite transcript locators explicitly

This commit is contained in:
Peter Steinberger
2026-05-09 05:48:48 +01:00
parent 63888f8cf1
commit 4fbcba23c1
5 changed files with 15 additions and 12 deletions

View File

@@ -260,7 +260,7 @@ function listSqliteTranscriptRecords(): SqliteTranscriptRecord[] {
agentId: entry.agentId,
sessionId: entry.sessionId,
path:
entry.path ??
entry.locator ??
createSqliteSessionTranscriptLocator({
agentId: entry.agentId,
sessionId: entry.sessionId,

View File

@@ -241,12 +241,12 @@ function resolveSqliteSessionTranscriptPath(params: {
}
const explicit = normalizeOptionalString(params.sessionEntry?.sessionFile);
if (explicit) {
const matched = candidates.find((entry) => entry.path === explicit);
const matched = candidates.find((entry) => entry.locator === explicit);
if (matched) {
return matched.path;
return matched.locator;
}
}
return candidates[0]?.path;
return candidates[0]?.locator;
}
function deriveTranscriptUsageSnapshot(

View File

@@ -196,7 +196,10 @@ describe("SQLite session transcript store", () => {
{
agentId: "main",
sessionId: "session-1",
path: createSqliteSessionTranscriptLocator({ agentId: "main", sessionId: "session-1" }),
locator: createSqliteSessionTranscriptLocator({
agentId: "main",
sessionId: "session-1",
}),
updatedAt: 200,
eventCount: 2,
},

View File

@@ -58,12 +58,12 @@ export type SqliteSessionTranscriptScope = {
};
export type SqliteSessionTranscriptLocator = SqliteSessionTranscriptScope & {
path: string;
locator: string;
updatedAt: number;
};
export type SqliteSessionTranscript = SqliteSessionTranscriptScope & {
path?: string;
locator?: string;
updatedAt: number;
eventCount: number;
};
@@ -277,8 +277,8 @@ export function listSqliteSessionTranscriptLocators(
return listSqliteSessionTranscripts(options).map((transcript) => ({
agentId: transcript.agentId,
sessionId: transcript.sessionId,
path:
transcript.path ??
locator:
transcript.locator ??
createSqliteSessionTranscriptLocator({
agentId: transcript.agentId,
sessionId: transcript.sessionId,
@@ -335,7 +335,7 @@ export function listSqliteSessionTranscripts(
{
agentId: agentDatabase.agentId,
sessionId: normalizeSessionId(record.session_id),
path: createSqliteSessionTranscriptLocator({
locator: createSqliteSessionTranscriptLocator({
agentId: agentDatabase.agentId,
sessionId: normalizeSessionId(record.session_id),
}),

View File

@@ -265,7 +265,7 @@ const applyCostTotal = (totals: CostUsageTotals, costTotal: number | undefined)
function getRememberedTranscriptPath(agentId: string, sessionId: string): string | undefined {
return listSqliteSessionTranscriptLocators().find(
(entry) => entry.agentId === agentId && entry.sessionId === sessionId,
)?.path;
)?.locator;
}
function resolveSyntheticSessionFile(params: {
@@ -590,7 +590,7 @@ export async function discoverAllSessions(params?: {
sessionFile: resolveSyntheticSessionFile({
agentId: transcript.agentId,
sessionId: transcript.sessionId,
rememberedPath: transcript.path,
rememberedPath: transcript.locator,
}),
mtime: transcript.updatedAt,
firstUserMessage,