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

fix: keep dashboard time labels current without API reads (#8531)

[._.]/ Adam Eivy8f8f8e16ea3a
diff --git a/client/src/components/CosDashboardWidget.jsx b/client/src/components/CosDashboardWidget.jsx
index fedfb8165d..4b562be490 100644
--- a/client/src/components/CosDashboardWidget.jsx
+++ b/client/src/components/CosDashboardWidget.jsx
@@ -17,7 +17,7 @@ import { useSocketResource } from '../hooks/useSocketResource';
import { useTimeTick } from '../hooks/useTimeTick';
import { timeAgo, formatWeekdayDate, formatCount } from '../utils/formatters';
-const RESOURCE_EVENTS = ['cos:tasks:changed', 'cos:tasks:user:changed', 'cos:tasks:cos:changed', 'cos:agent:spawned', 'cos:agent:completed', 'cos:agents:changed', 'cos:status', 'cos:status:paused', 'cos:status:resumed', 'cos:learning:changed'];
+const RESOURCE_EVENTS = ['cos:tasks:changed', 'cos:tasks:user:changed', 'cos:tasks:cos:changed', 'cos:agent:spawned', 'cos:agent:updated', 'cos:agent:completed', 'cos:agents:changed', 'cos:status', 'cos:status:paused', 'cos:status:resumed', 'cos:learning:changed'];
/**
* CosDashboardWidget - Compact CoS status widget for the main Dashboard
diff --git a/client/src/components/UpcomingTasksWidget.jsx b/client/src/components/UpcomingTasksWidget.jsx
index 2a06c7791d..5991546d73 100644
--- a/client/src/components/UpcomingTasksWidget.jsx
+++ b/client/src/components/UpcomingTasksWidget.jsx
@@ -11,6 +11,8 @@ import {
} from 'lucide-react';
import * as api from '../services/api';
import { useSocketResource } from '../hooks/useSocketResource';
+import { useTimeTick } from '../hooks/useTimeTick';
+import { timeAgo, timeUntil } from '../utils/formatters';
const RESOURCE_EVENTS = ['cos:schedule:changed', 'cos:scheduler:changed', 'cos:tasks:changed', 'cos:learning:changed', 'cos:config:changed'];
@@ -24,6 +26,10 @@ const UpcomingTasksWidget = memo(function UpcomingTasksWidget() {
{ namespace: 'cos', events: RESOURCE_EVENTS }
);
+ // Countdown labels keep moving without an API read. Eligibility remains
+ // authoritative server state and changes on scheduler/task events.
+ useTimeTick(60000);
+
// Don't render during the initial load.
if (loading) {
return null;
@@ -51,8 +57,13 @@ const UpcomingTasksWidget = memo(function UpcomingTasksWidget() {
}
// Separate ready tasks from scheduled ones
- const readyTasks = upcoming.filter(t => t.status === 'ready');
- const scheduledTasks = upcoming.filter(t => t.status === 'scheduled');
+ const currentTasks = upcoming.map(task => ({
+ ...task,
+ eligibleInFormatted: Number.isFinite(task.eligibleAt) ? timeUntil(task.eligibleAt) : task.eligibleInFormatted,
+ lastRunFormatted: task.lastRun ? timeAgo(task.lastRun) : task.lastRunFormatted,
+ }));
+ const readyTasks = currentTasks.filter(t => t.status === 'ready');
+ const scheduledTasks = currentTasks.filter(t => t.status === 'scheduled');
// Get interval type label
const getIntervalLabel = (intervalType) => {
diff --git a/client/src/components/dashboard/builtins/OpenThreadsWidget.jsx b/client/src/components/dashboard/builtins/OpenThreadsWidget.jsx
index c546cc5c7a..2c360b4581 100644
--- a/client/src/components/dashboard/builtins/OpenThreadsWidget.jsx
+++ b/client/src/components/dashboard/builtins/OpenThreadsWidget.jsx
@@ -3,6 +3,7 @@ import { Link } from 'react-router';
import { ListTodo, Pin } from 'lucide-react';
import * as api from '../../../services/api';
import { useSocketResource } from '../../../hooks/useSocketResource';
+import { useTimeTick } from '../../../hooks/useTimeTick';
import { isThreadOverdue, threadNextLine } from '../../../lib/brainThreads.js';
import { formatCount, formatDateShort } from '../../../utils/formatters';
import ThreadSourceClosedAction from '../../brain/ThreadSourceClosedAction';
@@ -24,6 +25,8 @@ const WIDGET_STATUSES = 'open,waiting';
export default function OpenThreadsWidget() {
const [completed, setCompleted] = useState({});
+ // Overdue coloring is local clock state, not a reason to re-read the API.
+ useTimeTick(60000);
const { data, loading } = useSocketResource(
() => api.listThreads({ status: WIDGET_STATUSES, limit: ROWS, offset: 0 }, { silent: true }),
{ events: RESOURCE_EVENTS },
diff --git a/client/src/components/dashboardWidgets.realtime.test.jsx b/client/src/components/dashboardWidgets.realtime.test.jsx
index 4dcef8ccf1..970407a0d1 100644
--- a/client/src/components/dashboardWidgets.realtime.test.jsx
+++ b/client/src/components/dashboardWidgets.realtime.test.jsx
@@ -86,6 +86,22 @@ describe('dashboard resource subscriptions', () => {
expect(api[read]).toHaveBeenCalledTimes(4);
});
+ it('advances overdue coloring and schedule countdowns with no network reads', async () => {
+ vi.setSystemTime(new Date('2026-01-01T12:00:00Z'));
+ api.listThreads.mockResolvedValue({ threads: [{ id: 'example', title: 'Example deadline', status: 'open', dueAt: '2026-01-01T12:00:30Z' }], total: 1 });
+ api.getCosUpcomingTasks.mockResolvedValue([{ taskType: 'example', description: 'Example task', status: 'scheduled', eligibleAt: Date.now() + 120000 }]);
+ render(<MemoryRouter><OpenThreadsWidget /><UpcomingTasksWidget /></MemoryRouter>);
+ await flush();
+ const dueDate = screen.getByText('Jan 1, 2026');
+ expect(dueDate).not.toHaveClass('text-port-error');
+ expect(screen.getByText('Next: in 2m')).toBeInTheDocument();
+ await act(async () => { await vi.advanceTimersByTimeAsync(60000); });
+ expect(dueDate).toHaveClass('text-port-error');
+ expect(screen.getByText('Next: in 1m')).toBeInTheDocument();
+ expect(api.listThreads).toHaveBeenCalledTimes(1);
+ expect(api.getCosUpcomingTasks).toHaveBeenCalledTimes(1);
+ });
+
it('refreshes the open snapshot list after backup finalization without a timer', async () => {
api.getBackupSnapshots.mockResolvedValue([{ id: 'example-before', fileCount: 1 }]);
render(<MemoryRouter><BackupWidget /></MemoryRouter>);
diff --git a/server/services/socket.test.js b/server/services/socket.test.js
index 463af8be1d..fe30d6310c 100644
--- a/server/services/socket.test.js
+++ b/server/services/socket.test.js
@@ -150,6 +150,7 @@ describe('socket.js — initSocket', () => {
createdSockets.length = 0;
authEvents.removeAllListeners('sessions:revoked-all');
meatspaceEvents.removeAllListeners();
+ dashboardEvents.removeAllListeners();
});
it('forwards death-clock invalidations without personal data', () => {