refactor: remove unused internal helpers and state (#5667)
* refactor: remove unused internal helpers and state * test(tui): await deferred submissions before reconnect attach
This commit is contained in:
1 parent
f37ba60ed4
commit
63cc5f270d
11 files changed
+12
-118
No files matched your search
@@ -1,15 +1,3 @@
|
||||
export function parsePublicHttpUrl(value: string): URL | null {
|
||||
try {
|
||||
const url = new URL(value);
|
||||
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
||||
if (url.username || url.password) return null;
|
||||
if (isPrivateHostname(url.hostname)) return null;
|
||||
return url;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Public URL normalized for timeline display, with credentials and request-specific noise removed. */
|
||||
export function parseSafeActivityHttpUrl(value: string): URL | null {
|
||||
try {
|
||||
|
||||
@@ -27,7 +27,6 @@ import type {
|
||||
SessionHandle,
|
||||
SessionAutomationsPayload,
|
||||
SettingsPayload,
|
||||
SettingsUpdate,
|
||||
SidebarStatePayload,
|
||||
SkillDetail,
|
||||
SkillActionPayload,
|
||||
@@ -882,26 +881,6 @@ export async function updateSidebarState(
|
||||
return mutation<SidebarStatePayload>(transport, "sidebar.update", { state });
|
||||
}
|
||||
|
||||
export async function updateSettings(
|
||||
transport: WebUIMutationTransport,
|
||||
update: SettingsUpdate,
|
||||
): Promise<SettingsPayload> {
|
||||
const payload: Record<string, unknown> = {};
|
||||
if (update.modelPreset !== undefined) {
|
||||
payload.model_preset = update.modelPreset ?? "default";
|
||||
}
|
||||
if (update.model !== undefined) payload.model = update.model;
|
||||
if (update.provider !== undefined) payload.provider = update.provider;
|
||||
if (update.contextWindowTokens !== undefined) {
|
||||
payload.context_window_tokens = update.contextWindowTokens;
|
||||
}
|
||||
if (update.timezone !== undefined) payload.timezone = update.timezone;
|
||||
if (update.toolHintMaxLength !== undefined) {
|
||||
payload.tool_hint_max_length = update.toolHintMaxLength;
|
||||
}
|
||||
return mutation<SettingsPayload>(transport, "settings.agent.update", payload);
|
||||
}
|
||||
|
||||
function modelGenerationSettingsPayload(
|
||||
configuration: Pick<
|
||||
ModelConfigurationCreate,
|
||||
|
||||
@@ -1204,15 +1204,6 @@ export interface ChannelConfigurePayload {
|
||||
nanobot_features?: NanobotFeaturesPayload;
|
||||
}
|
||||
|
||||
export interface SettingsUpdate {
|
||||
model?: string;
|
||||
provider?: string;
|
||||
modelPreset?: string | null;
|
||||
contextWindowTokens?: number;
|
||||
timezone?: string;
|
||||
toolHintMaxLength?: number;
|
||||
}
|
||||
|
||||
export interface ModelConfigurationCreate {
|
||||
name: string;
|
||||
provider: string;
|
||||
|
||||
@@ -57,7 +57,6 @@ import {
|
||||
updateMcpServerTools,
|
||||
updateNetworkSafetySettings,
|
||||
updateProviderSettings,
|
||||
updateSettings,
|
||||
updateSkillEnabled,
|
||||
updateWebSearchSettings,
|
||||
validateChannel,
|
||||
@@ -402,30 +401,6 @@ describe("webui API helpers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("serializes settings updates as a narrow mutation payload", async () => {
|
||||
await updateSettings(mutationTransport, {
|
||||
modelPreset: "default",
|
||||
model: "openrouter/test",
|
||||
provider: "openrouter",
|
||||
contextWindowTokens: 262144,
|
||||
timezone: "Asia/Shanghai",
|
||||
toolHintMaxLength: 120,
|
||||
});
|
||||
|
||||
expect(requestMutation).toHaveBeenCalledWith(
|
||||
"settings.agent.update",
|
||||
{
|
||||
model_preset: "default",
|
||||
model: "openrouter/test",
|
||||
provider: "openrouter",
|
||||
context_window_tokens: 262144,
|
||||
timezone: "Asia/Shanghai",
|
||||
tool_hint_max_length: 120,
|
||||
},
|
||||
20_000,
|
||||
);
|
||||
});
|
||||
|
||||
it("fetches token usage through the lightweight settings endpoint", async () => {
|
||||
await fetchSettingsUsage("tok");
|
||||
|
||||
|
||||
@@ -2,13 +2,12 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
formatCompactWebUrl,
|
||||
parsePublicHttpUrl,
|
||||
parseSafeActivityHttpUrl,
|
||||
} from "@/components/thread/activity/web-url";
|
||||
|
||||
describe("activity web URLs", () => {
|
||||
it("keeps public HTTP URLs and removes query noise from their label", () => {
|
||||
const url = parsePublicHttpUrl("https://www.example.com/docs/?token=private#section");
|
||||
const url = parseSafeActivityHttpUrl("https://www.example.com/docs/?token=private#section");
|
||||
expect(url).not.toBeNull();
|
||||
expect(formatCompactWebUrl(url!)).toBe("example.com/docs");
|
||||
});
|
||||
@@ -24,9 +23,8 @@ describe("activity web URLs", () => {
|
||||
"http://192.168.1.1",
|
||||
"http://[::1]",
|
||||
"http://[::ffff:127.0.0.1]",
|
||||
"https://user:password@example.com",
|
||||
])("rejects private or credential-bearing target %s", (value) => {
|
||||
expect(parsePublicHttpUrl(value)).toBeNull();
|
||||
])("rejects private target %s", (value) => {
|
||||
expect(parseSafeActivityHttpUrl(value)).toBeNull();
|
||||
});
|
||||
|
||||
it("normalizes credential-bearing public URLs for safe activity display", () => {
|
||||
|
||||
Reference in new issue
Block a user