Repository navigation
Fix/GitHub integration hanging and jit fetch - #98
Conversation
- Fix terminal hanging bug by adding process.exit(0) after GitHub key addition - Implement just-in-time key fetching for github:username format - Add automatic cache staleness check (24-hour refresh) - Add --refresh-github-keys flag to force key refresh - Improve error handling with detailed troubleshooting messages - Add lastFetched timestamp to GitHub keys for cache management Users can now send directly to github:username without pre-adding keys, and cached keys automatically refresh after 24 hours. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove duplicate 'fetching from GitHub' messages - Keep only essential user-facing logs - Simplify error output for better UX
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issues with GitHub key integration, specifically addressing hanging behavior and implementing just-in-time (JIT) key fetching with staleness checks. The changes introduce automatic key refresh capabilities and improve error handling for GitHub key operations.
Key Changes:
- Added
lastFetchedtimestamp tracking for GitHub keys to implement staleness detection (24-hour cache) - Implemented
--refresh-github-keysCLI flag to force re-fetching of cached keys - Added
process.exit(0)to prevent hanging after successful GitHub key addition
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/index.ts | Added lastFetched field to KeyInfo interface for tracking key fetch time |
| cli/keyManager.ts | Updated GitHubKeyAddInfo interface and key storage to include lastFetched timestamp |
| cli/index.ts | Added --refresh-github-keys option and process.exit(0) to prevent hanging |
| cli/index.js | Compiled JavaScript output with same changes as index.ts |
| cli/githubUtils.ts | Implemented staleness check (24-hour cache) and refresh logic in ensureGitHubKey |
| cli/encryptionUtils.ts | Added refreshGithubKeys parameter and improved error messages for GitHub key fetching |
| console.error(`\nError: Failed to fetch GitHub key for user "${username}"`); | ||
| console.error(`Details: ${error.message}`); | ||
| console.error(`\nPlease verify:`); | ||
| console.error(` 1. The GitHub username is correct`); | ||
| console.error(` 2. The user has a GPG key uploaded to GitHub`); | ||
| console.error(` 3. You have internet connectivity`); | ||
| console.error(`\nTo manually add a GitHub user's key, run:`); | ||
| console.error(` dedpaste keys --github ${username}`); |
There was a problem hiding this comment.
This error messaging logic is duplicated from the existing error handling patterns. Consider extracting this into a shared error formatting utility function to maintain consistency and reduce duplication.
| } | ||
|
|
||
| // Also check if we should refresh an existing GitHub key | ||
| if (friendKey && recipientName.startsWith('github:') && refreshGithubKeys) { |
There was a problem hiding this comment.
The condition recipientName.startsWith('github:') is checked multiple times in this function (lines 62 and 84). Consider extracting this into a helper function like isGitHubKey(recipientName) to improve readability and maintainability.
| // Check if key is stale (older than 24 hours) | ||
| const lastFetched = existingKey.lastFetched ? new Date(existingKey.lastFetched) : null; | ||
| const now = new Date(); | ||
| const maxAge = 24 * 60 * 60 * 1000; // 24 hours in milliseconds |
There was a problem hiding this comment.
The 24-hour cache duration is hardcoded. Consider extracting this as a named constant (e.g., GITHUB_KEY_CACHE_DURATION_MS) at the module level to make it configurable and easier to maintain.
|
Looks good @aarlint! |
Version bump type: patch PR: #98 Title: Fix/GitHub integration hanging and jit fetch
No description provided.