fix: reset session tokens on /new (#1542) (thanks @robbyczgw-cla)
This commit is contained in:
parent
78d9f5baff
commit
e2065e8d96
@ -19,6 +19,7 @@ Docs: https://docs.clawd.bot
|
|||||||
- CLI: suppress diagnostic session/run noise during auth probes.
|
- CLI: suppress diagnostic session/run noise during auth probes.
|
||||||
- Linux: include env-configured user bin roots in systemd PATH and align PATH audits. (#1512) Thanks @robbyczgw-cla.
|
- Linux: include env-configured user bin roots in systemd PATH and align PATH audits. (#1512) Thanks @robbyczgw-cla.
|
||||||
- TUI: render Gateway slash-command replies as system output (for example, `/context`).
|
- TUI: render Gateway slash-command replies as system output (for example, `/context`).
|
||||||
|
- TUI/Gateway: reset session token counters on `/new` and refresh the footer immediately. (#1542) Thanks @robbyczgw-cla.
|
||||||
- Media: preserve PNG alpha when possible; fall back to JPEG when still over size cap. (#1491) Thanks @robbyczgw-cla.
|
- Media: preserve PNG alpha when possible; fall back to JPEG when still over size cap. (#1491) Thanks @robbyczgw-cla.
|
||||||
- Agents: treat plugin-only tool allowlists as opt-ins; keep core tools enabled. (#1467)
|
- Agents: treat plugin-only tool allowlists as opt-ins; keep core tools enabled. (#1467)
|
||||||
- Exec approvals: persist allowlist entry ids to keep macOS allowlist rows stable. (#1521) Thanks @ngutman.
|
- Exec approvals: persist allowlist entry ids to keep macOS allowlist rows stable. (#1521) Thanks @ngutman.
|
||||||
|
|||||||
@ -345,11 +345,19 @@ describe("gateway server sessions", () => {
|
|||||||
const reset = await rpcReq<{
|
const reset = await rpcReq<{
|
||||||
ok: true;
|
ok: true;
|
||||||
key: string;
|
key: string;
|
||||||
entry: { sessionId: string };
|
entry: {
|
||||||
|
sessionId: string;
|
||||||
|
inputTokens?: number;
|
||||||
|
outputTokens?: number;
|
||||||
|
totalTokens?: number;
|
||||||
|
};
|
||||||
}>(ws, "sessions.reset", { key: "agent:main:main" });
|
}>(ws, "sessions.reset", { key: "agent:main:main" });
|
||||||
expect(reset.ok).toBe(true);
|
expect(reset.ok).toBe(true);
|
||||||
expect(reset.payload?.key).toBe("agent:main:main");
|
expect(reset.payload?.key).toBe("agent:main:main");
|
||||||
expect(reset.payload?.entry.sessionId).not.toBe("sess-main");
|
expect(reset.payload?.entry.sessionId).not.toBe("sess-main");
|
||||||
|
expect(reset.payload?.entry.inputTokens).toBe(0);
|
||||||
|
expect(reset.payload?.entry.outputTokens).toBe(0);
|
||||||
|
expect(reset.payload?.entry.totalTokens).toBe(0);
|
||||||
|
|
||||||
const badThinking = await rpcReq(ws, "sessions.patch", {
|
const badThinking = await rpcReq(ws, "sessions.patch", {
|
||||||
key: "agent:main:main",
|
key: "agent:main:main",
|
||||||
|
|||||||
@ -408,15 +408,16 @@ export function createCommandHandlers(context: CommandHandlerContext) {
|
|||||||
case "new":
|
case "new":
|
||||||
case "reset":
|
case "reset":
|
||||||
try {
|
try {
|
||||||
// Clear token counts immediately to avoid stale display (#1523)
|
await client.resetSession(state.currentSessionKey);
|
||||||
state.sessionInfo.inputTokens = null;
|
// Clear token counts after reset to avoid stale display while refreshing. (#1523)
|
||||||
state.sessionInfo.outputTokens = null;
|
state.sessionInfo.inputTokens = 0;
|
||||||
state.sessionInfo.totalTokens = null;
|
state.sessionInfo.outputTokens = 0;
|
||||||
|
state.sessionInfo.totalTokens = 0;
|
||||||
tui.requestRender();
|
tui.requestRender();
|
||||||
|
|
||||||
await client.resetSession(state.currentSessionKey);
|
|
||||||
chatLog.addSystem(`session ${state.currentSessionKey} reset`);
|
chatLog.addSystem(`session ${state.currentSessionKey} reset`);
|
||||||
await loadHistory();
|
await loadHistory();
|
||||||
|
await refreshSessionInfo();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
chatLog.addSystem(`reset failed: ${String(err)}`);
|
chatLog.addSystem(`reset failed: ${String(err)}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user