From 2f1b67153599a9ce3ddbc76d2fdf60ba0ace3316 Mon Sep 17 00:00:00 2001 From: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com> Date: Wed, 6 May 2026 10:15:18 +1000 Subject: [PATCH] fix: remove stale history refresh plumbing --- .../.generated/plugin-sdk-api-baseline.sha256 | 4 +- .../sessions-history-http.revocation.test.ts | 47 ++----------------- src/gateway/sessions-history-http.ts | 12 ++--- src/sessions/transcript-events.ts | 3 -- 4 files changed, 8 insertions(+), 58 deletions(-) diff --git a/docs/.generated/plugin-sdk-api-baseline.sha256 b/docs/.generated/plugin-sdk-api-baseline.sha256 index f9b6788143e..6c7bb4a541f 100644 --- a/docs/.generated/plugin-sdk-api-baseline.sha256 +++ b/docs/.generated/plugin-sdk-api-baseline.sha256 @@ -1,2 +1,2 @@ -ce3eef3355f00b88eba1dd54731f932a1ffff9dee64cb19402d7d89b2c363681 plugin-sdk-api-baseline.json -28eb08edb11108d80ec5d5bd12c97108495b064a4d6dd5ca3ecc01d12c2d4c42 plugin-sdk-api-baseline.jsonl +059550f1ced90b42d6e2cd7f425be6492aac6f4d358ed85dee26a071472f7a46 plugin-sdk-api-baseline.json +84206330fa320a40d57e3f478f3bbbce943f9aea5ea4f572445aac6da7cec4b9 plugin-sdk-api-baseline.jsonl diff --git a/src/gateway/sessions-history-http.revocation.test.ts b/src/gateway/sessions-history-http.revocation.test.ts index a3a829ab7e5..5598c26cd72 100644 --- a/src/gateway/sessions-history-http.revocation.test.ts +++ b/src/gateway/sessions-history-http.revocation.test.ts @@ -3,12 +3,7 @@ import type { IncomingMessage, ServerResponse } from "node:http"; import { afterEach, describe, expect, it, vi } from "vitest"; let transcriptUpdateHandler: - | ((update: { - sessionFile?: string; - message?: unknown; - messageId?: string; - forceHistoryRefresh?: boolean; - }) => void) + | ((update: { sessionFile?: string; message?: unknown; messageId?: string }) => void) | undefined; let authRevoked = false; let gatewayConfig: { @@ -21,7 +16,6 @@ let gatewayConfig: { webchat: { chatHistoryMaxChars: 2000 }, }; let authCheckCalls = 0; -let currentScopes = ["operator.read"]; vi.mock("../config/config.js", () => ({ getRuntimeConfig: () => ({ @@ -49,7 +43,7 @@ vi.mock("./http-utils.js", () => ({ const value = req.headers[name.toLowerCase()]; return Array.isArray(value) ? value[0] : value; }, - resolveTrustedHttpOperatorScopes: () => currentScopes, + resolveTrustedHttpOperatorScopes: () => ["operator.read"], authorizeScopedGatewayHttpRequestOrReply: async () => ({ cfg: { gateway: { webchat: { chatHistoryMaxChars: 2000 } } }, requestAuth: { trustDeclaredOperatorScopes: true }, @@ -113,41 +107,7 @@ vi.mock("./session-history-state.js", () => ({ messageSeq: 1, messageId, }), - refreshAsync: async () => ({ - items: [ - false - ? { - role: "user", - content: [{ type: "text", text: "The agent cannot read this message." }], - __openclaw: { - beforeAgentRunBlocked: { - content: [{ type: "text", text: "secret blocked prompt" }], - }, - }, - } - : { - role: "user", - content: [{ type: "text", text: "The agent cannot read this message." }], - }, - ], - nextCursor: null, - messages: [ - false - ? { - role: "user", - content: [{ type: "text", text: "The agent cannot read this message." }], - __openclaw: { - beforeAgentRunBlocked: { - content: [{ type: "text", text: "secret blocked prompt" }], - }, - }, - } - : { - role: "user", - content: [{ type: "text", text: "The agent cannot read this message." }], - }, - ], - }), + refreshAsync: async () => ({ items: [], nextCursor: null, messages: [] }), }), }, })); @@ -206,7 +166,6 @@ afterEach(() => { transcriptUpdateHandler = undefined; authRevoked = false; authCheckCalls = 0; - currentScopes = ["operator.read"]; gatewayConfig = { trustedProxies: ["10.0.0.1"], allowRealIpFallback: false, diff --git a/src/gateway/sessions-history-http.ts b/src/gateway/sessions-history-http.ts index d32d11186a6..31dcf597c45 100644 --- a/src/gateway/sessions-history-http.ts +++ b/src/gateway/sessions-history-http.ts @@ -23,11 +23,7 @@ import { getHeader, resolveTrustedHttpOperatorScopes, } from "./http-utils.js"; -import { - ADMIN_SCOPE, - TALK_SECRETS_SCOPE, - authorizeOperatorScopesForMethod, -} from "./method-scopes.js"; +import { authorizeOperatorScopesForMethod } from "./method-scopes.js"; import { DEFAULT_CHAT_HISTORY_TEXT_MAX_CHARS } from "./server-methods/chat.js"; import { buildSessionHistorySnapshot, @@ -164,9 +160,7 @@ export async function handleSessionHistoryHttpRequest( entry.sessionId, target.storePath, entry.sessionFile, - { - ...resolveSessionHistoryTailReadOptions(limit), - }, + resolveSessionHistoryTailReadOptions(limit), ) : undefined; // Cursor reads still need an arbitrary historical window. The common first @@ -328,7 +322,7 @@ export async function handleSessionHistoryHttpRequest( closeStream(); return; } - if (update.message !== undefined && update.forceHistoryRefresh !== true) { + if (update.message !== undefined) { if (limit === undefined && cursor === undefined) { const nextEvent = sseState.appendInlineMessage({ message: update.message, diff --git a/src/sessions/transcript-events.ts b/src/sessions/transcript-events.ts index 956a79069e7..4c540d209ef 100644 --- a/src/sessions/transcript-events.ts +++ b/src/sessions/transcript-events.ts @@ -5,7 +5,6 @@ export type SessionTranscriptUpdate = { sessionKey?: string; message?: unknown; messageId?: string; - forceHistoryRefresh?: boolean; }; type SessionTranscriptListener = (update: SessionTranscriptUpdate) => void; @@ -28,7 +27,6 @@ export function emitSessionTranscriptUpdate(update: string | SessionTranscriptUp sessionKey: update.sessionKey, message: update.message, messageId: update.messageId, - forceHistoryRefresh: update.forceHistoryRefresh, }; const trimmed = normalizeOptionalString(normalized.sessionFile); if (!trimmed) { @@ -43,7 +41,6 @@ export function emitSessionTranscriptUpdate(update: string | SessionTranscriptUp ...(normalizeOptionalString(normalized.messageId) ? { messageId: normalizeOptionalString(normalized.messageId) } : {}), - ...(normalized.forceHistoryRefresh === true ? { forceHistoryRefresh: true } : {}), }; for (const listener of SESSION_TRANSCRIPT_LISTENERS) { try {