Skip to content

fix(ios): wire Cloud Voices activation toggle, exclude .cloud from bare picker - #492

Merged
github-actions[bot] merged 1 commit into
devfrom
fix/cloudtts-ios-engine-activation
Aug 24, 2026
Merged

github-actions[bot] merged 1 commit into
devfrom
fix/cloudtts-ios-engine-activation

Conversation

@libravault-xyz

Copy link
Copy Markdown
Collaborator

What

Fixes #491, found while checking the current state of dev before opening this session's own (now-redundant, discarded) Settings UI PR: PR #482 — a parallel, independently-authorized dev-agent run on issue #452 (see that issue's own authorization comments) that merged while this session's own from-scratch Settings UI PR for the identical scope was still in progress — implemented provider/key/voice-id configuration but never wired activation.

Confirmed directly against the real merged content (git show origin/dev:..., not a stale assumption):

  • CloudVoicesSection.swift never referenced ttsEngineType/.cloud anywhere (zero matches).
  • SettingsView.ttsSection's segmented Picker listed TTSEngineType.allCases unfiltered, so "Cloud Voices" was directly selectable there with nothing configured. Not silently inert the way Android's own first Settings UI pass was (feat(android): Cloud Voices Settings UI — completes Android #451 #470's own critical finding) — selecting it does call switchTTSEngine(to: .cloud) — but CloudTtsEngine's gate then falls back to on-device on every real call, since nothing's configured. Confusing dead end, disconnected from the Cloud Voices section below it.

Changes

  • ttsSection's Picker now filters out .cloud — mirrors Android's TtsSettingsSection never listing CLOUD as a bare radio option. Footer copy fixed too (still claimed "no network access").
  • New "Use Cloud Voices for Read Aloud" toggle inside CloudVoicesSection, shown once a provider is merely selected — not gated on already being configured, which is exactly the gating bug Android's own PR feat(android): Cloud Voices Settings UI — completes Android #451 #470 hit and fixed (hiding it until configured leaves no discovery path at all). Disabled + explained until the selected provider actually has credentials saved and a non-blank voice id is set. Re-checks CloudTtsGate.canUseCloudTts before actually activating, not just relying on the toggle's own .disabled affordance. Disabling always reverts to .system, gate irrelevant.
  • Extracted the enable/disable decision as a pure static func canActivateCloudEngine, matching this file's own established isSaveEnabled/nextVoiceID precedent for testability (this repo has no ViewInspector/snapshot UI-testing infrastructure).
  • #Preview needed the two new @EnvironmentObjects the section now reads.

Testing

6 new CloudVoicesSectionTests cases covering canActivateCloudEngine's every branch (no provider selected, wrong provider configured, empty/whitespace voice id, the happy path). The gate re-check itself already has full coverage via CloudTtsGateTests (#472) — nothing new to test there.

Known limitation

No Xcode/macOS available in this environment — verified by careful manual review against the actual merged file content on dev and this file's own established static-helper testing convention. Real verification is this PR's own CI run.

Closes #491. Part of #452.

…re picker

Fixes #491, found while reviewing the current state of dev: PR #482
(a parallel, independently-authorized dev-agent run on issue #452 that
merged while this session's own from-scratch Settings UI PR for the
same scope was still in progress — genuine duplicate work, discarded
in favor of this small targeted fix instead of a competing rewrite)
implemented provider/key/voice-id configuration but never wired
activation: `CloudVoicesSection.swift` never referenced `ttsEngineType`
anywhere, and `ttsSection`'s segmented Picker listed `TTSEngineType
.allCases` unfiltered, making ".cloud" directly selectable there with
nothing configured — CloudTtsEngine's own gate would just silently
fall back to on-device every time, a confusing dead end disconnected
from the Cloud Voices section below it.

- `ttsSection`'s Picker now filters out `.cloud` — mirrors Android's
  `TtsSettingsSection` never listing CLOUD as a bare radio option.
  Footer copy fixed too (still claimed "no network access").
- New "Use Cloud Voices for Read Aloud" toggle inside `CloudVoicesSection`,
  shown once a provider is merely *selected* — not gated on already
  being configured, which is exactly the gating bug Android's own PR
  #470 hit and fixed (hiding it until configured leaves no discovery
  path at all). Disabled + explained until the selected provider
  actually has credentials saved and a non-blank voice id is set.
  Re-checks `CloudTtsGate.canUseCloudTts` before actually activating,
  not just relying on the toggle's own `.disabled` affordance.
  Disabling always reverts to `.system`, gate irrelevant.
- Extracted the enable/disable decision as a pure `static func
  canActivateCloudEngine`, matching this file's own established
  `isSaveEnabled`/`nextVoiceID` precedent for testability without
  ViewInspector/snapshot infrastructure (which this repo doesn't have).
- `#Preview` needed the two new `@EnvironmentObject`s added.

Testing: 6 new `CloudVoicesSectionTests` cases covering
`canActivateCloudEngine`'s every branch (no provider selected, wrong
provider configured, empty/whitespace voice id, the happy path). The
gate re-check itself already has full coverage via `CloudTtsGateTests`
(#472) — nothing new to test there.

No Xcode/macOS available in this environment — verified by careful
manual review against the actual merged file content on dev (`git
show origin/dev:...`, not a stale local assumption) and this file's
own established static-helper testing convention. Real verification is
this PR's own CI run.

Closes #491. Part of #452.
@github-actions github-actions Bot added the risk:low Principal review classified this PR as low risk label Aug 24, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-qa PR open, awaiting qa-agent verification label Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was opened outside the automated pipeline (author isn't libravault-pipeline-bot[bot]), so dev-agent.yml's own end-of-run classification step never ran for it — it would otherwise have sat with no risk/status label and nothing downstream would pick it up (see issue #223's actual history). This deterministic backstop (pr-intake.yml) classified its risk and applied status:needs-qa to route it into the normal pipeline from here.

@github-actions

Copy link
Copy Markdown
Contributor

📱 iOS Build Status: PASSED

✅ iOS Simulator Build & Unit Tests - success
⏭️ Android Core Modules - skipped

iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those.

View run details

@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

QA verification — PR #492 vs issue #491

Acceptance criteria (from issue #491's "Suggested fix")

# Criterion Result
1 Filter .cloud out of ttsSection's bare Picker ✅ PASS — SettingsView.swift:229 now TTSEngineType.allCases.filter { $0 != .cloud }; footer copy also fixed (no longer claims "no network access").
2 Add a "Use Cloud Voices for Read Aloud" toggle inside CloudVoicesSection, shown once a provider is selected (not gated on already configured) ✅ PASS — toggle placed inside the existing if let selectedProvider { ... } block (CloudVoicesSection.swift:80-124), so it appears as soon as a provider is picked, before any key is saved.
3 Disabled + explained until the selected provider is actually configured AND a voice id is set ✅ PASS — canActivateCloudEngine(selectedProvider:configuredProviders:voiceID:) requires the selected provider to be in configuredProviders and a non-blank (trimmed) voice id; toggle shows "Configure a provider and voice ID above first" while disabled, and stays enabled to turn off even if canActivate later becomes false.
4 Sets appState.ttsEngineType = .cloud / .system on toggle ✅ PASS — setCloudEngineActive(_:). Turning off always reverts to .system unconditionally, as required.
5 Re-checks CloudTtsGate.canUseCloudTts before actually activating (backstop, not just relying on .disabled) ✅ PASS — setCloudEngineActive calls CloudTtsGate.canUseCloudTts(isSubscribed:consentEnabled:) and no-ops if it fails, matching Android's onUseCloudEngineToggled pattern cited in the issue.

What I ran

No Xcode available on this (Linux) QA runner, same limitation the PR itself notes — so I read the diff/logic directly and then watched the PR's own real CI signal (gh run watch) to completion rather than relying on manual review alone:

  • iOS App Build & Test (build-ios-simulator, macOS runner, real xcodebuild build + xcodebuild test -only-testing:LibraVaultTests): ✅ success, 8m18s. ** BUILD SUCCEEDED ** / ** TEST SUCCEEDED ** in the raw log.
  • Confirmed from the raw log that CloudVoicesSectionTests.swift actually compiled into the LibraVaultTests target and its 6 new cases (testCannotActivateWhenNoProviderIsSelected, testCannotActivateWhenSelectedProviderIsNotConfigured, testCannotActivateWhenVoiceIDIsEmpty, testCannotActivateWhenVoiceIDIsWhitespaceOnly, testCanActivateWhenSelectedProviderIsConfiguredAndVoiceIDIsSet, testCannotActivateWhenADifferentProviderIsConfiguredInstead) each ran and passed individually — not just a suite-level "passed" summary.
  • iOS UI Tests (informational): ✅ success.
  • Android/Gradle: not run — this diff touches only ios/** (confirmed via git diff --stat against origin/dev and the workflow's own Detect Changed Paths job, which reported android: false), so testDebugUnitTest has nothing relevant to exercise here.

Test quality (AGENTS.md "prove a new test can fail" / this repo's mock-past-the-bug history)

canActivateCloudEngine is a brand-new pure static func — it does not exist on the pre-fix commit at all, so the new test file would fail to compile against parent commit 82ba777, which is as strong a regression-guard signal as this codebase's established static-helper convention (isSaveEnabled, nextVoiceID) gets, per this same file's own precedent and EncryptedVaultContentsViewTests's doc comment. Every branch of the gating logic is covered (no provider, wrong provider configured, empty voice id, whitespace-only voice id, happy path, and the "different provider configured" negative case) — no relaxed/loose mocking involved, it's plain value assertions against a pure function.

Regressions / related areas

Grepped the full iOS tree for other TTSEngineType.allCases or ttsEngineType = .cloud call sites — ttsSection's picker is the only other place .cloud was reachable, and it's now the only place filtering it out; no other bare picker exists. CloudTtsGateTests (pre-existing, #472) still passes unmodified, and the new code reuses CloudTtsGate rather than reimplementing gate logic.

AGENTS.md conventions

Branch name fix/cloudtts-ios-engine-activation ✅, commit fix(ios): … Conventional Commits ✅, tests shipped alongside the fix in the same commit (AGENTS.md explicitly allows this when tests are integral) ✅, body's "Closes #491. Part of #452." line matches resolve_linked_issue.sh's line-start regex correctly (verified against the actual script) ✅.

Note for principal review (not a QA blocker): issue #491 carries the security label, whose own description is "dev agent must stop and ask a human, never auto-implement," and the automated dev-agent's triage comment on the issue explicitly declined to open a PR for exactly that reason, applying status:needs-info. No subsequent authorization comment appears on the issue before this PR was opened ~3 minutes later. The PR was opened by libravault-xyz (a User-type GitHub account, not the pipeline bot) directly, which pr-intake.yml's own comment confirms is "outside the automated pipeline." This reads as a human choosing to implement it themselves rather than a pipeline bypass, but I'm flagging it explicitly since it's the kind of authorization-trail question that's principal review's call, not mine, and I don't want it to go unmentioned.

Verdict

All 5 acceptance-criterion items pass, the real CI build+test (including the new tests, individually confirmed) succeeded, the new tests exercise real new logic rather than a relaxed mock, and no regressions were found in related areas.

QA verdict: PASS

@github-actions github-actions Bot removed the status:needs-qa PR open, awaiting qa-agent verification label Aug 24, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-review QA passed, awaiting principal-review-agent label Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Principal review — verdict: auto-merge

Scope: adds an explicit "Use Cloud Voices for Read Aloud" toggle to CloudVoicesSection, gated on canActivateCloudEngine (provider selected + configured + non-blank voice id), re-checks CloudTtsGate before activating, and excludes .cloud from the bare ttsSection picker. Fixes issue #491.

Verified against ground truth

  • CI: confirmed iOS App Build & Test actually ran real xcodebuild build/test (not skipped) and passed — Build & Test iOS (Simulator) and iOS UI Tests (informational) both SUCCESS in statusCheckRollup, matching QA's own log excerpts. risk:low label was applied at 05:12:21, after the PR's only commit (05:09:49) — current, no re-classification needed.
  • Diff read in full (not the PR description) — logic in CloudVoicesSection.swift/SettingsView.swift matches what's described: canActivateCloudEngine is a pure static func, correctly requires the selected provider (not just any configured one) plus a trimmed non-blank voice id; setCloudEngineActive unconditionally reverts to .system on disable and re-checks CloudTtsGate.canUseCloudTts on enable rather than trusting the .disabled UI affordance alone.
  • agent-policy.yml sensitive paths: none of the 3 changed files match any glob (not Billing*, not workflows/keystore/vault paths) — confirmed by reading the file list against the policy directly, not assuming.
  • No new networking dependency/call: this PR only flips appState.ttsEngineType; the actual network path (CloudTtsEngine, vendor adapters) was already merged and authorized in earlier PRs (feat(ios): Cloud TTS vendor adapters — 5 vendors + AWS SigV4 signer #476, feat(ios): Cloud TTS engine wiring — makes Cloud TTS reachable #478, feat(ios): Cloud Voices Settings UI — completes iOS #452 #482). Checked the app for other network call sites (MermaidDiagramView.swift was the only other URLRequest hit) — that's a fully local WKURLSchemeHandler with default-src 'none' CSP, no real network — so the PR's new footer copy ("Cloud Voices... is the only other network activity this app can ever have") is factually accurate, not just asserted.
  • Authorization trail for the security-labeled originating issue (flagged explicitly by QA as "principal review's call"): iOS Cloud Voices: TTS engine picker exposes .cloud unfiltered, no activation toggle wired to configuration state #491 itself has no standalone human-authorization comment — the automated dev-agent triage correctly declined and parked it on status:needs-info for exactly that reason. But this PR was authored directly by libravault-xyz (User, not app/libravault-pipeline-bot) — i.e. the human's own interactive session, not the unsupervised background dev-agent the security gate in agent-policy.yml is written to constrain ("dev agent must stop and ask a human, never auto-implement"). This matches established, repeated precedent in this exact epic: PR feat(ios): Cloud TTS vendor adapters — 5 vendors + AWS SigV4 signer #476 and PR feat(ios): Cloud TTS engine wiring — makes Cloud TTS reachable #478 were also authored directly by libravault-xyz, both citing "Part of Premium Cloud TTS Voices — iOS implementation (BYOK, 5 presets) #452," which already carries two explicit "Human authorization to proceed (security-sensitive gate acknowledged)" comments (2026-08-23 08:18/08:21) covering this feature's security-sensitive scope. This PR is a same-epic bugfix to already-authorized plumbing, not new scope. I don't read this as an authorization bypass.

Findings

No CONFIRMED-severity findings.

One PLAUSIBLE, non-blocking note for whoever touches this next: ttsSection's segmented Picker binds to $appState.ttsEngineType over TTSEngineType.allCases.filter { $0 != .cloud }. When the new toggle sets ttsEngineType = .cloud, the picker's bound selection no longer matches any of its own displayed segments — SwiftUI segmented pickers typically render with nothing highlighted in that state, so the "Voice" picker and the new "Use Cloud Voices" toggle could visually disagree about what's active while Cloud Voices is on. Couldn't confirm the actual rendered behavior (no Xcode/simulator available here, same limitation the PR and QA both noted) — worth a quick look in the simulator, not worth blocking on.

Risk label (risk:low) stands; no CONFIRMED findings to override it.

@github-actions github-actions Bot added status:approved-auto-merge Principal review passed, risk:low — will auto-merge and removed status:needs-review QA passed, awaiting principal-review-agent labels Aug 24, 2026
@github-actions
github-actions Bot merged commit e5fbb79 into dev Aug 24, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Principal review classified this PR as low risk status:approved-auto-merge Principal review passed, risk:low — will auto-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS Cloud Voices: TTS engine picker exposes .cloud unfiltered, no activation toggle wired to configuration state

1 participant