Skip to content

Commit c89aa32

Browse files
authored
chore: delete dead code and the unread managed policy keys (#3378)
Signed-off-by: Dat Ngo Quoc <datlechin@gmail.com>
1 parent f637eb9 commit c89aa32

11 files changed

Lines changed: 93 additions & 713 deletions

‎TablePro/Core/AI/OllamaDetector.swift‎

Lines changed: 0 additions & 73 deletions
This file was deleted.

‎TablePro/Core/Diagnostics/TableLoadHistoryStore.swift‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ internal actor TableLoadHistoryStore: TableLoadSummarySink {
7575
pruneIfNeeded()
7676
}
7777

78-
internal func records() -> [TableLoadPerformanceRecord] {
79-
loadIfNeeded()
80-
return Self.decodeRecords(in: Self.readFile(at: fileURL)).map(\.record)
81-
}
82-
83-
/// Byte-for-byte stable for the same input, so an external report can diff two exports.
84-
internal func exportJSON() -> Data {
85-
(try? Self.makeEncoder(prettyPrinted: true).encode(records())) ?? Data()
86-
}
87-
8878
/// The first touch in a process reconciles the file against the retention rules, so a history
8979
/// left behind by a build that quit before pruning cannot grow past its caps.
9080
private func loadIfNeeded() {
@@ -197,7 +187,7 @@ internal actor TableLoadHistoryStore: TableLoadSummarySink {
197187
}
198188

199189
private static func encode(_ record: TableLoadPerformanceRecord) -> Data? {
200-
guard var data = try? makeEncoder(prettyPrinted: false).encode(record) else {
190+
guard var data = try? makeEncoder().encode(record) else {
201191
logger.error("Table load history record could not be encoded")
202192
return nil
203193
}
@@ -214,11 +204,9 @@ internal actor TableLoadHistoryStore: TableLoadSummarySink {
214204
}
215205
}
216206

217-
internal static func makeEncoder(prettyPrinted: Bool) -> JSONEncoder {
207+
internal static func makeEncoder() -> JSONEncoder {
218208
let encoder = JSONEncoder()
219-
encoder.outputFormatting = prettyPrinted
220-
? [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes]
221-
: [.sortedKeys, .withoutEscapingSlashes]
209+
encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
222210
encoder.dateEncodingStrategy = .custom { date, encoder in
223211
var container = encoder.singleValueContainer()
224212
try container.encode(timestamps.format(date))

‎TablePro/Core/MCP/Transport/MCPStdioMessageTransport.swift‎

Lines changed: 0 additions & 140 deletions
This file was deleted.

‎TablePro/Core/Services/Policy/ManagedPolicy.swift‎

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,22 @@ internal enum ManagedPolicy: String, CaseIterable, Sendable {
1717
/// raised to this; a stronger choice is left alone, so the policy is a floor and never a ceiling.
1818
case minimumSafeModeLevel = "com.TablePro.policy.minimumSafeModeLevel"
1919

20-
/// Stops the MCP server from listening, so an AI client cannot reach the databases at all.
21-
case mcpServerDisabled = "com.TablePro.policy.mcpServerDisabled"
22-
23-
/// Stops the in-app AI assistant, including inline suggestions.
24-
case aiAssistantDisabled = "com.TablePro.policy.aiAssistantDisabled"
25-
26-
/// Stops plugins being installed, from the registry or from a file.
27-
case pluginInstallDisabled = "com.TablePro.policy.pluginInstallDisabled"
28-
2920
internal var key: String { rawValue }
3021
}
3122

3223
internal protocol ManagedPolicyReading: Sendable {
33-
/// True when a configuration profile supplies this key, so the UI for it must be disabled.
34-
func isManaged(_ policy: ManagedPolicy) -> Bool
35-
func bool(_ policy: ManagedPolicy) -> Bool
3624
func string(_ policy: ManagedPolicy) -> String?
3725
}
3826

39-
/// Reads policy out of the standard preferences chain.
40-
///
41-
/// macOS already merges a configuration profile's values into `UserDefaults` at the highest
42-
/// priority, so reading a managed key needs no special path: the forced value simply wins. The one
43-
/// thing the normal API cannot tell you is *whether* a key was forced, which is what
44-
/// `CFPreferencesAppValueIsForced` is for. Its own header says callers "should use this function to
45-
/// determine whether or not to disable UI elements corresponding to those preference keys".
27+
/// Reads policy out of the standard preferences chain. macOS merges a configuration profile's
28+
/// values into `UserDefaults` at the highest priority, so the forced value simply wins.
4629
internal struct ManagedPolicyReader: ManagedPolicyReading, @unchecked Sendable {
4730
internal static let shared = ManagedPolicyReader()
4831

4932
private let defaults: UserDefaults
50-
private let applicationID: String
5133

52-
internal init(defaults: UserDefaults = .standard, applicationID: String = Bundle.main.bundleIdentifier ?? "") {
34+
internal init(defaults: UserDefaults = .standard) {
5335
self.defaults = defaults
54-
self.applicationID = applicationID
55-
}
56-
57-
internal func isManaged(_ policy: ManagedPolicy) -> Bool {
58-
guard !applicationID.isEmpty else { return false }
59-
return CFPreferencesAppValueIsForced(policy.key as CFString, applicationID as CFString)
60-
}
61-
62-
internal func bool(_ policy: ManagedPolicy) -> Bool {
63-
defaults.bool(forKey: policy.key)
6436
}
6537

6638
internal func string(_ policy: ManagedPolicy) -> String? {

0 commit comments

Comments
 (0)