diff --git a/web/features/skills/__tests__/detail-page.spec.tsx b/web/features/skills/__tests__/detail-page.spec.tsx index 232d4576130..e235714508f 100644 --- a/web/features/skills/__tests__/detail-page.spec.tsx +++ b/web/features/skills/__tests__/detail-page.spec.tsx @@ -603,17 +603,16 @@ describe('SkillDetailPage', () => { const sidebar = await screen.findByTestId('skill-detail-sidebar') const header = screen.getByTestId('skill-detail-sidebar-header') - expect(sidebar).toHaveClass('w-[248px]', 'bg-background-body', 'p-1') - expect(sidebar.firstElementChild).toHaveClass('rounded-lg', 'bg-background-default') - expect(header).toHaveClass('h-12', 'py-2', 'pr-2', 'pl-1') - expect(header.querySelector('.i-ri-arrow-left-s-line')).toBeInTheDocument() - expect(header.querySelector('.i-custom-vender-main-nav-app-home')).toBeInTheDocument() - expect(header).toHaveTextContent('/SKILLS') + expect(sidebar).toHaveClass('m-1', 'w-60', 'rounded-lg', 'bg-background-default') + expect(header).toHaveClass('h-12', 'gap-2', 'px-3') + expect(header.querySelector('.i-ri-arrow-left-line')).toBeInTheDocument() + expect(header.querySelector('.i-ri-box-3-line')).toBeInTheDocument() + expect(header).toHaveTextContent('SKILLS') expect( screen.getByRole('button', { name: 'skill.skillManagement.detail.searchFiles', }), - ).toHaveClass('size-8', 'rounded-[10px]') + ).toHaveClass('size-6', 'rounded-md') }) it('opens the inline tag selector with workspace tag options', async () => { diff --git a/web/features/skills/detail/file-editor.tsx b/web/features/skills/detail/file-editor.tsx index 549cd207c19..dd5697e2329 100644 --- a/web/features/skills/detail/file-editor.tsx +++ b/web/features/skills/detail/file-editor.tsx @@ -159,6 +159,7 @@ export function FileEditor({ const pendingPublishAfterSaveRef = useRef(false) const metadataKeyInputRef = useRef(null) const pendingDisplayNameRenameRef = useRef(false) + const displayNameDraftRef = useRef(displayNameDraft) const liveBodyTextareaRef = useRef(null) const liveBodyEditorRef = useRef(null) const sourceTextareaRef = useRef(null) @@ -241,6 +242,7 @@ export function FileEditor({ }, [referencePicker?.currentDirectory, referenceQuery, referenceTargets]) useEffect(() => { + displayNameDraftRef.current = markdownContent.displayName setDisplayNameDraft(markdownContent.displayName) }, [markdownContent.displayName]) @@ -845,17 +847,17 @@ export function FileEditor({ }) } - const trimmedMetadataKey = metadataKey.trim() - const canAddMetadata = - isSkillManifestFile && - isEditableMetadataKey(trimmedMetadataKey) && - !isProtectedMarkdownMetadataKey(trimmedMetadataKey) - - const handleAddMetadata = () => { - if (!isSkillManifestFile || !canAddMetadata) return + const handleAddMetadata = (keyOverride?: string, valueOverride?: string) => { + const nextKey = (keyOverride ?? metadataKey).trim() + if ( + !isSkillManifestFile || + !isEditableMetadataKey(nextKey) || + isProtectedMarkdownMetadataKey(nextKey) + ) + return updateDraftContent( - addMarkdownMetadata(draftContentRef.current, trimmedMetadataKey, metadataValue), + addMarkdownMetadata(draftContentRef.current, nextKey, valueOverride ?? metadataValue), ) setMetadataKey('') setMetadataValue('') @@ -863,10 +865,11 @@ export function FileEditor({ } const handleDisplayNameCommit = () => { - if (!isSkillManifestFile || readonly || displayNameDraft === markdownContent.displayName) return + const nextDisplayName = displayNameDraftRef.current + if (!isSkillManifestFile || readonly || nextDisplayName === markdownContent.displayName) return pendingDisplayNameRenameRef.current = true - updateDraftContent(setMarkdownDisplayName(draftContentRef.current, displayNameDraft)) + updateDraftContent(setMarkdownDisplayName(draftContentRef.current, nextDisplayName)) } const handleRemoveMetadata = (key: string) => { @@ -1043,7 +1046,14 @@ export function FileEditor({ valuePlaceholder={detail?.display_name ?? ''} readOnly={readonly} onBlurCapture={handleDisplayNameCommit} - onValueChange={readonly ? undefined : setDisplayNameDraft} + onValueChange={ + readonly + ? undefined + : (nextDisplayName) => { + displayNameDraftRef.current = nextDisplayName + setDisplayNameDraft(nextDisplayName) + } + } /> )} {markdownContent.metadata.map((entry) => { @@ -1111,6 +1121,10 @@ export function FileEditor({ if (event.key === 'Enter') { event.preventDefault() event.stopPropagation() + handleAddMetadata( + metadataKeyInputRef.current?.value, + event.currentTarget.value, + ) } }} onKeyUp={(event) => { @@ -1118,7 +1132,10 @@ export function FileEditor({ event.preventDefault() event.stopPropagation() - handleAddMetadata() + handleAddMetadata( + metadataKeyInputRef.current?.value, + event.currentTarget.value, + ) }} /> diff --git a/web/features/skills/detail/file-tree.tsx b/web/features/skills/detail/file-tree.tsx index 9a1d86f9003..e00c3be98f2 100644 --- a/web/features/skills/detail/file-tree.tsx +++ b/web/features/skills/detail/file-tree.tsx @@ -47,8 +47,6 @@ import { matchesKeyboardEvent, useHotkey } from '@tanstack/react-hotkeys' import { useMutation, useQueryClient } from '@tanstack/react-query' import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import SidebarLeftArrowIcon from '@/app/components/base/icons/src/vender/SidebarLeftArrowIcon' -import { DetailSidebarToggleButton } from '@/app/components/detail-sidebar/toggle-button' import Link from '@/next/link' import { consoleQuery } from '@/service/client' import { fetchSkillFileBlob, uploadSkillFile } from '../client' @@ -906,7 +904,7 @@ export function FileTree({ if (collapsed) { return ( -