Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(site): correct autostop restart prompt on the workspace schedule page - #27632

Merged
jakehwll merged 4 commits into
mainfrom
jakehwll/autostop-enable-restart-prompt
Aug 3, 2026
Merged

fix(site): correct autostop restart prompt on the workspace schedule page#27632
jakehwll merged 4 commits into
mainfrom
jakehwll/autostop-enable-restart-prompt

Conversation

@jakehwll

@jakehwll jakehwll commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was written by Coder Agents on behalf of Jake Howell.

Problem

Enabling autostop on a running workspace never showed the "restart now to apply?" dialog. The new TTL was saved, but a running build's deadline is only calculated when the build starts, so autostop silently did not take effect until a manual restart. Changing an already-enabled value did prompt, so the behavior was inconsistent.

Separately, dismissing that dialog with Apply later navigated the user away to the workspace, exactly like confirming did.

Root cause

The dialog was gated on getAutostop(workspace).autostopEnabled, which derives from workspace.ttl_ms — the pre-submit state (the workspace is not refetched until after the mutation). That expression means "was autostop enabled before this change", which maps to:

Transition Pre-submit enabled Dialog Correct?
Disabled → enabled (add) false not shown ❌ the reported bug
Enabled → new value (modify) true shown
Enabled → disabled (remove) true shown ❌ (nothing to apply)

This guard came from #16085, which intended to skip the prompt when removing autostop (safe, because that PR also made the backend clear a running build's deadline server-side when TTL is set to null). By keying off the old state it actually skipped the prompt on add and still showed it on remove — the opposite of its intent.

Fix

  • Key the prompt off the submitted form value (values.autostopEnabled), with an inline comment documenting the trigger conditions. This fixes the reported bug and restores feat: allow removing deadline for running workspace #16085's intent:
    • add → prompt ✅
    • modify → prompt ✅
    • remove → no prompt ✅ (deadline cleared server-side)
    • stopped / unchanged → no prompt ✅
  • Apply later now just closes the dialog and keeps the user on the schedule page; the saved value still applies on the next start. Restart is unchanged (restarts and navigates to the workspace).

Testing

Storybook play-function coverage on WorkspaceSchedulePage for all cases: enable, change value, disable, enable-while-stopped, autostart-only, and Apply-later-stays-on-page (the last also asserts restartWorkspace is not called). A prior story that asserted the pre-fix behavior (prompting on disable) was reworked. tsc and biome clean.

Investigation notes

History of the gating condition:

  • Originally if (data.autostopChanged) { ... } — prompted on every autostop change (enable included).
  • feat: allow removing deadline for running workspace #16085 ("allow removing deadline for running workspace", fixes FR: allow to disable auto-stop on running workspaces #9775) added && getAutostop(workspace).autostopEnabled. Its description states the goal was to "not show a confirmation dialog when the change is to remove autostop", and the same PR added backend logic in putWorkspaceTTL to clear a running build's deadline when TTL is null.
  • A later refactor added && workspace.latest_build.status === "running".

Because the backend already clears the deadline live on removal, no restart is needed there; the frontend only needs to prompt when autostop ends up enabled on a running workspace. The fix keys off the submitted state so all three transitions behave correctly.

The schedule page gated the restart-to-apply dialog on the workspace's
pre-submit autostop state, so enabling autostop on a running workspace
never prompted and the new deadline only applied on the next start.

Key the prompt off the submitted form value instead via a small pure
helper, shouldConfirmAutostopRestart, so enabling or changing autostop
while running prompts, while disabling (which clears the running build's
deadline server-side) does not.

This also restores the original intent of #16085, which meant to skip
the prompt when removing autostop but keyed off the old state.
@jakehwll jakehwll changed the title 🤖 fix(site): prompt to restart when enabling workspace autostop fix(site): prompt to restart when enabling workspace autostop Jul 29, 2026
@jakehwll
jakehwll requested a review from DanielleMaywood July 29, 2026 03:15
@jakehwll
jakehwll marked this pull request as ready for review July 29, 2026 03:15
chatgpt-codex-connector[bot]

This comment was marked as outdated.

@jakehwll
jakehwll marked this pull request as draft July 29, 2026 03:19
jakehwll added 2 commits July 29, 2026 03:23
Add Storybook play-function coverage for the autostop restart prompt and
document the trigger conditions inline: enabling or changing the value
while running prompts; disabling or a stopped workspace does not. Rework
the prior story that asserted the pre-fix behavior of prompting when
disabling autostop.
Dismissing the restart confirmation with "Apply later" navigated away to
the workspace, same as confirming. Close the dialog instead so the user
stays on the schedule page; the saved value still applies on the next
start.
@jakehwll jakehwll changed the title fix(site): prompt to restart when enabling workspace autostop fix(site): correct autostop restart prompt on the workspace schedule page Jul 29, 2026
@jakehwll
jakehwll marked this pull request as ready for review July 29, 2026 04:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21d7c6235e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +146 to +150
// effect immediately, but only when all of the following hold:
// - autostop actually changed (toggled or new TTL value),
// - autostop is enabled after the change; disabling clears the
// running build's deadline server-side, so no restart is
// needed, and

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Condense the restart-predicate comment

Keep the useful backend invariant, but remove the bullet-by-bullet walkthrough of the three conditions directly below it. This ten-line comment largely restates the if control flow and exceeds the frontend guidance to reserve comments for non-obvious constraints in one to three lines.

AGENTS.md reference: site/AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this area is pretty ambiguous, someone else can comment to this fact but this is an implementation detail that was already a problem once. I like the verbosity. YOMV.

@jakehwll
jakehwll merged commit a76c51d into main Aug 3, 2026
35 checks passed
@jakehwll
jakehwll deleted the jakehwll/autostop-enable-restart-prompt branch August 3, 2026 09:11
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 3, 2026
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.

FR: allow to disable auto-stop on running workspaces

2 participants