Feature: per-template Message field mode (optional, required or hidden)
Related to
Web-Frontend (what users interact with)
Impact
better user experience
Missing Feature
A per-template setting for the "Message (Optional)" field in the task dialog, with three modes: optional (today's behaviour), required, hidden.
Two existing needs pull the field in opposite directions:
- #3085 wants it required: every run must carry a reference (a ServiceNow RITM number in that case) for audit.
- Deployments that expose Semaphore to end users who click a template and press Run want it hidden, for the same reason #1957 wanted Dry Run and Diff gone (#4152): one more box that means nothing to those users, and every task in the history is labelled with whatever they typed, or nothing.
One setting covers both. Two independent flags (require_message, hide_message) would allow a template that both hides and requires the field.
Implementation
In the template form's Prompts row, a "Message" selector with Optional / Required / Hidden, default Optional. Its effect on the task dialog (New Task, and the schedule, integration and workflow forms that embed TaskParamsForm):
- Optional: current behaviour.
- Required: label loses "(Optional)"; the form's validation refuses a blank message, so Run stays blocked until one is typed. The API refuses it too: POST /project/{id}/tasks returns 400 template requires a task message when the message is blank. That applies to the user-launched path only; schedules, integrations and build chains add tasks to the pool directly with no one to type a message, and keep running.
- Hidden: the field is not rendered.
Stored as task_params.message_mode, so it applies to every app, and a template with no key reads as optional, so existing templates are unaffected. Template.Validate() rejects any other value.
Design
type TemplateMessageMode string
const (
TemplateMessageOptional TemplateMessageMode = "optional"
TemplateMessageRequired TemplateMessageMode = "required"
TemplateMessageHidden TemplateMessageMode = "hidden"
)
func (tpl *Template) MessageMode() (TemplateMessageMode, error) // absent / "" -> optional; unknown -> validation error
func (tpl *Template) ValidateTaskMessage(message string) error // blank message on a required template -> validation errorValidateTaskMessage is called from TaskController.AddTask after the template is resolved, before TaskPool.AddTask. Frontend reads template.task_params.message_mode in TaskForm.vue and TaskParamsForm.vue.
I have this already implemented and tested and I'm happy to open a PR once the approach is confirmed. It would close #3085 as well.
Source: semaphoreui/semaphore