From 4a0973a373a097c5712d086acab87ab5c9c20222 Mon Sep 17 00:00:00 2001
From: Dayuan Jiang <34411969+DayuanJiang@users.noreply.github.com>
Date: Sat, 10 Jan 2026 14:06:17 +0900
Subject: [PATCH] chore: remove dead code and consolidate duplicate types
(#555)
- Delete unused files: lib/ai-config.ts, components/ui/card.tsx, lib/token-counter.ts
- Remove js-tiktoken dependency (only used by deleted token-counter.ts)
- Consolidate ProviderName type: add "ollama" to model-config.ts, import in ai-providers.ts
- Consolidate DiagramOperation type: keep in chat/types.ts, import in utils.ts and hook
---
components/ui/card.tsx | 92 ------------------------------
hooks/use-diagram-tool-handlers.ts | 7 +--
lib/ai-config.ts | 26 ---------
lib/ai-providers.ts | 17 +-----
lib/token-counter.ts | 39 -------------
lib/types/model-config.ts | 7 ++-
lib/utils.ts | 9 +--
package.json | 1 -
8 files changed, 12 insertions(+), 186 deletions(-)
delete mode 100644 components/ui/card.tsx
delete mode 100644 lib/ai-config.ts
delete mode 100644 lib/token-counter.ts
diff --git a/components/ui/card.tsx b/components/ui/card.tsx
deleted file mode 100644
index 99541f3..0000000
--- a/components/ui/card.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import * as React from "react"
-
-import { cn } from "@/lib/utils"
-
-function Card({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardAction({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardContent({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-export {
- Card,
- CardHeader,
- CardFooter,
- CardTitle,
- CardAction,
- CardDescription,
- CardContent,
-}
diff --git a/hooks/use-diagram-tool-handlers.ts b/hooks/use-diagram-tool-handlers.ts
index 0e4c7bb..0636f00 100644
--- a/hooks/use-diagram-tool-handlers.ts
+++ b/hooks/use-diagram-tool-handlers.ts
@@ -1,4 +1,5 @@
import type { MutableRefObject } from "react"
+import type { DiagramOperation } from "@/components/chat/types"
import { isMxCellXmlComplete, wrapWithMxFile } from "@/lib/utils"
const DEBUG = process.env.NODE_ENV === "development"
@@ -29,12 +30,6 @@ type AddToolOutputParams = AddToolOutputSuccess | AddToolOutputError
type AddToolOutputFn = (params: AddToolOutputParams) => void
-interface DiagramOperation {
- operation: "update" | "add" | "delete"
- cell_id: string
- new_xml?: string
-}
-
interface UseDiagramToolHandlersParams {
partialXmlRef: MutableRefObject
editDiagramOriginalXmlRef: MutableRefObject