Make workspace git registration nonblocking (#542)

This commit is contained in:
Mohamed Boudra
2026-04-23 18:21:59 +08:00
committed by GitHub
parent 083cd34db4
commit dfc8223bcc
13 changed files with 557 additions and 318 deletions
@@ -85,6 +85,17 @@ function DisabledRenderCountProbe({
return null;
}
function HookResultProbe({
onResult,
serverId,
}: {
onResult: (result: ReturnType<typeof useSidebarWorkspacesList>) => void;
serverId: string;
}): null {
onResult(useSidebarWorkspacesList({ serverId }));
return null;
}
describe("applyStoredOrdering", () => {
it("keeps unknown items on the baseline while applying stored order", () => {
const result = applyStoredOrdering({
@@ -206,6 +217,7 @@ describe("useSidebarWorkspacesList", () => {
act(() => {
getHostRuntimeStore().syncHosts([]);
useSessionStore.getState().clearSession("srv-disabled");
useSessionStore.getState().clearSession("srv-loading");
useSidebarOrderStore.setState({
projectOrderByServerId: {},
workspaceOrderByServerAndProject: {},
@@ -234,6 +246,30 @@ describe("useSidebarWorkspacesList", () => {
expect(useSidebarOrderStore.getState().workspaceOrderByServerAndProject).toEqual({});
});
it("keeps the sidebar in initial load until workspace hydration succeeds", async () => {
const onResult = vi.fn();
act(() => {
useSessionStore.getState().initializeSession("srv-loading", null as unknown as DaemonClient);
});
container = document.createElement("div");
document.body.appendChild(container);
root = createRoot(container);
await act(async () => {
root?.render(React.createElement(HookResultProbe, { serverId: "srv-loading", onResult }));
});
expect(onResult).toHaveBeenLastCalledWith(
expect.objectContaining({
projects: [],
isLoading: true,
isInitialLoad: true,
}),
);
});
it("does not subscribe to order updates while disabled", async () => {
const onRender = vi.fn();
@@ -303,8 +303,7 @@ export function useSidebarWorkspacesList(options?: {
})();
}, [connectionStatus, isActive, runtime, serverId]);
const isLoading =
isActive && Boolean(serverId) && connectionStatus === "online" && !hasHydratedWorkspaces;
const isLoading = isActive && Boolean(serverId) && !hasHydratedWorkspaces;
const isInitialLoad = isLoading && projects.length === 0;
const isRevalidating = false;