Files
opencode-manager/backend/src/services/session-changes.ts
T
Chris Scott b36d412ca2 feat: add multi-run fusion and session change walkthroughs
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
2026-10-06 15:27:14 -04:00

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,
})
}