Approve tool use

The user has approved the tool use.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-06 20:15:14 +00:00
parent edd12b4454
commit 67525173cb
5 changed files with 450 additions and 1 deletions

View File

@@ -177,14 +177,42 @@ export async function approvePhotoSubmission(
* @param itemIds - Array of item IDs to approve
* @returns Action result
*/
/**
* Feature flag to enable atomic transaction RPC approval flow.
* Set to true to use the new process-selective-approval-v2 edge function
* that wraps the entire approval in a single PostgreSQL transaction.
*
* Benefits of v2:
* - True atomic transactions (all-or-nothing)
* - Automatic rollback on ANY error
* - Network-resilient (edge function crash = auto rollback)
* - Eliminates orphaned entities
*
* To enable: localStorage.setItem('use_rpc_approval', 'true')
* To disable: localStorage.setItem('use_rpc_approval', 'false')
*/
const USE_RPC_APPROVAL = typeof window !== 'undefined' &&
localStorage.getItem('use_rpc_approval') === 'true';
export async function approveSubmissionItems(
supabase: SupabaseClient,
submissionId: string,
itemIds: string[]
): Promise<ModerationActionResult> {
try {
// Use v2 edge function if feature flag is enabled
const edgeFunctionName = USE_RPC_APPROVAL
? 'process-selective-approval-v2'
: 'process-selective-approval';
console.log(`[Approval] Using edge function: ${edgeFunctionName}`, {
submissionId,
itemCount: itemIds.length,
useRpcApproval: USE_RPC_APPROVAL
});
const { data: approvalData, error: approvalError, requestId } = await invokeWithTracking(
'process-selective-approval',
edgeFunctionName,
{
itemIds,
submissionId,