fix(tui): normalize session key to lowercase to match gateway canonicalization (#34013)

Merged via squash.

Prepared head SHA: cfe06ca131
Co-authored-by: lynnzc <6257996+lynnzc@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
Lynn
2026-03-04 14:53:38 +08:00
committed by GitHub
parent 26e014311f
commit 9d941949c9
3 changed files with 24 additions and 2 deletions

View File

@@ -74,6 +74,27 @@ describe("resolveTuiSessionKey", () => {
}),
).toBe("agent:ops:incident");
});
it("lowercases session keys with uppercase characters", () => {
// Uppercase in agent-prefixed form
expect(
resolveTuiSessionKey({
raw: "agent:main:Test1",
sessionScope: "global",
currentAgentId: "main",
sessionMainKey: "agent:main:main",
}),
).toBe("agent:main:test1");
// Uppercase in bare form (prefixed by currentAgentId)
expect(
resolveTuiSessionKey({
raw: "Test1",
sessionScope: "global",
currentAgentId: "main",
sessionMainKey: "agent:main:main",
}),
).toBe("agent:main:test1");
});
});
describe("resolveGatewayDisconnectState", () => {

View File

@@ -203,9 +203,9 @@ export function resolveTuiSessionKey(params: {
return trimmed;
}
if (trimmed.startsWith("agent:")) {
return trimmed;
return trimmed.toLowerCase();
}
return `agent:${params.currentAgentId}:${trimmed}`;
return `agent:${params.currentAgentId}:${trimmed.toLowerCase()}`;
}
export function resolveGatewayDisconnectState(reason?: string): {