refactor: remove unused runtime and WebUI helpers (#5999)

* refactor: remove unused runtime and WebUI helpers

* fix: preserve exported agent helper methods
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-02 01:41:05 +08:00
1 parent d3d70f2065
commit 6ecb74aea9
17 files changed
+26 -143

No files matched your search

@@ -688,7 +688,7 @@ export function PaneWorkbench({
className={cn(
"thread-workspace relative flex h-full min-h-0 flex-col overflow-hidden bg-background",
chrome && displayedPanes.length > 1
&& "[--thread-header-position:relative] [--thread-prompt-inset:1rem]",
&& "[--thread-header-position:relative]",
)}
>
<TooltipProvider>
-7
View File
@@ -37,9 +37,7 @@
--session-handle-lightness: 0.5;
--session-handle-chroma: 0.12;
--temporary-control-active: #ef8e30;
--temporary-accent: 24 95% 53%;
--temporary-foreground: 17 88% 32%;
--temporary-border: 17 88% 40%;
--radius: 0.4375rem;
/* Shared shape scale: marks, compact content, controls, and progressively larger surfaces. */
--radius-mark: 0.25rem;
@@ -91,9 +89,7 @@
--session-handle-lightness: 0.75;
--session-handle-chroma: 0.11;
--temporary-control-active: #ef8e30;
--temporary-accent: 24 95% 53%;
--temporary-foreground: 32 98% 73%;
--temporary-border: 27 96% 61%;
--sidebar: var(--card);
--sidebar-foreground: 0 0% 98%;
--sidebar-content: 240 3% 84%;
@@ -637,13 +633,11 @@
/* Split content leaves no margin for floating conversation controls. */
.thread-workspace:has([data-file-preview-panel]) > * {
--thread-header-position: relative;
--thread-prompt-inset: 1rem;
}
/* Keep room for the 49.5rem message column and controls in the side margin. */
@container thread-workspace (max-width: 72rem) {
.thread-workspace > * {
--thread-header-position: relative;
--thread-prompt-inset: 1rem;
}
}
@@ -1127,7 +1121,6 @@
desktop, 4 columns / 16px gutter on mobile. Rows share the same tracks. */
@layer components {
.settings-grid {
--settings-baseline: 4px;
--settings-columns: 4;
--settings-gutter: 16px;
--settings-margin: 16px;
-13
View File
@@ -1,7 +1,6 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { useClient } from "@/providers/ClientProvider";
import i18n from "@/i18n";
import {
ApiError,
deleteSession as apiDeleteSession,
@@ -10,7 +9,6 @@ import {
listSessions,
} from "@/lib/api";
import { hasPendingAgentActivity } from "@/lib/activity-timeline";
import { deriveTitle } from "@/lib/format";
import { projectThreadEvents } from "@/lib/thread-event-projection";
import { webuiThreadCache } from "@/lib/webui-thread-cache";
import { readReloadSessions, writeReloadCache } from "@/lib/reload-cache";
@@ -707,14 +705,3 @@ export function useSessionHistory(key: string | null): {
activeTurnId: state.activeTurnId,
};
}
/** Produce a compact display title for a session. */
export function sessionTitle(
session: ChatSummary,
firstUserMessage?: string,
): string {
return deriveTitle(
session.title || firstUserMessage || session.preview,
i18n.t("chat.newChat"),
);
}
-7
View File
@@ -1088,13 +1088,6 @@ export async function fetchSidebarState(
);
}
export async function updateSidebarState(
transport: WebUIMutationTransport,
state: SidebarStatePayload,
): Promise<SidebarStatePayload> {
return mutation<SidebarStatePayload>(transport, "sidebar.update", { state });
}
function modelGenerationSettingsPayload(
configuration: Pick<
ModelConfigurationCreate,
+1 -9
View File
@@ -52,7 +52,6 @@ import {
pollChannelConnect,
startChannelConnect,
updateAutomation,
updateSidebarState,
updateImageGenerationSettings,
updateModelCallOrder,
updateModelConfiguration,
@@ -1158,7 +1157,7 @@ describe("webui API helpers", () => {
);
});
it("reads and writes persisted sidebar state", async () => {
it("reads persisted sidebar state", async () => {
const state = {
schema_version: 1,
pinned_keys: ["websocket:chat-1"],
@@ -1189,13 +1188,6 @@ describe("webui API helpers", () => {
headers: { Authorization: "Bearer tok" },
}),
);
await updateSidebarState(mutationTransport, state);
expect(requestMutation).toHaveBeenCalledWith(
"sidebar.update",
{ state },
20_000,
);
});
it("fetches workspace project state", async () => {
+1 -23
View File
@@ -2,7 +2,7 @@ import { act, renderHook, waitFor } from "@testing-library/react";
import type { ReactNode } from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { sessionTitle, useSessionHistory, useSessions } from "@/hooks/useSessions";
import { useSessionHistory, useSessions } from "@/hooks/useSessions";
import * as api from "@/lib/api";
import { webuiThreadCache } from "@/lib/webui-thread-cache";
import { activateReloadCache, clearReloadCache, writeReloadCache } from "@/lib/reload-cache";
@@ -130,28 +130,6 @@ describe("useSessions", () => {
webuiThreadCache.clear();
});
it("does not use low-information greetings as fallback session titles", () => {
expect(sessionTitle({
key: "websocket:chat-hi",
channel: "websocket",
chatId: "chat-hi",
createdAt: "2026-04-16T10:00:00Z",
updatedAt: "2026-04-16T10:00:00Z",
title: "",
preview: "hi",
})).toBe("New topic");
expect(sessionTitle({
key: "websocket:chat-work",
channel: "websocket",
chatId: "chat-work",
createdAt: "2026-04-16T10:00:00Z",
updatedAt: "2026-04-16T10:00:00Z",
title: "",
preview: "帮我优化 WebUI 性能",
})).toBe("帮我优化 WebUI 性能");
});
it("removes a session from the local list after delete succeeds", async () => {
vi.mocked(api.listSessions).mockResolvedValue([
{