-
Notifications
You must be signed in to change notification settings - Fork 285
feat: Auto-link correlated sources bidirectionally #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Automatically maintain bidirectional relationships between correlated sources. When a user selects a correlated source (e.g., Log → Metric), the target source is updated to link back (Metric → Log) if not already linked. - Works for both new and existing sources - Preserves existing correlations (no overwriting) - Improves data consistency across the application
🦋 Changeset detectedLatest commit: 1aeffc5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Stably Runner - Test Suite - 'Smoke Test'Test Suite Run Result: 🟢 Success (4/4 tests passed) [dashboard] This comment was generated from stably-runner-action |
const currentSourceId = watch('id'); | ||
|
||
useEffect(() => { | ||
const { unsubscribe } = watch(async (_value, { name, type }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this particular watch
signature is deprecated in favor of subscribe
https://react-hook-form.com/docs/useform/subscribe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's listed in the docs as deprecated and spelunking the react-hook-form releases this happened in v7.55.0 (commit 7f95b26). There is no subscribe
handler available until that revision.
We're currently using v7.43.8 so moving to the subscribe
approach would require buying into 12 possible breaking version bumps. Do we want to tackle that upgrade effort in this PR or make it a separate effort?
const previouslyLinkedSource = sources.find( | ||
s => | ||
s.kind === targetKind && | ||
(s as any)[targetField] === currentSourceId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
}); | ||
|
||
return () => unsubscribe(); | ||
}, [watch, kind, currentSourceId, sources, updateSource]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering if circular dependencies are possible here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is code to only set the bidirectional link if the other side of the link doesn't have a value. That should prevent infinite update loops as well as allowing users to setup more complex correlation DAGs.
Is that what you were getting at?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind adding a test or two for this?
Added a few comments/questions
Automatically maintain bidirectional relationships between correlated sources. When a user selects a correlated source (e.g., Log → Metric), the target source is updated to link back (Metric → Log) if not already linked. - Works for both new and existing sources - Preserves existing correlations (no overwriting) - Improves data consistency across the application
Automatically maintain bidirectional relationships between correlated sources. When a user selects a correlated source (e.g., Log → Metric), the target source is updated to link back (Metric → Log) if not already linked.