知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
refactor(android): keep record fields this version doesn't know, like the Mac's voiceprint matches
wquguru28d0baa2ffa8
diff --git a/android/cli/src/main/kotlin/cicada/cli/Tests.kt b/android/cli/src/main/kotlin/cicada/cli/Tests.ktindex 8290ae6..eba2156 100644--- a/android/cli/src/main/kotlin/cicada/cli/Tests.kt+++ b/android/cli/src/main/kotlin/cicada/cli/Tests.kt@@ -25,6 +25,7 @@ object Tests {"todoOwnersShowInTheUiLanguage" to ::todoOwnersShowInTheUiLanguage,"readsAMacRecordAndWritesItBackByteForByte" to ::readsAMacRecord,"keepsTheMacsImportAndRoomFields" to ::keepsTheMacsImportAndRoomFields,+ "keepsFieldsItDoesNotKnow" to ::keepsFieldsItDoesNotKnow,"jsonEdgeCases" to ::jsonEdgeCases,"findsTheNewestAndroidRelease" to ::findsTheNewestAndroidRelease,"updateCheckIsSilentAndDue" to ::updateCheckIsSilentAndDue,@@ -213,6 +214,17 @@ object Tests {equal("周会", SessionStore.displayTitle(untitled), "an imported file is known by its name until the notes name it")}+ /// The Mac's voiceprint library (1.10) adds voiceProfiles / voiceSuggestions; Android has no+ /// such library but must not drop them when it saves the record again.+ fun keepsFieldsItDoesNotKnow() {+ val ref = "{\n \"1\" : {\n \"id\" : \"6F9619FF-8B86-D011-B42D-00C04FC964FF\",\n \"name\" : \"Emma\",\n \"similarity\" : 0.75\n }\n }"+ // Sorted keys: both come after voiceNames, the last key of MAC.+ val mac = MAC.removeSuffix("\n}") + ",\n \"voiceProfiles\" : $ref,\n \"voiceSuggestions\" : $ref\n}"+ check(mac.contains("\"voiceProfiles\"") && mac.contains("\"voiceSuggestions\""), "test record has the fields")+ val s = Session.read(mac)!!+ equal(mac, Json.write(s.toJson()), "written back byte for byte")+ }+fun renamesLikeTheMac() {val store = SessionStore(loadNow = false)val s = store.begin(Instant.parse("2026-03-01T01:00:00Z"))diff --git a/android/core/src/main/kotlin/cicada/Models.kt b/android/core/src/main/kotlin/cicada/Models.ktindex 7ce7908..df06e46 100644--- a/android/core/src/main/kotlin/cicada/Models.kt+++ b/android/core/src/main/kotlin/cicada/Models.kt@@ -81,10 +81,13 @@ class Session(var importing: Boolean? = null,/// Heard through the microphone in the room (会议室) for some or all of it.var room: Boolean? = null,+ /// Keys this version doesn't know (the Mac's voiceProfiles / voiceSuggestions, newer+ /// fields), written back untouched so saving here never drops another platform's data.+ var extra: Map<String, Any?> = emptyMap(),) {val durationSeconds: Double get() = ((endedAt ?: Instant.now()).toEpochMilli() - startedAt.toEpochMilli()) / 1000.0- fun toJson(): Map<String, Any?> = mapOf(+ fun toJson(): Map<String, Any?> = extra + mapOf("id" to id, "title" to title, "startedAt" to Iso8601.write(startedAt), "endedAt" to endedAt?.let(Iso8601::write),"lines" to lines.map { it.toJson() }, "hasAudio" to hasAudio, "notes" to notes?.toJson(), "renamed" to renamed,"voiceNames" to voiceNames, "voiceGuesses" to voiceGuesses?.mapValues { it.value.toJson() },@@ -102,8 +105,12 @@ class Session(voiceGuesses = o["voiceGuesses"].obj()?.mapValues { VoiceGuess.from(it.value.obj() ?: emptyMap()) },sourceFile = o["sourceFile"].str(), sourcePath = o["sourcePath"].str(),importing = o["importing"].bool(), room = o["room"].bool(),+ extra = o.filterKeys { it !in KEYS },)+ private val KEYS = setOf("id", "title", "startedAt", "endedAt", "lines", "hasAudio", "notes", "renamed",+ "voiceNames", "voiceGuesses", "sourceFile", "sourcePath", "importing", "room")+fun read(text: String): Session? = Json.parseObject(text)?.let(::from)}}