mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 18:33:37 +00:00
fix: use session origin provider in sessions list
This commit is contained in:
@@ -52,6 +52,9 @@ export type SessionListRow = {
|
||||
key: string;
|
||||
kind: SessionKind;
|
||||
channel: string;
|
||||
origin?: {
|
||||
provider?: string;
|
||||
};
|
||||
spawnedBy?: string;
|
||||
label?: string;
|
||||
displayName?: string;
|
||||
|
||||
@@ -137,6 +137,12 @@ export function createSessionsListTool(opts?: {
|
||||
});
|
||||
|
||||
const entryChannel = typeof entry.channel === "string" ? entry.channel : undefined;
|
||||
const entryOrigin =
|
||||
entry.origin && typeof entry.origin === "object"
|
||||
? (entry.origin as Record<string, unknown>)
|
||||
: undefined;
|
||||
const originChannel =
|
||||
typeof entryOrigin?.provider === "string" ? entryOrigin.provider : undefined;
|
||||
const deliveryContext =
|
||||
entry.deliveryContext && typeof entry.deliveryContext === "object"
|
||||
? (entry.deliveryContext as Record<string, unknown>)
|
||||
@@ -155,7 +161,7 @@ export function createSessionsListTool(opts?: {
|
||||
const derivedChannel = deriveChannel({
|
||||
key,
|
||||
kind,
|
||||
channel: entryChannel,
|
||||
channel: entryChannel ?? originChannel,
|
||||
lastChannel,
|
||||
});
|
||||
|
||||
|
||||
@@ -432,6 +432,38 @@ describe("sessions_list transcriptPath resolution", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("sessions_list channel derivation", () => {
|
||||
beforeEach(() => {
|
||||
callGatewayMock.mockClear();
|
||||
loadConfigMock.mockReturnValue({
|
||||
session: { scope: "per-sender", mainKey: "main" },
|
||||
tools: {
|
||||
agentToAgent: { enabled: true },
|
||||
sessions: { visibility: "all" },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to origin.provider when the legacy top-level channel field is missing", async () => {
|
||||
callGatewayMock.mockResolvedValueOnce({
|
||||
path: "/tmp/sessions.json",
|
||||
sessions: [
|
||||
{
|
||||
key: "agent:main:discord:group:ops",
|
||||
kind: "group",
|
||||
origin: { provider: "discord" },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const result = await executeMainSessionsList();
|
||||
|
||||
expect(result.details).toMatchObject({
|
||||
sessions: [{ key: "agent:main:discord:group:ops", channel: "discord" }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("sessions_send gating", () => {
|
||||
beforeEach(() => {
|
||||
callGatewayMock.mockClear();
|
||||
|
||||
Reference in New Issue
Block a user