mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Fuse two to five completed multi-run entries into one synthesized session, and explain a session's diff as ordered walkthrough stops cached by diff hash. - Multi-run fusion service, persistence, routes and FuseRunDialog - Change walkthrough service, persistence, routes and ChangesWalkthroughDialog - Shared unified-diff parser plus bounded text generation, json-extract, text-truncate and service-error helpers
25 lines
765 B
TypeScript
25 lines
765 B
TypeScript
import type { FileDiffInfo } from '@opencode-manager/shared/opencode'
|
|
import type { OpenCodeClient } from './opencode/client'
|
|
|
|
export const SESSION_CHANGES_CONTEXT_LINES = 3
|
|
|
|
export async function readSessionChanges(client: OpenCodeClient, sessionId: string): Promise<FileDiffInfo[]> {
|
|
const [first, last] = await Promise.all([
|
|
client.api.message.list({ sessionID: sessionId, type: 'user', order: 'asc', limit: 1 }),
|
|
client.api.message.list({ sessionID: sessionId, type: 'user', order: 'desc', limit: 1 }),
|
|
])
|
|
|
|
const from = first.data[0]
|
|
const to = last.data[0]
|
|
if (!from || !to) {
|
|
return []
|
|
}
|
|
|
|
return client.api.session.diff({
|
|
sessionID: sessionId,
|
|
from: from.id,
|
|
to: to.id,
|
|
context: SESSION_CHANGES_CONTEXT_LINES,
|
|
})
|
|
}
|