TypeScriptRustViteMindloft

4,000 Green Tests That Missed a 4.3 MB Font, and a Colon That Ate a Letter on Windows

While rebranding Brainlet to Mindloft and shipping v0.7.5 through v0.8.2 across web, macOS, Windows, and Android, three bugs slipped past thousands of unit tests and only broke inside real Vite production builds, Windows Path semantics, and CSP headers.

Mindloft (formerly Brainlet / 枝间) shipped its rebrand and v0.8.0–v0.8.2 previews this week across the web app (mindloft.cc/app/), signed macOS (0.8.1), Windows x64 (0.8.2), Android APK (0.8.0), and iOS TestFlight (0.7.4).

Along the way, three bugs slipped cleanly past 4,000+ passing unit tests and only showed up when hitting a real Vite bundle, a Windows drive prefix, or strict browser CSP headers.

1. Extracting import.meta.url Into const base Dropped a 4.3 MB Font (v0.7.5)

Hours after v0.7.4 went live, PDF export in the production web app threw a font-loading failure. apps/web/dist/assets/ had no RamiloCJKSans-Regular.ttf-*.gz (4,327,412 bytes), and the minified bundle still contained an unrewritten new URL("../assets/RamiloCJKSans-Regular.ttf.gz", e).

Commit 6f76fa9b had refactored resolveFontUrl() in packages/export/src/export-font.ts so the mobile esbuild IIFE bundle wouldn’t choke on import.meta.url:

const base =
  typeof import.meta !== 'undefined' && typeof import.meta.url === 'string'
    ? import.meta.url
    : undefined;
if (!base) {
  throw new Error('...');
}
return new URL('../assets/RamiloCJKSans-Regular.ttf.gz', base);

Vite 8’s assetImportMetaUrl plugin matches asset URLs statically with a regex that requires literal import.meta.url as the second argument of new URL(...). Assigning it to base bypassed Vite’s asset detection completely.

Unit tests stayed green for three reasons: Vitest in Node reads via node:fs/promises, mobile preloads the font as base64 and skips resolveFontUrl(), and the Service Worker test mocked the manifest instead of running a real vite.build(). Commit 0366ad86 restored literal import.meta.url after the runtime guard, cleared rejected fontBytesPromise entries on failure, and added apps/web/test/export-font-build.test.ts to run a real Vite build and assert both the 4,327,412-byte asset and its exclusion from sw.js precaching. The macOS DMG jumped back from 14,903,381 to 23,580,493 bytes.

2. Path::file_name() Eating "A:" on Windows (v0.8.2)

Minutes after shipping v0.8.1, Windows native tests caught a filename truncation bug in safe_file_name(suggested_name) inside apps/desktop/src-tauri/src/lib.rs:

let candidate = Path::new(suggested_name)
    .file_name()
    .and_then(|name| name.to_str())
    .unwrap_or("");

Passing "A: notes" works on macOS and Linux ("A_ notes" after sanitization). On Windows, Rust’s std::path::Path parses A: as Prefix::Disk('A'), so .file_name() returns " notes" — silently eating the colon and the leading A.

Commit 4a094510 only calls Path::file_name() when suggested_name.contains(std::path::is_separator). The same Windows patch also embedded a Common Controls v6 .drectve manifest in #[cfg(all(windows, target_env = "msvc"))] test builds so dialog-linked Rust tests launch under MSVC, and updated publish-desktop-update.mjs --windows-installers-only to read tauri.windows.conf.json (0.8.2) instead of the shared tauri.conf.json (0.8.1).

3. Fixing Dark-Mode FOUC Without Breaking origin-move or Canvas Geometry (v0.8.1)

Switching the dark theme to deep forest #172114 exposed a bright flash on reload because packages/ui/src/tokens.css defaulted to color-scheme: light before hydration. Adding a synchronous inline boot script to apps/web/index.html fixed the flash, at the cost of having to recompute and sync the new SHA-256 script hash across four CSP definitions (index.html, tauri.conf.json, and deploy/web/ramilo.conf).

While hardening headers and typography in 219fbce5, two deliberate exceptions were kept:

  • No global Cross-Origin-Opener-Policy: same-origin: apps/web/src/origin-move.ts uses cross-origin window.open + postMessage to migrate local IndexedDB maps from legacy domains (brinlet.app and ramilo.mahui.me); enabling strict COOP would strand returning users’ offline maps.
  • UI chrome in rem, canvas nodes locked to px: Menus and site pages scale with rem, while --font-size-node (15px), --font-size-branch (17px), and --font-size-root (22px) stay in px because packages/layout computes node box geometry independently — scaling text without updating layout measurements would clip labels inside their boxes.

Current preview status: the web app and site are live on mindloft.cc, macOS (0.8.1, notarized), Windows (0.8.2, unsigned), and Android (0.8.0, signed APK) are available for download, iOS / iPadOS is in TestFlight (0.7.4), and HarmonyOS NEXT remains in real-device testing.

✦

Comments

  • Loading…

Comments are reviewed before publishing; email is visible only to me.