fix(aci): Selected project state should react to form changes#112484
fix(aci): Selected project state should react to form changes#112484
Conversation
saponifi3d
left a comment
There was a problem hiding this comment.
lgtm
the way i reasoned through the context / data splits here is that the context is setting things that change logic flows / which components are being rendered and therefore is logically different than just form data. is that more or less what you were thinking too?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Removed project-not-found guards cause unhandled throws
- Restored the project-not-found guard in edit.tsx that validates the detector's project exists before rendering the form, preventing useDetectorFormProject() from throwing an uncaught error.
Or push these changes by commenting:
@cursor push 825a7867a7
Preview (825a7867a7)
diff --git a/static/app/views/detectors/edit.tsx b/static/app/views/detectors/edit.tsx
--- a/static/app/views/detectors/edit.tsx
+++ b/static/app/views/detectors/edit.tsx
@@ -10,7 +10,7 @@
export default function DetectorEdit() {
const params = useParams<{detectorId: string}>();
- const {fetching: isFetchingProjects} = useProjects();
+ const {projects, fetching: isFetchingProjects} = useProjects();
useWorkflowEngineFeatureGate({redirect: true});
const {
@@ -34,6 +34,11 @@
);
}
+ const project = projects.find(p => p.id === detector.projectId);
+ if (!project) {
+ return <LoadingError message={t('Project not found')} />;
+ }
+
return (
<DetectorFormProvider detectorType={detector.type} detector={detector}>
<EditExistingDetectorForm detector={detector} />This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 15d15c8. Configure here.
Yeah the context is being used for state or data we need in the form components, but which isn't being sent to the endpoint when we save it |
This primarily fixes an issue where the selected project in other parts of the form were not updating correctly when the project was changed. The full project object was previously stored in a context at the top of the detector form, so other components could use things like the project icon, slug, etc. This PR simplifies things a bit by taking it out of the context and creating a new hook `useDetectorFormProject()` which takes the project ID from the form state and looks up the project in our cache.


Closes ISWF-2330
This primarily fixes an issue where the selected project in other parts of the form were not updating correctly when the project was changed.
The full project object was previously stored in a context at the top of the detector form, so other components could use things like the project icon, slug, etc. This PR simplifies things a bit by taking it out of the context and creating a new hook
useDetectorFormProject()which takes the project ID from the form state and looks up the project in our cache.