@threadbase-sh/scanner 0.9.2 → 0.9.3

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/dist/index.js CHANGED
@@ -1781,6 +1781,19 @@ var ConversationFilesRepo = class {
1781
1781
  const rows = this.db.prepare("SELECT absolute_path FROM conversation_files WHERE status != 'deleted'").all();
1782
1782
  return rows.map((r) => r.absolute_path);
1783
1783
  }
1784
+ // Active file paths belonging to any of the given accounts. Backs the
1785
+ // deletion-reconcile so a scan that covered only some accounts can't mark
1786
+ // another account's files deleted (they live in the same shared index.db but
1787
+ // a different profile owns them). Returns [] for an empty account list.
1788
+ activePathsByAccounts(accounts) {
1789
+ if (accounts.length === 0) return [];
1790
+ const placeholders = accounts.map(() => "?").join(", ");
1791
+ const rows = this.db.prepare(
1792
+ `SELECT absolute_path FROM conversation_files
1793
+ WHERE status != 'deleted' AND account IN (${placeholders})`
1794
+ ).all(...accounts);
1795
+ return rows.map((r) => r.absolute_path);
1796
+ }
1784
1797
  // Active files whose immediate parent is exactly parentDir (no nested
1785
1798
  // subdirectories). Backs the dir-mtime gate's reuse path: a project dir with
1786
1799
  // an unchanged mtime and no nested files can skip the glob entirely.
@@ -2153,8 +2166,15 @@ var PersistentEngine = class {
2153
2166
  scanned += batch.length;
2154
2167
  options.onProgress?.(scanned, discovered.length);
2155
2168
  }
2169
+ const coveredAccounts = /* @__PURE__ */ new Set();
2170
+ if (enabled.includes(CLAUDE_CODE_PROVIDER)) {
2171
+ for (const p of activeProfiles) coveredAccounts.add(p.id);
2172
+ }
2173
+ if (enabled.includes(CODEX_CLI_PROVIDER) && (options.codexRoots?.length ?? 0) > 0) {
2174
+ coveredAccounts.add("codex");
2175
+ }
2156
2176
  const seen = new Set(discovered.map((d) => d.filePath));
2157
- for (const path of this.files.allActivePaths()) {
2177
+ for (const path of this.files.activePathsByAccounts([...coveredAccounts])) {
2158
2178
  if (!seen.has(path)) this.markDeleted(path);
2159
2179
  }
2160
2180
  log.info({ scanned, indexed: this.conversations.count() }, "persistent: indexAll complete");