mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-05-09 00:20:09 +00:00
add new md content
This commit is contained in:
52
src/components/chat-view/MarkdownListFilesBlock.tsx
Normal file
52
src/components/chat-view/MarkdownListFilesBlock.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { FolderOpen } from 'lucide-react'
|
||||
import React from 'react'
|
||||
|
||||
import { useApp } from '../../contexts/AppContext'
|
||||
import { ApplyStatus, ListFilesToolArgs } from '../../types/apply'
|
||||
import { openMarkdownFile } from '../../utils/obsidian'
|
||||
|
||||
export default function MarkdownListFilesBlock({
|
||||
applyStatus,
|
||||
onApply,
|
||||
path,
|
||||
recursive,
|
||||
finish
|
||||
}: {
|
||||
applyStatus: ApplyStatus
|
||||
onApply: (args: ListFilesToolArgs) => void
|
||||
path: string,
|
||||
recursive: boolean,
|
||||
finish: boolean
|
||||
}) {
|
||||
const app = useApp()
|
||||
|
||||
const handleClick = () => {
|
||||
openMarkdownFile(app, path)
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
console.log('finish', finish, applyStatus)
|
||||
if (finish && applyStatus === ApplyStatus.Idle) {
|
||||
console.log('finish auto list files', path)
|
||||
onApply({
|
||||
type: 'list_files',
|
||||
filepath: path,
|
||||
recursive
|
||||
})
|
||||
}
|
||||
}, [finish])
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`infio-chat-code-block ${path ? 'has-filename' : ''}`}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<div className={'infio-chat-code-block-header'}>
|
||||
<div className={'infio-chat-code-block-header-filename'}>
|
||||
<FolderOpen size={14} className="infio-chat-code-block-header-icon" />
|
||||
List files: {path}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user