@bobfrankston/rmfmail 1.2.316 → 1.2.317

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/.commitmsg CHANGED
@@ -1,32 +1,37 @@
1
- New event: spelling suggestions, the right Google account, and a prompt refresh
1
+ Calendar sidebar: New event saves here, the list follows the date, Refresh pulls
2
2
 
3
- Three from Bob 2026-09-10 on the calendar sidebar's New event dialog.
3
+ Four from Bob 2026-09-10, all in the calendar sidebar.
4
4
 
5
- "Spelling correct didn't work." The main window's right-click handler
6
- replaced the native WebView2 menu with mailx's Cut/Copy/Paste block on
7
- every surface and Chromium's spelling suggestions and "Add to
8
- dictionary" exist only in the native menu, unreachable from JS. A word in
9
- the New event box was underlined with no menu that could fix it. Plain
10
- text controls (TEXTAREA, text-like INPUT) now keep the native menu, which
11
- already carries Cut/Copy/Paste/Select all for a text field; everything
12
- else is unchanged. (msger's compose items Bold, Italic, View source
13
- also appear on those fields via its IsEditable gate and forward to the
14
- compose frame, which is a no-op outside compose; cosmetic, noted.)
5
+ "Add an event puts me into Google Calendar. It should just save the event
6
+ because I can easily edit it later." The New event dialog now saves each
7
+ extracted event as a local row through createCalendarEvent the IPC and
8
+ the store-sync push to Google existed since the two-way cache and nothing
9
+ called them and the sidebar shows it at once; Google gets it from the
10
+ queue. The status line names what was saved. "Create as text" (AI parse
11
+ failed) becomes an all-day event today titled with the text. Wall-clock
12
+ times in a named zone are converted properly (wallClockToMs), so a "9am
13
+ Kuala Lumpur" invite stays 9am there. buildGoogleEventUrl, the authuser
14
+ work from v1.2.316 and the post-create refresh timers are gone with the
15
+ page they served.
15
16
 
16
- "I just used the add event but don't see them on Google calendar." The
17
- dialog opens Google Calendar's create page in the browser, which signs in
18
- as the browser's DEFAULT Google account, not necessarily the one mailx's
19
- calendar reads. The URL now carries authuser=<primary calendar account
20
- email> so the event lands where the sidebar looks.
17
+ "It is still showing me yesterday's calendar." The view date was fixed
18
+ when the module loaded and never moved. It now follows the calendar date
19
+ unless the reader has stepped to another day with › (Today clears
20
+ that), and re-renders at local midnight.
21
21
 
22
- "Creating an event should trigger an immediate update for the calendar
23
- view." The reader saves the event in the browser; mailx only learned of
24
- it at the next 5-minute throttled refresh. New refreshCalendarNow IPC
25
- (service, jsonrpc, mailxapi.js, api-client, MailxApi, Android stub that
26
- says ok:false) rewinds the throttle once and goes through
27
- getCalendarEvents, so the in-flight dedup and the calendarUpdated emit
28
- stay in one place; a 20 s floor of its own keeps it from reopening the
29
- quota hole the throttle closed. The sidebar arms it after a create: on
30
- the next window focus, and at 45 s / 2 min / 5 min in case the browser
31
- sits on another monitor. mailx-types 0.1.93, mailx-service 0.1.36,
32
- mailx-store-web 0.1.114.
22
+ "Still showing…" had a second cause: the Refresh button said "from
23
+ Google" and only re-read local rows the daemon's 5-minute throttle made
24
+ it a no-op most of the time. It now calls refreshCalendarNow (v1.2.316)
25
+ and reports when nothing was pulled and why. The window's focus does the
26
+ same, so an edit made in Google Calendar shows on coming back to rmfmail.
27
+
28
+ "How do I edit the calendar list? Perhaps more tooltip help would be
29
+ useful?" Every control in the sidebar header now says what it does and
30
+ what it does not: the calendar rows say that unticking hides a calendar
31
+ here while the list itself is the calendars selected in Google Calendar;
32
+ the ‹ › buttons say the list then stays on that day; New event says it
33
+ saves and how to edit. Event rows: click opens the event in Google
34
+ Calendar to edit; a just-saved row says it is syncing and cannot be
35
+ opened there yet; right-click offers Edit "‹title›" in Google Calendar
36
+ and Delete "‹title›" (local-first, queued to Google), with confirmAt at
37
+ the pointer.
@@ -57,3 +57,8 @@ tests/trust.test.ts, .commitmsg, TODO.md C165, root version 1.2.311. Then rebuil
57
57
  - Google account: buildGoogleEventUrl adds authuser=<primary calendar email> (getPrimaryAccount("calendar")).
58
58
  - Immediate update: refreshCalendarNow IPC (6 edits) + armPostCreateRefresh() in calendar-sidebar.ts (focus + 45s/2m/5m). Service floor 20s.
59
59
  - Status: compiled, bundles built, rebuild.cmd next, then restart.
60
+ - v1.2.316 published (spelling native menu, authuser, refreshCalendarNow). Superseded same morning:
61
+ New event now SAVES locally via createCalendarEvent (existing IPC + store-sync push, never called before);
62
+ buildGoogleEventUrl/authuser/post-create timers removed. viewPinned + followToday + midnight rollover.
63
+ Refresh button + window focus call refreshCalendarNow. Tooltips on all sidebar controls; event rows:
64
+ click = edit in Google, right-click = Delete "<title>" (deleteCalendarEvent). Publishing as v1.2.317.
@@ -6668,6 +6668,22 @@ __export(calendar_sidebar_exports, {
6668
6668
  isCalendarSidebarOn: () => isCalendarSidebarOn,
6669
6669
  showCalendarSidebar: () => showCalendarSidebar
6670
6670
  });
6671
+ function followToday() {
6672
+ if (viewPinned)
6673
+ return;
6674
+ const t = /* @__PURE__ */ new Date();
6675
+ viewYear = t.getFullYear();
6676
+ viewMonth = t.getMonth();
6677
+ viewDay = t.getDate();
6678
+ }
6679
+ function armMidnightRollover() {
6680
+ const now = /* @__PURE__ */ new Date();
6681
+ const next = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 5);
6682
+ window.setTimeout(() => {
6683
+ void refresh();
6684
+ armMidnightRollover();
6685
+ }, next.getTime() - now.getTime());
6686
+ }
6671
6687
  function calendarKind(id, primary) {
6672
6688
  if (primary)
6673
6689
  return "personal";
@@ -6747,7 +6763,7 @@ async function renderCalendarList() {
6747
6763
  host.innerHTML = "";
6748
6764
  } else {
6749
6765
  const sorted = [...list].sort((a, b) => (a.primary ? 0 : 1) - (b.primary ? 0 : 1) || a.name.localeCompare(b.name));
6750
- host.innerHTML = sorted.map((c) => `<label class="cal-side-cal-row" title="${escapeHtml6(c.name)}">
6766
+ host.innerHTML = sorted.map((c) => `<label class="cal-side-cal-row" title="${escapeHtml6(c.name)} \u2014 untick to hide its events in this list. Which calendars are listed is set in Google Calendar: the ones selected there appear; use Refresh after changing it.">
6751
6767
  <input type="checkbox" class="cal-side-cal-check" data-cal-id="${escapeHtml6(c.id)}" ${hiddenCalendars.has(c.id) ? "" : "checked"}>
6752
6768
  ${calIconHtml(c)}
6753
6769
  <span class="cal-side-cal-name">${escapeHtml6(c.name)}</span>
@@ -6956,7 +6972,7 @@ function renderEvents(events) {
6956
6972
  <span class="cal-side-event-title cal-side-event-holiday-title" title="${escapeHtml6(e.title)}">${calIconHtml(info)} ${escapeHtml6(e.title)}</span>
6957
6973
  </div>`;
6958
6974
  } else {
6959
- const titleAttr = link ? 'title="Click to open in Google Calendar"' : "";
6975
+ const titleAttr = link ? 'title="Click to open in Google Calendar to edit it. Right-click for more."' : 'title="Saved in rmfmail, syncing to Google \u2014 it can be opened there once it has synced. Right-click to delete."';
6960
6976
  html += `<div class="cal-side-event" data-id="${e.id}"${recurAttr} data-link="${escapeHtml6(link)}" ${titleAttr}>
6961
6977
  ${calIconHtml(info)}
6962
6978
  <span class="cal-side-event-time">${escapeHtml6(formatTime(e))}</span>
@@ -7001,18 +7017,43 @@ function renderEvents(events) {
7001
7017
  el.addEventListener("contextmenu", (e) => {
7002
7018
  e.preventDefault();
7003
7019
  const link = el.dataset.link;
7020
+ const uuid = el.dataset.id || "";
7021
+ const title = el.querySelector(".cal-side-event-title")?.textContent?.trim() || "this event";
7004
7022
  const items = [];
7005
7023
  if (link)
7006
7024
  items.push({
7007
- label: "View in browser",
7025
+ label: `Edit "${title}" in Google Calendar`,
7008
7026
  action: () => openInBrowser(link)
7009
7027
  });
7010
7028
  items.push({
7011
7029
  label: "Open Google Calendar",
7012
7030
  action: () => openInBrowser("https://calendar.google.com/")
7013
7031
  });
7014
- if (items.length > 0)
7015
- showContextMenu(e.clientX, e.clientY, items, { editTarget: e.target });
7032
+ if (uuid) {
7033
+ items.push({ label: "", action: () => {
7034
+ }, separator: true });
7035
+ items.push({
7036
+ label: `Delete "${title}"`,
7037
+ tooltip: "Removes it from your calendar in rmfmail now and from Google when it syncs.",
7038
+ action: async () => {
7039
+ if (!await confirmAt(e.clientX, e.clientY, `Delete "${title}"`))
7040
+ return;
7041
+ try {
7042
+ await deleteCalendarEvent(uuid);
7043
+ const st = document.getElementById("status-sync");
7044
+ if (st)
7045
+ st.textContent = `Deleted event: ${title}`;
7046
+ await refresh();
7047
+ } catch (err) {
7048
+ const st = document.getElementById("status-sync");
7049
+ if (st)
7050
+ st.textContent = `Couldn't delete "${title}": ${err?.message || err}`;
7051
+ console.error("[calendar] delete failed:", err);
7052
+ }
7053
+ }
7054
+ });
7055
+ }
7056
+ showContextMenu(e.clientX, e.clientY, items, { editTarget: e.target });
7016
7057
  });
7017
7058
  });
7018
7059
  }
@@ -7112,6 +7153,7 @@ async function renderTasks(prefetched) {
7112
7153
  });
7113
7154
  }
7114
7155
  async function refresh() {
7156
+ followToday();
7115
7157
  renderHead();
7116
7158
  const from = new Date(viewYear, viewMonth, viewDay);
7117
7159
  let prefetchedTasks;
@@ -7145,7 +7187,7 @@ function openNewEventDialog() {
7145
7187
  heading.textContent = "New event";
7146
7188
  const hint = document.createElement("div");
7147
7189
  hint.style.cssText = "font-size:0.9em;color:var(--color-text-muted);";
7148
- hint.textContent = "Describe the event in plain English \u2014 AI extracts the details and opens Google Calendar to confirm.";
7190
+ hint.textContent = "Describe the event in plain English \u2014 AI extracts the details and saves it to your calendar. Edit it afterwards if it needs adjusting.";
7149
7191
  const ta = document.createElement("textarea");
7150
7192
  ta.style.cssText = "width:100%;min-height:120px;font:inherit;padding:8px;border-radius:4px;border:1px solid var(--color-border, #ccc);box-sizing:border-box;resize:vertical;";
7151
7193
  ta.placeholder = "Lunch with John tomorrow at noon at Joe's Pizza";
@@ -7216,92 +7258,60 @@ function openNewEventDialog() {
7216
7258
  return;
7217
7259
  }
7218
7260
  }
7219
- const api = window.mailxapi;
7220
7261
  const targets = events.length ? events : [null];
7221
- let authuser = "";
7222
- try {
7223
- authuser = String((await getPrimaryAccount("calendar"))?.email || "");
7224
- } catch (e) {
7225
- console.warn("[calendar] primary account lookup failed, opening without authuser:", e?.message || e);
7226
- }
7262
+ const saved = [];
7227
7263
  for (const ev of targets) {
7228
- const url = buildGoogleEventUrl(ev, text, authuser);
7229
- if (api?.openExternal)
7230
- api.openExternal(url);
7231
- else
7232
- window.open(url, "_blank");
7264
+ const row = eventToLocalRow(ev, text);
7265
+ try {
7266
+ await createCalendarEvent(row);
7267
+ saved.push(row.title);
7268
+ } catch (e) {
7269
+ status.textContent = `Couldn't save "${row.title}": ${e?.message || e}`;
7270
+ createBtn.disabled = false;
7271
+ cancelBtn.disabled = false;
7272
+ return;
7273
+ }
7233
7274
  }
7234
- armPostCreateRefresh();
7235
7275
  close();
7276
+ const st = document.getElementById("status-sync");
7277
+ if (st)
7278
+ st.textContent = saved.length === 1 ? `Saved event: ${saved[0]}` : `Saved ${saved.length} events: ${saved.join("; ")}`;
7279
+ await refresh();
7236
7280
  });
7237
7281
  }
7238
- function armPostCreateRefresh() {
7239
- disarmPostCreateRefresh();
7240
- const pull = async (why) => {
7241
- try {
7242
- const r = await refreshCalendarNow();
7243
- if (!r?.ok)
7244
- console.log(`[calendar] post-create refresh (${why}) not started: ${r?.reason || "unknown"}`);
7245
- } catch (e) {
7246
- console.warn(`[calendar] post-create refresh (${why}) failed:`, e?.message || e);
7247
- }
7248
- };
7249
- postCreateFocusHandler = () => {
7250
- void pull("window focus");
7251
- };
7252
- window.addEventListener("focus", postCreateFocusHandler);
7253
- postCreateTimers = POST_CREATE_REFRESH_DELAYS_MS.map((ms, i) => window.setTimeout(() => {
7254
- void pull(`${ms / 1e3} s after create`);
7255
- if (i === POST_CREATE_REFRESH_DELAYS_MS.length - 1)
7256
- disarmPostCreateRefresh();
7257
- }, ms));
7258
- }
7259
- function disarmPostCreateRefresh() {
7260
- for (const t of postCreateTimers)
7261
- window.clearTimeout(t);
7262
- postCreateTimers = [];
7263
- if (postCreateFocusHandler)
7264
- window.removeEventListener("focus", postCreateFocusHandler);
7265
- postCreateFocusHandler = null;
7266
- }
7267
- function buildGoogleEventUrl(event, fallbackText, authuser = "") {
7268
- const base = "https://calendar.google.com/calendar/render?action=TEMPLATE";
7269
- const params = [];
7270
- if (authuser)
7271
- params.push(`authuser=${encodeURIComponent(authuser)}`);
7272
- const fmt = (iso) => {
7273
- const m = iso.match(/(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?)?/);
7274
- if (!m)
7275
- return "";
7276
- const [, y, mo, d, hh, mm, ss] = m;
7277
- const date = `${y}${mo}${d}`;
7278
- if (!hh)
7279
- return date;
7280
- return `${date}T${hh}${mm}${ss || "00"}`;
7281
- };
7282
- if (event?.title)
7283
- params.push(`text=${encodeURIComponent(event.title)}`);
7282
+ function eventToLocalRow(event, fallbackText) {
7283
+ const startOfToday = /* @__PURE__ */ new Date();
7284
+ startOfToday.setHours(0, 0, 0, 0);
7285
+ if (!event?.startISO) {
7286
+ return { title: (event?.title || fallbackText).slice(0, 200), startMs: startOfToday.getTime(), endMs: startOfToday.getTime() + 864e5, allDay: true };
7287
+ }
7288
+ const allDay = !!event.allDay || !event.startISO.includes("T");
7289
+ const startMs = allDay ? (/* @__PURE__ */ new Date(event.startISO.slice(0, 10) + "T00:00:00")).getTime() : wallClockToMs(event.startISO, event.timeZone);
7290
+ let endMs;
7291
+ if (event.endISO)
7292
+ endMs = allDay ? (/* @__PURE__ */ new Date(event.endISO.slice(0, 10) + "T00:00:00")).getTime() : wallClockToMs(event.endISO, event.timeZone);
7284
7293
  else
7285
- params.push(`text=${encodeURIComponent(fallbackText.slice(0, 200))}`);
7286
- if (event?.startISO) {
7287
- const startFmt = fmt(event.startISO);
7288
- if (event.allDay) {
7289
- const startDate = /* @__PURE__ */ new Date(event.startISO + (event.startISO.includes("T") ? "" : "T00:00:00"));
7290
- const endDate = new Date(startDate.getTime() + 864e5);
7291
- const endFmt = `${endDate.getFullYear()}${String(endDate.getMonth() + 1).padStart(2, "0")}${String(endDate.getDate()).padStart(2, "0")}`;
7292
- params.push(`dates=${startFmt}/${endFmt}`);
7293
- } else {
7294
- const endFmt = event.endISO ? fmt(event.endISO) : fmt(new Date(new Date(event.startISO).getTime() + 36e5).toISOString().slice(0, 19));
7295
- params.push(`dates=${startFmt}/${endFmt}`);
7294
+ endMs = startMs + (allDay ? 864e5 : 36e5);
7295
+ if (allDay && endMs <= startMs)
7296
+ endMs = startMs + 864e5;
7297
+ return { title: event.title || fallbackText.slice(0, 200), startMs, endMs, allDay, location: event.location || void 0, notes: event.notes || void 0 };
7298
+ }
7299
+ function wallClockToMs(iso, timeZone) {
7300
+ const local = new Date(iso).getTime();
7301
+ if (!timeZone)
7302
+ return local;
7303
+ try {
7304
+ let ms = local;
7305
+ for (let i = 0; i < 2; i++) {
7306
+ const parts = new Intl.DateTimeFormat("en-US", { timeZone, hourCycle: "h23", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }).formatToParts(new Date(ms)).reduce((o, p) => (o[p.type] = p.value, o), {});
7307
+ const asIfLocal = (/* @__PURE__ */ new Date(`${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}`)).getTime();
7308
+ ms += local - asIfLocal;
7296
7309
  }
7310
+ return ms;
7311
+ } catch (e) {
7312
+ console.warn(`[calendar] unknown time zone "${timeZone}", reading the time as local:`, e?.message || e);
7313
+ return local;
7297
7314
  }
7298
- if (event?.location)
7299
- params.push(`location=${encodeURIComponent(event.location)}`);
7300
- if (event?.notes)
7301
- params.push(`details=${encodeURIComponent(event.notes)}`);
7302
- if (event?.timeZone)
7303
- params.push(`ctz=${encodeURIComponent(event.timeZone)}`);
7304
- return `${base}&${params.join("&")}`;
7305
7315
  }
7306
7316
  async function showCalendarSidebar() {
7307
7317
  const el = document.getElementById("calendar-sidebar");
@@ -7345,6 +7355,7 @@ function initCalendarSidebar() {
7345
7355
  el.addEventListener("click", fn);
7346
7356
  };
7347
7357
  wireOnce("cal-side-prev", () => {
7358
+ viewPinned = true;
7348
7359
  const d = new Date(viewYear, viewMonth, viewDay - 1);
7349
7360
  viewYear = d.getFullYear();
7350
7361
  viewMonth = d.getMonth();
@@ -7352,6 +7363,7 @@ function initCalendarSidebar() {
7352
7363
  refresh();
7353
7364
  });
7354
7365
  wireOnce("cal-side-next", () => {
7366
+ viewPinned = true;
7355
7367
  const d = new Date(viewYear, viewMonth, viewDay + 1);
7356
7368
  viewYear = d.getFullYear();
7357
7369
  viewMonth = d.getMonth();
@@ -7359,12 +7371,22 @@ function initCalendarSidebar() {
7359
7371
  refresh();
7360
7372
  });
7361
7373
  wireOnce("cal-side-today", () => {
7362
- const t = /* @__PURE__ */ new Date();
7363
- viewYear = t.getFullYear();
7364
- viewMonth = t.getMonth();
7365
- viewDay = t.getDate();
7374
+ viewPinned = false;
7375
+ followToday();
7366
7376
  refresh();
7367
7377
  });
7378
+ if (!window.__mailxCalRolloverArmed) {
7379
+ window.__mailxCalRolloverArmed = true;
7380
+ armMidnightRollover();
7381
+ window.addEventListener("focus", () => {
7382
+ if (!isCalendarSidebarOn())
7383
+ return;
7384
+ void refreshCalendarNow().then((r) => {
7385
+ if (!r?.ok && r?.reason && !/refreshed \d+ s ago/.test(r.reason))
7386
+ console.log(`[calendar] focus refresh not started: ${r.reason}`);
7387
+ }).catch((e) => console.warn("[calendar] focus refresh failed:", e?.message || e));
7388
+ });
7389
+ }
7368
7390
  wireOnce("cal-side-new", () => {
7369
7391
  openNewEventDialog();
7370
7392
  });
@@ -7399,7 +7421,12 @@ function initCalendarSidebar() {
7399
7421
  if (btn)
7400
7422
  btn.disabled = true;
7401
7423
  try {
7402
- await Promise.all([renderCalendarList(), refresh()]);
7424
+ const [, , pulled] = await Promise.all([renderCalendarList(), refresh(), refreshCalendarNow()]);
7425
+ if (!pulled?.ok) {
7426
+ const st = document.getElementById("status-sync");
7427
+ if (st)
7428
+ st.textContent = `Calendar not pulled from Google: ${pulled?.reason || "unknown"}`;
7429
+ }
7403
7430
  } finally {
7404
7431
  setTimeout(() => {
7405
7432
  btn?.classList.remove("cal-side-refreshing");
@@ -7493,7 +7520,7 @@ function initCalendarSidebar() {
7493
7520
  }
7494
7521
  }
7495
7522
  }
7496
- var SIDEBAR_PREF, SHOW_RECURRING_PREF, SHOW_DONE_PREF, HORIZON_DAYS_PREF, HORIZON_DEFAULT_DAYS, HOLIDAY_HORIZON_MS, viewYear, viewMonth, viewDay, lastEvents, lastOverdueTasks, calById, calendarList, hiddenCalendars, selectedTaskUuids, TASK_DELETE_NOTE, POST_CREATE_REFRESH_DELAYS_MS, postCreateTimers, postCreateFocusHandler;
7523
+ var SIDEBAR_PREF, SHOW_RECURRING_PREF, SHOW_DONE_PREF, HORIZON_DAYS_PREF, HORIZON_DEFAULT_DAYS, HOLIDAY_HORIZON_MS, viewYear, viewMonth, viewDay, viewPinned, lastEvents, lastOverdueTasks, calById, calendarList, hiddenCalendars, selectedTaskUuids, TASK_DELETE_NOTE;
7497
7524
  var init_calendar_sidebar = __esm({
7498
7525
  "client/components/calendar-sidebar.js"() {
7499
7526
  "use strict";
@@ -7508,6 +7535,7 @@ var init_calendar_sidebar = __esm({
7508
7535
  viewYear = (/* @__PURE__ */ new Date()).getFullYear();
7509
7536
  viewMonth = (/* @__PURE__ */ new Date()).getMonth();
7510
7537
  viewDay = (/* @__PURE__ */ new Date()).getDate();
7538
+ viewPinned = false;
7511
7539
  lastEvents = [];
7512
7540
  lastOverdueTasks = [];
7513
7541
  calById = /* @__PURE__ */ new Map();
@@ -7515,9 +7543,6 @@ var init_calendar_sidebar = __esm({
7515
7543
  hiddenCalendars = /* @__PURE__ */ new Set();
7516
7544
  selectedTaskUuids = /* @__PURE__ */ new Set();
7517
7545
  TASK_DELETE_NOTE = "Removes it from Google Tasks. To mark it done instead, use the checkbox.";
7518
- POST_CREATE_REFRESH_DELAYS_MS = [45e3, 12e4, 3e5];
7519
- postCreateTimers = [];
7520
- postCreateFocusHandler = null;
7521
7546
  }
7522
7547
  });
7523
7548