diff --git a/.github/workflows/trigger-tasks-deploy-main.yml b/.github/workflows/trigger-tasks-deploy-main.yml index bbd03d59d..7d5a975c6 100644 --- a/.github/workflows/trigger-tasks-deploy-main.yml +++ b/.github/workflows/trigger-tasks-deploy-main.yml @@ -36,4 +36,4 @@ jobs: VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }} - run: bunx trigger.dev@4.0.0 deploy --env staging --log-level debug + run: bunx trigger.dev@4.0.6 deploy --env staging --log-level debug diff --git a/.github/workflows/trigger-tasks-deploy-release.yml b/.github/workflows/trigger-tasks-deploy-release.yml index b5b5f158c..28b78431b 100644 --- a/.github/workflows/trigger-tasks-deploy-release.yml +++ b/.github/workflows/trigger-tasks-deploy-release.yml @@ -40,4 +40,4 @@ jobs: VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }} - run: bunx trigger.dev@4.0.0 deploy + run: bunx trigger.dev@4.0.6 deploy diff --git a/apps/app/package.json b/apps/app/package.json index 5d795da36..63a720e59 100644 --- a/apps/app/package.json +++ b/apps/app/package.json @@ -49,8 +49,8 @@ "@tiptap/extension-table-cell": "^3.4.4", "@tiptap/extension-table-header": "^3.4.4", "@tiptap/extension-table-row": "^3.4.4", - "@trigger.dev/react-hooks": "4.0.0", - "@trigger.dev/sdk": "4.0.0", + "@trigger.dev/react-hooks": "4.0.6", + "@trigger.dev/sdk": "4.0.6", "@trycompai/db": "^1.3.7", "@trycompai/email": "workspace:*", "@types/canvas-confetti": "^1.9.0", @@ -117,7 +117,7 @@ "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.3.0", - "@trigger.dev/build": "4.0.0", + "@trigger.dev/build": "4.0.6", "@types/d3": "^7.4.3", "@types/jspdf": "^2.0.0", "@types/node": "^24.0.3", @@ -156,8 +156,8 @@ "db:generate": "bun run db:getschema && prisma generate", "db:getschema": "node ../../packages/db/scripts/combine-schemas.js && cp ../../packages/db/dist/schema.prisma prisma/schema.prisma", "db:migrate": "cd ../../packages/db && bunx prisma migrate dev && cd ../../apps/app", - "deploy:trigger-prod": "npx trigger.dev@4.0.0 deploy", - "dev": "bun i && bunx concurrently --kill-others --names \"next,trigger\" --prefix-colors \"yellow,blue\" \"next dev --turbo -p 3000\" \"bun run trigger:dev\"", + "deploy:trigger-prod": "npx trigger.dev@4.0.6 deploy", + "dev": "bun i && bunx concurrently --kill-others --names \"next,trigger\" --prefix-colors \"yellow,blue\" \"next dev --turbo -p 3000\" \"bunx trigger.dev@4.0.6 dev\"", "lint": "next lint && prettier --check .", "prebuild": "bun run db:generate", "start": "next start", @@ -173,7 +173,6 @@ "test:e2e:ui": "playwright test --ui", "test:ui": "vitest --ui", "test:watch": "vitest --watch", - "trigger:dev": "npx trigger.dev@4.0.0 dev", "typecheck": "tsc --noEmit" } } \ No newline at end of file diff --git a/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/actions/task-automation-actions.ts b/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/actions/task-automation-actions.ts index 13a14f103..40100081b 100644 --- a/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/actions/task-automation-actions.ts +++ b/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/actions/task-automation-actions.ts @@ -186,6 +186,7 @@ export async function executeAutomationScript(data: { orgId: string; taskId: string; automationId: string; + version?: number; // Optional: test specific version }) { try { const result = await callEnterpriseApi('/api/tasks-automations/trigger/execute', { @@ -361,6 +362,12 @@ export async function publishAutomation( }, }); + // Enable automation if not already enabled + await db.evidenceAutomation.update({ + where: { id: automationId }, + data: { isEnabled: true }, + }); + return { success: true, version, diff --git a/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/components/PublishDialog.tsx b/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/components/PublishDialog.tsx index 49d98adb1..bda713016 100644 --- a/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/components/PublishDialog.tsx +++ b/apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/components/PublishDialog.tsx @@ -12,10 +12,10 @@ import { import { Label } from '@comp/ui/label'; import { Textarea } from '@comp/ui/textarea'; import { Loader2 } from 'lucide-react'; -import { useParams } from 'next/navigation'; +import { useParams, useRouter } from 'next/navigation'; import { useState } from 'react'; import { toast } from 'sonner'; -import { publishAutomation } from '../actions/task-automation-actions'; +import { executeAutomationScript, publishAutomation } from '../actions/task-automation-actions'; import { useAutomationVersions } from '../hooks/use-automation-versions'; import { useSharedChatContext } from '../lib/chat-context'; @@ -25,6 +25,7 @@ interface PublishDialogProps { } export function PublishDialog({ open, onOpenChange }: PublishDialogProps) { + const router = useRouter(); const { orgId, taskId } = useParams<{ orgId: string; taskId: string; @@ -33,8 +34,20 @@ export function PublishDialog({ open, onOpenChange }: PublishDialogProps) { const { automationIdRef } = useSharedChatContext(); const [changelog, setChangelog] = useState(''); const [isPublishing, setIsPublishing] = useState(false); + const [showPostPublishOptions, setShowPostPublishOptions] = useState(false); + const [publishedVersion, setPublishedVersion] = useState(null); const { mutate } = useAutomationVersions(); + const handleDialogChange = (newOpen: boolean) => { + onOpenChange(newOpen); + // Reset state when dialog closes + if (!newOpen) { + setChangelog(''); + setShowPostPublishOptions(false); + setPublishedVersion(null); + } + }; + const handlePublish = async () => { setIsPublishing(true); @@ -50,12 +63,31 @@ export function PublishDialog({ open, onOpenChange }: PublishDialogProps) { throw new Error(result.error || 'Failed to publish'); } - toast.success(`Version ${result.version?.version} published successfully!`); - setChangelog(''); - onOpenChange(false); + const versionNumber = result.version?.version; + toast.success(`Version ${versionNumber} published successfully!`); + setPublishedVersion(versionNumber || null); // Refresh versions list await mutate(); + + // Trigger a test run with the new version + if (versionNumber) { + const runResult = await executeAutomationScript({ + orgId, + taskId, + automationId: automationIdRef.current, + version: versionNumber, + }); + + if (runResult.success) { + toast.success('Running automation with published version'); + } else { + toast.error(runResult.error || 'Failed to start automation run'); + } + } + + // Show post-publish options instead of closing + setShowPostPublishOptions(true); } catch (error) { toast.error(error instanceof Error ? error.message : 'Failed to publish automation'); } finally { @@ -63,38 +95,73 @@ export function PublishDialog({ open, onOpenChange }: PublishDialogProps) { } }; + const handleGoToOverview = () => { + handleDialogChange(false); + router.push(`/${orgId}/tasks/${taskId}/automations/${automationIdRef.current}/overview`); + }; + + const handleStayHere = () => { + handleDialogChange(false); + }; + return ( - + - - Publish Automation - - Create a new version of this automation. The current draft will remain editable. - - - -
-
- -