Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion electron/main/ipc-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ipcMain, BrowserWindow, dialog, app } from 'electron'
import { ipcMain, BrowserWindow, dialog, app, shell } from 'electron'
import { autoUpdater } from 'electron-updater'
import { join } from 'path'
import { rm as rmAsync, readFile, writeFile, mkdir, readdir, rename, cp } from 'fs/promises'
Expand Down Expand Up @@ -158,6 +158,13 @@ export function setupIpcHandlers(pythonBridge: PythonBridge, getWindow: WindowGe
}
})

ipcMain.handle('model:showInFolder', (_, modelId: string) => {
const modelDir = join(getSettings(app.getPath('userData')).modelsDir, modelId)
if (existsSync(modelDir)) {
shell.openPath(modelDir)
}
})

// Read local file → base64 (bypasses file:// restrictions in the renderer)
ipcMain.handle('fs:readFileBase64', async (_, filePath: string) => {
const buffer = await readFile(filePath)
Expand Down
1 change: 1 addition & 0 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ contextBridge.exposeInMainWorld('electron', {
download: (repoId: string, modelId: string, skipPrefixes?: string[]) => ipcRenderer.invoke('model:download', { repoId, modelId, skipPrefixes }),
delete: (modelId: string) => ipcRenderer.invoke('model:delete', modelId),
unloadAll: () => ipcRenderer.invoke('model:unloadAll'),
showInFolder: (modelId: string) => ipcRenderer.invoke('model:showInFolder', modelId),
onProgress: (cb: (data: { modelId: string; percent: number; file?: string; fileIndex?: number; totalFiles?: number; status?: string }) => void) => {
ipcRenderer.on('model:downloadProgress', (_event, data) => cb(data))
},
Expand Down
15 changes: 13 additions & 2 deletions src/areas/models/components/ModelCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ interface Props {

export function ModelCard({ model, onDelete, onGenerate, disabled }: Props): JSX.Element {
return (
<div className="flex flex-col gap-2 px-3.5 py-4 rounded-2xl border transition-all min-h-[110px] bg-zinc-900/60 border-zinc-800 hover:border-zinc-700">
<div className="relative flex flex-col gap-2 px-3.5 py-4 rounded-2xl border transition-all min-h-[110px] bg-zinc-900/60 border-zinc-800 hover:border-zinc-700">
{/* Open in explorer */}
<button
onClick={() => window.electron.model.showInFolder(model.id)}
title="Show in explorer"
className="absolute top-2.5 right-2.5 flex items-center justify-center w-6 h-6 rounded-lg text-zinc-600 hover:text-zinc-300 hover:bg-zinc-700/60 transition-all"
>
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
</svg>
</button>

{/* Name */}
<p className="text-xs font-semibold leading-tight truncate text-zinc-200">
<p className="text-xs font-semibold leading-tight truncate text-zinc-200 pr-6">
{formatModelName(model.id)}
</p>

Expand Down
1 change: 1 addition & 0 deletions src/shared/types/electron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ declare global {
download: (repoId: string, modelId: string, skipPrefixes?: string[]) => Promise<{ success: boolean; error?: string }>
delete: (modelId: string) => Promise<{ success: boolean; error?: string }>
unloadAll: () => Promise<{ success: boolean; error?: string }>
showInFolder: (modelId: string) => Promise<void>
onProgress: (cb: (data: { modelId: string; percent: number; file?: string; fileIndex?: number; totalFiles?: number; status?: string }) => void) => void
offProgress: () => void
}
Expand Down