Skip to content

feat: IdentityFile pull and arrow key hold-repeat - #66

Merged
involvex merged 2 commits into
mainfrom
cursor/identityfile-pull-arrow-repeat
Nov 26, 2026
Merged

involvex merged 2 commits into
mainfrom
cursor/identityfile-pull-arrow-repeat

Conversation

@involvex

@involvex involvex commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Pull unencrypted OpenSSH IdentityFile PEMs over SFTP during SSH config import and attach them to profiles that do not already have a key (encrypted/missing/already-keyed stay as hints).
  • Hold ← → ↑ ↓ on the shortcut bar to auto-repeat cursor movement (~400ms delay, then ~45ms interval).
  • Docs/changelog/suggestions updated; unit coverage for path resolution, PEM import, pull attach/hint, and repeat eligibility.

Related issues

N/A

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 behavior to change)
  • Documentation update
  • CI / tooling only

Platform tested

  • Android
  • Windows
  • Linux
  • macOS
  • iOS
  • Not applicable (docs/CI only)

Test plan

  • flutter pub get
  • flutter analyze (no errors)
  • flutter test
  • Manual testing on device/emulator

Steps:

  1. Run flutter test test/utils/identity_file_path_test.dart test/utils/pem_key_import_test.dart test/services/ssh_config_import_service_test.dart test/widgets/shortcut_key_repeat_test.dart
  2. Connect to a host with IdentityFile in ~/.ssh/config, import SSH config, confirm key attaches (or hint when passphrase-protected).
  3. Hold ← / → on the shortcut bar and confirm the cursor keeps moving.

Screenshots / recordings

N/A

Checklist

  • My code follows the project style in analysis_options.yaml
  • I did not commit secrets, credentials, or private keys
  • I updated documentation if user-facing behavior changed
  • I added or updated tests where appropriate

Note: test/fixtures/id_ed25519_unencrypted is a disposable OpenSSH test key generated for unit tests, not a real host credential.

Summary by Sourcery

Add SSH config IdentityFile key import and hold-to-repeat arrow shortcuts.

New Features:

  • Pull unencrypted OpenSSH IdentityFile keys during SSH config import and attach them to profiles without existing keys.
  • Auto-repeat arrow-key cursor movement while shortcut-bar arrow buttons are held.

Enhancements:

  • Retain safe hints for missing, encrypted, unreadable, or already-used IdentityFile paths and reuse shared imported keys.

Documentation:

  • Update feature documentation, changelog, project guidance, and suggestions to describe IdentityFile key pulling and arrow-key repeat behavior.

Tests:

  • Add coverage for IdentityFile path resolution, PEM key importing, key attachment and hint handling, shared-key reuse, and repeat eligibility.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4df2ab4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gitguardian

gitguardian Bot commented Nov 26, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
41125516 Triggered OpenSSH Private Key bb55c7f test/fixtures/id_ed25519_unencrypted View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Review the SSH config import outcomes and the merge/pull interface that passes pending IdentityFile paths through to key attachment.

  • lib/services/ssh_config_import_service.dart L1-16, L43-89, L246-362 (+10 small edits)

Review the parser’s IdentityFile contract and documentation alongside the import interface that consumes its parsed paths.

  • lib/utils/ssh_config_parser.dart L28, L56-61

Uses of the API

Review how profile import invokes the SFTP pull, persists keys and profiles, and reports the resulting hints and attached keys.

  • lib/widgets/profile_manager.dart L250-274, L281-284 (+2 small edits)

Implementation

Review how IdentityFile paths are expanded for Windows and POSIX configurations before remote reads.

  • lib/utils/identity_file_path.dart L1-81

Review PEM validation, encrypted-key rejection, algorithm mapping, and safe failure messages used by key import.

  • lib/utils/pem_key_import.dart L1-113

Documentation

Review the user-facing feature and release notes for the new IdentityFile pull and arrow-key repeat behavior.

  • CHANGELOG.md L10-14
  • docs/features.md L12-14

Review the project guidance and roadmap updates that record IdentityFile import behavior and its shipped status.

  • AGENTS.md L155
  • suggestions.md L60-61, L204

Tests

Review generated in-memory test keys and coverage for IdentityFile path resolution, PEM import, key attachment, hints, and shared-key reuse.

  • test/helpers/openssh_test_key.dart L1-81
  • test/services/ssh_config_import_service_test.dart L1-12, L49, L93-380
  • test/utils/identity_file_path_test.dart L1-79
  • test/utils/pem_key_import_test.dart L1-56

Review tests that verify which shortcut actions support repeat and how arrow actions map to terminal keys.

  • test/widgets/shortcut_key_repeat_test.dart L1-32

Other changes

Files not grouped.

  • lib/widgets/keyboard_shortcut_bar.dart L16-114, L286-347, L358-361 (+4 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@involvex
involvex marked this pull request as ready for review November 26, 2026 00:51
@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Sorry @involvex, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 12 hours by commenting @sourcery-ai review. Upgrade to get a review now.

Comment thread test/fixtures/id_ed25519_unencrypted Outdated
@@ -0,0 +1,7 @@
-----BEGIN OPENSSH PRIVATE KEY-----

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CRITICAL: Test fixture contains a real OpenSSH private key

The file test/fixtures/id_ed25519_unencrypted contains an actual OpenSSH private key (BEGIN OPENSSH PRIVATE KEY). GitGuardian has already flagged this as a secret. Even though the PR description states this is a "disposable" test key, committing any private key material to a repository is a security anti-pattern. This key should be replaced with a clearly fake/mock key that is obviously not real (e.g., using a placeholder like -----BEGIN OPENSSH PRIVATE KEY-----\nMOCK_KEY_DATA\n-----END OPENSSH PRIVATE KEY-----) or generated dynamically in the test setup.

candidate,
maxBytes: kIdentityFileMaxBytes,
);
pemText = utf8.decode(bytes, allowMalformed: false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Misleading error message on UTF-8 decode failure

utf8.decode(bytes, allowMalformed: false) throws a FormatException if the bytes are not valid UTF-8. The catch block treats all exceptions as "not found or unreadable", which is misleading for decoding errors (e.g., corrupted file, binary data, wrong encoding). Consider catching FileSystemException/StateError separately from FormatException to provide accurate error messages.

);
pemText = utf8.decode(bytes, allowMalformed: false);
} catch (_) {
lastError = 'not found or unreadable at $candidate';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Broad exception catching masks real errors

The catch (_) block catches all exceptions (including SocketException, PermissionException, TimeoutException, etc.) and converts them to a generic "not found or unreadable" message. This makes debugging difficult. Consider catching specific exception types or at least logging the original exception for debugging.

if (SSHKeyPair.isEncryptedPem(pem)) {
return const PemKeyImportResult.failed(PemKeyImportFailure.encrypted);
}
} catch (_) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Silent catch on encryption probe may mask parse errors

SSHKeyPair.isEncryptedPem(pem) throwing an exception could indicate a malformed PEM, not just an encrypted one. Silently continuing to fromPem may cause a subsequent parse failure with a less clear error message. Consider logging the exception or handling specific failure modes.

if (pulled.keys.isNotEmpty) {
final existingKeys = await ConfigService.getSSHKeys();
for (final key in pulled.keys) {
await SecureStorageService.writePrivateKey(key.id, key.privateKey);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: No error handling for secure storage and config save

If SecureStorageService.writePrivateKey or ConfigService.saveSSHKeys throws, the imported keys are not persisted but the profile update continues. This leaves profiles referencing key IDs that don't exist in secure storage/config. Wrap these in try-catch and roll back or report the failure to the user.

homes.add(homeFromConfig);
}
if (isWindowsConfig) {
final winHome = RemotePath.normalize('C:/Users/$username');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Windows home directory fallback may be incorrect

The fallback C:/Users/$username assumes the Windows profile folder matches the SSH username and is on C:. This may fail for users with renamed profiles, different drive letters, or domain-joined machines (e.g., C:/Users/username.DOMAIN). The homeFromConfig derivation (line 21) is more reliable when available.

final rawPath = entry.value;

final existingRef = profile.privateKey?.trim();
if (existingRef != null && existingRef.isNotEmpty) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Existing key check doesn't account for PEM strings in privateKey field

profile.privateKey?.trim() is checked for emptiness, but privateKey can contain a PEM string (as seen in profile_manager.dart:382 with looksLikePemPrivateKey check). A profile with a PEM string in privateKey would incorrectly be treated as having no key, potentially causing duplicate key imports. Consider using the same looksLikePemPrivateKey check or a dedicated hasKey helper.

Co-authored-by: Cursor <cursoragent@cursor.com>
if (!_repeatActive) {
return;
}
fire();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Hold-to-repeat doesn't verify connection on each timer fire

The periodic timer callback calls fire() without re-checking isConnected. If the SSH session disconnects while the user holds an arrow key, keys continue to be sent to a disconnected session. Consider checking ssh.activeSession?.isConnected inside the timer callback or the fire() function.

case 'ssh-ed25519':
return SSHKeyType.ed25519;
case 'ssh-rsa':
return SSHKeyType.rsa2048;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: All ssh-rsa keys mapped to rsa2048 regardless of actual size

The SSH algorithm name ssh-rsa doesn't encode key size (could be 2048, 3072, 4096 bits). Consider detecting the key size from the parsed key pair or using a generic RSA type if the enum supports it.

@involvex
involvex merged commit 97fc487 into main Nov 26, 2026
7 of 8 checks passed
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