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: bound GET /api/cos/tasks/user and /internal to open tasks plus the first completed page (#12997)

[._.]/ Adam Eivya5277b73414a
diff --git a/server/routes/cosTaskRoutes.js b/server/routes/cosTaskRoutes.js
index 27130146bb..a6e8dcb8da 100644
--- a/server/routes/cosTaskRoutes.js
+++ b/server/routes/cosTaskRoutes.js
@@ -233,16 +233,15 @@ router.get('/tasks', asyncHandler(async (req, res) => {
});
}));
-// GET /api/cos/tasks/user - Get user tasks
+// GET /api/cos/tasks/user and /internal - one source's bounded view: open tasks
+// whole, completed history reduced to the first page + `completedCount`
+// (page on with `/tasks?view=completed`); the raw store is `/tasks?view=full` (#12997).
router.get('/tasks/user', asyncHandler(async (req, res) => {
- const tasks = await cos.getUserTasks();
- res.json(tasks);
+ res.json((await cos.getTaskView({ kind: 'bare' })).user);
}));
-// GET /api/cos/tasks/internal - Get CoS internal tasks
router.get('/tasks/internal', asyncHandler(async (req, res) => {
- const tasks = await cos.getCosTasks();
- res.json(tasks);
+ res.json((await cos.getTaskView({ kind: 'bare' })).cos);
}));
// GET /api/cos/tasks/:id - One task with the queue it lives in. The Chief of
diff --git a/server/routes/cosTaskRoutes.test.js b/server/routes/cosTaskRoutes.test.js
index 11847000ea..a1cad199c1 100644
--- a/server/routes/cosTaskRoutes.test.js
+++ b/server/routes/cosTaskRoutes.test.js
@@ -160,7 +160,7 @@ describe('GET /api/cos/tasks/:id', () => {
it('is a 404 for an unknown id and never shadows the literal list routes', async () => {
cos.findTaskWithSource.mockResolvedValue(null);
- cos.getUserTasks.mockResolvedValue({ tasks: [] });
+ cos.getTaskView.mockResolvedValue({ user: { tasks: [] }, cos: { tasks: [] } });
const missing = await request(buildApp()).get('/api/cos/tasks/no-such-task');
expect(missing.status).toBe(404);
@@ -655,6 +655,16 @@ describe('GET /api/cos/tasks — bounded view routing (#9677)', () => {
expect(res.body.user.grouped.in_progress.map(t => t.id)).toEqual(['user/1']);
});
+ it.each([['user', 'user'], ['internal', 'cos']])('/tasks/%s serves that source from the bounded reader (#12997)', async (route, key) => {
+ cos.getTaskView.mockResolvedValue({ user: { ...open(), completedCount: 40 }, cos: { ...empty, type: 'internal', completedCount: 3 } });
+ const res = await request(buildApp()).get(`/api/cos/tasks/${route}`);
+ expect(cos.getTaskView).toHaveBeenCalledWith({ kind: 'bare' });
+ expect(cos.getUserTasks).not.toHaveBeenCalled();
+ expect(cos.getCosTasks).not.toHaveBeenCalled();
+ expect(res.body.completedCount).toBe(key === 'user' ? 40 : 3);
+ expect(res.body.user).toBeUndefined();
+ });
+
it('queue view summarizes the derived lists and forwards the selected id', async () => {
cos.getTaskView.mockResolvedValue({ user: { ...open(), completedCount: 9,
grouped: { pending: [{ id: 'user/1', status: 'pending', description: 'x' }], completed: [{ id: 'user/old', status: 'completed', description: 'y' }] } }, cos: empty });