fix: remove stale history refresh plumbing

This commit is contained in:
jesse-merhi
2026-05-06 10:15:18 +10:00
committed by clawsweeper
parent 545f12c067
commit 2f1b671535
4 changed files with 8 additions and 58 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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 {