Skip to content

Fix/GitHub integration hanging and jit fetch - #98

Merged
anoncam merged 2 commits into
mainfrom
fix/github-integration-hanging-and-jit-fetch
Oct 22, 2025
Merged

anoncam merged 2 commits into
mainfrom
fix/github-integration-hanging-and-jit-fetch

Conversation

@aarlint

@aarlint aarlint commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

aarlint and others added 2 commits October 22, 2025 13:47
- 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
@anoncam
anoncam requested a review from Copilot October 22, 2025 19:57

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 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 lastFetched timestamp tracking for GitHub keys to implement staleness detection (24-hour cache)
  • Implemented --refresh-github-keys CLI 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

Comment thread cli/encryptionUtils.ts
Comment on lines +72 to +79
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}`);

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread cli/encryptionUtils.ts
}

// Also check if we should refresh an existing GitHub key
if (friendKey && recipientName.startsWith('github:') && refreshGithubKeys) {

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread cli/githubUtils.ts
// 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

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@anoncam

anoncam commented Oct 22, 2025

Copy link
Copy Markdown
Owner

Looks good @aarlint!

@anoncam
anoncam merged commit 3727f45 into main Oct 22, 2025
3 checks passed
github-actions Bot added a commit that referenced this pull request Oct 22, 2025
Version bump type: patch
PR: #98
Title: Fix/GitHub integration hanging and jit fetch
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