Skip to content

feat: add restart language server command#25

Merged
Shinigami92 merged 2 commits intomainfrom
feat-restart-language-server
Apr 5, 2026
Merged

feat: add restart language server command#25
Shinigami92 merged 2 commits intomainfrom
feat-restart-language-server

Conversation

@Shinigami92
Copy link
Copy Markdown
Member

@Shinigami92 Shinigami92 commented Apr 5, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a "Restart Language Server" command accessible from the command palette
    • Extended syntax highlighting support to Vue Single File Components' template blocks
    • Language server now provides formatting capabilities in addition to diagnostics and hover features
  • Documentation

    • Updated feature documentation to reflect expanded syntax highlighting and language server capabilities

@Shinigami92 Shinigami92 self-assigned this Apr 5, 2026
@Shinigami92 Shinigami92 added the c: feature Request for new feature label Apr 5, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

Warning

Rate limit exceeded

@Shinigami92 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 13 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 18 minutes and 13 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a92cdef9-9aeb-4947-9e13-062e6a13d2f6

📥 Commits

Reviewing files that changed from the base of the PR and between 7cf572f and f644d83.

📒 Files selected for processing (2)
  • tests/__mocks__/vscode-languageclient-node.ts
  • tests/extension.test.ts
📝 Walkthrough

Walkthrough

The pull request adds a restart command for the HSML language server to the VS Code extension, refactors the client startup logic into a reusable helper, updates the README to clarify syntax highlighting and language-server capabilities, and introduces corresponding test mocks and test cases.

Changes

Cohort / File(s) Summary
Documentation
README.md
Extended features list to cover Vue SFC <template lang="hsml"> blocks and updated language-server capabilities to include formatting alongside diagnostics and hover.
Extension Implementation
client/src/extension.ts, package.json
Extracted client startup into startClient() helper function, changed client initialization to async with await, registered hsml.restartLanguageServer command that restarts or starts the client, and added command contribution to package.json manifest.
Test Infrastructure
tests/__mocks__/vscode-languageclient-node.ts, tests/__mocks__/vscode.ts
Added mockRestart function to LanguageClient mock and implemented commands.registerCommand mock returning a disposable object.
Test Coverage
tests/extension.test.ts
Added test case verifying command registration during activation and a test suite for the restart command that validates the callback invokes the mocked restart method.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A restart command hops so true,
Async helpers born anew,
Mocks and tests in perfect view,
Language servers restart too! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add restart language server command' directly and clearly summarizes the main change: adding a new restart language server command to the extension.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-restart-language-server

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
client/src/extension.ts 80.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Shinigami92 Shinigami92 force-pushed the feat-restart-language-server branch from 3a844c7 to 7cf572f Compare April 5, 2026 14:09
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/extension.test.ts (1)

44-55: Merge this into the existing describe('activate', ...) block.

There's already a describe('activate', ...) block starting at line 15. This creates a duplicate test suite with the same name, which can cause confusion in test output and violates DRY.

Proposed fix

Move the test case into the existing describe('activate', ...) block at lines 15-42:

 describe('activate', () => {
   // ... existing tests ...
+
+  it('should register restart command', async () => {
+    const { commands } = await import('vscode');
+    const { activate } = await import('../client/src/extension.js');
+    await activate(mockContext);
+
+    expect(commands.registerCommand).toHaveBeenCalledWith(
+      'hsml.restartLanguageServer',
+      expect.any(Function),
+    );
+  });
 });
-
-describe('activate', () => {
-  it('should register restart command', async () => {
-    const { commands } = await import('vscode');
-    const { activate } = await import('../client/src/extension.js');
-    await activate(mockContext);
-
-    expect(commands.registerCommand).toHaveBeenCalledWith(
-      'hsml.restartLanguageServer',
-      expect.any(Function),
-    );
-  });
-});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/extension.test.ts` around lines 44 - 55, This creates a duplicate
describe('activate', ...) suite; move the it('should register restart command',
async () => { ... }) test into the existing describe('activate', ...) block (the
one that already wraps tests starting around the earlier lines) so there's only
one describe for activate; keep the body that imports activate and vscode
commands, calls await activate(mockContext), and asserts
commands.registerCommand was called with 'hsml.restartLanguageServer' and
expect.any(Function) (referencing activate, mockContext, and the
commands.registerCommand assertion to locate the test).
tests/__mocks__/vscode-languageclient-node.ts (1)

3-5: Consider making mockStart return a Promise for consistency.

The new mockRestart correctly returns Promise.resolve(), matching the LanguageClient API. However, mockStart returns undefined, which is inconsistent since client/src/extension.ts now uses await client.start(). While await undefined works in JavaScript, aligning the mock with the actual API signature improves test fidelity.

Proposed fix
-export const mockStart = vi.fn();
+export const mockStart = vi.fn(() => Promise.resolve());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/__mocks__/vscode-languageclient-node.ts` around lines 3 - 5, mockStart
currently returns undefined while mockStop and mockRestart return promises;
update the mock so mockStart returns a resolved Promise to match the
LanguageClient API and the usage in client/src/extension.ts (where
client.start() is awaited). Locate mockStart in the
tests/__mocks__/vscode-languageclient-node.ts mock file and change its factory
to return a Promise.resolve() (consistent with mockStop/mockRestart) so tests
reflect the real async signature.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/extension.test.ts`:
- Around line 57-73: Add a test for the "no client" branch by resetting module
state with vi.resetModules() so the module-level client is undefined, then mock
resolveServerPath (e.g. resolveServerPath.mockResolvedValue('hsml')), import the
commands and the mocked languageclient (mockStart) and the extension module,
retrieve the registered 'hsml.restartLanguageServer' callback like the existing
test, invoke it, and assert that startClient (mockStart) was called instead of
client.restart; use the same pattern of looking up commands.registerCommand mock
calls to get the callback so the test exercises startClient when client is
absent.

---

Nitpick comments:
In `@tests/__mocks__/vscode-languageclient-node.ts`:
- Around line 3-5: mockStart currently returns undefined while mockStop and
mockRestart return promises; update the mock so mockStart returns a resolved
Promise to match the LanguageClient API and the usage in client/src/extension.ts
(where client.start() is awaited). Locate mockStart in the
tests/__mocks__/vscode-languageclient-node.ts mock file and change its factory
to return a Promise.resolve() (consistent with mockStop/mockRestart) so tests
reflect the real async signature.

In `@tests/extension.test.ts`:
- Around line 44-55: This creates a duplicate describe('activate', ...) suite;
move the it('should register restart command', async () => { ... }) test into
the existing describe('activate', ...) block (the one that already wraps tests
starting around the earlier lines) so there's only one describe for activate;
keep the body that imports activate and vscode commands, calls await
activate(mockContext), and asserts commands.registerCommand was called with
'hsml.restartLanguageServer' and expect.any(Function) (referencing activate,
mockContext, and the commands.registerCommand assertion to locate the test).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eed4c710-4c1c-43cb-adc7-e9cafe8b91c2

📥 Commits

Reviewing files that changed from the base of the PR and between 18abce0 and 7cf572f.

📒 Files selected for processing (6)
  • README.md
  • client/src/extension.ts
  • package.json
  • tests/__mocks__/vscode-languageclient-node.ts
  • tests/__mocks__/vscode.ts
  • tests/extension.test.ts

@Shinigami92 Shinigami92 added this pull request to the merge queue Apr 5, 2026
Merged via the queue into main with commit 90120f4 Apr 5, 2026
7 checks passed
@Shinigami92 Shinigami92 deleted the feat-restart-language-server branch April 5, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: feature Request for new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant