Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(onboarding): show timeline choice only on low-tier devices

Louis Beaumontfcde0d1b5afb
diff --git a/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx b/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx
index 1aa1a4d67..4c3305abf 100644
--- a/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx
+++ b/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx
@@ -22,6 +22,8 @@ const mocks = vi.hoisted(() => ({
completeOnboarding: vi.fn(async () => undefined),
capture: vi.fn(),
isSettingLocked: vi.fn((_key: string) => false),
+ settings: { deviceTier: "low" as string | null | undefined },
+ isSettingsLoaded: true,
}));
const onboardingData = { currentStep: "login", isCompleted: false };
@@ -49,6 +51,12 @@ vi.mock("@/lib/hooks/use-managed-policy", () => ({
isSettingLocked: mocks.isSettingLocked,
}),
}));
+vi.mock("@/lib/hooks/use-settings", () => ({
+ useSettings: () => ({
+ settings: mocks.settings,
+ isSettingsLoaded: mocks.isSettingsLoaded,
+ }),
+}));
vi.mock("@/components/onboarding/login-gate", () => ({
default: () => <div>regular sign in</div>,
}));
@@ -113,6 +121,8 @@ describe("enterprise onboarding authentication", () => {
onboardingData.isCompleted = false;
mocks.applyEnterpriseUiVisibility.mockResolvedValue(false);
mocks.isSettingLocked.mockImplementation(() => false);
+ mocks.settings.deviceTier = "low";
+ mocks.isSettingsLoaded = true;
});
it("offers regular sign-in and Enterprise Key on the login step", () => {
@@ -272,9 +282,11 @@ describe("timeline slide sequencing", () => {
onboardingData.isCompleted = false;
mocks.applyEnterpriseUiVisibility.mockResolvedValue(false);
mocks.isSettingLocked.mockImplementation(() => false);
+ mocks.settings.deviceTier = "low";
+ mocks.isSettingsLoaded = true;
});
- it("shows the timeline choice between permissions and engine", async () => {
+ it("shows the timeline choice between permissions and engine on a low-tier device", async () => {
render(<OnboardingPage />);
fireEvent.click(
@@ -288,6 +300,25 @@ describe("timeline slide sequencing", () => {
expect(screen.queryByText("engine")).not.toBeInTheDocument();
});
+ it.each(["mid", "high", undefined, null, "unknown", "LOW"])(
+ "skips the timeline choice when the device tier is %s",
+ async (deviceTier) => {
+ mocks.settings.deviceTier = deviceTier;
+
+ render(<OnboardingPage />);
+
+ fireEvent.click(
+ await screen.findByRole("button", { name: /finish permissions/i })
+ );
+
+ await waitFor(() =>
+ expect(mocks.setOnboardingStep).toHaveBeenCalledWith("engine")
+ );
+ expect(await screen.findByText("engine")).toBeInTheDocument();
+ expect(screen.queryByText("timeline choice")).not.toBeInTheDocument();
+ }
+ );
+
it("skips straight to engine when policy manages disableTimeline", async () => {
mocks.isSettingLocked.mockImplementation(
(key: string) => key === "disableTimeline"
@@ -334,6 +365,33 @@ describe("timeline slide sequencing", () => {
expect(await screen.findByText("timeline choice")).toBeInTheDocument();
});
+ it("does not resume a saved timeline step on a non-low-tier device", async () => {
+ onboardingData.currentStep = "timeline";
+ mocks.settings.deviceTier = "high";
+
+ render(<OnboardingPage />);
+
+ expect(await screen.findByText("engine")).toBeInTheDocument();
+ expect(screen.queryByText("timeline choice")).not.toBeInTheDocument();
+ });
+
+ it("waits for settings hydration before restoring a low-tier timeline step", async () => {
+ onboardingData.currentStep = "timeline";
+ mocks.settings.deviceTier = undefined;
+ mocks.isSettingsLoaded = false;
+
+ const view = render(<OnboardingPage />);
+ expect(screen.queryByText("timeline choice")).not.toBeInTheDocument();
+ expect(screen.queryByText("engine")).not.toBeInTheDocument();
+
+ mocks.settings.deviceTier = "low";
+ mocks.isSettingsLoaded = true;
+ view.rerender(<OnboardingPage />);
+
+ expect(await screen.findByText("timeline choice")).toBeInTheDocument();
+ expect(screen.queryByText("engine")).not.toBeInTheDocument();
+ });
+
it.each(["disableTimeline", "disableScreenshots"])(
"does not resume onto the timeline slide when policy manages %s",
async (lockedKey) => {
diff --git a/apps/screenpipe-app-tauri/app/onboarding/page.tsx b/apps/screenpipe-app-tauri/app/onboarding/page.tsx
index ac46e2189..5624577bc 100644
--- a/apps/screenpipe-app-tauri/app/onboarding/page.tsx
+++ b/apps/screenpipe-app-tauri/app/onboarding/page.tsx
@@ -14,6 +14,7 @@ import ConnectApps from "@/components/onboarding/connect-apps";
import FirstDashboard from "@/components/onboarding/first-dashboard";
import { useOnboarding } from "@/lib/hooks/use-onboarding";
import { useManagedPolicy } from "@/lib/hooks/use-managed-policy";
+import { useSettings } from "@/lib/hooks/use-settings";
import { EnterpriseLicensePrompt } from "@/components/enterprise-license-prompt";
import posthog from "posthog-js";
import { commands } from "@/lib/utils/tauri";
@@ -36,8 +37,8 @@ const SLIDE_WINDOW_SIZES: Record<SlideKey, { width: number; height: number }> =
"first-dashboard": { width: 500, height: 720 },
};
-// The timeline choice sits before "engine" so disableTimeline is persisted
-// before the engine spawns and reads it — no restart needed.
+// When shown, the timeline choice sits before "engine" so disableTimeline is
+// persisted before the engine spawns and reads it — no restart needed.
const SLIDE_ORDER: SlideKey[] = [
"login",
"permissions",
@@ -124,6 +125,7 @@ export default function OnboardingPage() {
[]
);
const { onboardingData, isLoading, completeOnboarding } = useOnboarding();
+ const { settings, isSettingsLoaded } = useSettings();
const completedForHiddenUiRef = React.useRef(false);
const transitioningRef = React.useRef(false);
const {
@@ -137,23 +139,35 @@ export default function OnboardingPage() {
policy: managedPolicy,
isSettingLocked,
} = useManagedPolicy();
+ // This intervention is intentionally narrow: only a canonical "low" tier
+ // written by the native hardware detector is enough evidence to show it.
+ // Missing, malformed, mid, and high tiers all skip it. We also wait for the
+ // settings store to hydrate below so its default/unknown state cannot be
+ // mistaken for hardware evidence.
+ const isConfidentLowEndDevice = settings.deviceTier === "low";
+
// The timeline slide writes disableTimeline AND disableScreenshots, so a
// policy owning either one already decides the outcome — showing the choice
- // would let it contradict what the user picked. Drop the slide from the
- // sequence in that case (which also keeps the progress bar count honest).
+ // would let it contradict what the user picked.
const timelineChoiceLocked =
isSettingLocked("disableTimeline") || isSettingLocked("disableScreenshots");
+ const timelineChoiceVisible =
+ isConfidentLowEndDevice && !timelineChoiceLocked;
const visibleOrder = useMemo(
- () => SLIDE_ORDER.filter((s) => s !== "timeline" || !timelineChoiceLocked),
- [timelineChoiceLocked]
+ () => SLIDE_ORDER.filter((s) => s !== "timeline" || timelineChoiceVisible),
+ [timelineChoiceVisible]
);
- // Read by the mount-only restore effect below, which must not re-run when the
- // policy resolves. Assigned during render, per the ref-mirror rule in CLAUDE.md.
- const lockedRef = React.useRef(timelineChoiceLocked);
- lockedRef.current = timelineChoiceLocked;
+ // Read by the hydration-gated restore effect below. Assigned during render,
+ // per the ref-mirror rule in CLAUDE.md.
+ const timelineChoiceVisibleRef = React.useRef(timelineChoiceVisible);
+ timelineChoiceVisibleRef.current = timelineChoiceVisible;
- // Restore saved step on mount
+ // Restore only after both settings and managed policy hydrate. Otherwise a
+ // low-tier device can briefly look unknown and a saved timeline step would
+ // be skipped before the real hardware tier arrives.
useEffect(() => {
+ if (!isSettingsLoaded || !isManagedDeploymentResolved) return;
+
const init = async () => {
const { loadOnboardingStatus } = useOnboarding.getState();
await loadOnboardingStatus();
@@ -184,16 +198,18 @@ export default function OnboardingPage() {
};
const mapped = stepMap[step];
if (mapped) {
- // A step saved before policy took ownership must not resume onto a
- // slide the policy now decides — skip to the next visible one.
+ // A saved step must not resume onto a slide that this device or its
+ // managed policy is no longer eligible to see.
setCurrentSlide(
- mapped === "timeline" && lockedRef.current ? "engine" : mapped
+ mapped === "timeline" && !timelineChoiceVisibleRef.current
+ ? "engine"
+ : mapped
);
}
}
};
init();
- }, []);
+ }, [isManagedDeploymentResolved, isSettingsLoaded]);
// Set window size + track view when slide changes
useEffect(() => {
@@ -309,7 +325,7 @@ export default function OnboardingPage() {
handleNextSlide,
]);
- if (isLoading || !isManagedDeploymentResolved) {
+ if (isLoading || !isSettingsLoaded || !isManagedDeploymentResolved) {
return (
<div className="flex items-center justify-center min-h-screen bg-background">
<div className="w-6 h-6 border border-foreground border-t-transparent rounded-full animate-spin" />