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
This commit is contained in:
Chris Scott committed 2026-10-06 15:27:14 -04:00
1 parent 90c6ccf236
commit b36d412ca2
66 files changed
+6228 -468

No files matched your search

@@ -0,0 +1,34 @@
import type { ModelRef } from '@opencode-manager/shared/opencode'
import type { OpenCodeClient } from './client'
export class GenerateTextTimeoutError extends Error {
constructor() {
super('Text generation timed out')
this.name = 'GenerateTextTimeoutError'
}
}
export async function generateTextWithTimeout(
client: OpenCodeClient,
input: { prompt: string; model?: ModelRef },
timeoutMs: number,
): Promise<string> {
const controller = new AbortController()
let timer: ReturnType<typeof setTimeout> | undefined
const timeout = new Promise<never>((_resolve, reject) => {
timer = setTimeout(() => {
controller.abort()
reject(new GenerateTextTimeoutError())
}, timeoutMs)
})
try {
const { text } = await Promise.race([
client.api.generate.text(input, { signal: controller.signal }),
timeout,
])
return text
} finally {
if (timer) clearTimeout(timer)
}
}