fix(webchat): preserve session labels across /new resets (#23755)

Co-authored-by: ThunderStormer <16649514+ThunderStormer@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-02-22 21:05:36 +01:00
parent 8a83ca54a1
commit 19046e0cfc
3 changed files with 41 additions and 0 deletions

View File

@@ -996,6 +996,42 @@ describe("initSessionState preserves behavior overrides across /new and /reset",
expect(result.sessionEntry.reasoningLevel).toBe("low");
});
it("/new preserves session label from previous session", async () => {
const storePath = await createStorePath("openclaw-reset-label-");
const sessionKey = "agent:main:telegram:dm:user-label";
const existingSessionId = "existing-session-label";
await seedSessionStoreWithOverrides({
storePath,
sessionKey,
sessionId: existingSessionId,
overrides: { label: "telegram-priority" },
});
const cfg = {
session: { store: storePath, idleMinutes: 999 },
} as OpenClawConfig;
const result = await initSessionState({
ctx: {
Body: "/new",
RawBody: "/new",
CommandBody: "/new",
From: "user-label",
To: "bot",
ChatType: "direct",
SessionKey: sessionKey,
Provider: "telegram",
Surface: "telegram",
},
cfg,
commandAuthorized: true,
});
expect(result.isNewSession).toBe(true);
expect(result.resetTriggered).toBe(true);
expect(result.sessionEntry.label).toBe("telegram-priority");
});
it("/new in a new session does not preserve overrides", async () => {
const storePath = await createStorePath("openclaw-new-no-preserve-");
const sessionKey = "agent:main:telegram:dm:user3";