diff --git a/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/done.md b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/done.md new file mode 100644 index 00000000..fa6847b1 --- /dev/null +++ b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/done.md @@ -0,0 +1,48 @@ +# Done + +- **Branch / head SHA**: `alanvardy-var-1179-make-an-rd-fish-function` @ + `75b392ac` (`chore: record implement artifacts for VAR-1179`); in sync with + `origin` (`git rev-list --left-right --count HEAD...origin/...` → `0 0`). + HEAD is rebased on `main` (`46844600`); no conflicts were present. + Phase 2 (`rd.fish`) is on dotfiles `main` @ `1ba21e5` — not on this branch. + +- **Mechanical checks** (all pass, shell-only diff): + - `bash -n scripts/run-devices.sh` — OK + - `bash -n scripts/test-run-devices.sh` — OK + - `shellcheck -S warning --exclude=SC1111 scripts/run-devices.sh` — OK + - `shellcheck -S warning --exclude=SC1111 scripts/test-run-devices.sh` — OK + - `bash scripts/test-run-devices.sh` — all pass, including the two new duo + filter assertions and the happy/sad duo flow cases. + - No warnings flagged. The full iOS gate was not re-run here: the diff is + shell-only and `scripts/test-run-devices.sh` is not wired into + `scripts/test.sh`; the plan's post-plan gate remains the regression check. + +- **Review outcome**: one bounded `reviewer` pass over the full diff + dotfiles + wrapper. **No blockers, no fixes worth doing now.** Verified independently: + env-parse ordering/opt-back-in is sound under `set -euo pipefail`; duo reuses + the Duo-only discovery filter and the `!= "sim"` zero-device fail-fast; + sim/watch/macOS legs are skipped; summary and toast never mislabel the leg or + print `0 simulator(s)`; the new negative assertions are non-vacuous (their + grepped strings exist in `run-devices.sh`). + - Optional improvements applied at the user's request: + (1) duo-mode no-device errors now read "No reachable iPhone Duo found." + and the `RUN_MAC=1` hint says "no reachable iPhone Duo found" — the shared + `iPhone/iPad` wording was actively misleading in duo mode, which filters + out a paired regular iPhone (`run-devices.sh:286-298`); the sad-path flow + test asserts the new string. (2) added `duo toast omits the simulator + count`, closing the regression gap where `and 0 simulator(s)` could return + unnoticed. Both validated with `bash -n`, `shellcheck -S warning + --exclude=SC1111`, and `bash scripts/test-run-devices.sh` (EXIT=0, 0 + failures). + - Optional items left as-is (intentional per plan): the "no physical iPhone + Duo found" notice remains `== "sim"` only; `IOS_TARGET=duo RUN_MAC=1` with + no Duo still runs macOS (now with the Duo-specific hint from #1). + +- **Remaining manual items**: the plan's on-device checks were not exercised + (no physical Duo in this session) — with the Duo paired/reachable, + `IOS_TARGET=duo ./scripts/run-devices.sh` should build/install/launch only + the Duo and print `iPhone Duo (device): 1/1 launched, 0 unreachable`; with no + Duo it should exit non-zero without touching sim/watch/macOS; and + `IOS_TARGET=duo RUN_WATCH=1 RUN_MAC=1` should re-enable those legs + (plan.md Verification → Manual). Post-plan gate (`./scripts/test.sh` via the + `run-gate` skill) is still outstanding if a regression check is wanted. diff --git a/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/implement.md b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/implement.md new file mode 100644 index 00000000..4d63484c --- /dev/null +++ b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/implement.md @@ -0,0 +1,66 @@ +# Implementation Summary + +## Commits +| Phase | Commit | Description | +|-------|--------|-------------| +| — | `2c3a908c` | chore: remove DELETEME marker (bootstrap cleanup) | +| 1 | `c7e47030` | Phase 1: IOS_TARGET=duo end-to-end in run-devices.sh | + +Phase 1 is on the ticket branch `alanvardy-var-1179-make-an-rd-fish-function` +(`SingleThread` repo, pushed to origin). + +Phase 2 is a separate repo/commit (dotfiles allows direct commits to `main`): + +| Phase | Commit | Description | +|-------|--------|-------------| +| 2 | `1ba21e5` | feat(fish): add rd for the Duo-only run-devices mode | + +Phase 2 is on `~/dev/dotfiles` `main` (pushed `98b4dc2..1ba21e5`), not the +ticket branch. + +## Automated Checks +- [x] `bash -n scripts/run-devices.sh` passed +- [x] `shellcheck -S warning --exclude=SC1111 scripts/run-devices.sh` passed +- [x] `bash scripts/test-run-devices.sh` passed, including the new + `duo mode emits only the physical Duo`, `duo mode excludes the regular + physical iPhone`, `flow: IOS_TARGET=duo installs only the iPhone Duo` + (+ sub-checks: no sim boot, no watch build, no macOS build, skipped + watch/macOS legs both reported) and `flow: IOS_TARGET=duo with no Duo + fails fast` +- [x] `rg -n 'test-run-devices' Makefile scripts/test.sh` still returns nothing + (no gate wiring needed) +- [x] `fish --no-execute ~/dev/dotfiles/fish/functions/rd.fish` reported no + syntax error +- [x] No dotfiles test targets exist (`ls ~/dev/dotfiles` shows no + `scripts/test.sh`) + +Scope note: the `duo` filter reuses the existing `mode != "device"` branch +unchanged — no Python edit was needed (Phase 1 changed only +`scripts/run-devices.sh` + `scripts/test-run-devices.sh`; Phase 2 created only +`fish/functions/rd.fish`). + +## Manual Verification Items (from the plan) +- [ ] With the physical Duo paired and reachable: + `IOS_TARGET=duo ./scripts/run-devices.sh` builds/installs/launches only the + Duo, prints `iPhone Duo (device): 1/1 launched, 0 unreachable`, and shows no + simulator boot, no watch build, no macOS build. +- [ ] With the Duo unpaired/unreachable, `IOS_TARGET=duo ./scripts/run-devices.sh` + exits non-zero with `No reachable iPhone/iPad found.` (or the unreachable + message) without touching sim/watch/macOS. +- [ ] `IOS_TARGET=duo RUN_WATCH=1 RUN_MAC=1 ./scripts/run-devices.sh` still + allows the watch/macOS legs (the opt-back-in path). +- [ ] From a SingleThread worktree, `rd` builds/installs/launches only the Duo + and prints the duo summary (same result as + `IOS_TARGET=duo ./scripts/run-devices.sh`). +- [ ] `functions rd` shows the function loaded from + `~/.config/fish/functions/rd.fish`. + +## Post-plan gate (parent / review step) +- [ ] Run the full CI-identical gate via the `run-gate` skill + (`./scripts/test.sh`: build + lint + Periphery + unit + UI) once after the + phases commit. The change is shell-only, so this is a regression check. +- [ ] `./scripts/test-run-devices.sh` is not part of `scripts/test.sh`; run it + directly in the gate worktree as well. +- [ ] Confirm the ticket branch has no `DELETEME` before merge (it is already + removed by `2c3a908c`) and that the dotfiles commit is on `main` (not the + ticket branch) — verified: dotfiles `1ba21e5` is on `main`. diff --git a/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/medium.md b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/medium.md new file mode 100644 index 00000000..56c436d9 --- /dev/null +++ b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/medium.md @@ -0,0 +1,66 @@ +# Task + +Add an `rd` fish function that builds, installs, and launches SingleThread **on +the physical iPhone Duo only** — skipping the regular iPhone/iPad simulator +legs, the Apple Watch leg, and the macOS leg. `r` is the current full-run +wrapper (`r.fish` → `./scripts/run-devices.sh`); `rd` is the narrow Duo-only +sibling. + +Concretely: + +1. **`rd` fish function.** Fish functions live in + `~/dev/dotfiles/fish/functions/*.fish` (that directory is symlinked to + `~/.config/fish/functions`), so add `rd.fish` there, following `r.fish`: + `function rd --wraps=./scripts/run-devices.sh --description '…'` then invoke + `./scripts/run-devices.sh` with whatever env selects the Duo-only mode below. +2. **A Duo-only mode on `scripts/run-devices.sh`.** Today there is no way to do + this: + * `IOS_TARGET=sim` (default) runs the sim iPhone/iPad legs **and** the + physical Duo **and** the watch **and** macOS. + * `IOS_TARGET=device` sweeps **every** paired physical iPhone/iPad and + ignores `DUO_DEVICE_ID` (the embedded Python only honours it when + `mode != "device"`, run-devices.sh ~line 239). + * `RUN_WATCH=0` / `RUN_MAC=0` exist, but nothing skips the sim legs. + Add the smallest flag that yields Duo-only (e.g. an `IOS_TARGET=duo` value, + or make `DUO_DEVICE_ID` filter in `device` mode), document it in the header + override block, and fix the summary so it reports the Duo leg honestly + instead of printing a 0/0 sim line. +3. **Update `scripts/test-run-devices.sh`** (the existing `run_flow` / fixture + harness): cover the new mode — a happy path that installs only the Duo and a + sad path (no/unreachable Duo), without regressing the `sim` / `device` + flows. Reuse `DEVICES_JSON_IN` and `scripts/fixtures/devicectl-devices.json`. + +Why: the user wants a one-command "push this build to my phone" loop without +paying the sim + watch + macOS build/launch cost on every run. + +## Why MEDIUM + +M1 holds: approach known (wrap `run-devices.sh` exactly like `r.fish`, extend +the existing `IOS_TARGET` env pattern), 0–2 unknowns, no new technology — no +schema/migration, no new subsystem, no product trade-off. M2 holds: no +data-model/API/UI change; the only choices (flag shape, whether `rd` builds from +scratch or reuses `DerivedData`) are scoped and precedented by VAR-1175's +`IOS_TARGET` work. M3 holds: **MULTI_MODULE** (`scripts/run-devices.sh` + +`scripts/test-run-devices.sh` + the dotfiles `rd.fish`, i.e. two repositories) +and **BROAD_TEST_SURFACE** (the flow harness must gain a mode variant and a +sad-path case). + +## Key files + +* `scripts/run-devices.sh` (~540 lines) — the change surface: header override + block (~lines 12–28), `IOS_TARGET`/`DUO_DEVICE_ID` env parsing (~72–76), the + embedded Python discovery filter where `device` mode ignores `DUO_DEVICE_ID` + (~211–263), the sim leg gated on `IOS_TARGET == "sim"` (~319–374), the Duo + device loop (~390–434), the watch/macOS legs, and the summary (~510+). +* `scripts/test-run-devices.sh` (~310 lines) — `extract_filter()`, `run_flow()`, + and the `IOS_TARGET=sim` / `IOS_TARGET=device` flow assertions to extend. +* `scripts/fixtures/devicectl-devices.json` — inventory fixture (contains the + physical `Fixture iPhone Duo` plus sim entries). +* `~/dev/dotfiles/fish/functions/r.fish` — the wrapper pattern to copy. +* `~/dev/dotfiles/fish/functions/` — where `rd.fish` must be created (symlinked + as `~/.config/fish/functions`). +* `.pi/orksorksorks/alanvardy-var-1175-run-the-regular-iphone-and-ipad-legs-in/` + — the prior `IOS_TARGET` ticket's plan/medium artifacts: the naming and + toggle conventions this change should mirror. +* `Makefile` / `scripts/test.sh` — check whether the new mode needs a + `-only-testing` / gate entry (the flow tests live outside the Xcode gate). diff --git a/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/plan.md b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/plan.md new file mode 100644 index 00000000..10b68efb --- /dev/null +++ b/.pi/orksorksorks/alanvardy-var-1179-make-an-rd-fish-function/plan.md @@ -0,0 +1,282 @@ +# Implementation Plan + +## Overview + +Add an `IOS_TARGET=duo` mode to `scripts/run-devices.sh` that deploys the build +to the physical iPhone Duo **only** — skipping the regular iPhone/iPad +simulator legs, the Apple Watch leg, and the macOS leg — report that leg +honestly in the summary, and add `rd.fish` to the dotfiles repo so +`rd` is a one-command Duo-only sibling of `r`. + +**Decisions locked (from `medium.md` + recon):** + +1. **Flag shape = `IOS_TARGET=duo`** (not a new boolean, not a change to + `device` mode). This mirrors the VAR-1175 `IOS_TARGET=sim|device` + convention and keeps `device` as the legacy all-physical sweep. +2. **`duo` implies watch + macOS off by default.** The RUN_WATCH/RUN_MAC + defaults are applied *after* a duo check with the unset-preserving + `${VAR:-…}` form, so an explicit `RUN_WATCH=1` / `RUN_MAC=1` still opts + back in. +3. **No Python filter change.** Duo is `!= "device"`, so it already falls into + the existing `mode != "device"` branch that keeps only the physical Duo and + honours `DUO_DEVICE_ID`. The filter gets a *test* proving this, not an edit. +4. **Two repos, two phases / two commits.** Phase 1 edits + `scripts/run-devices.sh` + `scripts/test-run-devices.sh` on the ticket + branch. Phase 2 creates `rd.fish` in `~/dev/dotfiles` (a different repo, + which per its `AGENTS.md` allows direct commits to `main`). +5. **No gate wiring.** `scripts/test-run-devices.sh` is standalone and is not + referenced by `Makefile` / `scripts/test.sh` (verified this session: + `rg -n 'test-run-devices' Makefile scripts/test.sh` returns nothing), so no + new gate entry is required. + +## Verified ground truth (checked this session) + +- `scripts/run-devices.sh:70-76` — env parsing block (`RUN_WATCH`, `RUN_MAC`, + `IOS_TARGET`, `SIM_*`, `DUO_DEVICE_ID`). +- `scripts/run-devices.sh:170-174` — discovery banner: sim banner if + `IOS_TARGET == "sim"`, else the all-physical banner. +- `scripts/run-devices.sh:211` — sole `<<'PY'` heredoc; `:237-244` is the + `if mode != "device":` Duo filter branch. **No edit needed.** +- `scripts/run-devices.sh:271-284` — zero-device gate, `!= "sim"` (duo already + fail-fasts correctly once `RUN_MAC` defaults to 0; no edit). +- `scripts/run-devices.sh:287` — "no physical iPhone Duo found" notice is + `== "sim"` only (duo correctly skips; no edit). +- `scripts/run-devices.sh:319` — sim leg guard `== "sim"` (duo skips; no edit). +- `scripts/run-devices.sh:432` / `:479` — watch leg `RUN_WATCH -eq 1`, macOS + leg `RUN_MAC -eq 1` (duo defaults flip these off). +- `scripts/run-devices.sh:510-515` — summary label block (needs a duo branch). +- `scripts/run-devices.sh:531-533` — final toast. +- `scripts/test-run-devices.sh:53-58` `extract_filter`; `:64-127` filter + assertions; `:191` `flow-no-devices.json`; `:193-208` `run_flow`; `:245-250` + existing sim/device flow cases. +- Fixture `scripts/fixtures/devicectl-devices.json` — physical Duo is + `CCCCCCCC-0000-0000-0000-000000000009` (`Fixture Duo Renamed`, + productType `iPhone19,4`); no fixture change is needed. +- `~/dev/dotfiles/fish/functions/r.fish`: + `function r --wraps=./scripts/run-devices.sh --description '…'; ./scripts/run-devices.sh $argv; end`. +- `~/dev/dotfiles/AGENTS.md` — direct pushes to `main` are allowed. + +--- + +## Phase 1: `IOS_TARGET=duo` end-to-end in `run-devices.sh` + offline coverage + +The walking skeleton: setting `IOS_TARGET=duo` discovers only the Duo, runs +only the physical device leg, skips sim/watch/macOS, and prints an honest +summary — proven offline by `scripts/test-run-devices.sh`. + +### Changes + +#### 1. Header docstring + env parsing — `scripts/run-devices.sh` + +**File**: `scripts/run-devices.sh` +**Action**: modify + +Update the intro line (line 8) and the override block (lines 15-16) to document +the new value: + +```bash +# iPhone Duo (via devicectl), install + launch the watch app on an Apple Watch +# simulator, and (by default) also build + launch it on the host Mac. Set +# IOS_TARGET=device to build + launch on every paired physical iPhone/iPad +# instead (the Duo is always deployed physically); IOS_TARGET=duo builds and +# launches on the physical Duo only. +``` + +```bash +# IOS_TARGET=sim # sim (default) → the regular iPhone/iPad legs run on +# # simulators; device → the old all-physical sweep; +# # duo → the physical iPhone Duo only (sim, watch and +# # macOS legs skipped unless RUN_WATCH/RUN_MAC opt in) +``` + +Replace the env-parsing block (lines 70-76) so `IOS_TARGET` is parsed first and +duo flips the leg defaults: + +```bash +IOS_TARGET="${IOS_TARGET:-sim}" +# Duo-only mode: the physical Duo is the only leg. Applied before the +# RUN_WATCH/RUN_MAC defaults so an explicit RUN_WATCH=1 / RUN_MAC=1 opts back in. +if [[ "$IOS_TARGET" == "duo" ]]; then + RUN_WATCH="${RUN_WATCH:-0}" + RUN_MAC="${RUN_MAC:-0}" +fi +RUN_WATCH="${RUN_WATCH:-1}" +RUN_MAC="${RUN_MAC:-1}" +SIM_IPHONE="${SIM_IPHONE:-}" # explicit UDID or device name; empty = worktree sim, else iPhone 17 +SIM_IPAD="${SIM_IPAD:-}" # explicit UDID or device name; empty = iPad (A16) +SIM_WATCH="${SIM_WATCH:-}" # explicit UDID or device name; empty = Apple Watch Series 11 (46mm) +DUO_DEVICE_ID="${DUO_DEVICE_ID:-}" +``` + +#### 2. Discovery banner — `scripts/run-devices.sh` + +**File**: `scripts/run-devices.sh` +**Action**: modify + +Duo uses the Duo banner (it discovers the same target as sim): + +```bash +if [[ "$IOS_TARGET" == "sim" || "$IOS_TARGET" == "duo" ]]; then + echo "==> Discovering the paired iPhone Duo…" +else + echo "==> Discovering paired iPhone/iPad devices…" +fi +``` + +#### 3. Summary + final toast — `scripts/run-devices.sh` + +**File**: `scripts/run-devices.sh` +**Action**: modify + +Add the duo branch so the leg is never mislabelled as `iPhone/iPad (device)` +and no `0/0` sim line is printed (line 510): + +```bash +if [[ "$IOS_TARGET" == "sim" ]]; then + echo " iPhone/iPad (sim): $SIM_LAUNCHED/$SIM_TOTAL launched" + echo " iPhone Duo (device): $IOS_LAUNCHED/${#DEVICES[@]} launched, $UNREACHABLE_COUNT unreachable" +elif [[ "$IOS_TARGET" == "duo" ]]; then + echo " iPhone Duo (device): $IOS_LAUNCHED/${#DEVICES[@]} launched, $UNREACHABLE_COUNT unreachable" +else + echo " iPhone/iPad (device): $IOS_LAUNCHED/${#DEVICES[@]} launched, $UNREACHABLE_COUNT unreachable" +fi +``` + +Drop the misleading `and 0 simulator(s)` from the duo toast (line 531): + +```bash +if [[ "$IOS_TARGET" == "duo" ]]; then + summary="Installed and launched on ${#DEVICES[@]} device(s)" +else + summary="Installed and launched on ${#DEVICES[@]} device(s) and $SIM_LAUNCHED simulator(s)" +fi +[[ "$RUN_MAC" -eq 1 ]] && summary="$summary and macOS" +[[ "$WATCH_LAUNCHED" -gt 0 ]] && summary="$summary and $WATCH_LAUNCHED Apple Watch(es)" +``` + +The watch/macOS summary lines (`Apple Watch (sim): skipped (RUN_WATCH=0)`, +`macOS: skipped (RUN_MAC=0)`) stay — they are the honest duo report. + +#### 4. Offline coverage — `scripts/test-run-devices.sh` + +**File**: `scripts/test-run-devices.sh` +**Action**: modify + +Add a filter-level duo assertion after the sim-mode filter assertions +(around line 107), proving the new value reaches the shared `!= "device"` +branch: + +```bash +# IOS_TARGET=duo reuses the sim filter semantics: only the physical Duo +# qualifies, and DUO_DEVICE_ID still wins. +python3 "$work/ios.py" "$FIXTURE" "$work/ios-duomode-unreachable.log" duo \ + > "$work/ios-duomode-out" 2>/dev/null +check "duo mode emits only the physical Duo" \ + "1" "$(grep -c '|Fixture Duo Renamed$' "$work/ios-duomode-out" || true)" +check "duo mode excludes the regular physical iPhone" \ + "0" "$(grep -c '|Fixture iPhone$' "$work/ios-duomode-out" || true)" +``` + +Add the happy + sad flow cases after the existing +`"IOS_TARGET=device restores the all-physical sweep"` case (line 248): + +```bash +run_flow "IOS_TARGET=duo installs only the iPhone Duo" 0 \ + "iPhone Duo (device): 1/1 launched" "iPhone/iPad" \ + DEVICES_JSON_IN="$FIXTURE" IOS_TARGET=duo +check "duo mode boots no simulator" "0" \ + "$(grep -c '==> Booting the' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode builds no watch app" "0" \ + "$(grep -c '==> Building SingleThreadWatch' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode builds no macOS app" "0" \ + "$(grep -c 'for macOS' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode reports the skipped watch leg" "1" \ + "$(grep -c 'Apple Watch (sim): skipped' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode reports the skipped macOS leg" "1" \ + "$(grep -c 'macOS: skipped' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +run_flow "IOS_TARGET=duo with no Duo fails fast" 1 \ + "No reachable iPhone/iPad found." "==> Booting the" \ + DEVICES_JSON_IN="$work/flow-no-devices.json" IOS_TARGET=duo +``` + +Notes for the implementer: `run_flow` env assignments follow the four +positional args (no `RUN_WATCH=0`/`RUN_MAC=0` — duo must supply those); the flow +log path is `$work/flow-$label.log`; the existing sim case asserts the Duo-only +filter still emits the Duo, so no fixture change is needed. + +### Verification +#### Automated +- [x] `bash -n scripts/run-devices.sh` passes +- [x] `shellcheck -S warning --exclude=SC1111 scripts/run-devices.sh` passes +- [x] `bash scripts/test-run-devices.sh` passes, including the two new duo flow cases and the duo filter assertions +- [x] `rg -n 'test-run-devices' Makefile scripts/test.sh` still returns nothing (no gate wiring needed) + +#### Manual +- [ ] With the physical Duo paired and reachable: + `IOS_TARGET=duo ./scripts/run-devices.sh` builds/installs/launches only the + Duo, prints `iPhone Duo (device): 1/1 launched, 0 unreachable`, and shows no + simulator boot, no watch build, no macOS build. +- [ ] With the Duo unpaired/unreachable, `IOS_TARGET=duo ./scripts/run-devices.sh` + exits non-zero with `No reachable iPhone/iPad found.` (or the unreachable + message) without touching sim/watch/macOS. +- [ ] `IOS_TARGET=duo RUN_WATCH=1 RUN_MAC=1 ./scripts/run-devices.sh` still + allows the watch/macOS legs (the opt-back-in path). + +--- + +## Phase 2: `rd.fish` Duo-only wrapper (dotfiles repo) + +A separate repo and commit: `rd` wraps `run-devices.sh` with +`IOS_TARGET=duo`, mirroring `r.fish`. + +### Changes + +#### 1. New fish function — `~/dev/dotfiles/fish/functions/rd.fish` + +**File**: `/Users/vardy/dev/dotfiles/fish/functions/rd.fish` +**Action**: create + +```fish +function rd --wraps=./scripts/run-devices.sh --description 'alias rd=IOS_TARGET=duo ./scripts/run-devices.sh' + env IOS_TARGET=duo ./scripts/run-devices.sh $argv +end +``` + +`env` scopes `IOS_TARGET` to the child process without leaking it into the +interactive session; `$argv` passes any extra args through (positional args do +not overwrite the env var). Do not add a matching `r`-style entry elsewhere. + +#### 2. Commit on dotfiles `main` + +This repo's `AGENTS.md` explicitly allows direct commits/pushes to `main`. +From `/Users/vardy/dev/dotfiles`: + +```bash +git add fish/functions/rd.fish +git commit -m "feat(fish): add rd for the Duo-only run-devices mode" +git push +``` + +### Verification +#### Automated +- [x] `fish --no-execute /Users/vardy/dev/dotfiles/fish/functions/rd.fish` reports no syntax error +- [x] No dotfiles test targets exist (`ls /Users/vardy/dev/dotfiles` shows no `scripts/test.sh`); the wrapper holds no logic beyond one env var, so the Phase 1 flow tests are the behaviour coverage + +#### Manual +- [ ] From a SingleThread worktree, `rd` builds/installs/launches only the Duo + and prints the duo summary (same result as `IOS_TARGET=duo ./scripts/run-devices.sh`). +- [ ] `functions rd` shows the function loaded from + `~/.config/fish/functions/rd.fish`. + +--- + +## Post-plan gate (parent, after both phases commit) + +- [ ] Run the full CI-identical gate via the `run-gate` skill + (`./scripts/test.sh`: build + lint + Periphery + unit + UI) once after the + phases commit. The change is shell-only, so this is a regression check. +- [ ] `./scripts/test-run-devices.sh` is not part of `scripts/test.sh`; run it + directly in the gate worktree as well. +- [ ] Confirm the ticket branch has no `DELETEME` before merge + (`git rm DELETEME`) and that the dotfiles commit is on `main` (not the ticket + branch). diff --git a/scripts/run-devices.sh b/scripts/run-devices.sh index 540efaca..e10801f2 100755 --- a/scripts/run-devices.sh +++ b/scripts/run-devices.sh @@ -6,14 +6,17 @@ set -euo pipefail # iPhone Duo (via devicectl), install + launch the watch app on an Apple Watch # simulator, and (by default) also build + launch it on the host Mac. Set # IOS_TARGET=device to build + launch on every paired physical iPhone/iPad -# instead (the Duo is always deployed physically). +# instead (the Duo is always deployed physically); IOS_TARGET=duo builds and +# launches on the physical Duo only. # # ./scripts/run-devices.sh # # Overrides (same env-override pattern as scripts/test.sh): # SCHEME=… BUNDLE_ID=… CONFIGURATION=… DERIVED_DATA=… # IOS_TARGET=sim # sim (default) → the regular iPhone/iPad legs run on -# # simulators; device → the old all-physical sweep +# # simulators; device → the old all-physical sweep; +# # duo → the physical iPhone Duo only (sim, watch and +# # macOS legs skipped unless RUN_WATCH/RUN_MAC opt in) # SIM_IPHONE=… # UDID or device name for the iPhone sim; empty → this # # worktree's .simulator_id, else the iPhone 17 default # SIM_IPAD=… # UDID or device name for the iPad sim; empty → iPad (A16) @@ -67,9 +70,15 @@ SCHEME="${SCHEME:-SingleThread}" BUNDLE_ID="${BUNDLE_ID:-app.alanvardy.SingleThread}" CONFIGURATION="${CONFIGURATION:-Debug}" DERIVED_DATA="${DERIVED_DATA:-DerivedData}" +IOS_TARGET="${IOS_TARGET:-sim}" +# Duo-only mode: the physical Duo is the only leg. Applied before the +# RUN_WATCH/RUN_MAC defaults so an explicit RUN_WATCH=1 / RUN_MAC=1 opts back in. +if [[ "$IOS_TARGET" == "duo" ]]; then + RUN_WATCH="${RUN_WATCH:-0}" + RUN_MAC="${RUN_MAC:-0}" +fi RUN_WATCH="${RUN_WATCH:-1}" RUN_MAC="${RUN_MAC:-1}" -IOS_TARGET="${IOS_TARGET:-sim}" SIM_IPHONE="${SIM_IPHONE:-}" # explicit UDID or device name; empty = worktree sim, else iPhone 17 SIM_IPAD="${SIM_IPAD:-}" # explicit UDID or device name; empty = iPad (A16) SIM_WATCH="${SIM_WATCH:-}" # explicit UDID or device name; empty = Apple Watch Series 11 (46mm) @@ -167,7 +176,7 @@ show_sim_window() { # $1 = UDID } # ── Discover devices ───────────────────────────────────────────────────────── -if [[ "$IOS_TARGET" == "sim" ]]; then +if [[ "$IOS_TARGET" == "sim" || "$IOS_TARGET" == "duo" ]]; then echo "==> Discovering the paired iPhone Duo…" else echo "==> Discovering paired iPhone/iPad devices…" @@ -273,7 +282,17 @@ if [[ ${#DEVICES[@]} -eq 0 && "$IOS_TARGET" != "sim" ]]; then echo "❌ $UNREACHABLE_COUNT device(s) found but unreachable — see messages above (unlock the device and connect it to this Mac's Wi-Fi, then retry)." >&2 exit 1 fi - if [[ "$RUN_MAC" -eq 1 ]]; then + if [[ "$IOS_TARGET" == "duo" ]]; then + # Duo mode filters out every non-Duo device, so a paired regular + # iPhone/iPad would still land here — name the Duo, not the phone. + if [[ "$RUN_MAC" -eq 1 ]]; then + echo " (no reachable iPhone Duo found — macOS run only)" + else + echo "❌ No reachable iPhone Duo found." >&2 + echo " Connect the iPhone Duo to this Mac's Wi-Fi and unlock it, then retry (set DUO_DEVICE_ID= to pin one)." >&2 + exit 1 + fi + elif [[ "$RUN_MAC" -eq 1 ]]; then echo " (no reachable iPhone/iPad found — macOS run only)" else echo "❌ No reachable iPhone/iPad found." >&2 @@ -510,6 +529,8 @@ echo "==> Summary" if [[ "$IOS_TARGET" == "sim" ]]; then echo " iPhone/iPad (sim): $SIM_LAUNCHED/$SIM_TOTAL launched" echo " iPhone Duo (device): $IOS_LAUNCHED/${#DEVICES[@]} launched, $UNREACHABLE_COUNT unreachable" +elif [[ "$IOS_TARGET" == "duo" ]]; then + echo " iPhone Duo (device): $IOS_LAUNCHED/${#DEVICES[@]} launched, $UNREACHABLE_COUNT unreachable" else echo " iPhone/iPad (device): $IOS_LAUNCHED/${#DEVICES[@]} launched, $UNREACHABLE_COUNT unreachable" fi @@ -528,7 +549,11 @@ fi echo "" if [[ "$failures" -eq 0 ]]; then - summary="Installed and launched on ${#DEVICES[@]} device(s) and $SIM_LAUNCHED simulator(s)" + if [[ "$IOS_TARGET" == "duo" ]]; then + summary="Installed and launched on ${#DEVICES[@]} device(s)" + else + summary="Installed and launched on ${#DEVICES[@]} device(s) and $SIM_LAUNCHED simulator(s)" + fi [[ "$RUN_MAC" -eq 1 ]] && summary="$summary and macOS" [[ "$WATCH_LAUNCHED" -gt 0 ]] && summary="$summary and $WATCH_LAUNCHED Apple Watch(es)" echo "✅ $summary." diff --git a/scripts/test-run-devices.sh b/scripts/test-run-devices.sh index 7db92965..f905a457 100755 --- a/scripts/test-run-devices.sh +++ b/scripts/test-run-devices.sh @@ -104,6 +104,15 @@ check "sim mode warns about the Duo's Developer Mode off" \ check "sim mode logs no unreachable devices" \ "0" "$(wc -l < "$work/ios-sim-unreachable.log" | tr -d ' ')" +# IOS_TARGET=duo reuses the sim filter semantics: only the physical Duo +# qualifies, and DUO_DEVICE_ID still wins. +python3 "$work/ios.py" "$FIXTURE" "$work/ios-duomode-unreachable.log" duo \ + > "$work/ios-duomode-out" 2>/dev/null +check "duo mode emits only the physical Duo" \ + "1" "$(grep -c '|Fixture Duo Renamed$' "$work/ios-duomode-out" || true)" +check "duo mode excludes the regular physical iPhone" \ + "0" "$(grep -c '|Fixture iPhone$' "$work/ios-duomode-out" || true)" + # DUO_DEVICE_ID wins over the name match: an explicit identifier selects exactly # the Duo, and a non-matching identifier selects nothing. python3 "$work/ios.py" "$FIXTURE" "$work/ios-duo-unreachable.log" sim \ @@ -248,6 +257,24 @@ run_flow "sim mode deploys only the iPhone Duo physically" 0 \ run_flow "IOS_TARGET=device restores the all-physical sweep" 0 \ "iPhone/iPad (device): 3/3 launched" "iPhone/iPad (sim)" \ DEVICES_JSON_IN="$FIXTURE" IOS_TARGET=device RUN_WATCH=0 RUN_MAC=0 +run_flow "IOS_TARGET=duo installs only the iPhone Duo" 0 \ + "iPhone Duo (device): 1/1 launched" "iPhone/iPad" \ + DEVICES_JSON_IN="$FIXTURE" IOS_TARGET=duo +check "duo mode boots no simulator" "0" \ + "$(grep -c '==> Booting the' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode builds no watch app" "0" \ + "$(grep -c '==> Building SingleThreadWatch' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode builds no macOS app" "0" \ + "$(grep -c 'for macOS' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode reports the skipped watch leg" "1" \ + "$(grep -c 'Apple Watch (sim): skipped' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo mode reports the skipped macOS leg" "1" \ + "$(grep -c 'macOS: skipped' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +check "duo toast omits the simulator count" "0" \ + "$(grep -c 'simulator(s)' "$work/flow-IOS_TARGET=duo installs only the iPhone Duo.log" || true)" +run_flow "IOS_TARGET=duo with no Duo fails fast" 1 \ + "No reachable iPhone Duo found." "==> Booting the" \ + DEVICES_JSON_IN="$work/flow-no-devices.json" IOS_TARGET=duo run_flow "macOS success is reported in the summary" 0 \ "macOS: built and launched" "macOS: build failed" \ DEVICES_JSON_IN="$work/flow-no-devices.json" RUN_WATCH=0 RUN_MAC=1