Skip to content

fix(logs): add status field to log detail API for polling#3405

Merged
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/log-stream-enrich
Mar 4, 2026
Merged

fix(logs): add status field to log detail API for polling#3405
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/log-stream-enrich

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Log detail API was missing status field, so the detail sidebar never polled for updates on running/pending logs
  • Added status to the select query and response in /api/logs/[id]

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
Copy link

vercel bot commented Mar 4, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 4, 2026 2:00am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR fixes a bug where the log detail sidebar would never poll for live updates on in-progress executions. The root cause was that the GET /api/logs/[id] endpoint was not including the status field in its database select query or JSON response, so the client-side detailRefetchInterval callback in logs.tsx (which checks for 'running' or 'pending' status to schedule a 3-second poll) would always receive undefined and skip polling.

Changes:

  • Added status: workflowExecutionLogs.status to the Drizzle ORM select query in /api/logs/[id]/route.ts
  • Added status: log.status to the response object returned to the client

Assessment:

  • The fix is minimal, targeted, and correct — status is a non-null column in the schema (text('status').notNull().default('running')) and is already typed as status?: string | null in the WorkflowLog interface, so no type changes are needed
  • The polling logic in logs.tsx using detailRefetchInterval will now correctly detect 'running' and 'pending' states and poll every 3 seconds until the execution completes

Confidence Score: 5/5

  • This PR is safe to merge — it's a minimal, additive fix with no side effects.
  • The change adds a single field (status) to an existing API select query and response object. The field already exists in the database schema as non-nullable, is already typed in the WorkflowLog interface, and is already consumed correctly by the client-side polling logic. There are no breaking changes, no security implications, and no logic alterations.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/api/logs/[id]/route.ts Adds the status field to both the Drizzle select query and the JSON response object, fixing the bug where the log detail sidebar never polled for live updates on running/pending executions.

Sequence Diagram

sequenceDiagram
    participant C as Client (logs.tsx)
    participant Q as React Query (useLogDetail)
    participant API as GET /api/logs/[id]
    participant DB as Database

    C->>Q: select log (running/pending)
    Q->>API: fetch /api/logs/{id}
    API->>DB: SELECT id, status, level, ... FROM workflow_execution_logs
    Note over DB,API: status field NOW included in SELECT
    DB-->>API: row with status = 'running'
    API-->>Q: { data: { ..., status: 'running' } }
    Q-->>C: data.status = 'running'
    Note over C,Q: detailRefetchInterval sees 'running'<br/>→ schedules poll in 3000ms
    loop Every 3s while status is running/pending
        Q->>API: refetch /api/logs/{id}
        API->>DB: SELECT id, status, ...
        DB-->>API: row with updated status
        API-->>Q: { data: { ..., status: 'completed' } }
        Q-->>C: data.status = 'completed'
        Note over C,Q: detailRefetchInterval sees 'completed'<br/>→ returns false, stops polling
    end
Loading

Last reviewed commit: 3eea3c6

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/log-stream-enrich branch from 3eea3c6 to 4241cfe Compare March 4, 2026 02:00
@waleedlatif1 waleedlatif1 merged commit 1cf7fdf into staging Mar 4, 2026
6 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/log-stream-enrich branch March 4, 2026 02:00
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