Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions TablePro/Core/Storage/ConnectionStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ private struct StoredConnection: Codable {
// AI policy
let aiPolicy: String?

// AI rules text included in the system prompt for this connection
let aiRules: String?

// AI tools whitelisted for this connection
let aiAlwaysAllowedTools: [String]?

Expand Down Expand Up @@ -527,6 +530,7 @@ private struct StoredConnection: Codable {

// AI policy
self.aiPolicy = connection.aiPolicy?.rawValue
self.aiRules = connection.aiRules
self.aiAlwaysAllowedTools = connection.aiAlwaysAllowedTools.isEmpty
? nil
: Array(connection.aiAlwaysAllowedTools).sorted()
Expand Down Expand Up @@ -574,6 +578,7 @@ private struct StoredConnection: Codable {
case safeModeLevel
case isReadOnly // Legacy key for migration reading only
case aiPolicy
case aiRules
case aiAlwaysAllowedTools
case mongoAuthSource, mongoReadPreference, mongoWriteConcern, redisDatabase
case mssqlSchema, oracleServiceName, startupCommands, sortOrder
Expand Down Expand Up @@ -613,6 +618,7 @@ private struct StoredConnection: Codable {
try container.encodeIfPresent(sshProfileId, forKey: .sshProfileId)
try container.encode(safeModeLevel, forKey: .safeModeLevel)
try container.encodeIfPresent(aiPolicy, forKey: .aiPolicy)
try container.encodeIfPresent(aiRules, forKey: .aiRules)
try container.encodeIfPresent(aiAlwaysAllowedTools, forKey: .aiAlwaysAllowedTools)
try container.encodeIfPresent(redisDatabase, forKey: .redisDatabase)
try container.encodeIfPresent(startupCommands, forKey: .startupCommands)
Expand Down Expand Up @@ -674,6 +680,7 @@ private struct StoredConnection: Codable {
safeModeLevel = wasReadOnly ? SafeModeLevel.readOnly.rawValue : SafeModeLevel.silent.rawValue
}
aiPolicy = try container.decodeIfPresent(String.self, forKey: .aiPolicy)
aiRules = try container.decodeIfPresent(String.self, forKey: .aiRules)
aiAlwaysAllowedTools = try container.decodeIfPresent([String].self, forKey: .aiAlwaysAllowedTools)
mongoAuthSource = try container.decodeIfPresent(String.self, forKey: .mongoAuthSource)
mongoReadPreference = try container.decodeIfPresent(String.self, forKey: .mongoReadPreference)
Expand Down Expand Up @@ -768,6 +775,7 @@ private struct StoredConnection: Codable {
sshTunnelMode: resolvedTunnelMode,
safeModeLevel: SafeModeLevel(rawValue: safeModeLevel) ?? .silent,
aiPolicy: parsedAIPolicy,
aiRules: aiRules,
aiAlwaysAllowedTools: Set(aiAlwaysAllowedTools ?? []),
redisDatabase: redisDatabase,
startupCommands: startupCommands,
Expand Down
5 changes: 5 additions & 0 deletions TablePro/Core/Sync/SyncRecordMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ struct SyncRecordMapper {
if let aiPolicy = connection.aiPolicy {
record["aiPolicy"] = aiPolicy.rawValue as CKRecordValue
}
if let aiRules = connection.aiRules, !aiRules.isEmpty {
record["aiRules"] = aiRules as CKRecordValue
}
if !connection.aiAlwaysAllowedTools.isEmpty {
let sorted = Array(connection.aiAlwaysAllowedTools).sorted()
record["aiAlwaysAllowedTools"] = sorted as CKRecordValue
Expand Down Expand Up @@ -135,6 +138,7 @@ struct SyncRecordMapper {
let tagId = (record["tagId"] as? String).flatMap { UUID(uuidString: $0) }
let groupId = (record["groupId"] as? String).flatMap { UUID(uuidString: $0) }
let aiPolicyRaw = record["aiPolicy"] as? String
let aiRulesRaw = record["aiRules"] as? String
let aiAlwaysAllowedToolsArray = record["aiAlwaysAllowedTools"] as? [String] ?? []
let redisDatabase = (record["redisDatabase"] as? Int64).map { Int($0) }
let startupCommands = record["startupCommands"] as? String
Expand Down Expand Up @@ -175,6 +179,7 @@ struct SyncRecordMapper {
sshProfileId: sshProfileId,
safeModeLevel: SafeModeLevel(rawValue: safeModeLevelRaw) ?? .silent,
aiPolicy: aiPolicyRaw.flatMap { AIConnectionPolicy(rawValue: $0) },
aiRules: aiRulesRaw,
aiAlwaysAllowedTools: Set(aiAlwaysAllowedToolsArray),
redisDatabase: redisDatabase,
startupCommands: startupCommands,
Expand Down
Loading