fix: use session origin provider in sessions list

This commit is contained in:
Tak Hoffman
2026-03-26 20:50:36 -05:00
parent e6c5ce136e
commit bd5fe92c94
3 changed files with 42 additions and 1 deletions

View File

@@ -52,6 +52,9 @@ export type SessionListRow = {
key: string;
kind: SessionKind;
channel: string;
origin?: {
provider?: string;
};
spawnedBy?: string;
label?: string;
displayName?: string;

View File

@@ -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,
});

View File

@@ -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();