mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
feat(tui): fuse all started results of a run from the run list
This commit is contained in:
1 parent
588bf7b12e
commit
f67a48b728
4 files changed
+19
-8
No files matched your search
+3
-2
@@ -168,8 +168,9 @@ attached Manager repo through `ocm`:
|
||||
optional base ref. `ctrl+s` launches, and the started sessions open in tabs.
|
||||
With no prompt, `/multirun` opens the runs browser for the attached repo:
|
||||
pick a run, open entry or fusion sessions, discard entries (`d` twice), select
|
||||
results with `space`, and press `f` to fuse them with a synthesis model. A
|
||||
fusion always runs in a new worktree.
|
||||
results with `space`, and press `f` to fuse them with a synthesis model. On
|
||||
the run list, `f` fuses every started result of the highlighted run. A fusion
|
||||
always runs in a new worktree.
|
||||
|
||||
Both commands need an OpenCode Manager release that exposes
|
||||
`/api/internal/session-goals` and `/api/internal/multi-runs`. An older Manager
|
||||
|
||||
@@ -281,6 +281,11 @@ function MultiRunsDialog(props: MultiRunsDialogProps & { context: Context }) {
|
||||
if ((name === 'return' || name === 'right') && current) {
|
||||
event.preventDefault()
|
||||
setPane('details')
|
||||
return
|
||||
}
|
||||
if (name === 'f') {
|
||||
event.preventDefault()
|
||||
startFusion()
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -326,7 +331,7 @@ function MultiRunsDialog(props: MultiRunsDialogProps & { context: Context }) {
|
||||
|
||||
const hints = createMemo(() => {
|
||||
if (pane() === 'fuse') return [['tab', 'next field'], ['enter', 'pick model'], ['ctrl+s', 'fuse'], ['ctrl+b', 'back']] as const
|
||||
if (pane() === 'runs') return [['↑↓', 'select run'], ['enter', 'open run'], ['n', 'new multi-run'], ['r', 'refresh']] as const
|
||||
if (pane() === 'runs') return [['↑↓', 'select run'], ['enter', 'open run'], ['f', 'fuse results'], ['n', 'new multi-run'], ['r', 'refresh']] as const
|
||||
return [
|
||||
['↑↓', 'move'],
|
||||
['enter', 'open session'],
|
||||
|
||||
@@ -141,12 +141,12 @@ export function canDiscard(entry: MultiRunEntry): boolean {
|
||||
return entry.status === 'started' || entry.status === 'failed'
|
||||
}
|
||||
|
||||
/** Toggles an entry in the fusion selection, ignoring non-source entries and selections past the model limit. */
|
||||
/** Toggles an entry in the fusion selection, keeping run order and ignoring non-sources and selections past the model limit. */
|
||||
export function toggleFusionSource(run: MultiRun, selected: readonly number[], entryId: number): number[] {
|
||||
if (selected.includes(entryId)) return selected.filter((id) => id !== entryId)
|
||||
if (!startedEntries(run).some((entry) => entry.id === entryId)) return [...selected]
|
||||
if (selected.length >= MULTI_RUN_MAX_MODELS) return [...selected]
|
||||
return [...selected, entryId]
|
||||
const sourceIds = startedEntries(run).map((entry) => entry.id)
|
||||
if (selected.includes(entryId)) return sourceIds.filter((id) => id !== entryId && selected.includes(id))
|
||||
if (!sourceIds.includes(entryId) || selected.length >= MULTI_RUN_MAX_MODELS) return sourceIds.filter((id) => selected.includes(id))
|
||||
return sourceIds.filter((id) => id === entryId || selected.includes(id))
|
||||
}
|
||||
|
||||
export function parseLaunchForm(form: LaunchFormInput, repoId: number): ActionResult<LaunchMultiRunRequest> {
|
||||
|
||||
@@ -298,6 +298,11 @@ describe('toggleFusionSource', () => {
|
||||
expect(toggleFusionSource(run, [1, 2], 1)).toEqual([2])
|
||||
})
|
||||
|
||||
it('keeps the selection in run order regardless of toggle order', () => {
|
||||
expect(toggleFusionSource(run, [4], 1)).toEqual([1, 4])
|
||||
expect(toggleFusionSource(run, [5, 2], 4)).toEqual([2, 4, 5])
|
||||
})
|
||||
|
||||
it('ignores entries that are not started and selections past the model limit', () => {
|
||||
expect(toggleFusionSource(run, [], 3)).toEqual([])
|
||||
expect(toggleFusionSource(run, [1, 2, 4, 5, 6], 99)).toEqual([1, 2, 4, 5, 6])
|
||||
|
||||
Reference in new issue
Block a user