From e13a41b9fef19a0f7d417ebfc4877d7258f81089 Mon Sep 17 00:00:00 2001 From: Jordan Montgomery Date: Fri, 9 May 2025 14:29:28 -0400 Subject: [PATCH] macOS setup experience scrolling optimization (#28995) For #28450 Avoids unnecessary updates to the UI's step list which makes a few nice changes: 1. We only scroll when actually needed 2. We scroll to the changed item, rather than potentially an unrelated item that the UI decided "changed" because we marked it for update even though its UI state did not change # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [x] Make sure fleetd is compatible with the latest released version of Fleet (see [Must rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/fleetd-development-and-release-strategy.md)). - [x] Orbit runs on macOS, Linux and Windows. Check if the orbit feature/bugfix should only apply to one platform (`runtime.GOOS`). - [x] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [x] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)). --------- Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> --- .../pkg/setup_experience/setup_experience.go | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/orbit/pkg/setup_experience/setup_experience.go b/orbit/pkg/setup_experience/setup_experience.go index 7ef41c4dbc..e5258b572b 100644 --- a/orbit/pkg/setup_experience/setup_experience.go +++ b/orbit/pkg/setup_experience/setup_experience.go @@ -36,6 +36,7 @@ type SetupExperiencer struct { sd *swiftdialog.SwiftDialog // Name of each step -> is that step done steps map[string]bool + uiSteps map[string]swiftdialog.ListItem started bool } @@ -44,6 +45,7 @@ func NewSetupExperiencer(client Client, rootDirPath string) *SetupExperiencer { OrbitClient: client, closeChan: make(chan struct{}), steps: make(map[string]bool), + uiSteps: make(map[string]swiftdialog.ListItem), rootDirPath: rootDirPath, } } @@ -144,17 +146,24 @@ func (s *SetupExperiencer) Run(oc *fleet.OrbitConfig) error { } for _, step := range steps { - item := resultToListItem(step) - if _, ok := s.steps[step.Name]; ok { - err = s.sd.UpdateListItemByTitle(item.Title, item.StatusText, item.Status) - if err != nil { - log.Info().Err(err).Msg("updating list item in setup experience UI") + currentStepState := resultToListItem(step) + if priorStepState, ok := s.uiSteps[step.Name]; ok { + if currentStepState != priorStepState { + // We only want to resend on change so we're not unnecessarily scrolling the UI + err = s.sd.UpdateListItemByTitle(currentStepState.Title, currentStepState.StatusText, currentStepState.Status) + if err != nil { + log.Info().Err(err).Msg("updating list item in setup experience UI") + } + } else { + log.Info().Msgf("setup experience: no change in status for %s", step.Name) + continue } } else { - err = s.sd.AddListItem(item) + err = s.sd.AddListItem(currentStepState) if err != nil { log.Info().Err(err).Msg("adding list item in setup experience UI") } + s.uiSteps[step.Name] = currentStepState s.steps[step.Name] = false }