Skip to content

Fix setting window navigation update issue #3547

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

Merged
merged 5 commits into from
May 16, 2025
Merged

Conversation

Jack251970
Copy link
Contributor

@Jack251970 Jack251970 commented May 15, 2025

Fix setting window navigation update issue

If the navigation is not triggered by button click, so we need to reset the page type in all setting pages.

And in setting window, we need to update the selected item in navigation view.

Check view model null instead of IsInitialized flag

If we use forward/backward button, IsInitialized is still true so we need to check nullability of view model instance instead.

Test

  • Use click / navigation button to navigate pages.

Confirmed by vzabrodin.

Resolve #3546.

@prlabeler prlabeler bot added the bug Something isn't working label May 15, 2025
@Jack251970 Jack251970 requested a review from Copilot May 15, 2025 10:41

This comment has been minimized.

Copy link

gitstream-cm bot commented May 15, 2025

🥷 Code experts: Yusyuriv, onesounds

Jack251970 has most 👩‍💻 activity in the files.
Jack251970, Yusyuriv have most 🧠 knowledge in the files.

See details

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 18 additions & 11 deletions
MAR 8 additions & 7 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Jack251970: 50%

Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 15 additions & 9 deletions
MAR 5 additions & 6 deletions
FEB 26 additions & 22 deletions
JAN
DEC

Knowledge based on git-blame:
Jack251970: 55%
Yusyuriv: 12%

Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 11 additions & 5 deletions
MAR 7 additions & 6 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Jack251970: 59%

Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 13 additions & 7 deletions
MAR 7 additions & 6 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Jack251970: 63%

Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 42 additions & 23 deletions
MAR 7 additions & 6 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Jack251970: 55%

Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 2 additions & 6 deletions
MAR 6 additions & 4 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Yusyuriv: 52%
Jack251970: 15%

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 4 additions & 10 deletions
MAR 7 additions & 4 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Yusyuriv: 48%
Jack251970: 14%

Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 1 additions & 3 deletions
MAR 4 additions & 4 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Yusyuriv: 48%
Jack251970: 14%

Flow.Launcher/SettingPages/Views/SettingsPanePluginStore.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 9 additions & 5 deletions
MAR 4 additions & 4 deletions
FEB 1 additions & 2 deletions
JAN
DEC

Knowledge based on git-blame:
Yusyuriv: 67%
Jack251970: 17%

Flow.Launcher/SettingPages/Views/SettingsPanePlugins.xaml.cs

Activity based on git-commit:

Jack251970
MAY 30 additions & 1 deletions
APR 1 additions & 3 deletions
MAR 4 additions & 4 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Jack251970: 56%
Yusyuriv: 28%

Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 1 additions & 6 deletions
MAR 6 additions & 4 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Yusyuriv: 48%
Jack251970: 14%

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs

Activity based on git-commit:

Jack251970
MAY
APR 8 additions & 12 deletions
MAR 4 additions & 14 deletions
FEB
JAN
DEC

Knowledge based on git-blame:
Yusyuriv: 62%
Jack251970: 24%

Flow.Launcher/SettingWindow.xaml.cs

Activity based on git-commit:

Jack251970
MAY 26 additions & 4 deletions
APR 56 additions & 26 deletions
MAR 9 additions & 18 deletions
FEB
JAN 14 additions & 8 deletions
DEC

Knowledge based on git-blame:
Jack251970: 46%
Yusyuriv: 32%

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Activity based on git-commit:

Jack251970
MAY
APR 24 additions & 48 deletions
MAR
FEB 2 additions & 3 deletions
JAN 19 additions & 38 deletions
DEC

Knowledge based on git-blame:
Jack251970: 37%
Yusyuriv: 32%

To learn more about /:\ gitStream - Visit our Docs

Copy link

gitstream-cm bot commented May 15, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Contributor

@Copilot 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 addresses the navigation update issues in the settings window by resetting the page type when navigation is not triggered by a button click and by using nullability checks for the view model instead of the IsInitialized flag.

  • Updated the SettingsWindowViewModel to include a PageType property with property change notification.
  • Modified settings pane view files to use a null-check on the view model and update PageType accordingly.
  • Changed WelcomePage files to use a null check for view model initialization.

Reviewed Changes

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

File Description
Flow.Launcher/ViewModel/SettingWindowViewModel.cs Added PageType property with change notification.
Flow.Launcher/SettingWindow.xaml.cs Updated event subscription pattern for view model property changes.
SettingsPane* files Updated OnNavigatedTo logic to check for null view models and reset PageType.
WelcomePage* files Replaced IsInitialized check with null check for view model initialization.

Copy link
Contributor

coderabbitai bot commented May 15, 2025

📝 Walkthrough

"""

Walkthrough

This change refactors the initialization logic for multiple settings and welcome pages by replacing IsInitialized checks with null checks on view models. It also introduces a PageType property in SettingWindowViewModel and ensures the navigation sidebar selection stays in sync with the current page, addressing navigation issues in the settings window.

Changes

Files Change Summary
Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs, WelcomePage2.xaml.cs, WelcomePage3.xaml.cs, WelcomePage4.xaml.cs, WelcomePage5.xaml.cs Changed Settings and _viewModel to readonly fields initialized eagerly via dependency injection. Moved _viewModel.PageNum assignment to start of OnNavigatedTo. Removed lazy initialization inside OnNavigatedTo.
Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml.cs, SettingsPaneGeneral.xaml.cs, SettingsPaneHotkey.xaml.cs, SettingsPanePluginStore.xaml.cs, SettingsPanePlugins.xaml.cs, SettingsPaneProxy.xaml.cs, SettingsPaneTheme.xaml.cs Added private readonly _settingViewModel field initialized via IoC. Set _settingViewModel.PageType unconditionally at start of OnNavigatedTo. Changed initialization check for _viewModel from IsInitialized to null check. Maintained InitializeComponent() guarded by IsInitialized.
Flow.Launcher/SettingWindow.xaml.cs Added private readonly _viewModel field initialized in constructor and set as DataContext. Added ViewModel_PropertyChanged handler to update navigation sidebar selection on PageType changes. Improved navigation selection logic to prevent redundant navigation and fix forward/back navigation issues. Unsubscribed handler on window close.
Flow.Launcher/ViewModel/SettingWindowViewModel.cs Added PageType property with backing field and change notification. Added SetPageType(Type) method to update PageType and return if changed. Added System namespace for Type.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingWindow
    participant SettingWindowViewModel
    participant SettingsPane (any)
    participant NavigationView

    User->>SettingWindow: Open Settings
    SettingWindow->>SettingWindowViewModel: Initialize, set DataContext
    SettingWindow->>NavigationView: Attach PropertyChanged handler

    User->>NavigationView: Select or navigate to a page (mouse/button/side button)
    NavigationView->>SettingsPane: Navigate to selected page
    SettingsPane->>SettingWindowViewModel: Set PageType to current page type

    SettingWindowViewModel-->>SettingWindow: Notify PropertyChanged(PageType)
    SettingWindow->>NavigationView: Update selected item to match PageType
Loading

Assessment against linked issues

Objective Addressed Explanation
Fix unhandled exception and sidebar selection desync when navigating Settings with mouse side buttons (#3546)

Possibly related PRs

  • Flow-Launcher/Flow.Launcher#3310: Refactors OnNavigatedTo methods in WelcomePage files to use dependency injection and simplify navigation logic, directly related to the changes in this PR.

Suggested reviewers

  • taooceros

Poem

A bunny hopped through settings, quite spry,
Refactored the pages with a keen coder’s eye.
No more sidebar confusion, no more crashy fright,
Now side buttons work, and navigation’s just right.
With each hop and click, the codebase grew neat—
🐇✨ Flow Launcher’s settings are now a treat!
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This comment has been minimized.

Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ forbidden-pattern 22
⚠️ non-alpha-in-dictionary 13

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs (1)

14-15: "Ioc" flagged by spell checker

The static analysis tool flags "Ioc" as an unrecognized word, but this is a common abbreviation for Inversion of Control in dependency injection contexts.

Consider adding "Ioc" to the project's custom dictionary to prevent these spell check warnings in the future.

🧰 Tools
🪛 GitHub Check: Check Spelling

[warning] 15-15:
Ioc is not a recognized word. (unrecognized-spelling)


[warning] 14-14:
Ioc is not a recognized word. (unrecognized-spelling)

🪛 GitHub Actions: Check Spelling

[warning] 14-14: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)


[warning] 15-15: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0e799b and ad94eba.

📒 Files selected for processing (5)
  • Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (1 hunks)
  • Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs (1 hunks)
  • Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs (1 hunks)
  • Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs (1 hunks)
  • Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs
  • Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs
  • Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs
🧰 Additional context used
🧬 Code Graph Analysis (1)
Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs (5)
Flow.Launcher/ViewModel/WelcomeViewModel.cs (1)
  • WelcomeViewModel (5-67)
Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs (1)
  • OnNavigatedTo (13-24)
Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (1)
  • OnNavigatedTo (15-26)
Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs (1)
  • OnNavigatedTo (13-24)
Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs (1)
  • OnNavigatedTo (16-27)
🪛 GitHub Check: Check Spelling
Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

[warning] 13-13:
Ioc is not a recognized word. (unrecognized-spelling)

Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

[warning] 15-15:
Ioc is not a recognized word. (unrecognized-spelling)


[warning] 14-14:
Ioc is not a recognized word. (unrecognized-spelling)

🪛 GitHub Actions: Check Spelling
Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

[warning] 13-13: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)


[warning] 28-28: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)

Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

[warning] 14-14: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)


[warning] 15-15: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (4)
Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs (2)

14-15: Improved initialization pattern with dependency injection

The change from lazy initialization to eager initialization with dependency injection is a good improvement. Making the view model readonly prevents accidental reassignment and ensures consistent state throughout the page lifecycle.

🧰 Tools
🪛 GitHub Check: Check Spelling

[warning] 15-15:
Ioc is not a recognized word. (unrecognized-spelling)


[warning] 14-14:
Ioc is not a recognized word. (unrecognized-spelling)

🪛 GitHub Actions: Check Spelling

[warning] 14-14: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)


[warning] 15-15: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)


19-21: Consistent page number reset during navigation

Moving the page number reset before the initialization check ensures that the page type is always updated correctly regardless of how the navigation was triggered (via buttons or otherwise). This directly addresses the navigation update issue mentioned in the PR objectives.

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (2)

12-13: Improved initialization pattern with dependency injection

Similar to WelcomePage2, this change implements a more robust initialization approach using dependency injection. This pattern is already used elsewhere in this class (line 28 with _translater), making this change consistent with the established code style.

🧰 Tools
🪛 GitHub Check: Check Spelling

[warning] 13-13:
Ioc is not a recognized word. (unrecognized-spelling)

🪛 GitHub Actions: Check Spelling

[warning] 13-13: Spell check warning: Ioc is not a recognized word. (unrecognized-spelling)


17-20: Consistent page number reset during navigation

Moving the page number reset before the initialization check ensures that navigation state is properly maintained. This change, consistent with other welcome pages, directly supports the PR objective of addressing navigation update issues in the settings window.

@jjw24 jjw24 merged commit e80d191 into dev May 16, 2025
13 checks passed
@jjw24 jjw24 deleted the setting_window_navigation_issue branch May 16, 2025 07:03
@jjw24 jjw24 added this to the 1.20.0 milestone May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Mouse side buttons navigation in Settings causes an unhandled exception
2 participants