mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
Steps 3 and 4 of the phone side, on the shared reader's latest (21cdab23). - Settings › Keyboard › Typing configs (beside Vocabulary, only while the experiment is on): Hex defaults first, then every kept config newest first with its status (In use, Best so far, applied or opened when), Use on each row (one tap, deletes nothing), and Delete all. A config's page shows its facts (based on, made from another iPhone's typing), Use or Use Hex defaults instead, Rename, Share (the kept file, unchanged) and Delete, and its parts with their switches (TypingConfigParts, shared with the review sheet), applied at once while it is the one in use. - History: never refuses a new config. At 20 the oldest that is neither active nor best so far goes, and the review names it before Apply (replaces the old refusal). Not now keeps the parts switched off. Records this phone's export ids. - Experiment off: the sheet's first action is Turn on typing configs, which shows the review at once; Open Experiments stays as the quieter second. - The review now reads the keyboards the Hex keyboard recorded (TypingConfigSettings .keyboards) instead of a keyboard the app built (TypingConfigKeyboard.swift removed), and each item's own list, position, evidence and cleaned text instead of indexing by path; the note is the review's cleaned one. With no keyboard recorded yet the sheet says so under For another keyboard. hiddenCharacters has its sentence. The active config is compiled again when Hex comes to the foreground and a keyboard was recorded since. - Delete what Hex learned also deletes every typing config and goes back to Hex defaults; its confirmation says so. - Export for your agent (Typing logs, experiment on): the warning sheet every time (design §5's wording, a variant for fewer days), the days to include, then one zip: the bundled package (ios/TypingConfig/package as a folder resource), the chosen logs and state/ (phone.json as state.md defines it, the recorded keyboards' layout; vocabulary.json with each word's model cost and spell-checker answer). Deleted once the share sheet closes. - Hex's own dictation (handed to Hex, Action Button) applies the active config's dictation fixes after Learn how I type's, never to a translated dictation (TypingConfigDictation). - Strings in English and Simplified Chinese. Verified on the Studio (iOS 27.2): TypingLogTests 15 of 15 (history at the limit, apply and go back, dictation fixes off for translation); every screen on iPhone 17 Pro and iPhone SE (3rd gen) in English and 简体中文; the export of two real days (6.6 MB of logs) is a 772 KB zip, built in about 2.5 s from Continue; its state/ read by the package's overview.py; the share sheet offers Copy, Save to Files and More (AirDrop and other apps don't show on the simulator). Through the real keyboard (Full Access granted in the simulator's TCC database, the keyboard's typing log and Full Access report confirming it), a tap 3.35 pt inside r types R with Hex defaults and E with a key-off config applied through the review sheet (e's right edge +0.2, word-rule evidence), the keyboard closed and opened in between.
116 lines
5.2 KiB
Swift
116 lines
5.2 KiB
Swift
import SwiftUI
|
|
|
|
/// Export for your agent: the warning, every time (design §5: it is true because the logs skip
|
|
/// only fields marked password, one-time code, card or secure), the days to include, then
|
|
/// Continue builds the zip and opens the share sheet. The zip is deleted once shared.
|
|
struct TypingConfigExportSheet: View {
|
|
let days: [TypingLogDay]
|
|
@Environment(\.dismiss) private var dismiss
|
|
@State private var chosen: Set<String>
|
|
@State private var building = false
|
|
@State private var failure: String?
|
|
|
|
init(days: [TypingLogDay]) {
|
|
self.days = days
|
|
_chosen = State(initialValue: Set(days.map(\.day)))
|
|
}
|
|
|
|
private var chosenDays: [TypingLogDay] { days.filter { chosen.contains($0.day) } }
|
|
private var allChosen: Bool { chosen.count == days.count }
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
TypingConfigSheetHeader(title: String(localized: "Export for your agent"), close: { dismiss() })
|
|
|
|
Text("One file with your typing logs and a skill your own AI agent follows to make a typing config for you. Open the file it makes on this iPhone to review it.")
|
|
.font(.system(size: 15))
|
|
.foregroundStyle(HexTheme.textMuted)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
|
|
HStack(alignment: .top, spacing: 10) {
|
|
Image(systemName: "exclamationmark.triangle")
|
|
.font(.system(size: 14))
|
|
.foregroundStyle(HexTheme.textBase)
|
|
.padding(.top, 1)
|
|
Text(allChosen
|
|
? String(localized: "This holds everything you typed and dictated with Hex in the last 14 days, including any password you typed outside a password field. Give it only to an agent you trust, and don't upload it anywhere you wouldn't share your messages.")
|
|
: String(localized: "This holds everything you typed and dictated with Hex on the days you chose, including any password you typed outside a password field. Give it only to an agent you trust, and don't upload it anywhere you wouldn't share your messages."))
|
|
.font(.system(size: 14))
|
|
.foregroundStyle(HexTheme.textBase)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
}
|
|
.padding(14)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.background(HexTheme.bgBase, in: RoundedRectangle(cornerRadius: HexTheme.cardRadius, style: .continuous))
|
|
|
|
SettingsSectionHeader(title: "Days")
|
|
SettingsCard {
|
|
ForEach(Array(days.enumerated()), id: \.element.id) { n, day in
|
|
if n > 0 { SettingsDivider() }
|
|
dayRow(day)
|
|
}
|
|
}
|
|
|
|
if let failure {
|
|
Text(failure)
|
|
.font(.system(size: 13))
|
|
.foregroundStyle(HexTheme.danger)
|
|
}
|
|
|
|
VStack(spacing: 4) {
|
|
OnboardingPrimaryButton(title: building ? "Preparing…" : "Continue", enabled: !building && !chosen.isEmpty, action: export)
|
|
OnboardingQuietButton(title: "Cancel") { dismiss() }
|
|
}
|
|
.padding(.top, 4)
|
|
}
|
|
.frame(maxWidth: 500)
|
|
.padding(.horizontal, 20)
|
|
.padding(.top, 24)
|
|
.padding(.bottom, 20)
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
.scrollBounceBehavior(.basedOnSize)
|
|
.background(HexTheme.bgDeep.ignoresSafeArea())
|
|
.presentationBackground(HexTheme.bgDeep)
|
|
.preferredColorScheme(.dark)
|
|
.interactiveDismissDisabled(building)
|
|
}
|
|
|
|
private func dayRow(_ day: TypingLogDay) -> some View {
|
|
Button {
|
|
if chosen.contains(day.day) { chosen.remove(day.day) } else { chosen.insert(day.day) }
|
|
} label: {
|
|
HStack(spacing: 12) {
|
|
SettingsRowLabel(title: TypingLogsView.title(day), detail: ByteCountFormatter.string(fromByteCount: Int64(day.bytes), countStyle: .file))
|
|
Spacer(minLength: 8)
|
|
Image(systemName: chosen.contains(day.day) ? "checkmark.circle.fill" : "circle")
|
|
.font(.system(size: 20))
|
|
.foregroundStyle(chosen.contains(day.day) ? HexTheme.textBase : HexTheme.textFaint)
|
|
}
|
|
.padding(.horizontal, 16)
|
|
.frame(minHeight: 50)
|
|
.contentShape(Rectangle())
|
|
}
|
|
.buttonStyle(.plain)
|
|
.accessibilityAddTraits(chosen.contains(day.day) ? .isSelected : [])
|
|
}
|
|
|
|
private func export() {
|
|
building = true
|
|
failure = nil
|
|
Task {
|
|
do {
|
|
let built = try await TypingConfigExport.build(days: chosenDays)
|
|
building = false
|
|
ShareSheet.present([built.url]) {
|
|
TypingConfigExport.discard(built)
|
|
dismiss()
|
|
}
|
|
} catch {
|
|
building = false
|
|
failure = String(localized: "Hex couldn't prepare the export. Nothing was shared.")
|
|
}
|
|
}
|
|
}
|
|
}
|