Skip to content

Implement Compose-based Error Panel, Error UI Model, and Tests for Comments#12404

Merged
theimpulson merged 15 commits intoTeamNewPipe:refactorfrom
SttApollo:Create_CommentSection_ErrorPanel
Oct 7, 2025
Merged

Implement Compose-based Error Panel, Error UI Model, and Tests for Comments#12404
theimpulson merged 15 commits intoTeamNewPipe:refactorfrom
SttApollo:Create_CommentSection_ErrorPanel

Conversation

@SttApollo
Copy link
Copy Markdown

@SttApollo SttApollo commented Jul 2, 2025

What is it?

  • Feature (user facing)
  • Codebase improvement (dev facing)

Description of the changes in your PR

  • Created a new Compose-based ErrorPanel component.
  • Ensured the new error panel is fully theme-adaptive using MaterialTheme.colorScheme and that all text is centered for visual parity with the legacy design.
  • Introduced a new ErrorPanelSpec data class to flexibly describe error panel content and actions.
  • Created ErrorUiModel interface to represent different failure states along with UnableToLoadCommentsUiModel specific to Comments section.
  • Added a focused test suite: Unit tests for ErrorUiModel and Integration tests for the two main error states in the comment section: Resource.Error (initial load failure) and LoadState.Error (paging failure). Would add Compose testing with approval to add a new dependency.
  • Manual Testing: Verified error handling by forcing errors in both CommentsViewModel (Resource.Error) and CommentsSource (LoadState.Error) to ensure proper UI rendering and error model mapping.

Before/After Screenshots/Screen Record

Before After
Before After

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

@github-actions github-actions Bot added the size/large PRs with less than 750 changed lines label Jul 2, 2025
@SttApollo
Copy link
Copy Markdown
Author

@Stypox Apologies for the fairly large diff—thought it would make sense to add a new Compose-based ErrorPanel and have it wired up end-to-end as a first step towards migration. I’m happy to split it up or tweak anything to fit the overall architecture—just let me know!

@ShareASmile ShareASmile added GUI Issue is related to the graphical user interface comments Anything to do with comments and comment replies under videos/audios rewrite Issues and PRs related to rewrite labels Jul 3, 2025
@github-project-automation github-project-automation Bot moved this to In Progress in Rewrite Jul 3, 2025
Copy link
Copy Markdown
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Thank you! I think this PR is the right size, and also you wrote many tests which increase the "PR line count" but do not add reviewing complexity, so there is no need to split it. And thanks for also writing test! I left a few comments to try to make the code more general so it can be used more seamlessly in other places in the app in the future (to replace other error panels in various places).

Comment thread app/src/main/java/org/schabi/newpipe/ui/components/common/ErrorPanel.kt Outdated
Comment thread app/src/main/java/org/schabi/newpipe/ui/components/common/ErrorPanel.kt Outdated
Comment thread app/src/main/java/org/schabi/newpipe/paging/CommentsSource.kt Outdated
@SttApollo
Copy link
Copy Markdown
Author

@Stypox I have incorporated your requests - removed the other files and just added one test file. Also I didn't want to add an additional dependency for compose testing but please let me know if you'd like me to!

@ShareASmile ShareASmile added the ready for review Most of the work is done, PR is now ready for a review label Jul 30, 2025
Comment thread app/src/main/java/org/schabi/newpipe/ui/components/common/ErrorPanel.kt Outdated
Comment thread app/src/main/java/org/schabi/newpipe/paging/CommentsSource.kt Outdated
Comment thread app/src/main/java/org/schabi/newpipe/ui/components/common/ErrorPanel.kt Outdated
@absurdlylongusername
Copy link
Copy Markdown
Member

absurdlylongusername commented Aug 12, 2025

@Stypox I have incorporated your requests - removed the other files and just added one test file. Also I didn't want to add an additional dependency for compose testing but please let me know if you'd like me to!

@SttApollo Tbh I have no qualms with you adding compose testing, because we are going to be adding UI tests very soon anyway. Currently we have no UI tests whatsoever, and I don't really see a downside to having tests for new functionality.

@Stypox, thoughts?

@Stypox
Copy link
Copy Markdown
Member

Stypox commented Aug 12, 2025

Yeah it would be cool if you added some tests! Would you be ok with opening a new PR after this one is merged, to setup the UI tests infrastructure and add tests for what you added in this PR? Otherwise you can also add UI tests in this PR, let us know what you prefer :-)

@SttApollo
Copy link
Copy Markdown
Author

Sure, I can open a new PR after this one is merged. For the UI test infra, I was thinking we could start with Compose instrumented testing—does that align with what you had in mind? Or should we also add Robolectric-based Compose tests and/or snapshot testing early on?

@Stypox Stypox force-pushed the Create_CommentSection_ErrorPanel branch from 98b3a7f to c9fab2b Compare September 4, 2025 14:41
@Stypox Stypox force-pushed the Create_CommentSection_ErrorPanel branch from c9fab2b to e27c7ed Compare September 5, 2025 11:38
SttApollo and others added 7 commits September 23, 2025 09:40
…rPanel.kt

Co-authored-by: Isira Seneviratne <31027858+Isira-Seneviratne@users.noreply.github.com>
…nt/CommentSection.kt

Co-authored-by: Isira Seneviratne <31027858+Isira-Seneviratne@users.noreply.github.com>
…nt/CommentSection.kt

Co-authored-by: Isira Seneviratne <31027858+Isira-Seneviratne@users.noreply.github.com>
- Moved from androidTest to test directory
- Removed Android test runner dependencies
- Renamed to CommentSectionErrorTest
- Addresses PR feedback until Compose testing is in place
Copy link
Copy Markdown
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you! I pushed two commits for correctly handling Locale-based ContextCompat.getString() in @Previews (otherwise some previews wouldn't be shown for me), and reordered the buttons to Recaptcha/Report, Retry, OpenInBrowser.

@Stypox
Copy link
Copy Markdown
Member

Stypox commented Oct 1, 2025

@absurdlylongusername feel free to merge if you are also ok with the changes, and then add the PR title + number to the 0.28.1 draft release :-)

@TobiGr
Copy link
Copy Markdown
Contributor

TobiGr commented Oct 1, 2025

Not to the 0.28.1 draft, but the refactor one, please :)

@absurdlylongusername
Copy link
Copy Markdown
Member

Hi @SttApollo, sorry for late response.

Thanks for your work thus far.

I can add Compose tests in a follow-up PR, or include them here if you prefer.

I'd prefer them to be in this PR, but ultimately up to you which you want: I just want them to be done ASAP. Ideally I don't want them being in a different PR to delay them being done, so I'm hoping you would have already started working on them, but if not then I guess it doesn't matter lol.


Just to confirm I understand the purpose of this PR: the purpose is to add an error panel specifically for the comments section as stated in #11716, right? The ErrorPanel.kt that was added is not intended to replace the existing error_panel.xml at a later date, is it? Because if so, it doesn't have the same structure (i.e. error_panel.xml has three text fields as you can see in the image, but ErrorPanel.kt only has one)

Error panel preview image

I was thinking we could start with Compose instrumented testing—does that align with what you had in mind?

This is fine. Would you be testing just ErrorPanel and CommentSection, or would you also plan to add higher level integration tests that replicate what is done for manual testing?


Was also going to suggest improving the ErrorPanel previews so that they show all the buttons, or have multiple previews for each expected code path; but @Stypox has just done that.

I'd also suggest having a preview for light and dark mode like we have in many other places.

I.e. adding this to ErrorPanel preview

@Preview(
    name = "Light mode",
    showBackground = true,
    uiMode = Configuration.UI_MODE_NIGHT_NO
)
@Preview(
    name = "Dark mode",
    showBackground = true,
    uiMode = Configuration.UI_MODE_NIGHT_YES
)

@absurdlylongusername absurdlylongusername changed the title Implement Compose-based Error Panel , Error UI Model , and Tests for Comments Implement Compose-based Error Panel, Error UI Model, and Tests for Comments Oct 1, 2025
@Stypox
Copy link
Copy Markdown
Member

Stypox commented Oct 1, 2025

@absurdlylongusername this is meant to completely replace error_panel.xml. It only has one text field, yes, but that's to reflect the fact that now the error message is chosen by the ErrorInfo instead of by the UI. Sure, we could add "getMainMessage()", "getSubmessage()", etc. to ErrorInfo, but I don't think it's worth it (the second and third lines of text were only used for a couple of errors even before).

@SttApollo
Copy link
Copy Markdown
Author

SttApollo commented Oct 1, 2025

@absurdlylongusername

I'd prefer them to be in this PR, but ultimately up to you which you want: I just want them to be done ASAP. Ideally I don't want them being in a different PR to delay them being done, so I'm hoping you would have already started working on them, but if not then I guess it doesn't matter lol.

Yes np, I'll add them to this PR in the next day or two.

Just to confirm I understand the purpose of this PR: the purpose is to add an error panel specifically for the comments section as stated in #11716, right? The ErrorPanel.kt that was added is not intended to replace the existing error_panel.xml at a later date, is it? Because if so, it doesn't have the same structure (i.e. error_panel.xml has three text fields as you can see in the image, but ErrorPanel.kt only has one)

It is intendend to replace the xml in the future as Stypox mentioned.

I was thinking we could start with Compose instrumented testing—does that align with what you had in mind?
This is fine. Would you be testing just ErrorPanel and CommentSection, or would you also plan to add higher level integration tests that replicate what is done for manual testing?

This is my plan so far

  1. Compose tests for ErrorPanel: render the panel with sample data representing each path network error, retryable error, ReCaptcha, and assert the right text and buttons are visible.
  2. Comments screen instrumentation test: launch the comments UI on device/emulator, run through load, scroll, retry, and ReCaptcha so it mirrors the manual check.

Was also going to suggest improving the ErrorPanel previews so that they show all the buttons, or have multiple previews for each expected code path; but @Stypox has just done that.
I'd also suggest having a preview for light and dark mode like we have in many other places.

Yes, will add this too.

@absurdlylongusername
Copy link
Copy Markdown
Member

@SttApollo @Stypox Okay cool, fantastic

@absurdlylongusername
Copy link
Copy Markdown
Member

@absurdlylongusername this is meant to completely replace error_panel.xml. It only has one text field, yes, but that's to reflect the fact that now the error message is chosen by the ErrorInfo instead of by the UI. Sure, we could add "getMainMessage()", "getSubmessage()", etc. to ErrorInfo, but I don't think it's worth it (the second and third lines of text were only used for a couple of errors even before).

Is there an issue currently to track replacing errorpanel.xml in the rest of the code?

@Stypox
Copy link
Copy Markdown
Member

Stypox commented Oct 2, 2025

Is there an issue currently to track replacing errorpanel.xml in the rest of the code?

No, because we want to replace every *.xml with Compose code, and we can't open 1000 issues for each XML file xD

But maybe this is a special case, where it would make sense to have an issue lying around that can be worked on. But what I think makes more sense is to just use the Compose error panel whenever converting a screen to Compose (I included this in #12674 for lists).

@absurdlylongusername
Copy link
Copy Markdown
Member

@Stypox

No, because we want to replace every *.xml with Compose code, and we can't open 1000 issues for each XML file xD

Touché, lol.

just use the Compose error panel whenever converting a screen to Compose

Yeah I'm more talking about noting this down somewhere so that it is documented. Idk where though.

@github-actions github-actions Bot added size/giant PRs with more than 750 changed lines and removed size/large PRs with less than 750 changed lines labels Oct 4, 2025
@SttApollo
Copy link
Copy Markdown
Author

@absurdlylongusername I ended up adding an inline TestCommentSection helper in CommentSectionInstrumentedTest instead of pulling in additional mock libraries, lmk if this approach works!

@SttApollo SttApollo force-pushed the Create_CommentSection_ErrorPanel branch from 245ef89 to 9d3ac1b Compare October 4, 2025 21:14
Comment thread app/src/main/java/org/schabi/newpipe/ui/components/common/ServiceColoredButton.kt Outdated
Comment thread app/src/main/java/org/schabi/newpipe/util/Localization.java
@SttApollo SttApollo force-pushed the Create_CommentSection_ErrorPanel branch from 3c748e8 to a31c26e Compare October 6, 2025 15:45
@absurdlylongusername
Copy link
Copy Markdown
Member

@SttApollo You seem to have reverted @Stypox's changes in aed4278.

Please restore them.

@SttApollo SttApollo force-pushed the Create_CommentSection_ErrorPanel branch 2 times, most recently from e56fc4b to 25e96d5 Compare October 6, 2025 21:55
@theimpulson
Copy link
Copy Markdown
Member

LTGM!

@theimpulson theimpulson merged commit 6e0b7be into TeamNewPipe:refactor Oct 7, 2025
5 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Rewrite Oct 7, 2025
@ShareASmile ShareASmile removed the ready for review Most of the work is done, PR is now ready for a review label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Anything to do with comments and comment replies under videos/audios GUI Issue is related to the graphical user interface rewrite Issues and PRs related to rewrite size/giant PRs with more than 750 changed lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants