Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(web): keep the local computer gate polling while the page is hidden
shoudi zheng436a24b53d6b
diff --git a/apps/web/src/features/local-computer/local-computer-gate.test.tsx b/apps/web/src/features/local-computer/local-computer-gate.test.tsxindex f3768049..9aead97c 100644--- a/apps/web/src/features/local-computer/local-computer-gate.test.tsx+++ b/apps/web/src/features/local-computer/local-computer-gate.test.tsx@@ -1,4 +1,8 @@-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import {+ focusManager,+ QueryClient,+ QueryClientProvider,+} from "@tanstack/react-query";import {act,fireEvent,@@ -9,7 +13,7 @@ import {} from "@testing-library/react";import { Suspense } from "react";import { createMemoryRouter, RouterProvider } from "react-router";-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import {anotherMeQueryKey,@@ -140,6 +144,46 @@ describe("Local Computer gate", () => {expect(screen.getByText("Shell content").closest("[inert]")).not.toBeNull();});+ it("keeps polling while the page is hidden so a preloaded desktop window leaves the gate", async () => {+ vi.useFakeTimers({ shouldAdvanceTime: true });+ const fixture = await renderShell({+ ...newMac,+ runtimes: [+ {+ models: [{ id: "claude-sonnet", label: "Claude Sonnet" }],+ status: "ready",+ type: "claude",+ version: "2.1.0",+ },+ ],+ });+ expect(await screen.findByText(/Creating your Another Me/)).toBeVisible();+ act(() => focusManager.setFocused(false));+ const server = fixture.runtime.server;+ const anotherMeGets = () =>+ server.requestsTo("GET", "/v0/tenants/{tenantId}/another-me").length;+ const computerGets = () =>+ server.requestsTo("GET", "/v0/tenants/{tenantId}/local-computers").length;+ const before = { anotherMe: anotherMeGets(), computers: computerGets() };++ await act(() => vi.advanceTimersByTimeAsync(3_100));+ await act(() => vi.advanceTimersByTimeAsync(3_100));++ expect(anotherMeGets()).toBeGreaterThanOrEqual(before.anotherMe + 2);+ expect(computerGets()).toBeGreaterThanOrEqual(before.computers + 2);++ fixture.anotherMe = {+ agent_actor_id: "actor-anotherme",+ room_id: "room-another-me",+ };+ await act(() => vi.advanceTimersByTimeAsync(3_100));+ await waitFor(() =>+ expect(+ screen.queryByRole("dialog", { name: "Connect your computer" }),+ ).toBeNull(),+ );+ });+it("waits for the CLI login while no Computer is connected", async () => {await renderShell();@@ -163,10 +207,12 @@ async function renderShell(const runtime = createTestTeamHubRuntime();const fixture: {anotherMe: { agent_actor_id?: string; room_id?: string };+ runtime: typeof runtime;queryClient: QueryClient;router: ReturnType<typeof createMemoryRouter>;} = {anotherMe: {},+ runtime,queryClient: new QueryClient({defaultOptions: { queries: { retry: false } },}),diff --git a/apps/web/src/features/local-computer/local-computer-gate.tsx b/apps/web/src/features/local-computer/local-computer-gate.tsxindex 34e18511..15fe1da7 100644--- a/apps/web/src/features/local-computer/local-computer-gate.tsx+++ b/apps/web/src/features/local-computer/local-computer-gate.tsx@@ -60,13 +60,18 @@ export function LocalComputerGate({const { client } = useTeamHubRuntime();const desktop = useDesktopComputer();const [platform, setPlatform] = useState(browserComputerPlatform);+ // The desktop preloads this page hidden so "Open Linger" can reveal a+ // rendered Room, and the realtime stream is closed while hidden, so the gate+ // keeps polling in the background or it never sees Another Me arrive.const computers = useQuery({...localComputersQueryOptions(client, tenantId),refetchInterval: pollIntervalMs,+ refetchIntervalInBackground: true,});useQuery({...anotherMeQueryOptions(client, tenantId),refetchInterval: pollIntervalMs,+ refetchIntervalInBackground: true,});const computer = gateComputer(computers.data?.items ?? []);const online = computer?.status === "online" && !computer.upgrade_required;