fix: improve error handling across Rust and TypeScript

- Log swallowed errors in file watcher and window operations (lib.rs, watcher.rs)
- Propagate recovery errors from bridge::recover_pending to SyncResult.errors
  so the frontend can display them instead of silently dropping failures
- Fix useTauriEvent/useTauriEvents race condition where cleanup fires before
  async listen() resolves, leaking the listener (cancelled flag pattern)
- Guard computeStaleness against invalid date strings (NaN -> 'normal'
  instead of incorrectly returning 'urgent')
- Strengthen isMcError type guard to check field types, not just presence
- Log warning when data directory resolution falls back to '.' (state.rs, bridge.rs)
- Add test for computeStaleness with invalid date inputs
This commit is contained in:
teernisse
2026-02-26 10:13:17 -05:00
parent 29b44f1b4c
commit 23a4e6bf19
7 changed files with 556 additions and 13 deletions

View File

@@ -31,6 +31,12 @@ describe("computeStaleness", () => {
).toISOString();
expect(computeStaleness(tenDaysAgo)).toBe("urgent");
});
it("returns 'normal' for invalid date strings instead of 'urgent'", () => {
expect(computeStaleness("not-a-date")).toBe("normal");
expect(computeStaleness("")).toBe("normal");
expect(computeStaleness("2026-13-99T99:99:99Z")).toBe("normal");
});
});
describe("isMcError", () => {