Skip to content

Add confirm dialog when deleting keys#54

Merged
karl-sjogren merged 1 commit into
developfrom
feature/confirm-delete
Dec 30, 2025
Merged

Add confirm dialog when deleting keys#54
karl-sjogren merged 1 commit into
developfrom
feature/confirm-delete

Conversation

@karl-sjogren
Copy link
Copy Markdown
Owner

Fixes #41

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.76%. Comparing base (2ec8cab) to head (9c72c45).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
src/Karls.BetterSecretsTool/Tool.cs 57.14% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #54      +/-   ##
===========================================
- Coverage    68.92%   68.76%   -0.17%     
===========================================
  Files           10       10              
  Lines          502      509       +7     
  Branches        81       83       +2     
===========================================
+ Hits           346      350       +4     
- Misses         112      113       +1     
- Partials        44       46       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a confirmation dialog when deleting secrets to prevent accidental deletions. The confirmation asks users to explicitly confirm deletion by typing "y" or "yes" before proceeding with the removal of a secret.

  • Added confirmation prompt in the RemoveSecret method that requires user input before deletion
  • Updated all existing tests to include the confirmation step by simulating "y" input
  • Properly escapes the key name in the confirmation message for safe display

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Karls.BetterSecretsTool/Tool.cs Implements the confirmation dialog with case-insensitive y/yes validation before deleting secrets
test/Karls.BetterSecretsTool.Tests/ConsoleUIIntegrationTests.cs Updates two test cases to simulate confirmation input ("y") for secret deletion flows
test/Karls.BetterSecretsTool.Tests/EndToEndIntegrationTests.cs Updates two end-to-end test cases to include confirmation step when testing secret deletion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +219 to +220
new TextPrompt<string>($"[grey]Are you sure you want to delete [red]{Markup.Escape(key)}[/]? ([green]y[/]/[red]n[/]):[/]")
.AllowEmpty());
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The confirmation logic treats an empty response (just pressing Enter) as a cancellation, which may not be intuitive for users. When users press Enter without typing anything, it's unclear whether they meant to confirm or cancel the deletion. Consider either:

  1. Requiring an explicit response (remove AllowEmpty() and provide a default value), or
  2. Treating empty responses as "no" explicitly by checking for empty string in the confirmation logic, or
  3. Using a Yes/No selection prompt instead of a text prompt for clearer user intent.
Suggested change
new TextPrompt<string>($"[grey]Are you sure you want to delete [red]{Markup.Escape(key)}[/]? ([green]y[/]/[red]n[/]):[/]")
.AllowEmpty());
new TextPrompt<string>($"[grey]Are you sure you want to delete [red]{Markup.Escape(key)}[/]? ([green]y[/]/[red]n[/]):[/]"));

Copilot uses AI. Check for mistakes.
// Simulate: D (delete secret), select the key (Enter to select first), confirm (y), then Q (quit)
console.Input.PushText("D");
console.Input.PushKey(ConsoleKey.Enter); // Select first (only) item
console.Input.PushTextWithEnter("y"); // Confirm deletion
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

There is no test coverage for the cancellation scenario when a user declines to delete a secret (e.g., by entering "n" or "no"). Add a test case that verifies the secret is not deleted when the user cancels the deletion confirmation.

Copilot uses AI. Check for mistakes.
// Simulate: D (delete secret), select the key (Enter to select first), confirm (y), then Q (quit)
console.Input.PushText("D");
console.Input.PushKey(ConsoleKey.Enter); // Select first (only) item
console.Input.PushTextWithEnter("y"); // Confirm deletion
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

There is no test coverage for the cancellation scenario when a user declines to delete a secret (e.g., by entering "n" or "no"). Add a test case that verifies the secret is not deleted when the user cancels the deletion confirmation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't cancel from list when selecting items to delete

2 participants