Skip to content

fix: warn and cleanup secrets when resetting encryption key#77

Closed
eyelock wants to merge 1 commit into
mainfrom
fix/encryption-key-reset-secrets-cleanup
Closed

fix: warn and cleanup secrets when resetting encryption key#77
eyelock wants to merge 1 commit into
mainfrom
fix/encryption-key-reset-secrets-cleanup

Conversation

@eyelock
Copy link
Copy Markdown
Owner

@eyelock eyelock commented Jan 19, 2026

Summary

Fixes a bug where resetting the encryption key would leave orphaned secret environment variables in both Global and Terminal settings.

Changes

  • ✅ Added detection of secrets before showing reset confirmation
  • ✅ Enhanced warning dialog showing count of affected secrets (global + terminal)
  • ✅ Automatic cleanup of all secret environment variables when user proceeds
  • ✅ User can cancel to abort with no changes
  • ✅ All tests pass (521 tests, 0 failures)

Test Plan

Manual Testing Required

Setup:

  1. Build and run the debug app
  2. Go to Settings → Environment
  3. Add some test secrets:
    • Global: Add 2-3 secret environment variables
    • Terminal: Edit a terminal card and add 2-3 secret variables

Test Case 1: Reset with secrets present

  1. Navigate to Settings → Environment → Security section
  2. Click "Reset Encryption Key" button
  3. Expected: Dialog shows specific count of secrets that will be removed
    • Example: "This will permanently delete 2 global secrets and 3 terminal secrets (5 total)"
  4. Click "Cancel"
  5. Expected: No changes made, secrets still exist

Test Case 2: Reset with secrets and proceed

  1. Click "Reset Encryption Key" button again
  2. Expected: Same detailed warning
  3. Click "Proceed" (destructive action)
  4. Expected:
    • Encryption key is reset
    • All global secrets removed from Settings → Environment
    • All terminal secrets removed from terminal cards
    • No orphaned secret metadata remains

Test Case 3: Reset with no secrets

  1. Ensure no secrets exist (if you just completed Test Case 2, you're good)
  2. Click "Reset Encryption Key" button
  3. Expected: Standard confirmation message (no mention of secrets)
  4. Click "Proceed"
  5. Expected: Encryption key reset successfully

Screenshots

Please add screenshots of the warning dialog showing secret counts

🤖 Generated with Claude Code

When resetting the encryption key, existing SECRETS in environment
variables become unreadable but were not being cleared, leaving
orphaned secret metadata in both Global and Terminal settings.

This fix adds:
- Detection of secrets before showing reset confirmation
- Enhanced warning dialog that shows count of affected secrets
  (both global and terminal-specific)
- Automatic cleanup of all secret environment variables from
  Global and all Terminal cards when user proceeds with reset
- User can cancel to abort the operation with no changes

The warning message dynamically shows:
- Number of global secrets that will be removed
- Number of terminal secrets that will be removed
- Total count
- Clear explanation that secrets are unrecoverable

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@eyelock eyelock closed this Jan 26, 2026
eyelock pushed a commit that referenced this pull request Jan 26, 2026
Enhances the encryption key reset confirmation dialog to show
exact counts of secrets that will be deleted (global and terminal).

When secrets exist:
- "This will permanently delete 2 global secrets and 3 terminal
  secrets (5 total)..."

When no secrets exist:
- Shows standard confirmation message

Integrates with PR #86's cleanup architecture while adding
improved UX from PR #77.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@eyelock
Copy link
Copy Markdown
Owner Author

eyelock commented Jan 26, 2026

Re-implemented here: #86
Cherry picked extra warning feature out of this branch to here: #87

@eyelock eyelock deleted the fix/encryption-key-reset-secrets-cleanup branch January 26, 2026 08:10
eyelock added a commit that referenced this pull request Jan 26, 2026
* feat(cli): Add separate debug binaries for TermQDebug.app testing

Creates termqclid and termqmcpd binaries that default to using the
debug bundle ID (net.eyelock.termq.app.debug) and debug data directory
(TermQ-Debug). This enables proper testing of TermQDebug.app via CLI
without needing to manually specify --debug flags or having commands
sent to the production app.

Changes:
- Add TERMQ_DEBUG_BUILD compile flag support to CLI and MCP server
- Create termqBundleIdentifier() helper to return appropriate bundle ID
- Build debug binaries with separate build directory to avoid contamination
- Install debug binaries to TermQDebug.app/Contents/Resources/
- Update shouldUseDebugMode() to force debug mode when flag is set

Resolves CLI delete command not working with TermQDebug.app during
Phase 4 testing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* docs: Document debug CLI/MCP binaries in CONTRIBUTING.md

* feat: Show secret counts in encryption key reset warning

Enhances the encryption key reset confirmation dialog to show
exact counts of secrets that will be deleted (global and terminal).

When secrets exist:
- "This will permanently delete 2 global secrets and 3 terminal
  secrets (5 total)..."

When no secrets exist:
- Shows standard confirmation message

Integrates with PR #86's cleanup architecture while adding
improved UX from PR #77.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: David Collie <support@eyelock.net>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

1 participant