From 50a9b0f8a2881865b9b1ebc35828458af2ac3b96 Mon Sep 17 00:00:00 2001 From: Micheal Parks Date: Fri, 10 Jul 2026 11:41:37 -0400 Subject: [PATCH 1/4] fix tweakpane race condition --- src/lib/components/App.svelte | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/components/App.svelte b/src/lib/components/App.svelte index b20b6e3cf..a9c475310 100644 --- a/src/lib/components/App.svelte +++ b/src/lib/components/App.svelte @@ -7,7 +7,7 @@ import { useXR } from '@threlte/xr' import { provideToast, ToastContainer } from '@viamrobotics/prime-core' import { primeTheme } from '@viamrobotics/tweakpane-config' - import { onMount, type Snippet } from 'svelte' + import type { Snippet } from 'svelte' import { ThemeUtils } from 'svelte-tweakpane-ui' import type { FragmentInfo } from '$lib/hooks/useFragmentInfo.svelte' @@ -88,6 +88,16 @@ details, }: Props = $props() + /** + * Apply the Viam tweakpane theme to the document element synchronously during + * setup — before any child `` is constructed. This must not be deferred + * to `onMount`: children (and their underlying Tweakpane instances) mount + * before the parent's `onMount` runs, so panes would occasionally paint with + * Tweakpane's default dark theme before the theme variables land on ``. + * `setGlobalDefaultTheme` no-ops when there is no document (prerender). + */ + ThemeUtils.setGlobalDefaultTheme(primeTheme) + provideWorld() provideSettingsTabs() @@ -122,10 +132,6 @@ environment.current.isStandalone = !localConfigProps }) - onMount(() => { - ThemeUtils.setGlobalDefaultTheme(primeTheme) - }) - const selected = useQuery(traits.Selected) From 36fd8659b2b9c7ba112d6195f4f225f80c5008f3 Mon Sep 17 00:00:00 2001 From: Micheal Parks <103450731+micheal-parks@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:42:25 -0400 Subject: [PATCH 2/4] Create gold-peas-beg.md --- .changeset/gold-peas-beg.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/gold-peas-beg.md diff --git a/.changeset/gold-peas-beg.md b/.changeset/gold-peas-beg.md new file mode 100644 index 000000000..ce95cd660 --- /dev/null +++ b/.changeset/gold-peas-beg.md @@ -0,0 +1,5 @@ +--- +"@viamrobotics/motion-tools": patch +--- + +Fix tweakpane styling race condition From e541a6111d20cb75954e14799004643115a95ef1 Mon Sep 17 00:00:00 2001 From: Micheal Parks Date: Fri, 10 Jul 2026 11:48:08 -0400 Subject: [PATCH 3/4] lint --- src/lib/components/App.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/App.svelte b/src/lib/components/App.svelte index a9c475310..ab593785f 100644 --- a/src/lib/components/App.svelte +++ b/src/lib/components/App.svelte @@ -1,13 +1,13 @@