Skip to content

Use getLegacyKeyTitle for backward-compatible key lookup - #20

Merged
shawntz merged 8 commits into
feat/add-headless-launchagentfrom
copilot/sub-pr-7-one-more-time
Jan 11, 2026
Merged

Use getLegacyKeyTitle for backward-compatible key lookup#20
shawntz merged 8 commits into
feat/add-headless-launchagentfrom
copilot/sub-pr-7-one-more-time

Conversation

Copilot AI commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

Description

The getLegacyKeyTitle function was defined but never called, preventing cleanup of SSH keys created with the old format (cassh-{connID}) when users upgrade to the new format (cassh-{connID}@{hostname}).

Changes:

  • findGitHubKeyIDByTitle: Extracts connection ID from new-format titles, generates legacy title via getLegacyKeyTitle(), and checks both formats in a single pass with exact matching
  • rotatePersonalGitHubSSH: Adds fallback lookup when GitHubKeyID is unset (migration scenario), attempts to find and delete keys using both title formats before generating new key
// Now handles both formats in one iteration
if keyTitle == title {
    return keyID  // New format: cassh-personal-123@MacBook-Pro
}
if legacyTitle != "" && keyTitle == legacyTitle {
    return keyID  // Legacy format: cassh-personal-123
}

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Related Issues

Addresses feedback from #7 (comment r2608119934)

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing

Test environment:

  • OS: macOS (darwin-specific code)
  • Go version: 1.24.11

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Security Considerations

  • This PR does not introduce any security concerns
  • I have considered the security implications and addressed them

CodeQL analysis: 0 alerts

Screenshots (if applicable)

N/A


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits December 13, 2025 08:22
Co-authored-by: shawntz <5200266+shawntz@users.noreply.github.com>
Co-authored-by: shawntz <5200266+shawntz@users.noreply.github.com>
Co-authored-by: shawntz <5200266+shawntz@users.noreply.github.com>
Co-authored-by: shawntz <5200266+shawntz@users.noreply.github.com>
Co-authored-by: shawntz <5200266+shawntz@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP on background key rotation feedback implementation Use getLegacyKeyTitle for backward-compatible key lookup Dec 13, 2025
Copilot AI requested a review from shawntz December 13, 2025 08:32
@shawntz
shawntz marked this pull request as ready for review December 19, 2025 09:54
Copilot AI review requested due to automatic review settings December 19, 2025 09:54

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes a bug where the getLegacyKeyTitle function was defined but never used, preventing cleanup of SSH keys created with the legacy format (cassh-{connID}) when users upgrade to the new format (cassh-{connID}@{hostname}). The fix enables backward-compatible key lookup to handle migration scenarios smoothly.

Key Changes:

  • Enhanced findGitHubKeyIDByTitle to extract connection IDs from new-format titles and check both new and legacy title formats with exact matching
  • Added fallback lookup in rotatePersonalGitHubSSH for migration scenarios where GitHubKeyID is unset, enabling discovery and cleanup of keys using either title format

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

Comment thread cmd/cassh-menubar/main.go Outdated
@shawntz

shawntz commented Jan 1, 2026

Copy link
Copy Markdown
Owner

fizzy

shawntz and others added 2 commits January 11, 2026 00:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@shawntz
shawntz merged commit e67b4c0 into feat/add-headless-launchagent Jan 11, 2026
@shawntz
shawntz deleted the copilot/sub-pr-7-one-more-time branch January 11, 2026 08:59
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.

3 participants