From 5c03a2e2513d7ac5a69b73e4627d104be729fd85 Mon Sep 17 00:00:00 2001 From: yyh Date: Thu, 15 Jan 2026 16:00:31 +0800 Subject: [PATCH] refactor(skill-editor): extract hooks and utils into separate directories - Extract useFileOperations hook to hooks/use-file-operations.ts - Move tree utilities to utils/tree-utils.ts - Move file utilities to utils/file-utils.ts (renamed from utils.ts) - Remove unnecessary JSDoc comments throughout components - Simplify type.ts to only contain local type definitions - Clean up store/index.ts by removing verbose comments --- .../workflow/skill/editor-tab-item.tsx | 21 +- .../components/workflow/skill/editor-tabs.tsx | 31 +- .../workflow/skill/file-operations-menu.tsx | 321 +----------------- .../workflow/skill/file-tree-context-menu.tsx | 6 - .../workflow/skill/file-tree-node.tsx | 27 +- web/app/components/workflow/skill/files.tsx | 48 +-- .../skill/hooks/use-file-operations.ts | 293 ++++++++++++++++ .../workflow/skill/sidebar-search-add.tsx | 24 +- .../workflow/skill/skill-doc-editor.tsx | 79 +---- .../components/workflow/skill/store/index.ts | 62 +--- web/app/components/workflow/skill/type.ts | 151 -------- .../skill/{utils.ts => utils/file-utils.ts} | 39 ++- .../workflow/skill/utils/tree-utils.ts | 86 +++++ 13 files changed, 448 insertions(+), 740 deletions(-) create mode 100644 web/app/components/workflow/skill/hooks/use-file-operations.ts rename web/app/components/workflow/skill/{utils.ts => utils/file-utils.ts} (63%) create mode 100644 web/app/components/workflow/skill/utils/tree-utils.ts diff --git a/web/app/components/workflow/skill/editor-tab-item.tsx b/web/app/components/workflow/skill/editor-tab-item.tsx index d39b621cf6..b346ec2685 100644 --- a/web/app/components/workflow/skill/editor-tab-item.tsx +++ b/web/app/components/workflow/skill/editor-tab-item.tsx @@ -8,22 +8,7 @@ import { useCallback } from 'react' import { useTranslation } from 'react-i18next' import FileTypeIcon from '@/app/components/base/file-uploader/file-type-icon' import { cn } from '@/utils/classnames' -import { getFileIconType } from './utils' - -/** - * EditorTabItem - Single tab item in the tab bar - * - * Features: - * - Click to activate - * - Close button (shown on hover or when active) - * - Dirty indicator (orange dot) - * - File type icon based on extension - * - * Design specs from Figma: - * - Height: 32px (pb-2 pt-2.5 = 18px content + padding) - * - Font: 13px, medium (500) when active - * - Icon: 16x16 in 20x20 container - */ +import { getFileIconType } from './utils/file-utils' type EditorTabItemProps = { fileId: string @@ -62,16 +47,13 @@ const EditorTabItem: FC = ({ )} onClick={handleClick} > - {/* Icon with dirty indicator */}
- {/* Dirty indicator dot */} {isDirty && ( )}
- {/* File name */} = ({ {name} - {/* Close button */}