mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
perf(gateway): share one node.list snapshot across session catalog providers (#114646)
This commit is contained in:
committed by
GitHub
parent
1af330548a
commit
8f8e40dabe
@@ -374,7 +374,7 @@ async function listOpenCodeHosts(
|
||||
}
|
||||
let nodes: Awaited<ReturnType<PluginRuntime["nodes"]["list"]>>["nodes"];
|
||||
try {
|
||||
nodes = (await runtime.nodes.list()).nodes;
|
||||
nodes = (await (query.listNodes?.() ?? runtime.nodes.list())).nodes;
|
||||
} catch {
|
||||
return hosts;
|
||||
}
|
||||
|
||||
@@ -688,19 +688,20 @@ describe("OpenCode session catalog", () => {
|
||||
}),
|
||||
};
|
||||
const invoke = vi.fn().mockResolvedValue(page);
|
||||
const nodes = [
|
||||
{
|
||||
nodeId: "node-1",
|
||||
connected: true,
|
||||
commands: [OPENCODE_SESSIONS_LIST_COMMAND, OPENCODE_TERMINAL_RESUME_COMMAND],
|
||||
},
|
||||
];
|
||||
const runtimeListNodes = vi.fn().mockResolvedValue({ nodes });
|
||||
const requestListNodes = vi.fn().mockResolvedValue({ nodes });
|
||||
registerOpenCodeSessionCatalog({
|
||||
pluginConfig: {},
|
||||
runtime: {
|
||||
nodes: {
|
||||
list: vi.fn().mockResolvedValue({
|
||||
nodes: [
|
||||
{
|
||||
nodeId: "node-1",
|
||||
connected: true,
|
||||
commands: [OPENCODE_SESSIONS_LIST_COMMAND, OPENCODE_TERMINAL_RESUME_COMMAND],
|
||||
},
|
||||
],
|
||||
}),
|
||||
list: runtimeListNodes,
|
||||
invoke,
|
||||
},
|
||||
},
|
||||
@@ -711,7 +712,13 @@ describe("OpenCode session catalog", () => {
|
||||
registerNodeInvokePolicy: vi.fn(),
|
||||
} as unknown as OpenClawPluginApi);
|
||||
|
||||
await expect(provider!.list({ hostIds: ["node:node-1"], search: "remote" })).resolves.toEqual([
|
||||
await expect(
|
||||
provider!.list({
|
||||
hostIds: ["node:node-1"],
|
||||
search: "remote",
|
||||
listNodes: requestListNodes,
|
||||
}),
|
||||
).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
sessions: [
|
||||
expect.objectContaining({
|
||||
@@ -722,6 +729,8 @@ describe("OpenCode session catalog", () => {
|
||||
],
|
||||
}),
|
||||
]);
|
||||
expect(requestListNodes).toHaveBeenCalledOnce();
|
||||
expect(runtimeListNodes).not.toHaveBeenCalled();
|
||||
expect(invoke).toHaveBeenNthCalledWith(1, {
|
||||
nodeId: "node-1",
|
||||
command: OPENCODE_SESSIONS_LIST_COMMAND,
|
||||
|
||||
Reference in New Issue
Block a user