Skip to content

Miduo/224 optimize login latecy#225

Open
Miduo666 wants to merge 2 commits intoanusii:devfrom
Miduo666:miduo/224_optimize_login_latecy
Open

Miduo/224 optimize login latecy#225
Miduo666 wants to merge 2 commits intoanusii:devfrom
Miduo666:miduo/224_optimize_login_latecy

Conversation

@Miduo666
Copy link
Contributor

@Miduo666 Miduo666 commented Mar 2, 2026

Pull Request Details

What issue does this PR address

  • [Description]

Associated Issue

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist

Complete the check-list below to ensure your branch is ready for PR.

  • Screenshots included in linked issue #
  • Changes adhere to the style and coding guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules
  • The update contains no confidential information
  • The update has no duplicated content
  • No lint check errors are related to these changes (make prep or flutter analyze lib)
  • Integration test dart test output or screenshot included in issue #
  • I tested the PR on these devices:
    • Android
    • iOS
    • Linux
    • MacOS
    • Windows
    • Web
  • I have identified reviewers
  • The PR has been approved by reviewers

Finalising

Once PR discussion is complete and reviewers have approved:

  • Merge dev into the this branch
  • Resolve any conflicts
  • Add a one line summary into the CHANGELOG.md
  • Push to the git repository and review
  • Merge the PR into dev

@gjwgit
Copy link
Contributor

gjwgit commented Mar 5, 2026

Thanks @Miduo666.

Please fix the conflict and merge the latest dev.

Ask copilot to review.

@Miduo666
Copy link
Contributor Author

Miduo666 commented Mar 6, 2026

Thanks @Miduo666.

Please fix the conflict and merge the latest dev.

Ask copilot to review.

Hi @gjwgit
I'm currently having issues requesting Copilot for the PR. Could you please trigger the Copilot review on your end?

Also, just a quick heads-up: the code depends on the new solidpod package (which is still in PR). Copilot might throw an error like The named parameter 'wasAlreadyLoggedIn' isn't defined. because it hasn't seen the updated definitions in the pending package PR yet

@Miduo666
Copy link
Contributor Author

Miduo666 commented Mar 6, 2026

Also I can not request Copilot in Solidpod and Solid_auth

Copy link

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

Optimizes the SolidUI login flow to reduce redundant work during authentication and to avoid blocking the initial UI while login assets/app metadata are being resolved (issue #224).

Changes:

  • Passes precomputed login status into solidAuthenticate() to avoid repeating isUserLoggedIn() work.
  • Removes the “wait for assets to resolve” loading gate and triggers a rebuild once higher-quality assets are resolved.
  • Parallelizes package info + default folder/file generation and consolidates into a single setState().

Reviewed changes

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

File Description
lib/src/widgets/solid_login_auth_handler.dart Avoids redundant login-state work by forwarding wasAlreadyLoggedIn into solidAuthenticate().
lib/src/widgets/solid_login.dart Improves perceived latency by not blocking first paint, and reduces init time via parallel async work + single rebuild.
Comments suppressed due to low confidence (1)

lib/src/widgets/solid_login.dart:340

  • effectiveImage falls back to widget.image while asset resolution is still in progress. If the caller provides an AssetImage path that is not in the bundle (the case this resolver is designed to handle), Flutter will attempt to load that missing asset during the first frame and emit an image loading exception (and may show a broken image) before _resolvedImage is set. Consider using a known-good placeholder (e.g., SolidConfig.soliduiDefaultImage) until _resolvedImage is available, or otherwise ensuring the initial image load cannot reference a missing asset (e.g., via an errorBuilder-based Image widget rather than DecorationImage).
    // Use resolved image if available, otherwise fall back to the widget's
    // own AssetImage immediately — this prevents the UI being blocked by a
    // loading spinner while assets are resolving in the background.

    final effectiveImage = _resolvedImage ?? widget.image;

    // The login box's default image Widget for the left/background panel
    // depending on screen width.

    final loginBoxDecor = BoxDecoration(
      image: DecorationImage(image: effectiveImage, fit: BoxFit.cover),
    );

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

Comment on lines +270 to 287
// Start fetching app info immediately — it is independent of appDirName.
final appInfoFuture = getAppNameVersion();
await setAppDirName(widget.appDirectory);
final folders = await generateDefaultFolders();
final files = await generateDefaultFiles();
// Now that appDirName is set, resolve folders/files in parallel with the
// already-running appInfo future.
final results = await Future.wait([
generateDefaultFolders(),
generateDefaultFiles(),
appInfoFuture,
]);
final customFolders = generateCustomFolders(widget.customFolderPathList);
if (!mounted) return;
// Single setState: avoids two separate widget rebuilds.
setState(() {
defaultFolders = folders + customFolders;
defaultFiles = files;
});
final appInfo = await getAppNameVersion();
if (!mounted) return;
setState(() {
defaultFolders = (results[0] as List<String>) + customFolders;
defaultFiles = results[1] as Map<dynamic, dynamic>;
final appInfo = results[2] as ({String name, String version});
appName = appInfo.name;
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Using Future.wait([...]) with heterogeneous futures forces the results into a positional List and requires runtime casts by index (results[0] as ...). This is brittle and can silently break if any return type changes. A more maintainable approach is to start the typed futures (final foldersFuture = ..., etc.), await Future.wait<void>([foldersFuture, filesFuture, appInfoFuture]), and then read the typed results from the original futures/variables.

Copilot uses AI. Check for mistakes.
Comment on lines +390 to 393
// Use resolved logo if available, otherwise fall back to widget's own logo.

final effectiveLogo = _resolvedLogo ?? SolidConfig.soliduiDefaultLogo;
final effectiveLogo = _resolvedLogo ?? widget.logo;

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

effectiveLogo also falls back to widget.logo before _resolvedLogo is computed. If widget.logo points to a missing asset, the first build can trigger an image loading exception before the resolver falls back to the solidui defaults. Consider using a guaranteed-existing placeholder until _resolvedLogo is set (or ensure missing assets are handled without throwing during the initial frame).

Copilot uses AI. Check for mistakes.
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