Skip to content

Toolbar: show a running profile save and disable what it would refuse - #121

Merged
A21-devs merged 3 commits into
mainfrom
feat/toolbar-profile-busy
Dec 1, 2026
Merged

A21-devs merged 3 commits into
mainfrom
feat/toolbar-profile-busy

Conversation

@A21-devs

@A21-devs A21-devs commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Closes #117

Since #115 the backend refuses Save state and the power actions while a profile save runs, but the toolbar only found out when you clicked. Now it knows ahead of time.

Backend

  • Profiles takes an optional onWork(vm, work) callback and calls it when a save, launch or delete starts and ends ('saving' | 'launching' | 'removing', or null). profiles.work() returns the ones running now.
  • ipc sends it on vm:profileWork. New profileWork() / onProfileWork() on the API so a window that opens mid-save gets it too.
  • I kept this off VmRuntimeState: the runner doesn't know about profiles, and a save goes through off and starting again while it's running.

UI

  • The status next to the VM name reads "Saving profile" (or Launching/Deleting profile) instead of Running/Powered off while it runs.
  • Power on, Suspend/Resume, Save state, Restart, Shut down and Clone are disabled with a tooltip "Saving profile. Wait for it to finish." Force off stays enabled, it's still the way out of a stuck guest.
  • Ctrl+Enter and Delete are held back the same way.
  • The mock backend reports a save for 4 s, so dev:web shows it.

Testing

  • npm run typecheck, npm test (139 passed), npm run build
  • New test: onWork gets saving then null even when the save fails, and work() is empty after.
  • Not checked in the browser pane this run (the preview server couldn't be started), only type-checked and built.

Profiles reports when a save, launch or delete starts and ends. ipc sends
it as vm:profileWork, and profileWork() returns the ones already running
when a window opens.
While a profile save, launch or delete runs on the selected VM, its status
reads Saving profile (or Launching/Deleting), and Power on, Suspend,
Resume, Save state, Restart, Shut down and Clone are disabled with a
tooltip saying why. Force off stays enabled as the way out. Ctrl+Enter and
Delete are held back the same way. The mock backend reports it too.
@A21-devs A21-devs added enhancement New feature or request ui labels Dec 1, 2026

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The toolbar side is right: every button the backend refuses during a profile operation is now disabled with a reason, Force off is left alone, and onWork is called from exclusive's finally, so a failed save can't leave the toolbar stuck disabled.

One gap in the same spirit, inline below: the Hardware tab still only looks at status.


export default function VmDetail(props: Props) {
const { vm, isDraft, status, host, onSave, onCancelDraft, onDelete, onDirtyChange } = props
const { vm, isDraft, status, work, host, onSave, onCancelDraft, onDelete, onDirtyChange } = props

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

work gets as far as the status text, but the Hardware tab still uses locked={status !== 'off'} and canSave only checks status === 'off'. A disk-only profile save (VM off) or the off stretch of a launch leaves the form, Save, Ctrl+S and Delete enabled, and save / remove then fail with "busy with a profile". Lock them on work !== null too.

Comment thread src/renderer/src/App.tsx
if (s.status === 'off') setUsage(({ [s.name]: _gone, ...rest }) => rest)
if (s.status === 'off') setHibernating((cur) => (cur.has(s.name) ? new Set([...cur].filter((n) => n !== s.name)) : cur))
})
window.vmm.profileWork().then(setProfileWork)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Minor, no change needed: if a vm:profileWork event lands before this reply, the reply overwrites it. Same pattern as states() above it. The worst case is the toolbar staying enabled until the next event, which is what we had before this PR.

@A21-devs

A21-devs commented Dec 1, 2026

Copy link
Copy Markdown
Owner Author

Fixed the Hardware tab in 1708651: VmDetail now locks it on status !== 'off' || work !== null, and canSave (Save button and Ctrl+S) uses the same flag. The notice above the form says "Saving profile. Wait for it to finish." instead of "Power off the VM", which would have been wrong for a VM that is already off. Reran typecheck, npm test (139 passed) and build.

Left the profileWork() ordering as is, as noted.

A disk-only profile save, or a launch rolling the disk back, runs while
the VM is off, so the form, Save, Ctrl+S and Delete stayed enabled and
then failed with busy with a profile. The notice above the form says why
it is locked.

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Checked 1708651 against the earlier comment. locked now covers both cases and feeds the fieldset, Revert, Save, Delete and canSave, so Ctrl+S follows it too. The notice text matches the toolbar tooltip. The port forward check (checkPorts={!locked}) also pauses during a profile operation, which is fine since the form can't be edited then anyway. Nothing else to raise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toolbar: show that a profile save is running and disable what it would refuse

1 participant