Add a toggle

This commit is contained in:
Stephen 2026-06-02 07:50:20 -04:00
parent ca2df1efd2
commit c504ef3ef5
4 changed files with 19 additions and 1 deletions

View file

@ -21,6 +21,7 @@ enum AppBootstrapper {
UserDefaults.standard.register(defaults: [
"enableAdvancedOptions": enableAdvancedOptions,
UserDefaults.Keys.txmOverride: false,
UserDefaults.Keys.confirmExternalJITRequests: true,
"keepAliveAudio": true,
"keepAliveLocation": true
])

View file

@ -9,6 +9,8 @@ extension UserDefaults {
enum Keys {
/// Forces the app to treat the current device as TXM-capable so scripts always run.
static let txmOverride = "overrideTXMForScripts"
/// Requires confirmation before external links can enable JIT.
static let confirmExternalJITRequests = "confirmExternalJITRequests"
static let bundleScriptMap = "BundleScriptMap"
static let defaultScriptName = "DefaultScriptName"
static let defaultScriptNameValue = ""

View file

@ -10,6 +10,7 @@ import SwiftUI
struct HomeView: View {
@AppStorage("autoQuitAfterEnablingJIT") private var doAutoQuitAfterEnablingJIT = false
@AppStorage("bundleID") private var bundleID: String = ""
@AppStorage(UserDefaults.Keys.confirmExternalJITRequests) private var confirmExternalJITRequests = true
@ObservedObject private var mounting = MountingProgress.shared
@ -180,7 +181,12 @@ struct HomeView: View {
config.scriptData = scriptInfo.data
config.scriptName = scriptInfo.name
}
pendingExternalURLAction = .enableJIT(config)
let action = HomeExternalAction.enableJIT(config)
if confirmExternalJITRequests {
pendingExternalURLAction = action
} else {
performExternalURLAction(action)
}
case "kill-process":
if let pidStr = queryValue(["pid"], in: components), let pid = Int(pidStr) {
pendingExternalURLAction = .killProcess(pid)

View file

@ -15,6 +15,7 @@ private enum SettingsLinks {
struct SettingsView: View {
@AppStorage(UserDefaults.Keys.txmOverride) private var overrideTXMDetection = false
@AppStorage(UserDefaults.Keys.confirmExternalJITRequests) private var confirmExternalJITRequests = true
@AppStorage("keepAliveAudio") private var keepAliveAudio = true
@AppStorage("keepAliveLocation") private var keepAliveLocation = true
@ -112,6 +113,14 @@ struct SettingsView: View {
}
Section("Behavior") {
Toggle(isOn: $confirmExternalJITRequests) {
VStack(alignment: .leading, spacing: 2) {
Text("Confirm JIT Links")
Text("Ask before external links enable JIT or run scripts.")
.font(.caption).foregroundStyle(.secondary)
}
}
Toggle(isOn: $overrideTXMDetection) {
VStack(alignment: .leading, spacing: 2) {
Text("Always Run Scripts")