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: Retry a human-action reminder when its notification fails, and reject steps whose notes exceed the cap instead of truncating them

[._.]/ Adam Eivy18c1d6f546c0
diff --git a/server/lib/humanActions.js b/server/lib/humanActions.js
index fe69db5ceb..4c5805a6ec 100644
--- a/server/lib/humanActions.js
+++ b/server/lib/humanActions.js
@@ -26,6 +26,8 @@ export const HUMAN_ACTION_CATCH_UP_MS = 24 * 60 * 60 * 1000;
// before `Date.now()` reaches the due time; a step this close counts as due.
export const HUMAN_ACTION_EARLY_FIRE_MS = 1000;
+export const HUMAN_ACTION_NOTES_MAX = 20000;
+
const planKey = z.string().trim().min(1).max(40)
.regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, 'planKey must be a lowercase dash slug');
@@ -54,7 +56,15 @@ export const humanActionPlanSchema = z.object({
planKey,
title: z.string().trim().min(1).max(120),
steps: z.array(humanActionStepSchema).min(1).max(30),
-}).strict();
+}).strict().superRefine((plan, ctx) => {
+ // Thread notes are capped; reject a step that would not fit rather than cut it
+ // (a cut can drop a fenced block's closing fence or accepted instructions).
+ plan.steps.forEach((step, i) => {
+ if (buildHumanActionNotes(step, { planTitle: plan.title }).length > HUMAN_ACTION_NOTES_MAX) {
+ ctx.addIssue({ code: "custom", path: ["steps", i], message: `step notes exceed ${HUMAN_ACTION_NOTES_MAX} characters; shorten its instructions or content` });
+ }
+ });
+});
export const humanActionPlanTag = (key) => `${HUMAN_ACTION_PLAN_TAG_PREFIX}${key}`;
@@ -94,7 +104,7 @@ export function humanActionThreadFields(step, plan) {
status: 'open',
priority: step.priority || 'normal',
nextAction: step.instructions[0].slice(0, 500),
- notes: buildHumanActionNotes(step, { planTitle: plan.title }).slice(0, 20000),
+ notes: buildHumanActionNotes(step, { planTitle: plan.title }),
dueAt: new Date(step.dueAt).toISOString(),
tags: [HUMAN_ACTION_TAG, humanActionPlanTag(plan.planKey)],
pinned: false,
diff --git a/server/lib/humanActions.test.js b/server/lib/humanActions.test.js
index c488a1a161..688be9cde5 100644
--- a/server/lib/humanActions.test.js
+++ b/server/lib/humanActions.test.js
@@ -21,6 +21,13 @@ const plan = humanActionPlanSchema.parse({
});
describe('humanActionPlanSchema', () => {
+ it('rejects a step whose rendered notes exceed the thread notes cap instead of truncating', () => {
+ const big = { ...plan, steps: [{ ...plan.steps[0], content: Array.from({ length: 5 }, (_, i) => ({ label: `L${i}`, text: 'x'.repeat(5000) })) }] };
+ const result = humanActionPlanSchema.safeParse(big);
+ expect(result.success).toBe(false);
+ expect(result.error.issues[0].path).toEqual(['steps', 0]);
+ });
+
it('refuses a due time without an offset, so a local time is never read as UTC', () => {
const bad = { ...plan, steps: [{ ...plan.steps[0], dueAt: '2026-10-07T10:00:00' }] };
expect(humanActionPlanSchema.safeParse(bad).success).toBe(false);
diff --git a/server/services/humanActionReminders.js b/server/services/humanActionReminders.js
index 3d70d7b5d0..a24ea61f59 100644
--- a/server/services/humanActionReminders.js
+++ b/server/services/humanActionReminders.js
@@ -60,14 +60,24 @@ async function fireHumanActionReminder(threadId, deps = {}) {
// rather than dropping the reminder until the next unrelated write.
if (notYet) (deps.requeue || queueReconcile)();
if (!reminded) return false;
- await notify({
+ const sent = await notify({
type: NOTIFICATION_TYPES.ACTION_DUE,
title: `Time to: ${reminded.title}`,
description: reminded.nextAction || 'Open the step for its instructions.',
priority: ['high', 'urgent'].includes(reminded.priority) ? 'high' : 'medium',
link: threadLink(threadId),
metadata: { threadId, dueAt: reminded.dueAt },
+ }).then(() => true, (err) => {
+ console.error(`❌ Human action notification failed for ${threadId}: ${err.message}`);
+ return false;
});
+ if (!sent) {
+ // Un-stamp so the retry (and the next boot) can deliver it.
+ await storage.updateWith('threads', threadId, (fresh) => (
+ fresh.remindedFor === reminded.dueAt ? { remindedFor: null } : null
+ ));
+ return false;
+ }
console.log(`⏰ Human action due: ${reminded.title}`);
return true;
}
diff --git a/server/services/humanActionReminders.test.js b/server/services/humanActionReminders.test.js
index 20a274a90a..bbe8f03c18 100644
--- a/server/services/humanActionReminders.test.js
+++ b/server/services/humanActionReminders.test.js
@@ -55,6 +55,16 @@ const depsFor = (storage) => ({
describe('human action reminders', () => {
beforeEach(() => stopHumanActionReminders());
+ it('un-stamps a step whose notification failed so a retry can deliver it', async () => {
+ const storage = fakeStore([step({ dueAt: '2026-10-06T17:59:00.000Z' })]);
+ const deps = depsFor(storage);
+ deps.addNotification.mockRejectedValueOnce(new Error('disk full'));
+ expect(await fireHumanActionReminder('step-1', deps)).toBe(false);
+ expect(storage.byId.get('step-1').remindedFor).toBeNull();
+ expect(await fireHumanActionReminder('step-1', deps)).toBe(true);
+ expect(deps.addNotification).toHaveBeenCalledTimes(2);
+ });
+
it('arms future steps, catches up a due one once, and skips steps another machine created', async () => {
const storage = fakeStore([
step(),