diff --git a/plugin/src/App/init.lua b/plugin/src/App/init.lua index 0a9ed3bc..232f612e 100644 --- a/plugin/src/App/init.lua +++ b/plugin/src/App/init.lua @@ -542,6 +542,10 @@ function App:checkSyncReminder() end function App:startSyncReminderPolling() + -- Feature disabled: polling GET /api/rojo every 30s is expensive and + -- the setting was hidden behind showNotifications anyway. + do return end + if self.syncReminderPollingThread ~= nil or Settings:get("syncReminderMode") == "None" diff --git a/plugin/src/ServeSession.lua b/plugin/src/ServeSession.lua index 5e5966ea..501a6746 100644 --- a/plugin/src/ServeSession.lua +++ b/plugin/src/ServeSession.lua @@ -350,48 +350,57 @@ function ServeSession:start() self.__serverInfo = serverInfo - local computePatchClock = os.clock() - Log.debug("[TIMING] __computeInitialPatch() starting") - return self:__computeInitialPatch(serverInfo):andThen(function(catchUpPatch) - Log.debug( - "[TIMING] __computeInitialPatch() completed ({} ms)", - string.format("%.1f", (os.clock() - computePatchClock) * 1000) - ) - self:setLoadingText("Starting sync loop...") - - local wsClock = os.clock() - Log.debug("[TIMING] connectWebSocket() starting") - -- Connect WebSocket BEFORE showing confirmation so changes - -- during confirmation can be merged into the patch - -- Note: connectWebSocket returns a Promise that only resolves when - -- the connection closes, so we don't chain .andThen() on it - self.__apiContext - :connectWebSocket({ - ["messages"] = function(messagesPacket) - self:__onWebSocketMessage(messagesPacket) - end, - }) - :catch(function(err) - if self.__status ~= Status.Disconnected then - self:__stopInternal(err) - end - end) - Log.debug( - "[TIMING] connectWebSocket() initiated ({} ms)", - string.format("%.1f", (os.clock() - wsClock) * 1000) - ) - - local confirmClock = os.clock() - Log.debug("[TIMING] __confirmAndApplyInitialPatch() starting") - -- Now show confirmation and wait for user decision - return self:__confirmAndApplyInitialPatch(catchUpPatch, serverInfo):andThen(function(...) - Log.debug( - "[TIMING] __confirmAndApplyInitialPatch() completed ({} ms)", - string.format("%.1f", (os.clock() - confirmClock) * 1000) - ) - return ... + self:setLoadingText("Fetching git metadata...") + return self.__apiContext + :getGitMetadata() + :andThen(function(gitMeta) + serverInfo.gitMetadata = gitMeta + end) + :catch(function() end) + :andThen(function() + local computePatchClock = os.clock() + Log.debug("[TIMING] __computeInitialPatch() starting") + return self:__computeInitialPatch(serverInfo):andThen(function(catchUpPatch) + Log.debug( + "[TIMING] __computeInitialPatch() completed ({} ms)", + string.format("%.1f", (os.clock() - computePatchClock) * 1000) + ) + self:setLoadingText("Starting sync loop...") + + local wsClock = os.clock() + Log.debug("[TIMING] connectWebSocket() starting") + -- Connect WebSocket BEFORE showing confirmation so changes + -- during confirmation can be merged into the patch + -- Note: connectWebSocket returns a Promise that only resolves when + -- the connection closes, so we don't chain .andThen() on it + self.__apiContext + :connectWebSocket({ + ["messages"] = function(messagesPacket) + self:__onWebSocketMessage(messagesPacket) + end, + }) + :catch(function(err) + if self.__status ~= Status.Disconnected then + self:__stopInternal(err) + end + end) + Log.debug( + "[TIMING] connectWebSocket() initiated ({} ms)", + string.format("%.1f", (os.clock() - wsClock) * 1000) + ) + + local confirmClock = os.clock() + Log.debug("[TIMING] __confirmAndApplyInitialPatch() starting") + -- Now show confirmation and wait for user decision + return self:__confirmAndApplyInitialPatch(catchUpPatch, serverInfo):andThen(function(...) + Log.debug( + "[TIMING] __confirmAndApplyInitialPatch() completed ({} ms)", + string.format("%.1f", (os.clock() - confirmClock) * 1000) + ) + return ... + end) + end) end) - end) end) :andThen(function() Log.debug( diff --git a/src/web/api.rs b/src/web/api.rs index 974384a1..1361b10c 100644 --- a/src/web/api.rs +++ b/src/web/api.rs @@ -404,28 +404,6 @@ impl ApiService { Vec::new() }; - let git_metadata = if let Some(repo_root) = self.serve_session.git_repo_root() { - let tree_handle = self.serve_session.tree_handle(); - let repo_root = repo_root.to_owned(); - let initial_head = self - .serve_session - .initial_head_commit() - .map(|s| s.to_owned()); - let t = Instant::now(); - let result = tokio::task::spawn_blocking(move || { - crate::git::compute_git_metadata(&tree_handle, &repo_root, initial_head.as_deref()) - }) - .await - .ok(); - log::debug!( - "[TIMING] handle_api_rojo: compute_git_metadata {}ms", - t.elapsed().as_millis() - ); - result - } else { - None - }; - log::debug!( "[TIMING] handle_api_rojo: total {}ms", handler_start.elapsed().as_millis() @@ -446,7 +424,7 @@ impl ApiService { sync_scripts_only: self.serve_session.sync_scripts_only(), ignore_hidden_services, visible_services, - git_metadata, + git_metadata: None, }) }