Add support for folders in Watch app#4376
Add support for folders in Watch app#4376joelhawksley wants to merge 22 commits intohome-assistant:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds folder support to the Home Assistant Watch app, allowing users to organize their watch items into collapsible folders for better navigation. This addresses issue #1422 which requested folder organization for the watch app.
Changes:
- Adds a new
foldertype toMagicItem.ItemTypewith nested items support via theitemsproperty - Implements iOS UI for creating, editing, and managing folders in the Watch configuration view
- Implements watchOS UI for navigating into folders and displaying folder contents
- Updates the communication service to properly handle folder items and their children
- Adds comprehensive unit tests for folder management functionality
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/Shared/MagicItem/MagicItem.swift | Adds folder type and items property to support nested folder structure |
| Sources/Shared/MagicItem/MagicItemProvider.swift | Adds folder info provider with folder icon and default name |
| Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationViewModel.swift | Implements folder management methods (add, update, delete, move items) |
| Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationView.swift | Adds UI for creating folders with name input sheet |
| Sources/App/Settings/AppleWatch/HomeCustomization/FolderDetailView.swift | Implements folder content editing view with item management |
| Sources/App/Settings/AppleWatch/HomeCustomization/FolderEditView.swift | Implements folder customization view for icon, colors, and name |
| Sources/Extensions/Watch/Home/WatchHomeView.swift | Adds folder navigation with back button and folder row display |
| Sources/Extensions/Watch/Home/MagicItemRow/WatchFolderRow.swift | Implements Watch folder row UI component with chevron indicator |
| Sources/Extensions/Watch/Home/MagicItemRow/WatchMagicViewRow.swift | Refactors icon color handling for consistency |
| Sources/Watch/WatchCommunicatorService.swift | Updates to send folder and nested item info to Watch, handles folder press events |
| Tests/App/Watch/WatchConfig.test.swift | Adds comprehensive unit tests for folder operations |
| FolderDetailView.swift | Duplicate file in project root (should be removed) |
| HomeAssistant.xcworkspace/contents.xcworkspacedata | Adds workspace file reference (likely unintended) |
| Podfile.lock | Updates HAKit checksum and CocoaPods version (likely unintended) |
| HomeAssistant.xcodeproj/project.pbxproj | Adds new files to Xcode project |
Files not reviewed (1)
- HomeAssistant.xcworkspace/contents.xcworkspacedata: Language not supported
Comments suppressed due to low confidence (2)
FolderDetailView.swift:64
- The project uses SFSafeSymbols for type-safe SF Symbol references. Use systemSymbol parameter instead of systemName with string literals to comply with the coding guidelines and avoid runtime errors from invalid symbol names.
Image(systemName: "line.3.horizontal")
FolderDetailView.swift:77
- The project uses SFSafeSymbols for type-safe SF Symbol references. Use systemSymbol parameter instead of systemName with string literals to comply with the coding guidelines and avoid runtime errors from invalid symbol names.
Image(systemName: "line.3.horizontal")
Sources/Extensions/Watch/Home/MagicItemRow/WatchFolderRow.swift
Outdated
Show resolved
Hide resolved
Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationView.swift
Show resolved
Hide resolved
Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationView.swift
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Looking good! I'll be able to review it on Monday, meanwhile feel free to evaluate Copilots comments and address if necessary. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nto watch-folders
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (1)
Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationView.swift:257
- This passes a hard-coded fallback folder name ("Folder"). Prefer
L10n.Watch.Configuration.Folder.defaultNamefor localization consistency. Also, consider not passingfolderNameas a separate constant—after editing a folder name inFolderEditView,FolderDetailView’s navigation title won’t update because it uses this captured value.
NavigationLink {
FolderDetailView(
folderId: item.id,
folderName: item.displayText ?? "Folder",
viewModel: viewModel
)
Sources/App/Settings/AppleWatch/HomeCustomization/FolderEditView.swift
Outdated
Show resolved
Hide resolved
Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationView.swift
Outdated
Show resolved
Hide resolved
Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationView.swift
Outdated
Show resolved
Hide resolved
Sources/App/Settings/AppleWatch/HomeCustomization/WatchConfigurationView.swift
Outdated
Show resolved
Hide resolved
Sources/App/Settings/AppleWatch/HomeCustomization/FolderDetailView.swift
Show resolved
Hide resolved
…ew.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…rationView.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…rationView.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks @bgoncal! I did a few cleanup rounds with Copilot and verified that things still work locally. I recognize that newbie/AI PRs can be a burden on reviewers, so please let me know if you'd like me to do some more learning before trying to land this change ❤️ |
|
If you have some extra time before Monday, could you check if your changes do not impact database parsing coming from a version of the app without the folder feature? Flow:
Just to be sure it won't fail decoding from SQLite (GRDB) |
|
@bgoncal I am away from my computer until Monday morning. Happy to do that test when I get in 👍 |
bgoncal
left a comment
There was a problem hiding this comment.
I tried the updating flow that I mentioned during the weekend and it looks like all good. Something I noticed is that when you tap the folder on your watch it does not do the push navigation animation, it just changes the view contents to the folder contents without any animation, I think this should be improved as well
| "watch.config.migration_error.failed_create_new_config" = "儲存起始手錶設定失敗,錯誤:%@"; | ||
| "watch.config.migration_error.failed_migrate_actions" = "遷移動作至手錶設定失敗,錯誤:%@"; | ||
| "watch.config.migration_error.failed_to_save" = "儲存新手錶設定失敗,錯誤:%@"; | ||
| "watch.configuration.add_folder.title" = "Add Folder"; |
There was a problem hiding this comment.
Remove all changes to localizable files besides english one. Later on localization will be handled in "Lokalise".
| PODFILE CHECKSUM: 4e98e76c5198159e1291eb551b129c0a38fd0c43 | ||
|
|
||
| COCOAPODS: 1.15.2 | ||
| COCOAPODS: 1.16.2 |
There was a problem hiding this comment.
Remove this file change from the PR
| import Shared | ||
| import SwiftUI | ||
|
|
||
| struct FolderDetailView: View { |
There was a problem hiding this comment.
We use dark mode always for Apple Watch related screens, to mimic what Apple does in the Apple Watch App, please update this view and others in this PR
| } | ||
|
|
||
| private var folderItems: [MagicItem] { | ||
| if let folder = viewModel.watchConfig.items.first(where: { $0.type == .folder && $0.id == folderId }) { |
There was a problem hiding this comment.
Cant you use the computed variable that you have at the top?
| } | ||
|
|
||
| @ViewBuilder | ||
| private var addFolderSheet: some View { |
There was a problem hiding this comment.
This one is currently displaying in light mode as well
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Oh btw I fixed lint issues on your branch but for the future you can use |
Summary
It's pretty unwieldy to navigate a long list of items in the current Watch app. By adding the ability to group items into folders, you can now create a mini dashboard of sorts that is significantly easier to use.
For full disclosure, this was my first time writing Swift and otherwise working with Xcode. I had a lot of help from Claude Opus but did what I could to self-review and test.
Screenshots
demo.mov
Link to pull request in Documentation repository
TODO: I will write docs assuming the UI flow is approved.
Any other notes
Related issue: #1422