fix(browser): require managed runtime ownership for tab cap cleanup

This commit is contained in:
pandego
2026-03-01 14:14:54 +01:00
committed by Peter Steinberger
parent 9b938f2bf6
commit 22ec577d80
2 changed files with 22 additions and 1 deletions

View File

@@ -476,6 +476,11 @@ describe("browser server-context tab selection state", () => {
global.fetch = withFetchPreconnect(fetchMock);
const state = makeState("openclaw");
(state.profiles as Map<string, unknown>).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<string, unknown>).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<string, unknown>).set("openclaw", {
profile: { name: "openclaw" },
running: { pid: 1234, proc: { on: vi.fn() } },
lastTargetId: null,
});
const ctx = createBrowserRouteContext({ getState: () => state });
const openclaw = ctx.forProfile("openclaw");

View File

@@ -139,7 +139,13 @@ function createProfileContext(
};
const enforceManagedTabLimit = async (keepTargetId: string): Promise<void> => {
if (profile.driver !== "openclaw" || !profile.cdpIsLoopback || state().resolved.attachOnly) {
const profileState = getProfileState();
if (
profile.driver !== "openclaw" ||
!profile.cdpIsLoopback ||
state().resolved.attachOnly ||
!profileState.running
) {
return;
}