@@ -199,7 +199,7 @@ public void tick() {
199199 enterReadyState ();
200200 return ;
201201 }
202- if ((startupState == StartupState .LOADING || startupState == StartupState .SERVER_STOPPED ) && !startupProbeRunning ) {
202+ if ((startupState == StartupState .LOADING || startupState == StartupState .SERVER_STOPPED || startupState == StartupState . INSTALLED ) && !startupProbeRunning ) {
203203 beginStartupProbe (false );
204204 }
205205 }
@@ -226,6 +226,7 @@ private void ensureStartupWidgets() {
226226 .accentType (ThemeManager .getAccent ("nice" ))
227227 .size (180 , 20 )
228228 .autoWidthOnTextChange (true )
229+ .entranceAnimation (false )
229230 .onClick (this ::runSetupFlow )
230231 .build ();
231232 setupReSyncButton .setVisible (false );
@@ -238,6 +239,7 @@ private void ensureStartupWidgets() {
238239 .accentType (ThemeManager .getAccent ("nice" ))
239240 .size (180 , 20 )
240241 .autoWidthOnTextChange (true )
242+ .entranceAnimation (false )
241243 .onClick (this ::openServerScreen )
242244 .build ();
243245 welcomeServerButton .setVisible (false );
@@ -323,7 +325,10 @@ private void probeStartupStateAsync() {
323325 enterReadyState ();
324326 return ;
325327 }
326- if (startupState == StartupState .INSTALLED || startupState == StartupState .INSTALLING ) {
328+ if (startupState == StartupState .INSTALLING ) {
329+ return ;
330+ }
331+ if (startupState == StartupState .INSTALLED && resolvedState != StartupState .READY && resolvedState != StartupState .LOADING ) {
327332 return ;
328333 }
329334 switch (resolvedState ) {
@@ -367,6 +372,9 @@ private StartupState computeStartupState() {
367372 if (!isRunning ) {
368373 return StartupState .SERVER_STOPPED ;
369374 }
375+ if (flowManager .getFlowAvailabilityIssue (serverId , server ) != null ) {
376+ return StartupState .SETUP ;
377+ }
370378 return StartupState .LOADING ;
371379 }
372380 if (flowManager .isFlowClientConnected (serverId )) {
@@ -697,8 +705,10 @@ private boolean setupForNonReStudio() throws Exception {
697705
698706 Path serverPath = Path .of (instance .getPath ());
699707 Path pluginsPath = serverPath .resolve (resolvePluginsDirectory (instance ));
708+ Path reSyncJarPath = pluginsPath .resolve ("ReSync.jar" );
700709 ensureDirectory (fs , pluginsPath );
701- transfer .downloadFile (RESYNC_RELEASE_URL , pluginsPath .resolve ("ReSync.jar" ), null ).get (90 , TimeUnit .SECONDS );
710+ transfer .downloadFile (RESYNC_RELEASE_URL , reSyncJarPath , null ).get (90 , TimeUnit .SECONDS );
711+ registerReSyncResource (instance , reSyncJarPath );
702712
703713 Path configDir = pluginsPath .resolve ("ReSync" );
704714 ensureDirectory (fs , configDir );
@@ -718,13 +728,28 @@ private boolean setupForNonReStudio() throws Exception {
718728 backendConfig .credentials = new HashMap <>();
719729 }
720730 backendConfig .credentials .put ("resyncEnabled" , "true" );
721- backendConfig .credentials .put ("resyncPort" , String .valueOf (RESYNC_PORT ));
722- backendConfig .credentials .put ("resyncApiKey" , apiKey );
723731 instance .save ();
724732 }
725733 return true ;
726734 }
727735
736+ private void registerReSyncResource (Instance instance , Path reSyncJarPath ) {
737+ if (instance == null || reSyncJarPath == null ) {
738+ return ;
739+ }
740+ try {
741+ boolean remoteBackend = instance .getBackendConfig () != null && !"LOCAL" .equalsIgnoreCase (instance .getBackendConfig ().type );
742+ if (remoteBackend ) {
743+ Rebase .get ().getResourceManager ().invalidateCache (instance );
744+ Rebase .get ().getResourceManager ().getResources (instance ).get (30 , TimeUnit .SECONDS );
745+ return ;
746+ }
747+ Rebase .get ().getResourceManager ().loadResource (instance , reSyncJarPath ).get (30 , TimeUnit .SECONDS );
748+ } catch (Exception ignored ) {
749+ Rebase .get ().getResourceManager ().invalidateCache (instance );
750+ }
751+ }
752+
728753 private String generateApiKey () {
729754 byte [] key = new byte [32 ];
730755 secureRandom .nextBytes (key );
@@ -4223,7 +4248,7 @@ public void refresh() {
42234248 enterReadyState ();
42244249 return ;
42254250 }
4226- if (startupState == StartupState .LOADING || startupState == StartupState .SERVER_STOPPED ) {
4251+ if (startupState == StartupState .LOADING || startupState == StartupState .SERVER_STOPPED || startupState == StartupState . INSTALLED ) {
42274252 beginStartupProbe (false );
42284253 }
42294254 return ;
0 commit comments