summaryrefslogtreecommitdiff
path: root/docs/plans/2026-02-23-held-posts-toggle-implementation.md
blob: 7f84e5524226247ac79229cd7e276a4b7f6dff53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Held Posts Toggle Implementation Plan

> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

**Goal:** Add a settings toggle to allow showing held posts on Moebooru providers, while keeping default feed behavior aligned with website ordering.

**Architecture:** Persist a global boolean in `SettingsManager`, pass it into `BooruManager`, and conditionally apply default `holds:false` in the Moebooru tag helper. Expose the toggle in Provider settings and rebuild manager instances when the setting changes so requests immediately reflect the new behavior.

**Tech Stack:** Swift, SwiftUI, `@AppStorage`, XCTest source-assertion tests.

---

### Task 1: Add failing tests for toggle persistence and wiring

**Files:**
- Modify: `SoraTests/ViewDerivedDataTests.swift`

**Step 1: Write failing tests**
- Add a test asserting `SettingsManager` contains `@AppStorage("showHeldMoebooruPosts") var showHeldMoebooruPosts = false`.
- Add a test asserting `MainView` passes `showHeldMoebooruPosts: settings.showHeldMoebooruPosts` when creating `BooruManager`.
- Add a test asserting `BooruManager.moebooruTagString` guards on `showHeldMoebooruPosts` and bypasses forced `holds:false` when enabled.

**Step 2: Run tests to verify failure**
- Run: `xcodebuild -scheme Sora -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.2' -only-testing:SoraTests/ViewDerivedDataTests test`
- Expected: New tests fail due missing setting/wiring.

### Task 2: Implement the setting and manager behavior

**Files:**
- Modify: `Sora/Data/Settings/SettingsManager.swift`
- Modify: `Sora/Data/Booru/BooruManager.swift`
- Modify: `Sora/Views/MainView.swift`
- Modify: `Sora/Views/Settings/Section/SettingsSectionProviderView.swift`

**Step 1: Add setting storage**
- Add `@AppStorage("showHeldMoebooruPosts") var showHeldMoebooruPosts = false` to `SettingsManager`.

**Step 2: Thread setting into manager**
- Add `showHeldMoebooruPosts` init param + stored property in `BooruManager`.
- Update Moebooru tag helper:
  - Respect explicit `holds:*` as-is.
  - If `showHeldMoebooruPosts == true`, return raw tags (no forced filter).
  - Else append `holds:false` default.

**Step 3: Wire manager creation points**
- Update `MainView` manager constructors to pass `showHeldMoebooruPosts: settings.showHeldMoebooruPosts`.
- Add `.onChange(of: settings.showHeldMoebooruPosts)` to rebuild manager and refresh feed.

**Step 4: Expose toggle in settings UI**
- Add `Toggle("Show Held Posts", isOn: $settings.showHeldMoebooruPosts)` to Provider settings section.
- Add concise help text that this affects Moebooru feeds.

### Task 3: Verify and finalize

**Files:**
- Modify (if needed): `SoraTests/ViewDerivedDataTests.swift`

**Step 1: Run targeted tests**
- Run: `xcodebuild -scheme Sora -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.2' -only-testing:SoraTests/ViewDerivedDataTests test`
- Expected: PASS.

**Step 2: Run lint**
- Run: `swiftlint lint --quiet`
- Expected: PASS.

**Step 3: Summarize behavior**
- Confirm default (`false`) preserves website-aligned ordering.
- Confirm toggle (`true`) includes held posts for Moebooru providers.