refactor: centralize main session key normalization in apps
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
- Doctor: run legacy state migrations in non-interactive mode without prompts.
|
- Doctor: run legacy state migrations in non-interactive mode without prompts.
|
||||||
- Cron: parse Telegram topic targets for isolated delivery. (#478) — thanks @nachoiacovino
|
- Cron: parse Telegram topic targets for isolated delivery. (#478) — thanks @nachoiacovino
|
||||||
- Cron: enqueue main-session system events under the resolved main session key. (#510)
|
- Cron: enqueue main-session system events under the resolved main session key. (#510)
|
||||||
|
- Mobile: centralize main session key normalization for iOS/Android runtime helpers. — thanks @steipete
|
||||||
- Outbound: default Telegram account selection for config-only tokens; remove heartbeat-specific accountId handling. (follow-up #516) — thanks @YuriNachos
|
- Outbound: default Telegram account selection for config-only tokens; remove heartbeat-specific accountId handling. (follow-up #516) — thanks @YuriNachos
|
||||||
- Cron: allow Telegram delivery targets with topic/thread IDs (e.g. `-100…:topic:123`). (#474) — thanks @mitschabaude-bot
|
- Cron: allow Telegram delivery targets with topic/thread IDs (e.g. `-100…:topic:123`). (#474) — thanks @mitschabaude-bot
|
||||||
- Heartbeat: resolve Telegram account IDs from config-only tokens; cron tool accepts canonical `jobId` and legacy `id` for job actions. (#516) — thanks @YuriNachos
|
- Heartbeat: resolve Telegram account IDs from config-only tokens; cron tool accepts canonical `jobId` and legacy `id` for job actions. (#516) — thanks @YuriNachos
|
||||||
|
|||||||
@@ -700,8 +700,8 @@ class NodeRuntime(context: Context) {
|
|||||||
val ui = config?.get("ui").asObjectOrNull()
|
val ui = config?.get("ui").asObjectOrNull()
|
||||||
val raw = ui?.get("seamColor").asStringOrNull()?.trim()
|
val raw = ui?.get("seamColor").asStringOrNull()?.trim()
|
||||||
val sessionCfg = config?.get("session").asObjectOrNull()
|
val sessionCfg = config?.get("session").asObjectOrNull()
|
||||||
val rawMainKey = sessionCfg?.get("mainKey").asStringOrNull()?.trim()
|
val mainKey = normalizeMainKey(sessionCfg?.get("mainKey").asStringOrNull())
|
||||||
_mainSessionKey.value = rawMainKey?.takeIf { it.isNotEmpty() } ?: "main"
|
_mainSessionKey.value = mainKey
|
||||||
|
|
||||||
val parsed = parseHexColorArgb(raw)
|
val parsed = parseHexColorArgb(raw)
|
||||||
_seamColorArgb.value = parsed ?: DEFAULT_SEAM_COLOR_ARGB
|
_seamColorArgb.value = parsed ?: DEFAULT_SEAM_COLOR_ARGB
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.clawdbot.android
|
||||||
|
|
||||||
|
internal fun normalizeMainKey(raw: String?): String {
|
||||||
|
val trimmed = raw?.trim()
|
||||||
|
return if (!trimmed.isNullOrEmpty()) trimmed else "main"
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ import android.speech.tts.UtteranceProgressListener
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.clawdbot.android.bridge.BridgeSession
|
import com.clawdbot.android.bridge.BridgeSession
|
||||||
|
import com.clawdbot.android.normalizeMainKey
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
@@ -814,7 +815,7 @@ class TalkModeManager(
|
|||||||
val config = root?.get("config").asObjectOrNull()
|
val config = root?.get("config").asObjectOrNull()
|
||||||
val talk = config?.get("talk").asObjectOrNull()
|
val talk = config?.get("talk").asObjectOrNull()
|
||||||
val sessionCfg = config?.get("session").asObjectOrNull()
|
val sessionCfg = config?.get("session").asObjectOrNull()
|
||||||
val mainKey = sessionCfg?.get("mainKey").asStringOrNull()?.trim()?.takeIf { it.isNotEmpty() } ?: "main"
|
val mainKey = normalizeMainKey(sessionCfg?.get("mainKey").asStringOrNull())
|
||||||
val voice = talk?.get("voiceId")?.asStringOrNull()?.trim()?.takeIf { it.isNotEmpty() }
|
val voice = talk?.get("voiceId")?.asStringOrNull()?.trim()?.takeIf { it.isNotEmpty() }
|
||||||
val aliases =
|
val aliases =
|
||||||
talk?.get("voiceAliases").asObjectOrNull()?.entries?.mapNotNull { (key, value) ->
|
talk?.get("voiceAliases").asObjectOrNull()?.entries?.mapNotNull { (key, value) ->
|
||||||
|
|||||||
@@ -330,8 +330,7 @@ final class NodeAppModel {
|
|||||||
let ui = config["ui"] as? [String: Any]
|
let ui = config["ui"] as? [String: Any]
|
||||||
let raw = (ui?["seamColor"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
let raw = (ui?["seamColor"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||||
let session = config["session"] as? [String: Any]
|
let session = config["session"] as? [String: Any]
|
||||||
let rawMainKey = (session?["mainKey"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
let mainKey = SessionKey.normalizeMainKey(session?["mainKey"] as? String)
|
||||||
let mainKey = rawMainKey.isEmpty ? "main" : rawMainKey
|
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
self.seamColorHex = raw.isEmpty ? nil : raw
|
self.seamColorHex = raw.isEmpty ? nil : raw
|
||||||
self.mainSessionKey = mainKey
|
self.mainSessionKey = mainKey
|
||||||
|
|||||||
8
apps/ios/Sources/SessionKey.swift
Normal file
8
apps/ios/Sources/SessionKey.swift
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum SessionKey {
|
||||||
|
static func normalizeMainKey(_ raw: String?) -> String {
|
||||||
|
let trimmed = (raw ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
return trimmed.isEmpty ? "main" : trimmed
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -651,8 +651,7 @@ final class TalkModeManager: NSObject {
|
|||||||
guard let config = json["config"] as? [String: Any] else { return }
|
guard let config = json["config"] as? [String: Any] else { return }
|
||||||
let talk = config["talk"] as? [String: Any]
|
let talk = config["talk"] as? [String: Any]
|
||||||
let session = config["session"] as? [String: Any]
|
let session = config["session"] as? [String: Any]
|
||||||
let rawMainKey = (session?["mainKey"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
self.mainSessionKey = SessionKey.normalizeMainKey(session?["mainKey"] as? String)
|
||||||
self.mainSessionKey = rawMainKey.isEmpty ? "main" : rawMainKey
|
|
||||||
self.defaultVoiceId = (talk?["voiceId"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
self.defaultVoiceId = (talk?["voiceId"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
if let aliases = talk?["voiceAliases"] as? [String: Any] {
|
if let aliases = talk?["voiceAliases"] as? [String: Any] {
|
||||||
var resolved: [String: String] = [:]
|
var resolved: [String: String] = [:]
|
||||||
|
|||||||
Reference in New Issue
Block a user