Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat(agent): preview PDFs and note truncated text in the file preview dialog (#45045)
yyha14f826cda45
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsxindex 4361ac0a0e1..e6a5b36e6c2 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsx@@ -49,6 +49,9 @@ const mocks = vi.hoisted(() => ({})),previewQueryOptions: vi.fn((_options: ConfigFileQueryOptionsInput) => ({})),downloadQueryOptions: vi.fn((_options: ConfigFileQueryOptionsInput) => ({})),+ downloadFile: vi.fn(async (input: ConfigFileQueryOptionsInput['input']) => ({+ url: `https://example.com/${input.params.name}`,+ })),downloadBlob: vi.fn(),downloadUrl: vi.fn(),fileUploadConfig: {@@ -60,6 +63,11 @@ const mocks = vi.hoisted(() => ({},}))+vi.mock('@/app/components/base/file-uploader/pdf-highlighter-adapter', () => ({+ PdfLoader: ({ url }: { url: string }) => <div data-testid="pdf-loader" data-url={url} />,+ PdfHighlighter: () => null,+}))+vi.mock('@/utils/download', () => ({downloadBlob: mocks.downloadBlob,downloadUrl: mocks.downloadUrl,@@ -168,6 +176,9 @@ vi.mock('@/service/console', async (importOriginal) => {'files.upload.post': mocks.uploadFileMutationFn,'agent.byAgentId.config.files.batch.post': mocks.commitFileMutationFn,'apps.byAppId.agent.config.files.batch.post': mocks.commitFileMutationFn,+ 'agent.byAgentId.config.files.byName.download.get': mocks.downloadFile,+ 'apps.byAppId.agent.config.files.byName.download.get': mocks.downloadFile,+ 'trialApps.byAppId.agent.config.files.byName.download.get': mocks.downloadFile,}),}})@@ -314,6 +325,94 @@ describe('AgentFiles', () => {expect(within(dialog).getAllByText('available.pdf').length).toBeGreaterThan(0)})+ it('should preview PDFs from the download URL without loading the text preview', async () => {+ const user = userEvent.setup()+ const previewQueryFn = vi.fn(async () => ({+ name: 'guide.pdf',+ binary: true,+ truncated: false,+ text: null,+ }))+ mocks.previewQueryOptions.mockImplementation(() => ({ queryFn: previewQueryFn }))+ renderAgentFiles({+ initialDraft: createInitialDraft({+ files: [+ {+ id: 'guide.pdf',+ name: 'guide.pdf',+ icon: 'pdf',+ fileId: 'guide-file-id',+ configName: 'guide.pdf',+ },+ ],+ }),+ })++ await user.click(screen.getByRole('button', { name: 'guide.pdf' }))+ const dialog = await screen.findByRole('dialog')++ expect(await within(dialog).findByTestId('pdf-loader')).toHaveAttribute(+ 'data-url',+ 'https://example.com/guide.pdf',+ )+ expect(previewQueryFn).not.toHaveBeenCalled()+ })++ it('should keep an open PDF preview when downloading it from the header', async () => {+ const user = userEvent.setup()+ const downloadQueryFn = vi.fn(async () => ({ url: 'https://example.com/preview-guide.pdf' }))+ mocks.downloadQueryOptions.mockImplementation(() => ({ queryFn: downloadQueryFn }))+ renderAgentFiles({+ initialDraft: createInitialDraft({+ files: [+ {+ id: 'guide.pdf',+ name: 'guide.pdf',+ icon: 'pdf',+ fileId: 'guide-file-id',+ configName: 'guide.pdf',+ },+ ],+ }),+ })++ await user.click(screen.getByRole('button', { name: 'guide.pdf' }))+ const dialog = await screen.findByRole('dialog')+ const loader = await within(dialog).findByTestId('pdf-loader')+ await user.click(+ within(dialog).getByRole('button', { name: /common\.operation\.download.*guide\.pdf/ }),+ )++ await waitFor(() => {+ expect(mocks.downloadUrl).toHaveBeenCalledWith({+ url: 'https://example.com/guide.pdf',+ fileName: 'guide.pdf',+ })+ })+ expect(downloadQueryFn).toHaveBeenCalledOnce()+ expect(within(dialog).getByTestId('pdf-loader')).toBe(loader)+ expect(loader).toHaveAttribute('data-url', 'https://example.com/preview-guide.pdf')+ })++ it('should note when a text preview is truncated', async () => {+ const user = userEvent.setup()+ mocks.previewQueryOptions.mockImplementation(({ input }) => ({+ queryFn: async () => ({+ name: input.params.name,+ binary: false,+ truncated: true,+ text: 'First 64 KiB',+ }),+ }))+ renderAgentFiles()++ await user.click(screen.getByRole('button', { name: 'brief.md' }))++ expect(+ await screen.findByText('agentV2.agentDetail.configure.files.preview.truncated'),+ ).toBeInTheDocument()+ })+it('should delete configured files by config name', async () => {const user = userEvent.setup()renderAgentFiles()@@ -554,20 +653,14 @@ describe('AgentFiles', () => {)await waitFor(() => {- expect(mocks.downloadQueryOptions).toHaveBeenCalledWith(- expect.objectContaining({- input: expect.objectContaining({- params: {- agent_id: 'agent-1',- name: 'diagram.png',- },- }),- }),- )+ expect(mocks.downloadUrl).toHaveBeenCalledWith({+ url: 'https://example.com/diagram.png',+ fileName: 'diagram.png',+ })})- expect(mocks.downloadUrl).toHaveBeenCalledWith({- url: 'https://example.com/diagram.png',- fileName: 'diagram.png',+ expect(mocks.downloadFile).toHaveBeenCalledWith({+ params: { agent_id: 'agent-1', name: 'diagram.png' },+ query: { draft_type: 'draft', version_id: undefined },})})@@ -585,20 +678,14 @@ describe('AgentFiles', () => {)await waitFor(() => {- expect(mocks.downloadQueryOptions).toHaveBeenCalledWith(- expect.objectContaining({- input: expect.objectContaining({- params: {- agent_id: 'agent-1',- name: 'diagram.png',- },- }),- }),- )+ expect(mocks.downloadUrl).toHaveBeenCalledWith({+ url: 'https://example.com/diagram.png',+ fileName: 'diagram.png',+ })})- expect(mocks.downloadUrl).toHaveBeenCalledWith({- url: 'https://example.com/diagram.png',- fileName: 'diagram.png',+ expect(mocks.downloadFile).toHaveBeenCalledWith({+ params: { agent_id: 'agent-1', name: 'diagram.png' },+ query: { draft_type: 'draft', version_id: undefined },})const trialFile = consoleQuery.trialApps.byAppId.agent.config.files.byNamefor (const operation of [trialFile.preview.get, trialFile.download.get]) {diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/index.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/index.tsxindex 6abc9a879db..2da65287595 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/index.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/index.tsx@@ -13,7 +13,7 @@ import {FileTreeLabel,} from '@langgenius/dify-ui/file-tree'import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'-import { skipToken, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'+import { skipToken, useMutation, useQuery } from '@tanstack/react-query'import { noop } from 'es-toolkit/function'import { useAtomValue, useSetAtom } from 'jotai'import { useCallback, useId, useRef, useState } from 'react'@@ -26,7 +26,8 @@ import {removeAgentFileAtom,upsertAgentFilesAtom,} from '@/features/agent-v2/agent-composer/store-modules/files'-import { consoleQuery } from '@/service/console'+import { hasFileDataPreview } from '@/features/agent-v2/file-icon'+import { consoleClient, consoleQuery } from '@/service/console'import { downloadBlob, downloadUrl } from '@/utils/download'import { useRegisterAgentOrchestrateAddAction } from '../add-actions-context'import { ConfigureSectionAddButton } from '../common/add-button'@@ -87,7 +88,6 @@ function AgentFileItem({}) {const { t } = useTranslation(['agentV2'])const readOnly = useAgentOrchestrateReadOnly()- const queryClient = useQueryClient()const [isPreviewOpen, setIsPreviewOpen] = useState(false)const [selectedFileId, setSelectedFileId] = useState<string>()const selectedFile = selectedFileId ? findAgentFileNode(files, selectedFileId) : undefined@@ -97,6 +97,9 @@ function AgentFileItem({const previewFileId = isVirtualPreviewFile? undefined: getAgentFilePreviewKey(selectedPreviewFile)+ const canLoadPreview = isPreviewOpen && !!previewFileId+ const isFileDataPreview = hasFileDataPreview(selectedPreviewFile.icon)+ const shouldLoadTextPreview = canLoadPreview && !isFileDataPreviewconst agentPreviewQuery = useQuery({...consoleQuery.agent.byAgentId.config.files.byName.preview.get.queryOptions({input: {@@ -110,12 +113,7 @@ function AgentFileItem({},},}),- enabled:- isPreviewOpen &&- !!previewFileId &&- !isVirtualPreviewFile &&- !apiContext.workflow &&- !apiContext.trialAppId,+ enabled: shouldLoadTextPreview && !apiContext.workflow && !apiContext.trialAppId,})const workflowPreviewQuery = useQuery({...consoleQuery.apps.byAppId.agent.config.files.byName.preview.get.queryOptions({@@ -131,7 +129,7 @@ function AgentFileItem({},},}),- enabled: isPreviewOpen && !!previewFileId && !isVirtualPreviewFile && !!apiContext.workflow,+ enabled: shouldLoadTextPreview && !!apiContext.workflow,})const trialPreviewQuery = useQuery(consoleQuery.trialApps.byAppId.agent.config.files.byName.preview.get.queryOptions({@@ -141,7 +139,7 @@ function AgentFileItem({query: { version_id: apiContext.versionId },}: skipToken,- enabled: !!apiContext.trialAppId && isPreviewOpen && !!previewFileId && !isVirtualPreviewFile,+ enabled: !!apiContext.trialAppId && shouldLoadTextPreview,}),)const previewQuery = apiContext.trialAppId@@ -149,12 +147,8 @@ function AgentFileItem({: apiContext.workflow? workflowPreviewQuery: agentPreviewQuery- const isImagePreviewFile = selectedPreviewFile.icon === 'image'const shouldDownloadPreviewFile =- isPreviewOpen &&- !!previewFileId &&- !isVirtualPreviewFile &&- (isImagePreviewFile || !!previewQuery.data?.binary)+ canLoadPreview && (isFileDataPreview || !!previewQuery.data?.binary)const agentDownloadQuery = useQuery({...consoleQuery.agent.byAgentId.config.files.byName.download.get.queryOptions({input: {@@ -169,6 +163,7 @@ function AgentFileItem({},}),staleTime: 0,+ refetchOnWindowFocus: false,enabled: shouldDownloadPreviewFile && !apiContext.workflow && !apiContext.trialAppId,})const workflowDownloadQuery = useQuery({@@ -186,6 +181,7 @@ function AgentFileItem({},}),staleTime: 0,+ refetchOnWindowFocus: false,enabled: shouldDownloadPreviewFile && !!apiContext.workflow,})const trialDownloadQuery = useQuery(@@ -198,6 +194,7 @@ function AgentFileItem({: skipToken,enabled: !!apiContext.trialAppId && shouldDownloadPreviewFile,staleTime: 0,+ refetchOnWindowFocus: false,}),)const downloadQuery = apiContext.trialAppId@@ -219,58 +216,27 @@ function AgentFileItem({}const fileName = getAgentFilePreviewKey(targetFile)- if (apiContext.trialAppId) {- const result = await queryClient.query({- ...consoleQuery.trialApps.byAppId.agent.config.files.byName.download.get.queryOptions({- input: {- params: { app_id: apiContext.trialAppId, name: fileName },- query: { version_id: apiContext.versionId },- },- }),- staleTime: 0,- })- downloadUrl({ url: result.url, fileName: targetFile.name })- return- }- if (apiContext.workflow) {- const result = await queryClient.query({- ...consoleQuery.apps.byAppId.agent.config.files.byName.download.get.queryOptions({- input: {- params: {- app_id: apiContext.workflow.appId,- name: fileName,- },+ const result = apiContext.trialAppId+ ? await consoleClient.trialApps.byAppId.agent.config.files.byName.download.get({+ params: { app_id: apiContext.trialAppId, name: fileName },+ query: { version_id: apiContext.versionId },+ })+ : apiContext.workflow+ ? await consoleClient.apps.byAppId.agent.config.files.byName.download.get({+ params: { app_id: apiContext.workflow.appId, name: fileName },query: {node_id: apiContext.workflow.nodeId,draft_type: apiContext.draftType,version_id: apiContext.versionId,},- },- }),- staleTime: 0,- })- downloadUrl({ url: result.url, fileName: targetFile.name })- return- }-- const result = await queryClient.query({- ...consoleQuery.agent.byAgentId.config.files.byName.download.get.queryOptions({- input: {- params: {- agent_id: apiContext.agentId,- name: fileName,- },- query: {- draft_type: apiContext.draftType,- version_id: apiContext.versionId,- },- },- }),- staleTime: 0,- })+ })+ : await consoleClient.agent.byAgentId.config.files.byName.download.get({+ params: { agent_id: apiContext.agentId, name: fileName },+ query: { draft_type: apiContext.draftType, version_id: apiContext.versionId },+ })downloadUrl({ url: result.url, fileName: targetFile.name })},- [apiContext, queryClient],+ [apiContext],)const downloadFileAction = useCallback((targetFile: AgentFileNode) => {@@ -333,11 +299,12 @@ function AgentFileItem({content: selectedPreviewFile.virtualContent ?? previewQuery.data?.text ?? undefined,downloadUrl: downloadQuery.isFetching ? undefined : downloadQuery.data?.url,fileName: selectedPreviewFile.name,+ fileType: selectedPreviewFile.icon,isDownloadError: downloadQuery.isError,isDownloadLoading: shouldDownloadPreviewFile && downloadQuery.isFetching,- isError: !isVirtualPreviewFile && previewQuery.isError,- isImage: isImagePreviewFile,- isLoading: !isVirtualPreviewFile && previewQuery.isPending,+ isError: shouldLoadTextPreview && previewQuery.isError,+ isLoading: shouldLoadTextPreview && previewQuery.isPending,+ truncated: previewQuery.data?.truncated,},onDownloadFile: onDownloadFile ? () => onDownloadFile(selectedPreviewFile) : undefined,onSelectFile: (selectedFile) => setSelectedFileId(selectedFile.id),diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/detail-dialog.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/detail-dialog.spec.tsxindex 5b629f5f26d..155758e841b 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/detail-dialog.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/detail-dialog.spec.tsx@@ -1,8 +1,10 @@+import type { ReactElement, ReactNode } from 'react'import type { AgentSkillDetail } from '../detail-dialog'import { Dialog } from '@langgenius/dify-ui/dialog'import { codeToTokens, isSupportedLanguage } from '@pierre/highlights'-import { render, screen, waitFor } from '@testing-library/react'-import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'+import { render, screen, waitFor, within } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'import { QueryClientTestProvider } from '@/test/console/query-provider'import { createTestQueryClient } from '@/test/query-client'import { AgentSkillDetailDialog } from '../detail-dialog'@@ -10,25 +12,51 @@ import { AgentSkillDetailDialog } from '../detail-dialog'// Spy on the real highlighter so tests can assert which files reach the lexers.vi.mock('@pierre/highlights', { spy: true })+// The URL picks the loader state: "pending" keeps `beforeLoad`, "broken" renders `errorMessage`.+vi.mock('@/app/components/base/file-uploader/pdf-highlighter-adapter', () => ({+ PdfLoader: ({+ beforeLoad,+ children,+ errorMessage,+ url,+ }: {+ beforeLoad: ReactNode+ children: (pdfDocument: unknown) => ReactNode+ errorMessage: ReactElement+ url: string+ }) => (+ <div data-testid="pdf-loader" data-url={url}>+ {url.includes('pending')+ ? beforeLoad+ : url.includes('broken')+ ? errorMessage+ : children({ numPages: 1 })}+ </div>+ ),+ PdfHighlighter: () => <div data-testid="pdf-document" />,+}))+const mockCodeToTokens = vi.mocked(codeToTokens)const mockIsSupportedLanguage = vi.mocked(isSupportedLanguage)const highlighterQueryKey = ['agent-v2', 'file-highlighter']-const renderPreview = (+const previewTree = (filePreview: AgentSkillDetail['filePreview'],queryClient = createTestQueryClient(),-) =>- render(- <QueryClientTestProvider queryClient={queryClient}>- <Dialog open>- <AgentSkillDetailDialog- skillName="demo"- detail={{ description: 'Demo files', files: [], filePreview, sections: [] }}- />- </Dialog>- </QueryClientTestProvider>,- )+ onDownloadFile?: AgentSkillDetail['onDownloadFile'],+) => (+ <QueryClientTestProvider queryClient={queryClient}>+ <Dialog open>+ <AgentSkillDetailDialog+ skillName="demo"+ detail={{ description: 'Demo files', files: [], filePreview, onDownloadFile, sections: [] }}+ />+ </Dialog>+ </QueryClientTestProvider>+)++const renderPreview = (...args: Parameters<typeof previewTree>) => render(previewTree(...args))const getLineCode = (text: string) =>screen.getByText((_, element) => element?.tagName === 'CODE' && element.textContent === text)@@ -77,6 +105,9 @@ describe('AgentSkillDetailDialog file preview', () => {expect(getLineCode('first line').children).toHaveLength(0)expect(getLineCode('second line').children).toHaveLength(0)+ expect(+ screen.queryByText('agentV2.agentDetail.configure.files.preview.truncated'),+ ).not.toBeInTheDocument()expect(queryClient.getQueryState(highlighterQueryKey)).toMatchObject({ fetchStatus: 'idle' })expect(mockIsSupportedLanguage).not.toHaveBeenCalled()})@@ -100,4 +131,94 @@ describe('AgentSkillDetailDialog file preview', () => {await waitFor(() => expect(mockCodeToTokens).toHaveBeenCalled(), { timeout: 5000 })expect(getLineCode('const a = 1').children).toHaveLength(0)})++ it('should note when the text preview is truncated', () => {+ renderPreview({ content: 'first line', fileName: 'notes.txt', truncated: true })++ expect(+ screen.getByText('agentV2.agentDetail.configure.files.preview.truncated'),+ ).toBeInTheDocument()+ })+})++describe('AgentSkillDetailDialog PDF preview', () => {+ afterEach(() => {+ vi.restoreAllMocks()+ })++ const renderPdf = (+ filePreview: NonNullable<AgentSkillDetail['filePreview']>,+ onDownloadFile?: AgentSkillDetail['onDownloadFile'],+ ) =>+ renderPreview(+ { fileName: 'guide.pdf', fileType: 'pdf', ...filePreview },+ undefined,+ onDownloadFile,+ )++ it('should render a PDF from its download URL', async () => {+ renderPdf({ downloadUrl: 'https://files.example.com/guide.pdf' })++ expect(await screen.findByTestId('pdf-document')).toBeInTheDocument()+ expect(screen.getByTestId('pdf-loader')).toHaveAttribute(+ 'data-url',+ 'https://files.example.com/guide.pdf',+ )+ })++ it('should show the loading state while the PDF document loads', async () => {+ renderPdf({ downloadUrl: 'https://files.example.com/pending.pdf' })++ const loader = await screen.findByTestId('pdf-loader')+ expect(within(loader).getByLabelText('common.loading')).toBeInTheDocument()+ })++ it('should render a PDF from file data through an object URL', async () => {+ const createObjectURL = vi+ .spyOn(URL, 'createObjectURL')+ .mockReturnValueOnce('blob:first')+ .mockReturnValueOnce('blob:second')+ const revokeObjectURL = vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {})+ const first = new Blob(['%PDF-1.7'], { type: 'application/pdf' })+ const second = new Blob(['%PDF-1.7 second'], { type: 'application/pdf' })+ const { rerender, unmount } = renderPdf({ fileData: first })++ expect(await screen.findByTestId('pdf-loader')).toHaveAttribute('data-url', 'blob:first')+ expect(createObjectURL).toHaveBeenCalledWith(first)++ rerender(previewTree({ fileData: second, fileName: 'guide.pdf', fileType: 'pdf' }))+ await waitFor(() =>+ expect(screen.getByTestId('pdf-loader')).toHaveAttribute('data-url', 'blob:second'),+ )+ expect(revokeObjectURL).toHaveBeenCalledWith('blob:first')++ unmount()+ expect(revokeObjectURL).toHaveBeenCalledWith('blob:second')+ })++ it('should offer the download when no PDF source is available', async () => {+ const user = userEvent.setup()+ const onDownloadFile = vi.fn()+ renderPdf({}, onDownloadFile)++ expect(+ screen.getByText('agentV2.agentDetail.configure.files.preview.unsupported'),+ ).toBeInTheDocument()+ expect(screen.queryByTestId('pdf-loader')).not.toBeInTheDocument()+ await user.click(screen.getByRole('link', { name: 'common.operation.download' }))+ expect(onDownloadFile).toHaveBeenCalledWith('preview')+ })++ it('should request a fresh download when the PDF fails to load', async () => {+ const user = userEvent.setup()+ const onDownloadFile = vi.fn()+ renderPdf({ downloadUrl: 'https://files.example.com/broken.pdf' }, onDownloadFile)++ const loader = await screen.findByTestId('pdf-loader')+ expect(+ within(loader).getByText('agentV2.agentDetail.configure.files.preview.failed'),+ ).toBeInTheDocument()+ await user.click(within(loader).getByRole('link', { name: 'common.operation.download' }))+ expect(onDownloadFile).toHaveBeenCalledWith('preview')+ })})diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsxindex 19178e47407..33ad00b6962 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsx@@ -94,6 +94,11 @@ vi.mock('@/app/notifications', () => ({},}))+vi.mock('@/app/components/base/file-uploader/pdf-highlighter-adapter', () => ({+ PdfLoader: ({ url }: { url: string }) => <div data-testid="pdf-loader" data-url={url} />,+ PdfHighlighter: () => null,+}))+vi.mock('@/utils/download', () => ({downloadBlob: mocks.downloadBlob,downloadUrl: mocks.downloadUrl,@@ -1859,6 +1864,189 @@ describe('AgentSkills', () => {expect(revokeObjectURL).toHaveBeenCalledWith('blob:skill-image')})+ it('should preview and download PDF skill members from one authenticated Blob', async () => {+ const user = userEvent.setup()+ vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:skill-pdf')+ vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {})+ const previewQueryFn = vi.fn(async () => ({+ path: 'assets/guide.pdf',+ binary: true,+ truncated: false,+ text: null,+ }))+ mocks.previewQueryOptions.mockImplementation(() => ({ queryFn: previewQueryFn }))+ mocks.inspectQueryOptions.mockImplementation(({ input }) => ({+ queryFn: async () => ({+ id: input.params.name,+ name: input.params.name,+ description: 'Inspect skill',+ source: 'config_skill_zip',+ files: [+ {+ path: 'SKILL.md',+ name: 'SKILL.md',+ type: 'file',+ previewable: true,+ downloadable: true,+ },+ {+ path: 'assets/guide.pdf',+ name: 'guide.pdf',+ type: 'file',+ previewable: true,+ downloadable: true,+ },+ ],+ skill_md: { path: 'SKILL.md', size: 8, truncated: false, binary: false, text: '# Skill\n' },+ warnings: [],+ }),+ }))+ renderAgentSkills()++ await user.click(screen.getByText('Tender Analyzer').closest('button')!)+ await user.click(await screen.findByText('assets'))+ await user.click(screen.getByText('guide.pdf').closest('button')!)++ const loader = await screen.findByTestId('pdf-loader')+ expect(loader).toHaveAttribute('data-url', 'blob:skill-pdf')+ expect(mocks.fetch).toHaveBeenCalledWith(+ expect.stringContaining('path=assets%2Fguide.pdf'),+ expect.objectContaining({ credentials: 'include' }),+ )+ expect(previewQueryFn).not.toHaveBeenCalled()++ await user.click(+ screen.getByRole('button', { name: /common\.operation\.download.*guide\.pdf/ }),+ )++ expect(mocks.downloadBlob).toHaveBeenCalledWith({+ data: expect.any(Blob),+ fileName: 'guide.pdf',+ })+ expect(mocks.fetch).toHaveBeenCalledOnce()+ expect(screen.getByTestId('pdf-loader')).toBe(loader)+ })++ it('should not download a stale cached PDF while its content refreshes', async () => {+ const user = userEvent.setup()+ vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:skill-pdf')+ vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {})+ let resolveContent!: (response: Response) => void+ mocks.fetch.mockImplementationOnce(+ () =>+ new Promise<Response>((resolve) => {+ resolveContent = resolve+ }),+ )+ mocks.inspectQueryOptions.mockImplementation(({ input }) => ({+ queryFn: async () => ({+ id: input.params.name,+ name: input.params.name,+ description: 'Inspect skill',+ source: 'config_skill_zip',+ files: [+ {+ path: 'SKILL.md',+ name: 'SKILL.md',+ type: 'file',+ previewable: true,+ downloadable: true,+ },+ {+ path: 'assets/guide.pdf',+ name: 'guide.pdf',+ type: 'file',+ previewable: true,+ downloadable: true,+ },+ ],+ skill_md: { path: 'SKILL.md', size: 8, truncated: false, binary: false, text: '# Skill\n' },+ warnings: [],+ }),+ }))+ const view = renderAgentSkills()+ view.queryClient.setQueryData(+ [+ 'agent-v2',+ 'skill-file-content',+ '/console/api/agent/agent-1/config/skills/Tender%20Analyzer/files/content?path=assets%2Fguide.pdf',+ ],+ new Blob(['stale pdf']),+ )++ await user.click(screen.getByText('Tender Analyzer').closest('button')!)+ await user.click(await screen.findByText('assets'))+ await user.click(screen.getByText('guide.pdf').closest('button')!)+ await waitFor(() => expect(mocks.fetch).toHaveBeenCalledOnce())+ await user.click(+ screen.getByRole('button', { name: /common\.operation\.download.*guide\.pdf/ }),+ )+ expect(mocks.downloadBlob).not.toHaveBeenCalled()++ resolveContent(new Response('current pdf', { headers: { 'Content-Type': 'application/pdf' } }))++ await waitFor(() => {+ expect(mocks.downloadBlob).toHaveBeenCalledWith({+ data: expect.any(Blob),+ fileName: 'guide.pdf',+ })+ })+ const [{ data }] = mocks.downloadBlob.mock.calls[0]! as [{ data: Blob }]+ await expect(data.text()).resolves.toBe('current pdf')+ })++ it('should note a truncated SKILL.md and download the full file from the server', async () => {+ const user = userEvent.setup()+ mocks.inspectQueryOptions.mockImplementation(({ input }) => ({+ queryFn: async () => ({+ id: input.params.name,+ name: input.params.name,+ description: 'Inspect skill',+ source: 'config_skill_zip',+ files: [+ {+ path: 'SKILL.md',+ name: 'SKILL.md',+ type: 'file',+ previewable: true,+ downloadable: true,+ },+ ],+ skill_md: {+ path: 'SKILL.md',+ size: 200_000,+ truncated: true,+ binary: false,+ text: '# Skill\n',+ },+ warnings: [],+ }),+ }))+ renderAgentSkills()++ await user.click(screen.getByText('Tender Analyzer').closest('button')!)+ expect(+ await screen.findByText('agentV2.agentDetail.configure.files.preview.truncated'),+ ).toBeInTheDocument()++ await user.click(screen.getByRole('button', { name: /common\.operation\.download.*SKILL\.md/ }))++ await waitFor(() => {+ expect(mocks.fetch).toHaveBeenCalledWith(+ expect.stringContaining('path=SKILL.md'),+ expect.objectContaining({ credentials: 'include' }),+ )+ })+ await waitFor(() => {+ expect(mocks.downloadBlob).toHaveBeenCalledWith({+ data: expect.any(Blob),+ fileName: 'SKILL.md',+ })+ })+ const [{ data }] = mocks.downloadBlob.mock.calls[0]! as [{ data: Blob }]+ await expect(data.text()).resolves.toBe('downloaded skill file')+ })+it('should download inspected SKILL.md content as markdown', async () => {const user = userEvent.setup()renderAgentSkills()diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsxindex dd30de57ab9..d596c221b7a 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx@@ -18,10 +18,11 @@ import {ScrollAreaViewport,} from '@langgenius/dify-ui/scroll-area'import { queryOptions, useQuery } from '@tanstack/react-query'+import dynamic from 'next/dynamic'import { useCallback, useId, useMemo } from 'react'import { useTranslation } from 'react-i18next'import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'-import { getFileExtension } from '@/features/agent-v2/file-icon'+import { getFileExtension, hasFileDataPreview } from '@/features/agent-v2/file-icon'import { AgentFileTree } from '../files/tree'type AgentSkillDetailSection = {@@ -49,13 +50,14 @@ export type AgentSkillDetail = {content?: stringdownloadActionLoadingTarget?: AgentSkillDetailDownloadAction | nulldownloadUrl?: string+ fileData?: BlobfileName?: string- imageData?: Blob+ fileType?: AgentFileNode['icon']isDownloadError?: booleanisDownloadLoading?: booleanisError?: boolean- isImage?: booleanisLoading?: boolean+ truncated?: boolean}onFolderOpenChange?: (context: { file: AgentFileNode; depth: number; open: boolean }) => voidonFolderEnter?: (context: { file: AgentFileNode; depth: number }) => void@@ -68,6 +70,11 @@ export type AgentSkillDetail = {const keepSkillFoldersClosed = () => false+const AgentFilePdfPreview = dynamic(+ () => import('./pdf-preview').then((module) => module.AgentFilePdfPreview),+ { ssr: false, loading: () => <AgentFilePreviewLoading /> },+)+function AgentSkillFileList({fileListHeader,fileListLoading,@@ -173,19 +180,19 @@ function AgentSkillDetailSectionBlock({ section }: { section: AgentSkillDetailSe)}-function AgentSkillImagePreview({ fileName, imageData }: { fileName?: string; imageData: Blob }) {+function AgentSkillImagePreview({ fileName, fileData }: { fileName?: string; fileData: Blob }) {const setImageRef = useCallback((image: HTMLImageElement | null) => {if (!image) return- const objectUrl = URL.createObjectURL(imageData)+ const objectUrl = URL.createObjectURL(fileData)image.src = objectUrlreturn () => {URL.revokeObjectURL(objectUrl)}},- [imageData],+ [fileData],)return (@@ -199,44 +206,86 @@ function AgentSkillImagePreview({ fileName, imageData }: { fileName?: string; im)}+function AgentFilePreviewLoading() {+ return (+ <div className="flex min-h-40 flex-1 items-center justify-center">+ <LoadingPlaceholder />+ </div>+ )+}++function AgentFilePreviewFallback({+ downloadActionLoadingTarget,+ downloadUrl,+ message,+ onDownloadFile,+}: Pick<+ NonNullable<AgentSkillDetail['filePreview']>,+ 'downloadActionLoadingTarget' | 'downloadUrl'+> &+ Pick<AgentSkillDetail, 'onDownloadFile'> & { message: string }) {+ const { t: tCommon } = useTranslation(['common'])+ const isPreviewDownloadLoading = downloadActionLoadingTarget === 'preview'++ return (+ <div className="flex min-w-0 flex-wrap items-center gap-2 px-4">+ <span className="system-sm-regular text-text-tertiary">{message}</span>+ {onDownloadFile && (+ <a+ href={downloadUrl || '#'}+ aria-disabled={isPreviewDownloadLoading}+ onClick={(event) => {+ if (isPreviewDownloadLoading) {+ event.preventDefault()+ return+ }+ if (!downloadUrl) {+ event.preventDefault()+ onDownloadFile('preview')+ }+ }}+ target="_blank"+ rel="noreferrer"+ className="inline-flex min-w-0 items-center gap-1 rounded-md px-2 py-1 system-sm-medium text-text-accent outline-hidden hover:bg-state-base-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid"+ >+ <span+ aria-hidden+ className={cn(+ 'size-4 shrink-0',+ isPreviewDownloadLoading+ ? 'i-ri-loader-2-line animate-spin motion-reduce:animate-none'+ : 'i-ri-download-2-line',+ )}+ />+ <span className="shrink-0">+ {isPreviewDownloadLoading+ ? tCommon(($) => $['operation.downloading'])+ : tCommon(($) => $['operation.download'])}+ </span>+ </a>+ )}+ </div>+ )+}+function AgentFilePreviewContent({binary,content,downloadActionLoadingTarget,downloadUrl,+ fileData,fileName,- imageData,+ fileType,isDownloadError,isDownloadLoading,isError,- isImage,isLoading,onDownloadFile,-}: {- binary?: boolean- content?: string- downloadActionLoadingTarget?: AgentSkillDetailDownloadAction | null- downloadUrl?: string- fileName?: string- imageData?: Blob- isDownloadError?: boolean- isDownloadLoading?: boolean- isError?: boolean- isImage?: boolean- isLoading?: boolean- onDownloadFile?: (action: AgentSkillDetailDownloadAction) => void-}) {+ truncated,+}: NonNullable<AgentSkillDetail['filePreview']> & Pick<AgentSkillDetail, 'onDownloadFile'>) {const { t } = useTranslation(['agentV2'])- const { t: tCommon } = useTranslation(['common'])- const isPreviewDownloadLoading = downloadActionLoadingTarget === 'preview'- if (isLoading || isDownloadLoading) {- return (- <div className="flex min-h-40 flex-1 items-center justify-center">- <LoadingPlaceholder />- </div>- )- }+ if (isLoading || isDownloadLoading) return <AgentFilePreviewLoading />if (isError || isDownloadError) {return (@@ -246,62 +295,46 @@ function AgentFilePreviewContent({)}- if (isImage) {- if (imageData) return <AgentSkillImagePreview fileName={fileName} imageData={imageData} />- if (downloadUrl) {- return (- <div className="flex min-h-40 flex-1 items-start justify-center overflow-auto px-2 pb-4">- <img- src={downloadUrl}- alt={fileName ?? ''}- className="max-h-140 max-w-full rounded-lg object-contain"+ if (fileType === 'image' && fileData)+ return <AgentSkillImagePreview fileName={fileName} fileData={fileData} />++ if (fileType === 'image' && downloadUrl) {+ return (+ <div className="flex min-h-40 flex-1 items-start justify-center overflow-auto px-2 pb-4">+ <img+ src={downloadUrl}+ alt={fileName ?? ''}+ className="max-h-140 max-w-full rounded-lg object-contain"+ />+ </div>+ )+ }++ if (fileType === 'pdf' && (fileData || downloadUrl)) {+ return (+ <AgentFilePdfPreview+ data={fileData}+ url={downloadUrl}+ loading={<AgentFilePreviewLoading />}+ failure={+ <AgentFilePreviewFallback+ downloadActionLoadingTarget={downloadActionLoadingTarget}+ message={t(($) => $['agentDetail.configure.files.preview.failed'])}+ onDownloadFile={onDownloadFile}/>- </div>- )- }+ }+ />+ )}- if (binary) {+ if (binary || hasFileDataPreview(fileType)) {return (- <div className="flex min-w-0 flex-wrap items-center gap-2 px-4">- <span className="system-sm-regular text-text-tertiary">- {t(($) => $['agentDetail.configure.files.preview.unsupported'])}- </span>- {onDownloadFile && (- <a- href={downloadUrl || '#'}- aria-disabled={isPreviewDownloadLoading}- onClick={(event) => {- if (isPreviewDownloadLoading) {- event.preventDefault()- return- }- if (!downloadUrl) {- event.preventDefault()- onDownloadFile?.('preview')- }- }}- target="_blank"- rel="noreferrer"- className="inline-flex min-w-0 items-center gap-1 rounded-md px-2 py-1 system-sm-medium text-text-accent outline-hidden hover:bg-state-base-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid"- >- <span- aria-hidden- className={cn(- 'size-4 shrink-0',- isPreviewDownloadLoading- ? 'i-ri-loader-2-line animate-spin motion-reduce:animate-none'- : 'i-ri-download-2-line',- )}- />- <span className="shrink-0">- {isPreviewDownloadLoading- ? tCommon(($) => $['operation.downloading'])- : tCommon(($) => $['operation.download'])}- </span>- </a>- )}- </div>+ <AgentFilePreviewFallback+ downloadActionLoadingTarget={downloadActionLoadingTarget}+ downloadUrl={downloadUrl}+ message={t(($) => $['agentDetail.configure.files.preview.unsupported'])}+ onDownloadFile={onDownloadFile}+ />)}@@ -313,7 +346,17 @@ function AgentFilePreviewContent({)}- return <AgentFileTextPreview content={content} fileName={fileName} />+ return (+ <>+ {truncated && (+ <p className="flex items-center gap-1 px-4 system-xs-regular text-text-tertiary">+ <span aria-hidden className="i-ri-information-line size-3.5 shrink-0" />+ {t(($) => $['agentDetail.configure.files.preview.truncated'])}+ </p>+ )}+ <AgentFileTextPreview content={content} fileName={fileName} />+ </>+ )}const loadFileHighlighter = async () => {@@ -509,17 +552,7 @@ export function AgentSkillDetailBody({>{detail.filePreview && (<AgentFilePreviewContent- binary={detail.filePreview.binary}- content={detail.filePreview.content}- downloadActionLoadingTarget={detail.filePreview.downloadActionLoadingTarget}- downloadUrl={detail.filePreview.downloadUrl}- fileName={detail.filePreview.fileName}- imageData={detail.filePreview.imageData}- isDownloadError={detail.filePreview.isDownloadError}- isDownloadLoading={detail.filePreview.isDownloadLoading}- isError={detail.filePreview.isError}- isImage={detail.filePreview.isImage}- isLoading={detail.filePreview.isLoading}+ {...detail.filePreview}onDownloadFile={detail.onDownloadFile}/>)}diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/pdf-preview.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/pdf-preview.tsxnew file mode 100644index 00000000000..a8cc0c7f628--- /dev/null+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/pdf-preview.tsx@@ -0,0 +1,64 @@+'use client'++import type { ReactElement } from 'react'+import { noop } from 'es-toolkit/function'+import { useEffect, useState } from 'react'+import {+ PdfHighlighter,+ PdfLoader,+} from '@/app/components/base/file-uploader/pdf-highlighter-adapter'+import { basePath } from '@/utils/var'++export function AgentFilePdfPreview({+ data,+ failure,+ loading,+ url,+}: {+ data?: Blob+ failure: ReactElement+ loading: ReactElement+ url?: string+}) {+ const [objectUrl, setObjectUrl] = useState<string>()++ useEffect(() => {+ if (!data) return++ const nextObjectUrl = URL.createObjectURL(data)+ // oxlint-disable-next-line eslint-react/set-state-in-effect -- Browser object URLs are external resources created and revoked with this effect lifecycle.+ setObjectUrl(nextObjectUrl)+ return () => URL.revokeObjectURL(nextObjectUrl)+ }, [data])++ const pdfUrl = url ?? objectUrl++ return (+ <div className="relative flex min-h-40 flex-1 flex-col">+ {pdfUrl ? (+ <PdfLoader+ key={pdfUrl}+ workerSrc={`${basePath}/pdf.worker.min.mjs`}+ url={pdfUrl}+ beforeLoad={loading}+ errorMessage={failure}+ >+ {(pdfDocument) => (+ <PdfHighlighter+ pdfDocument={pdfDocument}+ pdfScaleValue="page-width"+ enableAreaSelection={() => false}+ scrollRef={noop}+ onScrollChange={noop}+ onSelectionFinished={() => null}+ highlightTransform={() => <div />}+ highlights={[]}+ />+ )}+ </PdfLoader>+ ) : (+ loading+ )}+ </div>+ )+}diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/use-skill-detail.ts b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/use-skill-detail.tsindex 63ca4833911..39085f0c6f6 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/use-skill-detail.ts+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/use-skill-detail.ts@@ -10,7 +10,7 @@ import { useCallback, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { toast } from '@/app/notifications'import { API_PREFIX, CSRF_COOKIE_NAME, CSRF_HEADER_NAME } from '@/config'-import { getDriveFileIconType } from '@/features/agent-v2/file-icon'+import { getDriveFileIconType, hasFileDataPreview } from '@/features/agent-v2/file-icon'import { consoleQuery } from '@/service/console'import { downloadBlob } from '@/utils/download'@@ -42,6 +42,7 @@ const getSkillFileContentQueryOptions = (url: string) =>queryKey: skillFileContentQueryKey(url),queryFn: () => fetchSkillFileContent(url),staleTime: 0,+ refetchOnWindowFocus: false,})const isSkillFolder = (file: AgentConfigSkillFileResponse) => file.type === 'directory'@@ -248,6 +249,9 @@ export function useAgentSkillDetail({const selectedPreviewPath = isSkillMdSelected? undefined: (selectedFile?.configName ?? selectedFile?.id)+ const isFileDataPreview = hasFileDataPreview(selectedFile?.icon)+ const shouldLoadTextPreview = isOpen && !!selectedPreviewPath && !isFileDataPreview+ const shouldLoadFileData = isOpen && !!selectedPreviewPath && isFileDataPreviewconst agentPreviewQuery = useQuery({...consoleQuery.agent.byAgentId.config.skills.byName.files.preview.get.queryOptions({input: {@@ -262,7 +266,7 @@ export function useAgentSkillDetail({},},}),- enabled: isOpen && !!selectedPreviewPath && !apiContext.workflow && !apiContext.trialAppId,+ enabled: shouldLoadTextPreview && !apiContext.workflow && !apiContext.trialAppId,})const workflowPreviewQuery = useQuery({...consoleQuery.apps.byAppId.agent.config.skills.byName.files.preview.get.queryOptions({@@ -279,7 +283,7 @@ export function useAgentSkillDetail({},},}),- enabled: isOpen && !!selectedPreviewPath && !!apiContext.workflow,+ enabled: shouldLoadTextPreview && !!apiContext.workflow,})const trialPreviewQuery = useQuery(consoleQuery.trialApps.byAppId.agent.config.skills.byName.files.preview.get.queryOptions({@@ -289,7 +293,7 @@ export function useAgentSkillDetail({query: { path: selectedPreviewPath ?? '', version_id: apiContext.versionId },}: skipToken,- enabled: !!apiContext.trialAppId && isOpen && !!selectedPreviewPath,+ enabled: !!apiContext.trialAppId && shouldLoadTextPreview,}),)const previewQuery = apiContext.trialAppId@@ -297,8 +301,6 @@ export function useAgentSkillDetail({: apiContext.workflow? workflowPreviewQuery: agentPreviewQuery- const isImagePreviewFile = selectedFile?.icon === 'image'- const shouldLoadImagePreview = isOpen && !!selectedPreviewPath && isImagePreviewFileconst agentDownloadQuery = useQuery({...consoleQuery.agent.byAgentId.config.skills.byName.files.download.get.queryOptions({input: {@@ -314,7 +316,8 @@ export function useAgentSkillDetail({},}),staleTime: 0,- enabled: shouldLoadImagePreview && !apiContext.workflow && !apiContext.trialAppId,+ refetchOnWindowFocus: false,+ enabled: shouldLoadFileData && !apiContext.workflow && !apiContext.trialAppId,})const workflowDownloadQuery = useQuery({...consoleQuery.apps.byAppId.agent.config.skills.byName.files.download.get.queryOptions({@@ -332,7 +335,8 @@ export function useAgentSkillDetail({},}),staleTime: 0,- enabled: shouldLoadImagePreview && !!apiContext.workflow,+ refetchOnWindowFocus: false,+ enabled: shouldLoadFileData && !!apiContext.workflow,})const trialDownloadQuery = useQuery(consoleQuery.trialApps.byAppId.agent.config.skills.byName.files.download.get.queryOptions({@@ -342,8 +346,9 @@ export function useAgentSkillDetail({query: { path: selectedPreviewPath ?? '', version_id: apiContext.versionId },}: skipToken,- enabled: !!apiContext.trialAppId && shouldLoadImagePreview,+ enabled: !!apiContext.trialAppId && shouldLoadFileData,staleTime: 0,+ refetchOnWindowFocus: false,}),)const downloadQuery = apiContext.trialAppId@@ -352,11 +357,11 @@ export function useAgentSkillDetail({? workflowDownloadQuery: agentDownloadQueryconst skillFileContentUrl = downloadQuery.data?.url- const imageContentQuery = useQuery(+ const fileContentQuery = useQuery(skillFileContentUrl? {...getSkillFileContentQueryOptions(skillFileContentUrl),- enabled: shouldLoadImagePreview,+ enabled: shouldLoadFileData,}: {queryKey: skillFileContentQueryKey(),@@ -371,7 +376,11 @@ export function useAgentSkillDetail({const path = file.configName ?? file.idconst isSkillMdFile = path === inspectQuery.data?.skill_md.path || file.name === 'SKILL.md'- if (isSkillMdFile && inspectQuery.data?.skill_md.text !== undefined) {+ if (+ isSkillMdFile &&+ !inspectQuery.data?.skill_md.truncated &&+ inspectQuery.data?.skill_md.text !== undefined+ ) {downloadBlob({data: new Blob([inspectQuery.data.skill_md.text], {type: 'text/markdown;charset=utf-8',@@ -381,6 +390,11 @@ export function useAgentSkillDetail({return}+ if (isFileDataPreview && fileContentQuery.isSuccess && !fileContentQuery.isFetching) {+ downloadBlob({ data: fileContentQuery.data, fileName: file.name })+ return+ }+setDownloadActionLoadingTarget(action)try {if (apiContext.trialAppId) {@@ -452,6 +466,11 @@ export function useAgentSkillDetail({apiContext,inspectQuery.data?.skill_md.path,inspectQuery.data?.skill_md.text,+ inspectQuery.data?.skill_md.truncated,+ fileContentQuery.data,+ fileContentQuery.isFetching,+ fileContentQuery.isSuccess,+ isFileDataPreview,queryClient,selectedFile,skill.name,@@ -469,19 +488,21 @@ export function useAgentSkillDetail({? (inspectQuery.data?.skill_md.text ?? undefined): (previewQuery.data?.text ?? undefined),downloadActionLoadingTarget,+ fileData: fileContentQuery.isFetching ? undefined : fileContentQuery.data,fileName: selectedFile?.name,- imageData: imageContentQuery.isFetching ? undefined : imageContentQuery.data,- isDownloadError:- shouldLoadImagePreview && (downloadQuery.isError || imageContentQuery.isError),+ fileType: selectedFile?.icon,+ isDownloadError: shouldLoadFileData && (downloadQuery.isError || fileContentQuery.isError),isDownloadLoading:- shouldLoadImagePreview && (downloadQuery.isFetching || imageContentQuery.isFetching),+ shouldLoadFileData && (downloadQuery.isFetching || fileContentQuery.isFetching),isError: isSkillMdSelected? inspectQuery.isError- : !!selectedPreviewPath && previewQuery.isError,- isImage: isImagePreviewFile,+ : shouldLoadTextPreview && previewQuery.isError,isLoading: isSkillMdSelected? inspectQuery.isPending- : !!selectedPreviewPath && previewQuery.isPending,+ : shouldLoadTextPreview && previewQuery.isPending,+ truncated: isSkillMdSelected+ ? inspectQuery.data?.skill_md.truncated+ : previewQuery.data?.truncated,},onDownloadFile: canDownload ? handleDownloadFile : undefined,onSelectFile: (file) => setSelectedFileId(file.id),diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsxindex 1b6588520bb..b5f02229373 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsx@@ -197,6 +197,11 @@ vi.mock('@/service/console', async (importOriginal) => {}})+vi.mock('@/app/components/base/file-uploader/pdf-highlighter-adapter', () => ({+ PdfLoader: ({ url }: { url: string }) => <div data-testid="pdf-loader" data-url={url} />,+ PdfHighlighter: () => null,+}))+vi.mock('@/utils/download', () => ({downloadUrl: mocks.downloadUrl,}))@@ -289,7 +294,7 @@ function mockFileReadAsBinary(source: AgentWorkingDirectorySource) {}))}-function expectedImagePreviewRequest(source: AgentWorkingDirectorySource, path: string) {+function expectedFileUrlRequest(source: AgentWorkingDirectorySource, path: string) {if (source.type === 'agent') {return {params: { agent_id: source.agentId },@@ -670,7 +675,7 @@ describe('AgentWorkingDirectoryPanel', () => {})expect(previewClient).toHaveBeenNthCalledWith(2,- expectedImagePreviewRequest(identitySource, initialImagePath),+ expectedFileUrlRequest(identitySource, initialImagePath),)await user.click(await screen.findByText(fileName(nextImagePath)))@@ -681,7 +686,7 @@ describe('AgentWorkingDirectoryPanel', () => {})expect(previewClient).toHaveBeenNthCalledWith(3,- expectedImagePreviewRequest(identitySource, nextImagePath),+ expectedFileUrlRequest(identitySource, nextImagePath),)},)@@ -716,6 +721,48 @@ describe('AgentWorkingDirectoryPanel', () => {},)+ it.each(previewSourceCases)(+ 'should preview $label PDFs from a download URL without reading the file text',+ async ({ source, previewClient }) => {+ const readQueryFn = vi.fn(async () => ({+ binary: true,+ path: '~/report.pdf',+ text: null,+ truncated: false,+ }))+ ;(source.type === 'agent'+ ? mocks.sandboxFileReadQueryOptions+ : mocks.workflowSandboxFileReadQueryOptions+ ).mockImplementation(() => ({ queryFn: readQueryFn }))+ mockFileListEntries(source, [{ name: 'report.pdf', type: 'file' }])+ previewClient.mockResolvedValueOnce({ url: 'https://example.com/report.pdf' })+ renderWorkingDirectoryPanel({ source })++ expect(await screen.findByTestId('pdf-loader')).toHaveAttribute(+ 'data-url',+ 'https://example.com/report.pdf',+ )+ expect(previewClient).toHaveBeenCalledWith(expectedFileUrlRequest(source, 'report.pdf'))+ expect(readQueryFn).not.toHaveBeenCalled()+ },+ )++ it('should note when a working directory file preview is truncated', async () => {+ mocks.sandboxFileReadQueryOptions.mockImplementation(({ input }: QueryOptionsInput) => ({+ queryFn: async () => ({+ binary: false,+ path: input.query?.path ?? '',+ text: 'First 64 KiB',+ truncated: true,+ }),+ }))+ renderWorkingDirectoryPanel({ source: agentSource })++ expect(+ await screen.findByText('agentV2.agentDetail.configure.files.preview.truncated'),+ ).toBeInTheDocument()+ })+it('should download workflow files from the exact node execution', async () => {const user = userEvent.setup()const download = createDeferred<{ url: string }>()diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsxindex 9dcca80527d..9a943d91a97 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsx@@ -18,7 +18,7 @@ import { skipToken, useMutation, useQueries, useQuery } from '@tanstack/react-quimport { useCallback, useId, useState } from 'react'import { useTranslation } from 'react-i18next'import { toast } from '@/app/notifications'-import { getFileIconType } from '@/features/agent-v2/file-icon'+import { getFileIconType, hasFileDataPreview } from '@/features/agent-v2/file-icon'import { consoleClient, consoleQuery } from '@/service/console'import { isNotFoundError } from '@/service/http-error'import { downloadUrl } from '@/utils/download'@@ -383,10 +383,11 @@ function AgentWorkingDirectoryContent({},},)+ const isFileDataPreview = hasFileDataPreview(selectedWorkingDirectoryFile?.icon)+ const shouldReadFile = !!selectedWorkingDirectoryFile && !isFileDataPreviewconst fileReadQuery = useQuery({...fileReadQueryOptions,- enabled:- open && !!selectedWorkingDirectoryFile && selectedWorkingDirectoryFile.icon !== 'image',+ enabled: open && shouldReadFile,queryFn: async (context): Promise<SandboxReadResponse> => {try {return await fileReadQueryOptions.queryFn(context)@@ -412,18 +413,16 @@ function AgentWorkingDirectoryContent({consoleQuery.apps.byAppId.workflowRuns.byWorkflowRunId.agentNodes.byNodeId.sandbox.files.download.post.mutationOptions(),)const { mutateAsync: downloadAgentSandboxFile } = agentSandboxDownloadMutation- const isImagePreviewFile = selectedWorkingDirectoryFile?.icon === 'image'const selectedWorkingDirectoryFilePath = selectedWorkingDirectoryFile?.idconst { mutateAsync: downloadWorkflowSandboxFile } = workflowSandboxDownloadMutationconst isFileDownloadPending =agentSandboxDownloadMutation.isPending || workflowSandboxDownloadMutation.isPending- const isFileReadLoading =- !!selectedWorkingDirectoryFile && !isImagePreviewFile && fileReadQuery.isPending- const imagePreviewQuery = useQuery({+ const isFileReadLoading = shouldReadFile && fileReadQuery.isPending+ const fileUrlQuery = useQuery({queryKey: ['agent-v2','working-directory',- 'image-preview',+ 'file-url',source.type,source.type === 'agent' ? source.agentId : source.appId,source.type === 'agent' ? source.callerType : source.workflowRunId,@@ -462,7 +461,9 @@ function AgentWorkingDirectoryContent({},)},- enabled: open && !!selectedWorkingDirectoryFile && isImagePreviewFile,+ enabled: open && isFileDataPreview,+ refetchOnWindowFocus: false,+ retry: false,})const handleDownloadFile = useCallback(async (action: AgentSkillDetailDownloadAction) => {@@ -611,13 +612,14 @@ function AgentWorkingDirectoryContent({binary: fileReadQuery.data?.binary,content: fileReadQuery.data?.text ?? undefined,downloadActionLoadingTarget,- downloadUrl: imagePreviewQuery.data?.url,+ downloadUrl: fileUrlQuery.data?.url,fileName: isFileListLoading ? '' : selectedWorkingDirectoryFile?.name,- isDownloadError: imagePreviewQuery.isError,- isDownloadLoading: !!isImagePreviewFile && imagePreviewQuery.isPending,+ fileType: selectedWorkingDirectoryFile?.icon,+ isDownloadError: fileUrlQuery.isError,+ isDownloadLoading: isFileDataPreview && fileUrlQuery.isPending,isError: (fileListQuery.isError && !hasNoActiveBinding) || fileReadQuery.isError,- isImage: isImagePreviewFile,isLoading: isFileListLoading || isFileReadLoading,+ truncated: fileReadQuery.data?.truncated,},onDownloadFile: selectedWorkingDirectoryFile ? handleDownloadFile : undefined,folderOpenState: ({ file }) => {diff --git a/web/features/agent-v2/file-icon.ts b/web/features/agent-v2/file-icon.tsindex 6d3adf503b6..906b726c6cb 100644--- a/web/features/agent-v2/file-icon.ts+++ b/web/features/agent-v2/file-icon.ts@@ -53,6 +53,10 @@ export function getFileExtension(fileName: string) {return fileName.split('.').pop()?.toLowerCase() ?? ''}+export function hasFileDataPreview(fileType?: FileTreeIconType) {+ return fileType === 'image' || fileType === 'pdf'+}+export function getFileIconType(fileName: string, mimeType?: string | null): FileTreeIconType {const extension = getFileExtension(fileName)diff --git a/web/i18n/locales/ar-TN/agent-v-2.json b/web/i18n/locales/ar-TN/agent-v-2.jsonindex c6ca6617182..bbe328cc6af 100644--- a/web/i18n/locales/ar-TN/agent-v-2.json+++ b/web/i18n/locales/ar-TN/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "الملف غير موجود","agentDetail.configure.files.preview.empty": "لا يوجد محتوى معاينة.","agentDetail.configure.files.preview.failed": "فشل تحميل المعاينة.",+ "agentDetail.configure.files.preview.truncated": "يُعرض جزء البداية فقط من هذا الملف.","agentDetail.configure.files.preview.unsupported": "هذا الملف لا يدعم المعاينة.","agentDetail.configure.files.remove": "إزالة {{name}}","agentDetail.configure.files.richTip": "للمواد المرجعية الأطول من أن تُلصق في Prompt: المواصفات، القوالب، الإرشادات. <docLink>تعرّف على المزيد</docLink>\n\nفي وضع Build، يمكن للوكيل إعدادها لك.",diff --git a/web/i18n/locales/az-AZ/agent-v-2.json b/web/i18n/locales/az-AZ/agent-v-2.jsonindex df68c2e18f0..a33ce670384 100644--- a/web/i18n/locales/az-AZ/agent-v-2.json+++ b/web/i18n/locales/az-AZ/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Fayl tapılmadı","agentDetail.configure.files.preview.empty": "Önbaxış məzmunu yoxdur.","agentDetail.configure.files.preview.failed": "Önbaxışı yükləmək mümkün olmadı.",+ "agentDetail.configure.files.preview.truncated": "Bu faylın yalnız başlanğıcı göstərilir.","agentDetail.configure.files.preview.unsupported": "Bu fayl üçün önbaxış dəstəklənmir.","agentDetail.configure.files.remove": "{{name}} faylını çıxar","agentDetail.configure.files.richTip": "Təlimata yerləşdirmək üçün həddindən artıq uzun olan istinad materialları: spesifikasiyalar, şablonlar, göstərişlər. <docLink>Ətraflı öyrən</docLink>\n\nQurma rejimində agent bunları sizin üçün hazırlaya bilər.",diff --git a/web/i18n/locales/de-DE/agent-v-2.json b/web/i18n/locales/de-DE/agent-v-2.jsonindex 29c7b871a5f..b713e479146 100644--- a/web/i18n/locales/de-DE/agent-v-2.json+++ b/web/i18n/locales/de-DE/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Datei nicht gefunden","agentDetail.configure.files.preview.empty": "Kein Vorschauinhalt.","agentDetail.configure.files.preview.failed": "Vorschau konnte nicht geladen werden.",+ "agentDetail.configure.files.preview.truncated": "Es wird nur der Anfang dieser Datei angezeigt.","agentDetail.configure.files.preview.unsupported": "Für diese Datei wird keine Vorschau unterstützt.","agentDetail.configure.files.remove": "{{name}} entfernen","agentDetail.configure.files.richTip": "Für Referenzmaterial, das zu lang zum Einfügen in den Prompt ist: Spezifikationen, Vorlagen, Richtlinien. <docLink>Mehr erfahren</docLink>\n\nIm Build-Modus kann der Agent diese Einrichtung für Sie übernehmen.",diff --git a/web/i18n/locales/en-US/agent-v-2.json b/web/i18n/locales/en-US/agent-v-2.jsonindex 71a54e1e3b5..6fcc320f460 100644--- a/web/i18n/locales/en-US/agent-v-2.json+++ b/web/i18n/locales/en-US/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "File not found","agentDetail.configure.files.preview.empty": "No preview content.","agentDetail.configure.files.preview.failed": "Failed to load preview.",+ "agentDetail.configure.files.preview.truncated": "Only the beginning of this file is shown.","agentDetail.configure.files.preview.unsupported": "Preview is not supported for this file.","agentDetail.configure.files.remove": "Remove {{name}}","agentDetail.configure.files.richTip": "For reference material too long to paste into the Prompt: specs, templates, guidelines. <docLink>Learn more</docLink>\n\nIn Build mode, the agent can set these up for you.",diff --git a/web/i18n/locales/es-ES/agent-v-2.json b/web/i18n/locales/es-ES/agent-v-2.jsonindex bafbf27ef4f..b06237125cc 100644--- a/web/i18n/locales/es-ES/agent-v-2.json+++ b/web/i18n/locales/es-ES/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Archivo no encontrado","agentDetail.configure.files.preview.empty": "Sin contenido de vista previa.","agentDetail.configure.files.preview.failed": "Error al cargar la vista previa.",+ "agentDetail.configure.files.preview.truncated": "Solo se muestra el comienzo de este archivo.","agentDetail.configure.files.preview.unsupported": "Este archivo no admite vista previa.","agentDetail.configure.files.remove": "Eliminar {{name}}","agentDetail.configure.files.richTip": "Para material de referencia demasiado largo para pegar en el Prompt: especificaciones, plantillas, guías. <docLink>Más información</docLink>\n\nEn modo Build, el agente puede configurarlos por ti.",diff --git a/web/i18n/locales/fa-IR/agent-v-2.json b/web/i18n/locales/fa-IR/agent-v-2.jsonindex 2cedb8ad08b..83cc6fbccfc 100644--- a/web/i18n/locales/fa-IR/agent-v-2.json+++ b/web/i18n/locales/fa-IR/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "فایل یافت نشد","agentDetail.configure.files.preview.empty": "محتوای پیشنمایش وجود ندارد.","agentDetail.configure.files.preview.failed": "بارگذاری پیشنمایش ناموفق بود.",+ "agentDetail.configure.files.preview.truncated": "فقط ابتدای این فایل نمایش داده میشود.","agentDetail.configure.files.preview.unsupported": "این فایل از پیشنمایش پشتیبانی نمیکند.","agentDetail.configure.files.remove": "حذف {{name}}","agentDetail.configure.files.richTip": "برای منابع مرجعی که برای چسباندن در Prompt بیش از حد طولانیاند: مشخصات، قالبها، دستورالعملها. <docLink>بیشتر بدانید</docLink>\n\nدر حالت Build، عامل میتواند این موارد را برای شما تنظیم کند.",diff --git a/web/i18n/locales/fr-FR/agent-v-2.json b/web/i18n/locales/fr-FR/agent-v-2.jsonindex e6e1c14f5dd..352911db9de 100644--- a/web/i18n/locales/fr-FR/agent-v-2.json+++ b/web/i18n/locales/fr-FR/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Fichier introuvable","agentDetail.configure.files.preview.empty": "Aucun contenu d’aperçu.","agentDetail.configure.files.preview.failed": "Échec du chargement de l’aperçu.",+ "agentDetail.configure.files.preview.truncated": "Seul le début de ce fichier est affiché.","agentDetail.configure.files.preview.unsupported": "Ce fichier ne prend pas en charge l’aperçu.","agentDetail.configure.files.remove": "Supprimer {{name}}","agentDetail.configure.files.richTip": "Pour les documents de référence trop longs à coller dans le Prompt : spécifications, modèles, consignes. <docLink>En savoir plus</docLink>\n\nEn mode Build, l'agent peut les configurer pour vous.",diff --git a/web/i18n/locales/hi-IN/agent-v-2.json b/web/i18n/locales/hi-IN/agent-v-2.jsonindex dd17bc74d97..08779ef806c 100644--- a/web/i18n/locales/hi-IN/agent-v-2.json+++ b/web/i18n/locales/hi-IN/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "फ़ाइल नहीं मिली","agentDetail.configure.files.preview.empty": "कोई पूर्वावलोकन सामग्री नहीं।","agentDetail.configure.files.preview.failed": "पूर्वावलोकन लोड करने में विफल।",+ "agentDetail.configure.files.preview.truncated": "इस फ़ाइल का केवल शुरुआती भाग दिखाया गया है।","agentDetail.configure.files.preview.unsupported": "यह फ़ाइल पूर्वावलोकन का समर्थन नहीं करती।","agentDetail.configure.files.remove": "{{name}} हटाएँ","agentDetail.configure.files.richTip": "Prompt में चिपकाने के लिए बहुत लंबी संदर्भ सामग्री के लिए: स्पेक्स, टेम्पलेट, दिशानिर्देश। <docLink>ज़्यादा जानें</docLink>\n\nBuild mode में, एजेंट इन्हें आपके लिए सेट कर सकता है।",diff --git a/web/i18n/locales/id-ID/agent-v-2.json b/web/i18n/locales/id-ID/agent-v-2.jsonindex e00c7fa03cd..31fe5a0f064 100644--- a/web/i18n/locales/id-ID/agent-v-2.json+++ b/web/i18n/locales/id-ID/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "File tidak ditemukan","agentDetail.configure.files.preview.empty": "Tidak ada konten pratinjau.","agentDetail.configure.files.preview.failed": "Gagal memuat pratinjau.",+ "agentDetail.configure.files.preview.truncated": "Hanya bagian awal file ini yang ditampilkan.","agentDetail.configure.files.preview.unsupported": "File ini tidak mendukung pratinjau.","agentDetail.configure.files.remove": "Hapus {{name}}","agentDetail.configure.files.richTip": "Untuk materi referensi yang terlalu panjang untuk ditempel ke Prompt: spesifikasi, templat, panduan. <docLink>Pelajari selengkapnya</docLink>\n\nDalam mode Build, agen dapat menyiapkannya untuk Anda.",diff --git a/web/i18n/locales/it-IT/agent-v-2.json b/web/i18n/locales/it-IT/agent-v-2.jsonindex 20d76e55f9c..5a2c9483f95 100644--- a/web/i18n/locales/it-IT/agent-v-2.json+++ b/web/i18n/locales/it-IT/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "File non trovato","agentDetail.configure.files.preview.empty": "Nessun contenuto in anteprima.","agentDetail.configure.files.preview.failed": "Impossibile caricare l’anteprima.",+ "agentDetail.configure.files.preview.truncated": "Viene mostrato solo l'inizio di questo file.","agentDetail.configure.files.preview.unsupported": "Questo file non supporta l’anteprima.","agentDetail.configure.files.remove": "Rimuovi {{name}}","agentDetail.configure.files.richTip": "Per materiale di riferimento troppo lungo da incollare nel Prompt: specifiche, modelli, linee guida. <docLink>Scopri di più</docLink>\n\nIn modalità Build, l'agente può configurarli per te.",diff --git a/web/i18n/locales/ja-JP/agent-v-2.json b/web/i18n/locales/ja-JP/agent-v-2.jsonindex e7588d66497..9dac8498fd1 100644--- a/web/i18n/locales/ja-JP/agent-v-2.json+++ b/web/i18n/locales/ja-JP/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "ファイルが見つかりません","agentDetail.configure.files.preview.empty": "プレビュー内容はありません。","agentDetail.configure.files.preview.failed": "プレビューの読み込みに失敗しました。",+ "agentDetail.configure.files.preview.truncated": "このファイルの先頭部分のみ表示しています。","agentDetail.configure.files.preview.unsupported": "ファイルはプレビューに対応していません。","agentDetail.configure.files.remove": "{{name}} を削除","agentDetail.configure.files.richTip": "Prompt に貼り付けるには長すぎる参考資料向けです: 仕様、テンプレート、ガイドライン。<docLink>詳細を見る</docLink>\n\nBuild モードでは、エージェントがこれらを設定できます。",diff --git a/web/i18n/locales/ko-KR/agent-v-2.json b/web/i18n/locales/ko-KR/agent-v-2.jsonindex fc88ffb2301..fd2c3602409 100644--- a/web/i18n/locales/ko-KR/agent-v-2.json+++ b/web/i18n/locales/ko-KR/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "파일을 찾을 수 없음","agentDetail.configure.files.preview.empty": "미리보기 내용이 없습니다.","agentDetail.configure.files.preview.failed": "미리보기를 불러오지 못했습니다.",+ "agentDetail.configure.files.preview.truncated": "이 파일의 앞부분만 표시됩니다.","agentDetail.configure.files.preview.unsupported": "이 파일은 미리보기를 지원하지 않습니다.","agentDetail.configure.files.remove": "{{name}} 제거","agentDetail.configure.files.richTip": "Prompt에 붙여넣기에는 너무 긴 참고 자료용입니다: 사양, 템플릿, 가이드라인. <docLink>자세히 알아보기</docLink>\n\nBuild mode에서는 에이전트가 이를 대신 설정할 수 있습니다.",diff --git a/web/i18n/locales/lo-LA/agent-v-2.json b/web/i18n/locales/lo-LA/agent-v-2.jsonindex 3c31f11a25a..3a4d276ebc8 100644--- a/web/i18n/locales/lo-LA/agent-v-2.json+++ b/web/i18n/locales/lo-LA/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "ບໍ່ພົບໄຟລ໌","agentDetail.configure.files.preview.empty": "ບໍ່ມີເນື້ອຫາຕົວຢ່າງ.","agentDetail.configure.files.preview.failed": "ໂຫຼດຕົວຢ່າງບໍ່ສຳເລັດ.",+ "agentDetail.configure.files.preview.truncated": "ສະແດງພຽງສ່ວນຕົ້ນຂອງໄຟລ໌ນີ້ເທົ່ານັ້ນ.","agentDetail.configure.files.preview.unsupported": "ບໍ່ຮອງຮັບການເບິ່ງຕົວຢ່າງສຳລັບໄຟລ໌ນີ້.","agentDetail.configure.files.remove": "ລຶບ {{name}} ອອກ","agentDetail.configure.files.richTip": "ສຳລັບເອກະສານອ້າງອີງທີ່ມີເນື້ອຫາຍາວເກີນໄປທີ່ຈະວາງລົງໃນ Prompt ເຊັ່ນ: ຂໍ້ກຳນົດ, ເທມເພຼດ, ຄຳແນະນຳ. <docLink>ຮຽນຮູ້ເພີ່ມເຕີມ</docLink>\n\nໃນໂໝດສ້າງ, ຕົວແທນສາມາດຕັ້ງຄ່າເຫຼົ່ານີ້ໃຫ້ທ່ານໄດ້.",diff --git a/web/i18n/locales/nl-NL/agent-v-2.json b/web/i18n/locales/nl-NL/agent-v-2.jsonindex 1cc140db612..af5d7cb401e 100644--- a/web/i18n/locales/nl-NL/agent-v-2.json+++ b/web/i18n/locales/nl-NL/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Bestand niet gevonden","agentDetail.configure.files.preview.empty": "Geen voorbeeldinhoud.","agentDetail.configure.files.preview.failed": "Laden van voorbeeld mislukt.",+ "agentDetail.configure.files.preview.truncated": "Alleen het begin van dit bestand wordt weergegeven.","agentDetail.configure.files.preview.unsupported": "Dit bestand ondersteunt geen voorbeeldweergave.","agentDetail.configure.files.remove": "{{name}} verwijderen","agentDetail.configure.files.richTip": "Voor referentiemateriaal dat te lang is om in de Prompt te plakken: specificaties, sjablonen, richtlijnen. <docLink>Meer informatie</docLink>\n\nIn de Build-modus kan de agent dit voor u instellen.",diff --git a/web/i18n/locales/pl-PL/agent-v-2.json b/web/i18n/locales/pl-PL/agent-v-2.jsonindex 03bbebfc11c..7bec24d434b 100644--- a/web/i18n/locales/pl-PL/agent-v-2.json+++ b/web/i18n/locales/pl-PL/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Nie znaleziono pliku","agentDetail.configure.files.preview.empty": "Brak treści podglądu.","agentDetail.configure.files.preview.failed": "Nie udało się załadować podglądu.",+ "agentDetail.configure.files.preview.truncated": "Wyświetlany jest tylko początek tego pliku.","agentDetail.configure.files.preview.unsupported": "Ten plik nie obsługuje podglądu.","agentDetail.configure.files.remove": "Usuń {{name}}","agentDetail.configure.files.richTip": "Dla materiałów referencyjnych zbyt długich do wklejenia w Prompt: specyfikacje, szablony, wytyczne. <docLink>Dowiedz się więcej</docLink>\n\nW trybie Build agent może skonfigurować je za Ciebie.",diff --git a/web/i18n/locales/pt-BR/agent-v-2.json b/web/i18n/locales/pt-BR/agent-v-2.jsonindex 2ae622e42e7..6fd18905e7a 100644--- a/web/i18n/locales/pt-BR/agent-v-2.json+++ b/web/i18n/locales/pt-BR/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Arquivo não encontrado","agentDetail.configure.files.preview.empty": "Sem conteúdo de pré-visualização.","agentDetail.configure.files.preview.failed": "Falha ao carregar a pré-visualização.",+ "agentDetail.configure.files.preview.truncated": "Somente o início deste arquivo é exibido.","agentDetail.configure.files.preview.unsupported": "Este arquivo não oferece suporte à pré-visualização.","agentDetail.configure.files.remove": "Remover {{name}}","agentDetail.configure.files.richTip": "Para materiais de referência longos demais para colar no Prompt: especificações, modelos, diretrizes. <docLink>Saiba mais</docLink>\n\nNo modo Build, o agente pode configurar isso para você.",diff --git a/web/i18n/locales/ro-RO/agent-v-2.json b/web/i18n/locales/ro-RO/agent-v-2.jsonindex 649b8f7c3fd..fbc3bc18f85 100644--- a/web/i18n/locales/ro-RO/agent-v-2.json+++ b/web/i18n/locales/ro-RO/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Fișierul nu a fost găsit","agentDetail.configure.files.preview.empty": "Niciun conținut de previzualizat.","agentDetail.configure.files.preview.failed": "Încărcarea previzualizării a eșuat.",+ "agentDetail.configure.files.preview.truncated": "Este afișat doar începutul acestui fișier.","agentDetail.configure.files.preview.unsupported": "Acest fișier nu acceptă previzualizarea.","agentDetail.configure.files.remove": "Elimină {{name}}","agentDetail.configure.files.richTip": "Pentru materiale de referință prea lungi pentru a fi lipite în Prompt: specificații, șabloane, ghiduri. <docLink>Aflați mai multe</docLink>\n\nÎn modul Build, agentul le poate configura pentru dvs.",diff --git a/web/i18n/locales/ru-RU/agent-v-2.json b/web/i18n/locales/ru-RU/agent-v-2.jsonindex 783533837ca..633ce72245f 100644--- a/web/i18n/locales/ru-RU/agent-v-2.json+++ b/web/i18n/locales/ru-RU/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Файл не найден","agentDetail.configure.files.preview.empty": "Нет содержимого для предпросмотра.","agentDetail.configure.files.preview.failed": "Не удалось загрузить предпросмотр.",+ "agentDetail.configure.files.preview.truncated": "Показано только начало этого файла.","agentDetail.configure.files.preview.unsupported": "Этот файл не поддерживает предварительный просмотр.","agentDetail.configure.files.remove": "Удалить {{name}}","agentDetail.configure.files.richTip": "Для справочных материалов, которые слишком длинные для вставки в Prompt: спецификации, шаблоны, инструкции. <docLink>Подробнее</docLink>\n\nВ режиме Build агент может настроить это за вас.",diff --git a/web/i18n/locales/sl-SI/agent-v-2.json b/web/i18n/locales/sl-SI/agent-v-2.jsonindex 8d978e9d43b..5df2535b6e4 100644--- a/web/i18n/locales/sl-SI/agent-v-2.json+++ b/web/i18n/locales/sl-SI/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Datoteka ni bila najdena","agentDetail.configure.files.preview.empty": "Ni vsebine za predogled.","agentDetail.configure.files.preview.failed": "Predogleda ni bilo mogoče naložiti.",+ "agentDetail.configure.files.preview.truncated": "Prikazan je samo začetek te datoteke.","agentDetail.configure.files.preview.unsupported": "Ta datoteka ne podpira predogleda.","agentDetail.configure.files.remove": "Odstrani {{name}}","agentDetail.configure.files.richTip": "Za referenčno gradivo, ki je predolgo za lepljenje v Prompt: specifikacije, predloge, smernice. <docLink>Več o tem</docLink>\n\nV načinu Build jih lahko agent nastavi namesto vas.",diff --git a/web/i18n/locales/th-TH/agent-v-2.json b/web/i18n/locales/th-TH/agent-v-2.jsonindex 61047a1cfd8..4bf9c970be4 100644--- a/web/i18n/locales/th-TH/agent-v-2.json+++ b/web/i18n/locales/th-TH/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "ไม่พบไฟล์","agentDetail.configure.files.preview.empty": "ไม่มีเนื้อหาสำหรับแสดงตัวอย่าง","agentDetail.configure.files.preview.failed": "โหลดตัวอย่างไม่สำเร็จ",+ "agentDetail.configure.files.preview.truncated": "แสดงเฉพาะส่วนต้นของไฟล์นี้","agentDetail.configure.files.preview.unsupported": "ไฟล์นี้ไม่รองรับการแสดงตัวอย่าง","agentDetail.configure.files.remove": "ลบ {{name}}","agentDetail.configure.files.richTip": "สำหรับเอกสารอ้างอิงที่ยาวเกินกว่าจะวางใน Prompt: สเปก เทมเพลต แนวทาง <docLink>ดูข้อมูลเพิ่มเติม</docLink>\n\nในโหมด Build agent สามารถตั้งค่าสิ่งเหล่านี้ให้คุณได้",diff --git a/web/i18n/locales/tr-TR/agent-v-2.json b/web/i18n/locales/tr-TR/agent-v-2.jsonindex 29ee287e55c..be16312c15f 100644--- a/web/i18n/locales/tr-TR/agent-v-2.json+++ b/web/i18n/locales/tr-TR/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Dosya bulunamadı","agentDetail.configure.files.preview.empty": "Önizleme içeriği yok.","agentDetail.configure.files.preview.failed": "Önizleme yüklenemedi.",+ "agentDetail.configure.files.preview.truncated": "Bu dosyanın yalnızca başlangıcı gösteriliyor.","agentDetail.configure.files.preview.unsupported": "Bu dosya önizlemeyi desteklemiyor.","agentDetail.configure.files.remove": "{{name}} kaldır","agentDetail.configure.files.richTip": "Prompt içine yapıştırmak için fazla uzun olan referans materyalleri için: teknik özellikler, şablonlar, yönergeler. <docLink>Daha fazla bilgi</docLink>\n\nBuild mode'da agent bunları sizin için ayarlayabilir.",diff --git a/web/i18n/locales/uk-UA/agent-v-2.json b/web/i18n/locales/uk-UA/agent-v-2.jsonindex 2307ec689f4..bc7de8a5411 100644--- a/web/i18n/locales/uk-UA/agent-v-2.json+++ b/web/i18n/locales/uk-UA/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Файл не знайдено","agentDetail.configure.files.preview.empty": "Немає вмісту для перегляду.","agentDetail.configure.files.preview.failed": "Не вдалося завантажити перегляд.",+ "agentDetail.configure.files.preview.truncated": "Показано лише початок цього файлу.","agentDetail.configure.files.preview.unsupported": "Попередній перегляд цього файлу не підтримується.","agentDetail.configure.files.remove": "Видалити {{name}}","agentDetail.configure.files.richTip": "Для довідкових матеріалів, які занадто довгі для вставлення в Prompt: специфікації, шаблони, інструкції. <docLink>Докладніше</docLink>\n\nУ режимі Build агент може налаштувати це за вас.",diff --git a/web/i18n/locales/vi-VN/agent-v-2.json b/web/i18n/locales/vi-VN/agent-v-2.jsonindex 6553c66bb11..50a39375165 100644--- a/web/i18n/locales/vi-VN/agent-v-2.json+++ b/web/i18n/locales/vi-VN/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "Không tìm thấy tệp","agentDetail.configure.files.preview.empty": "Không có nội dung xem trước.","agentDetail.configure.files.preview.failed": "Tải xem trước thất bại.",+ "agentDetail.configure.files.preview.truncated": "Chỉ hiển thị phần đầu của tệp này.","agentDetail.configure.files.preview.unsupported": "Tệp này không hỗ trợ xem trước.","agentDetail.configure.files.remove": "Xóa {{name}}","agentDetail.configure.files.richTip": "Dành cho tài liệu tham khảo quá dài để dán vào Prompt: thông số, mẫu, hướng dẫn. <docLink>Tìm hiểu thêm</docLink>\n\nỞ chế độ Build, tác nhân có thể thiết lập những mục này cho bạn.",diff --git a/web/i18n/locales/zh-Hans/agent-v-2.json b/web/i18n/locales/zh-Hans/agent-v-2.jsonindex 172d97ff1a4..3a58fc3da3a 100644--- a/web/i18n/locales/zh-Hans/agent-v-2.json+++ b/web/i18n/locales/zh-Hans/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "未找到文件","agentDetail.configure.files.preview.empty": "暂无预览内容。","agentDetail.configure.files.preview.failed": "预览加载失败。",+ "agentDetail.configure.files.preview.truncated": "仅显示该文件的开头部分。","agentDetail.configure.files.preview.unsupported": "该文件不支持预览。","agentDetail.configure.files.remove": "移除 {{name}}","agentDetail.configure.files.richTip": "上传过长、不适合放入提示词的参考资料:规格、模板、指南。<docLink>了解更多</docLink>\n\n在构建模式中,Agent 可帮你完成这些设置。",diff --git a/web/i18n/locales/zh-Hant/agent-v-2.json b/web/i18n/locales/zh-Hant/agent-v-2.jsonindex 35f999fa71c..9326989edbf 100644--- a/web/i18n/locales/zh-Hant/agent-v-2.json+++ b/web/i18n/locales/zh-Hant/agent-v-2.json@@ -99,6 +99,7 @@"agentDetail.configure.files.missing": "找不到檔案","agentDetail.configure.files.preview.empty": "暫無預覽內容。","agentDetail.configure.files.preview.failed": "預覽載入失敗。",+ "agentDetail.configure.files.preview.truncated": "僅顯示此檔案的開頭部分。","agentDetail.configure.files.preview.unsupported": "此檔案不支援預覽。","agentDetail.configure.files.remove": "移除 {{name}}","agentDetail.configure.files.richTip": "上傳過長、不適合放入提示詞的參考資料:規格、範本、指南。<docLink>了解更多</docLink>\n\n在建置模式中,Agent 可幫你完成這些設定。",diff --git a/web/i18n/resources.generated.d.ts b/web/i18n/resources.generated.d.tsindex 343c3a7ac19..81cbde4133d 100644--- a/web/i18n/resources.generated.d.ts+++ b/web/i18n/resources.generated.d.ts@@ -261,6 +261,7 @@ export default interface Resources {'agentDetail.configure.files.missing': 'File not found''agentDetail.configure.files.preview.empty': 'No preview content.''agentDetail.configure.files.preview.failed': 'Failed to load preview.'+ 'agentDetail.configure.files.preview.truncated': 'Only the beginning of this file is shown.''agentDetail.configure.files.preview.unsupported': 'Preview is not supported for this file.''agentDetail.configure.files.remove': 'Remove {{name}}''agentDetail.configure.files.richTip': 'For reference material too long to paste into the Prompt: specs, templates, guidelines. <docLink>Learn more</docLink>\n\nIn Build mode, the agent can set these up for you.'