From f0ba739e4470100895346b495d7c7fa99d0f22cd Mon Sep 17 00:00:00 2001 From: yyh Date: Fri, 6 Feb 2026 14:27:52 +0800 Subject: [PATCH] fix(skill-editor): select only filename stem when renaming files Use setSelectionRange to exclude the file extension from the initial selection, matching the behavior of VS Code and Finder. --- .../workflow/skill/file-tree/tree-edit-input.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/app/components/workflow/skill/file-tree/tree-edit-input.tsx b/web/app/components/workflow/skill/file-tree/tree-edit-input.tsx index 8a5dcb6345..3db59a62cf 100644 --- a/web/app/components/workflow/skill/file-tree/tree-edit-input.tsx +++ b/web/app/components/workflow/skill/file-tree/tree-edit-input.tsx @@ -19,8 +19,16 @@ const TreeEditInput = ({ node }: TreeEditInputProps) => { : t('skillSidebar.fileNamePlaceholder') useEffect(() => { - inputRef.current?.focus() - inputRef.current?.select() + const input = inputRef.current + if (!input) + return + input.focus() + const name = input.value + const dotIndex = isFolder ? -1 : name.lastIndexOf('.') + if (dotIndex > 0) + input.setSelectionRange(0, dotIndex) + else + input.select() }, []) const handleKeyDown = (e: React.KeyboardEvent) => {