Skip to content

fix: preserve env config on capsule remove, add --purge flag#646

Merged
joshuajbouw merged 3 commits intomainfrom
fix/preserve-env-on-remove
Mar 27, 2026
Merged

fix: preserve env config on capsule remove, add --purge flag#646
joshuajbouw merged 3 commits intomainfrom
fix/preserve-env-on-remove

Conversation

@MastaP
Copy link
Copy Markdown
Contributor

@MastaP MastaP commented Mar 27, 2026

Linked Issue

Closes #647

Summary

astrid capsule remove was unconditionally deleting the capsule's env.json (API keys, secrets). This forced users to re-enter credentials on every reinstall cycle.

Changes

  • remove.rs: env.json deletion moved behind --purge flag (default: preserve)
  • remove.rs: remove_file error now propagated with context instead of silently ignored
  • main.rs: added --purge CLI flag to CapsuleCommands::Remove
  • Tests: 3 new tests for purge=false (preserved), purge=true (deleted), and no-op purge
  • Tests: existing tests updated to pass new purge parameter

Before: remove → deletes env.json → install → prompts for config again
After: remove → env.json preserved → install → skips prompting, config reused

Use astrid capsule remove --purge to explicitly delete saved configuration.

Test Plan

  • cargo test -p astrid — 153 tests pass (150 existing + 3 new)
  • Manual: remove without --purge → env.json preserved → reinstall skips prompting
  • Manual: remove --purge → env.json deleted → reinstall prompts for config

Previously, 'astrid capsule remove' always deleted the env.json
containing user configuration (API keys, secrets). This forced users
to re-enter credentials on every reinstall.

Now env.json is preserved by default. The install command already
skips prompting when env.json exists, so reinstall is seamless.

Use 'astrid capsule remove --purge' to explicitly delete saved
configuration along with the capsule.
@MastaP MastaP requested a review from joshuajbouw as a code owner March 27, 2026 16:05
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the capsule removal workflow to improve user experience by preventing unnecessary data loss. By default, environment configurations are now retained during removal, ensuring that users do not need to re-authenticate or re-enter credentials upon reinstalling a capsule. A new purge mechanism has been added to support scenarios where a complete removal of all associated data is required.

Highlights

  • Configuration Persistence: Modified the capsule removal process to preserve 'env.json' files by default, preventing the loss of API keys and environment variables during reinstallation.
  • New CLI Flag: Introduced a new '--purge' flag to the 'capsule remove' command, allowing users to explicitly delete configuration files when a full cleanup is desired.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


The config was lost in the fray, When capsules were taken away. But now with a flag, And no more to drag, The secrets are here to stay.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a --purge flag to the capsule removal command, allowing users to optionally delete environment configurations that were previously removed by default. Feedback was provided regarding the lack of automated tests for this new functionality, as required by the style guide, and the need for explicit error handling when deleting configuration files to prevent silent failures.

MastaP added 2 commits March 27, 2026 17:12
- Handle remove_file Result with context instead of silently ignoring
- Add 3 tests: preserve without purge, delete with purge, no-op purge
@MastaP MastaP added the newcomer-approved Maintainer has approved this new contributor's PR label Mar 27, 2026
Copy link
Copy Markdown
Contributor

@joshuajbouw joshuajbouw left a comment

Choose a reason for hiding this comment

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

LGTM!

@joshuajbouw joshuajbouw merged commit 81b47cd into main Mar 27, 2026
18 of 19 checks passed
@joshuajbouw joshuajbouw deleted the fix/preserve-env-on-remove branch March 27, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

newcomer-approved Maintainer has approved this new contributor's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: capsule remove deletes env config, breaking reinstall

2 participants