@@ -5,8 +5,16 @@ import path from "node:path";
55import { afterAll , beforeAll , describe , expect , it , vi } from "vitest" ;
66import type { OpenClawConfig } from "../config/config.js" ;
77import { registerSandboxBackend } from "./sandbox/backend.js" ;
8+ import {
9+ DEFAULT_SANDBOX_BROWSER_PREFIX ,
10+ DEFAULT_SANDBOX_CONTAINER_PREFIX ,
11+ } from "./sandbox/constants.js" ;
812import { ensureSandboxWorkspaceForSession , resolveSandboxContext } from "./sandbox/context.js" ;
9- import { resolveSandboxScopeKey , slugifySessionKey } from "./sandbox/shared.js" ;
13+ import {
14+ formatSandboxContainerName ,
15+ resolveSandboxScopeKey ,
16+ slugifySessionKey ,
17+ } from "./sandbox/shared.js" ;
1018
1119const updateRegistryMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
1220const syncSkillsToWorkspaceMock = vi . hoisted ( ( ) => vi . fn ( async ( ) => undefined ) ) ;
@@ -72,6 +80,23 @@ describe("resolveSandboxScopeKey", () => {
7280 ) ;
7381 } ) ;
7482
83+ it ( "keeps workspace uniqueness suffixes inside default container name limits" , ( ) => {
84+ const first = "agent:poly:msteams:channel-with-shared-readable-prefix-alpha:workspace:1234abcd" ;
85+ const second = "agent:poly:msteams:channel-with-shared-readable-prefix-beta:workspace:1234abcd" ;
86+
87+ const dockerFirst = formatSandboxContainerName ( DEFAULT_SANDBOX_CONTAINER_PREFIX , first ) ;
88+ const dockerSecond = formatSandboxContainerName ( DEFAULT_SANDBOX_CONTAINER_PREFIX , second ) ;
89+ const browserFirst = formatSandboxContainerName ( DEFAULT_SANDBOX_BROWSER_PREFIX , first ) ;
90+ const browserSecond = formatSandboxContainerName ( DEFAULT_SANDBOX_BROWSER_PREFIX , second ) ;
91+
92+ for ( const name of [ dockerFirst , dockerSecond , browserFirst , browserSecond ] ) {
93+ expect ( name . length ) . toBeLessThanOrEqual ( 63 ) ;
94+ expect ( name ) . toMatch ( / - w o r k s p a c e - 1 2 3 4 a b c d - [ a - f 0 - 9 ] { 8 } $ / ) ;
95+ }
96+ expect ( dockerFirst ) . not . toBe ( dockerSecond ) ;
97+ expect ( browserFirst ) . not . toBe ( browserSecond ) ;
98+ } ) ;
99+
75100 it ( "scopes session sandboxes by workspace" , ( ) => {
76101 const first = resolveSandboxScopeKey ( "session" , "agent:poly:msteams:channel-1" , {
77102 workspaceDir : "/tmp/openclaw-customers/atica/openclaw/agents/poly/workspace" ,
0 commit comments