Finish Home and Phone settings cohesion
This commit is contained in:
@@ -82,6 +82,14 @@ Singleton {
|
|||||||
values.initialized = true;
|
values.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetHomeDefaults(): void {
|
||||||
|
persistTimer.stop();
|
||||||
|
values.favorites = [];
|
||||||
|
values.initialized = false;
|
||||||
|
root.saveError = "";
|
||||||
|
preferencesFile.writeAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
function isSelected(entityId: string): bool {
|
function isSelected(entityId: string): bool {
|
||||||
for (var index = 0; index < values.favorites.length; index++) {
|
for (var index = 0; index < values.favorites.length; index++) {
|
||||||
if (values.favorites[index].id === entityId) {
|
if (values.favorites[index].id === entityId) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ ShellRoot {
|
|||||||
function alias(id: string, value: string): void { HomePreferences.setAlias(id, value); }
|
function alias(id: string, value: string): void { HomePreferences.setAlias(id, value); }
|
||||||
function move(id: string, index: int): void { HomePreferences.move(id, index); }
|
function move(id: string, index: int): void { HomePreferences.move(id, index); }
|
||||||
function remove(id: string): void { HomePreferences.remove(id); }
|
function remove(id: string): void { HomePreferences.remove(id); }
|
||||||
|
function reset(): void { HomePreferences.resetHomeDefaults(); }
|
||||||
function status(): string {
|
function status(): string {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
initialized: HomePreferences.initialized,
|
initialized: HomePreferences.initialized,
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import QtQuick
|
|||||||
import qs.config
|
import qs.config
|
||||||
import qs.services
|
import qs.services
|
||||||
|
|
||||||
Item {
|
SettingsPage {
|
||||||
id: root
|
id: root
|
||||||
objectName: "home-phone-page"
|
objectName: "home-phone-page"
|
||||||
|
title: "Home & Phone"
|
||||||
|
lede: "Choose what appears in Control Center and keep phone continuity close at hand."
|
||||||
|
|
||||||
property string lightQuery: searchInput.text.trim().toLowerCase()
|
property string lightQuery: searchInput.text.trim().toLowerCase()
|
||||||
|
|
||||||
@@ -41,36 +43,6 @@ Item {
|
|||||||
return "Home Assistant is unavailable";
|
return "Home Assistant is unavailable";
|
||||||
}
|
}
|
||||||
|
|
||||||
Flickable {
|
|
||||||
anchors.fill: parent
|
|
||||||
clip: true
|
|
||||||
contentWidth: width
|
|
||||||
contentHeight: content.implicitHeight + 64
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: content
|
|
||||||
width: parent.width - 68
|
|
||||||
x: 34
|
|
||||||
y: 30
|
|
||||||
spacing: 16
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "Home & Phone"
|
|
||||||
color: Theme.fg
|
|
||||||
font.family: Theme.fontFamily
|
|
||||||
font.pixelSize: 27
|
|
||||||
font.weight: Font.DemiBold
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "Choose what appears in Control Center and keep phone continuity close at hand."
|
|
||||||
color: Theme.fgDim
|
|
||||||
font.family: Theme.fontFamily
|
|
||||||
font.pixelSize: Theme.fontSize
|
|
||||||
bottomPadding: 6
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsCard {
|
SettingsCard {
|
||||||
title: "Home Assistant"
|
title: "Home Assistant"
|
||||||
subtitle: root.homeStatus()
|
subtitle: root.homeStatus()
|
||||||
@@ -311,6 +283,4 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
# Settings Home & Phone Completion Implementation Plan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Finish the Home & Phone Settings page on Panama's shared Settings vocabulary and give the global reset path a named, durable Home preference API.
|
||||||
|
|
||||||
|
**Architecture:** `HomePhonePage` adopts `SettingsPage` for the shared scrolling/title/lede scaffold while retaining its specialized catalog, reorder, alias, and phone controls. `HomePreferences.resetHomeDefaults()` becomes the sole Home-store reset boundary: it returns the store to fresh-install state and writes immediately so `SystemSettings.restoreDefaults()` can call it without mutating aliases.
|
||||||
|
|
||||||
|
**Tech Stack:** Quickshell 0.3 QML, QtQuick, Bash contract tests, Hyprland.
|
||||||
|
|
||||||
|
**Spec:** `docs/superpowers/specs/2026-08-17-panama-cohesion-design.md`
|
||||||
|
|
||||||
|
## Global Constraints
|
||||||
|
|
||||||
|
- Do not touch `SystemSettings.qml`, `PreferenceSchema.qml`, keybinds, or Claude's shared row implementations in this branch.
|
||||||
|
- Preserve ordered Home favorites, aliases, first-four Control Center badges, search, drag and keyboard reorder, retry state, Home Assistant status copy, and BlueBubbles availability behavior.
|
||||||
|
- Automated tests must not toggle or dim a real light and must not launch BlueBubbles.
|
||||||
|
- New behavior follows red-green TDD; fixture and state directories remain isolated from the live desktop.
|
||||||
|
- No mock phase and no new visual direction: this is cohesion work against the already-approved design.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Shared Home & Phone page and named reset boundary
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `config/dot/quickshell/config/HomePreferences.qml`
|
||||||
|
- Modify: `config/dot/quickshell/home-preferences-harness.qml`
|
||||||
|
- Modify: `config/dot/quickshell/modules/settings/HomePhonePage.qml`
|
||||||
|
- Modify only if required for shared vocabulary compatibility: `config/dot/quickshell/modules/settings/HomeFavoriteCard.qml`
|
||||||
|
- Modify only if required for shared vocabulary compatibility: `config/dot/quickshell/modules/settings/AvailableLightRow.qml`
|
||||||
|
- Modify: `tests/quickshell/home-preferences-contract.sh`
|
||||||
|
- Modify: `tests/quickshell/home-phone-settings-contract.sh`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: `SettingsPage { title; lede; default content }`, existing `SettingsCard`, `SettingRow`, `ActionRow`, `TextRow`, `HomeAssistant`, `SystemSettings.bluebubblesAvailable`, and writable `HomePreferences` adapter state.
|
||||||
|
- Produces: `HomePreferences.resetHomeDefaults(): void`, which sets `favorites` to `[]`, sets `initialized` to `false`, clears stale save error state, and invokes `preferencesFile.writeAdapter()` immediately after stopping the debounce timer.
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write failing contracts**
|
||||||
|
|
||||||
|
Add `reset()` to the isolated `home-pref-test` IPC harness. Extend `home-preferences-contract.sh` to seed aliases/order, invoke reset, and require both IPC state and `panama-home.json` to become exactly `{"initialized":false,"favorites":[]}` without waiting for the 180 ms debounce interval. Extend `home-phone-settings-contract.sh` to require `SettingsPage {`, `title: "Home & Phone"`, and the existing lede through `lede:`, while rejecting the copied root `Flickable` scaffold.
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run contracts to verify RED**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tests/quickshell/home-preferences-contract.sh
|
||||||
|
tests/quickshell/home-phone-settings-contract.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: the preference contract fails because `reset` is missing; the page contract fails because the page still owns a copied `Flickable` scaffold.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Implement the reset API and shared page scaffold**
|
||||||
|
|
||||||
|
Implement this public boundary in `HomePreferences.qml`:
|
||||||
|
|
||||||
|
```qml
|
||||||
|
function resetHomeDefaults(): void {
|
||||||
|
persistTimer.stop();
|
||||||
|
values.favorites = [];
|
||||||
|
values.initialized = false;
|
||||||
|
root.saveError = "";
|
||||||
|
preferencesFile.writeAdapter();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the `HomePhonePage` root `Item` plus nested `Flickable`/title/lede scaffold with:
|
||||||
|
|
||||||
|
```qml
|
||||||
|
SettingsPage {
|
||||||
|
id: root
|
||||||
|
objectName: "home-phone-page"
|
||||||
|
title: "Home & Phone"
|
||||||
|
lede: "Choose what appears in Control Center and keep phone continuity close at hand."
|
||||||
|
// Existing SettingsCard content remains in order.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Use shared `ActionRow` or `TextRow` only where their single-action/read-only contracts preserve all current status and accessibility behavior. Keep specialized rows when the shared primitive would lose information.
|
||||||
|
|
||||||
|
- [ ] **Step 4: Run focused contracts to GREEN**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tests/quickshell/home-preferences-contract.sh
|
||||||
|
tests/quickshell/home-phone-settings-contract.sh
|
||||||
|
tests/quickshell/settings-pages-contract.sh
|
||||||
|
tests/quickshell/settings-rows-contract.sh
|
||||||
|
tests/quickshell/settings-commit-reset-contract.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: every command exits 0; no test launches BlueBubbles or changes a real Home Assistant entity.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Commit**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add config/dot/quickshell/config/HomePreferences.qml \
|
||||||
|
config/dot/quickshell/home-preferences-harness.qml \
|
||||||
|
config/dot/quickshell/modules/settings/HomePhonePage.qml \
|
||||||
|
config/dot/quickshell/modules/settings/HomeFavoriteCard.qml \
|
||||||
|
config/dot/quickshell/modules/settings/AvailableLightRow.qml \
|
||||||
|
tests/quickshell/home-preferences-contract.sh \
|
||||||
|
tests/quickshell/home-phone-settings-contract.sh \
|
||||||
|
docs/superpowers/plans/2026-08-18-settings-home-phone-completion.md
|
||||||
|
git commit -m "Finish Home and Phone settings cohesion"
|
||||||
|
```
|
||||||
@@ -80,8 +80,12 @@ system_settings="$repo_dir/config/dot/quickshell/services/SystemSettings.qml"
|
|||||||
[[ -f "$home_page" ]] || fail 'HomePhonePage.qml is missing'
|
[[ -f "$home_page" ]] || fail 'HomePhonePage.qml is missing'
|
||||||
[[ -f "$favorite_card" ]] || fail 'HomeFavoriteCard.qml is missing'
|
[[ -f "$favorite_card" ]] || fail 'HomeFavoriteCard.qml is missing'
|
||||||
[[ -f "$available_row" ]] || fail 'AvailableLightRow.qml is missing'
|
[[ -f "$available_row" ]] || fail 'AvailableLightRow.qml is missing'
|
||||||
assert_contains 'text: "Home & Phone"' "$home_page"
|
assert_contains 'SettingsPage {' "$home_page"
|
||||||
assert_contains 'text: "Choose what appears in Control Center and keep phone continuity close at hand."' "$home_page"
|
assert_contains 'title: "Home & Phone"' "$home_page"
|
||||||
|
assert_contains 'lede: "Choose what appears in Control Center and keep phone continuity close at hand."' "$home_page"
|
||||||
|
if rg -q '^\s*Flickable \{' "$home_page"; then
|
||||||
|
fail 'HomePhonePage.qml still owns a copied Flickable scaffold'
|
||||||
|
fi
|
||||||
assert_contains 'Connected · ' "$home_page"
|
assert_contains 'Connected · ' "$home_page"
|
||||||
assert_contains 'Last update unavailable · showing saved controls' "$home_page"
|
assert_contains 'Last update unavailable · showing saved controls' "$home_page"
|
||||||
assert_contains 'Authentication required' "$home_page"
|
assert_contains 'Authentication required' "$home_page"
|
||||||
|
|||||||
@@ -83,6 +83,21 @@ wait_for_file_content() {
|
|||||||
fail 'preferences file did not contain the complete atomic update'
|
fail 'preferences file did not contain the complete atomic update'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_for_reset_file_content() {
|
||||||
|
local expected='{"initialized":false,"favorites":[]}'
|
||||||
|
local state_file=""
|
||||||
|
|
||||||
|
for _ in $(seq 1 18); do
|
||||||
|
state_file="$(find "$state_home" -name panama-home.json -print -quit)"
|
||||||
|
if [[ -n "$state_file" ]] \
|
||||||
|
&& jq -e --argjson expected "$expected" '. == $expected' "$state_file" >/dev/null; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep 0.01
|
||||||
|
done
|
||||||
|
fail 'reset did not persist the default Home state before the debounce interval'
|
||||||
|
}
|
||||||
|
|
||||||
# A leading JSON whitespace prevents qs from expanding the array into IPC
|
# A leading JSON whitespace prevents qs from expanding the array into IPC
|
||||||
# positional arguments; JSON.parse() intentionally accepts that whitespace.
|
# positional arguments; JSON.parse() intentionally accepts that whitespace.
|
||||||
initial_ids=' ["light.kitchen","light.hall","light.desk"]'
|
initial_ids=' ["light.kitchen","light.hall","light.desk"]'
|
||||||
@@ -90,6 +105,7 @@ expected='{"initialized":true,"favorites":[{"id":"light.desk","alias":""},{"id":
|
|||||||
expected_file='{"initialized":true,"favorites":[{"id":"light.desk","alias":""},{"id":"light.kitchen","alias":"Island"}]}'
|
expected_file='{"initialized":true,"favorites":[{"id":"light.desk","alias":""},{"id":"light.kitchen","alias":"Island"}]}'
|
||||||
empty_expected='{"initialized":true,"favorites":[],"saveError":""}'
|
empty_expected='{"initialized":true,"favorites":[],"saveError":""}'
|
||||||
empty_file='{"initialized":true,"favorites":[]}'
|
empty_file='{"initialized":true,"favorites":[]}'
|
||||||
|
reset_expected='{"initialized":false,"favorites":[],"saveError":""}'
|
||||||
|
|
||||||
start_harness
|
start_harness
|
||||||
qs_for_harness ipc call home-pref-test initialize "$initial_ids" >/dev/null
|
qs_for_harness ipc call home-pref-test initialize "$initial_ids" >/dev/null
|
||||||
@@ -99,9 +115,20 @@ qs_for_harness ipc call home-pref-test remove light.hall >/dev/null
|
|||||||
wait_for_status "$expected"
|
wait_for_status "$expected"
|
||||||
wait_for_file_content "$expected_file"
|
wait_for_file_content "$expected_file"
|
||||||
|
|
||||||
|
qs_for_harness ipc call home-pref-test reset >/dev/null
|
||||||
|
wait_for_status "$reset_expected"
|
||||||
|
wait_for_reset_file_content
|
||||||
|
|
||||||
stop_harness
|
stop_harness
|
||||||
start_harness
|
start_harness
|
||||||
|
wait_for_status "$reset_expected"
|
||||||
|
|
||||||
|
qs_for_harness ipc call home-pref-test initialize "$initial_ids" >/dev/null
|
||||||
|
qs_for_harness ipc call home-pref-test alias light.kitchen ' Island ' >/dev/null
|
||||||
|
qs_for_harness ipc call home-pref-test move light.desk 0 >/dev/null
|
||||||
|
qs_for_harness ipc call home-pref-test remove light.hall >/dev/null
|
||||||
wait_for_status "$expected"
|
wait_for_status "$expected"
|
||||||
|
wait_for_file_content "$expected_file"
|
||||||
|
|
||||||
qs_for_harness ipc call home-pref-test remove light.desk >/dev/null
|
qs_for_harness ipc call home-pref-test remove light.desk >/dev/null
|
||||||
qs_for_harness ipc call home-pref-test remove light.kitchen >/dev/null
|
qs_for_harness ipc call home-pref-test remove light.kitchen >/dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user