Skip to content

Add a back button to the onboarding home network step - #6071

Open
RaHehl wants to merge 11 commits into
home-assistant:mainfrom
RaHehl:onboarding-permissions-back
Open

RaHehl wants to merge 11 commits into
home-assistant:mainfrom
RaHehl:onboarding-permissions-back

Conversation

@RaHehl

@RaHehl RaHehl commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

AI Policy

Select exactly one option that describes AI usage in this contribution:

  • I have not used AI for this contribution.
  • AI assistance was used for this contribution.
  • AI fully generated the code for this contribution, but I've reviewed and understood it before submitting and will respond without AI during review.

Summary

After "Most secure", the home network step had no way back. It now has a Back button in the navigation bar, on this step only. Going back restores the previous security level; a location grant or Wi-Fi save arriving afterwards no longer moves the flow on.

The back transition needed a fix: a removed view animates with its last render, so the page being left is redrawn with the back direction first. The direction now lives in the view.

Android counterpart: home-assistant/android#7642. Android keeps "Most secure" selected instead of restoring the level.

Flow map

flowchart TD
    A([Onboarding]) -->|no remote access set up| DIS[Local-only disclaimer]
    A -->|remote access set up| LOC
    DIS --> LOC["Location (first server)<br/>Privacy choices (added server)"]
    LOC -->|server has an HTTPS URL| DONE([Done])
    LOC -->|HTTP URLs only| LA[Local access]
    W([Frontend, HTTP-only server]) -->|location not decided| LOC2[Location]
    W -->|security level not decided| LA
    LOC2 --> LA
    LA -->|Less secure| DONE
    LA -->|Most secure, location denied| LA
    LA -->|Most secure, location allowed| HN[Home network]
    HN -->|Wi-Fi name saved| DONE
    HN ==>|"Back (this PR)"| LA
    linkStyle 12 stroke:#03a9f4,stroke-width:3px
Loading

Tested

# Start Path Back shown Result
1 First server, location allowed Home network → Back → Less secure Home network only Less secure
2 First server, location allowed Home network → Back → Most secure → Wi-Fi name Home network only Most secure, SSID saved, no second location prompt
3 First server, location denied Most secure stays on Local access → Less secure never Less secure
4 Second server Privacy → Local access → Home network → Back → Less secure Home network only Second: Less secure, first server unchanged
5 Frontend, location reset Location → Local access → Home network → Back → Most secure → Wi-Fi name Home network only, Close still there Less → Most secure, other server unchanged

Simulator, result checked in the server settings. The new unit tests fail without their change. The E2E test now goes back once, green in light and dark.

Screenshots

Light Dark
Onboarding, home network Home network, light Home network, dark
Frontend entry (Close and Back) Frontend entry, Close and Back

Back and forward again, light:

ios-back-light.mp4

Dark:

ios-back-dark.mp4

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Split from #6067.

The permissions steps are not on a navigation stack, so a choice could not be revised:
after picking the most secure local access, the home network step could only be left by
entering a network name. Show a back button in the navigation bar from the second step on.
Where the flow is opened from the app with a close button, that button moves to the
trailing edge.
A save that settles after the user went back from the home network step no longer marks
the step as done.
Earlier steps have side effects going back would not undo, such as registering sensors for an additional server. The button now sits in the step content, so the page's navigation bar and the close button of the permissions cover stay as they were.
@RaHehl RaHehl changed the title Add a back button to the onboarding permissions steps Add a back button to the onboarding home network step Oct 15, 2026
bgoncal pushed a commit that referenced this pull request Oct 15, 2026
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## AI Policy
<!-- Please read our AI policy before contributing:
https://developers.home-assistant.io/docs/ai_policy -->
- [x] I have read the [Open Home Foundation AI
Policy](https://developers.home-assistant.io/docs/ai_policy).

Select exactly one option that describes AI usage in this contribution:

- [ ] I have not used AI for this contribution.
- [ ] AI assistance was used for this contribution.
- [x] AI fully generated the code for this contribution, but I've
reviewed and understood it before submitting and will respond without AI
during review.

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
The device name screen has had no way out since #5178. If saving keeps
failing, the app has to be killed.

- Adds a Cancel button.
- A failure before the server is saved no longer waits for the token
revocation and no longer deletes an existing server with the same
instance ID.

Tested in the simulator, including the invitation flow.

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->
Device name


https://github.com/user-attachments/assets/c24ff71c-ced5-45c7-a1ac-38a5f70787ed

Invitation


https://github.com/user-attachments/assets/aa5cc46c-318f-415f-aa2f-a75e10c90078

Second server


https://github.com/user-attachments/assets/df1b5586-845c-4a7a-9fbc-229369834ac1

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
Permissions back button: #6071. Android already has a back button here.
The direction is view state now, set before the page being left is
removed. Back needs the local access choice before the home network step,
and a location grant that arrives after going back no longer moves the
flow on. The tests no longer share the global location permission.
@RaHehl
RaHehl marked this pull request as ready for review October 19, 2026 08:04
Copilot AI balanced review requested due to automatic review settings October 19, 2026 08:04

Copilot AI left a comment

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.

🟡 Changes recommended

A pending Wi-Fi success flag can undo Back navigation and prevent subsequent saves from advancing.

1 open issue
What changed in this PR

Adds a Back button to onboarding’s home-network step so users can revisit their connection security choice.

Changes:

  • Restores the previous security level on Back and guards late callbacks.
  • Updates navigation-bar visibility and transition direction.
  • Adds localized text and back-navigation test coverage.
File Description
Tests/​UI/​OnboardingE2ETests.swift Exercises Back and forward navigation.
Tests/​App/​Onboarding/​OnboardingPermissionsNavigationViewModelTests.swift Tests restoration, callback handling, and Back availability.
Sources/​Shared/​Resources/​Swiftgen/​Strings.swift Adds the generated Back accessor.
Sources/​App/​Resources/​en.lproj/​Localizable.strings Adds the English Back label.
Sources/​App/​Onboarding/​Steps/​Permissions/​OnboardingPermissionsNavigationViewModel.swift Implements Back and callback guards.
Sources/​App/​Onboarding/​Steps/​Permissions/​OnboardingPermissionsNavigationView.swift Adds the button and directional transitions.
Sources/​App/​Onboarding/​Container/​OnboardingNavigationView.swift Enables conditional navigation-bar visibility.
Sources/​App/​Accessibility/​AccessibilityIdentifier.swift Adds the Back button’s test identifier.

Review effort: Balanced

Copilot AI left a comment

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.

🔵 Needs a closer look

Deferred SwiftUI transitions interacting with permission callbacks across multiple entry points warrant final platform-level human review.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.59574% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.11%. Comparing base (7be51e5) to head (cfea625).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...missions/OnboardingPermissionsNavigationView.swift 61.53% 10 Missing ⚠️
...nboarding/Container/OnboardingNavigationView.swift 0.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (76.59%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6071   +/-   ##
=======================================
  Coverage   56.11%   56.11%           
=======================================
  Files        1256     1256           
  Lines       83431    83465   +34     
=======================================
+ Hits        46819    46839   +20     
- Misses      36612    36626   +14     
Files with missing lines Coverage Δ
...ons/OnboardingPermissionsNavigationViewModel.swift 87.70% <100.00%> (+2.81%) ⬆️
...nboarding/Container/OnboardingNavigationView.swift 32.53% <0.00%> (ø)
...missions/OnboardingPermissionsNavigationView.swift 44.91% <61.53%> (+0.47%) ⬆️

... and 15 files with indirect coverage changes

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants