mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
* iOS: Send feedback form that posts to Bellhop Adds a Send feedback form to the Hex app (never the keyboard) that sends one report to Bellhop, Anomaly's feedback inbox, following blhp.app/docs/feedback's "Building a feedback form" checklist: - Entry points: a Send feedback row on Home's Privacy policy / Support / Acknowledgements card, and one at the end of Settings › Experiments. Both are absent in a build without a report key. - The form: Problem / Idea / Question / Other, an optional subject, the message, pictures (Hex's own key window drawn just before the form opens, removable with one tap; more from the permission-free photo picker, up to 5), an optional email, Send anonymously (hides the email and drops email and install id), and what is sent in plain words. Limits are checked before sending (message 20,000, subject 200, 5 pictures, 10 MiB each, 20 MiB in all); every picture is re-encoded as JPEG at 80% with its longest side at most 2048 px (HEIC included). - Sending: multipart/form-data with a payload JSON part and screenshot parts, an Idempotency-Key made at the tap and reused for every retry, visible upload progress, network failures and 5xx retried 4 times with 1/2/4 s backoff, 409 request_pending and 429 retried after Retry-After, other 4xx never retried. 401 and 403 feedback_disabled are logged as a fault and shown as "unavailable"; 413, 415, 429 and offline get kind words. A thank-you says, when the answer has email "pending", that a reply comes by email and the address needs confirming once. - Payload: message, subject, category, app, device (model identifier, BCP 47 locale), metadata (screen, dictation_language, speech_model), email and a random install id kept in Hex's UserDefaults. No user, no logs, nothing Hex keeps on the phone. - Report key: BELLHOP_REPORT_KEY in HEXMobile/Feedback.xcconfig (empty in git), set by a gitignored Feedback.local.xcconfig or by ci_post_clone.sh from Xcode Cloud's BELLHOP_REPORT_KEY secret, read at run time from Info.plist's BellhopReportKey. No key lives in Swift. - Debug-only launch arguments (--feedback-log-request, --feedback-key, --feedback-endpoint, --feedback-drop-first-response, --feedback-broken-image) for simulator proof of each path. - Simplified Chinese for every new string; docs in ios/docs/settings-and-home.md. Verified on the Studio's iPhone 17 Pro simulator (iOS 27.2) through the form itself: a send with picture and email got 201 #3, email "pending"; an anonymous send got 201 #4, email "none", with no email or install_id in the payload; a dropped first answer was retried with the same key and got the same #5; a wrong key got one 401 and "unavailable"; a refused connection was tried 4 times (0, +1, +3, +7 s) with one key, then said offline; a half-cut picture got one 415. The keyboard appex has no Bellhop key or address. code-shape.py --check passes. No unit test: no existing HEXMobileTests file covers the app's networking. * Privacy: say what Send feedback sends, when and to whom The app's Privacy page and the website's privacy policy (site/src/iphone.ts) said Hex collects no data. With Send feedback that's no longer exact, so: - Settings › Privacy gets a Feedback note (only in builds with a report key): nothing is sent until Send; then the message, pictures kept, email if given and details about Hex and the iPhone go to Anomaly's feedback inbox; dictations, typing and what Hex learned never do. - The policy's summary, card line (CARD_VERSION 2) and description now say Hex sends only the feedback you choose to send; a new "Feedback you send" section lists every field, when (only on Send), to whom (Anomaly's feedback inbox, Bellhop), what anonymous drops, and what is never included; "no servers your words could be sent to" and the children line are reworded to stay true. The header comment that checks claims against ios/ names the new request. Verified: site bun test passes (20/20) and renderPrivacy renders the new section; the Privacy page's string has its Simplified Chinese. * iOS feedback: the email decides anonymous, no Send anonymously switch Ryan: one thing instead of two. The optional email now decides: - An email given: not anonymous; the email and the install id are sent, as before. - No email: "anonymous": true, no email and no install id (none is made for an anonymous send), no user, nothing identifying in metadata. - A typed email that isn't an address stops Send; once they leave the field the form says "That isn't an email address. Fix it, or clear it to send without one." It is never sent broken or as anonymous by accident. Removed: the Send anonymously switch and its strings. Added one line under the email field, "With an email, the team can reply. Without one, your feedback is anonymous.", and the what-is-sent paragraph follows the field (the install id is named only with an email). The website policy's feedback section now covers Hex on iPhone and on Android together, for the Android form being built alongside. Simplified Chinese for the new strings; docs updated. Verified on the Studio's iPhone 17 Pro simulator through the form: with ryan@anoma.ly and Hex's window picture, 201 #6, email "pending", payload with email and install_id; with no email, 201 #7, email "none", payload "anonymous": true and no email, install_id or user. No existing HEXMobileTests file covers the feedback payload, so no test case changed. * iOS feedback: ship the report key in Feedback.xcconfig The key only came from a gitignored local file or an Xcode Cloud secret that doesn't exist, so a TestFlight build would have had no Send feedback row. Bellhop report keys are publishable and safe to ship inside an app, and Android keeps its key in android/gradle.properties, so: - HEXMobile/Feedback.xcconfig now sets BELLHOP_REPORT_KEY. The optional include of Feedback.local.xcconfig stays after it, so a local file or ci_post_clone.sh (from an Xcode Cloud BELLHOP_REPORT_KEY secret, if one is ever set) overrides it, for a rotation. Still no key in Swift; it reaches the app as Info.plist's BellhopReportKey. - ci_post_clone.sh and the docs say so; rotation: new key, revoke the old in Bellhop › Settings › Report keys, change the xcconfig, ship a build. - FeedbackSender logs "feedback sent as #<number>" (notice, public), so a Release build's send can be traced to its issue. Verified from a clean tree of this commit (git archive, no local override) on the Studio: a Release simulator build's Info.plist carries the key, the app shows Send feedback on Home and a send through the form got 201.
403 lines
15 KiB
Swift
403 lines
15 KiB
Swift
import SwiftUI
|
||
|
||
/// Settings › Experiments: unfinished features grouped by domain (Dictation, Languages,
|
||
/// Keyboard layout, Typing), off until turned on. They live in the App Group so the keyboard
|
||
/// reads them too.
|
||
struct ExperimentsSettingsPage: View {
|
||
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
||
@State private var revision = 0
|
||
@State private var cleanupAvailability = AppleIntelligenceCleanupAvailability.current
|
||
@State private var adaptiveTouchStatus = AdaptiveTouchStatus.sessionOnly
|
||
@State private var confirmingTouchReset = false
|
||
@State private var multilingualParakeet = MultilingualParakeetSettings().isEnabled
|
||
private let multilingualParakeetFits = MultilingualParakeetSettings.fits()
|
||
|
||
private func toggleBinding(_ get: @escaping () -> Bool, _ set: @escaping (Bool) -> Void) -> Binding<Bool> {
|
||
Binding(
|
||
get: {
|
||
_ = revision
|
||
return get()
|
||
},
|
||
set: { value in
|
||
set(value)
|
||
revision += 1
|
||
}
|
||
)
|
||
}
|
||
|
||
private func keyboardBinding(_ keyPath: WritableKeyPath<FullKeyboardSettings, Bool>) -> Binding<Bool> {
|
||
toggleBinding(
|
||
{ FullKeyboardSettings()[keyPath: keyPath] },
|
||
{
|
||
var current = FullKeyboardSettings()
|
||
current[keyPath: keyPath] = $0
|
||
}
|
||
)
|
||
}
|
||
|
||
private var adaptiveTouchOn: Bool {
|
||
_ = revision
|
||
return AdaptiveTouchSettings().isEnabled
|
||
}
|
||
|
||
private var keyboardThemesOn: Bool {
|
||
_ = revision
|
||
return FullKeyboardSettings().keyboardThemesEnabled
|
||
}
|
||
|
||
private var spatialAutocorrectOn: Bool {
|
||
_ = revision
|
||
let settings = FullKeyboardSettings()
|
||
return settings.autocorrect && settings.spatialAutocorrect
|
||
}
|
||
|
||
var body: some View {
|
||
SettingsPageScaffold(title: "Experiments") {
|
||
dictationSection
|
||
languagesSection
|
||
layoutSection
|
||
typingSection
|
||
|
||
// Testers tell the team how an experiment went (absent without a report key).
|
||
if Feedback.isAvailable {
|
||
SettingsCard {
|
||
FeedbackRow(screen: "Settings › Experiments", dictation: DictationController.shared)
|
||
}
|
||
.padding(.top, 8)
|
||
}
|
||
}
|
||
.animation(HexMotion.settleAnimation(reduceMotion: reduceMotion), value: adaptiveTouchOn)
|
||
.animation(HexMotion.settleAnimation(reduceMotion: reduceMotion), value: keyboardThemesOn)
|
||
.onChange(of: multilingualParakeet) { _, enabled in
|
||
guard enabled != MultilingualParakeetSettings().isEnabled else { return }
|
||
MultilingualParakeetSettings().isEnabled = enabled
|
||
// On: downloads beside the engine that dictates; off: stops and deletes it.
|
||
DictationController.shared.multilingualParakeetChanged()
|
||
}
|
||
.onAppear {
|
||
cleanupAvailability = AppleIntelligenceCleanupAvailability.current
|
||
multilingualParakeet = MultilingualParakeetSettings().isEnabled
|
||
refreshAdaptiveTouchStatus()
|
||
revision += 1
|
||
}
|
||
}
|
||
|
||
@ViewBuilder
|
||
private var dictationSection: some View {
|
||
SettingsSectionHeader(title: "Dictation")
|
||
|
||
SettingsCard {
|
||
SettingsToggleRow(
|
||
title: String(localized: "Multilingual model (Parakeet)"),
|
||
detail: multilingualParakeetFits
|
||
? String(localized: "25 languages, even mixed in one sentence. \(ParakeetUltraTranscriber.downloadSize) download. Once ready, keyboard dictation opens Hex.")
|
||
: String(localized: "Needs an iPhone with 6 GB of memory or more"),
|
||
isOn: $multilingualParakeet
|
||
)
|
||
.disabled(!multilingualParakeetFits)
|
||
|
||
if multilingualParakeet {
|
||
MultilingualModelStatus(
|
||
download: DictationController.shared.multilingualDownload,
|
||
retry: { DictationController.shared.retryMultilingualParakeet() },
|
||
turnOff: { multilingualParakeet = false }
|
||
)
|
||
.padding(.horizontal, 12)
|
||
.padding(.bottom, 12)
|
||
}
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Two-language dictation"),
|
||
detail: String(localized: "Checks a second keyboard language and keeps the better match."),
|
||
isOn: toggleBinding(
|
||
{ TwoLanguageDictationSettings().isEnabled },
|
||
{ TwoLanguageDictationSettings().isEnabled = $0 }
|
||
)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Voice isolation"),
|
||
detail: String(localized: "Records with Apple's voice chat processing so Control Center's Mic Mode can offer Voice Isolation. Other audio may be lowered while recording, and Bluetooth headphones may switch to the call (hands-free) profile."),
|
||
isOn: toggleBinding(
|
||
{ VoiceIsolationSettings().isEnabled },
|
||
{ VoiceIsolationSettings().isEnabled = $0 }
|
||
)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Clean up with Apple Intelligence"),
|
||
detail: cleanupAvailability.reason ?? String(localized: "Fixes misheard words on device"),
|
||
isOn: toggleBinding(
|
||
{ AppleIntelligenceCleanupSettings().isEnabled },
|
||
{ AppleIntelligenceCleanupSettings().isEnabled = $0 }
|
||
)
|
||
)
|
||
.disabled(!cleanupAvailability.isAvailable)
|
||
}
|
||
}
|
||
|
||
@ViewBuilder
|
||
private var languagesSection: some View {
|
||
SettingsSectionHeader(title: "Languages")
|
||
|
||
SettingsCard {
|
||
SettingsToggleRow(
|
||
title: String(localized: "Hinglish (Hindi in Latin letters)"),
|
||
detail: String(localized: "Adds Hinglish to dictation languages"),
|
||
isOn: toggleBinding(
|
||
{ HinglishSettings().isEnabled },
|
||
{ HinglishSettings().isEnabled = $0 }
|
||
)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Greeklish (Greek in Latin letters)"),
|
||
detail: String(localized: "Adds Greeklish to dictation languages"),
|
||
isOn: toggleBinding(
|
||
{ GreeklishSettings().isEnabled },
|
||
{ GreeklishSettings().isEnabled = $0 }
|
||
)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Korean keyboard (두벌식)"),
|
||
detail: String(localized: "Adds 한국어, composing syllables as you type"),
|
||
isOn: keyboardBinding(\.koreanKeyboard)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Swipe typing in more languages"),
|
||
detail: String(localized: "French and Polish, and German with German spatial autocorrect"),
|
||
isOn: keyboardBinding(\.swipeMoreLanguages)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "German spatial autocorrect"),
|
||
detail: String(localized: "Needs Spatial autocorrect"),
|
||
isOn: keyboardBinding(\.germanSpatialAutocorrect)
|
||
)
|
||
.disabled(!spatialAutocorrectOn)
|
||
}
|
||
}
|
||
|
||
@ViewBuilder
|
||
private var layoutSection: some View {
|
||
SettingsSectionHeader(title: "Keyboard layout")
|
||
|
||
SettingsCard {
|
||
SettingsToggleRow(
|
||
title: String(localized: "Comma and period keys"),
|
||
detail: String(localized: "Puts comma and period keys beside the space bar on the letters keyboard."),
|
||
isOn: keyboardBinding(\.commaPeriodKeys)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Dvorak punctuation keys"),
|
||
detail: String(localized: "Adds comma, period and semicolon keys to the English Dvorak keyboard."),
|
||
isOn: keyboardBinding(\.dvorakPunctuation)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Quick accents"),
|
||
detail: String(localized: "Holding a letter selects its main accent, so letting go types it. Slide to pick another."),
|
||
isOn: keyboardBinding(\.quickAccents)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "ABC under the emoji key"),
|
||
detail: String(localized: "In the emoji panel, ABC takes the emoji key's place"),
|
||
isOn: keyboardBinding(\.emojiLettersUnderEmojiKey)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Keyboard themes"),
|
||
isOn: keyboardBinding(\.keyboardThemesEnabled)
|
||
)
|
||
|
||
if keyboardThemesOn {
|
||
SettingsDivider()
|
||
KeyboardThemeRow(
|
||
theme: Binding(
|
||
get: {
|
||
_ = revision
|
||
return FullKeyboardSettings().keyboardTheme
|
||
},
|
||
set: { value in
|
||
FullKeyboardSettings().keyboardTheme = value
|
||
revision += 1
|
||
}
|
||
)
|
||
)
|
||
}
|
||
|
||
// Only relevant on foldable hardware (iPhone Duo): hide on slab iPhones.
|
||
if FullKeyboardView.isFoldable {
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Join the keyboard when unfolded"),
|
||
detail: String(localized: "On the iPhone Duo unfolded, keeps the keys on one keyboard instead of splitting them."),
|
||
isOn: keyboardBinding(\.joinsKeyboardWhenUnfolded)
|
||
)
|
||
}
|
||
}
|
||
}
|
||
|
||
@ViewBuilder
|
||
private var typingSection: some View {
|
||
SettingsSectionHeader(title: "Typing")
|
||
|
||
SettingsCard {
|
||
SettingsToggleRow(
|
||
title: String(localized: "Adaptive touch"),
|
||
detail: String(localized: "Learns where you tap each key."),
|
||
isOn: toggleBinding(
|
||
{ AdaptiveTouchSettings().isEnabled },
|
||
{ enabled in
|
||
AdaptiveTouchSettings().isEnabled = enabled
|
||
refreshAdaptiveTouchStatus()
|
||
}
|
||
)
|
||
)
|
||
|
||
if adaptiveTouchOn {
|
||
Text(adaptiveTouchStatusText)
|
||
.font(.system(size: 12))
|
||
.foregroundStyle(HexTheme.textMuted)
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
.padding(.horizontal, 16)
|
||
.padding(.bottom, 10)
|
||
.accessibilityIdentifier("adaptive-touch-status")
|
||
|
||
SettingsDivider()
|
||
|
||
Button {
|
||
confirmingTouchReset = true
|
||
} label: {
|
||
Text("Reset touch learning")
|
||
.font(.system(size: 15, weight: .regular))
|
||
.foregroundStyle(HexTheme.danger)
|
||
.frame(maxWidth: .infinity, minHeight: 50, alignment: .leading)
|
||
.padding(.horizontal, 16)
|
||
.contentShape(Rectangle())
|
||
}
|
||
.buttonStyle(.plain)
|
||
.confirmationDialog("Reset touch learning?", isPresented: $confirmingTouchReset, titleVisibility: .visible) {
|
||
Button("Reset touch learning", role: .destructive) {
|
||
AdaptiveTouchSettings().requestReset()
|
||
refreshAdaptiveTouchStatus()
|
||
}
|
||
}
|
||
}
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Two-thumb selection"),
|
||
detail: String(localized: "On the space bar trackpad, a second thumb selects text"),
|
||
isOn: keyboardBinding(\.twoThumbSelection)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Delete swiped words letter by letter"),
|
||
isOn: keyboardBinding(\.deletesSwipedWordsLetterByLetter)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Hide word suggestions"),
|
||
detail: String(localized: "Autocorrect still works"),
|
||
isOn: keyboardBinding(\.hideWordSuggestions)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Emoji shortcodes"),
|
||
detail: String(localized: "Type a colon and a name, like :pizza, to pick an emoji."),
|
||
isOn: keyboardBinding(\.emojiShortcodes)
|
||
)
|
||
|
||
SettingsDivider()
|
||
|
||
SettingsToggleRow(
|
||
title: String(localized: "Learn each language separately"),
|
||
detail: String(localized: "Learned words and fixes stay with their language"),
|
||
isOn: toggleBinding(
|
||
{ TypingJournalSettings().learnsPerLanguage },
|
||
{ TypingJournalSettings().learnsPerLanguage = $0 }
|
||
)
|
||
)
|
||
}
|
||
}
|
||
|
||
private var adaptiveTouchStatusText: String {
|
||
switch adaptiveTouchStatus {
|
||
case .sessionOnly:
|
||
String(localized: "Without Full Access, resets when the keyboard closes")
|
||
case .learning(let taps):
|
||
String(localized: "Learning: \(taps) of \(AdaptiveTouchModel.activeTaps) taps")
|
||
case .active:
|
||
String(localized: "Active, using your own key centers")
|
||
}
|
||
}
|
||
|
||
private func refreshAdaptiveTouchStatus() {
|
||
adaptiveTouchStatus = SettingsSnapshotFixture.adaptiveTouchStatus
|
||
?? AdaptiveTouchStatus.current(fullAccessConfirmed: KeyboardBridge().fullAccessSeenAt != nil)
|
||
}
|
||
}
|
||
|
||
/// Experiments › Keyboard themes: the theme the full keyboard draws while it's on.
|
||
private struct KeyboardThemeRow: View {
|
||
@Binding var theme: KeyboardTheme
|
||
|
||
var body: some View {
|
||
HStack(spacing: 12) {
|
||
SettingsRowLabel(title: String(localized: "Theme"))
|
||
Spacer(minLength: 8)
|
||
Menu {
|
||
ForEach(KeyboardTheme.allCases, id: \.self) { option in
|
||
Button {
|
||
theme = option
|
||
} label: {
|
||
if theme == option {
|
||
Label(option.name, systemImage: "checkmark")
|
||
} else {
|
||
Text(option.name)
|
||
}
|
||
}
|
||
}
|
||
} label: {
|
||
SettingsMenuValue(value: theme.name)
|
||
}
|
||
}
|
||
.padding(.horizontal, 16)
|
||
.frame(minHeight: 50)
|
||
}
|
||
}
|