Skip to content
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

home: Stop assuming account existence from loading page #1235

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Dec 30, 2024

We could pass realmUrl when initializing the _LoadingPlaceholderPage, but that will still require a check for the existence of the account.

The loading page will be blank when the account does not exist. The user can't easily reach this page because they can only logout from ChooseAccountPage, until we start invalidating API keys. Even then, they will only see the blank page briefly before getting navigated, so we should not show any text at all.

Screenshot

image

Fixes: #1219

@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Dec 30, 2024
@PIG208
Copy link
Member Author

PIG208 commented Dec 30, 2024

Not sure if we still show the loading indicator there, though. This page can be visible for a frame only after #737, but if we don't have the realmUrl, there will potentially be a layout shift as the circular indicator's position is affected by the hidden text.

Because realmUrl probably stays the same for the same accountId, an alternative fix would be caching the realm URL when we first learn about the account, and pass that down. This requires us to know for sure that the account exists at some point, unless we allow the realmUrl to be null for the loading page.

@gnprice
Copy link
Member

gnprice commented Dec 30, 2024

Not sure if we still show the loading indicator there, though. This page can be visible for a frame only after #737, but if we don't have the realmUrl, there will potentially be a layout shift as the circular indicator's position is affected by the hidden text.

Yeah, that's a fine reason to leave out the loading indicator. It's probably less jarring to have it disappear while the page is animating out than to have it suddenly shift while the page is animating out.

Note it's more than a frame — the animation duration for leaving a page is more like 200ms.

@chrisbobbe
Copy link
Collaborator

LGTM, thanks! Marking for Greg's review.

@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Jan 11, 2025
@chrisbobbe chrisbobbe assigned gnprice and unassigned chrisbobbe Jan 11, 2025
@chrisbobbe chrisbobbe requested a review from gnprice January 11, 2025 02:20
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks! The fix looks good. A couple of comments below on the test.

await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
await tester.pumpWidget(const ZulipApp());
await tester.pump(Duration.zero); // wait for the loading page
await tester.pump(loadPerAccountDuration);
Copy link
Member

Choose a reason for hiding this comment

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

What's the role of loadPerAccountDuration here? It doesn't look like anything else in the test refers to it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it is not needed.

Comment on lines 452 to 455
await tester.pump(Duration.zero); // wait for the loading page
await tester.pump(loadPerAccountDuration);

final element = tester.element(find.byType(HomePage));
Copy link
Member

Choose a reason for hiding this comment

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

This test feels like it could easily stop having any effect if something otherwise unrelated changes about the timing of the steps here. It could end up not getting to the loading placeholder at all — or going past it, to the normal contents of HomePage.

How about having it check that it can find a widget with text containing, say, "taking a while"? That should be pretty identifying of the loading page.

Copy link
Member Author

@PIG208 PIG208 Jan 16, 2025

Choose a reason for hiding this comment

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

We can't check for "taking a while" because the text cannot be rendered without the realmUrl. The fix replaced the page with SizedBox.shrink() which doesn't really stand out as a widget to look for. I ended up adding CircularProgressIndicator back instead. It might result in a layout shift as mentioned earlier.

Copy link
Member

Choose a reason for hiding this comment

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

Making the test easier to write is definitely not a good reason to change the actual UX in a way we previously decided we didn't like. 🙂

The SizedBox.shrink() only comes after logging out, right? The step I'm asking for above is to check that we got to the loading placeholder page in the first place, right before logging the user out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I see. Previously the account would finish loading before getting logged out. This setup relies on the behavior that after logging out, the app is briefly brought back to the loading page after removing the PerAccountStore and Account, and stays there until the route is popped from the navigator.

By removing the extra pump, checking it before logging out works.

Looking for another way to check for the alternative loading placeholder page after logging out, I found that we might do something like this without modifying the UX:

      // Missing AppBar title currently only applies to the loading pages,
      // but the check is still somewhat brittle.
      check(tester.widget<AppBar>(find.byType(AppBar))).title.isNull();

      check(tester.widget<SizedBox>(find.byType(SizedBox)))
        ..width.equals(0)
        ..height.equals(0);

For now, I'm pushing a revision that checks for the loading placeholder page before logging out, with the UX restored.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Rereading #1219, it's really about what happens after the normal contents of HomePage have already loaded, and the account subsequently gets logged out. The involvement of _LoadingPlaceholderPage is really just a detail of how the bug happened — there's no reason there needs to be a "loading placeholder" involved in the process of removing an account.

OK, so in order to function as a regression test for that issue, the test should exercise that situation: the data fully loads, and then the account gets logged out. I think that's what an earlier revision of this PR (before last week) did.

But because the issue is about HomePage, not _LoadingPlaceholderPage, there's no need to have it check that a loading page is involved at that point… and it should go outside of the _LoadingPlaceholderPage test group. I think the test group is what confused me earlier — it's a way of saying the test is about _LoadingPlaceholderPage, so I noticed the test didn't really ensure _LoadingPlaceholderPage was involved in what it tested and that seemed like a problem.

In particular, consider what should happen if in the future we change the behavior of HomePage (perhaps via MaterialAccountWidgetRoute) so that when the account gets logged out, the loadingPlaceholderPage doesn't get built — instead it's just an empty page or something. This test will still be doing a useful job by checking that when the user gets logged out from HomePage, there's no crash — effectively checking that that new arrangement doesn't reintroduce this bug. But there's no need for it to complain about the fact that _LoadingPlaceholderPage is no longer present.

This new version of the test, where the loading page is still in place when the user gets logged out, is potentially useful too — so we might as well keep it, in addition to restoring the test that's a more direct regression test for #1219.

@PIG208 PIG208 force-pushed the pr-home branch 2 times, most recently from 21a347c to 1e13482 Compare January 17, 2025 04:11
We could pass realmUrl when initializing the `_LoadingPlaceholderPage`,
but that will still require a check for the existence of the account.

The loading page will be blank when the account does not exist. The user
can't easily reach this page because they can only logout from
`ChooseAccountPage`, until we start invalidating API keys. Even then,
they will only see the blank page briefly before getting navigated, so
we should not show any text at all.

Fixes: zulip#1219

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208
Copy link
Member Author

PIG208 commented Jan 24, 2025

Thanks for the review! Updated the PR by restoring the old version of this test, with a minor tweak that checks that HomePage is fully loaded, and removed the check for loading page after logging out. The new version of the test is kept too.

@PIG208 PIG208 requested a review from gnprice January 24, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui: Incorrect null-check operator in _LoadingPlaceholderPageState.build
3 participants