From 71b25175a6fb7ed19448b68ba5523a33f9f4c583 Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Mon, 23 Nov 2026 01:33:26 +0900 Subject: [PATCH] chore: remove unused site files and conversation copy interfaces --- knip.jsonc | 7 -- src/chat/core/conversation-copy.ts | 23 ------ src/components/FeatureGrid.tsx | 32 --------- src/contexts/AdsContext.tsx | 7 -- src/hooks/useAdPreference.ts | 43 ------------ src/hooks/useInlineEdit.ts | 109 ----------------------------- src/stores/userSettings.ts | 17 ----- 7 files changed, 238 deletions(-) delete mode 100644 src/components/FeatureGrid.tsx delete mode 100644 src/contexts/AdsContext.tsx delete mode 100644 src/hooks/useAdPreference.ts delete mode 100644 src/hooks/useInlineEdit.ts delete mode 100644 src/stores/userSettings.ts diff --git a/knip.jsonc b/knip.jsonc index 58875efff..c377dd366 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -36,7 +36,6 @@ "src/components/BottomCTA.tsx", "src/components/DocFeedbackContext.tsx", "src/components/DocsCalloutNewsletter.tsx", - "src/components/FeatureGrid.tsx", "src/components/FrameworkIconTabs.tsx", "src/components/Gam.tsx", "src/components/LandingCommunitySection.tsx", @@ -97,11 +96,7 @@ "src/components/landing/codeExamples.ts", "src/components/npm-stats/index.ts", "src/components/shop/ShopDropCard.tsx", - "src/components/shop/ShopHero3D.tsx", // Removed by PR #1541 "src/components/shop/ShopStrip.tsx", - "src/contexts/AdsContext.tsx", - "src/hooks/useAdPreference.ts", - "src/hooks/useInlineEdit.ts", "src/hooks/useQueryGGPPPDiscount.ts", "src/libraries/cli.tsx", "src/libraries/config.tsx", @@ -125,7 +120,6 @@ "src/server/blog.ts", "src/server/runtime/ejs-compat.server.ts", "src/server/sponsors.ts", - "src/stores/userSettings.ts", "src/utils/auth.client.ts", "src/utils/cookies.server.ts", "src/utils/docFeedback.client.ts", @@ -145,7 +139,6 @@ "encoding-sniffer", "gray-matter", "iconv-lite", - "maath", // Removed by PR #1541 "parse5-parser-stream", "remove-markdown", "source-map-explorer", diff --git a/src/chat/core/conversation-copy.ts b/src/chat/core/conversation-copy.ts index c1b93e1c1..dfcecf548 100644 --- a/src/chat/core/conversation-copy.ts +++ b/src/chat/core/conversation-copy.ts @@ -111,29 +111,6 @@ export type BranchRecord = | BranchEvidenceRecord | BranchRetryRecord | BranchActionEvidenceRecord -export interface ConversationSourceRef { - workspaceId: string - botId: string - conversationId?: string - messageId: string - toolCallId?: string - resultId?: string - digest: string -} -export interface BranchProvenance { - operationId: string - sourceBotId: string - sourceConversationId: string - sourceEpoch: string - sourceRevision: number - sourceMessageId: string | null - sourceMessageDigest: string | null - sourceMessagePosition?: 'before' - prefixDigest: string - copiedAt: number - copySchemaVersion: 1 | 2 - kind: CopyKind -} export function canonicalCopyJson(value: unknown): string { if (value === null || typeof value !== 'object') return JSON.stringify(value) ?? 'null' diff --git a/src/components/FeatureGrid.tsx b/src/components/FeatureGrid.tsx deleted file mode 100644 index d27ae18eb..000000000 --- a/src/components/FeatureGrid.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import * as React from 'react' -import { CheckCircleIcon } from '@phosphor-icons/react' - -type FeatureGridProps = { - title?: string - items: React.ReactNode[] - gridClassName?: string -} - -export function FeatureGrid({ title, items, gridClassName }: FeatureGridProps) { - return ( -
- {title ? ( -
-

{title}

-
- ) : null} -
- {items.map((d, i) => ( - - {d} - - ))} -
-
- ) -} diff --git a/src/contexts/AdsContext.tsx b/src/contexts/AdsContext.tsx deleted file mode 100644 index 7617f16a2..000000000 --- a/src/contexts/AdsContext.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import * as React from 'react' -import { useAdsPreference } from '~/stores/userSettings' - -export function AdGate({ children }: { children: React.ReactNode }) { - const { adsEnabled } = useAdsPreference() - return adsEnabled ? <>{children} : null -} diff --git a/src/hooks/useAdPreference.ts b/src/hooks/useAdPreference.ts deleted file mode 100644 index e5fba487e..000000000 --- a/src/hooks/useAdPreference.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { useCurrentUserQuery } from './useCurrentUser' -import { useCapabilities } from './useCapabilities' -import { hasCapability } from '~/db/types' -import * as React from 'react' - -const STORAGE_KEY = 'tanstack-ads-preference' - -function getStoredPreference(): boolean | null { - if (typeof window === 'undefined') return null - const stored = localStorage.getItem(STORAGE_KEY) - return stored === null ? null : stored === 'true' -} - -// Legacy hook for backward compatibility - now uses current user query -export function useAdsPreference() { - const userQuery = useCurrentUserQuery() - const capabilities = useCapabilities() - const [storedPreference] = React.useState(() => getStoredPreference()) - - let adsEnabled: boolean - - if (userQuery.isLoading || !userQuery.data) { - adsEnabled = storedPreference ?? true - } else { - const user = userQuery.data - const adsDisabled = user.adsDisabled ?? false - const canDisableAds = hasCapability(capabilities, 'disableAds') - adsEnabled = !canDisableAds || !adsDisabled - } - - // Save to localStorage when we have resolved data - React.useEffect(() => { - if ( - !userQuery.isLoading && - userQuery.data && - typeof window !== 'undefined' - ) { - localStorage.setItem(STORAGE_KEY, String(adsEnabled)) - } - }, [userQuery.isLoading, userQuery.data, adsEnabled]) - - return { adsEnabled } -} diff --git a/src/hooks/useInlineEdit.ts b/src/hooks/useInlineEdit.ts deleted file mode 100644 index 83a815be5..000000000 --- a/src/hooks/useInlineEdit.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { useState, useCallback } from 'react' - -type UseInlineEditOptions = { - /** Extract initial edit state from the item being edited */ - getInitialState: (item: TItem) => TEditState - /** Get empty state (for when nothing is being edited) */ - getEmptyState: () => TEditState - /** Function to save the edited state */ - saveFn: (itemId: string, state: TEditState) => Promise - /** Extract ID from item */ - getId: (item: TItem) => string - /** Label for error messages */ - itemLabel?: string - /** Callback on error */ - onError?: (error: Error) => void -} - -/** - * Hook for inline edit/save/cancel state management. - * Handles tracking which item is being edited, the edit state, and save/cancel actions. - * - * @example - * const { - * editingId, - * editState, - * isEditing, - * startEdit, - * cancelEdit, - * save, - * updateField, - * } = useInlineEdit({ - * getInitialState: (role) => ({ - * name: role.name, - * description: role.description || '', - * capabilities: role.capabilities, - * }), - * getEmptyState: () => ({ name: '', description: '', capabilities: [] }), - * saveFn: async (id, state) => updateRole.mutateAsync({ roleId: id, ...state }), - * getId: (role) => role._id, - * }) - */ -export function useInlineEdit< - TItem, - TEditState extends Record, ->(options: UseInlineEditOptions) { - const [editingId, setEditingId] = useState(null) - const [editState, setEditState] = useState( - options.getEmptyState(), - ) - const [isSaving, setIsSaving] = useState(false) - - const startEdit = useCallback( - (item: TItem) => { - setEditingId(options.getId(item)) - setEditState(options.getInitialState(item)) - }, - [options], - ) - - const cancelEdit = useCallback(() => { - setEditingId(null) - setEditState(options.getEmptyState()) - }, [options]) - - const save = useCallback(async () => { - if (!editingId) return - - setIsSaving(true) - try { - await options.saveFn(editingId, editState) - cancelEdit() - } catch (err) { - const error = err instanceof Error ? err : new Error('Unknown error') - const label = options.itemLabel || 'item' - console.error(`Failed to save ${label}:`, error) - if (options.onError) { - options.onError(error) - } else { - alert(`Failed to save ${label}: ${error.message}`) - } - } finally { - setIsSaving(false) - } - }, [editingId, editState, options, cancelEdit]) - - const updateField = useCallback( - (field: K, value: TEditState[K]) => { - setEditState((prev) => ({ ...prev, [field]: value })) - }, - [], - ) - - const isEditing = useCallback( - (item: TItem) => editingId === options.getId(item), - [editingId, options], - ) - - return { - editingId, - editState, - isSaving, - isEditing, - startEdit, - cancelEdit, - save, - updateField, - setEditState, - } -} diff --git a/src/stores/userSettings.ts b/src/stores/userSettings.ts deleted file mode 100644 index dd39d702c..000000000 --- a/src/stores/userSettings.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { create } from 'zustand' - -export { useAdsPreference } from '~/hooks/useAdPreference' - -export type UserSettings = Record - -type UserSettingsState = { - settings: UserSettings - hasHydrated: boolean - setHasHydrated: (value: boolean) => void -} - -export const useUserSettingsStore = create()((set) => ({ - settings: {}, - hasHydrated: true, - setHasHydrated: (value) => set({ hasHydrated: value }), -}))