fix(theseus/home): dynamic search-engine name in placeholder

Home page's search-box placeholder was hardcoded "Search the web
(DuckDuckGo)", but the browser's default engine has been Startpage
for a while and any user can switch to another in Settings. The
"DuckDuckGo" claim then contradicted the actual engine that would
run the query (main.js routes through settings.searchEngine).

Fix: placeholder starts as plain "Search the web" and populates on
load with "Search the web with <engine.name>" via a new
window.home.getEngines() IPC (reuses the existing search-engines
handler). Silently no-ops if the preload isn't bound.

Also swapped the never-fires no-preload fallback URL from
duckduckgo.com to startpage.com so it matches Theseus's own default.
This commit is contained in:
Local Dev 2026-09-08 00:20:37 +02:00
parent 4869adbf9d
commit 8e60469703
2 changed files with 21 additions and 2 deletions

View file

@ -10,6 +10,10 @@ contextBridge.exposeInMainWorld("home", {
setCards: (cards) => ipcRenderer.invoke("home-cards-set", cards), setCards: (cards) => ipcRenderer.invoke("home-cards-set", cards),
resetCards: () => ipcRenderer.invoke("home-cards-reset"), resetCards: () => ipcRenderer.invoke("home-cards-reset"),
navigate: (url) => ipcRenderer.invoke("navigate", url), navigate: (url) => ipcRenderer.invoke("navigate", url),
// Current default search engine — used to populate the search box
// placeholder with the actual engine name (e.g. "Search the web with
// Startpage") instead of hardcoding DuckDuckGo.
getEngines: () => ipcRenderer.invoke("search-engines"),
// Main pushes an updated list here after a successful remote refresh // Main pushes an updated list here after a successful remote refresh
// (only when the user has not customised locally). home.html re-renders. // (only when the user has not customised locally). home.html re-renders.
onCards: (cb) => ipcRenderer.on("home-cards", (_e, list) => cb(list)), onCards: (cb) => ipcRenderer.on("home-cards", (_e, list) => cb(list)),

View file

@ -118,7 +118,7 @@
<h1>Theseus <span class="g">Navigator</span></h1> <h1>Theseus <span class="g">Navigator</span></h1>
<p class="tag">A browser that follows the thread. Names that live on the Bitcoin Cash chain.</p> <p class="tag">A browser that follows the thread. Names that live on the Bitcoin Cash chain.</p>
<form id="searchForm"> <form id="searchForm">
<input id="q" name="q" placeholder="Search the web (DuckDuckGo)" autofocus spellcheck="false"> <input id="q" name="q" placeholder="Search the web" autofocus spellcheck="false">
<button type="submit">Search</button> <button type="submit">Search</button>
</form> </form>
<p class="hint">Tip: type a <b>.bch</b> name in the address bar above to open a decentralized site.</p> <p class="hint">Tip: type a <b>.bch</b> name in the address bar above to open a decentralized site.</p>
@ -165,8 +165,23 @@
e.preventDefault(); e.preventDefault();
const q = $("q").value.trim(); if (!q) return; const q = $("q").value.trim(); if (!q) return;
if (window.home && window.home.navigate) window.home.navigate(q); if (window.home && window.home.navigate) window.home.navigate(q);
else window.location.href = "https://duckduckgo.com/?q=" + encodeURIComponent(q); // Fallback if the preload didn't bind (shouldn't happen). Startpage
// over DuckDuckGo since that's Theseus's own default engine now.
else window.location.href = "https://www.startpage.com/do/search?q=" + encodeURIComponent(q);
}); });
// Populate placeholder with the user's current default engine name so
// "Search the web with <engine>" reflects reality. Silently no-ops if
// the preload or IPC isn't available (dev-open of home.html in a plain
// Chromium tab). Also refreshes on onEngines events would be nice but
// main only broadcasts `engines` to chrome — home only queries at load,
// which is fine because switching engines is a settings action that
// usually implies a reload of the tab shortly after.
if (window.home && window.home.getEngines) {
window.home.getEngines().then((r) => {
const name = r && r.engines && r.engines.find((x) => x.id === r.current)?.name;
if (name) $("q").placeholder = "Search the web with " + name;
}).catch(() => {});
}
function badgeClass(b) { function badgeClass(b) {
// Normalize badge label into a CSS class (spaces + case → dashes / lower). // Normalize badge label into a CSS class (spaces + case → dashes / lower).
if (!b) return "b-default"; if (!b) return "b-default";