fix(sessions): prevent duplicate goal starts and lost autosave updates

- Block prompt submission while an armed goal is starting.
- Launch multi-runs with mutate so a failed launch is not an
  unhandled rejection.
- Save changed session automation fields in one update so concurrent
  autosaves cannot overwrite each other.
This commit is contained in:
Chris Scott committed 2026-10-03 22:51:03 -04:00
1 parent 96e02e9646
commit 2072fae1b6
6 files changed
+137 -38

No files matched your search

@@ -165,6 +165,23 @@ describe('MultiRunDialog', () => {
})
})
it('keeps the launch tab when the launch request fails', async () => {
const user = userEvent.setup()
mocks.launchMultiRun.mockRejectedValue(new Error('launch failed'))
renderDialog()
await user.type(screen.getByLabelText('Group name'), 'Sweep')
await user.type(screen.getByLabelText('Prompt'), 'go')
await user.click(screen.getByRole('checkbox', { name: 'GPT-4o' }))
await user.click(screen.getByRole('button', { name: 'Launch' }))
await waitFor(() => {
expect(mocks.launchMultiRun).toHaveBeenCalled()
})
expect(screen.getByLabelText('Group name')).toBeInTheDocument()
expect(screen.queryByText('No runs yet.')).not.toBeInTheDocument()
})
it('submits the catalog id for configured model aliases', async () => {
const user = userEvent.setup()
mocks.launchMultiRun.mockResolvedValue(startedRun)
@@ -94,7 +94,7 @@ export function MultiRunDialog({
const canSubmit =
name.trim().length > 0 && prompt.trim().length > 0 && selectedModels.length > 0 && !launch.isPending
const handleLaunch = async () => {
const handleLaunch = () => {
const request: LaunchMultiRunRequest = {
repoId,
name: name.trim(),
@@ -103,8 +103,7 @@ export function MultiRunDialog({
isolate,
...(baseRef.trim() ? { baseRef: baseRef.trim() } : {}),
}
await launch.mutateAsync(request)
setActiveTab('runs')
launch.mutate(request, { onSuccess: () => setActiveTab('runs') })
}
const openEntry = (entry: MultiRunEntry) => {
@@ -200,7 +199,7 @@ export function MultiRunDialog({
</div>
<div className="flex justify-end">
<Button onClick={() => { void handleLaunch() }} disabled={!canSubmit}>
<Button onClick={handleLaunch} disabled={!canSubmit}>
{launch.isPending ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />