Skip to content

Automate browser based workflows with AI

shu/script status pending (#3481)

Shuchang Zheng5a0a228b5637
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunCode.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunCode.tsx
index 1bec9ed51..a6ea0a6f6 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunCode.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunCode.tsx
@@ -52,7 +52,7 @@ function WorkflowRunCode(props?: Props) {
cacheKeyValue,
workflowPermanentId,
pollIntervalMs: !isFinalized ? 3000 : undefined,
- status: "draft",
+ status: "pending",
workflowRunId: workflowRun?.workflow_run_id,
});
const orderedBlockLabels = getOrderedBlockLabels(workflow);
@@ -87,7 +87,7 @@ function WorkflowRunCode(props?: Props) {
cacheKey,
cacheKeyValue,
undefined,
- "draft",
+ "pending",
workflowRun?.workflow_run_id,
],
});
diff --git a/skyvern/core/script_generations/generate_script.py b/skyvern/core/script_generations/generate_script.py
index b40b39069..91436ff47 100644
--- a/skyvern/core/script_generations/generate_script.py
+++ b/skyvern/core/script_generations/generate_script.py
@@ -1605,7 +1605,7 @@ async def generate_workflow_script_python_code(
run_id: str | None = None,
script_id: str | None = None,
script_revision_id: str | None = None,
- draft: bool = False,
+ pending: bool = False,
) -> str:
"""
Build a LibCST Module and emit .code (PEP-8-formatted source).
@@ -1685,7 +1685,7 @@ async def generate_workflow_script_python_code(
script_id=script_id,
organization_id=organization_id,
block_label=block_name,
- update=draft,
+ update=pending,
)
except Exception as e:
LOG.error("Failed to create script block", error=str(e), exc_info=True)
@@ -1800,7 +1800,7 @@ async def generate_workflow_script_python_code(
script_id=script_id,
organization_id=organization_id,
block_label=settings.WORKFLOW_START_BLOCK_LABEL,
- update=draft,
+ update=pending,
)
except Exception as e:
LOG.error("Failed to create __start_block__", error=str(e), exc_info=True)
diff --git a/skyvern/forge/agent_functions.py b/skyvern/forge/agent_functions.py
index 7b963dda3..4c78a7b38 100644
--- a/skyvern/forge/agent_functions.py
+++ b/skyvern/forge/agent_functions.py
@@ -641,7 +641,7 @@ class AgentFunction:
root_workflow_run_id=context.root_workflow_run_id,
organization_id=context.organization_id,
)
- await workflow_script_service.generate_or_update_draft_workflow_script(
+ await workflow_script_service.generate_or_update_pending_workflow_script(
workflow_run=workflow_run,
workflow=workflow,
)
diff --git a/skyvern/services/script_service.py b/skyvern/services/script_service.py
index 0c6ace586..6d23e689d 100644
--- a/skyvern/services/script_service.py
+++ b/skyvern/services/script_service.py
@@ -58,7 +58,7 @@ async def build_file_tree(
script_id: str,
script_version: int,
script_revision_id: str,
- draft: bool = False,
+ pending: bool = False,
) -> dict[str, FileNode]:
"""Build a hierarchical file tree from a list of files and upload the files to s3 with the same tree structure."""
file_tree: dict[str, FileNode] = {}
@@ -71,7 +71,7 @@ async def build_file_tree(
# Create artifact and upload to S3
try:
- if draft:
+ if pending:
# get the script file object
script_file = await app.DATABASE.get_script_file_by_path(
script_revision_id=script_revision_id,
diff --git a/skyvern/services/workflow_script_service.py b/skyvern/services/workflow_script_service.py
index 109c99c35..e35111a1e 100644
--- a/skyvern/services/workflow_script_service.py
+++ b/skyvern/services/workflow_script_service.py
@@ -15,7 +15,7 @@ LOG = structlog.get_logger()
jinja_sandbox_env = SandboxedEnvironment()
-async def generate_or_update_draft_workflow_script(
+async def generate_or_update_pending_workflow_script(
workflow_run: WorkflowRun,
workflow: Workflow,
) -> None:
@@ -44,7 +44,7 @@ async def generate_or_update_draft_workflow_script(
workflow=workflow,
script=script,
rendered_cache_key_value=rendered_cache_key_value,
- draft=True,
+ pending=True,
)
@@ -111,7 +111,7 @@ async def generate_workflow_script(
workflow: Workflow,
script: Script,
rendered_cache_key_value: str,
- draft: bool = False,
+ pending: bool = False,
) -> None:
try:
LOG.info(
@@ -135,7 +135,7 @@ async def generate_workflow_script(
organization_id=workflow.organization_id,
script_id=script.script_id,
script_revision_id=script.script_revision_id,
- draft=draft,
+ pending=pending,
)
except Exception:
LOG.error("Failed to generate workflow script source", exc_info=True)
@@ -160,21 +160,21 @@ async def generate_workflow_script(
script_id=script.script_id,
script_version=script.version,
script_revision_id=script.script_revision_id,
- draft=draft,
+ pending=pending,
)
# check if an existing drfat workflow script exists for this workflow run
- existing_draft_workflow_script = None
+ existing_pending_workflow_script = None
status = ScriptStatus.published
- if draft:
+ if pending:
status = ScriptStatus.pending
- existing_draft_workflow_script = await app.DATABASE.get_workflow_script(
+ existing_pending_workflow_script = await app.DATABASE.get_workflow_script(
organization_id=workflow.organization_id,
workflow_permanent_id=workflow.workflow_permanent_id,
workflow_run_id=workflow_run.workflow_run_id,
statuses=[status],
)
- if not existing_draft_workflow_script:
+ if not existing_pending_workflow_script:
# Record the workflow->script mapping for cache lookup
await app.DATABASE.create_workflow_script(
organization_id=workflow.organization_id,