diff --git a/src/browser/server-context.remote-tab-ops.test.ts b/src/browser/server-context.remote-tab-ops.test.ts index 47531b14e75..509c3e7a3c2 100644 --- a/src/browser/server-context.remote-tab-ops.test.ts +++ b/src/browser/server-context.remote-tab-ops.test.ts @@ -476,6 +476,11 @@ describe("browser server-context tab selection state", () => { global.fetch = withFetchPreconnect(fetchMock); const state = makeState("openclaw"); + (state.profiles as Map).set("openclaw", { + profile: { name: "openclaw" }, + running: { pid: 1234, proc: { on: vi.fn() } }, + lastTargetId: null, + }); const ctx = createBrowserRouteContext({ getState: () => state }); const openclaw = ctx.forProfile("openclaw"); @@ -516,6 +521,11 @@ describe("browser server-context tab selection state", () => { global.fetch = withFetchPreconnect(fetchMock); const state = makeState("openclaw"); + (state.profiles as Map).set("openclaw", { + profile: { name: "openclaw" }, + running: { pid: 1234, proc: { on: vi.fn() } }, + lastTargetId: null, + }); const ctx = createBrowserRouteContext({ getState: () => state }); const openclaw = ctx.forProfile("openclaw"); @@ -699,6 +709,11 @@ describe("browser server-context tab selection state", () => { global.fetch = withFetchPreconnect(fetchMock); const state = makeState("openclaw"); + (state.profiles as Map).set("openclaw", { + profile: { name: "openclaw" }, + running: { pid: 1234, proc: { on: vi.fn() } }, + lastTargetId: null, + }); const ctx = createBrowserRouteContext({ getState: () => state }); const openclaw = ctx.forProfile("openclaw"); diff --git a/src/browser/server-context.ts b/src/browser/server-context.ts index cf576c0ca16..0da19af4f28 100644 --- a/src/browser/server-context.ts +++ b/src/browser/server-context.ts @@ -139,7 +139,13 @@ function createProfileContext( }; const enforceManagedTabLimit = async (keepTargetId: string): Promise => { - if (profile.driver !== "openclaw" || !profile.cdpIsLoopback || state().resolved.attachOnly) { + const profileState = getProfileState(); + if ( + profile.driver !== "openclaw" || + !profile.cdpIsLoopback || + state().resolved.attachOnly || + !profileState.running + ) { return; }