feat(keyboard): add clipboard history and undo pastes
Ship optional keyboard clipboard history with settings, suggestion strip, and paste-permission guidance; let undo roll back clipboard inserts; bump build to 64.
This commit is contained in:
@@ -39,6 +39,10 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
public static let polishIntensity = "config.polishIntensity"
|
||||
public static let aiResponseLength = "config.aiResponseLength"
|
||||
public static let llmThinkingEnabled = "config.llmThinkingEnabled"
|
||||
/// When true, the keyboard records system clipboard text into local history.
|
||||
public static let clipboardHistoryEnabled = "config.clipboardHistoryEnabled"
|
||||
/// When true (and history is on), show the newest clipboard item as a suggestion strip.
|
||||
public static let clipboardCandidateBarEnabled = "config.clipboardCandidateBarEnabled"
|
||||
public static let detectedAppContext = "config.detectedAppContext"
|
||||
public static let detectedAppContextAt = "config.detectedAppContextAt"
|
||||
public static let personalDictionary = "config.personalDictionary.v1"
|
||||
@@ -94,6 +98,10 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
public var aiResponseLength: AIResponseLength
|
||||
/// Enables provider-specific reasoning / thinking controls for polish LLM requests.
|
||||
public var llmThinkingEnabled: Bool
|
||||
/// Opt-in clipboard history capture in the keyboard extension.
|
||||
public var clipboardHistoryEnabled: Bool
|
||||
/// Opt-in clipboard suggestion strip above the key surfaces.
|
||||
public var clipboardCandidateBarEnabled: Bool
|
||||
public var personalDictionary: PersonalDictionary
|
||||
public var polishStyleCatalog: PolishStyleCatalog
|
||||
public var activePolishStyleId: String
|
||||
@@ -269,6 +277,8 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
storedRawValue: defaults.string(forKey: Keys.aiResponseLength)
|
||||
),
|
||||
llmThinkingEnabled: defaults.bool(forKey: Keys.llmThinkingEnabled),
|
||||
clipboardHistoryEnabled: defaults.bool(forKey: Keys.clipboardHistoryEnabled),
|
||||
clipboardCandidateBarEnabled: defaults.bool(forKey: Keys.clipboardCandidateBarEnabled),
|
||||
personalDictionary: decodePersonalDictionary(from: defaults),
|
||||
polishStyleCatalog: decodePolishStyleCatalog(from: defaults),
|
||||
activePolishStyleId: defaults.string(forKey: Keys.activePolishStyleId)
|
||||
@@ -401,6 +411,8 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
defaults.set(polishIntensity.rawValue, forKey: Keys.polishIntensity)
|
||||
defaults.set(aiResponseLength.rawValue, forKey: Keys.aiResponseLength)
|
||||
defaults.set(llmThinkingEnabled, forKey: Keys.llmThinkingEnabled)
|
||||
defaults.set(clipboardHistoryEnabled, forKey: Keys.clipboardHistoryEnabled)
|
||||
defaults.set(clipboardCandidateBarEnabled, forKey: Keys.clipboardCandidateBarEnabled)
|
||||
defaults.set(activePolishStyleId, forKey: Keys.activePolishStyleId)
|
||||
defaults.set(flowSkipAppSwitch, forKey: Keys.flowSkipAppSwitch)
|
||||
defaults.set(flowInactivityDuration.rawValue, forKey: Keys.flowInactivityDuration)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// ClipboardHistoryEntry.swift
|
||||
// OSGKeyboard · Shared
|
||||
//
|
||||
// One persisted clipboard history row (plain text / Unicode emoji only).
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct ClipboardHistoryEntry: Codable, Equatable, Identifiable, Sendable {
|
||||
public let id: UUID
|
||||
public var text: String
|
||||
public var createdAt: Date
|
||||
/// Pasteboard changeCount when this row was captured (best-effort).
|
||||
public var changeCount: Int?
|
||||
|
||||
public init(
|
||||
id: UUID = UUID(),
|
||||
text: String,
|
||||
createdAt: Date = Date(),
|
||||
changeCount: Int? = nil
|
||||
) {
|
||||
self.id = id
|
||||
self.text = text
|
||||
self.createdAt = createdAt
|
||||
self.changeCount = changeCount
|
||||
}
|
||||
}
|
||||
@@ -260,6 +260,26 @@ public final class ProviderConfig: ObservableObject, @unchecked Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
/// When enabled, the keyboard records clipboard text into a local history list.
|
||||
@Published public var clipboardHistoryEnabled: Bool {
|
||||
didSet {
|
||||
guard !isApplyingConfiguration,
|
||||
clipboardHistoryEnabled != configuration.clipboardHistoryEnabled else { return }
|
||||
configuration.clipboardHistoryEnabled = clipboardHistoryEnabled
|
||||
persistConfiguration(postConfigChanged: true)
|
||||
}
|
||||
}
|
||||
|
||||
/// When enabled (and history is on), show the newest clipboard item as a suggestion strip.
|
||||
@Published public var clipboardCandidateBarEnabled: Bool {
|
||||
didSet {
|
||||
guard !isApplyingConfiguration,
|
||||
clipboardCandidateBarEnabled != configuration.clipboardCandidateBarEnabled else { return }
|
||||
configuration.clipboardCandidateBarEnabled = clipboardCandidateBarEnabled
|
||||
persistConfiguration(postConfigChanged: true)
|
||||
}
|
||||
}
|
||||
|
||||
/// When enabled, the host app tries to return to the source app after a cold-start handoff.
|
||||
@Published public var flowSkipAppSwitch: Bool {
|
||||
didSet {
|
||||
@@ -401,6 +421,8 @@ public final class ProviderConfig: ObservableObject, @unchecked Sendable {
|
||||
polishIntensity = configuration.polishIntensity
|
||||
aiResponseLength = configuration.aiResponseLength
|
||||
llmThinkingEnabled = configuration.llmThinkingEnabled
|
||||
clipboardHistoryEnabled = configuration.clipboardHistoryEnabled
|
||||
clipboardCandidateBarEnabled = configuration.clipboardCandidateBarEnabled
|
||||
flowSkipAppSwitch = configuration.flowSkipAppSwitch
|
||||
flowInactivityDuration = configuration.flowInactivityDuration
|
||||
localASRCustomLanguageModelEnabled = configuration.localASRCustomLanguageModelEnabled
|
||||
@@ -431,6 +453,8 @@ public final class ProviderConfig: ObservableObject, @unchecked Sendable {
|
||||
aiResponseLength = .default
|
||||
localASRCustomLanguageModelEnabled = true
|
||||
llmThinkingEnabled = false
|
||||
clipboardHistoryEnabled = false
|
||||
clipboardCandidateBarEnabled = false
|
||||
hasAcknowledgedCloudSharing = false
|
||||
configuration.providerId = polishPreset.id
|
||||
configuration.baseURL = polishPreset.defaultBaseURL
|
||||
@@ -444,6 +468,8 @@ public final class ProviderConfig: ObservableObject, @unchecked Sendable {
|
||||
configuration.aiResponseLength = .default
|
||||
configuration.localASRCustomLanguageModelEnabled = true
|
||||
configuration.llmThinkingEnabled = false
|
||||
configuration.clipboardHistoryEnabled = false
|
||||
configuration.clipboardCandidateBarEnabled = false
|
||||
configuration.hasAcknowledgedCloudSharing = false
|
||||
isApplyingConfiguration = false
|
||||
persistConfiguration()
|
||||
@@ -495,6 +521,8 @@ public final class ProviderConfig: ObservableObject, @unchecked Sendable {
|
||||
polishIntensity = fresh.polishIntensity
|
||||
aiResponseLength = fresh.aiResponseLength
|
||||
llmThinkingEnabled = fresh.llmThinkingEnabled
|
||||
clipboardHistoryEnabled = fresh.clipboardHistoryEnabled
|
||||
clipboardCandidateBarEnabled = fresh.clipboardCandidateBarEnabled
|
||||
flowSkipAppSwitch = fresh.flowSkipAppSwitch
|
||||
flowInactivityDuration = fresh.flowInactivityDuration
|
||||
localASRCustomLanguageModelEnabled = fresh.localASRCustomLanguageModelEnabled
|
||||
|
||||
@@ -31,6 +31,8 @@ public struct SyncedAppSettingsV2: Codable, Equatable, Sendable {
|
||||
public var aiResponseLength: SyncedField<AIResponseLength>
|
||||
public var activePolishStyleId: SyncedField<String>
|
||||
public var llmThinkingEnabled: SyncedField<Bool>
|
||||
public var clipboardHistoryEnabled: SyncedField<Bool>
|
||||
public var clipboardCandidateBarEnabled: SyncedField<Bool>
|
||||
public var flowSkipAppSwitch: SyncedField<Bool>
|
||||
public var flowInactivityDuration: SyncedField<FlowInactivityDuration>
|
||||
|
||||
@@ -55,6 +57,8 @@ public struct SyncedAppSettingsV2: Codable, Equatable, Sendable {
|
||||
aiResponseLength: SyncedField<AIResponseLength>? = nil,
|
||||
activePolishStyleId: SyncedField<String>,
|
||||
llmThinkingEnabled: SyncedField<Bool>,
|
||||
clipboardHistoryEnabled: SyncedField<Bool>? = nil,
|
||||
clipboardCandidateBarEnabled: SyncedField<Bool>? = nil,
|
||||
flowSkipAppSwitch: SyncedField<Bool>,
|
||||
flowInactivityDuration: SyncedField<FlowInactivityDuration>
|
||||
) {
|
||||
@@ -86,6 +90,16 @@ public struct SyncedAppSettingsV2: Codable, Equatable, Sendable {
|
||||
)
|
||||
self.activePolishStyleId = activePolishStyleId
|
||||
self.llmThinkingEnabled = llmThinkingEnabled
|
||||
self.clipboardHistoryEnabled = clipboardHistoryEnabled ?? SyncedField(
|
||||
value: false,
|
||||
updatedAt: llmThinkingEnabled.updatedAt,
|
||||
deviceID: llmThinkingEnabled.deviceID
|
||||
)
|
||||
self.clipboardCandidateBarEnabled = clipboardCandidateBarEnabled ?? SyncedField(
|
||||
value: false,
|
||||
updatedAt: llmThinkingEnabled.updatedAt,
|
||||
deviceID: llmThinkingEnabled.deviceID
|
||||
)
|
||||
self.flowSkipAppSwitch = flowSkipAppSwitch
|
||||
self.flowInactivityDuration = flowInactivityDuration
|
||||
}
|
||||
@@ -111,6 +125,8 @@ public struct SyncedAppSettingsV2: Codable, Equatable, Sendable {
|
||||
case aiResponseLength
|
||||
case activePolishStyleId
|
||||
case llmThinkingEnabled
|
||||
case clipboardHistoryEnabled
|
||||
case clipboardCandidateBarEnabled
|
||||
case flowSkipAppSwitch
|
||||
case flowInactivityDuration
|
||||
}
|
||||
@@ -182,6 +198,22 @@ public struct SyncedAppSettingsV2: Codable, Equatable, Sendable {
|
||||
updatedAt: keyboardHapticIntensity.updatedAt,
|
||||
deviceID: keyboardHapticIntensity.deviceID
|
||||
)
|
||||
clipboardHistoryEnabled = try container.decodeIfPresent(
|
||||
SyncedField<Bool>.self,
|
||||
forKey: .clipboardHistoryEnabled
|
||||
) ?? SyncedField(
|
||||
value: false,
|
||||
updatedAt: keyboardHapticIntensity.updatedAt,
|
||||
deviceID: keyboardHapticIntensity.deviceID
|
||||
)
|
||||
clipboardCandidateBarEnabled = try container.decodeIfPresent(
|
||||
SyncedField<Bool>.self,
|
||||
forKey: .clipboardCandidateBarEnabled
|
||||
) ?? SyncedField(
|
||||
value: false,
|
||||
updatedAt: keyboardHapticIntensity.updatedAt,
|
||||
deviceID: keyboardHapticIntensity.deviceID
|
||||
)
|
||||
flowSkipAppSwitch = try container.decode(SyncedField<Bool>.self, forKey: .flowSkipAppSwitch)
|
||||
flowInactivityDuration = try container.decode(
|
||||
SyncedField<FlowInactivityDuration>.self,
|
||||
@@ -237,6 +269,8 @@ public struct SyncedAppSettingsV2: Codable, Equatable, Sendable {
|
||||
aiResponseLength.updatedAt,
|
||||
activePolishStyleId.updatedAt,
|
||||
llmThinkingEnabled.updatedAt,
|
||||
clipboardHistoryEnabled.updatedAt,
|
||||
clipboardCandidateBarEnabled.updatedAt,
|
||||
flowSkipAppSwitch.updatedAt,
|
||||
flowInactivityDuration.updatedAt,
|
||||
].max() ?? .distantPast
|
||||
@@ -277,6 +311,8 @@ public extension SyncedAppSettingsV2 {
|
||||
aiResponseLength: field(configuration.aiResponseLength),
|
||||
activePolishStyleId: field(configuration.activePolishStyleId),
|
||||
llmThinkingEnabled: field(configuration.llmThinkingEnabled),
|
||||
clipboardHistoryEnabled: field(configuration.clipboardHistoryEnabled),
|
||||
clipboardCandidateBarEnabled: field(configuration.clipboardCandidateBarEnabled),
|
||||
flowSkipAppSwitch: field(configuration.flowSkipAppSwitch),
|
||||
flowInactivityDuration: field(configuration.flowInactivityDuration)
|
||||
)
|
||||
@@ -309,6 +345,8 @@ public extension SyncedAppSettingsV2 {
|
||||
aiResponseLength: field(AIResponseLength.default),
|
||||
activePolishStyleId: field(PolishStylePackCatalog.defaultID),
|
||||
llmThinkingEnabled: field(false),
|
||||
clipboardHistoryEnabled: field(false),
|
||||
clipboardCandidateBarEnabled: field(false),
|
||||
flowSkipAppSwitch: field(legacy.flowSkipAppSwitch),
|
||||
flowInactivityDuration: field(legacy.flowInactivityDuration)
|
||||
)
|
||||
@@ -356,6 +394,14 @@ public extension SyncedAppSettingsV2 {
|
||||
remote: remote.activePolishStyleId
|
||||
),
|
||||
llmThinkingEnabled: .merge(local: local.llmThinkingEnabled, remote: remote.llmThinkingEnabled),
|
||||
clipboardHistoryEnabled: .merge(
|
||||
local: local.clipboardHistoryEnabled,
|
||||
remote: remote.clipboardHistoryEnabled
|
||||
),
|
||||
clipboardCandidateBarEnabled: .merge(
|
||||
local: local.clipboardCandidateBarEnabled,
|
||||
remote: remote.clipboardCandidateBarEnabled
|
||||
),
|
||||
flowSkipAppSwitch: .merge(local: local.flowSkipAppSwitch, remote: remote.flowSkipAppSwitch),
|
||||
flowInactivityDuration: .merge(
|
||||
local: local.flowInactivityDuration,
|
||||
@@ -384,6 +430,8 @@ public extension SyncedAppSettingsV2 {
|
||||
configuration.aiResponseLength = aiResponseLength.value
|
||||
configuration.activePolishStyleId = activePolishStyleId.value
|
||||
configuration.llmThinkingEnabled = llmThinkingEnabled.value
|
||||
configuration.clipboardHistoryEnabled = clipboardHistoryEnabled.value
|
||||
configuration.clipboardCandidateBarEnabled = clipboardCandidateBarEnabled.value
|
||||
configuration.flowSkipAppSwitch = flowSkipAppSwitch.value
|
||||
configuration.flowInactivityDuration = flowInactivityDuration.value
|
||||
}
|
||||
@@ -414,6 +462,8 @@ public extension SyncedAppSettingsV2 {
|
||||
patch(©.aiResponseLength, value: configuration.aiResponseLength)
|
||||
patch(©.activePolishStyleId, value: configuration.activePolishStyleId)
|
||||
patch(©.llmThinkingEnabled, value: configuration.llmThinkingEnabled)
|
||||
patch(©.clipboardHistoryEnabled, value: configuration.clipboardHistoryEnabled)
|
||||
patch(©.clipboardCandidateBarEnabled, value: configuration.clipboardCandidateBarEnabled)
|
||||
patch(©.flowSkipAppSwitch, value: configuration.flowSkipAppSwitch)
|
||||
patch(©.flowInactivityDuration, value: configuration.flowInactivityDuration)
|
||||
return copy
|
||||
@@ -447,6 +497,8 @@ public extension SyncedAppSettingsV2 {
|
||||
touch(©.aiResponseLength, value: configuration.aiResponseLength)
|
||||
touch(©.activePolishStyleId, value: configuration.activePolishStyleId)
|
||||
touch(©.llmThinkingEnabled, value: configuration.llmThinkingEnabled)
|
||||
touch(©.clipboardHistoryEnabled, value: configuration.clipboardHistoryEnabled)
|
||||
touch(©.clipboardCandidateBarEnabled, value: configuration.clipboardCandidateBarEnabled)
|
||||
touch(©.flowSkipAppSwitch, value: configuration.flowSkipAppSwitch)
|
||||
touch(©.flowInactivityDuration, value: configuration.flowInactivityDuration)
|
||||
return copy
|
||||
|
||||
Reference in New Issue
Block a user