Skip to content

Commit 3285517

Browse files
committed
fix: retain per-agent chat routes after identity consolidation
1 parent 7b0fb42 commit 3285517

4 files changed

Lines changed: 62 additions & 73 deletions

File tree

‎src/skills/workshop/service.test.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,14 @@ describe("skill workshop proposals", () => {
771771
});
772772

773773
const listed = await listSkillProposals({ agentId: "main", workspaceDir: secondWorkspaceDir });
774-
expect(listed.proposals).toEqual([
775-
expect.objectContaining({ id: second.record.id }),
774+
expect(listed.proposals.toSorted((a, b) => a.skillKey.localeCompare(b.skillKey))).toEqual([
776775
expect.objectContaining({ id: quarantined.record.id, workspaceMismatch: true }),
777776
expect.objectContaining({ id: first.record.id, workspaceMismatch: true }),
777+
expect.objectContaining({ id: second.record.id }),
778778
]);
779-
expect(listed.proposals[0]).not.toHaveProperty("workspaceMismatch");
779+
expect(listed.proposals.find((entry) => entry.id === second.record.id)).not.toHaveProperty(
780+
"workspaceMismatch",
781+
);
780782
await expect(
781783
inspectSkillProposal(first.record.id, {
782784
agentId: "main",
@@ -1008,10 +1010,14 @@ describe("skill workshop proposals", () => {
10081010
});
10091011

10101012
const manifest = await readSkillProposalManifest();
1011-
expect(manifest.proposals.map((entry) => [entry.skillKey, entry.status])).toEqual([
1013+
expect(
1014+
manifest.proposals
1015+
.toSorted((a, b) => a.skillKey.localeCompare(b.skillKey))
1016+
.map((entry) => [entry.skillKey, entry.status]),
1017+
).toEqual([
1018+
["draft-one", "rejected"],
10121019
["draft-three", "applied"],
10131020
["draft-two", "quarantined"],
1014-
["draft-one", "rejected"],
10151021
]);
10161022
await expect(
10171023
fs.access(path.join(workspaceDir, "skills", "draft-one", "SKILL.md")),

‎ui/src/e2e/agent-selection-persistence.e2e.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ async function hasOpenClawStartup(gateway: MockGatewayControls): Promise<boolean
9898
const params = request.params as
9999
| { agentId?: unknown; limit?: unknown; sessionKey?: unknown }
100100
| undefined;
101-
return params?.agentId === "openclaw" && params.sessionKey === "global" && params.limit === 100;
101+
return (
102+
params?.agentId === "openclaw" &&
103+
params.sessionKey === "agent:openclaw:main" &&
104+
params.limit === 100
105+
);
102106
});
103107
}
104108

‎ui/src/pages/chat/route-loader.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
import {
1919
buildAgentMainSessionKey,
2020
isUiGlobalSessionKey,
21-
isUiGlobalScopeConfigured,
2221
parseAgentSessionKey,
2322
resolveAgentIdFromSessionKey,
2423
resolveUiConfiguredMainKey,
@@ -181,14 +180,6 @@ function mainSessionKey(
181180
context: ApplicationContext,
182181
target: Extract<SessionPathTarget, { kind: "main" }>,
183182
): string {
184-
if (
185-
isUiGlobalScopeConfigured({
186-
agentsList: context.agents.state.agentsList,
187-
hello: context.gateway.snapshot.hello,
188-
})
189-
) {
190-
return "global";
191-
}
192183
return buildAgentMainSessionKey({
193184
agentId: target.agentId,
194185
mainKey: configuredMainKey(context),
@@ -379,8 +370,6 @@ export async function loadChatRoute(
379370
return {
380371
kind: "session",
381372
sessionKey,
382-
// Global keys omit the agent; the route must retain that owner separately.
383-
...(isUiGlobalSessionKey(sessionKey) ? { agentId: target.agentId } : {}),
384373
...draftRouteDataFromLocation(routeLocation),
385374
face,
386375
...(canonicalLocation && canonicalLocation.search !== routeLocation.search

‎ui/src/pages/chat/route-resolution.test.ts‎

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -110,65 +110,55 @@ function targetLocation(target: ReturnType<typeof sessionNavigationTarget>) {
110110
}
111111

112112
describe("gateway-backed session route resolution", () => {
113-
it.each([
114-
{ mainKey: "main", face: "chat", preferenceDerived: false },
115-
{ mainKey: "main", face: "dashboard", preferenceDerived: false },
116-
{ mainKey: "main", face: "chat", preferenceDerived: true },
117-
{ mainKey: "workspace", face: "chat", preferenceDerived: false },
118-
{ mainKey: "workspace", face: "dashboard", preferenceDerived: false },
119-
{ mainKey: "workspace", face: "chat", preferenceDerived: true },
120-
] as const)(
121-
"resolves global $face ownership with $mainKey (preference=$preferenceDerived)",
122-
async ({ mainKey, face, preferenceDerived }) => {
123-
const globalRow = row({ key: "global", kind: "global", boardFace: "dashboard" });
124-
const { context, list } = contextFor(({ agentId, search }) =>
125-
agentId === "research" && search === "global" ? result([globalRow]) : result([]),
126-
);
127-
context.agents.state.agentsList = {
128-
defaultId: "main",
129-
mainKey,
130-
scope: "global",
131-
agents: [],
132-
};
133-
context.gateway.snapshot.hello = {
134-
snapshot: {
135-
sessionDefaults: {
136-
defaultAgentId: "main",
137-
mainKey,
138-
mainSessionKey: "global",
139-
},
113+
it("resolves a non-default agent's canonical global face from its scoped row", async () => {
114+
const globalRow = row({ key: "global", kind: "global", boardFace: "dashboard" });
115+
const { context, list } = contextFor(({ agentId, search }) =>
116+
agentId === "research" && search === "global" ? result([globalRow]) : result([]),
117+
);
118+
context.agents.state.agentsList = {
119+
defaultId: "main",
120+
mainKey: "main",
121+
scope: "global",
122+
agents: [],
123+
};
124+
context.gateway.snapshot.hello = {
125+
snapshot: {
126+
sessionDefaults: {
127+
defaultAgentId: "main",
128+
mainKey: "main",
129+
mainSessionKey: "global",
140130
},
141-
} as ApplicationContext["gateway"]["snapshot"]["hello"];
131+
},
132+
} as ApplicationContext["gateway"]["snapshot"]["hello"];
142133

143-
const location = {
144-
pathname: `/${face}/research`,
145-
search: preferenceDerived ? `?${SESSION_FACE_PREFERENCE_PARAM}=1` : "",
134+
await expect(
135+
loadChatRoute(
136+
context,
137+
{
138+
pathname: "/chat/research",
139+
search: `?${SESSION_FACE_PREFERENCE_PARAM}=1`,
140+
hash: "",
141+
},
142+
"chat",
143+
new AbortController().signal,
144+
),
145+
).resolves.toEqual({
146+
kind: "session",
147+
sessionKey: "global",
148+
agentId: "research",
149+
draft: undefined,
150+
face: "dashboard",
151+
canonicalLocation: { pathname: "/dashboard/research", search: "", hash: "" },
152+
canonicalLocationSource: {
153+
pathname: "/chat/research",
154+
search: `?${SESSION_FACE_PREFERENCE_PARAM}=1`,
146155
hash: "",
147-
};
148-
await expect(
149-
loadChatRoute(context, location, face, new AbortController().signal),
150-
).resolves.toEqual({
151-
kind: "session",
152-
sessionKey: "global",
153-
agentId: "research",
154-
draft: undefined,
155-
face: preferenceDerived ? "dashboard" : face,
156-
...(preferenceDerived
157-
? {
158-
canonicalLocation: { pathname: "/dashboard/research", search: "", hash: "" },
159-
canonicalLocationSource: location,
160-
}
161-
: {}),
162-
});
163-
if (preferenceDerived) {
164-
expect(list).toHaveBeenCalledWith(
165-
expect.objectContaining({ agentId: "research", search: "global" }),
166-
);
167-
} else {
168-
expect(list).not.toHaveBeenCalled();
169-
}
170-
},
171-
);
156+
},
157+
});
158+
expect(list).toHaveBeenCalledWith(
159+
expect.objectContaining({ agentId: "research", search: "global" }),
160+
);
161+
});
172162

173163
it("applies an uncached stored face to a preference-derived open", async () => {
174164
const dashboardRow = row({ boardFace: "dashboard" });

0 commit comments

Comments
 (0)