1- import { showRefreshLoadingAtLocation } from '@nx-console/vscode-lsp-client' ;
1+ import {
2+ getNxlsClient ,
3+ NxlsClient ,
4+ showRefreshLoadingAtLocation ,
5+ } from '@nx-console/vscode-lsp-client' ;
26import { selectProject } from '@nx-console/vscode-nx-cli-quickpicks' ;
37import { revealNxProject } from '@nx-console/vscode-nx-config-decoration' ;
48import { getNxWorkspaceProjects } from '@nx-console/vscode-nx-workspace' ;
@@ -8,6 +12,14 @@ import { AtomizerDecorationProvider } from './atomizer-decorations';
812import { NxProjectTreeProvider } from './nx-project-tree-provider' ;
913import { NxTreeItem } from './nx-tree-item' ;
1014import { ProjectGraphErrorDecorationProvider } from './project-graph-error-decorations' ;
15+ import {
16+ NxStartDaemonRequest ,
17+ NxWorkspaceRefreshNotification ,
18+ } from '@nx-console/language-server-types' ;
19+ import {
20+ logAndShowError ,
21+ showErrorMessageWithOpenLogs ,
22+ } from '@nx-console/vscode-output-channels' ;
1123
1224export function initNxProjectView (
1325 context : ExtensionContext ,
@@ -19,10 +31,14 @@ export function initNxProjectView(
1931 } ) ;
2032
2133 context . subscriptions . push ( nxProjectTreeView ) ;
22-
23- commands . registerCommand (
24- 'nxConsole.showProjectConfiguration' ,
25- showProjectConfiguration ,
34+ context . subscriptions . push (
35+ commands . registerCommand (
36+ 'nxConsole.showProjectConfiguration' ,
37+ showProjectConfiguration ,
38+ ) ,
39+ commands . registerCommand ( 'nxConsole.restartDaemonWatcher' , async ( ) => {
40+ await tryRestartDaemonWatcher ( ) ;
41+ } ) ,
2642 ) ;
2743
2844 AtomizerDecorationProvider . register ( context ) ;
@@ -66,3 +82,17 @@ export async function showProjectConfiguration(selection: NxTreeItem) {
6682 const target = viewItem . nxTarget ;
6783 return revealNxProject ( project , root , target ) ;
6884}
85+
86+ async function tryRestartDaemonWatcher ( ) {
87+ getTelemetry ( ) . logUsage ( 'misc.restart-daemon-watcher' ) ;
88+
89+ const nxlsClient = getNxlsClient ( ) ;
90+ try {
91+ await nxlsClient . sendRequest ( NxStartDaemonRequest , undefined ) ;
92+ } catch ( e ) {
93+ showErrorMessageWithOpenLogs ( 'Failed to start Nx daemon watcher' ) ;
94+ return ;
95+ }
96+
97+ await nxlsClient . sendNotification ( NxWorkspaceRefreshNotification ) ;
98+ }
0 commit comments