feat(desktop): deterministic alias from seed + git hash on home screen + fix EACCES on Android
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 3m41s
Mirror to GitHub / mirror (push) Failing after 38s

Three home-screen issues from the first Tauri Android APK:

1. Alias was empty (no seed-derived name).
   Port the adjective+noun word lists from the old Kotlin SettingsRepository
   into a `derive_alias()` helper that maps the first 4 bytes of the seed to
   indices in those lists. Same seed → same alias forever, different seeds →
   effectively random aliases — so reinstalls keep the user's identity AND
   the friendly name they're used to.

2. Build identity was invisible — couldn't tell which APK was actually
   installed (this caused us a lot of grief on the Kotlin app).
   build.rs now captures `git rev-parse --short HEAD` and emits it as
   `WZP_GIT_HASH`, exposed via a new `get_app_info` command. The frontend
   stamps `build <hash> • <alias>` under the fingerprint on the home screen.

3. Register on relay failed with `Permission denied (os error 13)`.
   Root cause: I hardcoded `/data/data/com.wzp.phone/files/.wzp` as the
   identity dir, but the Tauri Android package id is `com.wzp.desktop` —
   so the app was trying to write into another app's data directory and
   getting EACCES at the filesystem layer. Fix: resolve the data dir from
   Tauri's `path().app_data_dir()` API in the `setup()` callback and stash
   it in a `OnceLock<PathBuf>`. Works on Android, macOS, Linux, Windows
   without any cfg gymnastics.

Also: `get_app_info` returns the resolved `data_dir` so we can debug
storage issues from the UI (it's set as the build-hash element's title).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-04-09 11:55:51 +04:00
parent 69ee3115b6
commit 7639aaf08d
3 changed files with 143 additions and 11 deletions

View File

@@ -354,10 +354,13 @@ function renderRecentRooms(rooms: RecentRoom[]) {
applySettings();
setTimeout(pingAllRelays, 300);
// Load fingerprint + render identicon
// Load fingerprint + alias + git hash + render identicon
interface AppInfo { git_hash: string; alias: string; fingerprint: string; data_dir: string }
(async () => {
try {
const fp: string = await invoke("get_identity");
const info: AppInfo = await invoke("get_app_info");
const fp = info.fingerprint;
myFingerprint = fp;
myFingerprintEl.textContent = fp;
myFingerprintEl.style.cursor = "pointer";
@@ -373,7 +376,29 @@ setTimeout(pingAllRelays, 300);
const icon = createIdenticonEl(fp, 28, true);
myIdenticonEl.innerHTML = "";
myIdenticonEl.appendChild(icon);
} catch {}
// Prefill alias if the user hasn't typed one yet
if (!aliasInput.value.trim()) {
aliasInput.value = info.alias;
const s = loadSettings();
s.alias = info.alias;
saveSettingsObj(s);
}
// Stamp the build hash on the home screen so we can prove which build
// is installed (this caused us a lot of grief on the Kotlin app).
let buildEl = document.getElementById("build-hash");
if (!buildEl) {
buildEl = document.createElement("div");
buildEl.id = "build-hash";
buildEl.style.cssText = "font-size:10px;opacity:0.6;text-align:center;margin-top:4px;font-family:monospace";
myFingerprintEl.parentElement?.appendChild(buildEl);
}
buildEl.textContent = `build ${info.git_hash}${info.alias}`;
buildEl.title = info.data_dir;
} catch (e) {
console.error("get_app_info failed", e);
}
})();
// ── Connect ──