File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,6 +140,16 @@ export async function POST(req: NextRequest) {
140140 const workflowId = resolved . workflowId
141141 const workflowResolvedName = resolved . workflowName
142142
143+ // Resolve workspace from workflow so it can be sent as implicit context to the Go backend.
144+ let resolvedWorkspaceId : string | undefined
145+ try {
146+ const { getWorkflowById } = await import ( '@/lib/workflows/utils' )
147+ const wf = await getWorkflowById ( workflowId )
148+ resolvedWorkspaceId = wf ?. workspaceId ?? undefined
149+ } catch {
150+ logger . warn ( `[${ tracker . requestId } ] Failed to resolve workspaceId from workflow` )
151+ }
152+
143153 const userMessageIdToUse = userMessageId || crypto . randomUUID ( )
144154 try {
145155 logger . info ( `[${ tracker . requestId } ] Received chat POST` , {
@@ -213,6 +223,7 @@ export async function POST(req: NextRequest) {
213223 message,
214224 workflowId : workflowId || '' ,
215225 workflowName : workflowResolvedName ,
226+ workspaceId : resolvedWorkspaceId ,
216227 userId : authenticatedUserId ,
217228 userMessageId : userMessageIdToUse ,
218229 mode,
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ export async function POST(req: NextRequest) {
112112 const requestPayload = await buildCopilotRequestPayload (
113113 {
114114 message,
115+ workspaceId,
115116 userId : authenticatedUserId ,
116117 userMessageId,
117118 mode : 'agent' ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export interface BuildPayloadParams {
1212 message : string
1313 workflowId ?: string
1414 workflowName ?: string
15+ workspaceId ?: string
1516 userId : string
1617 userMessageId : string
1718 mode : string
@@ -146,6 +147,7 @@ export async function buildCopilotRequestPayload(
146147 message,
147148 ...( workflowId ? { workflowId } : { } ) ,
148149 ...( params . workflowName ? { workflowName : params . workflowName } : { } ) ,
150+ ...( params . workspaceId ? { workspaceId : params . workspaceId } : { } ) ,
149151 userId,
150152 ...( selectedModel ? { model : selectedModel } : { } ) ,
151153 ...( provider ? { provider } : { } ) ,
You can’t perform that action at this time.
0 commit comments