Skip to content

Commit e29164a

Browse files
committed
remove task detail prewarm from boot gate
1 parent 77dc5e3 commit e29164a

2 files changed

Lines changed: 8 additions & 32 deletions

File tree

packages/ui/src/features/tasks/queries.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,3 @@ export function getCachedTaskDetail(taskId: string): Task | undefined {
4343
IMPERATIVE_QUERY_CLIENT,
4444
).getQueryData<Task>(taskDetailQuery(taskId).queryKey);
4545
}
46-
47-
// Warms the task-detail cache so a task route's first render finds its task
48-
// instead of flashing the route spinner (used by the boot loading gate).
49-
export async function ensureTaskDetailCached(taskId: string): Promise<void> {
50-
if (getCachedTaskDetail(taskId) ?? getCachedTask(taskId)) return;
51-
await resolveService<ImperativeQueryClient>(IMPERATIVE_QUERY_CLIENT)
52-
.ensureQueryData(taskDetailQuery(taskId))
53-
.catch(() => undefined);
54-
}

packages/ui/src/shell/App.tsx

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingSt
2020
import { SettingsDialog } from "@posthog/ui/features/settings/SettingsDialog";
2121
import { UpdateBanner } from "@posthog/ui/features/sidebar/components/UpdateBanner";
2222
import { PendingPromptRecovery } from "@posthog/ui/features/task-detail/components/PendingPromptRecovery";
23-
import { ensureTaskDetailCached } from "@posthog/ui/features/tasks/queries";
2423
import { router } from "@posthog/ui/router/router";
2524
import { AppLoadingScreen } from "@posthog/ui/shell/AppLoadingScreen";
2625
import { track } from "@posthog/ui/shell/analytics";
@@ -36,10 +35,6 @@ interface AppProps {
3635
devToolbar?: ReactNode;
3736
}
3837

39-
// Cap on how long the boot gate waits for the restored task to fetch, so a
40-
// slow or hung request can never block app startup.
41-
const BOOT_WARMUP_MAX_MS = 5_000;
42-
4338
function App({ devToolbar }: AppProps) {
4439
const { isBootstrapped } = useAuthSession();
4540
const authState = useAuthStateValue((state) => state);
@@ -94,28 +89,18 @@ function App({ devToolbar }: AppProps) {
9489
!needsInviteCode &&
9590
!needsAiApproval;
9691

97-
// Run the initial route's loaders and warm its task data before the router
98-
// ever mounts, so the boot loading screen holds until the app is ready and
99-
// no route spinner flashes.
92+
// Run the initial route's loaders before the router ever mounts, so the boot
93+
// loading screen holds until the route is ready.
10094
const [initialRouteLoaded, setInitialRouteLoaded] = useState(false);
10195
useEffect(() => {
10296
if (initialRouteLoaded || !readyForMainApp) return;
10397
let cancelled = false;
104-
const holdWhileLoading = async () => {
105-
await router.load().catch(() => undefined);
106-
const taskId = router.state.matches
107-
.map((match) => (match.params as { taskId?: string }).taskId)
108-
.find(Boolean);
109-
if (taskId) {
110-
await Promise.race([
111-
ensureTaskDetailCached(taskId),
112-
new Promise((resolve) => setTimeout(resolve, BOOT_WARMUP_MAX_MS)),
113-
]);
114-
}
115-
};
116-
void holdWhileLoading().finally(() => {
117-
if (!cancelled) setInitialRouteLoaded(true);
118-
});
98+
void router
99+
.load()
100+
.catch(() => undefined)
101+
.finally(() => {
102+
if (!cancelled) setInitialRouteLoaded(true);
103+
});
119104
return () => {
120105
cancelled = true;
121106
};

0 commit comments

Comments
 (0)