narrow sandbox slug fix to shared/agent scopes only

This commit is contained in:
Bryan Tegomoh 2026-03-20 23:05:50 -05:00
parent 90fea3d714
commit c96192bb02
2 changed files with 14 additions and 8 deletions

View File

@ -141,11 +141,14 @@ export async function ensureSandboxBrowser(params: {
return null;
}
// Include workspaceDir in the slug so co-hosted instances with different HOME
// dirs produce distinct container names (fixes #51363).
// Include workspaceDir in the slug for shared/agent scopes so co-hosted
// instances with different HOME dirs produce distinct container names
// (fixes #51363). Session-scope containers are already collision-free via
// their per-session unique key, so we leave those names unchanged to avoid
// orphaning existing containers on upgrade.
const slug = slugifySessionKey(
params.cfg.scope === "shared"
? `shared:${params.workspaceDir}`
params.cfg.scope === "session"
? params.scopeKey
: `${params.scopeKey}:${params.workspaceDir}`,
);
const name = `${params.cfg.browser.containerPrefix}${slug}`;

View File

@ -496,11 +496,14 @@ export async function ensureSandboxContainer(params: {
cfg: SandboxConfig;
}) {
const scopeKey = resolveSandboxScopeKey(params.cfg.scope, params.sessionKey);
// Include workspaceDir in the slug so co-hosted instances with different HOME
// dirs produce distinct container names (fixes #51363).
// Include workspaceDir in the slug for shared/agent scopes so co-hosted
// instances with different HOME dirs produce distinct container names
// (fixes #51363). Session-scope containers are already collision-free via
// their per-session unique key, so we leave those names unchanged to avoid
// orphaning existing containers on upgrade.
const slug = slugifySessionKey(
params.cfg.scope === "shared"
? `shared:${params.workspaceDir}`
params.cfg.scope === "session"
? scopeKey
: `${scopeKey}:${params.workspaceDir}`,
);
const name = `${params.cfg.docker.containerPrefix}${slug}`;