mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 00:11:19 +00:00
refactor(ui): remove unused module exports (#101262)
This commit is contained in:
parent
b2baf799b4
commit
62e5d4406d
11 changed files with 33 additions and 55 deletions
|
|
@ -3,7 +3,7 @@ export function normalizeModuleId(id: string): string {
|
|||
return id.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
export function moduleIdIncludesPackage(id: string, packageName: string): boolean {
|
||||
function moduleIdIncludesPackage(id: string, packageName: string): boolean {
|
||||
const normalized = normalizeModuleId(id);
|
||||
return (
|
||||
normalized.includes(`/node_modules/${packageName}/`) ||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ export function parsePluginApprovalRequested(payload: unknown): ExecApprovalRequ
|
|||
};
|
||||
}
|
||||
|
||||
export function pruneExecApprovalQueue(queue: ExecApprovalRequest[]): ExecApprovalRequest[] {
|
||||
function pruneExecApprovalQueue(queue: ExecApprovalRequest[]): ExecApprovalRequest[] {
|
||||
const now = Date.now();
|
||||
return queue.filter((entry) => entry.expiresAtMs > now);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { normalizeLowercaseStringOrEmpty } from "../lib/string-coerce.ts";
|
|||
import { matchesNodeSearch, parseConfigSearchQuery, renderNode } from "./config-form.node.ts";
|
||||
import { hintForPath, humanize, schemaType, type JsonSchema } from "./config-form.shared.ts";
|
||||
|
||||
export type ConfigFormProps = {
|
||||
type ConfigFormProps = {
|
||||
schema: JsonSchema | null;
|
||||
uiHints: ConfigUiHints;
|
||||
value: Record<string, unknown> | null;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Control UI view renders config form screen content.
|
||||
export { renderConfigForm, type ConfigFormProps, SECTION_META } from "./config-form.render.ts";
|
||||
export { renderConfigForm, SECTION_META } from "./config-form.render.ts";
|
||||
export { analyzeConfigSchema, type ConfigSchemaAnalysis } from "./config-form.analyze.ts";
|
||||
export { renderNode } from "./config-form.node.ts";
|
||||
export { schemaType, type JsonSchema } from "./config-form.shared.ts";
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export function formatUnknownText(
|
|||
return Object.prototype.toString.call(value);
|
||||
}
|
||||
|
||||
export type UiTimeFormatPreference = "auto" | "12" | "24";
|
||||
type UiTimeFormatPreference = "auto" | "12" | "24";
|
||||
|
||||
// Resolved `agents.defaults.timeFormat`, threaded in once at bootstrap. "auto"
|
||||
// (or unset) keeps the browser locale default so existing deployments render
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import {
|
|||
resolveAuthHintKind,
|
||||
resolvePairingHint,
|
||||
shouldShowInsecureContextHint,
|
||||
shouldShowPairingHint,
|
||||
} from "./overview-hints.ts";
|
||||
|
||||
afterEach(() => {
|
||||
|
|
@ -74,43 +73,31 @@ describe("resolveGatewayTokenForUrlEdit", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("shouldShowPairingHint", () => {
|
||||
it("returns true for 'pairing required' close reason", () => {
|
||||
expect(shouldShowPairingHint(false, "disconnected (1008): pairing required")).toBe(true);
|
||||
});
|
||||
|
||||
it("matches case-insensitively", () => {
|
||||
expect(shouldShowPairingHint(false, "Pairing Required")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when connected", () => {
|
||||
expect(shouldShowPairingHint(true, "disconnected (1008): pairing required")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false when lastError is null", () => {
|
||||
expect(shouldShowPairingHint(false, null)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for unrelated errors", () => {
|
||||
expect(shouldShowPairingHint(false, "disconnected (1006): no reason")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for auth errors", () => {
|
||||
expect(shouldShowPairingHint(false, "disconnected (4008): unauthorized")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true for structured pairing code", () => {
|
||||
expect(
|
||||
shouldShowPairingHint(
|
||||
false,
|
||||
"disconnected (4008): connect failed",
|
||||
ConnectErrorDetailCodes.PAIRING_REQUIRED,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolvePairingHint", () => {
|
||||
it.each([
|
||||
["close reason", "disconnected (1008): pairing required", undefined],
|
||||
["case-insensitive close reason", "Pairing Required", undefined],
|
||||
[
|
||||
"structured pairing code",
|
||||
"disconnected (4008): connect failed",
|
||||
ConnectErrorDetailCodes.PAIRING_REQUIRED,
|
||||
],
|
||||
])("detects pairing required from %s", (_name, lastError, lastErrorCode) => {
|
||||
expect(resolvePairingHint(false, lastError, lastErrorCode)).toEqual({
|
||||
kind: "pairing-required",
|
||||
requestId: null,
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
["connected clients", true, "disconnected (1008): pairing required"],
|
||||
["missing errors", false, null],
|
||||
["unrelated errors", false, "disconnected (1006): no reason"],
|
||||
["auth errors", false, "disconnected (4008): unauthorized"],
|
||||
])("ignores %s", (_name, connected, lastError) => {
|
||||
expect(resolvePairingHint(connected, lastError)).toBeNull();
|
||||
});
|
||||
|
||||
it("detects scope-upgrade pending approval and keeps the request id", () => {
|
||||
expect(
|
||||
resolvePairingHint(
|
||||
|
|
|
|||
|
|
@ -74,15 +74,6 @@ export function resolvePairingHint(
|
|||
return null;
|
||||
}
|
||||
|
||||
/** Whether the overview should show device-pairing guidance for this error. */
|
||||
export function shouldShowPairingHint(
|
||||
connected: boolean,
|
||||
lastError: string | null,
|
||||
lastErrorCode?: string | null,
|
||||
): boolean {
|
||||
return resolvePairingHint(connected, lastError, lastErrorCode) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the overview auth hint to show, if any.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { getSafeLocalStorage } from "../../local-storage.ts";
|
|||
import type { SessionCapability } from "./index.ts";
|
||||
import { parseAgentSessionKey } from "./session-key.ts";
|
||||
|
||||
export const SESSION_CUSTOM_GROUPS_STORAGE_KEY = "openclaw:sessions:custom-groups";
|
||||
const SESSION_CUSTOM_GROUPS_STORAGE_KEY = "openclaw:sessions:custom-groups";
|
||||
|
||||
export function loadStoredSessionCustomGroups(): string[] {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ type SessionAgentOptionsState = {
|
|||
sessionKey: string;
|
||||
};
|
||||
|
||||
export type SessionAgentFilterOption = {
|
||||
type SessionAgentFilterOption = {
|
||||
id: string;
|
||||
label: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export function readChatQueueForSession(
|
|||
: (host.chatQueueBySession?.[sessionKey] ?? []);
|
||||
}
|
||||
|
||||
export function writeChatQueueForSession(
|
||||
function writeChatQueueForSession(
|
||||
host: ChatQueueSessionHost,
|
||||
sessionKey: string,
|
||||
queue: ChatQueueItem[],
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export type ChatRealtimeState = {
|
|||
toggleRealtimeTalk: () => Promise<void>;
|
||||
};
|
||||
|
||||
export function createDefaultRealtimeTalkOptions(): RealtimeTalkOptions {
|
||||
function createDefaultRealtimeTalkOptions(): RealtimeTalkOptions {
|
||||
return {
|
||||
model: "",
|
||||
voice: "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue