From a87f14eccd1f210c14db2900b951461a27480c3c Mon Sep 17 00:00:00 2001 From: shine1i Date: Mon, 2 Feb 2026 14:52:58 +0100 Subject: [PATCH] refactor: remove unused components, mock data, and redundant logic across chat features; streamline settings and runtime handling for better maintainability --- .../frontend/src/features/chat/chat-page.tsx | 36 ++--- .../src/features/chat/chat-settings-sheet.tsx | 37 ++--- .../src/features/chat/chat-top-bar.tsx | 151 ------------------ .../src/features/chat/runtime-provider.tsx | 46 +----- .../src/features/chat/thread-sidebar.tsx | 1 - studio/frontend/src/features/chat/types.ts | 4 - 6 files changed, 30 insertions(+), 245 deletions(-) delete mode 100644 studio/frontend/src/features/chat/chat-top-bar.tsx diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx index cc1fdfbe6a..6de42ed671 100644 --- a/studio/frontend/src/features/chat/chat-page.tsx +++ b/studio/frontend/src/features/chat/chat-page.tsx @@ -18,7 +18,6 @@ import { memo, useCallback, useEffect, - useMemo, useRef, useState, } from "react"; @@ -38,7 +37,6 @@ import { import { ThreadSidebar } from "./thread-sidebar"; import type { ChatView } from "./types"; -// TODO: fetch from API at runtime const LORA_MODELS: ModelOption[] = [ { id: "outputs/llama-3.1-8b-instruct-lora", @@ -75,17 +73,9 @@ const GGUF_MODELS: ModelOption[] = [ }, ]; -type SingleContentProps = { - threadId?: string; -}; - -type CompareContentProps = { - pairId: string; -}; - const SingleContent = memo(function SingleContent({ threadId, -}: SingleContentProps): ReactElement { +}: { threadId?: string }): ReactElement { return (
@@ -97,7 +87,7 @@ const SingleContent = memo(function SingleContent({ const CompareContent = memo(function CompareContent({ pairId, -}: CompareContentProps): ReactElement { +}: { pairId: string }): ReactElement { const handlesRef = useRef>({}); const [baseThreadId, setBaseThreadId] = useState(); const [loraThreadId, setLoraThreadId] = useState(); @@ -123,9 +113,9 @@ const CompareContent = memo(function CompareContent({ return (
-
+
-
+
Base Model @@ -142,8 +132,8 @@ const CompareContent = memo(function CompareContent({
-
- +
+ Fine-tuned (LoRA)
@@ -215,13 +205,10 @@ export function ChatPage(): ReactElement { [], ); - const models = useMemo( - () => - inferenceParams.inferenceEngine === "llama-cpp" - ? GGUF_MODELS - : LORA_MODELS, - [inferenceParams.inferenceEngine], - ); + const models = + inferenceParams.inferenceEngine === "llama-cpp" + ? GGUF_MODELS + : LORA_MODELS; return ( - {/* main chat area */}
- {/* top bar */}
@@ -275,7 +260,6 @@ export function ChatPage(): ReactElement { )}
- {/* inline settings panel on right */} (BUILTIN_PRESETS); const [activePreset, setActivePreset] = useState("Default"); - const set = (key: keyof InferenceParams) => (v: number | string) => - onParamsChange({ ...params, [key]: v }); + function set(key: K) { + return (v: InferenceParams[K]) => onParamsChange({ ...params, [key]: v }); + } function applyPreset(name: string) { const p = presets.find((pr) => pr.name === name); @@ -218,10 +211,9 @@ export function ChatSettingsPanel({ return (