Commit f300d3c7b9

f300d3c7b9fbcdfde2cefeae3b658662fdfcaedf

parent: a11f067734

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-20 21:51 UTC

Plan: Task 14b, the step list and dragging back

Add batch F2: a step list on demand and fold drag segments crossed in both
directions, before Task 15. A fold-and-unfold stays one way at its peak,
since its return half is the unfold.

Ref #9

Layout: unified · split

docs/superpowers/plans/2026-10-19-fold.md +76 −3
@@ -119,7 +119,7 @@ Done once, before Task 0.
119 119
1201. `gitbay init fold` in this directory. The repo is public. This runs `git init`, creates the repo and sets `origin`. 1201. `gitbay init fold` in this directory. The repo is public. This runs `git init`, creates the repo and sets `origin`.
1212. Add `.gitignore` (`.build/`, `.swiftpm/`, `App/*.xcodeproj/`, `DerivedData/`, `.DS_Store`) and `LICENSE` (0BSD). Commit them with `docs/`, and push to `main`. `CLAUDE.md` is excluded by the author's global gitignore, as in the other krz repos, and stays local; edits to it are not part of any merge request. This first push is the one direct push to `main`; every later change goes through a merge request. 1212. Add `.gitignore` (`.build/`, `.swiftpm/`, `App/*.xcodeproj/`, `DerivedData/`, `.DS_Store`) and `LICENSE` (0BSD). Commit them with `docs/`, and push to `main`. `CLAUDE.md` is excluded by the author's global gitignore, as in the other krz repos, and stays local; edits to it are not part of any merge request. This first push is the one direct push to `main`; every later change goes through a merge request.
1223. Work is batched into eight merge requests, each with one gitbay issue: 1223. Work is batched into nine merge requests, each with one gitbay issue:
123 123
124 | Batch | Tasks | Branch | 124 | Batch | Tasks | Branch |
125 |---|---|---| 125 |---|---|---|
@@ -130,6 +130,7 @@ Done once, before Task 0.
130 | D | 7, 7b, 8 — `foldc`, non-rigid steps, `foldlint`, the cup | `compiler-and-cup` | 130 | D | 7, 7b, 8 — `foldc`, non-rigid steps, `foldlint`, the cup | `compiler-and-cup` |
131 | E | 9–10 — diagram, renderer | `diagram-and-renderer` | 131 | E | 9–10 — diagram, renderer | `diagram-and-renderer` |
132 | F | 11–14 — the app | `app` | 132 | F | 11–14 — the app | `app` |
133 | F2 | 14b — step list, dragging back | `step-access` |
133 | G | 15 — crane, sampan, box | `models` | 134 | G | 15 — crane, sampan, box | `models` |
134 135
135 Batches A and A2 merge alone, since Tasks 0 and 0b can stop the plan. Each batch commits task by task on its branch, ends with `gitbay mr create --source <branch> --target main`, merges when `swift test --package-path Packages/FoldKit` (and, from batch F, the `xcodebuild` test) is green, and the branch is then deleted locally and remotely. Commit messages end with `Ref #N` for the batch's issue; the batch's last commit uses `Closes #N`. 136 Batches A and A2 merge alone, since Tasks 0 and 0b can stop the plan. Each batch commits task by task on its branch, ends with `gitbay mr create --source <branch> --target main`, merges when `swift test --package-path Packages/FoldKit` (and, from batch F, the `xcodebuild` test) is green, and the branch is then deleted locally and remotely. Commit messages end with `Ref #N` for the batch's issue; the batch's last commit uses `Closes #N`.
@@ -2060,6 +2061,80 @@ git commit -m "Orbit and zoom, accessibility pass and release assets"
2060 2061
2061--- 2062---
2062 2063
2064### Task 14b: The step list and dragging back
2065
2066**Files:**
2067- Create: `App/Sources/StepListView.swift`
2068- Modify: `App/Sources/StepView.swift`, `App/Sources/FoldSession.swift`
2069- Modify: `Packages/FoldKit/Sources/Folding/FoldParameterMapping.swift`
2070- Test: `App/UITests/StepListTests.swift`, `App/Tests/FoldSessionTests.swift`, `Packages/FoldKit/Tests/FoldingTests/FoldParameterTests.swift`, `App/UITests/AccessibilityAuditTests.swift`
2071
2072**Interfaces:**
2073- Consumes: Tasks 11–14.
2074- Produces:
2075 - `struct StepListView: View` — every step's number and `instruction`, the current one marked
2076 - `func (FoldSession).open(step: Int)` — step counted from 1; loads that step at *t* = 0 with the camera at its viewpoint, as completing the step before it does
2077
2078**The step list.** A toolbar button (`steps.button`, label "Steps") opens the list on demand: a popover on iPad, a sheet on iPhone. The navigation title reads "Step n of N"; `step.index` stays the bare number. Choosing a step opens it at its start, frame n − 1, whatever was folded before; choosing the current step closes the list and leaves *t* alone. Nothing about the list advances *t*.
2079
2080**Dragging back.** A step's segments — axis windows and non-rigid phases — are crossed in both directions: the search runs outward from `current` across segment boundaries, so dragging the flap back takes *t* back through earlier windows and phases to 0. Where the path doubles back on screen at a boundary (a non-rigid step's open and pop), the segment *t* is in is kept until the finger leaves the overlap, so a finger moving along the retraced stretch neither jumps ahead nor falls back. The 0.5-point end tolerance applies at *t* = 1 only. A `foldAndUnfold` stays one way at its peak: its return half passes through the same poses as its outbound half, so dragging back after the peak is the unfold.
2081
2082- [ ] **Step 1: Write the failing tests**
2083
2084```swift
2085// FoldParameterTests
2086@Test func aStaggeredStepCanBeDraggedBackPastItsWindowBoundary() throws {
2087 // follow letter-staggered's samples to t = 0.75, then back to 0: t tracks k/128 both ways
2088}
2089
2090@Test func aNonRigidStepCanBeDraggedBackThroughItsPhases() throws {
2091 // follow the reverse fixture's samples to t = 1, then back: t never increases, and ends below 0.01
2092}
2093
2094@Test func aFoldAndUnfoldStillUnfoldsAfterItsPeak() throws {
2095 // quarters step 1: past 0.5, dragging back toward the start goes to 1
2096}
2097```
2098
2099```swift
2100// StepListTests
2101func testTheStepListOpensAChosenStepAtItsStart() {
2102 let app = XCUIApplication(); app.launch()
2103 app.buttons["Cup"].tap()
2104 app.buttons["steps.button"].tap()
2105 app.buttons["step.5"].tap()
2106 XCTAssertEqual(app.staticTexts["step.index"].label, "5")
2107 XCTAssertEqual(app.otherElements["fold.paper"].value as? String, "0%")
2108}
2109
2110func testTheStepListNamesEveryStep() {
2111 // six rows for the cup, each labelled with its number and instruction
2112}
2113```
2114
2115`FoldSessionTests` covers `open(step:)` (the camera resets, *t* is 0, the diagram is step n's) and choosing the current step. The accessibility audit opens the list at both text sizes.
2116
2117- [ ] **Step 2: Run tests to verify they fail**
2118
2119Run: `swift test --package-path Packages/FoldKit --filter FoldParameterTests`, then `xcodebuild -project App/Fold.xcodeproj -scheme Fold -destination 'platform=iOS Simulator,name=iPhone 17 Pro,OS=26.5' test`
2120Expected: FAIL.
2121
2122- [ ] **Step 3: Implement the step list, `open(step:)` and two-way segments**
2123
2124- [ ] **Step 4: Run tests to verify they pass**
2125
2126Run: as above, then `-only-testing:FoldUITests/FoldGestureTests -test-iterations 100`.
2127Expected: PASS.
2128
2129- [ ] **Step 5: Commit**
2130
2131```bash
2132git add App Packages
2133git commit -m "Step list and dragging back across segments"
2134```
2135
2136---
2137
2063### Task 15: The crane, the sampan and the box 2138### Task 15: The crane, the sampan and the box
2064 2139
2065**Files:** 2140**Files:**
@@ -2155,8 +2230,6 @@ git commit -m "The crane, the sampan and the box"
2155 2230
2156## Open before Task 15 2231## Open before Task 15
2157 2232
2158- **Reaching an earlier or chosen step.** The app starts each model at step 1 and has no step list; the spec leaves its form open (a visible strip or revealed on demand). On the crane, revisiting a step means refolding from the start.
2159- **Dragging back past a peak, phase or window.** A fold-and-unfold cannot be dragged back once past its peak, a reverse fold past its open phase, or a staggered step past an internal window end, although the spec's first goal says a step can be folded "and back".
2160- **Multi-axis steps in the app.** The fold drag's path joins each segment's followed centroid end to end, so on a multi-axis step it can leave the paper view; a short window nested inside a long one falls back to a vertical drag while the paper moves; non-rigid steps follow the axis with the most travel per phase, untested until one ships. Check all three on the crane. The catalogue gate exercises `FoldParameterMapping` on every step but not `ReorientMapping`. 2233- **Multi-axis steps in the app.** The fold drag's path joins each segment's followed centroid end to end, so on a multi-axis step it can leave the paper view; a short window nested inside a long one falls back to a vertical drag while the paper moves; non-rigid steps follow the axis with the most travel per phase, untested until one ships. Check all three on the crane. The catalogue gate exercises `FoldParameterMapping` on every step but not `ReorientMapping`.
2161- On device: the fold drag's 0.5-point end tolerance is about 14° on the cup's shortest iPhone paths; check it against "the last 10° completes itself". Check that a late second finger orbits rather than folds. Measure the session and mapping build times on the crane. 2234- On device: the fold drag's 0.5-point end tolerance is about 14° on the cup's shortest iPhone paths; check it against "the last 10° completes itself". Check that a late second finger orbits rather than folds. Measure the session and mapping build times on the crane.
2162 2235