Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updates for telemetry update
  • Loading branch information
sawka committed Mar 2, 2026
commit 13bed120a95066f970ae12a9c79b4ed0db543ff0
12 changes: 9 additions & 3 deletions frontend/app/onboarding/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ type PageName = "init" | "notelemetrystar" | "features";

const pageNameAtom: PrimitiveAtom<PageName> = atom<PageName>("init");

const InitPage = ({ isCompact }: { isCompact: boolean }) => {
const InitPage = ({
isCompact,
telemetryUpdateFn,
}: {
isCompact: boolean;
telemetryUpdateFn: (value: boolean) => Promise<void>;
}) => {
const telemetrySetting = useSettingsKeyAtom("telemetry:enabled");
const clientData = useAtomValue(ClientModel.getInstance().clientAtom);
const [telemetryEnabled, setTelemetryEnabled] = useState<boolean>(!!telemetrySetting);
Expand All @@ -46,7 +52,7 @@ const InitPage = ({ isCompact }: { isCompact: boolean }) => {

const setTelemetry = (value: boolean) => {
fireAndForget(() =>
services.ClientService.TelemetryUpdate(value).then(() => {
telemetryUpdateFn(value).then(() => {
setTelemetryEnabled(value);
})
);
Expand Down Expand Up @@ -284,7 +290,7 @@ const NewInstallOnboardingModal = () => {
let pageComp: React.JSX.Element = null;
switch (pageName) {
case "init":
pageComp = <InitPage isCompact={isCompact} />;
pageComp = <InitPage isCompact={isCompact} telemetryUpdateFn={services.ClientService.TelemetryUpdate} />;
break;
case "notelemetrystar":
pageComp = <NoTelemetryStarPage isCompact={isCompact} />;
Expand Down
6 changes: 4 additions & 2 deletions frontend/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// SPDX-License-Identifier: Apache-2.0

import Logo from "@/app/asset/logo.svg";
import { initGlobalAtoms } from "@/app/store/global-atoms";
import { getAtoms, initGlobalAtoms } from "@/app/store/global-atoms";
import { GlobalModel } from "@/app/store/global-model";
import { globalStore } from "@/app/store/jotaiStore";
import { loadFonts } from "@/util/fontutil";
import React, { lazy, Suspense } from "react";
import { createRoot } from "react-dom/client";
Expand All @@ -12,7 +14,6 @@ import "../app/app.scss";

// preview.css should come *after* app.scss (don't remove the newline above otherwise prettier will reorder these imports)
// preview.css re-exports tailwindsetup.css and adds @source "../app" so Tailwind v4 scans frontend/app/** for class names
import { GlobalModel } from "@/app/store/global-model";
import "./preview.css";

// Vite glob import — statically analyzed at build time, lazily loaded at runtime.
Expand Down Expand Up @@ -134,6 +135,7 @@ function initPreview() {
isPreview: true,
} as GlobalInitOptions;
initGlobalAtoms(initOpts);
globalStore.set(getAtoms().fullConfigAtom, {} as FullConfigType);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Initialize fullConfigAtom with a structurally safe default, not {}.

Line 138 sets {} as FullConfigType; preview components that read fullConfig.presets/fullConfig.settings directly can throw at runtime.

🔧 Proposed fix
-    globalStore.set(getAtoms().fullConfigAtom, {} as FullConfigType);
+    globalStore.set(
+        getAtoms().fullConfigAtom,
+        {
+            settings: {},
+            presets: {},
+            connections: {},
+        } as FullConfigType
+    );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
globalStore.set(getAtoms().fullConfigAtom, {} as FullConfigType);
globalStore.set(
getAtoms().fullConfigAtom,
{
settings: {},
presets: {},
connections: {},
} as FullConfigType
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/preview/preview.tsx` at line 138, Replace the unsafe cast "{} as
FullConfigType" used in globalStore.set(getAtoms().fullConfigAtom, {} as
FullConfigType) with a structurally complete default that matches FullConfigType
(e.g., include default presets array and default settings object or use an
exported DEFAULT_FULL_CONFIG). Update the initialization so fullConfig.presets
and fullConfig.settings are defined (either create and use a DEFAULT_FULL_CONFIG
constant or import an existing default) before calling globalStore.set to avoid
runtime property access errors.

GlobalModel.getInstance().initialize(initOpts);
loadFonts();
const root = createRoot(document.getElementById("main")!);
Expand Down
2 changes: 1 addition & 1 deletion frontend/preview/previews/onboarding.preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function OnboardingFeaturesV() {
return (
<div className="flex flex-col w-full gap-8">
<div className="w-[560px] rounded-[10px] p-[30px] relative overflow-hidden bg-panel">
<InitPage isCompact={false} />
<InitPage isCompact={false} telemetryUpdateFn={async () => {}} />
</div>
<div className="w-[560px] rounded-[10px] p-[30px] relative overflow-hidden bg-panel">
<NoTelemetryStarPage isCompact={false} />
Expand Down