mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd): return log snapshot for paused tasks (#21771)
Previously the task logs endpoint only worked when the workspace was running, leaving users unable to view task history after pausing. This change adds snapshot retrieval with state-based branching: active tasks fetch live logs from AgentAPI, paused/initializing/pending tasks return stored snapshots (providing continuity during pause/resume), and error/unknown states return HTTP 409 Conflict. The response includes snapshot metadata (snapshot, snapshot_at) to indicate whether logs are live or historical. Closes coder/internal#1254
This commit is contained in:
+6
-2
@@ -346,9 +346,13 @@ type TaskLogEntry struct {
|
||||
Time time.Time `json:"time" format:"date-time" table:"time,default_sort"`
|
||||
}
|
||||
|
||||
// TaskLogsResponse contains the logs for a task.
|
||||
// TaskLogsResponse contains task logs and metadata. When snapshot is false,
|
||||
// logs are fetched live from the task app. When snapshot is true, logs are
|
||||
// fetched from a stored snapshot captured during pause.
|
||||
type TaskLogsResponse struct {
|
||||
Logs []TaskLogEntry `json:"logs"`
|
||||
Logs []TaskLogEntry `json:"logs"`
|
||||
Snapshot bool `json:"snapshot,omitempty"`
|
||||
SnapshotAt *time.Time `json:"snapshot_at,omitempty"`
|
||||
}
|
||||
|
||||
// TaskLogs retrieves logs from the task app.
|
||||
|
||||
Reference in New Issue
Block a user