Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: reorder error

Gus2ebe256a276b
diff --git a/src/shared/src/db/queries/agent-pin.ts b/src/shared/src/db/queries/agent-pin.ts
index 46f042a3e..8f3c65c9d 100644
--- a/src/shared/src/db/queries/agent-pin.ts
+++ b/src/shared/src/db/queries/agent-pin.ts
@@ -44,18 +44,18 @@ export async function reorderPins(
userId: string,
orderedAgentIds: string[],
) {
- await db.transaction(async (tx) => {
- for (let i = 0; i < orderedAgentIds.length; i++) {
- await tx
+ await (db as any).batch(
+ orderedAgentIds.map((id, i) =>
+ db
.update(agentPin)
.set({ position: i })
.where(
and(
- eq(agentPin.agentId, orderedAgentIds[i]),
+ eq(agentPin.agentId, id),
eq(agentPin.workspaceId, workspaceId),
eq(agentPin.userId, userId),
)
- );
- }
- });
+ )
+ )
+ );
}
diff --git a/src/shared/src/db/queries/agent-sidebar-order.ts b/src/shared/src/db/queries/agent-sidebar-order.ts
index ddd182460..3b9825505 100644
--- a/src/shared/src/db/queries/agent-sidebar-order.ts
+++ b/src/shared/src/db/queries/agent-sidebar-order.ts
@@ -16,24 +16,22 @@ export async function reorder(
userId: string,
orderedAgentIds: string[],
) {
- await db.transaction(async (tx) => {
- await tx
+ await (db as any).batch([
+ db
.delete(agentSidebarOrder)
.where(
and(
eq(agentSidebarOrder.workspaceId, workspaceId),
eq(agentSidebarOrder.userId, userId),
)
- );
- if (orderedAgentIds.length > 0) {
- await tx.insert(agentSidebarOrder).values(
- orderedAgentIds.map((agentId, i) => ({
- agentId,
- workspaceId,
- userId,
- position: i,
- }))
- );
- }
- });
+ ),
+ ...orderedAgentIds.map((agentId, i) =>
+ db.insert(agentSidebarOrder).values({
+ agentId,
+ workspaceId,
+ userId,
+ position: i,
+ })
+ ),
+ ]);
}