chore(deadcode): remove stale preview helper APIs

This commit is contained in:
Vincent Koc
2026-06-22 14:54:45 +08:00
parent 23b4f33195
commit c57fee8239
6 changed files with 12 additions and 61 deletions

View File

@@ -842,7 +842,6 @@ vi.mock("../../stream-mode.js", () => ({
rendered: incoming,
source: incoming,
}),
buildStatusFinalPreviewText: () => "status",
resolveSlackStreamingConfig: () => ({
mode: mockedSlackStreamingMode,
nativeStreaming: mockedNativeStreaming,

View File

@@ -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.");
});
});

View File

@@ -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}`;
}

View File

@@ -1242,7 +1242,6 @@ vi.mock("./doctor/shared/preview-warnings.js", () => {
warningNotes: await collectWarnings(params),
};
}),
collectDoctorPreviewWarnings: vi.fn(collectWarnings),
};
});

View File

@@ -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<typeof collectDoctorPreviewNotes>[0],
): Promise<string[]> {
return (await collectDoctorPreviewNotes(params)).warningNotes;
}
type TestManifestRecord = {
id: string;
channels: string[];

View File

@@ -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<string[]> {
return (await collectDoctorPreviewNotes(params)).warningNotes;
}