Skip to content

[issues/619] Migrate to combined ExtensionError type#658

Merged
couimet merged 1 commit into
mainfrom
issues/619
Jun 16, 2026
Merged

[issues/619] Migrate to combined ExtensionError type#658
couimet merged 1 commit into
mainfrom
issues/619

Conversation

@couimet

@couimet couimet commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

The extension naturally produces two error shapes: RangeLinkError from rangelink-core-ts and RangeLinkExtensionError from the extension itself. Define a combined ExtensionError = RangeLinkError | RangeLinkExtensionError union, widen ExtensionResult<T> to carry it, and let boundary functions pass core errors through instead of wrapping them. No behavior change at callers.

Changes

  • Add ExtensionError union type in src/types/ExtensionError.ts.
  • Widen ExtensionResult<T> and ExtensionResult.err() to accept ExtensionError rather than only RangeLinkExtensionError. Existing call sites are source-compatible because RangeLinkExtensionError is assignable to the union.
  • Simplify generateLinkFromSelections: pass formatLink errors through with ExtensionResult.err(result.error) instead of wrapping. Drop the now-unused GENERATE_LINK_FORMAT_FAILED code from RangeLinkExtensionErrorCodes.
  • Fix two mock setups (SendRouter.test.ts, terminalInsertFactory.test.ts) that were still using RangeLinkError to simulate ClipboardService, which moved to RangeLinkExtensionError in Extract ContextKeyService from PasteDestinationManager #609. Update the two formatLink error tests in generateLinkFromSelections.test.ts to assert on the pass-through core error.
  • Side-quest cleanup in the same diff: add spyOnFormatLink and spyOnFindLinksInText helpers, then remove the import * as rangelinkCore from 'rangelink-core-ts' namespace imports from three test files that only used them to drive jest.spyOn. This isolates the namespace-import pattern to the helper layer, matching the existing spyOn* convention.

Key Discoveries

  • RangeLinkExtensionErrorCodes is already a strict superset of RangeLinkErrorCodes. The combined union does not need any code-table changes.
  • The project already had a helper convention (spyOnToInputSelection.ts, spyOnFormatMessage.ts, etc.) for the import * as + jest.spyOn pattern. Following it was strictly better than the jest.mock() alternative that was first considered.

Test Plan

  • All existing Jest tests pass (118 suites, 2060 tests, coverage 98.26% / 95.84% / 95.24% / 98.28%).
  • Prettier and ESLint clean across the workspace.
  • test:release:automated will be exercised by CI.

Related

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@couimet, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 minutes and 57 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bdd94fbe-907b-41a5-8871-72afd3d0c3df

📥 Commits

Reviewing files that changed from the base of the PR and between 2693b66 and 258e63b.

📒 Files selected for processing (19)
  • packages/rangelink-vscode-extension/src/__tests__/commands/BindToTerminalCommand.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/destinations/ComposablePasteDestination.integration.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/destinations/capabilities/TerminalFocusCapability.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/destinations/capabilities/insertFactories/terminalInsertFactory.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/helpers/index.ts
  • packages/rangelink-vscode-extension/src/__tests__/helpers/spyOnFindLinksInText.ts
  • packages/rangelink-vscode-extension/src/__tests__/helpers/spyOnFormatLink.ts
  • packages/rangelink-vscode-extension/src/__tests__/navigation/RangeLinkDocumentProvider.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/navigation/RangeLinkTerminalProvider.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/services/SendRouter.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/services/TerminalPasteService.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/services/TerminalSelectionService.test.ts
  • packages/rangelink-vscode-extension/src/__tests__/utils/generateLinkFromSelections.test.ts
  • packages/rangelink-vscode-extension/src/config/validation.ts
  • packages/rangelink-vscode-extension/src/errors/RangeLinkExtensionErrorCodes.ts
  • packages/rangelink-vscode-extension/src/types/ExtensionError.ts
  • packages/rangelink-vscode-extension/src/types/ExtensionResult.ts
  • packages/rangelink-vscode-extension/src/types/index.ts
  • packages/rangelink-vscode-extension/src/utils/generateLinkFromSelections.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issues/619

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

⚠️ QA Coverage Gap Detected

The PR introduces changes to the command behavior by modifying how binding results are handled, specifically changing from 'Result' to 'ExtensionResult'. This affects the output of the binding commands, which is user-visible.

Suggested test cases:

  • Binding to Terminal: Verify successful binding to a terminal returns the correct destination information (automatable)
  • Binding to Terminal: Verify failed binding to a terminal returns the correct error information (automatable)

Generated by QA Gap Check (GPT-4o-mini via GitHub Models)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

The extension naturally produces two error shapes: `RangeLinkError` from `rangelink-core-ts` and `RangeLinkExtensionError` from the extension itself. Define a combined `ExtensionError = RangeLinkError | RangeLinkExtensionError` union, widen `ExtensionResult<T>` to carry it, and let boundary functions pass core errors through instead of wrapping them. No behavior change at callers.

- Add `ExtensionError` union type in `src/types/ExtensionError.ts`.
- Widen `ExtensionResult<T>` and `ExtensionResult.err()` to accept `ExtensionError` rather than only `RangeLinkExtensionError`. Existing call sites are source-compatible because `RangeLinkExtensionError` is assignable to the union.
- Simplify `generateLinkFromSelections`: pass `formatLink` errors through with `ExtensionResult.err(result.error)` instead of wrapping. Drop the now-unused `GENERATE_LINK_FORMAT_FAILED` code from `RangeLinkExtensionErrorCodes`.
- Fix two mock setups (`SendRouter.test.ts`, `terminalInsertFactory.test.ts`) that were still using `RangeLinkError` to simulate `ClipboardService`, which moved to `RangeLinkExtensionError` in #609. Update the two `formatLink` error tests in `generateLinkFromSelections.test.ts` to assert on the pass-through core error.
- Side-quest cleanup in the same diff: add `spyOnFormatLink` and `spyOnFindLinksInText` helpers, then remove the `import * as rangelinkCore from 'rangelink-core-ts'` namespace imports from three test files that only used them to drive `jest.spyOn`. This isolates the namespace-import pattern to the helper layer, matching the existing `spyOn*` convention.

- `RangeLinkExtensionErrorCodes` is already a strict superset of `RangeLinkErrorCodes`. The combined union does not need any code-table changes.
- The project already had a helper convention (`spyOnToInputSelection.ts`, `spyOnFormatMessage.ts`, etc.) for the `import * as` + `jest.spyOn` pattern. Following it was strictly better than the `jest.mock()` alternative that was first considered.

- [x] All existing Jest tests pass (118 suites, 2060 tests, coverage 98.26% / 95.84% / 95.24% / 98.28%).
- [x] Prettier and ESLint clean across the workspace.
- [ ] `test:release:automated` will be exercised by CI.

- Closes #619
@github-actions

Copy link
Copy Markdown

✅ CI / Integration Tests (with overrides) — run summary

Duration: 0m 57s

QA TC IDs: 2 exercised across 0 features

Report: View run & artifacts

Reproduce locally: ./scripts/run-integration-tests.sh --label needs-override --exclude-label cursor --exclude-assisted

Feature breakdown
Feature TCs IDs

@github-actions

Copy link
Copy Markdown

✅ CI / Integration Tests (automated) — run summary

Duration: 11m 7s

QA TC IDs: 163 exercised across 0 features

Report: View run & artifacts

Reproduce locally: ./scripts/run-integration-tests.sh --exclude-label requires-extensions --exclude-label cursor --automated

Feature breakdown
Feature TCs IDs

@github-actions

Copy link
Copy Markdown

✅ CI / Integration Tests (with extensions) — run summary

Duration: 12m 59s

Unit tests: Ran in separate Test & Validate job

QA TC IDs: 195 exercised across 0 features

Report: View run & artifacts

Reproduce locally: ./scripts/run-integration-tests.sh --exclude-label cursor --exclude-label needs-override --exclude-assisted

Feature breakdown
Feature TCs IDs

@couimet couimet merged commit 0327b09 into main Jun 16, 2026
7 checks passed
@couimet couimet deleted the issues/619 branch June 16, 2026 21:29
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.

Migrate remaining RangeLinkError usages to RangeLinkExtensionError

1 participant