From 099ea1a98cfd3ae6b06a519e6d4192470f971dae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 00:13:01 +0000 Subject: [PATCH 1/3] Initial plan From 70505111888d433c67f1a26e97e8cc93ec3f0438 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 00:20:06 +0000 Subject: [PATCH 2/3] feat: add audio and video file playback support in Agent Folder Support playing multimedia files (audio: mp3, wav, ogg, flac, aac, m4a, wma; video: mp4, webm, ogv, mov, avi, mkv) using native HTML5 audio and video elements with controls, instead of showing raw binary content. Co-authored-by: lightaime <23632352+lightaime@users.noreply.github.com> --- electron/main/fileReader.ts | 18 +++++++++++++ src/components/Folder/index.tsx | 45 +++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/electron/main/fileReader.ts b/electron/main/fileReader.ts index adccf1782..79afb26fc 100644 --- a/electron/main/fileReader.ts +++ b/electron/main/fileReader.ts @@ -501,6 +501,24 @@ export class FileReader { resolve(content); } else if (['pdf'].includes(type)) { resolve(filePath); + } else if ( + [ + 'mp3', + 'wav', + 'ogg', + 'flac', + 'aac', + 'm4a', + 'wma', + 'mp4', + 'webm', + 'ogv', + 'mov', + 'avi', + 'mkv', + ].includes(type) + ) { + resolve(filePath); } else if (type === 'csv') { try { const htmlContent = await this.parseCsv(filePath); diff --git a/src/components/Folder/index.tsx b/src/components/Folder/index.tsx index 08476c699..ed378870f 100644 --- a/src/components/Folder/index.tsx +++ b/src/components/Folder/index.tsx @@ -221,8 +221,25 @@ export default function Folder({ data: _data }: { data?: Agent }) { setLoading(true); console.log('file', JSON.parse(JSON.stringify(file))); - // For PDF files, use data URL instead of custom protocol - if (file.type === 'pdf') { + // For PDF and audio/video files, use data URL instead of custom protocol + if ( + [ + 'pdf', + 'mp3', + 'wav', + 'ogg', + 'flac', + 'aac', + 'm4a', + 'wma', + 'mp4', + 'webm', + 'ogv', + 'mov', + 'avi', + 'mkv', + ].includes(file.type?.toLowerCase()) + ) { window.ipcRenderer .invoke('read-file-dataurl', file.path) .then((dataUrl: string) => { @@ -662,6 +679,30 @@ export default function Folder({ data: _data }: { data?: Agent }) {
{selectedFile.content}
From 571e82db82a176cfa5a4e79113ced174b827dbfe Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 9 Feb 2026 00:21:52 +0000
Subject: [PATCH 3/3] refactor: extract media extension constants to reduce
duplication
Co-authored-by: lightaime <23632352+lightaime@users.noreply.github.com>
---
src/components/Folder/index.tsx | 27 ++++----------
test/unit/electron/main/fileReader.test.ts | 42 ++++++++++++++++++++++
2 files changed, 49 insertions(+), 20 deletions(-)
diff --git a/src/components/Folder/index.tsx b/src/components/Folder/index.tsx
index ed378870f..e731cd541 100644
--- a/src/components/Folder/index.tsx
+++ b/src/components/Folder/index.tsx
@@ -60,6 +60,10 @@ interface FileInfo {
isRemote?: boolean;
}
+const AUDIO_EXTENSIONS = ['mp3', 'wav', 'ogg', 'flac', 'aac', 'm4a', 'wma'];
+const VIDEO_EXTENSIONS = ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv'];
+const MEDIA_EXTENSIONS = [...AUDIO_EXTENSIONS, ...VIDEO_EXTENSIONS];
+
// FileTree component to render nested file structure
interface FileTreeProps {
node: FileTreeNode;
@@ -222,24 +226,7 @@ export default function Folder({ data: _data }: { data?: Agent }) {
console.log('file', JSON.parse(JSON.stringify(file)));
// For PDF and audio/video files, use data URL instead of custom protocol
- if (
- [
- 'pdf',
- 'mp3',
- 'wav',
- 'ogg',
- 'flac',
- 'aac',
- 'm4a',
- 'wma',
- 'mp4',
- 'webm',
- 'ogv',
- 'mov',
- 'avi',
- 'mkv',
- ].includes(file.type?.toLowerCase())
- ) {
+ if (['pdf', ...MEDIA_EXTENSIONS].includes(file.type?.toLowerCase())) {
window.ipcRenderer
.invoke('read-file-dataurl', file.path)
.then((dataUrl: string) => {
@@ -679,7 +666,7 @@ export default function Folder({ data: _data }: { data?: Agent }) {
- ) : ['mp3', 'wav', 'ogg', 'flac', 'aac', 'm4a', 'wma'].includes(
+ ) : AUDIO_EXTENSIONS.includes(
selectedFile.type.toLowerCase()
) ? (
@@ -691,7 +678,7 @@ export default function Folder({ data: _data }: { data?: Agent }) {
{t('folder.audio-not-supported')}
- ) : ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv'].includes(
+ ) : VIDEO_EXTENSIONS.includes(
selectedFile.type.toLowerCase()
) ? (
diff --git a/test/unit/electron/main/fileReader.test.ts b/test/unit/electron/main/fileReader.test.ts
index c5ef79b6e..991ca1217 100644
--- a/test/unit/electron/main/fileReader.test.ts
+++ b/test/unit/electron/main/fileReader.test.ts
@@ -277,6 +277,48 @@ describe('File Operations and Utilities', () => {
});
});
+ describe('Multimedia File Type Detection', () => {
+ const audioExtensions = ['mp3', 'wav', 'ogg', 'flac', 'aac', 'm4a', 'wma'];
+ const videoExtensions = ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv'];
+ const mediaExtensions = [...audioExtensions, ...videoExtensions];
+
+ it('should recognize audio file extensions', () => {
+ audioExtensions.forEach((ext) => {
+ const filePath = `/path/to/file.${ext}`;
+ const fileExt = path.extname(filePath).slice(1);
+ expect(mediaExtensions).toContain(fileExt);
+ });
+ });
+
+ it('should recognize video file extensions', () => {
+ videoExtensions.forEach((ext) => {
+ const filePath = `/path/to/file.${ext}`;
+ const fileExt = path.extname(filePath).slice(1);
+ expect(mediaExtensions).toContain(fileExt);
+ });
+ });
+
+ it('should not treat non-media files as multimedia', () => {
+ const nonMediaExtensions = ['txt', 'json', 'csv', 'html', 'py', 'js'];
+ nonMediaExtensions.forEach((ext) => {
+ const isMedia = mediaExtensions.includes(ext);
+ expect(isMedia).toBe(false);
+ });
+ });
+
+ it('should distinguish audio from video extensions', () => {
+ audioExtensions.forEach((ext) => {
+ expect(audioExtensions).toContain(ext);
+ expect(videoExtensions).not.toContain(ext);
+ });
+
+ videoExtensions.forEach((ext) => {
+ expect(videoExtensions).toContain(ext);
+ expect(audioExtensions).not.toContain(ext);
+ });
+ });
+ });
+
describe('File Content Processing', () => {
it('should process text file content', () => {
const content = 'Line 1\nLine 2\nLine 3';