{ if (deleteTarget) { if (deleteTarget.path === '__bulk__') { bulkDelete(); } else { handleDelete(deleteTarget.path, deleteTarget.name); } deleteTarget = null; } }} /> { if (!active) return; if (event.key === 'Escape' && fileAsk) { fileAsk = null; event.preventDefault(); } else handleKeydown(event); }} on:click={handleWindowClick} on:pointerdown={(event) => { if (fileAsk && !dirtyChoice && !(event.target as Element)?.closest('[data-file-ask]')) fileAsk = null; }} /> {#if comparison} {#key comparison} {/key} {/if} {#if terminalChatContextHidden} {:else if terminalChatContextPending}
{$i18n.t('Start the chat to use this terminal.')}
{:else if !selectedTerminal}
{$i18n.t('No Terminal connection configured.')}
{$i18n.t('Add your Open Terminal URL and API key in Settings → Integrations.')}
{:else}
!isSearching && handleDragOver(e)} on:dragleave={(e) => { if (!(e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget))) { isDragOver = false; } }} on:drop={(e) => !isSearching && handleDrop(e)} role="region" aria-label={$i18n.t('File browser')} tabindex="-1" > {#if isDragOver && !isSearching}
{$i18n.t('Drop to upload')}
{/if} {#if previewPort === null} { if (selectedFile) { const fileName = selectedFile.split('/').pop() ?? ''; openEntry({ name: fileName, type: 'file', size: 0 }); } else { refreshBrowser(); } }} onNewFolder={startNewFolder} onNewFile={startNewFile} onUploadFiles={handleUploadFiles} onUploadFolder={() => openUploadPicker(true)} onDownloadDir={() => downloadFile(currentPath)} onMove={handleMovePaths} onSort={toggleSort} onToggleHidden={toggleHidden} > {#if (isMarkdown || isCsv || isHtml || isJson || isSvg || isNotebook) && fileContent !== null && !editing} {/if} {#if isTextFile} {#if isHtml && showRaw} {:else if isHtml} {:else if isMarkdown && showRaw} {:else if isMarkdown} {:else if isCode} {:else if editing} {:else} {/if} {/if} {#if fileContent !== null} {/if} {#if !selectedFile && showSearch}
{ if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); void toggleSearch(); } }} /> {#if searchQuery} {/if}
{/if} {#if pinnedComparison}
{$i18n.t('Comparing with {{name}}', { name: pinnedComparison.name })}
{/if} {#if selectedCount > 0 && !isSearching} { if (canCompare) openComparison([ comparisonFile(comparisonEntries[0]), comparisonFile(comparisonEntries[1]) ]); }} canDelete={selectedEntriesWritable} onDelete={() => { deleteTarget = { path: '__bulk__', name: `${selectedCount} items` }; showDeleteConfirm = true; }} onDownload={bulkDownload} onSelectAll={selectAll} onClear={clearSelection} /> {/if} {/if} {#if diskChanged}
{$i18n.t('File updated on disk. Your local changes are preserved.')}
{/if}
{ closeDirectoryMenu(); if (!comparison && e.target === e.currentTarget && selectedCount > 0) clearSelection(); }} on:contextmenu={(e) => { if (comparison || selectedFile || previewPort !== null || isSearching) return; if ((e.target as HTMLElement)?.closest('[data-file-row]')) return; e.preventDefault(); directoryMenu = { x: e.clientX, y: e.clientY }; }} > {#if previewPort !== null} { previewPort = null; }} /> {:else if selectedFile !== null} {#if supportsComments(selectedFile) && selectedTerminal} {#key `${selectedTerminal.url}|${selectedTerminal.key}|${chatId}|${selectedFile}|${commentGeneration}`} { openedFile = pendingFile; publishFile(); }} bind:currentSlide bind:sheet={selectedExcelSheet} /> {/key} {:else} (onOpenFile ? onOpenFile(path) : showFileNavPath.set({ path }))} bind:currentSlide {selectedFile} readOnly={!selectedFileWritable} {fileLoading} {fileImageUrl} {fileVideoUrl} {fileAudioUrl} {filePdfData} {fileSqliteData} {fileModelData} {fileDocxData} {fileContent} {fileOfficeHtml} {fileOfficeSlides} targetPage={documentTargetPage} {excelSheetNames} {selectedExcelSheet} searchTarget={fileSearchTarget} onSheetChange={async (sheet) => { if (!excelWorkbook) return; selectedExcelSheet = sheet; const { excelToTable } = await import('$lib/utils/excelToTable'); const result = await excelToTable(excelWorkbook.Sheets[sheet]); const DOMPurify = (await import('dompurify')).default; fileOfficeHtml = DOMPurify.sanitize(result.html); }} baseUrl={previewBaseUrl} apiKey={selectedTerminal?.key ?? ''} overlay={overlay || isDraggingHandle} onSave={saveFile} /> {/if} {:else} {#if isSearching} {#if matchLoading}
{:else if matchError}
{matchError}
{:else if !matchResults?.length}
{$i18n.t('No matches')}
{:else} {#if filenameMatches.length > 0}
{$i18n.t('Filename matches')}
{#each filenameMatches as match (match.path)} {#if match.content_matches.length > 0} {@const preview = match.content_matches[0]} {/if} {/each} {/if} {#if contentOnlyMatches.length > 0}
{$i18n.t('Content matches')}
{#each contentOnlyMatches as match (match.path)} {#if match.content_matches.length > 0} {@const preview = match.content_matches[0]} {/if} {/each} {/if} {#if nextMatchOffset !== null}
{#if matchLoadingMore} {:else if matchLoadMoreError} {/if}
{/if} {/if} {:else if uploading}
{$i18n.t('Uploading...')}
{:else if loading || (effectiveTerminalId && $terminalServers === null)}
{:else if error}
{error}
{:else if visibleEntries.length === 0 && !creatingFolder && !creatingFile}
{$i18n.t('This folder is empty')}
{/if} {#if !isSearching && !loading && !error && !uploading && !(effectiveTerminalId && $terminalServers === null)} {#if visibleEntries.length > 0 || creatingFolder || creatingFile}
    {#if creatingFolder}
  • {#if viewMode === 'grid'} {:else} {/if} { if (e.key === 'Enter') submitNewFolder(); if (e.key === 'Escape') { creatingFolder = false; newFolderName = ''; } }} on:blur={submitNewFolder} />
  • {/if} {#if creatingFile}
  • {#if viewMode === 'list'} {/if} { if (e.key === 'Enter') submitNewFile(); if (e.key === 'Escape') { creatingFile = false; newFileName = ''; } }} on:blur={submitNewFile} />
  • {/if} {#each visibleEntries as entry (entry.fullPath)} openEntry({ ...row, fullPath: entry.fullPath, parentPath: entry.parentPath, depth: entry.depth, rowIndex: entry.rowIndex })} onSelectForComparison={() => (pinnedComparison = comparisonFile(entry))} comparisonPath={pinnedComparison?.path ?? null} onCompareWithSelected={pinnedComparison ? () => { if (pinnedComparison) openComparison([pinnedComparison, comparisonFile(entry)]); } : undefined} onDownload={downloadFile} onNewFolder={startNewFolderIn} onNewFile={startNewFileIn} onDelete={requestDelete} onMove={handleMovePaths} onRename={handleRename} onSelect={handleSelect} onLongPress={enterSelectionMode} onToggleExpand={toggleExpand} showDate={sortBy === 'date' || sortBy === 'created'} dateField={sortBy === 'created' ? 'created' : 'modified'} {showHidden} parentWritable={currentWritable} /> {/each}
{/if} {/if} {/if}
{#if selectedTerminal && !selectedFile && previewPort === null && !isSearching}
{#key JSON.stringify([chatId, selectedTerminal.url])} { if (onOpenPort) { onOpenPort(e.detail, previewBaseUrl); return; } selectedFile = null; clearFilePreview(); previewPort = e.detail; }} /> {/key}
{/if} {#if showTerminalDock}
{#if terminalExpanded}
{/if} {#key JSON.stringify([chatId, effectiveTerminalId])} {/key}
{/if} { if (!currentWritable || !directoryUploadInput?.files?.length) return; await handleUploadFiles(Array.from(directoryUploadInput.files)); directoryUploadInput.value = ''; }} /> {#if directoryMenu}
{/if}
{/if} {#if fileAsk} {#key fileAsk.anchor}
{#if fileAsk.text}
{fileAsk.text}
{/if}