mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(multi-run): add a runs sheet with inline fusion
Replace the centered Multi-run dialog and the stacked Fusion dialog with one right-side runs sheet, turn fusion into an inline selection mode, and pre-approve each selected source workspace for the fusion session. - Move MultiRunDialog into a SideDrawer with Runs / New run tabs; add MultiRunCard, FusionComposer and an optimistic starting fusion. - Add buildFusionSourcePermissionRuleset (external_directory allow, edit deny) and thread permissions through SessionLauncher.launch. - Apply the default permission mode to fusion sessions after launch. - Let ModelCombobox and BranchCombobox take a listClassName; make SideDrawer ignore an Escape already handled by a nested layer.
This commit is contained in:
1 parent
b0361cd98b
commit
f2e06abb62
23 files changed
+2122
-1736
No files matched your search
@@ -2,7 +2,12 @@ import { useMutation, useQuery, useQueryClient, type QueryClient } from '@tansta
|
||||
import { discardMultiRunEntry, fuseMultiRun, launchMultiRun, listMultiRuns } from '@/api/multiRuns'
|
||||
import { repoSiblingsQueryKey } from '@/hooks/useRepoSiblings'
|
||||
import { showToast } from '@/lib/toast'
|
||||
import type { FuseMultiRunRequest, LaunchMultiRunRequest, MultiRun } from '@opencode-manager/shared/schemas'
|
||||
import type {
|
||||
FuseMultiRunRequest,
|
||||
LaunchMultiRunRequest,
|
||||
MultiRun,
|
||||
MultiRunFusion,
|
||||
} from '@opencode-manager/shared/schemas'
|
||||
|
||||
function multiRunQueryKey(repoId: number) {
|
||||
return ['multi-runs', repoId] as const
|
||||
@@ -13,6 +18,29 @@ function invalidateMultiRunCaches(queryClient: QueryClient, repoId: number) {
|
||||
queryClient.invalidateQueries({ queryKey: repoSiblingsQueryKey(repoId) })
|
||||
}
|
||||
|
||||
function buildStartingFusion(run: MultiRun, request: FuseMultiRunRequest): MultiRunFusion {
|
||||
const now = Date.now()
|
||||
const entriesById = new Map(run.entries.map((entry) => [entry.id, entry]))
|
||||
return {
|
||||
id: -now,
|
||||
requestId: request.requestId,
|
||||
model: request.model,
|
||||
instructions: request.instructions ?? null,
|
||||
isolated: request.isolate,
|
||||
baseRef: request.baseRef ?? null,
|
||||
status: 'starting',
|
||||
sessionId: null,
|
||||
directory: null,
|
||||
error: null,
|
||||
sources: request.entryIds.flatMap((entryId) => {
|
||||
const entry = entriesById.get(entryId)
|
||||
return entry?.sessionId ? [{ entryId, sessionId: entry.sessionId, model: entry.model, truncated: false }] : []
|
||||
}),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
}
|
||||
}
|
||||
|
||||
function countEntries(run: MultiRun, status: MultiRun['entries'][number]['status']) {
|
||||
return run.entries.filter((entry) => entry.status === status).length
|
||||
}
|
||||
@@ -55,7 +83,21 @@ export function useFuseMultiRun(repoId: number) {
|
||||
return useMutation({
|
||||
mutationFn: ({ runId, request }: { runId: number; request: FuseMultiRunRequest }) =>
|
||||
fuseMultiRun(runId, request),
|
||||
onMutate: async ({ runId, request }) => {
|
||||
const queryKey = multiRunQueryKey(repoId)
|
||||
await queryClient.cancelQueries({ queryKey })
|
||||
queryClient.setQueryData<MultiRun[]>(queryKey, (runs) =>
|
||||
runs?.map((run) =>
|
||||
run.id === runId && !run.fusions.some((fusion) => fusion.requestId === request.requestId)
|
||||
? { ...run, fusions: [...run.fusions, buildStartingFusion(run, request)] }
|
||||
: run,
|
||||
),
|
||||
)
|
||||
},
|
||||
onSuccess: (run, variables) => {
|
||||
queryClient.setQueryData<MultiRun[]>(multiRunQueryKey(repoId), (runs) =>
|
||||
runs?.map((candidate) => (candidate.id === run.id ? run : candidate)),
|
||||
)
|
||||
invalidateMultiRunCaches(queryClient, repoId)
|
||||
const fusion = run.fusions.find((candidate) => candidate.requestId === variables.request.requestId)
|
||||
if (fusion?.status === 'started') {
|
||||
|
||||
Reference in new issue
Block a user