Theseus: switcher is direct-load (no more soft-mode re-prompt); blur URL on submit

Chip switcher now bypasses navigateTab/loadBns entirely and calls loadURL
directly. Rationale: the user explicitly clicked a registry chip; that IS the
choice. Routing through navigateTab -> loadBns was reaching the collision
decision path in some races and could re-show the soft-mode 'Open with...'
prompt as an unwanted extra step. Direct load guarantees the switch is atomic.

Prov is updated inline using entries.get(host) for the BCDN case (source/records/
category), same shape loadBns would have produced. internalNav flag guards the
programmatic load from the will-navigate handler (redirect chains stay clean).

Also: address bar blurs on Enter so the tabs-event handler can update it to
the actual loaded URL (search keyword no longer sticks in the address bar
after search results load).
This commit is contained in:
Local Dev 2026-08-02 18:40:38 +02:00
parent ef260e0451
commit d1aa46c8d2

27
main.js
View file

@ -1006,12 +1006,31 @@ ipcMain.handle("collision-switch", async (_e, arg) => {
const choice = (raw === "bcdn" || raw === "bcnr") ? "bcnr" const choice = (raw === "bcdn" || raw === "bcnr") ? "bcnr"
: (raw === "icann") ? "icann" : (raw === "icann") ? "icann"
: (t.prov.kind === "ok" ? "icann" : "bcnr"); // flip the current one : (t.prov.kind === "ok" ? "icann" : "bcnr"); // flip the current one
// Transient per-tab override consumed once by loadBns — no soft-mode re-prompt
// for this specific chip-triggered switch.
t.collisionOverride = choice;
// Optional persistent memory ("Always use…" from the popover switcher). // Optional persistent memory ("Always use…" from the popover switcher).
rememberCollision(host, tld, choice, arg?.remember || "no"); rememberCollision(host, tld, choice, arg?.remember || "no");
return navigateTab(t.id, host + (t.prov.path || "/")); const registry = registryOf(tld);
// DIRECT navigation — bypass navigateTab/loadBns entirely so nothing in the
// collision-decision path can trigger a re-prompt on an explicit user switch.
// The user clicked the switcher; they've made their choice. Just load it.
setLoading(t, true);
t.internalNav = true;
try {
if (choice === "icann") {
t.url = "https://" + host + "/";
await t.view.webContents.loadURL(t.url);
t.prov = { host, kind: "web", note: "switched to ICANN", tld, registry };
} else {
t.url = host + "/";
await t.view.webContents.loadURL(`bns://${host}/`);
const rec = entries.get(host);
const r = rec?.entry?.records || {};
const src = r.h ? "on-chain (chain)" : r.s3 ? "Sia network" : r.ip ? "direct server" : r.u ? "redirect" : "record";
t.prov = { host, kind: "ok", source: src, category: rec?.entry?.category, records: Object.keys(r), tld, registry };
}
} catch (e) { console.warn("collision-switch load failed:", e?.message); }
finally { t.internalNav = false; setLoading(t, false); }
if (t.id === activeId) pushNav(t.prov);
emitTabs();
}); });
ipcMain.handle("collision-state", () => ({ ipcMain.handle("collision-state", () => ({
policy: settings.collisionPolicy, policy: settings.collisionPolicy,