Files
Primora/apps/desktop/ui/index.html
T
Tomáš DvořákandDevin d44bbcceda
CI / Backend Tests (push) Canceled after 0s
CI / Frontend Tests (push) Canceled after 0s
CI / Build All Services (push) Canceled after 0s
CI / Docker Build (auth) (push) Canceled after 0s
CI / Docker Build (backend) (push) Canceled after 0s
CI / Docker Build (frontend) (push) Canceled after 0s
CI / Publish edge images (auth) (push) Canceled after 0s
CI / Publish edge images (backend) (push) Canceled after 0s
CI / Publish edge images (frontend) (push) Canceled after 0s
CI / Migration Up/Down (push) Canceled after 0s
CI / Compose E2E Smoke (push) Canceled after 0s
CI / Lint (push) Canceled after 0s
fix: QA hardening across desktop connect, CLI, setup, and PWA update flow (#52)
- desktop: probe-then-persist server URL — scheme-less input tries https
  then http; a failed probe no longer saves a dead URL that would trap
  the next launch in a redirect to a broken address
- frontend: close the create-collection modal on successful submit
  (backdrop stayed mounted and intercepted navigation)
- frontend: reload once on service-worker controllerchange so returning
  users don't run a stale cached shell after a deploy
- frontend: gate dashboard empty states on resource loading to stop the
  "No project selected" / "Create your workspace" flash
- cli: resolve scheduled-job refs by name or id for jobs:run, jobs:runs,
  and jobs:rm, matching bucket/org resolution
- cli: correct stale pk_live_/pk_test_ help text to the real prm_ format;
  align README command spellings and demo seed prefixes
- setup: rewrite all public URL vars (auth, vite, backend) and cookie
  domain for the entered host — https for domains, http for IPs — with
  anchored full-line substitutions so stale ports/paths can't survive
- docs: VITE_* vars never reach the frontend image build; the app
  resolves API/auth URLs same-origin at runtime, so host changes need no
  rebuild — noted HTTPS requirement for PWA/secure-context features

Generated with [Devin](https://devin.ai)

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-03 18:52:53 +02:00

147 lines
5.3 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="dark" />
<title>Primora</title>
<link rel="icon" type="image/svg+xml" href="icon.svg" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<main class="card">
<img src="icon.svg" class="logo" alt="" />
<h1>Primora</h1>
<p class="sub">Connect to your self-hosted deployment.</p>
<form id="form">
<input
id="url"
type="text"
inputmode="url"
placeholder="https://primora.example.com"
autocomplete="off"
spellcheck="false"
autofocus
/>
<button type="submit" id="go">Connect</button>
</form>
<p id="err" class="err" hidden></p>
<p class="hint">The desktop app renders the console served by your own server. Nothing is hosted by us.</p>
<p class="hint"><a href="#" id="vault-link" class="vlink">Open the local Secrets Vault</a></p>
<div id="update" hidden>
<p class="hint" id="update-text"></p>
<button type="button" id="update-install">Update &amp; restart</button>
</div>
</main>
<script type="module">
const tauri = window.__TAURI__;
const form = document.getElementById("form");
const input = document.getElementById("url");
const button = document.getElementById("go");
const err = document.getElementById("err");
const fail = (msg) => {
err.textContent = msg;
err.hidden = false;
button.disabled = false;
button.textContent = "Connect";
};
// Updater — check before auto-connecting: a saved URL redirects
// immediately, so the check must resolve first or it never shows.
// Bounded at 5s; failures are silent (dev builds, offline, no
// manifest). Unsigned artifacts can never install — minisign is
// enforced by the plugin against the pubkey baked into the bundle.
const updateP = (tauri?.updater && tauri?.process)
? Promise.race([
tauri.updater.check().catch(() => null),
new Promise((r) => setTimeout(() => r(null), 5000)),
])
: Promise.resolve(null);
if (!tauri) {
fail("This page is meant to run inside the Primora desktop app.");
} else {
// A saved deployment URL means "skip the form" on every launch —
// unless an update is waiting, which wins the redirect.
const update = await updateP;
if (update) {
const box = document.getElementById("update");
const text = document.getElementById("update-text");
const install = document.getElementById("update-install");
text.textContent = `Update available — v${update.version} (you have ${update.currentVersion}).`;
box.hidden = false;
install.addEventListener("click", async () => {
install.disabled = true;
install.textContent = "Downloading…";
try {
await update.downloadAndInstall();
await tauri.process.relaunch();
} catch (e) {
install.disabled = false;
install.textContent = "Update & restart";
text.textContent = `Update failed: ${e}`;
}
});
// "Not now" continues to the saved server.
const later = document.createElement("button");
later.type = "button";
later.textContent = "Not now";
later.style.marginLeft = "0.5rem";
later.addEventListener("click", () => { const saved = _savedUrl; if (saved) location.replace(saved); });
box.appendChild(later);
}
const _savedUrl = await tauri.core.invoke("get_server_url").catch(() => null);
if (_savedUrl && !update) location.replace(_savedUrl);
}
document.getElementById("vault-link").addEventListener("click", (e) => {
e.preventDefault();
tauri?.event.emit("open-vault");
});
const probe = async (url) => {
try {
// Opaque (no-cors) — proves the host answers, not that it is a
// Primora deployment. A wrong-but-alive URL is recoverable via the
// tray menu's "Change server".
await fetch(url, { mode: "no-cors", signal: AbortSignal.timeout(8000) });
return true;
} catch {
return false;
}
};
form.addEventListener("submit", async (event) => {
event.preventDefault();
err.hidden = true;
button.disabled = true;
button.textContent = "Checking…";
let url = input.value.trim();
if (!/^https?:\/\//i.test(url)) {
// Self-hosted deployments are often plain HTTP on a LAN — probe
// https first, fall back to http, and only keep the one that answers.
const https = `https://${url}`;
url = (await probe(https)) ? https : `http://${url}`;
}
if (!(await probe(url))) {
fail("Server did not respond. Check the URL and that the deployment is up.");
return;
}
try {
await tauri.core.invoke("set_server_url", { url });
} catch (e) {
fail(String(e));
return;
}
location.replace(url);
});
</script>
</body>
</html>