@bobfrankston/mailx-imap 0.1.109 → 0.1.110

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.
Files changed (2) hide show
  1. package/index.js +16 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1764,7 +1764,18 @@ export class ImapManager extends EventEmitter {
1764
1764
  // Apply changed-state FETCH — flag updates since prior modSeq.
1765
1765
  for (const m of qr.changedMessages) {
1766
1766
  try {
1767
+ // LOCAL-FIRST: never let a server reconcile clobber a flag
1768
+ // the user just changed locally but whose push hasn't drained
1769
+ // yet — that's the "I unflag it and it quickly comes back"
1770
+ // bug (Bob 2026-06-27). Skip any message with a pending flag
1771
+ // action; the drain will push it and a later reconcile syncs.
1772
+ const pendingFlag = this.db.findPendingSyncAction(accountId, "flags", m.uid, folderId);
1773
+ if (pendingFlag) {
1774
+ console.error(` [flag-reconcile] SKIP uid=${m.uid} folder=${folderId} — pending local flag action wins`);
1775
+ continue;
1776
+ }
1767
1777
  const flagsArr = Array.from(m.flags || []).map(f => String(f));
1778
+ console.error(` [flag-reconcile] OVERWRITE uid=${m.uid} folder=${folderId} server=[${flagsArr.join(",")}]`);
1768
1779
  this.db.updateMessageFlags(accountId, folderId, m.uid, flagsArr);
1769
1780
  }
1770
1781
  catch { /* row may have just been VANISHED */ }
@@ -4168,13 +4179,17 @@ export class ImapManager extends EventEmitter {
4168
4179
  const MANAGED = ["\\Seen", "\\Flagged"];
4169
4180
  const impliedRemove = MANAGED.filter(f => !desired.includes(f));
4170
4181
  const toRemove = [...new Set([...explicitRemove, ...impliedRemove])];
4182
+ // console.error so it lands in the captured daemon log
4183
+ // (worker stdout is NOT piped; stderr is). Temporary
4184
+ // diagnostic for the "flag won't persist" hunt.
4185
+ console.error(` [flag-drain] ${accountId} uid=${action.uid} folder="${folder.path}" +[${desired.join(",")}] -[${toRemove.join(",")}]`);
4171
4186
  if (desired.length > 0) {
4172
4187
  await client.addFlags(folder.path, action.uid, desired);
4173
4188
  }
4174
4189
  if (toRemove.length > 0) {
4175
4190
  await client.removeFlags(folder.path, action.uid, toRemove);
4176
4191
  }
4177
- console.log(` [sync] Updated flags UID ${action.uid} (+[${desired.join(",")}] -[${toRemove.join(",")}])`);
4192
+ console.error(` [flag-drain] ${accountId} uid=${action.uid} OK (server STORE done)`);
4178
4193
  break;
4179
4194
  }
4180
4195
  case "append": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.109",
3
+ "version": "0.1.110",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",