Conversation
Adds missing context.mounted checks across async gaps in several files to prevent potential runtime crashes when widgets are unmounted while async operations are pending. This improves the overall reliability of the application and clears analyzer warnings. Co-authored-by: insign <1113045+insign@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e37c0723e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!changed || !wasActiveProject) { | ||
| return; | ||
| } | ||
| if (!mounted) return; |
There was a problem hiding this comment.
Keep chat scope sync even if page unmounts during close
_closeProjectContext now returns when mounted is false before calling ChatProvider.onProjectScopeChanged(). If the async closeProject call completes after the chat page is disposed (for example, user closes a project then quickly navigates away), the project context changes but chat state is never switched, leaving ChatProvider on the previous scope until some later manual refresh. This regression is specific to the new guard and can cause stale sessions/models after closing the active project.
Useful? React with 👍 / 👎.
|
_closeProjectContext now returns when mounted is false before calling ChatProvider.onProjectScopeChanged(). If the async closeProject call completes after the chat page is disposed (for example, user closes a project then quickly navigates away), the project context changes but chat state is never switched, leaving ChatProvider on the previous scope until some later manual refresh. This regression is specific to the new guard and can cause stale sessions/models after closing the active project. |
You're absolutely right, returning early on |
Refactors the async gap fix in `_closeProjectContext` to capture the `ChatProvider` reference prior to the async call. This resolves the issue where skipping state synchronization when unmounted caused stale chat state if the user closed a project and navigated away quickly. Co-authored-by: insign <1113045+insign@users.noreply.github.com>
This PR adds missing
context.mountedchecks after asynchronous operations to prevent potential runtime crashes caused by unmounted widgets. By ensuring we do not operate on invalid contexts, this change improves application stability and resolvesuse_build_context_synchronouslyanalyzer warnings.Changes:
lib/presentation/pages/chat_page/chat_page_workspace_controller.dart: Addedif (!mounted) return;check in_closeProjectContext.lib/presentation/pages/settings/sections/about_settings_section.dart: Replacedif (!mounted)withif (!context.mounted)to properly guard passed BuildContexts in_triggerOnboardingTourand_confirmResetApp.lib/presentation/widgets/chat_message/chat_message_text_part.dart: Addedif (!context.mounted) return;before calling_showLinkOpenFeedbackafterawait launchUrl(...).The
make checksuite confirms that tests pass and the number of analyzer issues has dropped as a result of these fixes.PR created automatically by Jules for task 75362650297974914 started by @insign