Engine
{#if e?.state === "stopped"}
- {name} is not answering. Visitors may not reach any host. Switching to {other} is the quickest way back.
+ Visitors may not reach any host. Switching to {other} is the quickest way back.
{:else}
- {#if e?.since}Since {when(e.since, app.now)}. {/if}
+ {#if e?.since}Since {whenInline(e.since, app.now)}. {/if}
{#if running === "pingora"}
- {#if notReady}Caddy is not ready: its settings have not been built yet.{:else}Caddy is ready with the same routes: built {when(e?.fallback_ready?.built_at, app.now)}{e?.fallback_ready?.current ? "" : " (it is rebuilt from the current routes when you switch)"}.{/if}
+ {#if notReady}Caddy is not ready: its settings have not been built yet.{:else if differs > 0}Caddy is built with the same routes {whenInline(fr?.built_at, app.now)}, but {differs} of {fr?.compared} hosts behave differently on it.{:else}Caddy is ready with the same routes: built {whenInline(fr?.built_at, app.now)}{fr?.compared ? `, and all ${fr.compared} hosts behave the same` : ""}.{/if}
+ {#if !notReady && !fr?.current} It is rebuilt from the current routes when you switch.{/if}
{:else}Pingora is ready with the same routes.{/if}
+ {#if running === "pingora" && !notReady && fr?.differences.length}
+
+ {/if}
{/if}
What happens
@@ -81,10 +95,10 @@
Open connections close; videos and uploads in progress restart.
Hosts and certificates stay the same.
{#if running === "pingora"}
-
Share links stop working while Caddy serves: visitors with a link get the normal sign-in. They work again when you switch back.{#if activeLinks} Hosts with share links: {activeLinks}.{/if}
-
Changes wait while Caddy serves; switch back to make them.
+
Share links stop working while Caddy serves: visitors with a link get the normal sign-in. They work again when you switch back.{#if activeLinks}{" "}{activeLinks === 1 ? "1 share link is" : `${activeLinks} share links are`} active.{/if}
+
Changes keep working: Ianitor tries each one on Caddy and undoes it if a host stops answering.
{:else}
-
Share links work again, and changes can be made again.
+
Share links work again.
{/if}
This page may lose contact for a few seconds.
diff --git a/apps/web/src/components/HostList.svelte b/apps/web/src/components/HostList.svelte
index a51cd60..70e0ea0 100644
--- a/apps/web/src/components/HostList.svelte
+++ b/apps/web/src/components/HostList.svelte
@@ -111,7 +111,7 @@
{w}{phoneDetail(h) ? ` · ${phoneDetail(h)}` : ""}
- {h.upstreams[0] ?? ""} {#if h.upstreams.length > 1} +{h.upstreams.length - 1} more {/if}
+ {h.upstreams[0] ?? ""} {#if h.upstreams.length > 1}{" "}+{h.upstreams.length - 1} more {/if}
{running.includes(h.hostname) ? "Changing now · " : ""}{s.text}
{#if h.certificate.state === "pending"}Waiting for Let's Encrypt to issue the certificate. {/if}
{#if h.certificate.state === "failed"}
diff --git a/apps/web/src/components/HostMenu.svelte b/apps/web/src/components/HostMenu.svelte
index 95be1ee..9fcad4a 100644
--- a/apps/web/src/components/HostMenu.svelte
+++ b/apps/web/src/components/HostMenu.svelte
@@ -52,7 +52,9 @@
function pick(it: Item) {
if (it.reason) return;
- close(false);
+ // Focus back on More first: a dialog the item opens returns focus there when it closes
+ // (§2.9), not to a menu item that no longer exists.
+ close(true);
it.run();
}
diff --git a/apps/web/src/components/HostPanel.svelte b/apps/web/src/components/HostPanel.svelte
index 23001bc..961825d 100644
--- a/apps/web/src/components/HostPanel.svelte
+++ b/apps/web/src/components/HostPanel.svelte
@@ -8,7 +8,7 @@
import { Banner, Button, Details, Dialog, Icon, Segmented } from "@ianitor/ui";
import ApplyProgress from "./ApplyProgress.svelte";
import { ApiError, call, del, get, newKey, sentence } from "../lib/api";
- import { app, changesBlocked, refresh, toast } from "../lib/app.svelte";
+ import { app, changesBlocked, refresh, restoreLastKept, toast } from "../lib/app.svelte";
import { FINAL, follow } from "../lib/applies";
import { firstSentence } from "../lib/format";
import type { ApplyView, ErrorBody, HeaderRule, HostSpec } from "../lib/types";
@@ -62,6 +62,8 @@
// ---- the apply
let apply = $state(null);
+ let restoring = $state(false);
+ let restoreProblem = $state(null);
let phase = $state<"form" | "progress">("form");
let stop: (() => void) | undefined;
let closeTimer: ReturnType | undefined;
@@ -128,16 +130,43 @@
rev = app.overview?.rev ?? null;
if (!signinOk) host.auth = "none";
}
- loading = false;
- if (focusField) {
- if (focusField.startsWith("health_check")) more = true;
- setTimeout(() => document.getElementById(fieldId(focusField))?.focus(), 0);
+ // A form saved before this tab went to sign in comes back (App.svelte, signIn).
+ try {
+ const raw = sessionStorage.getItem(DRAFT);
+ const d = raw ? (JSON.parse(raw) as { hostname: string; host: typeof host }) : null;
+ if (d && d.hostname === (hostname ?? "") && !resume) {
+ Object.assign(host, d.host);
+ more = more || d.host.hc || d.host.req.length > 0 || d.host.resp.length > 0;
+ }
+ sessionStorage.removeItem(DRAFT);
+ } catch {
+ /* no storage: nothing to bring back */
}
+ loading = false;
+ if (phase === "form") {
+ // The Dialog focused its heading while this said "Loading…": now the first field
+ // (Hostname; Send traffic to when editing), so typing right after opening works.
+ const f = focusField ?? (hostname ? "upstreams[0]" : "hostname");
+ if (f.startsWith("health_check")) more = true;
+ setTimeout(() => document.getElementById(fieldId(f))?.focus(), 0);
+ }
+ window.addEventListener("ianitor:save-draft", saveDraft);
});
+ const DRAFT = "ianitor-draft";
+ function saveDraft() {
+ if (phase !== "form") return;
+ try {
+ sessionStorage.setItem(DRAFT, JSON.stringify({ hostname: hostname ?? "", host: $state.snapshot(host) }));
+ } catch {
+ /* no storage */
+ }
+ }
+
onDestroy(() => {
stop?.();
clearTimeout(closeTimer);
+ if (typeof window !== "undefined") window.removeEventListener("ianitor:save-draft", saveDraft);
});
function fieldId(f: string): string {
@@ -226,6 +255,7 @@
function onApply(a: ApplyView) {
apply = a;
if (a.state === "kept") {
+ if (a.kind !== "remove") app.focusHost = a.hosts[0] ?? null;
closeTimer = setTimeout(() => onclose(), 1500);
}
}
@@ -291,6 +321,10 @@
return `Removing ${h}`;
case "share_links":
return `Turning on share links for ${h}`;
+ case "undo":
+ return `Undoing: ${apply.summary.replace(/^Undid: /, "")}`;
+ case "restore":
+ return apply.summary.replace(/^Restored /, "Restoring ");
default:
return `Changing ${h}`;
}
@@ -321,7 +355,7 @@
{#if apply.state === "kept"}
{#snippet title()}kept {apply?.hosts[0] ?? name} {apply?.kind === "remove" ? "is removed." : "is live."}{/snippet}
- {apply.reason?.message ?? ""}{#if apply.commit_short} Saved as commit {apply.commit_short}{apply.push?.state === "pushed" ? " and pushed to Gitea" : ""}.{/if}
+ {(apply.reason?.message ?? "").replace(/^\S+ is (live|removed)\.\s*/, "")}{#if apply.commit_short} Saved as commit {apply.commit_short}{apply.push?.state === "pushed" ? " and pushed to Gitea" : ""}.{/if}
{:else if apply.state === "reverted" || apply.state === "failed"}
{@const parts = firstSentence(apply.reason?.message ?? "")}
@@ -337,7 +371,12 @@
{#if apply.reason?.detail} {/if}
Your form is kept. History records the attempt as {apply.state === "failed" ? "not applied" : "reverted"}.
{:else if apply.state === "needs_attention"}
- {#snippet title()}Ianitor could not undo a failed change. {/snippet}{apply.reason?.message}
+ {#snippet title()}Ianitor could not undo a failed change. {/snippet}{apply.reason?.message}
+ {#if restoreProblem}{restoreProblem}
{/if}
+ {#snippet actions()}
+ {#if app.overview?.undo?.target} { restoring = true; restoreProblem = await restoreLastKept(); restoring = false; }}>Restore the last kept version {/if}
+ {/snippet}
+
{/if}
{:else}
- Valid for {lifetime} days, until {until}. It lets this device into hosts that ask for a Domi device certificate.
+ {#if capped}Valid until {until}, when the Domi intermediate certificate ends (renew it to issue for a full year).{:else}Valid for {lifetime} days, until {until}.{/if} It lets this device into hosts that ask for a Domi device certificate.
{:else if request.state === "waiting"}
Waiting for approval
- Approve it on the server, and only if it shows the same code:
+ Custos cannot approve device certificates yet, so approve it on the server, and only if it shows the same code:
{request.match_code}
{#if request.approve_command}Run on the server:
{request.approve_command} {/if}
- The request stays open for {Math.floor(secondsLeft(request.expires_at) / 60)}:{String(secondsLeft(request.expires_at) % 60).padStart(2, "0")}. Nothing is issued until it is approved.
+ The request stays open for 10 minutes ({Math.floor(secondsLeft(request.expires_at) / 60)}:{String(secondsLeft(request.expires_at) % 60).padStart(2, "0")} left). Nothing is issued until it is approved.
Cancel request
Waiting for approval. Code {request.match_code}.
{:else if issuedDevice}
- {#snippet title()}{issuedDevice.name} has a certificate. Approved at {when(request?.approved_at, app.now)}.{/snippet}
+ {#snippet title()}{issuedDevice.name} has a certificate. Approved {atTime(request?.approved_at, app.now)}.{/snippet}
{#if tokenCopied}Copied. Paste it into Custos now. Ianitor cannot show it again.
{/if}
- {made.expires_at ? `Expires on ${shortDate(made.expires_at)}.` : "Never expires."}
+ {made.expires_at ? `Expires on ${longDate(made.expires_at, false)}.` : "Never expires."}
{#if askClose}
Close without copying? The token cannot be shown again.
(askClose = false)}>Go back closeToken(true)}>Close anyway
diff --git a/apps/web/tests/flows.test.ts b/apps/web/tests/flows.test.ts
index 55f8ecf..b666f8b 100644
--- a/apps/web/tests/flows.test.ts
+++ b/apps/web/tests/flows.test.ts
@@ -146,7 +146,8 @@ describe("ROADMAP §4 flows, clicks counted", () => {
start();
await click(await screen.findByRole("button", { name: "Renew" }));
await waitFor(() => expect(called("POST", "/certs/intermediate/renewal")).toBe(true));
- await screen.findByLabelText("Match code 47 19 83");
+ // The renewal is waiting: the banner says where to sign it (no code to compare with openssl).
+ await screen.findByRole("button", { name: "Sign it by hand" });
expect(clicks).toBe(1);
});
@@ -176,6 +177,29 @@ describe("focus", () => {
await user.keyboard("recipes.home.test");
expect((await screen.findByLabelText("Hostname") as HTMLInputElement).value).toBe("recipes.home.test");
});
+
+ it("the share dialog opens on Copy link and gives focus back to the row's More button", async () => {
+ start();
+ const more = await screen.findByRole("button", { name: "More for wiki.home.test" });
+ await click(more);
+ await click(await screen.findByRole("menuitem", { name: /Share link/ }));
+ const copy = await screen.findByRole("button", { name: "Copy link" });
+ await waitFor(() => expect(document.activeElement).toBe(copy));
+ // jsdom fires no cancel event on Esc for a modal dialog: close it with its button.
+ await click(screen.getByRole("button", { name: "Close" }));
+ await waitFor(() => expect(screen.queryByRole("button", { name: "Copy link" })).toBeNull());
+ await waitFor(() => expect(document.activeElement).toBe(more));
+ });
+
+ it("the engine popover closes with Esc and focus goes back to the chip", async () => {
+ start();
+ const chip = await screen.findByRole("button", { name: /^Engine: Pingora/ });
+ await click(chip);
+ await screen.findByRole("button", { name: "Switch to Caddy" });
+ await user.keyboard("{Escape}");
+ await waitFor(() => expect(screen.queryByRole("button", { name: "Switch to Caddy" })).toBeNull());
+ expect(document.activeElement).toBe(screen.getByRole("button", { name: /^Engine: Pingora/ }));
+ });
});
describe("sign-in and contact", () => {
diff --git a/apps/web/tests/mockApi.ts b/apps/web/tests/mockApi.ts
index 58967a4..1c1228e 100644
--- a/apps/web/tests/mockApi.ts
+++ b/apps/web/tests/mockApi.ts
@@ -73,7 +73,7 @@ export function installMock(): Mock {
since: now(),
target: null,
switchable: true,
- fallback_ready: { built_at: now(), current: true },
+ fallback_ready: { built_at: now(), current: true, compared: 3, matched: 3, differences: ["Every host: Caddy adds its own Server and Via headers to answers, and a Content-Type when your service sends none."] },
last_error: null,
notes: [],
},
diff --git a/packages/ui/src/Dialog.svelte b/packages/ui/src/Dialog.svelte
index 718004a..e4dad8f 100644
--- a/packages/ui/src/Dialog.svelte
+++ b/packages/ui/src/Dialog.svelte
@@ -39,12 +39,29 @@
if (modal && typeof el.showModal === "function") el.showModal();
else if (typeof el.show === "function") el.show();
else el.setAttribute("open", "");
- const first = el.querySelector(
- "[data-autofocus], input:not([type=hidden]):not([readonly]):not([type=radio]), textarea, select",
- );
+ const first =
+ el.querySelector("[data-autofocus]") ??
+ el.querySelector("input:not([type=hidden]):not([readonly]):not([type=radio]), textarea:not([readonly]), select");
(first ?? el.querySelector(".ia-dialog-title"))?.focus();
}
+ // A dialog opened with show() (the popover) gets no cancel event: Esc and a click outside
+ // close it here, like the modal ones.
+ const key = (e: KeyboardEvent) => {
+ if (!modal && e.key === "Escape" && escape) {
+ e.preventDefault();
+ onclose();
+ }
+ };
+ const down = (e: PointerEvent) => {
+ if (!modal && escape && el && e.target instanceof Node && !el.contains(e.target)) onclose();
+ };
+ document.addEventListener("keydown", key);
+ // On the next turn, so the click that opened the popover does not close it.
+ const t = setTimeout(() => document.addEventListener("pointerdown", down), 0);
return () => {
+ clearTimeout(t);
+ document.removeEventListener("keydown", key);
+ document.removeEventListener("pointerdown", down);
if (opener instanceof HTMLElement && document.contains(opener)) opener.focus();
};
});
diff --git a/packages/ui/src/components.css b/packages/ui/src/components.css
index 1561a9e..23bd0d7 100644
--- a/packages/ui/src/components.css
+++ b/packages/ui/src/components.css
@@ -12,6 +12,15 @@
@import "@fontsource/manrope/latin-400.css";
@import "@fontsource/manrope/latin-600.css";
@import "@fontsource/manrope/latin-700.css";
+/* latin-ext: Czech names and places (č, ř, ů) in host names, device names and messages. */
+@import "@fontsource/cinzel/latin-ext-500.css";
+@import "@fontsource/cormorant-garamond/latin-ext-500.css";
+@import "@fontsource/cormorant-garamond/latin-ext-600.css";
+@import "@fontsource/manrope/latin-ext-400.css";
+@import "@fontsource/manrope/latin-ext-600.css";
+@import "@fontsource/manrope/latin-ext-700.css";
+
+html, body { margin: 0; }
.ia .sr-only {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
@@ -98,7 +107,10 @@
.ia .ia-engine small { color: var(--muted); font-weight: 400; font-size: 0.86rem; }
/* ── Lists and rows (§2.5) ──────────────────────────────────────────────── */
-.ia .ia-list { border: 1px solid var(--hairline); border-radius: var(--radius-lg); overflow: hidden; }
+.ia .ia-list { border: 1px solid var(--hairline); border-radius: var(--radius-lg); }
+/* No overflow clipping on the list: a row's menu must reach past it. The end rows carry the corners. */
+.ia .ia-list > :first-child { border-top-left-radius: calc(var(--radius-lg) - 1px); border-top-right-radius: calc(var(--radius-lg) - 1px); }
+.ia .ia-list > :last-child { border-bottom-left-radius: calc(var(--radius-lg) - 1px); border-bottom-right-radius: calc(var(--radius-lg) - 1px); }
.ia .ia-row { display: grid; grid-template-columns: 128px minmax(0, 1.4fr) minmax(0, 1.6fr) 44px; gap: 16px; padding: 12px 10px 12px 18px; align-items: start; border-top: 1px solid var(--hairline); }
.ia .ia-row:first-child { border-top: 0; }
.ia .ia-row.head { background: var(--colonnade); padding-top: 10px; padding-bottom: 10px; align-items: center; }
@@ -121,6 +133,7 @@
background: none; color: var(--text-2); font-weight: 600; font-size: 0.92rem; text-align: left; cursor: pointer;
}
.ia .ia-menu [role="menuitem"]:hover, .ia .ia-menu [role="menuitem"]:focus { background: var(--surface-2); color: var(--text); outline: none; }
+.ia .ia-menu [role="menuitem"]:focus-visible { outline: var(--focus-ring); outline-offset: -2px; }
.ia .ia-menu [role="menuitem"].danger { color: var(--danger); }
.ia .ia-menu [role="menuitem"][aria-disabled="true"] { color: var(--disabled); cursor: not-allowed; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.ia .ia-menu .reason { flex-basis: 100%; padding-left: 28px; font-weight: 400; font-size: var(--fs-sub); color: var(--muted); }
@@ -185,7 +198,7 @@
@media (max-width: 719.98px) { .ia .ia-toasts { right: 16px; left: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); } }
.ia .ia-progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.ia .ia-progress > span { display: block; height: 100%; background: var(--accent); transition: width var(--dur-tick) linear; }
-.ia .ia-secret { display: block; width: 100%; background: var(--surface); border: 1px solid var(--control-edge); border-radius: var(--radius-sm); box-shadow: var(--carved); padding: 12px 14px; font-weight: 600; letter-spacing: 0.02em; word-break: break-all; color: var(--text); font: inherit; }
+.ia .ia-secret { display: block; width: 100%; background: var(--surface); border: 1px solid var(--control-edge); border-radius: var(--radius-sm); box-shadow: var(--carved); padding: 12px 14px; font: inherit; font-weight: 600; letter-spacing: 0.02em; word-break: break-all; overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text); resize: none; }
.ia .ia-details pre { background: var(--surface); border-radius: var(--radius-sm); color: var(--muted); font-size: var(--fs-sub); white-space: pre-wrap; padding: 10px 12px; margin: 6px 0; }
.ia .ia-frame { border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 32px; text-align: center; }
.ia .ia-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 12px 14px; }
diff --git a/packages/ui/src/icons.ts b/packages/ui/src/icons.ts
index 7ca9b9d..d5d99de 100644
--- a/packages/ui/src/icons.ts
+++ b/packages/ui/src/icons.ts
@@ -17,6 +17,7 @@ export const ICONS = {
building: "M4 21V5l8-3 8 3v16M9 21v-5h6v5M8 8h2M14 8h2M8 12h2M14 12h2",
swap: "M7 7h13l-4-4M17 17H4l4 4",
copy: "M9 9h11v11H9zM5 15H4V4h11v1",
+ download: "M12 4v11M7 10l5 5 5-5M5 20h14",
chevron: "M6 9l6 6 6-6",
dots: "M5 12h.01M12 12h.01M19 12h.01",
close: "M6 6l12 12M18 6 6 18",