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
fix: agent activity filters now apply to Load More and Moltworld history is no longer empty by default (#12953)
[._.]/ Adam Eivyadd3a9b010d3
diff --git a/client/src/components/agents/tabs/ActivityTab.jsx b/client/src/components/agents/tabs/ActivityTab.jsxindex 4883c6e3ff..1c30014833 100644--- a/client/src/components/agents/tabs/ActivityTab.jsx+++ b/client/src/components/agents/tabs/ActivityTab.jsx@@ -4,6 +4,8 @@ import BrailleSpinner from '../../BrailleSpinner';import { ACTION_TYPES } from '../constants';import { formatDateTime } from '../../../utils/formatters';+const PAGE_SIZE = 50;+export default function ActivityTab({ agentId }) {const [activities, setActivities] = useState([]);const [loading, setLoading] = useState(true);@@ -11,11 +13,11 @@ export default function ActivityTab({ agentId }) {const [hasMore, setHasMore] = useState(true);const fetchData = useCallback(async () => {- const activitiesData = await api.getAgentActivities(- 50, [agentId], actionFilter || null+ const activitiesData = await api.getAgentActivityTimeline(+ PAGE_SIZE, [agentId], null, actionFilter || null);setActivities(activitiesData);- setHasMore(activitiesData.length >= 50);+ setHasMore(activitiesData.length >= PAGE_SIZE);setLoading(false);}, [agentId, actionFilter]);@@ -28,10 +30,10 @@ export default function ActivityTab({ agentId }) {const lastTimestamp = activities[activities.length - 1].timestamp;const moreData = await api.getAgentActivityTimeline(- 50, [agentId], lastTimestamp+ PAGE_SIZE, [agentId], lastTimestamp, actionFilter || null);- if (moreData.length < 50) {+ if (moreData.length < PAGE_SIZE) {setHasMore(false);}diff --git a/client/src/components/agents/tabs/ActivityTab.test.jsx b/client/src/components/agents/tabs/ActivityTab.test.jsxnew file mode 100644index 0000000000..c0f01fdf1f--- /dev/null+++ b/client/src/components/agents/tabs/ActivityTab.test.jsx@@ -0,0 +1,37 @@+import { act, fireEvent, render, screen } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++vi.mock('../../../services/api', () => ({+ getAgentActivityTimeline: vi.fn(),+}));++import * as api from '../../../services/api';+import ActivityTab from './ActivityTab.jsx';++const page = (action, count, prefix = 'a') => Array.from({ length: count }, (_, i) => ({+ id: `${prefix}-${i}`, action, status: 'completed', timestamp: `2026-08-23T00:${String(59 - i).padStart(2, '0')}:00.000Z`,+}));++describe('ActivityTab filter paging', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ });++ it('sends the selected action for the first page and for Load More', async () => {+ api.getAgentActivityTimeline.mockImplementation(async (_l, _a, before) => page('post', 50, before ? 'more' : 'a'));++ render(<ActivityTab agentId="agent-1" />);+ await screen.findByText('Activity Log');+ expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(50, ['agent-1'], null, null);++ await act(async () => {+ fireEvent.change(screen.getByLabelText('Filter by action'), { target: { value: 'post' } });+ });+ expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(50, ['agent-1'], null, 'post');++ await act(async () => { fireEvent.click(await screen.findByRole('button', { name: 'Load More' })); });+ expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(+ 50, ['agent-1'], '2026-08-23T00:10:00.000Z', 'post'+ );+ });+});diff --git a/client/src/components/agents/tabs/WorldTab.jsx b/client/src/components/agents/tabs/WorldTab.jsxindex 2003913bb6..ea1f00eeb5 100644--- a/client/src/components/agents/tabs/WorldTab.jsx+++ b/client/src/components/agents/tabs/WorldTab.jsx@@ -35,6 +35,9 @@ const HISTORY_ACTION_ICONS = {mw_interact: '🤝'};+const MW_HISTORY_ACTIONS = ['mw_explore', 'mw_build', 'mw_think', 'mw_say', 'mw_heartbeat', 'mw_interact'];+const HISTORY_PAGE_SIZE = 30;+const HISTORY_FILTERS = [{ value: '', label: 'All' },{ value: 'mw_explore', label: 'Explore' },@@ -173,23 +176,17 @@ export default function WorldTab({ agentId }) {// Fetch activity historyconst fetchHistory = useCallback(async (append = false, before = null) => {setHistoryLoading(true);- const mwActions = historyFilter || 'mw_explore,mw_build,mw_think,mw_say,mw_heartbeat,mw_interact';- let data;- if (before) {- data = await api.getAgentActivityTimeline(30, [agentId], before).catch(() => null);- } else {- data = await api.getAgentActivities(30, [agentId], mwActions).catch(() => null);- }+ const mwActions = historyFilter || MW_HISTORY_ACTIONS;+ const data = await api.getAgentActivityTimeline(HISTORY_PAGE_SIZE, [agentId], before, mwActions).catch(() => null);if (data) {- const items = Array.isArray(data) ? data : data.activities || [];- // Filter to mw_* actions only- const mwItems = items.filter(a => a.action?.startsWith('mw_'));+ const items = Array.isArray(data) ? data : [];if (append) {- setHistory(prev => [...prev, ...mwItems]);+ setHistory(prev => [...prev, ...items]);} else {- setHistory(mwItems);+ setHistory(items);}- setHistoryHasMore(mwItems.length >= 30);+ // The server already applied the filter, so a full page means more may exist.+ setHistoryHasMore(items.length >= HISTORY_PAGE_SIZE);}setHistoryLoading(false);}, [agentId, historyFilter]);diff --git a/client/src/components/agents/tabs/WorldTab.test.jsx b/client/src/components/agents/tabs/WorldTab.test.jsxnew file mode 100644index 0000000000..37a77f3635--- /dev/null+++ b/client/src/components/agents/tabs/WorldTab.test.jsx@@ -0,0 +1,52 @@+import { act, fireEvent, render, screen } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++vi.mock('../../../services/api', () => ({+ getPlatformAccounts: vi.fn(),+ moltworldStatus: vi.fn(),+ moltworldRateLimits: vi.fn(),+ moltworldGetQueue: vi.fn(),+ getAgentActivityTimeline: vi.fn(),+}));+vi.mock('../../../hooks/useMoltworldWs', () => ({+ default: () => ({ connectionStatus: 'disconnected', feedItems: [], presence: [], connect: vi.fn(), disconnect: vi.fn() }),+}));+vi.mock('../../../services/socket', () => ({+ default: { on: vi.fn(), off: vi.fn() },+}));++import * as api from '../../../services/api';+import WorldTab from './WorldTab.jsx';++const MW_ALL = ['mw_explore', 'mw_build', 'mw_think', 'mw_say', 'mw_heartbeat', 'mw_interact'];+const rows = (count, prefix = 'r') => Array.from({ length: count }, (_, i) => ({+ id: `${prefix}-${i}`, action: 'mw_think', status: 'completed', timestamp: `2026-08-23T00:${String(59 - i).padStart(2, '0')}:00.000Z`,+}));++describe('WorldTab activity history', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ api.getPlatformAccounts.mockResolvedValue([{ id: 'acct-1', status: 'active', credentials: { username: 'example' } }]);+ api.moltworldStatus.mockResolvedValue(null);+ api.moltworldRateLimits.mockResolvedValue(null);+ api.moltworldGetQueue.mockResolvedValue([]);+ api.getAgentActivityTimeline.mockImplementation(async (_l, _a, before) => rows(30, before ? 'more' : 'r'));+ });++ it('lists every mw_* action by default and keeps the filter on Load More', async () => {+ render(<WorldTab agentId="agent-1" />);+ await screen.findByText('Activity History');+ await act(async () => {});+ expect(api.getAgentActivityTimeline).toHaveBeenCalledWith(30, ['agent-1'], null, MW_ALL);++ await act(async () => {+ fireEvent.change(screen.getByLabelText('Filter history'), { target: { value: 'mw_think' } });+ });+ expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(30, ['agent-1'], null, 'mw_think');++ await act(async () => { fireEvent.click(await screen.findByRole('button', { name: 'Load More' })); });+ expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(+ 30, ['agent-1'], '2026-08-23T00:30:00.000Z', 'mw_think'+ );+ });+});diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.jsindex 885d75e0a9..168fd1868a 100644--- a/client/src/services/apiAgents.js+++ b/client/src/services/apiAgents.js@@ -15,10 +15,12 @@ export const getAgentActivities = (limit = 50, agentIds = null, action = null) =if (action) params.set('action', action);return request(`/agents/activity?${params}`);};-export const getAgentActivityTimeline = (limit = 50, agentIds = null, before = null) => {+// `action` is one action string or an array of them (sent comma-joined).+export const getAgentActivityTimeline = (limit = 50, agentIds = null, before = null, action = null) => {const params = new URLSearchParams();params.set('limit', limit);if (agentIds) params.set('agentIds', agentIds.join(','));+ if (action) params.set('action', [].concat(action).join(','));if (before) params.set('before', before);return request(`/agents/activity/timeline?${params}`);};diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 06c083d650..094f33bfe3 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -1938,6 +1938,8 @@ export const agentActivityQuerySchema = z.object({export const agentActivityTimelineQuerySchema = z.object({limit: agentActivityLimit(50),agentIds: agentActivityIds,+ // One action or a comma-separated list (the Moltworld history asks for every mw_* kind).+ action: csvIdsParam({ max: 10, maxIdLength: 64 }),before: z.preprocess(emptyToUndefined, z.string().datetime().optional()),}).strict();diff --git a/server/routes/agentActivity.js b/server/routes/agentActivity.jsindex 38837f5feb..ec6ce8a1a0 100644--- a/server/routes/agentActivity.js+++ b/server/routes/agentActivity.js@@ -31,9 +31,9 @@ router.get('/', asyncHandler(async (req, res) => {// GET /timeline - Get activity timeline (for infinite scroll)router.get('/timeline', asyncHandler(async (req, res) => {- const { limit, agentIds, before } = validateRequest(agentActivityTimelineQuerySchema, req.query);+ const { limit, agentIds, action, before } = validateRequest(agentActivityTimelineQuerySchema, req.query);- res.json(await agentActivity.getActivityTimeline({ limit, agentIds, beforeTimestamp: before }));+ res.json(await agentActivity.getActivityTimeline({ limit, agentIds, actions: action, beforeTimestamp: before }));}));// GET /agent/:agentId - Get activities for specific agentdiff --git a/server/routes/agentActivity.test.js b/server/routes/agentActivity.test.jsindex e6fdcfa765..55858d7486 100644--- a/server/routes/agentActivity.test.js+++ b/server/routes/agentActivity.test.js@@ -266,12 +266,32 @@ describe('activity route validation', () => {expect(activityMocks.getActivityTimeline).not.toHaveBeenCalled();});+ it('forwards a single action and a comma list as an actions array', async () => {+ await get('/timeline?action=post');+ expect(activityMocks.getActivityTimeline).toHaveBeenLastCalledWith(expect.objectContaining({ actions: ['post'] }));++ await get('/timeline?action=mw_say,%20mw_think&before=2026-08-23T00:00:05.000Z');+ expect(activityMocks.getActivityTimeline).toHaveBeenLastCalledWith(expect.objectContaining({+ actions: ['mw_say', 'mw_think'],+ beforeTimestamp: '2026-08-23T00:00:05.000Z',+ }));+ });++ it('rejects an over-long action list or an over-long action', async () => {+ activityMocks.getActivityTimeline.mockClear();+ const eleven = Array.from({ length: 11 }, (_, i) => `a${i}`).join(',');+ expect((await get(`/timeline?action=${eleven}`)).status).toBe(400);+ expect((await get(`/timeline?action=${'x'.repeat(65)}`)).status).toBe(400);+ expect(activityMocks.getActivityTimeline).not.toHaveBeenCalled();+ });+it('forwards a valid cursor and coerced limit', async () => {const res = await get('/timeline?limit=25&before=2026-08-23T00:00:05.000Z');expect(res.status).toBe(200);expect(activityMocks.getActivityTimeline).toHaveBeenCalledWith({limit: 25,agentIds: undefined,+ actions: undefined,beforeTimestamp: '2026-08-23T00:00:05.000Z',});});diff --git a/server/services/agentActivity.js b/server/services/agentActivity.jsindex 64ffa05047..e64e947968 100644--- a/server/services/agentActivity.js+++ b/server/services/agentActivity.js@@ -246,7 +246,7 @@ export async function getAgentStats(agentId, days = 7) {* Get activity timeline for display*/export async function getActivityTimeline(options = {}) {- const { agentIds = null, limit = 100, beforeTimestamp = null } = options;+ const { agentIds = null, actions = null, limit = 100, beforeTimestamp = null } = options;const before = beforeTimestamp ? new Date(beforeTimestamp).getTime() : null;await ensureActivityDir();@@ -272,7 +272,8 @@ export async function getActivityTimeline(options = {}) {const data = await loadActivity(agentId, date);for (const activity of data.activities || []) {const timestamp = new Date(activity.timestamp).getTime();- if (before === null || timestamp < before) {+ // Filter before the limit cut so a filtered page stays full.+ if ((before === null || timestamp < before) && (!actions || actions.includes(activity.action))) {dayActivities.push({ agentId, ...activity });}}diff --git a/server/services/agentActivity.test.js b/server/services/agentActivity.test.jsindex f410176b46..9372329d8d 100644--- a/server/services/agentActivity.test.js+++ b/server/services/agentActivity.test.js@@ -69,6 +69,26 @@ describe('getActivityTimeline', () => {expect(second).toEqual(first);});+ it('filters by action before the limit cut and still honors the cursor', async () => {+ const mixed = (id, ts, action) => ({ ...entry(id, ts), action });+ await writeDay('agent-a', '2026-08-23', [+ mixed('say-1', '2026-08-23T00:00:09.000Z', 'mw_say'),+ mixed('post-1', '2026-08-23T00:00:08.000Z', 'post'),+ mixed('think-1', '2026-08-23T00:00:07.000Z', 'mw_think'),+ ]);+ await writeDay('agent-a', '2026-08-22', [+ mixed('say-2', '2026-08-22T00:00:09.000Z', 'mw_say'),+ mixed('post-2', '2026-08-22T00:00:08.000Z', 'post'),+ ]);++ const ids = async (options) => (await getActivityTimeline(options)).map(({ id }) => id);+ await expect(ids({ limit: 2, actions: ['post'] })).resolves.toEqual(['post-1', 'post-2']);+ await expect(ids({ limit: 3, actions: ['mw_say', 'mw_think'] })).resolves.toEqual(['say-1', 'think-1', 'say-2']);+ await expect(ids({+ limit: 5, actions: ['mw_say'], beforeTimestamp: '2026-08-23T00:00:09.000Z',+ })).resolves.toEqual(['say-2']);+ });+it('skips empty days while walking backward', async () => {await writeDay('agent-a', '2026-08-23', []);await writeDay('agent-a', '2026-08-21', [entry('older', '2026-08-21T09:00:00.000Z')]);