fix(setup): detect existing statusline, create backup, and prompt before overwriting#546
Open
tenondecrpc wants to merge 1 commit into
Open
Conversation
…ore overwriting Before this change, /claude-hud:setup unconditionally overwrote the statusLine key in settings.json without warning, backup, or recovery. If a user had another statusline plugin (claude-pace, cc-statusline, etc.) or a custom script configured, it was silently destroyed. Add Step 2.5 between Test Command and Apply Configuration: - 2.5.1: Read existing statusLine.command from settings.json - 2.5.2: Classify the existing statusline (claude-hud reinstall, known project, statusline script, or custom) to choose the right prompt tone - 2.5.3: Always create a timestamped backup of settings.json before any modification (also protects against corruption like jarrodwatts#315) - 2.5.4: If a non-claude-hud statusline exists, prompt the user with Replace / Keep / Cancel options via AskUserQuestion - 2.5.5: Save the previous command to ~/.claude/plugins/claude-hud/previous-statusline.txt for easy restoration Step 3 now references the backup and notes that setup exits early if the user chose Keep or Cancel. A restoration section is added after Step 3 with instructions to recover from the backup. Closes jarrodwatts#545
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.
Problem
/claude-hud:setupunconditionally overwrites thestatusLinekey insettings.jsonwithout detecting, warning about, or backing up any existing statusline configuration. If a user has another plugin (claude-pace, cc-statusline, etc.) or a custom script configured, it is silently destroyed with no recovery path.This also means that if setup writes invalid JSON (as happened in #315), there is no backup to restore from.
Fix
Adds Step 2.5 between Test Command and Apply Configuration:
statusLine.commandfromsettings.json(bash + PowerShell)claude-hud(reinstall), known project (claude-pace,cc-statusline), statusline script, or customsettings.json.bak.YYYYMMDD-HHMMSS) before any modification~/.claude/plugins/claude-hud/previous-statusline.txtfor easy restorationStep 3 now references the backup and notes that setup exits early if the user chose Keep or Cancel. A restoration section is added after Step 3.
Test plan
settings.json.bak.*backup is created before any writeprevious-statusline.txtis saved when replacing another statuslinesettings.json