refactor(ui): centralize lifecycle action gating and labels - #6
Open
thetimblank wants to merge 1 commit into
Open
refactor(ui): centralize lifecycle action gating and labels#6thetimblank wants to merge 1 commit into
thetimblank wants to merge 1 commit into
Conversation
The sleep gate (online && !proxy) and the sleeping-state labels were copy-pasted across the server card, network node menu and server overview panel, which had already let the overview panel diverge (broader isRunning gate for sleep, !isOffline for force-kill, no stop affordance while sleeping). Add canStartStatus/canStopStatus/canRestartStatus/canForceKillStatus/ canSleepServer plus start/stop/forceKill label helpers next to isStoppedStatus in data/servers.tsx, and route all four lifecycle surfaces (including the dashboard tile) through them. Unit-tests the gates and labels. Closes #4 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4.
Problem
The sleep gate (
status === 'online' && !isProxyProvider(...)) and the sleeping-state labels (Shutdown/Force Kill,Awake,Stop sleeping) were copy-pasted acrossserver-card.tsx,ServerNodeMenu.tsxandserver-overview-panel.tsx(and the dashboard tile repeated the start/stop gates too). That duplication had already let the overview panel drift.Change
Added lifecycle helpers next to
isStoppedStatus/isRunningStatusin src/data/servers.tsx:canStartStatus,canStopStatus,canRestartStatus,canForceKillStatus,canSleepServer(server)startActionLabel,stopActionLabel,forceKillActionLabelAll four lifecycle surfaces now render from these — server card, dashboard tile, network node menu, server overview panel.
Behavior differences this collapses (all in the overview panel, which was the outlier)
crashedserver (it was gated on!isOffline); matches the card and node menu.crashednow offers Serve (previously onlyofflinedid).Also unified the node menu's wording with the rest of the app:
Start→Serve,Force kill→Force Kill.Testing
src/data/server-lifecycle-actions.test.tscovers every gate across all six statuses plus the proxy case and the labels.npm run test:run— 148 tests pass;npm run buildclean.🤖 Generated with Claude Code