Skip to content

refactor: Fix ui flashes from on prop changes#1812

Open
mfortman11 wants to merge 5 commits into
mainfrom
no-adjust-state-on-prop
Open

refactor: Fix ui flashes from on prop changes#1812
mfortman11 wants to merge 5 commits into
mainfrom
no-adjust-state-on-prop

Conversation

@mfortman11

@mfortman11 mfortman11 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Eliminate stale UI flashes from state-on-prop-change effects

Fixes 10 instances of no-adjust-state-on-prop-change across 5 files. These useEffect calls synced state to prop changes, causing React to render once with stale values before the effect corrected them — users
briefly saw wrong data.

Changes:

  • file-list.tsx — Tab reset on retry tab disappearing moved to render-time check
  • use-task-dialog.ts — Selection clear on dialog close and status category fallback moved to prev-prop pattern
  • animated-provider-steps.tsx — Removed redundant startTime state (was just a copy of processingStartTime prop); elapsed time now captured during render on completion transition
  • onboarding-step.tsx — Split monolithic effect into render-time prop adjustments + a slimmer effect for the typewriter animation interval only
  • unified-cloud-picker.tsx — Replaced fake-async effect with render-time check (the "async" function was synchronous); removed dead isLoadingBaseUrl state and unreachable loading UI

Summary by CodeRabbit

  • Refactor
    • Improved onboarding step transitions by syncing text/visibility/completion changes instantly, reducing lag in the typing animation.
    • Refined onboarding timing so elapsed time updates precisely when a step completes.
    • Improved OneDrive cloud picking responsiveness by removing the interim “Loading” state during auto-detection.
    • Updated task dialog tab/filter behavior to react immediately to availability and selection changes.
    • Clear dialog selections promptly when the dialog closes.

@github-actions github-actions Bot added community frontend 🟨 Issues related to the UI/UX and removed community labels Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 78e0ed44-4f2d-4825-baab-d8c37ff81396

📥 Commits

Reviewing files that changed from the base of the PR and between d5a22db and 72e1ac0.

📒 Files selected for processing (1)
  • frontend/components/cloud-picker/unified-cloud-picker.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/components/cloud-picker/unified-cloud-picker.tsx

Walkthrough

Five frontend components refactor state management from useEffect-based initialization and effects to render-time conditionals and local state tracking. AnimatedProviderSteps detects completion transitions to set elapsed time, OnboardingStep synchronizes text/visibility/completion state during render, UnifiedCloudPicker inlines OneDrive URL detection, and TaskDialogFileList and useTaskDialog hook consolidate state resets into conditional blocks instead of effect watchers.

Changes

Render-time state synchronization refactor

Layer / File(s) Summary
Completion-transition elapsed time detection
frontend/app/onboarding/_components/animated-provider-steps.tsx
AnimatedProviderSteps now detects the transition into completion via prevIsCompleted tracking and computes elapsedTime directly from processingStartTime at that moment, removing the prior startTime state and initialization effect.
Onboarding step input-change synchronization
frontend/app/onboarding/_components/onboarding-step.tsx
OnboardingStep tracks previous text, isVisible, and isCompleted values and synchronizes displayedText/showChildren during render when inputs change, moving reset logic from useEffect into a dedicated conditional block and removing the timing comment.
OneDrive base URL inline conditional detection
frontend/components/cloud-picker/unified-cloud-picker.tsx
UnifiedCloudPicker removes isLoadingBaseUrl state and its associated async effect, replacing with an inline render-time conditional that sets autoBaseUrl when provider is onedrive and required credentials exist, and removes the loading UI branch.
Task dialog and file list state synchronization
frontend/components/task-dialog/file-list.tsx, frontend/components/task-dialog/use-task-dialog.ts
TaskDialogFileList and useTaskDialog hook remove useEffect imports and replace effect-based logic: file-list moves tab-switch validation to render time, and the hook tracks previous open state to clear selectedPaths on close and resets statusCategory inline when category count is zero.

Possibly related PRs

  • langflow-ai/openrag#1739: The main PR's frontend/components/task-dialog/use-task-dialog.ts changes how the task dialog reacts to open/filter updates (local previous-open tracking and render-time state resets), which is directly tied to the retrieved PR's new task dialog open/close state added in frontend/contexts/task-context.tsx and used across the task dialog UI.

Suggested reviewers

  • lucaseduoli

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 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 accurately summarizes the main change: eliminating UI flashes from state updates triggered by prop changes by moving logic from useEffect to render-time checks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch no-adjust-state-on-prop

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.

@github-actions github-actions Bot added refactor and removed refactor labels Jun 9, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/components/cloud-picker/unified-cloud-picker.tsx (1)

31-31: ⚠️ Potential issue | 🟠 Major

Fix stale effectiveBaseUrl caused by persisted autoBaseUrl when switching providers

unified-cloud-picker.tsx stores OneDrive’s fallback in component state (autoBaseUrl) and derives effectiveBaseUrl as baseUrl || autoBaseUrl. Since there’s no reset when provider changes away from "onedrive", createProviderHandler(provider, ..., effectiveBaseUrl) can receive the OneDrive picker URL for subsequent providers while baseUrl is still unset.

Suggested fix
-  const [autoBaseUrl, setAutoBaseUrl] = useState<string | undefined>(undefined);
-
-  const effectiveBaseUrl = baseUrl || autoBaseUrl;
-
-  if (provider === "onedrive" && !baseUrl && accessToken && !autoBaseUrl) {
-    setAutoBaseUrl("https://onedrive.live.com/picker");
-  }
+  const effectiveBaseUrl =
+    baseUrl ??
+    (provider === "onedrive" && accessToken
+      ? "https://onedrive.live.com/picker"
+      : undefined);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/components/cloud-picker/unified-cloud-picker.tsx` at line 31, The
stale OneDrive URL comes from storing OneDrive’s fallback in state (autoBaseUrl)
and using effectiveBaseUrl = baseUrl || autoBaseUrl even after provider changes;
update the component so autoBaseUrl is cleared or ignored when provider !==
"onedrive" — e.g., add a useEffect that watches provider and sets
setAutoBaseUrl(undefined) whenever provider changes away from "onedrive", or
only pass a OneDrive-specific effectiveBaseUrl into
createProviderHandler(provider, ..., effectiveBaseUrl) by computing
effectiveBaseUrl conditionally (use baseUrl || autoBaseUrl only if provider ===
"onedrive"); ensure references to autoBaseUrl, effectiveBaseUrl and
createProviderHandler are updated accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/app/onboarding/_components/animated-provider-steps.tsx`:
- Around line 30-38: The component seeds prevIsCompleted incorrectly and never
handles the true->false transition; change initialization of prevIsCompleted so
it does not start from the incoming isCompleted prop (initialize false) and
replace the inline if-block with a useEffect that watches isCompleted and
processingStartTime: when isCompleted becomes true && prevIsCompleted is false,
setElapsedTime(Date.now() - processingStartTime) (guarding for undefined
processingStartTime) and setPrevIsCompleted(true); when isCompleted becomes
false, setPrevIsCompleted(false) so subsequent completions recompute
elapsedTime; update references to setPrevIsCompleted and setElapsedTime inside
that effect.

In `@frontend/app/onboarding/_components/onboarding-step.tsx`:
- Around line 38-40: On mount OnboardingStep currently initializes displayedText
and showChildren to empty/false which causes blank render when isVisible &&
isCompleted && !isMarkdown; change the initial state setup so displayedText
initializes to text and showChildren to true when props.isVisible &&
props.isCompleted && !props.isMarkdown (keep prev as before), and ensure the
typing useEffect still early-returns for completed cases—this guarantees
immediate full text and children on first render for the non-markdown completed
case.

---

Outside diff comments:
In `@frontend/components/cloud-picker/unified-cloud-picker.tsx`:
- Line 31: The stale OneDrive URL comes from storing OneDrive’s fallback in
state (autoBaseUrl) and using effectiveBaseUrl = baseUrl || autoBaseUrl even
after provider changes; update the component so autoBaseUrl is cleared or
ignored when provider !== "onedrive" — e.g., add a useEffect that watches
provider and sets setAutoBaseUrl(undefined) whenever provider changes away from
"onedrive", or only pass a OneDrive-specific effectiveBaseUrl into
createProviderHandler(provider, ..., effectiveBaseUrl) by computing
effectiveBaseUrl conditionally (use baseUrl || autoBaseUrl only if provider ===
"onedrive"); ensure references to autoBaseUrl, effectiveBaseUrl and
createProviderHandler are updated accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dc95ce7a-6ed6-40c3-8cad-df6606d2a5ee

📥 Commits

Reviewing files that changed from the base of the PR and between cb3f5ed and 92d342a.

📒 Files selected for processing (5)
  • frontend/app/onboarding/_components/animated-provider-steps.tsx
  • frontend/app/onboarding/_components/onboarding-step.tsx
  • frontend/components/cloud-picker/unified-cloud-picker.tsx
  • frontend/components/task-dialog/file-list.tsx
  • frontend/components/task-dialog/use-task-dialog.ts

Comment thread frontend/app/onboarding/_components/animated-provider-steps.tsx Outdated
Comment thread frontend/app/onboarding/_components/onboarding-step.tsx Outdated
@github-actions github-actions Bot added refactor and removed refactor labels Jun 9, 2026
@github-actions github-actions Bot added refactor and removed refactor labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend 🟨 Issues related to the UI/UX refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant