A retry now carries the operator's worktree choice (refresh onto the base branch or continue the work already pushed on the task branch) from the dashboard through the task action to the daemon dispatch, and persists it on the task row so it survives a reload. The daemon resolves the mode from the task, never from the workflow; BeginRemediation records continue explicitly so a remediation still resumes its pull request branch.
59 lines
2.4 KiB
Go
59 lines
2.4 KiB
Go
package webui
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
|
"github.com/samcharles93/archie-core/internal/events"
|
|
"github.com/samcharles93/archie-core/internal/taskstate"
|
|
)
|
|
|
|
// changeStatusMeta describes how to present one changes_captured status value.
|
|
// The IDs are the producer's own constants (internal/domain/workflow/task), so
|
|
// the dashboard never spells them out and a rename reaches the browser instead
|
|
// of turning every row into a raw status code.
|
|
type changeStatusMeta struct {
|
|
ID string `json:"id"`
|
|
Label string `json:"label"`
|
|
}
|
|
|
|
// taskMetaView is the whole GET /api/task-meta payload. It is served as one
|
|
// struct rather than an inline map so the wire shape is declared in one place
|
|
// and pinned against the dashboard's freeze-dried snapshot by a fixture test.
|
|
type taskMetaView struct {
|
|
Statuses []taskstate.StatusMeta `json:"statuses"`
|
|
Actions []taskstate.ActionMeta `json:"actions"`
|
|
RetryModes []taskstate.RetryModeMeta `json:"retry_modes"`
|
|
ChangeStatuses []changeStatusMeta `json:"change_statuses"`
|
|
ConfigSchema string `json:"config_schema"`
|
|
}
|
|
|
|
// buildTaskMeta derives the lifecycle presentation catalog: the status
|
|
// vocabulary (with label, pill severity, "needs you" grouping), the operator
|
|
// action controls (with label, button variant, confirm prompt), the retry
|
|
// worktree modes (with label, description and which is the default), the
|
|
// changes_captured status labels and the schema stamp a config_captured
|
|
// payload carries. Everything the dashboard can present that also exists on
|
|
// the server is derived here, so the frontend never has to keep a hand-synced
|
|
// copy of the vocabulary or the control set.
|
|
func buildTaskMeta() taskMetaView {
|
|
return taskMetaView{
|
|
Statuses: taskstate.Statuses(),
|
|
Actions: taskstate.ActionCatalog(),
|
|
RetryModes: taskstate.RetryModes(),
|
|
ChangeStatuses: []changeStatusMeta{
|
|
{ID: task.ChangeAdded, Label: "Added"},
|
|
{ID: task.ChangeModified, Label: "Modified"},
|
|
{ID: task.ChangeDeleted, Label: "Deleted"},
|
|
{ID: task.ChangeRenamed, Label: "Renamed"},
|
|
{ID: task.ChangeTypeChanged, Label: "Type changed"},
|
|
},
|
|
ConfigSchema: events.ConfigCapturedSchema,
|
|
}
|
|
}
|
|
|
|
// handleTaskMeta serves the catalog. See buildTaskMeta for what it carries.
|
|
func (s *Server) handleTaskMeta(w http.ResponseWriter, _ *http.Request) {
|
|
writeJSON(w, buildTaskMeta())
|
|
}
|