Skip to content

feat(cli): warn user if setting autostart on workspace with template-level autostart#20454

Merged
mtojek merged 3 commits into
mainfrom
15619-warn-autostart
Oct 24, 2025
Merged

feat(cli): warn user if setting autostart on workspace with template-level autostart#20454
mtojek merged 3 commits into
mainfrom
15619-warn-autostart

Conversation

@mtojek

@mtojek mtojek commented Oct 24, 2025

Copy link
Copy Markdown
Member

Description

This PR adds a warning message in the CLI when a user sets an autostart schedule for a workspace, and the workspace's template has autostart requirement restrictions (specific days of the week).

Changes

  • CLI Warning: When running coder schedule start <workspace> <schedule>, the CLI now checks if the template has AutostartRequirement.DaysOfWeek restrictions and warns the user
  • Test Coverage: Added comprehensive tests for the warning functionality

Example Output

$ coder schedule start my-workspace 9:30AM Mon-Fri
Warning: your workspace template restricts autostart to the following days: monday, wednesday, friday.
Your workspace may not autostart on days not in this list.

Technical Notes

  • The warning is sent to stderr (not stdout) following CLI conventions
  • Warning only appears when setting a schedule (not when setting to "manual")
  • In AGPL mode, AutostartRequirement always returns all days (enterprise feature), but the warning logic works for both AGPL and Enterprise editions

Testing

  • ✅ All existing schedule tests pass
  • ✅ New tests added and passing
  • ✅ Linting and formatting pass

Fixes #15619

…level autostart

When a user sets a workspace autostart schedule via the CLI, and the
template has autostart requirement restrictions (days of week), warn
the user that their workspace may not autostart on days not allowed
by the template.

This helps users understand why their workspace might not autostart
as expected when template-level restrictions are in place.

Fixes #15619
This test was not applicable in AGPL mode and was always skipped.
@mtojek mtojek requested a review from johnstcn October 24, 2025 09:54
@mtojek mtojek marked this pull request as ready for review October 24, 2025 09:54

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo one wording suggestion

Comment thread cli/schedule.go Outdated
Use positive wording 'may only autostart on these days' instead of
'may not autostart on days not in this list'.

Co-authored-by: Cian Johnston <cian@coder.com>
@mtojek mtojek enabled auto-merge (squash) October 24, 2025 10:13
@mtojek mtojek merged commit fb9d8e3 into main Oct 24, 2025
25 checks passed
@mtojek mtojek deleted the 15619-warn-autostart branch October 24, 2025 10:18
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: cli: warn user if setting autostart on workspace with template-level autostart

2 participants