Skip to content

fix(logs, workflows): snapshot fetch optionality, restore consistent draft read snapshots - #6594

Merged
icecrasher321 merged 2 commits into
stagingfrom
fix/logs-perf
Aug 12, 2026
Merged

fix(logs, workflows): snapshot fetch optionality, restore consistent draft read snapshots#6594
icecrasher321 merged 2 commits into
stagingfrom
fix/logs-perf

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • Don't always need snapshot data
  • Restore consistent draft read snapshots

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 12, 2026 4:21am

Request Review

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches workflow draft-read and log-detail query paths, including stronger workspace scoping on snapshot loads. Incorrect filtering or join changes could affect read correctness or access boundaries.

Overview
Avoids loading unused execution snapshots in log detail, and restores consistent, workspace-scoped draft workflow reads.

fetchLogDetail no longer goes through getPublicWorkflowLog (which joined workflowExecutionSnapshots / user). It queries the detail fields it needs directly, so log detail no longer materializes heavy workflowState snapshot data.

Draft readWorkflowDefinition now uses the canonical loadWorkflowReadSnapshot path (same consistent transaction as other reads) instead of loading normalized tables alone. loadWorkflowReadSnapshot also requires workspaceId and filters the workflow row by workspace + non-archived at query time; callers like readWorkflow are updated accordingly.

Reviewed by Cursor Bugbot for commit 3125237. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR avoids fetching unused execution snapshots for internal log details and restores consistent workflow-row and draft-state reads within one repeatable-read transaction.

  • Replaces the broad public-log query with a workspace-scoped detail query that omits unused snapshot and owner joins.
  • Requires workflow read snapshots to be scoped to the canonical workspace and active workflow.
  • Uses the canonical snapshot for draft workflow-definition responses while preserving immutable deployment-state reads.
  • Adds focused tests for log-query optionality and draft snapshot consistency.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or non-blocking defects identified.

The replacement log query preserves all fields used by log-detail responses, and every workflow snapshot caller supplies the canonical workspace while retaining authorization and active-workflow checks.

Important Files Changed

Filename Overview
apps/sim/lib/logs/fetch-log-detail.ts Replaces a broad shared query with a workspace-scoped query that retains consumed fields while avoiding unused snapshot and user joins.
apps/sim/lib/workflows/queries.ts Extends repeatable-read snapshots with canonical workspace and active-workflow filtering.
apps/sim/lib/workflows/application/read-workflow-definition.ts Returns draft metadata and normalized state from the same snapshot while leaving deployed reads on the deployment-state path.
apps/sim/lib/workflows/application/read-workflow.ts Passes the canonical context workspace into the newly scoped snapshot query.
apps/sim/lib/logs/fetch-log-detail.test.ts Verifies internal log details no longer fetch execution snapshots or workflow-owner data.
apps/sim/lib/workflows/application/read-workflow-definition.test.ts Covers consistent draft snapshots, invalid snapshot records, and preservation of deployed-state behavior.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant UseCase as Authorized workflow use case
  participant Context as Context resolver
  participant DB as PostgreSQL
  Caller->>UseCase: Read draft workflow
  UseCase->>Context: Resolve active workflow and workspace
  Context->>DB: Load canonical active workflow
  DB-->>Context: Workflow context
  UseCase->>DB: Begin REPEATABLE READ snapshot
  par Consistent draft state
    DB->>DB: Load normalized workflow tables
  and Consistent workflow metadata
    DB->>DB: Load active workflow scoped by workspace
  end
  DB-->>UseCase: Workflow record and normalized state
  UseCase-->>Caller: Consistent draft definition
Loading

Reviews (1): Last reviewed commit: "fix(workflows): restore consistent draft..." | Re-trigger Greptile

@icecrasher321
icecrasher321 merged commit eb26b42 into staging Aug 12, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/logs-perf branch August 12, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant