Move to threads based system.

This commit is contained in:
Gabriel Brown
2026-06-22 10:37:26 -04:00
parent 8ae6c4b533
commit 206b64176b
82 changed files with 6169 additions and 1930 deletions
+13
View File
@@ -22,6 +22,13 @@ const syncStatus = v.union(
v.literal('merged'),
);
const syncDecision = v.union(
v.literal('auto_synced'),
v.literal('thread_created'),
v.literal('ignored'),
v.literal('failed'),
);
export const listRecent = query({
args: { limit: v.optional(v.number()) },
handler: async (ctx, { limit }) => {
@@ -52,6 +59,7 @@ export const createInternal = internalMutation({
args: {
spoonId: v.id('spoons'),
ownerId: v.id('users'),
threadId: v.optional(v.id('threads')),
kind: syncKind,
status: syncStatus,
upstreamFrom: v.optional(v.string()),
@@ -60,6 +68,7 @@ export const createInternal = internalMutation({
aiAssessment: v.optional(v.string()),
mergeRequestUrl: v.optional(v.string()),
error: v.optional(v.string()),
decision: v.optional(syncDecision),
},
handler: async (ctx, args): Promise<Id<'syncRuns'>> => {
const now = Date.now();
@@ -74,6 +83,7 @@ export const createInternal = internalMutation({
export const patchInternal = internalMutation({
args: {
syncRunId: v.id('syncRuns'),
threadId: v.optional(v.id('threads')),
status: v.optional(syncStatus),
upstreamFrom: v.optional(v.string()),
upstreamTo: v.optional(v.string()),
@@ -81,9 +91,11 @@ export const patchInternal = internalMutation({
aiAssessment: v.optional(v.string()),
mergeRequestUrl: v.optional(v.string()),
error: v.optional(v.string()),
decision: v.optional(syncDecision),
},
handler: async (ctx, args) => {
const patch: Partial<Doc<'syncRuns'>> = { updatedAt: Date.now() };
if (args.threadId !== undefined) patch.threadId = args.threadId;
if (args.status !== undefined) patch.status = args.status;
if (args.upstreamFrom !== undefined) patch.upstreamFrom = args.upstreamFrom;
if (args.upstreamTo !== undefined) patch.upstreamTo = args.upstreamTo;
@@ -95,6 +107,7 @@ export const patchInternal = internalMutation({
patch.mergeRequestUrl = args.mergeRequestUrl;
}
if (args.error !== undefined) patch.error = args.error;
if (args.decision !== undefined) patch.decision = args.decision;
await ctx.db.patch(args.syncRunId, patch);
return { success: true };
},