theseus/home-preload.js

27 lines
1.5 KiB
JavaScript
Raw Normal View History

Theseus UX batch: tabs, address history, password autofill MVP, home cards Six user-visible improvements + supporting infra, all uncommitted from the earlier session-in-progress state. Ships together in one release. Chrome / tabs - Same-size tabs: flex 1 1 0 with max 200px, min 60px. Container gets overflow: hidden so many tabs shrink evenly instead of scrolling out. - Drag-and-drop tab reordering. HTML5 drag events on each .tab; drop side chosen by pointer x within target (Chrome UX). New move-tab IPC splices the tabs array + re-emits. Address bar - Persistent history at userData/history.json capped at 500 LRU. Ranked by host-prefix > url-prefix > contains > title-contains > recency. - Floating suggestions dropdown (addressPicker WebContentsView) anchored under the URL bar. Debounced 80ms input; ArrowUp/Down forward to the picker via address-cursor IPC; Enter fires goURL; blur closes after 160ms so click-through registers. New files address-picker.html + address-picker-preload.js. Cleared by existing clearHistoryOnQuit. Password autofill (A.2 MVP) - Green key chip in the address bar appears when the vault is UNLOCKED and the active tab's host has matching credentials (exact hostname match for phase 1; eTLD+1 upgrade queued as A.2.5). - Click chip → floating picker of usernames. Click a match → main.js runs a small script in the active tab: finds first visible input[type=password]:not([disabled]), walks the same form for a visible text/email/tel/url/search input whose name/id/autocomplete matches /username|user|email|login|account|id/, fills both via the native value setter + dispatches input/change so React/Vue-controlled inputs update. New files pw-fill.html + pw-fill-preload.js. - emitPwAvailability fires from pushNav + vault setup/unlock/lock so the chip's visibility + count stays accurate. Bookmarks bar - Right-click context menu on the favorites bar. On empty area: "Add current page" (or "Remove current page" if already saved). On a specific bookmark: "Open", "Edit title…" (prompt), "Remove", plus the add/remove-current entry. Uses a shared .ctxmenu style mirroring the settings ctxmenu (dark/light aware). - Empty-state text updated to mention right-click. Home page - Larger responsive card grid: auto-fill minmax(260-280px, 1fr) with breakpoints at 600/900/1200. Cards have a subtitle line, a colored badge (on-chain / Sia / server / custom), and edit affordances that reveal only in Edit mode. - User-editable set: Edit toggle reveals per-card ✎/✕ + a dashed "+ Add card" tile. Modal for add/edit with title / URL / subtitle / badge. Reset-to-defaults button. - Persisted at userData/home-cards.json. New home-preload.js exposes window.home = { getCards, setCards, resetCards, navigate }. IPC handlers in main.js validate sender.getURL() matches our own home.html — third-party pages see the API shape via the preload but can't act on the user's local cards. - Fallback set of 2 cards renders when window.home is unavailable (e.g. opening home.html directly outside Electron for preview) so the grid is never blank. Docs - TheseusNavigator/ROADMAP-identity-wallet.md — the phased plan for the two independent strands (password manager A.2/3, browser wallet B.1-6). Committed earlier this session; re-listed here for context. - TheseusNavigator/SESSION-PROMPT-identity-wallet.md — pastable kickoff for the next session picking up either strand. Files added to build.files: address-picker.html, address-picker-preload.js, pw-fill.html, pw-fill-preload.js, home-preload.js.
2026-08-17 02:17:12 +02:00
// Preload for tab webContents that host the built-in home page. All non-
// settings tabs get this preload since we don't know in advance whether a
// tab will land on home.html; the corresponding IPC handlers in main.js
// validate the sender's URL is our own home.html file:// and reject any
// origin-mismatched call, so a third-party page can inspect the API's
// SHAPE but can't invoke it against local user data.
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("home", {
getCards: () => ipcRenderer.invoke("home-cards-get"),
setCards: (cards) => ipcRenderer.invoke("home-cards-set", cards),
resetCards: () => ipcRenderer.invoke("home-cards-reset"),
navigate: (url) => ipcRenderer.invoke("navigate", url),
Ship Theseus 0.3.0 bb9d8dec (home cards decoupled from browser release) Setup bb9d8dec124b8e2a976642ed77051b04edd1d03185581f99db845ef168919836 Portable 1e2d02aea13656574c374440b0c41374290f1bbf85ac6313cec075292cfc34f8 Home cards decoupled from the installer. Theseus now fetches https://dl.silentmode.st/home-cards.json at boot and every 6h, caches into <userData>/home-cards-remote.json, and applies it as the default tier. Priority in loadHomeCards() is: 1. <userData>/home-cards.json (user edits — unchanged, always win) 2. <userData>/home-cards-remote.json (last successful fetch) 3. DEFAULT_HOME_CARDS (code fallback for offline first-boot) On a successful refresh, main pushes the new list to every home tab via the home-cards IPC — but only when the user has NO local edits. The user's edit mode remains authoritative. Content updates now happen by editing site/home-cards.json and running scp + sia-upload. No browser build required. Prometheus.X copy fix: "Decentralized App Marketplace" (was "marketplace for BCDN-hosted apps" — the marketplace isn't BCDN- specific). Applied to both DEFAULT_HOME_CARDS (fallback) and site/home-cards.json (canonical live copy). Deployed: - scp installers + manifest + tools/ + releases/ + home-cards.json to /opt/silent-mode/dl/ and /opt/silent-mode/site/ - sia-upload of both site trees - verified home-cards.json served 200, manifest 0.3.0 live Existing installs of 0.2.5 will surface 0.3.0 in the update chip and also pull the new home-cards.json — so the "Decentralized App Marketplace" wording lands on ANY current install (0.3.0+) the moment this commit deploys, without waiting for anyone to install 0.3.0. Wait — 0.3.0 is what CARRIES the fetch logic. So the auto-pull benefit only kicks in from 0.3.0 onward. Users on 0.2.5 or earlier need to install 0.3.0 once; from then on every home-card edit reaches them without a new browser release.
2026-08-31 18:38:09 +02:00
// Main pushes an updated list here after a successful remote refresh
// (only when the user has not customised locally). home.html re-renders.
onCards: (cb) => ipcRenderer.on("home-cards", (_e, list) => cb(list)),
Theseus UX batch: tabs, address history, password autofill MVP, home cards Six user-visible improvements + supporting infra, all uncommitted from the earlier session-in-progress state. Ships together in one release. Chrome / tabs - Same-size tabs: flex 1 1 0 with max 200px, min 60px. Container gets overflow: hidden so many tabs shrink evenly instead of scrolling out. - Drag-and-drop tab reordering. HTML5 drag events on each .tab; drop side chosen by pointer x within target (Chrome UX). New move-tab IPC splices the tabs array + re-emits. Address bar - Persistent history at userData/history.json capped at 500 LRU. Ranked by host-prefix > url-prefix > contains > title-contains > recency. - Floating suggestions dropdown (addressPicker WebContentsView) anchored under the URL bar. Debounced 80ms input; ArrowUp/Down forward to the picker via address-cursor IPC; Enter fires goURL; blur closes after 160ms so click-through registers. New files address-picker.html + address-picker-preload.js. Cleared by existing clearHistoryOnQuit. Password autofill (A.2 MVP) - Green key chip in the address bar appears when the vault is UNLOCKED and the active tab's host has matching credentials (exact hostname match for phase 1; eTLD+1 upgrade queued as A.2.5). - Click chip → floating picker of usernames. Click a match → main.js runs a small script in the active tab: finds first visible input[type=password]:not([disabled]), walks the same form for a visible text/email/tel/url/search input whose name/id/autocomplete matches /username|user|email|login|account|id/, fills both via the native value setter + dispatches input/change so React/Vue-controlled inputs update. New files pw-fill.html + pw-fill-preload.js. - emitPwAvailability fires from pushNav + vault setup/unlock/lock so the chip's visibility + count stays accurate. Bookmarks bar - Right-click context menu on the favorites bar. On empty area: "Add current page" (or "Remove current page" if already saved). On a specific bookmark: "Open", "Edit title…" (prompt), "Remove", plus the add/remove-current entry. Uses a shared .ctxmenu style mirroring the settings ctxmenu (dark/light aware). - Empty-state text updated to mention right-click. Home page - Larger responsive card grid: auto-fill minmax(260-280px, 1fr) with breakpoints at 600/900/1200. Cards have a subtitle line, a colored badge (on-chain / Sia / server / custom), and edit affordances that reveal only in Edit mode. - User-editable set: Edit toggle reveals per-card ✎/✕ + a dashed "+ Add card" tile. Modal for add/edit with title / URL / subtitle / badge. Reset-to-defaults button. - Persisted at userData/home-cards.json. New home-preload.js exposes window.home = { getCards, setCards, resetCards, navigate }. IPC handlers in main.js validate sender.getURL() matches our own home.html — third-party pages see the API shape via the preload but can't act on the user's local cards. - Fallback set of 2 cards renders when window.home is unavailable (e.g. opening home.html directly outside Electron for preview) so the grid is never blank. Docs - TheseusNavigator/ROADMAP-identity-wallet.md — the phased plan for the two independent strands (password manager A.2/3, browser wallet B.1-6). Committed earlier this session; re-listed here for context. - TheseusNavigator/SESSION-PROMPT-identity-wallet.md — pastable kickoff for the next session picking up either strand. Files added to build.files: address-picker.html, address-picker-preload.js, pw-fill.html, pw-fill-preload.js, home-preload.js.
2026-08-17 02:17:12 +02:00
});
Theseus 0.1.3: branded error page for load failures (BUILT, NOT DEPLOYED) Setup f2afc14efc63008cbb9dad44176e94146386db4c0afda4459f1d4eb929172b6d Portable 5d08b1415526934db8de780949a610896064fe9567aa0e5e1702ebabd7eb7df2 Chromium's default 'This site can't be reached' replaced with a Theseus- themed error page. did-fail-load on every tab's webContents (main frame only, non-ignorable code) routes the tab to error.html with the attempt URL, host, error code, and description as query params. The page keeps t.url pointing at the failed URL so the address bar shows what the user typed and they can edit + retry - refreshTabUrl's existing file:// skip means the error page's own path never leaks back into the bar. Five kinds, chosen by pickErrorKind(code, host): name-not-registered BCNR-eligible host + ERR_NAME_NOT_RESOLVED. Says "no BCDN record on chain, no clearnet host either." Offers Register on Sirius + Search + Retry + Home. name-unreachable ERR_NAME_NOT_RESOLVED on a non-BCNR host. DNS failed - offers Retry + Search + Register + Home. unreachable CONN_REFUSED/RESET/TIMED_OUT/CLOSED/NETWORK_CHANGED. Offers Retry + Tor guide + Home. tls ERR_CERT_* range (-200..-299). Offers Retry + Home. generic Everything else. home-preload.js gains `window.errorpage` alongside `window.home`. Both APIs are sender-URL-gated in main - a random page seeing the shape can't invoke them (isErrorPageSender / isHomePageSender). The external- open handler additionally allowlists Silent Mode domains only. package.json build.files gets error.html + error-preload.js so electron-builder actually bundles them (GOTCHAS rule: an unlisted runtime-loaded file silently opens blank). Ship pages (releases-manifest.json, tools/index.html, releases/index.html, site-theseus-x/index.html) updated to 0.1.3 with the new hashes. DEPLOY STATUS - blocked on VPS SSH: my IP was hit with a full-port ban mid-turn (likely fail2ban from the burst of scp during the 0.1.0-0.1.2 iterations). Site pages/manifest/installers are committed locally but NOT yet on dl.silentmode.st or the Sia mirror. Live still reads 0.1.2. User needs to unban 195.184.247.106 on their end, or wait for the ban to expire, before the ship pages match reality.
2026-08-31 13:38:05 +02:00
// Same preload also serves the branded error page (error.html). Handlers in
// main.js sender-check for error.html so a random page seeing the API shape
// can't drive navigation.
contextBridge.exposeInMainWorld("errorpage", {
retry: (url) => ipcRenderer.invoke("error-retry", url),
goHome: () => ipcRenderer.invoke("error-home"),
searchFor: (text) => ipcRenderer.invoke("error-search", text),
registerOnSirius: (host) => ipcRenderer.invoke("error-register", host),
openExternal: (url) => ipcRenderer.invoke("error-open-external", url),
});