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: close review queue triage gaps (#7741)

[._.]/ Adam Eivy32e62ab14741
diff --git a/client/src/pages/Review.jsx b/client/src/pages/Review.jsx
index 954b2e040f..6aaf38a8bb 100644
--- a/client/src/pages/Review.jsx
+++ b/client/src/pages/Review.jsx
@@ -104,6 +104,7 @@ const ACTION_VIEWS = [
{ id: 'all', label: 'All', icon: ListTodo },
{ id: 'waiting', label: 'Waiting', icon: Hourglass },
{ id: 'someday', label: 'Someday', icon: Sparkles },
+ { id: 'snoozed', label: 'Snoozed', icon: Clock3 },
{ id: 'history', label: 'History', icon: HistoryIcon },
];
const ACTION_VIEW_IDS = new Set(ACTION_VIEWS.map(({ id }) => id));
diff --git a/docs/features/review-queue.md b/docs/features/review-queue.md
index df06b97233..9f3dc4110b 100644
--- a/docs/features/review-queue.md
+++ b/docs/features/review-queue.md
@@ -51,7 +51,8 @@ separate from notification-read state for the delivery layer. `snooze` and
`unsnooze` change presentation only, while `dismiss` is advertised only for
`isRecommendation` rows. A triage mutation re-reads the source and rejects
unavailable sources or unsupported capabilities before writing the local
-marker.
+marker. Snoozes are limited to 30 days; the `snoozed` Actions view exposes
+active snoozes so the user can restore one early.
Source-owned rows may also carry `sourceOwned: true` and `triageOnly: true`.
Generic Review completion rejects those rows; an explicit source operation
diff --git a/server/lib/validation.js b/server/lib/validation.js
index e9ef47d74b..4fb4fa1e11 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -1777,7 +1777,7 @@ export const agentActivityCleanupSchema = z.object({
export const reviewQueueQuerySchema = z.object({
limit: z.preprocess(emptyToUndefined, z.coerce.number().int().min(1).max(100).optional()),
cursor: z.preprocess(emptyToUndefined, z.string().trim().min(1).max(4096).optional()),
- view: z.preprocess(emptyToUndefined, z.enum(['today', 'all', 'waiting', 'someday', 'history']).optional()),
+ view: z.preprocess(emptyToUndefined, z.enum(['today', 'all', 'waiting', 'someday', 'history', 'snoozed']).optional()),
}).strict();
// =============================================================================
diff --git a/server/routes/review.js b/server/routes/review.js
index f84e640317..4d891927df 100644
--- a/server/routes/review.js
+++ b/server/routes/review.js
@@ -3,7 +3,7 @@ import { z } from 'zod';
import { asyncHandler } from '../lib/errorHandler.js';
import { reviewQueueQuerySchema, validateRequest } from '../lib/validation.js';
import * as reviewService from '../services/review.js';
-import { buildQueue, resolveQueueItem, triageQueueItem, promoteAskQueueItem } from '../services/reviewQueue.js';
+import { buildQueue, MAX_REVIEW_QUEUE_SNOOZE_MS, resolveQueueItem, triageQueueItem, promoteAskQueueItem } from '../services/reviewQueue.js';
const router = express.Router();
@@ -84,6 +84,10 @@ const triageQueueSchema = z.object({
if (value.operation === 'snooze' && !value.snoozedUntil) {
context.addIssue({ code: z.ZodIssueCode.custom, path: ['snoozedUntil'], message: 'snoozedUntil is required for the snooze operation' });
}
+ if (value.operation === 'snooze' && value.snoozedUntil
+ && Date.parse(value.snoozedUntil) - Date.now() > MAX_REVIEW_QUEUE_SNOOZE_MS) {
+ context.addIssue({ code: z.ZodIssueCode.custom, path: ['snoozedUntil'], message: 'snoozedUntil cannot be more than 30 days in the future' });
+ }
if (value.operation !== 'snooze' && value.snoozedUntil !== undefined) {
context.addIssue({ code: z.ZodIssueCode.custom, path: ['snoozedUntil'], message: 'snoozedUntil is only valid for the snooze operation' });
}
diff --git a/server/routes/review.test.js b/server/routes/review.test.js
index bc2251a8c0..9c0364d9f9 100644
--- a/server/routes/review.test.js
+++ b/server/routes/review.test.js
@@ -1,4 +1,4 @@
-import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import express from 'express';
import { request } from '../lib/testHelper.js';
import { errorMiddleware } from '../lib/errorHandler.js';
@@ -7,10 +7,12 @@ const buildQueue = vi.fn();
const resolveQueueItem = vi.fn();
const triageQueueItem = vi.fn();
const promoteAskQueueItem = vi.fn();
+const MAX_REVIEW_QUEUE_SNOOZE_MS = 30 * 24 * 60 * 60 * 1000;
vi.mock('../services/review.js', () => ({}));
vi.mock('../services/reviewQueue.js', () => ({
buildQueue,
+ MAX_REVIEW_QUEUE_SNOOZE_MS,
resolveQueueItem,
triageQueueItem,
promoteAskQueueItem,
@@ -30,6 +32,10 @@ beforeEach(() => {
vi.clearAllMocks();
});
+afterEach(() => {
+ vi.useRealTimers();
+});
+
describe('GET /api/review/queue', () => {
it('passes the requested page through without reapplying the old source cap', async () => {
const items = Array.from({ length: 40 }, (_, index) => ({ id: `brain:b${index}` }));
@@ -110,7 +116,7 @@ describe('POST /api/review/queue/resolve', () => {
describe('POST /api/review/queue/triage', () => {
it('validates the snooze timestamp and forwards it to the queue service', async () => {
- const snoozedUntil = '2099-01-01T00:00:00.000Z';
+ const snoozedUntil = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString();
triageQueueItem.mockResolvedValue({ id: 'brain:b1', operation: 'snooze', triaged: true });
const response = await request(makeApp())
@@ -122,6 +128,7 @@ describe('POST /api/review/queue/triage', () => {
});
it('requires a timestamp for snooze and rejects timestamps on other operations', async () => {
+ vi.useFakeTimers({ now: new Date('2026-09-20T10:00:00.000Z') });
const missing = await request(makeApp())
.post('/api/review/queue/triage')
.send({ id: 'brain:b1', operation: 'snooze' });
@@ -133,5 +140,15 @@ describe('POST /api/review/queue/triage', () => {
.send({ id: 'ask:a1', operation: 'dismiss', snoozedUntil: '2099-01-01T00:00:00.000Z' });
expect(extra.status).toBe(400);
expect(triageQueueItem).not.toHaveBeenCalled();
+
+ const tooFar = await request(makeApp())
+ .post('/api/review/queue/triage')
+ .send({
+ id: 'brain:b1',
+ operation: 'snooze',
+ snoozedUntil: new Date(Date.now() + MAX_REVIEW_QUEUE_SNOOZE_MS + 1).toISOString(),
+ });
+ expect(tooFar.status).toBe(400);
+ expect(triageQueueItem).not.toHaveBeenCalled();
});
});
diff --git a/server/services/reviewQueue.js b/server/services/reviewQueue.js
index 86ac7cda1f..1d253d18bb 100644
--- a/server/services/reviewQueue.js
+++ b/server/services/reviewQueue.js
@@ -60,6 +60,7 @@ export const REVIEW_QUEUE_MAX_PAGE_SIZE = 100;
const REVIEW_QUEUE_SOURCE_PROBE_LIMIT = REVIEW_QUEUE_SOURCE_READ_LIMIT + 1;
const REVIEW_QUEUE_SNAPSHOT_TTL_MS = 30_000;
const REVIEW_QUEUE_MAX_SNAPSHOTS = 100;
+export const MAX_REVIEW_QUEUE_SNOOZE_MS = 30 * 24 * 60 * 60 * 1000;
const ACTION_KINDS = Object.freeze({
brain: 'brain.classify',
@@ -136,7 +137,7 @@ async function getActiveGoalOptions() {
.map((g) => ({ id: g.id, title: typeof g.title === 'string' && g.title ? g.title : '(untitled goal)' }));
}
-const COMMITMENT_VIEWS = new Set(['today', 'all', 'waiting', 'someday', 'history']);
+const COMMITMENT_VIEWS = new Set(['today', 'all', 'waiting', 'someday', 'history', 'snoozed']);
const ACTIVE_THREAD_STATUSES = new Set(['open', 'waiting', 'someday']);
function isDueByLocalToday(thread, timezone, now = new Date()) {
@@ -154,12 +155,14 @@ function threadBelongsToView(thread, view, timezone, now = new Date()) {
if (!COMMITMENT_VIEWS.has(view)) return ACTIVE_THREAD_STATUSES.has(thread.status);
if (view === 'all') return ACTIVE_THREAD_STATUSES.has(thread.status);
if (view === 'history') return isTerminalThreadStatus(thread.status);
+ if (view === 'snoozed') return ACTIVE_THREAD_STATUSES.has(thread.status);
if (view === 'waiting' || view === 'someday') return thread.status === view;
return ACTIVE_THREAD_STATUSES.has(thread.status) && isDueByLocalToday(thread, timezone, now);
}
const visibleInLiveViews = (producer, view) => {
if (!view) return producer.source !== 'history';
+ if (view === 'snoozed') return producer.source !== 'history';
if (Array.isArray(producer.views)) return producer.views.includes(view);
return view === 'today' || view === 'all';
};
@@ -763,9 +766,11 @@ const emptyTriageState = Object.freeze({
deliveryGeneration: 0,
});
-function triageOperationsFor(item) {
+function triageOperationsFor(item, { snoozed = false } = {}) {
return [
- { id: 'snooze', label: 'Snooze', available: true },
+ snoozed
+ ? { id: 'unsnooze', label: 'Unsnooze', available: true }
+ : { id: 'snooze', label: 'Snooze', available: true },
...(item.isRecommendation === true
? [{ id: 'dismiss', label: 'Dismiss', available: true }]
: []),
@@ -777,7 +782,7 @@ function triageOperationsFor(item) {
* This is exported as a pure boundary so expiry and occurrence rollover can
* be tested with an injected clock.
*/
-export function applyQueueTriage(items, entries = [], now = new Date()) {
+export function applyQueueTriage(items, entries = [], now = new Date(), { includeSnoozed = false } = {}) {
const byIdentity = new Map(
entries
.map((entry) => {
@@ -795,7 +800,7 @@ export function applyQueueTriage(items, entries = [], now = new Date()) {
const snoozedUntilMs = state.snoozedUntil ? Date.parse(state.snoozedUntil) : NaN;
const snoozed = Number.isFinite(snoozedUntilMs) && snoozedUntilMs > currentTime;
const dismissed = state.dismissed && item.isRecommendation === true;
- if (snoozed || dismissed) return [];
+ if (dismissed || (includeSnoozed ? !snoozed : snoozed)) return [];
return [{
...item,
triage: {
@@ -803,7 +808,7 @@ export function applyQueueTriage(items, entries = [], now = new Date()) {
dismissed: state.dismissed,
deliveryGeneration: state.deliveryGeneration,
},
- triageOperations: triageOperationsFor(item),
+ triageOperations: triageOperationsFor(item, { snoozed }),
}];
});
}
@@ -1028,6 +1033,12 @@ export async function triageQueueItem(queueItemId, operation, input = {}, { now:
code: 'VALIDATION_ERROR',
});
}
+ if (parsed.getTime() - now.getTime() > MAX_REVIEW_QUEUE_SNOOZE_MS) {
+ throw new ServerError('snoozedUntil cannot be more than 30 days in the future', {
+ status: 400,
+ code: 'VALIDATION_ERROR',
+ });
+ }
snoozedUntil = parsed.toISOString();
} else if (input?.snoozedUntil !== undefined) {
throw new ServerError('snoozedUntil is only valid for the snooze operation', {
@@ -1078,6 +1089,7 @@ export async function triageQueueItem(queueItemId, operation, input = {}, { now:
} else {
await reviewQueueTriageStore.upsertReviewQueueTriage(next);
}
+ __resetQueueSnapshots();
return {
id: queueItemId,
@@ -1215,7 +1227,9 @@ async function gatherFullQueue(query = {}, { applyTriageState = true, now = new
}));
let items = deduplicateItems(results.flatMap((result) => result.items));
- if (applyTriageState) items = applyQueueTriage(items, await readQueueTriageForProjection(), clock);
+ if (applyTriageState) {
+ items = applyQueueTriage(items, await readQueueTriageForProjection(), clock, { includeSnoozed: view === 'snoozed' });
+ }
items.sort((a, b) => compareQueueItems(a, b, clock.getTime()));
const shownCounts = sourceShownCounts(items);
const sources = {};
diff --git a/server/services/reviewQueue.test.js b/server/services/reviewQueue.test.js
index bfdc5c77fc..c502f2bcc5 100644
--- a/server/services/reviewQueue.test.js
+++ b/server/services/reviewQueue.test.js
@@ -721,6 +721,15 @@ describe('reviewQueue triage', () => {
const visible = await buildQueue({ now: new Date('2026-09-20T11:00:00.000Z') });
expect(visible.items.map((item) => item.id)).toEqual(['brain:b1']);
+
+ const snoozedView = await buildQueue({
+ query: { view: 'snoozed' },
+ now: new Date(now),
+ });
+ expect(snoozedView.items.map((item) => item.id)).toEqual(['brain:b1']);
+ expect(snoozedView.items[0].triageOperations).toEqual([
+ { id: 'unsnooze', label: 'Unsnooze', available: true },
+ ]);
});
it('keys presentation state by occurrence and revision instead of source id alone', () => {
@@ -772,7 +781,7 @@ describe('reviewQueue triage', () => {
await expect(triageQueueItem('brain:b1', 'snooze', {
snoozedUntil: '2026-09-20T11:00:00.000Z',
- })).rejects.toMatchObject({ status: 503, code: 'SOURCE_UNAVAILABLE' });
+ }, { now: new Date('2026-09-20T10:00:00.000Z') })).rejects.toMatchObject({ status: 503, code: 'SOURCE_UNAVAILABLE' });
expect(reviewQueueTriageStore.upsertReviewQueueTriage).not.toHaveBeenCalled();
});
@@ -780,16 +789,25 @@ describe('reviewQueue triage', () => {
brain.getInboxLog.mockResolvedValue([{ id: 'b1', capturedText: 'required', capturedAt: 'revision-1' }]);
await expect(triageQueueItem('brain:b1', 'snooze', {
- snoozedUntil: '2099-01-01T00:00:00.000Z',
- })).resolves.toMatchObject({ id: 'brain:b1', operation: 'snooze', triaged: true });
+ snoozedUntil: '2026-09-27T10:00:00.000Z',
+ }, { now: new Date('2026-09-20T10:00:00.000Z') })).resolves.toMatchObject({ id: 'brain:b1', operation: 'snooze', triaged: true });
expect(reviewQueueTriageStore.upsertReviewQueueTriage).toHaveBeenCalledWith(expect.objectContaining({
actionKey: 'brain.classify:b1',
revision: 'revision-1',
- snoozedUntil: '2099-01-01T00:00:00.000Z',
+ snoozedUntil: '2026-09-27T10:00:00.000Z',
}));
expect(brain.markInboxDone).not.toHaveBeenCalled();
});
+ it('rejects an effectively permanent snooze window', async () => {
+ brain.getInboxLog.mockResolvedValue([{ id: 'b1', capturedText: 'required' }]);
+
+ await expect(triageQueueItem('brain:b1', 'snooze', {
+ snoozedUntil: '2099-01-01T00:00:00.000Z',
+ }, { now: new Date('2026-09-20T10:00:00.000Z') })).rejects.toMatchObject({ status: 400, code: 'VALIDATION_ERROR' });
+ expect(reviewQueueTriageStore.upsertReviewQueueTriage).not.toHaveBeenCalled();
+ });
+
it('clears a stored snooze through the explicit unsnooze operation', async () => {
brain.getInboxLog.mockResolvedValue([{ id: 'b1', capturedText: 'required', capturedAt: 'revision-1' }]);
reviewQueueTriageStore.listReviewQueueTriage.mockResolvedValue([{
@@ -810,6 +828,24 @@ describe('reviewQueue triage', () => {
revision: 'revision-1',
}));
});
+
+ it('invalidates a pagination snapshot after a triage mutation', async () => {
+ brain.getInboxLog.mockResolvedValue([
+ { id: 'b1', capturedText: 'first' },
+ { id: 'b2', capturedText: 'second' },
+ ]);
+ const first = await buildQueue({ limit: 1 });
+ expect(first.nextCursor).toBeTruthy();
+
+ await triageQueueItem('brain:b1', 'snooze', {
+ snoozedUntil: '2026-09-27T10:00:00.000Z',
+ }, { now: new Date('2026-09-20T10:00:00.000Z') });
+
+ await expect(buildQueue({ limit: 1, cursor: first.nextCursor })).rejects.toMatchObject({
+ status: 409,
+ code: 'CURSOR_EXPIRED',
+ });
+ });
});
describe('reviewQueue.promoteAskQueueItem', () => {