Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions packages/runtime/src/__tests__/runtime-event-read-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1894,17 +1894,6 @@ class ReadOnlyStore implements SessionStore {
return { ...makeHeader(id), ...patch };
}

async markSessionReadThrough(id: string, readThroughTs: number): Promise<SessionHeader> {
const header = makeHeader(id);
if (
!Number.isFinite(readThroughTs) ||
!header.hasUnread ||
(header.lastMessageAt !== undefined && header.lastMessageAt > readThroughTs)
)
return header;
return { ...header, hasUnread: false };
}

async archive(_sessionId: string): Promise<void> {}
async unarchive(_sessionId: string): Promise<void> {}
async setFlagged(_sessionId: string, _isFlagged: boolean): Promise<void> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ function memoryStore(): SessionStore {
header = { ...header, ...patch };
return header;
},
markSessionReadThrough: async () => header,
archive: async () => {},
unarchive: async () => {},
setFlagged: async () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2538,10 +2538,6 @@ class TinySessionStore implements SessionStore {
return clone(next);
}

async markSessionReadThrough(sessionId: string, _readThroughTs: number): Promise<SessionHeader> {
return this.readHeader(sessionId);
}

async archive(sessionId: string): Promise<void> {
await this.updateHeader(sessionId, { isArchived: true, status: 'archived' });
}
Expand Down
22 changes: 0 additions & 22 deletions packages/runtime/src/__tests__/session-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17060,7 +17060,6 @@ class MemorySessionStore implements SessionStore {
readonly failNextReadMessagesFor = new Map<string, number>();
readonly failListTurnsFor = new Set<string>();
readonly failUpdateHeaderFor = new Set<string>();
readonly interleaveBeforeMarkSessionReadWriteFor = new Map<string, () => Promise<void> | void>();
failNextAppendMessage: ((message: StoredMessage) => boolean) | undefined;
failAfterNextAppendMessage: ((message: StoredMessage) => boolean) | undefined;
disposeCount = 0;
Expand Down Expand Up @@ -17277,7 +17276,6 @@ class MemorySessionStore implements SessionStore {
error.code = 'ENOENT';
throw error;
}
await this.runMarkSessionReadInterleave(sessionId);
return header;
}

Expand Down Expand Up @@ -17323,26 +17321,6 @@ class MemorySessionStore implements SessionStore {
return next;
}

async markSessionReadThrough(sessionId: string, readThroughTs: number): Promise<SessionHeader> {
await this.runMarkSessionReadInterleave(sessionId);
if (this.failUpdateHeaderFor.has(sessionId))
throw new Error(`Cannot update header for ${sessionId}`);
const current = await this.readHeader(sessionId);
if (!current.hasUnread) return current;
if (current.lastMessageAt !== undefined && current.lastMessageAt > readThroughTs)
return current;
const next = { ...current, hasUnread: false };
this.headers.set(sessionId, next);
return next;
}

private async runMarkSessionReadInterleave(sessionId: string): Promise<void> {
const hook = this.interleaveBeforeMarkSessionReadWriteFor.get(sessionId);
if (!hook) return;
this.interleaveBeforeMarkSessionReadWriteFor.delete(sessionId);
await hook();
}

async archive(sessionId: string): Promise<void> {
await this.updateHeader(sessionId, {
isArchived: true,
Expand Down
7 changes: 0 additions & 7 deletions packages/runtime/src/session-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ export interface SessionStore {
sessionId: string,
input: SessionConfigurationStoreUpdate,
): Promise<VersionedSessionHeader>;
markSessionReadThrough(sessionId: string, readThroughTs: number): Promise<SessionHeader>;
archive(sessionId: string): Promise<void>;
unarchive(sessionId: string): Promise<void>;
setFlagged(sessionId: string, isFlagged: boolean): Promise<void>;
Expand Down Expand Up @@ -1642,12 +1641,6 @@ export class SessionManager {
if (header) this.runtimeKernel.updateCachedHeader(sessionId, header);
}

async markSessionRead(sessionId: string, readThroughTs: number | undefined): Promise<void> {
if (readThroughTs === undefined || !Number.isFinite(readThroughTs)) return;
const next = await this.deps.store.markSessionReadThrough(sessionId, readThroughTs);
this.runtimeKernel.updateCachedHeader(sessionId, next);
}

async renameSession(sessionId: string, name: string): Promise<void> {
await this.deps.store.rename(sessionId, name);
const header = await this.deps.store.readHeader(sessionId).catch(() => undefined);
Expand Down
2 changes: 0 additions & 2 deletions packages/storage/src/execution-stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,6 @@ async function createExecutionStoresForWrite<K extends StorageRootKind, E extend
run(() => sessionStore.updateSessionConfiguration(sessionId, input)),
markSessionReadThroughMessage: (sessionId, messageId) =>
run(() => sessionStore.markSessionReadThroughMessage(sessionId, messageId)),
markSessionReadThrough: (sessionId, readThroughTs) =>
run(() => sessionStore.markSessionReadThrough(sessionId, readThroughTs)),
archive: (sessionId) => run(() => sessionStore.archive(sessionId)),
unarchive: (sessionId) => run(() => sessionStore.unarchive(sessionId)),
setFlagged: (sessionId, isFlagged) =>
Expand Down
18 changes: 0 additions & 18 deletions packages/storage/src/session-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ export interface SessionStore {
appendMessage(sessionId: string, message: StoredMessage): Promise<void>;
appendMessages(sessionId: string, messages: StoredMessage[]): Promise<void>;
updateHeader(sessionId: string, patch: Partial<SessionHeader>): Promise<SessionHeader>;
markSessionReadThrough(sessionId: string, readThroughTs: number): Promise<SessionHeader>;
archive(sessionId: string): Promise<void>;
unarchive(sessionId: string): Promise<void>;
setFlagged(sessionId: string, isFlagged: boolean): Promise<void>;
Expand Down Expand Up @@ -870,23 +869,6 @@ class SqliteSessionStore implements SessionAuthorityStore {
await this.metadata.completeSessionRetirementCleanup(sessionId);
}

async markSessionReadThrough(sessionId: string, readThroughTs: number): Promise<SessionHeader> {
const header = await this.readHeaderSnapshot(sessionId);
const messages = await this.readMessagesSnapshot(sessionId);
const effectiveLastMessageAt = maxTimestamp(
header.lastMessageAt,
latestVisibleMessageAt(messages),
);
if (
!Number.isFinite(readThroughTs) ||
!header.hasUnread ||
(effectiveLastMessageAt !== undefined && effectiveLastMessageAt > readThroughTs)
) {
return header;
}
return this.updateHeader(sessionId, { hasUnread: false });
}

async archive(sessionId: string): Promise<void> {
const now = Date.now();
await this.updateHeader(sessionId, {
Expand Down
Loading