Skip to content

fix live preview for display height and depth sliders#2263

Open
nehaaprasad wants to merge 1 commit intoMentra-Community:devfrom
nehaaprasad:fix/no-prv-slsi-adj-hei-dep
Open

fix live preview for display height and depth sliders#2263
nehaaprasad wants to merge 1 commit intoMentra-Community:devfrom
nehaaprasad:fix/no-prv-slsi-adj-hei-dep

Conversation

@nehaaprasad
Copy link
Copy Markdown

@nehaaprasad nehaaprasad commented Mar 23, 2026

Summary

  • Enable live updates for depth slider while dragging.
  • Enable live updates for height slider while dragging.

Test plan

  • Drag both sliders and confirm preview updates live.
  • Release sliders and confirm final position is correct.

Closes #2250

Summary by CodeRabbit

  • Bug Fixes
    • Settings sliders now update in real-time as you adjust them, rather than waiting until you finish adjusting.

@nehaaprasad nehaaprasad requested a review from a team as a code owner March 23, 2026 03:27
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

A bug fix modifies the position settings screen to pass setter functions directly to the slider's onValueChange prop, enabling live preview updates during slider adjustment instead of only on release.

Changes

Cohort / File(s) Summary
Slider Preview Fix
mobile/src/app/miniapps/settings/position.tsx
Changed SliderSetting components' onValueChange from no-op functions to directly use setDashboardDepth and setDashboardHeight setters, enabling live preview feedback as sliders are adjusted.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A slider hops, the preview glows,
No more delays, the live view flows,
With each small tweak, the settings dance,
Height and depth now get their chance!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix live preview for display height and depth sliders' directly and clearly summarizes the main change: enabling live updates for height and depth sliders.
Linked Issues check ✅ Passed The code changes successfully implement the requirements from issue #2250 by modifying onValueChange to use setter functions, enabling live preview updates during slider adjustments.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing live preview for height and depth sliders as specified in issue #2250; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mobile/src/app/miniapps/settings/position.tsx`:
- Around line 43-44: The handlers currently call the persisted/synced setter
(setDashboardDepth) on every onValueChange and again on onValueSet, causing
excessive storage/network writes; change the component to update a transient
local state during drag (use a local state variable and call setDashboardDepth
only from onValueSet) so onValueChange updates only local UI state and
onValueSet performs the single persisted/synced write; apply the same change for
the other pair at lines 53-54 (the second persisted setter).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a83af77-fd24-4a93-8069-87234e500d0e

📥 Commits

Reviewing files that changed from the base of the PR and between dcbc966 and de1545b.

📒 Files selected for processing (1)
  • mobile/src/app/miniapps/settings/position.tsx

Comment on lines +43 to 44
onValueChange={setDashboardDepth}
onValueSet={setDashboardDepth}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid persisting/syncing settings on every drag tick.

Line 43 and Line 53 now call persisted/server-synced setters on every onValueChange, and Line 44/Line 54 call them again on release. This creates high-frequency storage + network writes and duplicate final writes.

💡 Proposed fix (live preview + single persisted write on release)
-import {useCallback, useEffect} from "react"
+import {useCallback, useEffect, useState} from "react"
@@
 export default function ScreenSettingsScreen() {
@@
   const [dashboardDepth, setDashboardDepth] = useSetting(SETTINGS.dashboard_depth.key)
   const [dashboardHeight, setDashboardHeight] = useSetting(SETTINGS.dashboard_height.key)
+  const [previewDepth, setPreviewDepth] = useState(dashboardDepth ?? 5)
+  const [previewHeight, setPreviewHeight] = useState(dashboardHeight ?? 4)
@@
   useEffect(() => {
     setEnabled(false)
     return () => setEnabled(true)
   }, [setEnabled])
+
+  useEffect(() => {
+    setPreviewDepth(dashboardDepth ?? 5)
+  }, [dashboardDepth])
+
+  useEffect(() => {
+    setPreviewHeight(dashboardHeight ?? 4)
+  }, [dashboardHeight])
@@
         <SliderSetting
@@
-          value={dashboardDepth ?? 5}
+          value={previewDepth}
@@
-          onValueChange={setDashboardDepth}
-          onValueSet={setDashboardDepth}
+          onValueChange={setPreviewDepth}
+          onValueSet={(value) => {
+            setPreviewDepth(value)
+            setDashboardDepth(value)
+          }}
         />
@@
         <SliderSetting
@@
-          value={dashboardHeight ?? 4}
+          value={previewHeight}
@@
-          onValueChange={setDashboardHeight}
-          onValueSet={setDashboardHeight}
+          onValueChange={setPreviewHeight}
+          onValueSet={(value) => {
+            setPreviewHeight(value)
+            setDashboardHeight(value)
+          }}
         />

Also applies to: 53-54

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mobile/src/app/miniapps/settings/position.tsx` around lines 43 - 44, The
handlers currently call the persisted/synced setter (setDashboardDepth) on every
onValueChange and again on onValueSet, causing excessive storage/network writes;
change the component to update a transient local state during drag (use a local
state variable and call setDashboardDepth only from onValueSet) so onValueChange
updates only local UI state and onValueSet performs the single persisted/synced
write; apply the same change for the other pair at lines 53-54 (the second
persisted setter).

@aisraelov
Copy link
Copy Markdown
Member

Hey @naaa760 thanks for the PR. have you tested this?

@nehaaprasad
Copy link
Copy Markdown
Author

@aisraelov yess

@aisraelov aisraelov changed the base branch from main to dev March 30, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug report: No preview as sliders were adjusted for height and depth of

2 participants