Skip to content

Commit 18dfa39

Browse files
committed
add sessionuser id"
1 parent 4679ed3 commit 18dfa39

5 files changed

Lines changed: 9 additions & 1 deletion

File tree

apps/sim/app/api/workflows/[id]/execute/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
505505
workflowId,
506506
workspaceId: workflow.workspaceId ?? undefined,
507507
userId: actorUserId,
508+
sessionUserId: isClientSession ? userId : undefined,
508509
triggerType,
509510
useDraftState: shouldUseDraftState,
510511
startTime: new Date().toISOString(),
@@ -772,6 +773,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
772773
workflowId,
773774
workspaceId: workflow.workspaceId ?? undefined,
774775
userId: actorUserId,
776+
sessionUserId: isClientSession ? userId : undefined,
775777
triggerType,
776778
useDraftState: shouldUseDraftState,
777779
startTime: new Date().toISOString(),

apps/sim/executor/execution/snapshot-serializer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export function serializePauseSnapshot(
101101
workflowId: context.workflowId,
102102
workspaceId: context.workspaceId,
103103
userId: metadataFromContext?.userId ?? '',
104+
sessionUserId: metadataFromContext?.sessionUserId,
104105
triggerType: metadataFromContext?.triggerType ?? 'manual',
105106
triggerBlockId: triggerBlockIds[0],
106107
useDraftState,

apps/sim/executor/execution/snapshot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface ExecutionMetadata {
77
workflowId: string
88
workspaceId?: string
99
userId: string
10+
sessionUserId?: string
1011
triggerType: string
1112
triggerBlockId?: string
1213
useDraftState: boolean

apps/sim/lib/workflows/executor/execution-core.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ export async function executeWorkflowCore(
152152
// Merge block states
153153
const mergedStates = mergeSubblockState(blocks)
154154

155-
const personalEnvUserId = metadata.isClientSession ? userId : workflow.userId || userId
155+
const personalEnvUserId =
156+
metadata.isClientSession && metadata.sessionUserId
157+
? metadata.sessionUserId
158+
: workflow.userId || userId
156159

157160
const { personalEncrypted, workspaceEncrypted, personalDecrypted, workspaceDecrypted } =
158161
await getPersonalAndWorkspaceEnv(personalEnvUserId, providedWorkspaceId)

apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ export class PauseResumeManager {
639639
requestId: baseSnapshot.metadata.requestId,
640640
startTime: new Date().toISOString(),
641641
userId,
642+
sessionUserId: baseSnapshot.metadata.sessionUserId,
642643
useDraftState: baseSnapshot.metadata.useDraftState,
643644
isClientSession: baseSnapshot.metadata.isClientSession,
644645
resumeFromSnapshot: true,

0 commit comments

Comments
 (0)