@bobfrankston/rmfmail 1.2.180 → 1.2.182

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/mailx.js CHANGED
@@ -328,6 +328,26 @@ function registerMailtoWindows(unregister) {
328
328
  lines.push("app on this PC\" to reach rmfmail.");
329
329
  return { ok: failed === 0, message: lines.join("\n") };
330
330
  }
331
+ /** Cheap probe: is the mailto registration already in place AND pointing at
332
+ * an up-to-date per-app launcher? Lets daemon startup skip the full
333
+ * ~15-reg.exe-spawn registration pass on every boot. Stale cases that
334
+ * return false: never registered, launcher missing, or the npm package
335
+ * ships a newer rmfmailto.exe than the per-app copy (post-update). */
336
+ function mailtoRegistrationCurrent() {
337
+ try {
338
+ const perApp = path.join(process.env.LOCALAPPDATA || "", "rmfmail", "bin", "rmfmailto.exe");
339
+ if (!fs.existsSync(perApp))
340
+ return false;
341
+ const pkgExe = path.join(import.meta.dirname, "rmfmailto.exe");
342
+ if (fs.existsSync(pkgExe) && fs.statSync(pkgExe).mtimeMs > fs.statSync(perApp).mtimeMs)
343
+ return false;
344
+ const out = execSync(`reg query "HKCU\\Software\\Classes\\rmfmail\\shell\\open\\command" /ve`, { stdio: ["pipe", "pipe", "pipe"] }).toString();
345
+ return out.toLowerCase().includes(perApp.toLowerCase());
346
+ }
347
+ catch {
348
+ return false;
349
+ }
350
+ }
331
351
  if (hasFlag("register-mailto") || hasFlag("unregister-mailto")) {
332
352
  const unregister = hasFlag("unregister-mailto");
333
353
  // C124: Linux registration — a .desktop entry claiming the mailto:
@@ -2068,6 +2088,15 @@ RFC 5322 with CRLF line endings. Bodies are quoted-printable encoded (readable i
2068
2088
  // chunks for a few minutes, which a one-shot CLI command shouldn't wait
2069
2089
  // on. No-op once converted.
2070
2090
  db.startFtsTrigramMigration();
2091
+ // Background FTS body backfill: index body text for messages whose .eml
2092
+ // is on disk but whose FTS row is preview-only (the read-only-worker
2093
+ // backfill bug left ~179k rows body-less — "orwell finds one message",
2094
+ // Bob 2026-07-27). Paced one parse per ~100 ms; skips indexed rows, so
2095
+ // once caught up each boot's re-scan costs seconds. Start after 3 min
2096
+ // so boot sync and first paints aren't competing with sweep parses.
2097
+ setTimeout(() => {
2098
+ store.runFtsBodyBackfillSweep().catch((e) => console.error(` [fts-backfill] sweep failed: ${e?.message || e}`));
2099
+ }, 180_000);
2071
2100
  // Native client is the only option (iflow-direct)
2072
2101
  const svc = new MailxService(store, imapManager);
2073
2102
  // Loopback popout-window server (renders a single message for its own OS
@@ -2149,6 +2178,29 @@ RFC 5322 with CRLF line endings. Bodies are quoted-printable encoded (readable i
2149
2178
  // Linux/mac users still go through the CLI (xdg / TODO C124).
2150
2179
  if (process.platform === "win32") {
2151
2180
  svc.setMailtoRegisterFn(async () => registerMailtoWindows(false));
2181
+ // Auto-register at daemon startup (Bob 2026-07-27: "that should be
2182
+ // automatic"). Install-time is NOT a reliable hook — npm's
2183
+ // allowScripts policy skips this package's install scripts, so a
2184
+ // postinstall registration would silently never run. Startup runs on
2185
+ // every machine that actually launches the app, self-heals after
2186
+ // updates (probe notices a newer packaged rmfmailto.exe), and the
2187
+ // probe keeps already-registered boots to one reg.exe query.
2188
+ // Deferred 5s so the registration pass never sits in the boot path.
2189
+ // Registers rmfmail as an AVAILABLE mailto handler; Windows 11 still
2190
+ // requires the one-time Default-apps pick (UserChoice hash — C46).
2191
+ setTimeout(() => {
2192
+ try {
2193
+ if (mailtoRegistrationCurrent())
2194
+ return;
2195
+ const r = registerMailtoWindows(false);
2196
+ console.log(` [mailto] startup auto-registration ${r.ok ? "completed" : "FAILED"}`);
2197
+ if (!r.ok)
2198
+ console.log(r.message);
2199
+ }
2200
+ catch (e) {
2201
+ console.error(` [mailto] startup auto-registration failed: ${e?.message || e}`);
2202
+ }
2203
+ }, 5000);
2152
2204
  }
2153
2205
  svc.setPopupFn(async (opts) => {
2154
2206
  // Own WebView2 profile so a reminder popup can never share (and