Skip to content

Comments

ENG-1378 automatic source appending for evd incorrectly pre pends#788

Merged
mdroidian merged 5 commits intomainfrom
eng-1378-automatic-source-appending-for-evd-incorrectly-pre-pends
Feb 21, 2026
Merged

ENG-1378 automatic source appending for evd incorrectly pre pends#788
mdroidian merged 5 commits intomainfrom
eng-1378-automatic-source-appending-for-evd-incorrectly-pre-pends

Conversation

@mdroidian
Copy link
Contributor

@mdroidian mdroidian commented Feb 16, 2026

https://www.loom.com/share/12276fa951e14a1d824e8da9e5f6ab7d

Summary

Fixes the EVD create flow so a prefilled Source is visibly locked and treated as an existing node, instead of being silently converted into a “new source” input path.

Problem

In the create-node modal, the referenced Source could appear prefilled but still behave as unlocked. In that state, the input update path could clear the referenced uid, which then caused submit logic to treat it as a new source and re-run source formatting.

Root Cause

FuzzySelectInput kept a separate local isLocked state that could drift from the actual source-of-truth (value.uid), and lock behavior relied on prop-sync logic.

What Changed

  • Refactored lock behavior to be derived, not stored:
    • isLocked = mode === "create" && Boolean(value?.uid)
    • File: apps/roam/src/components/FuzzySelectInput.tsx
  • Removed prop-sync lock mechanism and related props:
    • Removed initialIsLocked
    • Removed onLockedChange
    • Removed the useEffect that copied prop state into local lock state
    • File: apps/roam/src/components/FuzzySelectInput.tsx
  • Updated selection/clear behavior to drive lock purely via value.uid:
    • Selecting existing item (uid present) locks automatically
    • Clearing resets uid and unlocks automatically
    • File: apps/roam/src/components/FuzzySelectInput.tsx
  • Removed obsolete prop usage in dialog:
    • File: apps/roam/src/components/ModifyNodeDialog.tsx

Why This Approach

This removes duplicated state and makes lock behavior deterministic from a single source of truth. It is simpler, more React-idiomatic, and avoids stale lock transitions.


Open with Devin

Summary by CodeRabbit

  • Refactor
    • Simplified internal state management in the fuzzy select component, reducing dependencies and redundant props while preserving all user-facing functionality and UI behavior.

@linear
Copy link

linear bot commented Feb 16, 2026

@supabase
Copy link

supabase bot commented Feb 16, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

devin-ai-integration[bot]

This comment was marked as resolved.

@mdroidian
Copy link
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

📝 Walkthrough

Walkthrough

The PR simplifies FuzzySelectInput's locking mechanism by removing public props (onLockedChange, initialUid, initialIsLocked) and deriving lock state internally as mode === "create" && Boolean(value?.uid). ModifyNodeDialog is updated to stop using the removed props, and the isReferencedNodeLocked computation is streamlined to directly check for a uid's presence.

Changes

Cohort / File(s) Summary
FuzzySelectInput Locking Refactor
apps/roam/src/components/FuzzySelectInput.tsx
Removed public locking props (onLockedChange, initialUid, initialIsLocked) and internal isLocked state; replaced with derived condition. Simplified handleSelect, reworked handleClear and handleInputChange flows, adjusted effect logic to bail early when locked, and updated input onChange routing.
ModifyNodeDialog Prop Usage
apps/roam/src/components/ModifyNodeDialog.tsx
Removed initialUid prop from Content input FuzzySelectInput. Removed initialUid and initialIsLocked props from Referenced Node input FuzzySelectInput. Simplified isReferencedNodeLocked computation to check Boolean(referencedNodeValue.uid) directly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions 'automatic source appending for evd incorrectly pre pends' but the actual changes are about refactoring lock behavior in FuzzySelectInput to prevent mishandled prefilled sources. Update the title to clearly describe the main change: e.g., 'Refactor FuzzySelectInput lock behavior to derive from value.uid instead of prop state' or 'Fix prefilled source behavior by making lock state deterministic in FuzzySelectInput'.
Merge Conflict Detection ⚠️ Warning ⚠️ Unable to check for merge conflicts: Failed to fetch base branch: From https://github.com/DiscourseGraphs/discourse-graph
! [rejected] main -> main (non-fast-forward)
+ 84db740...41b12f4 main -> origin/main (forced update)
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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
Contributor

@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.

🧹 Nitpick comments (2)
apps/roam/src/components/FuzzySelectInput.tsx (2)

71-79: isLocked in the dependency array is a derived value — consider using value?.uid instead.

isLocked is derived on every render (mode === "create" && Boolean(value?.uid)), so it's not a stable reference. While this works because React compares the primitive boolean value, it would be slightly more explicit and conventional to depend on the underlying values (mode, value?.uid) rather than a derived local variable. This is a minor readability nit — no functional issue.


66-69: value could be undefined — spread is safe but the dep array causes frequent re-creation.

value is typed as optional (value?: T), and {...undefined} is valid JS, so the spread is safe. However, since value is an object, the dependency [value, setValue] means this callback is recreated whenever the parent provides a new value reference. If this causes performance concerns, you could narrow the dep to [setValue] and access value via a ref, but this is fine for now.

@mdroidian
Copy link
Contributor Author


const handleSelect = useCallback(
(item: T) => {
if (mode === "create" && item.uid && item.uid !== initialUid) {
Copy link
Collaborator

@trangdoan982 trangdoan982 Feb 17, 2026

Choose a reason for hiding this comment

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

Oh I think we need another variable to detect if we're creating nodes in canvas.
Removing this and asserting const isLocked = mode === "create" && Boolean(value?.uid); makes it so that every new node creation in Canvas will have isLocked=true by default (because block uid is created first before the flow is finished)

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. Re-added isLocked and made it required.
https://www.loom.com/share/0403ecba18dd478995bfb9310a0a6aea

Copy link
Collaborator

@trangdoan982 trangdoan982 left a comment

Choose a reason for hiding this comment

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

lgtm

@mdroidian mdroidian merged commit 0a896f4 into main Feb 21, 2026
8 checks passed
@mdroidian mdroidian deleted the eng-1378-automatic-source-appending-for-evd-incorrectly-pre-pends branch February 21, 2026 22:57
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.

2 participants