From 6bdeb712f4710183e4f68e0dff015fb4f95487ca Mon Sep 17 00:00:00 2001 From: Val Alexander Date: Mon, 9 Mar 2026 18:56:28 -0500 Subject: [PATCH] fix: scope /kill to current session subtree and preserve usage.cost in chat.history - Restrict /kill matching to only subagents belonging to the current session's agent subtree (P1 review feedback) - Preserve nested usage.cost in chat.history sanitization so cost badges remain available (P2 review feedback) --- .gitignore | 1 + src/gateway/server-methods/chat.ts | 8 ++++++++ ui/src/ui/chat/slash-command-executor.ts | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 29afb5e1261..8c021b0d94a 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,4 @@ dist/protocol.schema.json # Synthing **/.stfolder/ +openclaw diff --git a/src/gateway/server-methods/chat.ts b/src/gateway/server-methods/chat.ts index 291e323b671..aa035661aa6 100644 --- a/src/gateway/server-methods/chat.ts +++ b/src/gateway/server-methods/chat.ts @@ -352,6 +352,14 @@ function sanitizeUsage(raw: unknown): Record | undefined { } } + // Preserve nested usage.cost when present + if ("cost" in u && u.cost != null && typeof u.cost === "object") { + const sanitizedCost = sanitizeCost(u.cost); + if (sanitizedCost) { + (out as Record).cost = sanitizedCost; + } + } + return Object.keys(out).length > 0 ? out : undefined; } diff --git a/ui/src/ui/chat/slash-command-executor.ts b/ui/src/ui/chat/slash-command-executor.ts index d1c767370a4..2d5366e7087 100644 --- a/ui/src/ui/chat/slash-command-executor.ts +++ b/ui/src/ui/chat/slash-command-executor.ts @@ -354,10 +354,10 @@ function resolveKillTargets( const isMatch = (normalizedTarget === "all" && belongsToCurrentSession) || normalizedKey === normalizedTarget || - (parsed?.agentId ?? "") === normalizedTarget || - normalizedKey.endsWith(`:subagent:${normalizedTarget}`) || - normalizedKey === `subagent:${normalizedTarget}` || - (belongsToCurrentSession && normalizedKey.endsWith(`:subagent:${normalizedTarget}`)); + (belongsToCurrentSession && + ((parsed?.agentId ?? "") === normalizedTarget || + normalizedKey.endsWith(`:subagent:${normalizedTarget}`) || + normalizedKey === `subagent:${normalizedTarget}`)); if (isMatch) { keys.add(key); }