refactor: remove remaining dead code

This commit is contained in:
chengyongru
2026-08-23 19:08:00 +08:00
committed by chengyongru
parent 3852956a71
commit 961b1fdd7d
46 changed files with 85 additions and 250 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import type { TFunction } from "i18next";
export type ChannelFieldMessages = {
type ChannelFieldMessages = {
label: string;
placeholder?: string;
help?: string;
+3 -3
View File
@@ -137,7 +137,7 @@ export function CapabilityMentionToken({
return <SessionMentionToken mention={segment.mention} label={segment.text} variant={variant} />;
}
export function SessionMentionToken({
function SessionMentionToken({
mention,
label,
variant,
@@ -172,7 +172,7 @@ export function SessionMentionToken({
);
}
export function CliAppMentionToken({
function CliAppMentionToken({
app,
label,
variant,
@@ -229,7 +229,7 @@ export function CliAppMentionToken({
);
}
export function McpPresetMentionToken({
function McpPresetMentionToken({
preset,
label,
variant,
+2 -2
View File
@@ -151,7 +151,7 @@ export function splitFilePath(path: string): { directory: string; name: string }
};
}
export function fileKindForPath(path: string): FileReferenceKind {
function fileKindForPath(path: string): FileReferenceKind {
const normalized = path.toLowerCase();
const name = normalized.split(/[\\/]/).pop() ?? normalized;
const ext = name.includes(".") ? name.split(".").pop() ?? "" : "";
@@ -193,7 +193,7 @@ export function fileKindForPath(path: string): FileReferenceKind {
}
}
export function FileReferenceIcon({ kind }: { kind: FileReferenceKind }) {
function FileReferenceIcon({ kind }: { kind: FileReferenceKind }) {
if (kind === "python") {
return (
<svg
+2 -2
View File
@@ -967,7 +967,7 @@ interface ReasoningBubbleProps {
hasBodyBelow: boolean;
}
export function ReasoningBubble({
function ReasoningBubble({
text,
streaming,
hasBodyBelow,
@@ -993,7 +993,7 @@ interface TraceGroupProps {
* collapsed because tool traces are supporting evidence, not the answer.
* A single click expands the exact calls when the user wants details.
*/
export function TraceGroup({ message }: TraceGroupProps) {
function TraceGroup({ message }: TraceGroupProps) {
const { t } = useTranslation();
const lines = message.traces ?? [message.content];
const count = lines.length;
@@ -174,7 +174,7 @@ export function ChannelLogo({
);
}
export function channelDisplayName(feature: NanobotFeatureInfo): string {
function channelDisplayName(feature: NanobotFeatureInfo): string {
return channelUiPresentation(feature.name, feature.webui)?.displayName ?? feature.display_name;
}
@@ -112,7 +112,7 @@ export function ChannelSetupLinks({
);
}
export function ChannelOfficialLink({
function ChannelOfficialLink({
feature,
setup,
}: {
@@ -6,7 +6,7 @@ import { Input } from "@/components/ui/input";
import type { ChannelConfigField } from "@/components/settings/channels/catalog";
import { cn } from "@/lib/utils";
export function channelFieldValue(field: ChannelConfigField, values: Record<string, string>): string {
function channelFieldValue(field: ChannelConfigField, values: Record<string, string>): string {
return values[field.key] ?? field.defaultValue ?? field.options?.[0]?.value ?? "";
}
@@ -27,7 +27,7 @@ export type ChannelSetupPresentation = {
presets?: ChannelProviderPreset[];
};
export type ChannelCatalogSetupPresentation = {
type ChannelCatalogSetupPresentation = {
mode?: "webui" | "credentials" | "connect";
command?: string;
docsUrl?: string;
@@ -38,15 +38,15 @@ export type ChannelCatalogSetupPresentation = {
presets?: ChannelProviderPresetDefinition[];
};
export type ChannelFieldPresentation = {
type ChannelFieldPresentation = {
key: string;
};
export type ChannelSetupActionDefinition = Omit<ChannelSetupAction, "label">;
type ChannelSetupActionDefinition = Omit<ChannelSetupAction, "label">;
export type ChannelProviderPresetDefinition = Omit<ChannelProviderPreset, "label">;
export type ChannelSetupAction = {
type ChannelSetupAction = {
id: string;
label: string;
url?: string;
@@ -72,7 +72,7 @@ export type ChannelConfigField = {
options?: ChannelConfigOption[];
};
export type ChannelConfigOption = {
type ChannelConfigOption = {
value: string;
label: string;
};
+1 -1
View File
@@ -14,7 +14,7 @@ export type SettingsSectionKey =
| "runtime"
| "advanced";
export type PendingRestartSection = "runtime" | "browser" | "image";
type PendingRestartSection = "runtime" | "browser" | "image";
export type PendingRestartSections = Record<PendingRestartSection, boolean>;
export type RestartAwarePayload = {
@@ -51,7 +51,7 @@ import type { CliAppInfo, McpPresetInfo, ToolProgressEvent, UIFileEdit, UIMessag
const ACTIVITY_SCROLL_NEAR_BOTTOM_PX = 24;
export { isAgentActivityMember, isReasoningOnlyAssistant };
export { isAgentActivityMember };
interface ActivityCounts {
reasoningSteps: number;
@@ -155,7 +155,7 @@ function FileEditRow({
);
}
export function hasVisibleDiffStats(edit: Pick<FileEditSummary, "added" | "deleted">): boolean {
function hasVisibleDiffStats(edit: Pick<FileEditSummary, "added" | "deleted">): boolean {
return edit.added > 0 || edit.deleted > 0;
}
@@ -3,7 +3,7 @@ import { compactActivityPath, redactActivityText } from "./activity-text";
export type GenericToolStatus = "running" | "done" | "error";
export type ToolFamily = "content-search" | "file-search" | "list" | "read" | "memory" | "generic";
export interface ToolField {
interface ToolField {
key:
| "query"
| "pattern"
@@ -7,7 +7,7 @@ import { displayWebHost, formatCompactWebUrl, parseSafeActivityHttpUrl } from ".
export type WebSearchStatus = "running" | "done" | "error";
export type WebSearchTarget = "web" | "x";
export interface WebSearchSource {
interface WebSearchSource {
title: string;
href: string;
host: string;
@@ -26,13 +26,13 @@ export function userPromptAnchors(messages: UIMessage[]): PromptAnchor[] {
});
}
export function promptLabel(content: string, index: number): string {
function promptLabel(content: string, index: number): string {
const text = content.replace(/\s+/g, " ").trim();
if (!text) return `Prompt ${index + 1}`;
return truncatePreview(text, 80);
}
export function promptPreview(content: string, index: number): string {
function promptPreview(content: string, index: number): string {
const text = compactPreview(content);
if (!text) return `Prompt ${index + 1}`;
return truncatePreview(text, 320);
+1 -1
View File
@@ -33,7 +33,7 @@ const buttonVariants = cva(
},
);
export interface ButtonProps
interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
+1 -1
View File
@@ -3,7 +3,7 @@ import * as React from "react";
import { formControlFocusClassName } from "@/components/ui/form-control";
import { cn } from "@/lib/utils";
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
+1 -1
View File
@@ -3,7 +3,7 @@ import * as React from "react";
import { formControlFocusClassName } from "@/components/ui/form-control";
import { cn } from "@/lib/utils";
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
({ className, ...props }, ref) => {
@@ -12,7 +12,7 @@ export type {
export const MAX_WORKBENCH_PANES = 4;
export const WORKBENCH_LAYOUTS = [
const WORKBENCH_LAYOUTS = [
"columns",
"rows",
"grid",
+5 -5
View File
@@ -9,10 +9,10 @@ import type { WebUIIngressLimits } from "@/lib/types";
* - ``ready`` — ``dataUrl`` available; safe to submit
* - ``error`` — validation / decode failure; chip shows inline error
*/
export type AttachmentStatus = "encoding" | "ready" | "error";
type AttachmentStatus = "encoding" | "ready" | "error";
export type AttachmentKind = "image" | "file";
export interface AttachedAttachment {
interface AttachedAttachment {
id: string;
kind: AttachmentKind;
file: File;
@@ -32,7 +32,7 @@ export interface AttachedAttachment {
export type AttachedImage = AttachedAttachment;
export interface RestoredReadyAttachment {
interface RestoredReadyAttachment {
dataUrl: string;
name?: string;
kind?: AttachmentKind;
@@ -55,8 +55,8 @@ export type AttachmentError =
| "io"; // file read failed at the browser layer
export const MAX_ATTACHMENTS_PER_MESSAGE = 4;
export const MAX_ATTACHMENT_BYTES = 6 * 1024 * 1024;
export const MAX_TOTAL_ATTACHMENT_BYTES = 24 * 1024 * 1024;
const MAX_ATTACHMENT_BYTES = 6 * 1024 * 1024;
const MAX_TOTAL_ATTACHMENT_BYTES = 24 * 1024 * 1024;
/** MIME whitelist — mirrors the server's and the ``<input accept>`` attr. */
const ACCEPTED_IMAGE_MIMES: ReadonlySet<string> = new Set([
+2 -2
View File
@@ -11,7 +11,7 @@ import { acceptedAttachmentKind } from "@/hooks/useAttachedImages";
* - Plain text pasted alongside attachments is *not* consumed by this helper,
* so the caller can still let the textarea receive it naturally.
*/
export function extractImageFilesFromPaste(
function extractImageFilesFromPaste(
event: ClipboardEvent | React.ClipboardEvent,
): File[] {
const clipboard = (event as ClipboardEvent).clipboardData
@@ -27,7 +27,7 @@ export function extractImageFilesFromPaste(
}
/** Extract dropped attachment files, mirroring ``extractImageFilesFromPaste``. */
export function extractImageFilesFromDrop(
function extractImageFilesFromDrop(
event: DragEvent | React.DragEvent,
): File[] {
const dt = (event as DragEvent).dataTransfer
+2 -2
View File
@@ -5,7 +5,7 @@ import { normalizeWorkbenchState } from "@/components/workbench/workbench-model"
import { fetchSidebarState } from "@/lib/api";
import type { ChatSummary, SidebarStatePayload } from "@/lib/types";
export const DEFAULT_SIDEBAR_STATE: SidebarStatePayload = {
const DEFAULT_SIDEBAR_STATE: SidebarStatePayload = {
schema_version: 1,
pinned_keys: [],
archived_keys: [],
@@ -74,7 +74,7 @@ function boolMap(value: unknown): Record<string, boolean> {
return out;
}
export function normalizeSidebarState(raw: unknown): SidebarStatePayload {
function normalizeSidebarState(raw: unknown): SidebarStatePayload {
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
return { ...DEFAULT_SIDEBAR_STATE, view: { ...DEFAULT_SIDEBAR_STATE.view } };
}
+1 -1
View File
@@ -51,7 +51,7 @@ export function normalizeLocale(
return baseMatch?.code ?? defaultLocale;
}
export function readStoredLocale(): SupportedLocale | null {
function readStoredLocale(): SupportedLocale | null {
if (typeof window === "undefined") return null;
try {
const raw = window.localStorage.getItem(LOCALE_STORAGE_KEY);
+1 -3
View File
@@ -10,7 +10,6 @@ import {
applyDocumentLocale,
defaultLocale,
fallbackLocale,
LOCALE_STORAGE_KEY,
normalizeLocale,
persistLocale,
resolveInitialLocale,
@@ -47,7 +46,7 @@ export function currentLocale(): SupportedLocale {
return normalizeLocale(i18n.resolvedLanguage ?? i18n.language ?? defaultLocale);
}
export async function loadLocaleResources(
async function loadLocaleResources(
locale: SupportedLocale,
): Promise<LocaleResource> {
const existing = resourcePromises.get(locale);
@@ -131,5 +130,4 @@ function syncLocaleSideEffects(language: string) {
persistLocale(locale);
}
export { LOCALE_STORAGE_KEY };
export default i18n;
+1 -1
View File
@@ -3,7 +3,7 @@ export type AnsiSegment = {
style?: AnsiStyle;
};
export type AnsiStyle = {
type AnsiStyle = {
backgroundColor?: string;
color?: string;
fontStyle?: "italic";
+1 -1
View File
@@ -1,4 +1,4 @@
export const DEFAULT_HTTP_TIMEOUT_MS = 20_000;
const DEFAULT_HTTP_TIMEOUT_MS = 20_000;
export async function fetchWithTimeout(
input: RequestInfo | URL,
+1 -1
View File
@@ -11,7 +11,7 @@ import {
type EncodeResponse,
} from "@/workers/imageEncode.worker";
export type { EncodeResponse, EncodeSuccess, EncodeFailure } from "@/workers/imageEncode.worker";
export type { EncodeResponse, EncodeFailure } from "@/workers/imageEncode.worker";
type Pending = {
resolve: (r: EncodeResponse) => void;
+1 -1
View File
@@ -113,7 +113,7 @@ interface PendingWebUIRequest extends PendingRequest<unknown> {
serializedFrame: string;
}
export class WebUIMutationError extends Error {
class WebUIMutationError extends Error {
status: number;
constructor(status: number, message: string) {
+2 -2
View File
@@ -124,7 +124,7 @@ export function logoFallbackUrls(logoUrl: string | null | undefined): string[] {
return urls;
}
export const PROVIDER_BRAND_ALIASES: Record<string, string> = {
const PROVIDER_BRAND_ALIASES: Record<string, string> = {
brave_search: "brave",
byteplus_coding_plan: "byteplus",
mimo: "xiaomi_mimo",
@@ -137,7 +137,7 @@ export const PROVIDER_BRAND_ALIASES: Record<string, string> = {
volcengine_coding_plan: "volcengine",
};
export const PROVIDER_LABEL_ALIASES: Record<string, string> = {
const PROVIDER_LABEL_ALIASES: Record<string, string> = {
brave_search: "Brave Search",
byteplus_coding_plan: "BytePlus",
minimaxAnthropic: "MiniMax",
+3 -3
View File
@@ -10,7 +10,7 @@ export interface RuntimeHost {
exportDiagnostics?: () => Promise<string>;
}
export interface HostRuntimeInfo {
interface HostRuntimeInfo {
surface: "native";
app_version: string;
engine_status: "starting" | "ready" | "restarting" | "stopped" | "crashed";
@@ -23,7 +23,7 @@ export interface HostRuntimeInfo {
engine_transport?: "unix_socket";
}
export interface NanobotHostApi {
interface NanobotHostApi {
getRuntimeInfo?(): Promise<HostRuntimeInfo>;
restartEngine?(): Promise<void>;
pickFolder?(): Promise<string | null>;
@@ -40,7 +40,7 @@ export interface NanobotHostApi {
): () => void;
}
export type HostSocketEvent =
type HostSocketEvent =
| { id: string; type: "open" }
| { data: string; id: string; type: "message" }
| { id: string; message: string; type: "error" }
+27 -27
View File
@@ -1,8 +1,8 @@
export type Role = "user" | "assistant" | "tool" | "system";
type Role = "user" | "assistant" | "tool" | "system";
/** "trace" rows are intermediate agent breadcrumbs (tool-call hints,
* progress pings) that should not be rendered as conversational replies. */
export type MessageKind = "message" | "trace";
type MessageKind = "message" | "trace";
export type UITurnPhase = "user" | "reasoning" | "activity" | "answer" | "complete";
export type MessageDeliveryStatus = "sending" | "accepted" | "failed";
@@ -37,7 +37,7 @@ export interface UIMediaAttachment {
name?: string;
}
export interface UIMessageSource { kind: "cron" | "local_trigger" | "trigger" | string; label?: string; }
interface UIMessageSource { kind: "cron" | "local_trigger" | "trigger" | string; label?: string; }
export interface TurnUsage {
prompt_tokens?: number;
@@ -144,7 +144,7 @@ export interface SessionHandle {
name: string;
}
export interface UISessionMessage {
interface UISessionMessage {
message_id: string;
session: SessionHandle;
}
@@ -226,14 +226,14 @@ export interface SkillSummary {
unavailable_reason?: string;
}
export interface SkillRequirements {
interface SkillRequirements {
bins: string[];
env: string[];
missing_bins: string[];
missing_env: string[];
}
export interface SkillInstallOption {
interface SkillInstallOption {
id: string;
kind: string;
label: string;
@@ -303,7 +303,7 @@ export interface SkillInstallPayload extends SkillsPayload {
}
/** Structured UI blob on ``progress`` WS frames; channels may add more ``kind`` values later. */
export interface AgentUIBlob {
interface AgentUIBlob {
kind: string;
data?: unknown;
}
@@ -455,16 +455,16 @@ export interface BootstrapResponse {
runtime_capabilities?: RuntimeCapabilities;
}
export interface WebUITransportLimits {
interface WebUITransportLimits {
max_frame_bytes: number;
envelope_reserve_bytes: number;
}
export interface WebUIMessageLimits {
interface WebUIMessageLimits {
max_text_bytes: number;
}
export interface WebUIAttachmentLimits {
interface WebUIAttachmentLimits {
max_count: number;
max_file_bytes: number;
max_total_bytes: number;
@@ -477,8 +477,8 @@ export interface WebUIIngressLimits {
}
export type RuntimeSurface = "browser" | "native";
export type RestartBehavior = "none" | "nextTurn" | "engineRestart" | "appRestart";
export type SettingsApplyStatus =
type RestartBehavior = "none" | "nextTurn" | "engineRestart" | "appRestart";
type SettingsApplyStatus =
| "idle"
| "pending"
| "applying"
@@ -492,7 +492,7 @@ export interface RuntimeCapabilities {
can_export_diagnostics: boolean;
}
export interface ProviderModelInfo {
interface ProviderModelInfo {
id: string;
label?: string | null;
description?: string | null;
@@ -783,12 +783,12 @@ export interface ApiServicePayload {
last_action?: "started" | "stopped" | string;
}
export interface AppPackageRef {
interface AppPackageRef {
manager: string;
name?: string;
}
export interface AppCapability {
interface AppCapability {
type: "cli" | "mcp" | "skill" | string;
entry_point?: string;
package?: AppPackageRef;
@@ -806,20 +806,20 @@ export interface AppCapability {
}>;
}
export interface AppPlan {
interface AppPlan {
supported: boolean;
strategy?: string;
managed_paths?: string[];
verification?: string[];
}
export interface AppTrust {
interface AppTrust {
registry: string;
level: string;
review_status: string;
}
export interface AppManifest {
interface AppManifest {
schema: "agent-app.v1" | string;
id: string;
display_name: string;
@@ -935,7 +935,7 @@ export interface NanobotFeaturesPayload {
};
}
export type ChannelSetupStatus =
type ChannelSetupStatus =
| "connected"
| "configured"
| "needs_setup"
@@ -943,9 +943,9 @@ export type ChannelSetupStatus =
| "unsupported"
| string;
export type ChannelValidationCheckStatus = "pass" | "warn" | "fail" | "skipped" | string;
type ChannelValidationCheckStatus = "pass" | "warn" | "fail" | "skipped" | string;
export interface ChannelValidationCheck {
interface ChannelValidationCheck {
id: string;
label: string;
status: ChannelValidationCheckStatus;
@@ -953,7 +953,7 @@ export interface ChannelValidationCheck {
action_url?: string;
}
export interface ChannelIdentity {
interface ChannelIdentity {
name?: string;
workspace?: string;
account?: string;
@@ -993,7 +993,7 @@ export interface PairingPayload {
};
}
export interface McpPresetField {
interface McpPresetField {
name: string;
label: string;
secret: boolean;
@@ -1033,7 +1033,7 @@ export interface McpPresetInfo {
manifest?: AppManifest;
}
export type McpOAuthFlowStatus =
type McpOAuthFlowStatus =
| "starting"
| "authorization_required"
| "connecting"
@@ -1089,7 +1089,7 @@ export interface McpPresetsPayload {
};
}
export type ChannelConnectStatus = "pending" | "succeeded" | "expired" | "cancelled" | "failed";
type ChannelConnectStatus = "pending" | "succeeded" | "expired" | "cancelled" | "failed";
export interface ChannelConnectPayload {
session_id: string;
@@ -1234,7 +1234,7 @@ export type ConnectionStatus =
| "closed"
| "error";
export interface InboundTurnMetadata {
interface InboundTurnMetadata {
turn_id?: string;
turn_phase?: UITurnPhase;
turn_seq?: number;
@@ -1430,7 +1430,7 @@ export interface OutboundMcpPresetMention {
}
/** Response shape for ``GET .../webui-thread`` (server-built transcript replay). */
export interface WebuiThreadPagePayload {
interface WebuiThreadPagePayload {
before_cursor?: string | null;
has_more_before?: boolean;
loaded_message_count?: number;
+1 -1
View File
@@ -23,7 +23,7 @@ export type EncodeInput = {
file: File;
};
export type EncodeSuccess = {
type EncodeSuccess = {
id: string;
ok: true;
dataUrl: string;