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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (copilot): calendar_next matches endTime>=now (in-progress + all-day-today); vision toggle syncs when browser stops sharing
Adam Eivydcca068956a2
diff --git a/PLAN.md b/PLAN.mdindex 19713ac551..3b92b7a67b 100644--- a/PLAN.md+++ b/PLAN.md@@ -11,7 +11,7 @@ _Batch-cleared 2026-05-25: 23 Next Up items shipped together via parallel sub-ag- [ ] [peer-sync-per-category-version-gate] **Generalize the cross-install schema version gate from whole-payload to per-category.** Surfaced by code review during the batch-clear of `[peer-sync-video-collection-metadata-sync]` (2026-05-25). `compareSchemaVersions` (`server/lib/schemaVersions.js`) walks the UNION of category keys, and the three gate sites (`dataSync.js` `applyRemote`, `peerSync.js` push, `importer.js` import) reject the ENTIRE payload on any `ahead.length > 0`. So introducing a brand-new category key — or bumping one category — makes every not-yet-upgraded peer reject ALL categories (universe, pipeline, …), severing sync across a federation that upgrades on independent schedules. `videoHistory` sidestepped this by deliberately staying OUT of `PORTOS_SCHEMA_VERSIONS` (see the comment there), but `mediaCollections: 1` has the same latent property. Fix: scope the ahead-check to the category (for `applyRemote`/import) or the record's kind→category (for push) actually being transferred, so a newer sender's unknown/bumped category gates only THAT category's transfer, not unrelated ones. Keep the union-walk for diagnostics/UI. Needs new cross-key test coverage (today's tests only exercise same-category gaps).- [ ] [voice-weather-settings-location] **Wire a real `settings.location { lat, lon }` field so `weather_now` can use a configured location.** Surfaced during the batch-clear review of `[voice-cos-tool-expansion]` (2026-05-25). The `weather_now` voice tool already reads `settings?.location?.{lat,lon}` (forward-compatible, guarded) but no Settings UI or Zod slice ever sets it, so with no `lat`/`lon` args it always falls back to the default location. Add a `location` settings field (Settings UI + a Zod slice in `server/lib/validation.js`), then the existing tool path lights up. Small.- [ ] [mediacard-use-mediaimage-for-syncing-assets] **`MediaCard.jsx` grid thumbnails still use a raw `<img src={previewUrl}>`.** Same peer-sync placeholder/live-swap gap that `[peer-sync-medialightbox-use-mediaimage-for-syncing-assets]` fixed for the lightbox — `client/src/components/media/MediaCard.jsx` (~line 42) doesn't get the "Syncing" placeholder or the `peerSync:asset-arrived` atomic swap. Swap the raw `<img>` for `MediaImage`. Surfaced by that item's cross-check during the batch-clear (2026-05-25); was outside its stated scope.-- [ ] [voice-tool-edge-hardening] **Edge-case hardening for the new voice tools (all low-severity, from the xhigh code-review 2026-05-25).** (b) `calendar_next`'s in-memory filter requires `start >= now` while the server-side `getEvents` keeps `endTime >= now`, so a currently-in-progress meeting is skipped from "what's next?" — decide intended semantics (current+next vs strictly-future) and align the two layers (related: [voice-calendar-next-allday-edge] covers the all-day facet). (c) `timer_set` is a bare in-memory `setTimeout` with no persistence (lost silently on restart) and no dedup across tool-loop iterations (LLM re-issue → double notification). Also minor: `dataSync.js` per-`(category,forPeerId)` `checksumCache` keys are never evicted (unbounded for cycling peer ids; negligible for a home federation). _(Fixed in the v2.9.0 release review: (a) the `calendar_today` DST-offset bug — `anchorLocalMidnightUtc` now samples the offset at the target midnight; and `resolveExcludeSet` is now deferred to the `getChecksum` cache-miss path.)_+- [ ] [voice-tool-edge-hardening] **Edge-case hardening for the new voice tools (all low-severity, from the xhigh code-review 2026-05-25).** (c) `timer_set` is a bare in-memory `setTimeout` with no persistence (lost silently on restart) and no dedup across tool-loop iterations (LLM re-issue → double notification). Also minor: `dataSync.js` per-`(category,forPeerId)` `checksumCache` keys are never evicted (unbounded for cycling peer ids; negligible for a home federation). _(Fixed in the v2.9.0 release review: (a) the `calendar_today` DST-offset bug — `anchorLocalMidnightUtc` now samples the offset at the target midnight; (b) `calendar_next` now matches calendarSync's `endTime >= now` range so in-progress and all-day-today events surface; and `resolveExcludeSet` is now deferred to the `getChecksum` cache-miss path.)_## Deferred Architecture (human-led planning)@@ -111,7 +111,6 @@ Surfaced during code review of the federated-media-collection-sync feature and c- [ ] [localllm-env-atomic-write] **`.env` backend marker write is non-atomic.** `writeBackend` in `server/services/localLlm.js` (~line 94) uses `writeFileSync` to rewrite `.env`; a crash mid-write could corrupt it. `atomicWrite` (temp+rename, passes strings through unchanged) would make it crash-safe — but `writeBackend` is currently sync and the write is tiny/rare. Surfaced during v2.8.0 release review (gemini, IMPROVEMENT). Deferred: requires a sync→async ripple for a microsecond-wide crash window.- [ ] [meatspace-workouts-read-path] **`getWorkouts()` is a write-only feature today.** Voice (`meatspace_log_workout`) and the palette can *write* workouts via `addWorkout` (`server/services/meatspaceHealth.js:194`), and `getWorkouts()` (line 189) is exported, but it has zero consumers — no route, no UI, no test reads workouts back. Wire a `GET /api/meatspace/workouts` route + a MeatSpace tab section so logged workouts are visible. Surfaced during v2.9.0 release review (claude, NIT). Deferred: feature-completion follow-up; the write side works and is tested.- [ ] [datasync-route-forpeer-test] **Route-level `forPeer` + `videoHistory` coverage gap.** `server/routes/dataSync.js` threads the `forPeer` query param (incl. the `typeof === 'string'` array-drop guard) and the new `videoHistory` category to `getSnapshot`/`getChecksum`, but coverage exists only at the service layer (`dataSync.pipelineUniverse.test.js`). Add a route test asserting `?forPeer=x` reaches the snapshot/checksum calls and that a repeated `?forPeer=a&forPeer=b` (array) drops to `undefined`. Surfaced during v2.9.0 release review (claude, NIT). Deferred: test-coverage gap only, no correctness defect.-- [ ] [voice-calendar-next-allday-edge] **`calendar_next` skips an all-day event occurring today.** `calendar_next` (`server/services/voice/tools.js` ~1525) selects the soonest event with `start.getTime() >= Date.now()`, but an all-day event today has its `startTime` at past local-midnight, so "what's next?" silently skips it and reports the next *timed* event. Treat today-or-later all-day events as still "upcoming." Surfaced during v2.9.0 release review (claude, NIT). Deferred: minor edge. (The sibling `calendar_today` DST-anchor bug was fixed in the same review — `anchorLocalMidnightUtc` now evaluates the offset at the target day's midnight, not at `now`.)- [ ] [voice-vision-pinned-text-model] **`ui_describe_visually` reuses the voice text model for vision.** `describeScreenshot` (`server/services/voice/pipeline.js:602`) + `ui_describe_visually` (`tools.js:1356`) send the screenshot to `cfg.llm.model` when the user has pinned a non-`'auto'` voice model. If that pinned model is text-only, the chart description is empty/garbage (degrades gracefully to a clean error, no crash; the `'auto'` default is fine). Route vision through a dedicated vision-provider config, or validate vision-capability and message accordingly. Surfaced during v2.9.0 release review (claude, NIT). Deferred: only bites a non-default pinned-model config.- [ ] [ltx2-utils-constants-qualified] **LTX2 negative-prompt patch imports a generic top-level module.** `scripts/generate_ltx2.py:92` tries `("utils", "constants")` to override `DEFAULT_NEGATIVE_PROMPT`; `utils` is a very generic top-level package name in a shared venv and could be shadowed (the `hasattr(...)` guard makes a wrong-module *write* improbable, so this is defense-in-depth only). If the real module is namespaced under the ltx package, prefer the fully-qualified import path. Surfaced during v2.9.0 release review (claude, NIT). Deferred: guarded; cosmetic robustness.diff --git a/client/src/components/voice/VoiceWidget.jsx b/client/src/components/voice/VoiceWidget.jsxindex 9dcee71b52..afc4629e51 100644--- a/client/src/components/voice/VoiceWidget.jsx+++ b/client/src/components/voice/VoiceWidget.jsx@@ -6,7 +6,7 @@ import {startContinuous, stopContinuous, isContinuous, whenPlaybackDrained, getVadLevel,webSpeechSupported, startWebSpeechCapture, stopWebSpeechCapture, isWebSpeechCapturing,onProactiveSpeech, captureScreenForVision, sendScreenshotResult,- enableVisionCapture, disableVisionCapture, isVisionCaptureEnabled,+ enableVisionCapture, disableVisionCapture, isVisionCaptureEnabled, onVisionCaptureEnded,} from '../../services/voiceClient';import { getVoiceConfig } from '../../services/apiVoice';import toast from '../ui/Toast';@@ -250,9 +250,16 @@ export default function VoiceWidget() {return () => offs.forEach((off) => off());}, [enabled, navigate]);- // Release the authorized screen-capture stream when the widget unmounts so a- // forgotten "vision ON" doesn't keep the browser's sharing indicator lit.- useEffect(() => () => disableVisionCapture(), []);+ // Keep the vision toggle in sync with the actual capture stream, and release+ // it on unmount. When the user clicks "Stop sharing" in the browser's own+ // chrome the track ends asynchronously — onVisionCaptureEnded flips the toggle+ // back to OFF so the button doesn't lie. Unmount unsubscribes first (so the+ // caller-initiated disable below doesn't try to setState after teardown) then+ // releases the stream so a forgotten "vision ON" doesn't keep sharing lit.+ useEffect(() => {+ const off = onVisionCaptureEnded(() => setVisionEnabled(false));+ return () => { off(); disableVisionCapture(); };+ }, []);// Auto-scroll to bottom on new contentuseEffect(() => {diff --git a/client/src/services/voiceClient.js b/client/src/services/voiceClient.jsindex e37d65df56..d04856bc6f 100644--- a/client/src/services/voiceClient.js+++ b/client/src/services/voiceClient.js@@ -471,15 +471,29 @@ export const onVoiceEvent = (event, handler) => {// the VoiceWidget wires to a button), we keep that stream alive, and// captureScreenForVision grabs a frame from it on demand without re-prompting.let visionStream = null;+// Optional callback invoked whenever the authorized stream ends — either via+// disableVisionCapture() or because the user clicked "Stop sharing" in the+// browser's own chrome (track 'ended'). Lets the UI sync its toggle state+// instead of going stale until the next screenshot request.+let onVisionEndedCb = null;-const clearVisionStream = () => {+const clearVisionStream = ({ notify = true } = {}) => {if (visionStream) visionStream.getTracks().forEach((t) => t.stop());visionStream = null;+ if (notify && typeof onVisionEndedCb === 'function') onVisionEndedCb();};// True when a live, user-authorized capture stream is available to grab frames.export const isVisionCaptureEnabled = () => !!(visionStream && visionStream.active);+// Register a callback fired when the capture stream ends (user stops sharing via+// the browser, or disableVisionCapture runs). Pass null to clear. Returns an+// unsubscribe fn for symmetry with the other subscribe helpers.+export const onVisionCaptureEnded = (cb) => {+ onVisionEndedCb = typeof cb === 'function' ? cb : null;+ return () => { onVisionEndedCb = null; };+};+// Authorize a screen-capture stream. MUST be called from within a user gesture// (a click handler) — getDisplayMedia rejects outside transient activation,// which is exactly why the server-initiated screenshot path can't call it.@@ -495,12 +509,15 @@ export const enableVisionCapture = async () => {}).catch(() => null);if (!stream) return false;visionStream = stream;- stream.getVideoTracks().forEach((t) => t.addEventListener('ended', clearVisionStream, { once: true }));+ // User-stopped (browser chrome) → clear + notify the UI so the toggle flips.+ stream.getVideoTracks().forEach((t) => t.addEventListener('ended', () => clearVisionStream(), { once: true }));return true;};-// Stop and release the authorized capture stream (widget teardown / user toggle-off).-export const disableVisionCapture = () => clearVisionStream();+// Stop and release the authorized capture stream (widget teardown / user+// toggle-off). Caller-initiated, so it does NOT fire onVisionCaptureEnded — the+// caller already owns the state change (and on unmount the cb is gone).+export const disableVisionCapture = () => clearVisionStream({ notify: false });// Grab one frame from the authorized vision stream as a JPEG data URL. Returns// null when no stream is authorized yet (the caller prompts the user to enablediff --git a/server/services/voice/tools.js b/server/services/voice/tools.jsindex 895e44c7f2..9b0155e9c5 100644--- a/server/services/voice/tools.js+++ b/server/services/voice/tools.js@@ -1555,9 +1555,15 @@ const TOOLS = [endDate: horizon,limit: 50,});+ // Match calendarSync.getEvents' range semantics (it keeps events whose+ // endTime >= startDate), so an in-progress meeting and an all-day event+ // that began at local midnight today both still count as "next" — a+ // strict startTime >= now would drop them. Use endTime when present,+ // falling back to startTime for events that carry only a start.+ const nowMs = Date.now();const next = events.find((e) => {- const start = new Date(e?.startTime);- return !Number.isNaN(start.getTime()) && start.getTime() >= Date.now();+ const ref = new Date(e?.endTime || e?.startTime);+ return !Number.isNaN(ref.getTime()) && ref.getTime() >= nowMs;});if (!next) {return { ok: true, found: false, summary: 'Nothing coming up on your calendar in the next 30 days.' };diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.jsindex 437a6b168d..c4300dca0d 100644--- a/server/services/voice/tools.test.js+++ b/server/services/voice/tools.test.js@@ -960,6 +960,29 @@ describe('calendar_next', () => {expect(r.found).toBe(false);expect(r.summary).toMatch(/Nothing coming up/);});++ it('returns an in-progress meeting (started before now, ends after) as "next"', async () => {+ // A meeting that's currently happening must count — startTime is in the+ // past but endTime is in the future, matching calendarSync's range.+ const startedAgo = new Date(Date.now() - 1800_000).toISOString();+ const endsSoon = new Date(Date.now() + 1800_000).toISOString();+ calendarEventsRef.value = [{ title: 'Standup (in progress)', startTime: startedAgo, endTime: endsSoon, allDay: false }];+ const r = await dispatchTool('calendar_next', {});+ expect(r.found).toBe(true);+ expect(r.title).toBe('Standup (in progress)');+ });++ it('returns an all-day event occurring today (start at past midnight, end later today)', async () => {+ // All-day events begin at local midnight (already past mid-day), but with an+ // endTime later today they must still surface as "next".+ const pastMidnight = new Date(Date.now() - 8 * 3600_000).toISOString();+ const endOfDay = new Date(Date.now() + 8 * 3600_000).toISOString();+ calendarEventsRef.value = [{ title: 'Conference Day', startTime: pastMidnight, endTime: endOfDay, allDay: true }];+ const r = await dispatchTool('calendar_next', {});+ expect(r.found).toBe(true);+ expect(r.title).toBe('Conference Day');+ expect(r.allDay).toBe(true);+ });});describe('anchorLocalMidnightUtc (DST-safe local-midnight anchor)', () => {