Skip to content

Keep model architectures list expanded when navigating back#6881

Open
andersendsa wants to merge 6 commits into
open-edge-platform:developfrom
andersendsa:keep_architecture
Open

Keep model architectures list expanded when navigating back#6881
andersendsa wants to merge 6 commits into
open-edge-platform:developfrom
andersendsa:keep_architecture

Conversation

@andersendsa

Copy link
Copy Markdown

Summary

Initializes the showMore state in ModelArchitecturesList to true if the currently selected model architecture is not in the collapsed list. This ensures that when a user selects a non-default model and navigates back from the "Advanced settings" screen, their selection is still visible.

Closes:#6823

How to test

  1. Open the Train model dialog.
  2. Click Show more in the model architectures list.
  3. Select an architecture that is not in the initially recommended/collapsed list (e.g., the 5th option).
  4. Click Advanced settings.
  5. Click Back.
  6. Verify that the model architectures list remains expanded, making the selected architecture visible.

Checklist

  • The PR title and description are clear and descriptive
  • I have manually tested the changes
  • All changes are covered by automated tests
  • All related issues are linked to this PR (if applicable)
  • Documentation has been updated (if applicable)

Initializes the `showMore` state in `ModelArchitecturesList` to `true`
if the currently selected model architecture is not in the collapsed list.
This ensures that when a user selects a non-default model and navigates
back from the "Advanced settings" screen, their selection is still visible.
Copilot AI review requested due to automatic review settings June 20, 2026 02:13
@andersendsa andersendsa requested a review from a team as a code owner June 20, 2026 02:13
@github-actions github-actions Bot added the Geti UI Issues related to Geti application frontend label Jun 20, 2026

Copilot AI 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.

Pull request overview

Updates the Train Model dialog’s model-architectures selector so that when a user returns from “Advanced settings”, the architectures list starts expanded if the currently selected architecture would otherwise be hidden in the collapsed/recommended subset.

Changes:

  • Initializes showMore based on whether the selected architecture is present in the collapsed (recommended) list.
  • Preserves visibility of non-default (non-collapsed) selections when navigating back from advanced settings.

Comment on lines +22 to +26
const [showMore, setShowMore] = useState<boolean>(() => {
if (selectedModelArchitectureId !== null) {
const isSelectedInCollapsed = collapsedArchitectures.some((arch) => arch.id === selectedModelArchitectureId);
return !isSelectedInCollapsed;
}
@andersendsa

Copy link
Copy Markdown
Author

Hi @piotrgrubicki pls let me know if this pr needs any changes or if it is good to merge

@dwesolow

Copy link
Copy Markdown
Contributor

Hi @andersendsa, thanks for contribution! Could you please implement test(s) for this change?

@andersendsa

Copy link
Copy Markdown
Author

Hi @andersendsa, thanks for contribution! Could you please implement test(s) for this change?

Hi @dwesolow I have added the test for this change the pr is ready for review

@andersendsa andersendsa requested a review from Copilot June 22, 2026 09:32

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines +22 to +28
const [showMore, setShowMore] = useState<boolean>(() => {
if (selectedModelArchitectureId !== null) {
const isSelectedInCollapsed = collapsedArchitectures.some((arch) => arch.id === selectedModelArchitectureId);
return !isSelectedInCollapsed;
}
return false;
});
Comment on lines +59 to +65
it('renders expanded list by default if a non-default architecture is already selected', () => {
mockSelectedModelArchitectureId.value = 'arch-5';
render(<ModelArchitecturesList />);

expect(screen.getByRole('button', { name: 'Show less' })).toBeVisible();
expect(screen.getByRole('button', { name: /Sort Models by:/i })).toBeVisible();
});
fireEvent.click(screen.getByRole('button', { name: 'Show less' }));
expect(screen.queryByRole('button', { name: /Sort Models by:/i })).not.toBeInTheDocument();
});

@dwesolow

Copy link
Copy Markdown
Contributor

We should test the change in higher level, to actually test expected behavior, i.e. if user clicks back in advanced settings, the model architectures are expended.

@github-actions github-actions Bot added the TEST Any changes in tests label Jun 23, 2026
@andersendsa andersendsa requested a review from dwesolow June 23, 2026 01:03
@andersendsa

Copy link
Copy Markdown
Author

We should test the change in higher level, to actually test expected behavior, i.e. if user clicks back in advanced settings, the model architectures are expended.

Hi @dwesolow i have added the test pls let me know if the pr needs any changes or if it is good to merge

dwesolow
dwesolow previously approved these changes Jun 23, 2026

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

Great job!

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

@andersendsa while the solution works, i feel like it's a bit hacky. Instead of collapsing/opening based on a condition, we should make this logic selection agnostic. By this i mean, selecting "advanced settings" or selecting a model should not affect the "show more logic". The issue right now is that the state is reset whenever you open Advanced settings because the model list is remounted. So, in order to avoid this, i think we should lift the "show more" state logic to the train model provider. This way the model list will be collapsed/opened regardless of where you are.

TL;DR -> Move showMore/setShowMore to TrainModelProvider to avoid state resets when we navigate to AdvancedSettings

@andersendsa

Copy link
Copy Markdown
Author

@andersendsa while the solution works, i feel like it's a bit hacky. Instead of collapsing/opening based on a condition, we should make this logic selection agnostic. By this i mean, selecting "advanced settings" or selecting a model should not affect the "show more logic". The issue right now is that the state is reset whenever you open Advanced settings because the model list is remounted. So, in order to avoid this, i think we should lift the "show more" state logic to the train model provider. This way the model list will be collapsed/opened regardless of where you are.

TL;DR -> Move showMore/setShowMore to TrainModelProvider to avoid state resets when we navigate to AdvancedSettings

Hi @jpggvilaca i have implemented the changes pls let me know if the pr needs anymore changes or if it is good to merge

const collapsedArchitectures = recommendedArchitectures.slice(0, SHOW_MORE_THRESHOLD);
const canToggleArchitecturesList = modelArchitectures.length > SHOW_MORE_THRESHOLD;

useEffect(() => {

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.

I dont think we need this useEffect anymore. This was what i mentioned previously. We dont need to open/close any show more. Now that the state is on the provider, the list should not collapse

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.

I dont think we need this useEffect anymore. This was what i mentioned previously. We dont need to open/close any show more. Now that the state is on the provider, the list should not collapse

@jpggvilaca I have reverted it

@andersendsa andersendsa requested a review from jpggvilaca June 23, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Geti UI Issues related to Geti application frontend TEST Any changes in tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants