diff --git a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts index a41fe5b0..3029d1a0 100644 --- a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts +++ b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts @@ -325,11 +325,16 @@ export const useFileBrowserApp = (basePath: string, rootOverride?: string, urlPa }; /** - * Create an empty file and open it in the editor. + * Create an empty file. That is all it does. + * + * It used to navigate straight into `/code-editor`, which made "New file" the one action in the browser + * that took you somewhere else. Creating a folder does not leave the folder; uploading does not open + * what you uploaded. Now this behaves like both: the file appears in the listing, and editing it is the + * same double-click that opens anything else — the viewer's pane has an editor in it. * * The name is taken whole, extension and all — `notes.txt`, `deploy.sh`, `.env`, `Makefile` — because - * the extension is what the editor uses to pick a language, and guessing one for the user would be - * wrong more often than not. No extension is fine too; that file simply opens as plain text. + * the extension is what picks the language, and guessing one for the user would be wrong more often + * than not. No extension is fine; that file opens as plain text. * * Refuses to clobber. `/write` is an overwrite, so creating over an existing name would silently empty * it — the one outcome nobody wants from a menu item called "New file". The check is a `read` because @@ -348,7 +353,6 @@ export const useFileBrowserApp = (basePath: string, rootOverride?: string, urlPa await files.writeFile(filePath, ''); await refresh(); toast.success(`Created "${name}"`); - navigate(`/code-editor?${EDITOR_FILE_PARAM}=${encodeURIComponent(filePath)}`); } catch { toast.error('Failed to create file'); } diff --git a/src/workspaces/officerdev/src/apps/FileViewer/FileViewerHeader.tsx b/src/workspaces/officerdev/src/apps/FileViewer/FileViewerHeader.tsx index cf199935..4a49d2bc 100644 --- a/src/workspaces/officerdev/src/apps/FileViewer/FileViewerHeader.tsx +++ b/src/workspaces/officerdev/src/apps/FileViewer/FileViewerHeader.tsx @@ -1,4 +1,19 @@ -import { Download, Loader2, Music, Film, Image, FileType2, Volume2, ScanText, FileText, AudioLines, FolderArchive, Save, Pencil, Eye } from 'lucide-react'; +import { + Download, + Loader2, + Music, + Film, + Image, + FileType2, + Volume2, + ScanText, + FileText, + AudioLines, + FolderArchive, + Save, + Pencil, + Eye, +} from 'lucide-react'; import { getIcon } from 'material-file-icons'; import { getLang } from './file-types'; import { useFileViewer } from './FileViewerContext'; @@ -49,7 +64,10 @@ export const FileViewerHeader = () => { {fileType === 'code' ? getLang(fileName) : fileType} - {editable && content && ( + {/* `content !== null`, NOT `content` — an empty file is the empty string, which is falsy, so a + file with nothing in it had no way to start editing. That is precisely the file you most want + to edit, and it is what "New file" produces. The body already got this right. */} + {editable && content !== null && ( )} {fileType === 'archive' && ( @@ -105,7 +127,11 @@ export const FileViewerHeader = () => { className="p-1 rounded hover:bg-current/10 disabled:opacity-40 transition-colors cursor-pointer" title="Extract" > - {extractLoading ? : } + {extractLoading ? ( + + ) : ( + + )} )} {handleSaveResult && (