:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): tell the server which sessions are archived (#82622)
Thomas Obermüller2da5b290a8fd
diff --git a/products/desktop/packages/api-client/src/posthog-client.ts b/products/desktop/packages/api-client/src/posthog-client.tsindex f20052068d86..c7a6976b7b98 100644--- a/products/desktop/packages/api-client/src/posthog-client.ts+++ b/products/desktop/packages/api-client/src/posthog-client.ts@@ -2604,6 +2604,18 @@ export class PostHogAPIClient {return normalizeTaskResponse(data, { teamId });}+ /**+ * Mirror this device's archive state onto the task, so every client agrees on+ * what is archived — and so the list endpoint, which hides archived tasks,+ * counts what the app actually shows. `archived` is on the write serializer+ * but not yet in the generated schema.+ */+ async setTaskArchived(taskId: string, archived: boolean): Promise<void> {+ await this.updateTask(taskId, {+ archived,+ } as unknown as Partial<Schemas.Task>);+ }+async deleteTask(taskId: string) {const teamId = await this.getTeamId();await this.api.delete(`/api/projects/{project_id}/tasks/{id}/`, {diff --git a/products/desktop/packages/core/src/archive/serverArchiveSync.test.ts b/products/desktop/packages/core/src/archive/serverArchiveSync.test.tsnew file mode 100644index 000000000000..f54457e42494--- /dev/null+++ b/products/desktop/packages/core/src/archive/serverArchiveSync.test.ts@@ -0,0 +1,35 @@+import { describe, expect, it } from "vitest";+import { pendingServerArchiveIds } from "./serverArchiveSync";++describe("pendingServerArchiveIds", () => {+ it.each([+ {+ name: "picks every archived task not yet mirrored",+ archived: ["a", "b", "c"],+ skip: [],+ expected: ["a", "b", "c"],+ },+ {+ name: "skips ids already synced or already tried this run",+ archived: ["a", "b", "c"],+ skip: ["a", "c"],+ expected: ["b"],+ },+ {+ name: "has nothing to do when the archive is fully mirrored",+ archived: ["a", "b"],+ skip: ["a", "b"],+ expected: [],+ },+ {+ name: "has nothing to do when nothing is archived",+ archived: [],+ skip: ["a"],+ expected: [],+ },+ ])("$name", ({ archived, skip, expected }) => {+ expect(pendingServerArchiveIds(new Set(archived), new Set(skip))).toEqual(+ expected,+ );+ });+});diff --git a/products/desktop/packages/core/src/archive/serverArchiveSync.ts b/products/desktop/packages/core/src/archive/serverArchiveSync.tsnew file mode 100644index 000000000000..ff681fcbf87f--- /dev/null+++ b/products/desktop/packages/core/src/archive/serverArchiveSync.ts@@ -0,0 +1,24 @@+/**+ * Which locally-archived tasks the server hasn't been told about.+ *+ * Archiving is a per-device act, so the server keeps listing sessions this+ * machine has hidden — and its count is what a space row's "view all" number+ * comes from, which is why that number can run hundreds above the list behind+ * it. The whole local archive is the work list: discovering the backlog+ * through a task-list page starves, because pages are capped at the newest+ * hundred rows and an archive is precisely the sessions too old to be there.+ *+ * `skip` is the ids already mirrored (durably, on this device) plus the ones+ * this run has already tried, so a task the server keeps refusing can't spin+ * the drain loop.+ */+export function pendingServerArchiveIds(+ archivedTaskIds: ReadonlySet<string>,+ skip: ReadonlySet<string>,+): string[] {+ const pending: string[] = [];+ for (const taskId of archivedTaskIds) {+ if (!skip.has(taskId)) pending.push(taskId);+ }+ return pending;+}diff --git a/products/desktop/packages/ui/src/features/archive/serverArchiveSyncStore.ts b/products/desktop/packages/ui/src/features/archive/serverArchiveSyncStore.tsnew file mode 100644index 000000000000..1351c16d697f--- /dev/null+++ b/products/desktop/packages/ui/src/features/archive/serverArchiveSyncStore.ts@@ -0,0 +1,64 @@+import { create } from "zustand";+import { persist } from "zustand/middleware";++// Beyond this the oldest mirrored ids are dropped. A dropped id costs one+// redundant (idempotent) PATCH on the next launch, so the cap only bounds+// storage, not correctness.+const SYNCED_IDS_CAP = 5000;++interface ServerArchiveSyncStore {+ /**+ * Archives this device has mirrored onto the server. Durable, so a backlog+ * is written once ever rather than once per launch.+ */+ syncedTaskIds: string[];+ /**+ * Restores whose server-side clear hasn't landed. Durable, because until the+ * clear lands the session is archived server-side — hidden from every list,+ * including this device's — and nothing else can rediscover it: the sync+ * pass reads the local archive, which the restore just removed it from.+ */+ pendingUnarchiveTaskIds: string[];+ markSynced: (taskId: string) => void;+ forgetSynced: (taskId: string) => void;+ queueUnarchive: (taskId: string) => void;+ clearUnarchive: (taskId: string) => void;+}++export const useServerArchiveSyncStore = create<ServerArchiveSyncStore>()(+ persist(+ (set) => ({+ syncedTaskIds: [],+ pendingUnarchiveTaskIds: [],+ markSynced: (taskId) =>+ set((state) => ({+ syncedTaskIds: [+ ...state.syncedTaskIds.filter((id) => id !== taskId),+ taskId,+ ].slice(-SYNCED_IDS_CAP),+ })),+ forgetSynced: (taskId) =>+ set((state) => ({+ syncedTaskIds: state.syncedTaskIds.filter((id) => id !== taskId),+ })),+ queueUnarchive: (taskId) =>+ set((state) =>+ state.pendingUnarchiveTaskIds.includes(taskId)+ ? state+ : {+ pendingUnarchiveTaskIds: [+ ...state.pendingUnarchiveTaskIds,+ taskId,+ ],+ },+ ),+ clearUnarchive: (taskId) =>+ set((state) => ({+ pendingUnarchiveTaskIds: state.pendingUnarchiveTaskIds.filter(+ (id) => id !== taskId,+ ),+ })),+ }),+ { name: "server-archive-sync" },+ ),+);diff --git a/products/desktop/packages/ui/src/features/archive/useServerArchiveSync.test.tsx b/products/desktop/packages/ui/src/features/archive/useServerArchiveSync.test.tsxnew file mode 100644index 000000000000..72703d4b4330--- /dev/null+++ b/products/desktop/packages/ui/src/features/archive/useServerArchiveSync.test.tsx@@ -0,0 +1,115 @@+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { act, renderHook, waitFor } from "@testing-library/react";+import type { ReactNode } from "react";+import { beforeEach, describe, expect, it, vi } from "vitest";++const apiClient = vi.hoisted(() => ({ setTaskArchived: vi.fn() }));++vi.mock("@posthog/ui/features/auth/authClient", () => ({+ useOptionalAuthenticatedClient: () => apiClient,+}));++const archivedIds = vi.hoisted(() => ({ current: new Set<string>() }));++vi.mock("@posthog/ui/features/archive/useArchivedTaskIds", () => ({+ useArchivedTaskIds: () => archivedIds.current,+}));++import { useServerArchiveSyncStore } from "./serverArchiveSyncStore";+import { useServerArchiveSync } from "./useServerArchiveSync";++let queryClient: QueryClient;+function wrapper({ children }: { children: ReactNode }) {+ return (+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>+ );+}++describe("useServerArchiveSync", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ archivedIds.current = new Set();+ useServerArchiveSyncStore.setState({+ syncedTaskIds: [],+ pendingUnarchiveTaskIds: [],+ });+ queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ });++ it("mirrors a locally archived task the server has not been told about", async () => {+ apiClient.setTaskArchived.mockResolvedValue(undefined);+ archivedIds.current = new Set(["t1"]);++ renderHook(() => useServerArchiveSync(), { wrapper });++ await waitFor(() =>+ expect(apiClient.setTaskArchived).toHaveBeenCalledWith("t1", true),+ );+ expect(useServerArchiveSyncStore.getState().syncedTaskIds).toContain("t1");+ });++ it("syncs a task archived after the drain's last read, before the drain ended", async () => {+ // Regression: the trigger for a task archived mid-drain hit the `running`+ // guard and returned, and nothing re-fired once the drain finished, so the+ // task stayed server-visible until an unrelated trigger or a relaunch.+ let releaseFirstPatch: () => void = () => {};+ const firstPatchStarted = new Promise<void>((patchCalled) => {+ apiClient.setTaskArchived.mockImplementationOnce(+ () =>+ new Promise<void>((resolve) => {+ releaseFirstPatch = resolve;+ patchCalled();+ }),+ );+ });+ apiClient.setTaskArchived.mockResolvedValue(undefined);+ archivedIds.current = new Set(["t1"]);++ const { rerender } = renderHook(() => useServerArchiveSync(), { wrapper });+ await firstPatchStarted;++ // A second task is archived while the first PATCH is still in flight.+ archivedIds.current = new Set(["t1", "t2"]);+ await act(async () => {+ rerender();+ releaseFirstPatch();+ });++ await waitFor(() =>+ expect(apiClient.setTaskArchived).toHaveBeenCalledWith("t2", true),+ );+ });++ it("leaves a task the server refused out of syncedTaskIds so a later pass retries it", async () => {+ apiClient.setTaskArchived.mockRejectedValue(new Error("nope"));+ archivedIds.current = new Set(["t1"]);++ renderHook(() => useServerArchiveSync(), { wrapper });++ await waitFor(() =>+ expect(apiClient.setTaskArchived).toHaveBeenCalledWith("t1", true),+ );+ expect(useServerArchiveSyncStore.getState().syncedTaskIds).not.toContain(+ "t1",+ );+ });++ it("clears a queued restore on the server and drops it from the mirrored record", async () => {+ apiClient.setTaskArchived.mockResolvedValue(undefined);+ useServerArchiveSyncStore.setState({+ syncedTaskIds: ["t1"],+ pendingUnarchiveTaskIds: ["t1"],+ });++ renderHook(() => useServerArchiveSync(), { wrapper });++ await waitFor(() =>+ expect(apiClient.setTaskArchived).toHaveBeenCalledWith("t1", false),+ );+ const state = useServerArchiveSyncStore.getState();+ expect(state.pendingUnarchiveTaskIds).not.toContain("t1");+ expect(state.syncedTaskIds).not.toContain("t1");+ });+});diff --git a/products/desktop/packages/ui/src/features/archive/useServerArchiveSync.ts b/products/desktop/packages/ui/src/features/archive/useServerArchiveSync.tsnew file mode 100644index 000000000000..6759d0903638--- /dev/null+++ b/products/desktop/packages/ui/src/features/archive/useServerArchiveSync.ts@@ -0,0 +1,164 @@+import { pendingServerArchiveIds } from "@posthog/core/archive/serverArchiveSync";+import { useServerArchiveSyncStore } from "@posthog/ui/features/archive/serverArchiveSyncStore";+import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";+import { taskKeys } from "@posthog/ui/features/tasks/taskKeys";+import { logger } from "@posthog/ui/shell/logger";+import { useQueryClient } from "@tanstack/react-query";+import { useEffect, useRef } from "react";++const log = logger.scope("server-archive-sync");++/**+ * A restore that couldn't reach the server. Until the clear lands the session+ * is archived server-side, which hides it from every list — including this+ * device's, where it was just restored — so the queue is durable and the sync+ * pass keeps trying.+ */+export function retryServerUnarchive(taskId: string): void {+ const store = useServerArchiveSyncStore.getState();+ store.forgetSynced(taskId);+ store.queueUnarchive(taskId);+}++/** A restored task, which may well be archived again before long. */+export function forgetServerArchive(taskId: string): void {+ useServerArchiveSyncStore.getState().forgetSynced(taskId);+}++/**+ * Tell the server about the sessions this device has archived.+ *+ * Archiving has always been local, so the server kept listing sessions the app+ * hides. Its count is what a space row's "view all" number is drawn from, which+ * left that number reading hundreds above the list it leads to. Marking the+ * task archived server-side drops it from the same list every count comes from,+ * and carries the archive to the user's other devices.+ *+ * The work list is the local archive itself, diffed against a durable record of+ * what this device has already mirrored — not a task-list page. Pages are+ * capped at the newest hundred rows, and an archive is precisely the sessions+ * too old to be there: discovery through a page synced whatever happened to be+ * recent and then starved. The drain runs once per backlog ever (the record+ * survives relaunch), sequentially, so it never competes with requests the+ * user is waiting on.+ */+export function useServerArchiveSync(): void {+ const client = useOptionalAuthenticatedClient();+ const archivedTaskIds = useArchivedTaskIds();+ const queryClient = useQueryClient();+ // Queued restores re-fire the effect. Mirrored-id progress deliberately+ // doesn't: this hook lives at the root, and subscribing to a record that+ // grows once per PATCH would re-render the tree hundreds of times per drain.+ const pendingUnarchive = useServerArchiveSyncStore(+ (s) => s.pendingUnarchiveTaskIds,+ );+ const running = useRef(false);+ const archivedRef = useRef(archivedTaskIds);+ const clientRef = useRef(client);++ // The drain loop re-reads these between passes, so a session archived while+ // it runs is picked up by the loop that's already going, and the effect that+ // fires for it lands on the `running` guard and is skipped. Written after the+ // render rather than during it, and before the drain effect below, which runs+ // later in the same commit — so the drain never reads a ref left behind by a+ // render React went on to discard.+ useEffect(() => {+ archivedRef.current = archivedTaskIds;+ clientRef.current = client;+ });++ useEffect(() => {+ if (!client || running.current) return;+ // The triggers, checked directly: don't start a drain that would find+ // nothing. The loop below re-reads both sources fresh each pass.+ const mirrored = new Set(+ useServerArchiveSyncStore.getState().syncedTaskIds,+ );+ if (+ pendingUnarchive.length === 0 &&+ pendingServerArchiveIds(archivedTaskIds, mirrored).length === 0+ ) {+ // Distinguishes "nothing to mirror" from "never ran" — the two are+ // otherwise identical in the console, and each app instance has its own+ // archive DB (dev vs packaged), so an unexpectedly small count here is+ // the tell that you're looking at the other instance's backlog.+ log.debug("Archive sync idle", {+ archivedLocally: archivedTaskIds.size,+ alreadyMirrored: mirrored.size,+ });+ return;+ }++ running.current = true;+ void (async () => {+ // Ids this run has already tried and the server refused — retried on the+ // next launch or trigger, but not by the very next pass of this loop.+ const attempted = new Set<string>();+ let changed = 0;+ // The drain's outcome IS the diagnosis when a count reads wrong, and a+ // run that finds work is rare (once per backlog) — so say what was found+ // and what happened to it, not just the failures.+ log.info("Draining archive state to the server", {+ archivedLocally: archivedTaskIds.size,+ alreadyMirrored: mirrored.size,+ pendingUnarchive: pendingUnarchive.length,+ });+ try {+ for (;;) {+ const api = clientRef.current;+ if (!api) break;+ const store = useServerArchiveSyncStore.getState();+ const unarchive = store.pendingUnarchiveTaskIds.filter(+ (id) => !attempted.has(id),+ );+ const archive = pendingServerArchiveIds(+ archivedRef.current,+ new Set([...store.syncedTaskIds, ...attempted]),+ );+ // No await stands between this read and the guard release below, so+ // a trigger either lands early enough for the next pass to see it or+ // late enough to start its own drain. There is no gap to lose one in.+ if (unarchive.length === 0 && archive.length === 0) break;++ // Restores lead: a session the server still has archived is+ // invisible everywhere, which is worse than a count that reads high.+ for (const taskId of unarchive) {+ try {+ await api.setTaskArchived(taskId, false);+ store.clearUnarchive(taskId);+ store.forgetSynced(taskId);+ changed++;+ } catch (error) {+ attempted.add(taskId);+ log.warn(+ `Failed to unarchive task ${taskId} on the server`,+ error,+ );+ }+ }+ for (const taskId of archive) {+ try {+ await api.setTaskArchived(taskId, true);+ store.markSynced(taskId);+ changed++;+ } catch (error) {+ attempted.add(taskId);+ log.warn(`Failed to archive task ${taskId} on the server`, error);+ }+ }+ }+ } finally {+ running.current = false;+ }+ log.info("Archive drain finished", {+ synced: changed,+ refused: attempted.size,+ });+ if (changed === 0) return;+ // Refetches the lists the drain just shortened, which is what moves the+ // space counts drawn from them.+ await queryClient.invalidateQueries({ queryKey: taskKeys.lists() });+ })();+ }, [client, archivedTaskIds, pendingUnarchive, queryClient]);+}diff --git a/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.test.tsx b/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.test.tsxindex 6d1334f55edc..4e34d771ab44 100644--- a/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.test.tsx+++ b/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.test.tsx@@ -17,10 +17,23 @@ const controller = vi.hoisted(() => ({runContextMenuAction: vi.fn(),}));+const apiClient = vi.hoisted(() => ({ setTaskArchived: vi.fn() }));+vi.mock("@posthog/di/react", () => ({useService: () => controller,}));+const archiveSync = vi.hoisted(() => ({+ forgetServerArchive: vi.fn(),+ retryServerUnarchive: vi.fn(),+}));++vi.mock("@posthog/ui/features/auth/authClient", () => ({+ useOptionalAuthenticatedClient: () => apiClient,+}));++vi.mock("@posthog/ui/features/archive/useServerArchiveSync", () => archiveSync);+vi.mock("@posthog/host-router/react", () => ({useHostTRPC: () => ({archive: {@@ -117,6 +130,47 @@ describe("useUnarchiveTask", () => {},);+ it.each<[string, RestoreOutcome, boolean]>([+ ["restored", { kind: "restored", navigateToTaskId: "t1" }, true],+ ["error", { kind: "error", message: "nope" }, false],+ ])(+ // A task left archived server-side is hidden from every list, so the row+ // would come back here and stay gone from the counts drawn off that list.+ "restore() with outcome %s clears the task's server archive: %s",+ async (_name, outcome, shouldClear) => {+ controller.restore.mockResolvedValue(outcome);+ const { result } = renderHook(() => useUnarchiveTask(), { wrapper });++ await act(async () => {+ await result.current.restore("t1", true);+ });++ if (shouldClear) {+ expect(apiClient.setTaskArchived).toHaveBeenCalledWith("t1", false);+ } else {+ expect(apiClient.setTaskArchived).not.toHaveBeenCalled();+ }+ },+ );++ it("hands a clear the server refused to the sync pass to retry", async () => {+ // Nothing else can find it: the reconciler reads task lists, and a task+ // the server has archived is in none of them.+ controller.restore.mockResolvedValue({+ kind: "restored",+ navigateToTaskId: "t1",+ } as RestoreOutcome);+ apiClient.setTaskArchived.mockRejectedValueOnce(new Error("offline"));+ const { result } = renderHook(() => useUnarchiveTask(), { wrapper });++ await act(async () => {+ await result.current.restore("t1", true);+ });++ expect(archiveSync.retryServerUnarchive).toHaveBeenCalledWith("t1");+ expect(archiveSync.forgetServerArchive).not.toHaveBeenCalled();+ });+it.each<[string, ContextMenuOutcome, boolean]>([["noop", { kind: "noop" }, false],["menu-error", { kind: "menu-error", message: "nope" }, false],diff --git a/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.ts b/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.tsindex be59577a0af4..0659150750a6 100644--- a/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.ts+++ b/products/desktop/packages/ui/src/features/archive/useUnarchiveTask.ts@@ -7,10 +7,18 @@ import {} from "@posthog/core/archive/archivedTasksController";import { useService } from "@posthog/di/react";import { useHostTRPC } from "@posthog/host-router/react";+import {+ forgetServerArchive,+ retryServerUnarchive,+} from "@posthog/ui/features/archive/useServerArchiveSync";+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";import { WORKSPACE_QUERY_KEY } from "@posthog/ui/features/workspace/identifiers";+import { logger } from "@posthog/ui/shell/logger";import { useQueryClient } from "@tanstack/react-query";import { useCallback } from "react";+const log = logger.scope("unarchive-task");+export interface UseUnarchiveTask {restore(taskId: string,@@ -31,6 +39,30 @@ export function useUnarchiveTask(): UseUnarchiveTask {);const trpc = useHostTRPC();const queryClient = useQueryClient();+ const client = useOptionalAuthenticatedClient();++ // The archive is mirrored onto the task server-side, where it hides the task+ // from every list — so restoring locally has to clear it, or the row comes+ // back on this device and stays gone from the lists the counts are drawn from.+ // A clear that doesn't land goes to the sync pass, which keeps trying: this+ // is the one direction the reconciler can't discover on its own, because a+ // task the server has archived is in none of the lists it reads.+ const clearServerArchived = useCallback(+ async (taskId: string) => {+ if (!client) {+ retryServerUnarchive(taskId);+ return;+ }+ try {+ await client.setTaskArchived(taskId, false);+ forgetServerArchive(taskId);+ } catch (error) {+ log.warn(`Failed to unarchive task ${taskId} on the server`, error);+ retryServerUnarchive(taskId);+ }+ },+ [client],+ );const invalidateTaskListCaches = useCallback(async () => {await Promise.all([@@ -48,11 +80,12 @@ export function useUnarchiveTask(): UseUnarchiveTask {) => {const outcome = await controller.restore(taskId, hasTask, options);if (outcome.kind === "restored") {+ await clearServerArchived(taskId);await invalidateTaskListCaches();}return outcome;},- [controller, invalidateTaskListCaches],+ [controller, clearServerArchived, invalidateTaskListCaches],);const remove = useCallback(@@ -74,6 +107,7 @@ export function useUnarchiveTask(): UseUnarchiveTask {hasTask,);if (outcome.kind === "restore" && outcome.outcome.kind === "restored") {+ await clearServerArchived(taskId);await invalidateTaskListCaches();} else if (outcome.kind === "delete" &&@@ -83,7 +117,7 @@ export function useUnarchiveTask(): UseUnarchiveTask {}return outcome;},- [controller, invalidateTaskListCaches],+ [controller, clearServerArchived, invalidateTaskListCaches],);return { restore, remove, runContextMenuAction };diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.tsindex 6c84acebc3cf..662bab0934ee 100644--- a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts@@ -227,7 +227,9 @@ export function useRecentSpaceTasks(});// A page that came back short is the whole space, so the count is exact// once the archived ones are dropped. A full page falls back to the- // server's total, which still counts anything archived in it.+ // server's total, which excludes archived tasks — bar any this device has+ // archived and not yet mirrored, which `useServerArchiveSync` is working+ // through.const built: SpaceTasks = {items: spaceTreeOrder(available, viewedAt, blockedTaskIds).slice(0,@@ -321,7 +323,8 @@ export function useSpaceOverview(people: spacePeople(live, createdBy, peopleLimit),// A page that came back short is the whole space, so the count is exact// once the archived ones are dropped. A full page falls back to the- // server's total, which still counts anything archived in it.+ // server's total, which excludes archived tasks — bar any this device has+ // archived and not yet mirrored.total: data.tasks.length < TREE_FETCH_LIMIT ? live.length : data.count,};}, [data, archivedTaskIds, createdBy, peopleLimit]);diff --git a/products/desktop/packages/ui/src/router/routes/__root.tsx b/products/desktop/packages/ui/src/router/routes/__root.tsxindex 34f606ce4376..89793f7e1c8d 100644--- a/products/desktop/packages/ui/src/router/routes/__root.tsx+++ b/products/desktop/packages/ui/src/router/routes/__root.tsx@@ -12,6 +12,7 @@ import { DeepLinkApprovalModal } from "@posthog/ui/features/agent-applications/cimport { useApprovalDeepLink } from "@posthog/ui/features/agent-applications/hooks/useApprovalDeepLink";import { AnnouncementBanner } from "@posthog/ui/features/announcements/AnnouncementBanner";import { AnnouncementsHost } from "@posthog/ui/features/announcements/AnnouncementsHost";+import { useServerArchiveSync } from "@posthog/ui/features/archive/useServerArchiveSync";import { useAuthStateValue } from "@posthog/ui/features/auth/store";import { UsageButton } from "@posthog/ui/features/billing/UsageButton";import { UsageLimitModal } from "@posthog/ui/features/billing/UsageLimitModal";@@ -235,6 +236,7 @@ function RootLayout() {const approvalDeepLink = useApprovalDeepLink();useSetupDiscovery();useNewTaskDeepLink();+ useServerArchiveSync();// hydrateTask is no longer needed — the URL is the source of truth and the// task cache populates the route automatically.