Skip to content

Auto-fill Contribute form from active graph metadata#392

Merged
pradeeban merged 2 commits intoControlCore-Project:devfrom
GREENRAT-K405:feat/autofill-contribute-detail
Apr 24, 2026
Merged

Auto-fill Contribute form from active graph metadata#392
pradeeban merged 2 commits intoControlCore-Project:devfrom
GREENRAT-K405:feat/autofill-contribute-detail

Conversation

@GREENRAT-K405
Copy link
Copy Markdown

The Contribute form previously required users to manually type their Study Name, Study Path, and Author Name every time even though the editor already stores all three values in state.
So, this is just a small improvement to store them in the contribute form by default (can be changed later when actually contributing).

image image

Copilot AI review requested due to automatic review settings April 24, 2026 05:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the UX of the Contribute modal by auto-populating the form’s Study Name, Study Path, and Author Name from the currently active graph/editor state, reducing repetitive manual entry.

Changes:

  • Initialize study, path, and auth state from the active graph metadata / uploaded directory name.
  • Add an effect that re-applies these defaults when the Contribute modal is opened.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +31
useEffect(() => {
if (superState.contributeModal) {
const activeGraph = superState.graphs[superState.curGraphIndex] ?? {};
setStudy(activeGraph.projectName ?? '');
setPath(superState.uploadedDirName ?? '');
setAuth(activeGraph.authorName ?? '');
}
}, [superState.contributeModal]);
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

useEffect reads superState.graphs, superState.curGraphIndex, and superState.uploadedDirName but only lists superState.contributeModal in the dependency array. This can lead to stale values being captured (and will typically trigger react-hooks/exhaustive-deps warnings under the current ESLint setup). Consider including the referenced values in the dependency list and gating the setters so they only run on the closed→open transition (e.g., via a useRef tracking previous open state) to avoid overwriting user edits while the modal remains open.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed with follow up PR!

const activeGraph = superState.graphs[superState.curGraphIndex] ?? {};
setStudy(activeGraph.projectName ?? '');
setPath(superState.uploadedDirName ?? '');
setAuth(activeGraph.authorName ?? '');
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

On modal open you reset study/path/auth, but other form state (title, desc, branch, and possibly showAdvanceOptions) is not reset anywhere. Since this modal component is mounted persistently, those values will carry over between opens, which is inconsistent with the new “auto-fill defaults on open” behavior. Consider resetting the remaining fields when the modal opens (or when closing) to avoid stale values being shown on subsequent contributions.

Suggested change
setAuth(activeGraph.authorName ?? '');
setAuth(activeGraph.authorName ?? '');
setTitle('');
setDesc('');
setBranch('');
setShowAdvanceOptions(false);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed with follow up PR!

@GREENRAT-K405
Copy link
Copy Markdown
Author

Hi @pradeeban , please have a look!

@pradeeban pradeeban merged commit 69c0659 into ControlCore-Project:dev Apr 24, 2026
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.

3 participants