Skip to content

feat: implement simple workspace state in language server#88

Merged
9romise merged 4 commits intomainfrom
workspace
Mar 23, 2026
Merged

feat: implement simple workspace state in language server#88
9romise merged 4 commits intomainfrom
workspace

Conversation

@9romise
Copy link
Member

@9romise 9romise commented Mar 23, 2026

No description provided.

@9romise 9romise marked this pull request as ready for review March 23, 2026 13:38
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

This pull request implements a workspace state management system for the language server's dependency resolution capabilities. It introduces a WorkspaceState class that maintains per-folder contexts and caches dependency information whilst listening for workspace and file change events. A new protocol method GET_PACKAGE_MANAGER_METHOD enables the server to query the client for detected package managers (npm, pnpm, or yarn). The language service plugin initialisation is updated to accept and utilise workspace state. Supporting configuration and build tooling are adjusted for the new workspace module and shared protocol definitions.

Possibly related PRs

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is completely empty with no text provided by the author. Add a meaningful pull request description explaining the changes, objectives, and rationale for implementing workspace state management in the language server.

✏️ 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 workspace

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.

Copy link
Contributor

@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)
packages/language-server/src/workspace.ts (2)

35-44: Function signature doesn't match interface contract.

The WorkspaceAdapter interface expects detectPackageManager(rootPath: string), but this implementation omits the rootPath parameter entirely. Although the closure captures folderUri and the behaviour is correct, the missing parameter may cause confusion and could break if the interface evolves.

♻️ Suggested fix to match interface signature
-    async detectPackageManager(): Promise<'npm' | 'pnpm' | 'yarn'> {
+    async detectPackageManager(_rootPath: string): Promise<'npm' | 'pnpm' | 'yarn'> {

99-107: Consider error handling for WorkspaceContext.create failures.

If WorkspaceContext.create throws (e.g., due to filesystem errors or malformed manifest files), the error will propagate uncaught. Since this is a cached function, a single failure could leave the cache in an inconsistent state or cause repeated failures.

🛡️ Suggested defensive approach
     async (folderUri) => {
       this.#connection.console.info(`[workspace-context] built ${folderUri.path}`)
       this.#cachedFolderPaths.add(folderUri.path)

-      return await WorkspaceContext.create(
-        folderUri.path,
-        createLanguageServerAdapter(folderUri, this.#connection),
-      )
+      try {
+        return await WorkspaceContext.create(
+          folderUri.path,
+          createLanguageServerAdapter(folderUri, this.#connection),
+        )
+      }
+      catch (error) {
+        this.#connection.console.error(`[workspace-context] failed to create context for ${folderUri.path}: ${error}`)
+        return undefined
+      }
     },

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 06ef8ea8-b6b1-41a6-8d6c-6518034d991a

📥 Commits

Reviewing files that changed from the base of the PR and between 1a6abe8 and f480c02.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • extensions/vscode/src/client.ts
  • packages/language-server/package.json
  • packages/language-server/src/server.ts
  • packages/language-server/src/workspace.ts
  • packages/language-server/tsconfig.json
  • packages/language-server/tsdown.config.ts
  • packages/language-service/package.json
  • packages/language-service/src/config.ts
  • packages/language-service/src/index.ts
  • packages/language-service/src/types.ts
  • packages/language-service/tsconfig.json
  • packages/language-service/tsdown.config.ts
  • pnpm-workspace.yaml
  • shared/protocol.ts
  • shared/types.ts
💤 Files with no reviewable changes (1)
  • shared/types.ts

@9romise 9romise added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit fda0c92 Mar 23, 2026
9 of 11 checks passed
@9romise 9romise deleted the workspace branch March 23, 2026 13:51
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