Skip to content

Track task initialization phases as workspace app statuses #20749

@ssncferreira

Description

@ssncferreira

Problem

PR #20692 introduced initialization messages for tasks by deriving status from the task status, workspace build status, and agent lifecycle. These messages are computed ad hoc in the API response.

A better approach would be to insert these as actual workspace_app_status records in the database. This would:

  • Provide a historical timeline of initialization phases
  • Make status changes queryable
  • Enable better debugging of initialization issues

Proposed approach

We can consider 2 stages of initialization for the 3 different components (workspaces, agents and apps):

  1. Provisioning stage: when the workspace is still pending or starting (the agent is created on the workspace starting phase).
  2. Agent/App initializing: when the agent and then the app are initializing

This means that the workspace pending phase would not be possible as an app status, but all other cases could be an app status, referring to a possible new TaskState (initializing).

For the second phase where agent/app exists (workspace starting onwards), we could insert app status records:

  • Option A: Agent explicitly reports status via PatchAppStatus on lifecycle transitions
  • Option B: Coderd automatically inserts app status on agent lifecycle changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions