Skip to content

Commit 6fca142

Browse files
icecrasher321claude
andcommitted
fix(sandboxes): stop create mode surviving a return to an open sandbox
Cursor Bugbot. Create mode and having a sandbox open are mutually exclusive, but nothing enforced it, so both could be set at once — and the screen then lied about which sandbox its Delete pointed at. With `isCreating` true and `selectedId` restored, `baseline` is null, so the editor renders an empty "New sandbox" form, while the Delete action is built from `selected` and still targets the restored sandbox. An admin looking at a blank create form could delete a sandbox it never named. Two ways in, both closed: - Browser Forward after starting a new sandbox restores `selectedId` without going through `closeEditor`. The render-time sync that already drops a stale draft now also leaves create mode, which is the same class of correction and the reason that block exists. - "New sandbox" set `isCreating` without clearing `selectedId`, so the same contradiction was reachable without touching history at all. It now clears the selection, with `history: 'replace'` because switching mode is not a destination. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4170319 commit 6fca142

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/settings/components/sandboxes

apps/sim/app/workspace/[workspaceId]/settings/components/sandboxes/sandboxes.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export function Sandboxes() {
8181
setDraft(null)
8282
setIssues([])
8383
}
84+
// Creating and having one open are mutually exclusive, and history can land on
85+
// a sandbox while create mode is still set — Forward after starting a new one.
86+
// Leaving both on renders an empty "New sandbox" form whose Delete still points
87+
// at the restored sandbox.
88+
if (selectedId) setIsCreating(false)
8489
}
8590

8691
const sandboxes = data?.sandboxes ?? []
@@ -260,6 +265,9 @@ export function Sandboxes() {
260265
onSelect: () => {
261266
setDraft(emptyDraft())
262267
setIsCreating(true)
268+
// Starting a new one is not editing the open one. Replace rather
269+
// than push: this is a mode switch, not a destination.
270+
void setSelectedId(null, { history: 'replace' })
263271
},
264272
},
265273
]

0 commit comments

Comments
 (0)