Skip to content

Commit f8aa866

Browse files
authored
fix: fork browser sandbox if multiple can be created (#8537)
* fix: fork browser sandbox if multiple can be created * fix: choose id depending on what's given
1 parent 34368f5 commit f8aa866

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/app/src/app/components/Create/CreateBox.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,14 @@ export const CreateBox: React.FC<CreateBoxProps> = ({
163163

164164
const createFromTemplate = (
165165
sandbox: SandboxToFork,
166-
{ name, createAs, permission, editor, customVMTier }: CreateParams
166+
{
167+
name,
168+
createAs,
169+
permission,
170+
editor,
171+
customVMTier,
172+
sandboxId,
173+
}: CreateParams
167174
) => {
168175
const openInVSCode = editor === 'vscode';
169176

@@ -177,7 +184,7 @@ export const CreateBox: React.FC<CreateBoxProps> = ({
177184

178185
actions.editor
179186
.forkExternalSandbox({
180-
sandboxId: sandbox.id,
187+
sandboxId,
181188
openInNewWindow: false,
182189
openInVSCode,
183190
autoLaunchVSCode,

packages/app/src/app/components/Create/CreateBox/CreateBoxForm.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ export const CreateBoxForm: React.FC<CreateBoxFormProps> = ({
121121
e.preventDefault();
122122

123123
onSubmit({
124+
sandboxId:
125+
runtime === 'browser'
126+
? template.browserSandboxId ?? template.id
127+
: template.id,
124128
name,
125129
createAs: runtime === 'browser' ? 'sandbox' : 'devbox',
126130
permission,

packages/app/src/app/components/Create/utils/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { GetGithubRepoQuery } from 'app/graphql/types';
22
import { TemplateType } from '@codesandbox/common/lib/templates';
33

44
export type CreateParams = {
5+
sandboxId: string;
56
name?: string;
67
createAs: 'devbox' | 'sandbox';
78
permission: 0 | 1 | 2;

0 commit comments

Comments
 (0)