From c57fee8239ed41dbdf741760d06e1d0efae36b23 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 22 Jun 2026 14:54:45 +0800 Subject: [PATCH] chore(deadcode): remove stale preview helper APIs --- .../dispatch.preview-fallback.test.ts | 1 - extensions/slack/src/stream-mode.test.ts | 29 +------------------ extensions/slack/src/stream-mode.ts | 25 ++++------------ src/commands/doctor-config-flow.test.ts | 1 - .../doctor/shared/preview-warnings.test.ts | 7 ++++- .../doctor/shared/preview-warnings.ts | 10 ------- 6 files changed, 12 insertions(+), 61 deletions(-) diff --git a/extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts b/extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts index 74c1af07c607..52966799b708 100644 --- a/extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts +++ b/extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts @@ -842,7 +842,6 @@ vi.mock("../../stream-mode.js", () => ({ rendered: incoming, source: incoming, }), - buildStatusFinalPreviewText: () => "status", resolveSlackStreamingConfig: () => ({ mode: mockedSlackStreamingMode, nativeStreaming: mockedNativeStreaming, diff --git a/extensions/slack/src/stream-mode.test.ts b/extensions/slack/src/stream-mode.test.ts index d1a287813dfd..43ce3ededb23 100644 --- a/extensions/slack/src/stream-mode.test.ts +++ b/extensions/slack/src/stream-mode.test.ts @@ -1,25 +1,6 @@ // Slack tests cover stream mode plugin behavior. import { describe, expect, it } from "vitest"; -import { - applyAppendOnlyStreamUpdate, - buildStatusFinalPreviewText, - resolveSlackStreamingConfig, - resolveSlackStreamMode, -} from "./stream-mode.js"; - -describe("resolveSlackStreamMode", () => { - it("defaults to replace", () => { - expect(resolveSlackStreamMode(undefined)).toBe("replace"); - expect(resolveSlackStreamMode("")).toBe("replace"); - expect(resolveSlackStreamMode("unknown")).toBe("replace"); - }); - - it("accepts valid modes", () => { - expect(resolveSlackStreamMode("replace")).toBe("replace"); - expect(resolveSlackStreamMode("status_final")).toBe("status_final"); - expect(resolveSlackStreamMode("append")).toBe("append"); - }); -}); +import { applyAppendOnlyStreamUpdate, resolveSlackStreamingConfig } from "./stream-mode.js"; describe("resolveSlackStreamingConfig", () => { it("defaults to partial mode with native streaming enabled", () => { @@ -119,11 +100,3 @@ describe("applyAppendOnlyStreamUpdate", () => { }); }); }); - -describe("buildStatusFinalPreviewText", () => { - it("cycles status dots", () => { - expect(buildStatusFinalPreviewText(1)).toBe("Status: thinking.."); - expect(buildStatusFinalPreviewText(2)).toBe("Status: thinking..."); - expect(buildStatusFinalPreviewText(3)).toBe("Status: thinking."); - }); -}); diff --git a/extensions/slack/src/stream-mode.ts b/extensions/slack/src/stream-mode.ts index 7d1866391f32..9e5a7e84a89d 100644 --- a/extensions/slack/src/stream-mode.ts +++ b/extensions/slack/src/stream-mode.ts @@ -1,5 +1,4 @@ // Slack plugin module implements stream mode behavior. -import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime"; import { mapStreamingModeToSlackLegacyDraftStreamMode, resolveSlackNativeStreaming, @@ -8,26 +7,17 @@ import { type StreamingMode, } from "./streaming-compat.js"; -type SlackStreamMode = SlackLegacyDraftStreamMode; type SlackStreamingMode = StreamingMode; -const DEFAULT_STREAM_MODE: SlackStreamMode = "replace"; - -export function resolveSlackStreamMode(raw: unknown): SlackStreamMode { - if (typeof raw !== "string") { - return DEFAULT_STREAM_MODE; - } - const normalized = normalizeLowercaseStringOrEmpty(raw); - if (normalized === "replace" || normalized === "status_final" || normalized === "append") { - return normalized; - } - return DEFAULT_STREAM_MODE; -} export function resolveSlackStreamingConfig(params: { streaming?: unknown; streamMode?: unknown; nativeStreaming?: unknown; -}): { mode: SlackStreamingMode; nativeStreaming: boolean; draftMode: SlackStreamMode } { +}): { + mode: SlackStreamingMode; + nativeStreaming: boolean; + draftMode: SlackLegacyDraftStreamMode; +} { const mode = resolveSlackStreamingMode(params); const nativeStreaming = resolveSlackNativeStreaming(params); return { @@ -70,8 +60,3 @@ export function applyAppendOnlyStreamUpdate(params: { changed: true, }; } - -export function buildStatusFinalPreviewText(updateCount: number): string { - const dots = ".".repeat((Math.max(1, updateCount) % 3) + 1); - return `Status: thinking${dots}`; -} diff --git a/src/commands/doctor-config-flow.test.ts b/src/commands/doctor-config-flow.test.ts index 2a165aacfc2b..0da47d0c12d3 100644 --- a/src/commands/doctor-config-flow.test.ts +++ b/src/commands/doctor-config-flow.test.ts @@ -1242,7 +1242,6 @@ vi.mock("./doctor/shared/preview-warnings.js", () => { warningNotes: await collectWarnings(params), }; }), - collectDoctorPreviewWarnings: vi.fn(collectWarnings), }; }); diff --git a/src/commands/doctor/shared/preview-warnings.test.ts b/src/commands/doctor/shared/preview-warnings.test.ts index e3dba60ed0c3..f9d4907d7112 100644 --- a/src/commands/doctor/shared/preview-warnings.test.ts +++ b/src/commands/doctor/shared/preview-warnings.test.ts @@ -7,11 +7,16 @@ import type { OpenClawConfig } from "../../../config/config.js"; import { collectDoctorPreviewNotes, collectChannelBoundMessageToolPolicyWarnings, - collectDoctorPreviewWarnings, collectProfileConfiguredToolSectionWarnings, collectVisibleReplyToolPolicyWarnings, } from "./preview-warnings.js"; +async function collectDoctorPreviewWarnings( + params: Parameters[0], +): Promise { + return (await collectDoctorPreviewNotes(params)).warningNotes; +} + type TestManifestRecord = { id: string; channels: string[]; diff --git a/src/commands/doctor/shared/preview-warnings.ts b/src/commands/doctor/shared/preview-warnings.ts index 8383a5444b30..7a80d96d8077 100644 --- a/src/commands/doctor/shared/preview-warnings.ts +++ b/src/commands/doctor/shared/preview-warnings.ts @@ -983,13 +983,3 @@ export async function collectDoctorPreviewNotes(params: { return { infoNotes, warningNotes: warnings }; } - -/** Collect warning notes only for callers that do not display info notes. */ -export async function collectDoctorPreviewWarnings(params: { - cfg: OpenClawConfig; - doctorFixCommand: string; - env?: NodeJS.ProcessEnv; - allowExec?: boolean; -}): Promise { - return (await collectDoctorPreviewNotes(params)).warningNotes; -}