Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs([move-usenextevalcountdown-to-hooks]): archive to DONE.md

[._.]/ Adam Eivybdc4ed1c9c25
diff --git a/DONE.md b/DONE.md
index 34db5536b7..8839532e4f 100644
--- a/DONE.md
+++ b/DONE.md
@@ -10,6 +10,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./
### 2026-05-19
+- **[move-usenextevalcountdown-to-hooks] Move `useNextEvalCountdown` from `components/cos/` to `client/src/hooks/`.** Relocated `client/src/components/cos/useNextEvalCountdown.js` (1s-tick countdown to the next CoS evaluation) to `client/src/hooks/useNextEvalCountdown.js` to conform to the CLAUDE.md "Module Organization" rule that `useX` hooks live exclusively under `client/src/hooks/`. Dropped the re-export from `components/cos/index.js`, added the catalog row to `client/src/hooks/README.md` (Apps / Sessions / Domain), and added the barrel re-export to `client/src/hooks/index.js`. Only consumer (`client/src/pages/ChiefOfStaff.jsx`) now imports the hook directly from `../hooks/useNextEvalCountdown`, matching the existing direct-import pattern it already uses for `useSocket` and `useLocalStorageBool`. Pure relocation — no behavioral changes. All 154 client tests pass (the `hooks/index.test.js` barrel-shape invariant test confirms the move is correctly wired).
- **[sharing-annotationssync-cache-bucket-asset-keys] Cache `listBucketAssetKeys` per (bucket, manifests-dir mtime).** `server/services/sharing/annotationsSync.js#listBucketAssetKeys` previously re-scanned every manifest in every auto-merge bucket on every 2s-debounced annotation flush. Manifests are the only source of truth post-v2 (content-addressed `assets/blobs/<hash>` paths don't carry filenames), so per-flush fan-out scaled O(buckets × manifests). The function now stats `<bucket>/manifests/` on each call and reuses the previously-parsed `Set<assetKey>` whenever the directory mtime matches — every manifest write/archive goes through `atomicWrite` (temp + rename) or `rename`, both of which bump the dir mtime, so the mtime is a complete invalidation signal. The legacy v1 `assets/{images,videos}/` dir scan stays uncached (small + rare fall-through). The annotation manifest emitted by `exportAnnotationsToBucket` rolls the cached mtime forward so the post-write bump doesn't immediately invalidate the same bucket's cache on the next flush. New `__resetBucketAssetKeysCache` test hook + 7 new vitest cases in `annotationsSync.test.js` covering hit, mtime-advance miss, per-bucket isolation, legacy-dir-scan-still-runs, ENOENT-on-manifests-dir as a stable cache key, non-ENOENT stat error bypasses caching, and post-write mtime-roll-forward keeps the next flush hot.
- **[export-isplainobject-helper-from-server-lib-objects] Export `isPlainObject` from `server/lib/objects.js`.** Promoted the previously-private `isPlainObject(v) = !!v && typeof v === 'object' && !Array.isArray(v)` helper to a named export of `server/lib/objects.js` (surfaces automatically through the `server/lib/index.js` barrel) and migrated 18 inline call sites onto it — every site that exactly matched the 3-part check pattern. Sites: the previously-private declarations in `server/lib/objects.js` + `server/lib/mediaModels.js` (which now imports from objects.js), the 12 sites enumerated in PLAN (`services/calendarAccounts.js`, `messageAccounts.js`, `messagePlaywrightSync.js`, `loras.js`, `mortalLoomStore.js`, `updateChecker.js`, `meatspacePost.js`, `dataSync.js`, `featureAgents.js`, `taskSchedule.js` — also dropped its single-use local `const isPlainObject`, `pipeline/issues.js`, `sharing/exporter.js`), and 4 additional matching sites that landed between when the PLAN entry was authored and now (`routes/loras.js#DELETE /auth/civitai`, `services/universeBuilderExpand.js#sanitizeCategory`, `server/scripts/moltbook-probe.mjs`, and `scripts/check-themes.js` ×2 — the last two caught by codex review after the initial grep missed `.mjs` files and the top-level `scripts/` dir). Sites with a partial-shape second predicate (`mortalLoomStore.js`'s `current[k] && typeof current[k] === 'object'` and the symmetric block in `featureAgents.js`) kept their second predicate intact — only the full 3-part check was migrated, keeping the PR a pure refactor. Helper retains the loose "non-null, non-array `object`" semantics that match every call site's behavior (Date / Map / class instances still return true — documented in the JSDoc and locked in by 3 new vitest cases). `server/lib/README.md` row updated to name both `deepMerge` and `isPlainObject`. No behavioral changes. All 5832 server tests + 154 client tests pass.
- **[unify-videogen-resolutions-with-shared-image-gen] Unify VideoGen `RESOLUTIONS` with shared image-gen list.** New `client/src/lib/videoGenResolutions.js` holding `VIDEO_RESOLUTIONS` as the companion to `imageGenResolutions.js`, registered in the lib barrel + README so future image+video work finds it via the catalog. New `resolveResolutionLabel(list, w, h) → { matched, label }` helper in `imageGenResolutions.js` collapses the duplicate "find matching preset OR fall back to `${w}×${h}` for the custom-fallback dropdown option" pattern that lived inline in both `client/src/pages/VideoGen.jsx` and `client/src/components/imageGen/ImageGenControls.jsx`. Both consumers now import the helper; image side's prior `(width && height ? ... : '')` empty-string-when-unset guard is preserved in the helper (returns `label: ''` when either dimension is falsy). Picked a distinct constant name (`VIDEO_RESOLUTIONS` vs the image side's `RESOLUTIONS`) to avoid a flat-barrel name collision in the lib `index.js` `export *` chain. All 154 client tests pass (barrel-shape test confirms the new module is wired correctly into both `index.js` and `README.md`).
diff --git a/PLAN.md b/PLAN.md
index a560451a22..294bedf53e 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -94,8 +94,6 @@ The 2026-04-25 CODEX 5.5 review's concrete bugs (Brain Feeds nav, Time Capsule n
### Deferred from better/2026-05-19
-- [ ] [move-usenextevalcountdown-to-hooks] **Move `useNextEvalCountdown` from `components/cos/` to `client/src/hooks/`.** `client/src/components/cos/useNextEvalCountdown.js` is a generic `useX` countdown hook living under `components/`, which the new "Module Organization" convention in CLAUDE.md places exclusively under `client/src/hooks/`. The other `useX`-named functions outside `hooks/` (`useThemeContext`, `useCitySettingsContext`, `useTokenEntries`) are context-consumer or pure `useMemo` helpers conventionally co-located with their providers — `useNextEvalCountdown` doesn't fit that exception. Surfaced by /simplify during the module-discovery PR; deferred to keep that PR scoped to infrastructure.
-
- [ ] **Migrate two remaining local formatters surfaced during the module-discovery PR.** Two additional local format definitions were found that aren't in the original tracker: (1) `client/src/components/calendar/EventDetail.jsx:10` defines `formatDateTime(dateStr, isAllDay)` with an all-day branch the shared `formatDateTime` lacks — extend the shared helper to take `{ allDay: true }` or keep this local and rename to `formatEventDateTime`. (2) `client/src/components/cos/tabs/TaskItem.jsx:78` defines `formatDurationMin(mins)` with a `~` approximation prefix (`~3h 30m`) — extend shared `formatDurationMin` with an `{ approximate: true }` option. Low priority; visual semantics need to be preserved exactly.
---