feat(notifications): emit at maintenance/turn/sync/reauth events
This commit is contained in:
@@ -4,6 +4,7 @@ import type { Doc, Id } from './_generated/dataModel';
|
||||
import type { MutationCtx } from './_generated/server';
|
||||
import { internalMutation, mutation, query } from './_generated/server';
|
||||
import { getOwnedSpoon, getRequiredUserId, optionalText } from './model';
|
||||
import { emitNotification } from './notifications';
|
||||
import type { AgentRuntimeName } from './runtimeSupport';
|
||||
import { runtimesForProfile } from './runtimeSupport';
|
||||
import { assertWorkerToken } from './workerAuth';
|
||||
@@ -1344,6 +1345,21 @@ export const updateStatus = mutation({
|
||||
}
|
||||
await ctx.db.patch(job.threadId, threadPatch);
|
||||
}
|
||||
if (
|
||||
(args.status === 'changes_ready' ||
|
||||
args.status === 'draft_pr_opened') &&
|
||||
job.status !== args.status
|
||||
) {
|
||||
await emitNotification(ctx, {
|
||||
userId: job.ownerId,
|
||||
kind: 'agent_turn_finished',
|
||||
title: 'Agent turn finished',
|
||||
body: args.summary ?? job.summary ?? '',
|
||||
link: `/threads/${job.threadId}`,
|
||||
threadId: job.threadId,
|
||||
spoonId: job.spoonId,
|
||||
});
|
||||
}
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
@@ -1687,6 +1703,17 @@ export const applyMaintenanceDecision = mutation({
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
});
|
||||
if (status === 'waiting_for_user') {
|
||||
await emitNotification(ctx, {
|
||||
userId: job.ownerId,
|
||||
kind: 'agent_needs_input',
|
||||
title: 'Agent needs your input',
|
||||
body: args.summary,
|
||||
link: `/threads/${job.threadId}`,
|
||||
threadId: job.threadId,
|
||||
spoonId: job.spoonId,
|
||||
});
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user