@bobfrankston/rmfmail 1.2.304 → 1.2.305

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/client/app.js CHANGED
@@ -1774,18 +1774,53 @@ function popUndo() {
1774
1774
  }
1775
1775
  return null;
1776
1776
  }
1777
- /** Route a "delete the selection" action (Delete key, Ctrl+D, top trash
1778
- * button) to whichever pane has a selection. Tasks take priority if
1779
- * any task rows are selected, delete those; otherwise fall through to
1780
- * messages. The previous behavior was to always delete messages, which
1781
- * surprised users who'd just selected a few tasks and hit Delete. */
1777
+ /** Which pane the user last acted in. Delete / Ctrl+D / the trash buttons are
1778
+ * app-wide gestures, so before they can act on "the selection" they have to
1779
+ * know WHOSE selection is meant, and the honest answer is the pane the user
1780
+ * was last working in not a fixed priority order.
1781
+ *
1782
+ * Capture phase, pointerdown: it must land before any handler that stops
1783
+ * propagation, and before focus moves. The toolbar buttons themselves are in
1784
+ * neither pane, so clicking one leaves this exactly as the user's last real
1785
+ * interaction set it. */
1786
+ let lastActionPane = "messages";
1787
+ document.addEventListener("pointerdown", (e) => {
1788
+ const t = e.target;
1789
+ if (!t?.closest)
1790
+ return;
1791
+ if (t.closest("#cal-side-tasks"))
1792
+ lastActionPane = "tasks";
1793
+ else if (t.closest(".message-list, .message-viewer, #ml-body, #message-viewer"))
1794
+ lastActionPane = "messages";
1795
+ }, true);
1796
+ /** Route a "delete the selection" action (Delete key, Ctrl+D, either trash
1797
+ * button) to the pane the user was last working in.
1798
+ *
1799
+ * 2026-09-05 — Claude Code (Opus 5), at Bob's direction ("I press del and the
1800
+ * message is not deleted whether I'm in the letter or summary and trashcan is
1801
+ * not working"). This used to give tasks an unconditional priority: any
1802
+ * non-empty task selection swallowed every delete gesture in the app. A task
1803
+ * selection is set by a single click on a task row, is never cleared by
1804
+ * anything the user does in the mail panes, and has no indicator outside the
1805
+ * sidebar — so one stray click on a task disabled Delete and both trash
1806
+ * buttons for messages, indefinitely, with no symptom other than nothing
1807
+ * happening. That is invisible modal state deciding what a destructive action
1808
+ * means, which is the same fault as a filter that reads as a selection.
1809
+ *
1810
+ * Routing on the last-touched pane keeps the behaviour the priority rule was
1811
+ * written for (select some tasks, press Delete, the tasks go) and drops the
1812
+ * part that was never intended. Acting on messages also clears any leftover
1813
+ * task selection, so the sidebar stops showing rows as chosen when the
1814
+ * gesture has plainly moved on. */
1782
1815
  async function deleteSelection() {
1783
1816
  try {
1784
1817
  const sidebar = await import("./components/calendar-sidebar.js");
1785
- if (sidebar.getSelectedTaskUuids().length > 0) {
1818
+ if (lastActionPane === "tasks" && sidebar.getSelectedTaskUuids().length > 0) {
1786
1819
  await sidebar.deleteSelectedTasks();
1787
1820
  return;
1788
1821
  }
1822
+ if (sidebar.getSelectedTaskUuids().length > 0)
1823
+ sidebar.clearTaskSelection();
1789
1824
  }
1790
1825
  catch { /* sidebar module not loaded yet — fall through to messages */ }
1791
1826
  await deleteSelectedMessages();