Skip to content

fix(language-server): recover project for external templates in solution-style workspaces#69769

Open
ShayanAbbas1 wants to merge 1 commit into
angular:mainfrom
ShayanAbbas1:fix-external-template-project-recovery
Open

fix(language-server): recover project for external templates in solution-style workspaces#69769
ShayanAbbas1 wants to merge 1 commit into
angular:mainfrom
ShayanAbbas1:fix-external-template-project-recovery

Conversation

@ShayanAbbas1

@ShayanAbbas1 ShayanAbbas1 commented Jul 14, 2026

Copy link
Copy Markdown

PR Checklist

  • The commit message follows our guidelines
  • Tests for the changes have been added (see note below)
  • Docs have been added / updated (not applicable)

PR Type

  • Bugfix

What is the current behavior?

In solution-style workspaces (the default Nx layout, where an app's tsconfig.json contains only project references), an external template that loses its configured-project association after being opened — e.g. because its component .ts file was closed and the project graph updated — permanently loses all language service features. Every subsequent request on the template hits getDefaultProjectForScriptInfo, whose bare openClientFile lookup can never resolve a config file for an HTML file, so it logs No config file for ... and returns null indefinitely until the user manually reopens the component file.

angular/vscode-ng-language-service#2165 fixed this same failure mode for the document-open path only; the request-time recovery path was left unpatched.

Reproduced in VS Code itself (Angular extension v22.0.1, server 22.x) with a template-opened-first session, in Zed, and with a raw LSP stdio client — details and Angular Language Service logs in #69768.

Issue Number: Fixes #69768

What is the new behavior?

getDefaultProjectForScriptInfo applies the same best-effort as onDidOpenTextDocument when the config lookup comes back empty for an external template: briefly open/close the sibling .ts file (guarded by projectService.openFiles, same as #2165) and retry. If the lookup still fails — openClientFile does not repeat the config search for an already-open file — the template's script info is attached directly to the configured project of its component.

Validated against a large Nx monorepo (Angular 19, ~30 projects) by driving @angular/language-server over raw LSP: with stock 21.1.5, definition requests on an orphaned template fail with No config file indefinitely (40+ consecutive failures reproduced); with this change the template re-attaches on the next request and features recover every time. This patch has also been in daily editor use (Zed) on that workspace.

Note on tests: server/src/session.ts currently has no unit spec, and the integration fixtures under integration/project are not solution-style. Happy to add a solution-style fixture + integration test if the reviewers can point me at the preferred shape.

Does this PR introduce a breaking change?

  • No

…ion-style workspaces

In a composite/solution-style workspace (e.g. an Nx monorepo, where an
app's tsconfig.json only contains project references), TypeScript can
never resolve a config file for an HTML file, since HTML files are not
listed in any referenced project. angular/vscode-ng-language-service#2165
worked around this in onDidOpenTextDocument by briefly opening the
sibling TS file so the right project loads when a template is opened
first.

However, getDefaultProjectForScriptInfo - the recovery path used by
getLSAndScriptInfo and onDidChangeTextDocument when a script info has no
configured project - did not receive the same workaround. When an open
template loses its project association (e.g. its component file is
closed and the project graph updates), every subsequent request on the
template fails with "No config file" and returns null indefinitely,
until the user manually reopens the component file.

Apply the same sibling-TS best effort in getDefaultProjectForScriptInfo,
and additionally attach the template's script info to the configured
project of its component when the config lookup still comes back empty
(openClientFile does not repeat the config lookup for already-open
files).

Fixes angular#69768
@google-cla

google-cla Bot commented Jul 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pullapprove
pullapprove Bot requested a review from kirjs July 14, 2026 15:30
@JeanMeche
JeanMeche requested review from atscott and removed request for kirjs July 14, 2026 16:04
@pkozlowski-opensource pkozlowski-opensource added the area: language-service Issues related to Angular's VS Code language service label Jul 22, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: language-service Issues related to Angular's VS Code language service

Projects

None yet

2 participants