Skip to content
Draft
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
6 changes: 5 additions & 1 deletion web-studio/src/lib/sessions/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('fetchSessionMessages', () => {
getSessionIdContextMock.mockReset()
})

it('combines completed archives with current context in chronological order', async () => {
it('combines completed archives with complete current history in chronological order', async () => {
getSessionBySessionIdMock.mockReturnValue(response({ commit_count: 2 }))
getSessionIdArchiveByArchiveIdMock
.mockReturnValueOnce(
Expand All @@ -77,6 +77,10 @@ describe('fetchSessionMessages', () => {
const result = await fetchSessionMessages('session-1')

expect(result.map(({ id }) => id)).toEqual(['1', '2', '3'])
expect(getSessionIdContextMock).toHaveBeenCalledWith({
path: { session_id: 'session-1' },
query: { token_budget: Number.MAX_SAFE_INTEGER },
})
expect(getSessionIdArchiveByArchiveIdMock).toHaveBeenNthCalledWith(1, {
path: { archive_id: 'archive_001', session_id: 'session-1' },
})
Expand Down
2 changes: 2 additions & 0 deletions web-studio/src/lib/sessions/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function deduplicateMessages(messages: Message[]): Message[] {
}

const SESSION_ARCHIVE_CONCURRENCY = 4
const COMPLETE_SESSION_HISTORY_TOKEN_BUDGET = Number.MAX_SAFE_INTEGER

async function mapWithConcurrency<T, TResult>(
items: T[],
Expand Down Expand Up @@ -164,6 +165,7 @@ export async function fetchSessionMessages(
const context = await getOvResult<SessionContextResult>(
getSessionIdContext({
path: { session_id: sessionId },
query: { token_budget: COMPLETE_SESSION_HISTORY_TOKEN_BUDGET },
}),
)

Expand Down
Loading