From c175d734d7330fe4f75468e4801fc6565ae77823 Mon Sep 17 00:00:00 2001 From: Bonchellon Date: Wed, 8 Jul 2026 09:43:33 +0300 Subject: [PATCH] =?UTF-8?q?0.2.4=20=E2=80=94=20fix=20code-editor=20white?= =?UTF-8?q?=20screen,=20rename=20package=20to=20"Exbyte=20Depot"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix critical crash: opening the built-in code editor blanked the whole app (white screen). The editing early-return sat above the syntax-highlight useMemo, so entering edit mode changed the hook count and React tore down the tree (Rules of Hooks violation). Moved all hooks above the early returns. - Diff-vs-previous button is now shown only for text/code files, not binaries (p4 diff2 on a .uasset only prints "files differ", which is useless). - Package renamed to "Exbyte Depot" (productName + mainBinaryName); identifier unchanged so existing installs upgrade in place. Co-Authored-By: Claude Opus 4.8 --- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 5 +++-- src/App.tsx | 2 +- src/CodeView.tsx | 16 +++++++++------- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index cf073b7..d38df1b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "exbyte-depot", "private": true, - "version": "0.2.3", + "version": "0.2.4", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e713883..f1f8f70 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -960,7 +960,7 @@ dependencies = [ [[package]] name = "exbyte-depot" -version = "0.2.2" +version = "0.2.3" dependencies = [ "encoding_rs", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d1a23d2..eb5d2ae 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "exbyte-depot" -version = "0.2.3" +version = "0.2.4" description = "Exbyte Depot — native Perforce client by Exbyte Studios" authors = ["Exbyte Studios"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 523f5ae..df0472c 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,8 @@ { "$schema": "https://schema.tauri.app/config/2", - "productName": "exbyte-depot", - "version": "0.2.3", + "productName": "Exbyte Depot", + "mainBinaryName": "Exbyte Depot", + "version": "0.2.4", "identifier": "com.bonchellon.exbyte-depot", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/App.tsx b/src/App.tsx index a35c35a..6caf7c0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2209,7 +2209,7 @@ function Preview({ file, onRevert, onFlash, editorId, editorName, onBlame, onDif {codeFile && onBlame && ( onBlame(spec || dp, name)}>{I.people} )} - {hist && onDiffPrev && ( + {hist && onDiffPrev && codeFile && ( onDiffPrev(file)}>{I.clock} )} {!hist && onRevert(file)}>{I.revert}{t("Revert")}} diff --git a/src/CodeView.tsx b/src/CodeView.tsx index 772a387..640fe75 100644 --- a/src/CodeView.tsx +++ b/src/CodeView.tsx @@ -96,6 +96,15 @@ export default function CodeView({ file, onFlash }: { file: OpenedFile; onFlash? } const pencil = ; + // NB: all hooks must run before any early return (Rules of Hooks) — compute + // the highlighted body here, above the editing/diff/error returns below. + const lang = langOf(name); + const highlighted = useMemo(() => { + if (code == null) return ""; + try { return lang ? hljs.highlight(code, { language: lang, ignoreIllegals: true }).value : esc(code); } + catch { return esc(code); } + }, [code, lang]); + // editing mode — plain textarea over the working copy if (editing) { return ( @@ -125,13 +134,6 @@ export default function CodeView({ file, onFlash }: { file: OpenedFile; onFlash? ); } - const lang = langOf(name); - const highlighted = useMemo(() => { - if (code == null) return ""; - try { return lang ? hljs.highlight(code, { language: lang, ignoreIllegals: true }).value : esc(code); } - catch { return esc(code); } - }, [code, lang]); - if (err === "binary") return
{t("Binary file — no code preview.")}
; if (err) return
{err}
; if (tooBig) return
{t("File is too large to preview.")}
;