Report unsupported incoming whisper shortcuts when loading profiles

This commit is contained in:
omar committed 2026-11-27 17:02:57 +03:00
1 parent 149bad248e
commit a8fc57c2e1
5 files changed
+52 -9

No files matched your search

+2
View File
@@ -2,6 +2,8 @@
## Unreleased ## Unreleased
- Shortcut profile diagnostics now distinguish unsupported Block Incoming Whispers bindings from other invalid entries. Other valid bindings remain usable.
- Whisper history and notifications use the sender captured at receipt. A guest who later receives the same client number cannot inherit the original guest's reply action. - Whisper history and notifications use the sender captured at receipt. A guest who later receives the same client number cannot inherit the original guest's reply action.
- Reply Whisper addresses only the connection that sent the whisper, even when a second client is connected with the same UID. Saved whisper lists keep their existing multi-client behavior. - Reply Whisper addresses only the connection that sent the whisper, even when a second client is connected with the same UID. Saved whisper lists keep their existing multi-client behavior.
+2
View File
@@ -2,6 +2,8 @@
## Current Windows account-free checkpoint (2026-11-26) ## Current Windows account-free checkpoint (2026-11-26)
**Block Incoming Whispers shortcut (excluded):** The reference declares ActivateBlock, DeactivateBlock and ToggleBlock without a demonstrated dispatcher. Importing those modes in a disposable version 2 shortcut profile produced an explicit diagnostic, no local down/up action, and no global registration candidates; the profile bytes and a working Reply Whisper chord were preserved. The supported receive-mode selector is separate. No OS global shortcut was registered.
**Whisper sender identity on Windows:** The native client records the UID and nickname captured by the receiving core. A later roster cannot turn an unknown sender or a recycled client number into a reply target. On private beta14, two diagnostic cores matched the receipt to the sender roster under Allow All, observed neither playback nor a receipt under Deny All, then received an identified whisper after re-enabling. The connected Slint receive selector persisted Deny All across profile reopen. Three core and four native regression checks passed separately. A physical Reply shortcut and live recipient-number reassignment were not exercised. **Whisper sender identity on Windows:** The native client records the UID and nickname captured by the receiving core. A later roster cannot turn an unknown sender or a recycled client number into a reply target. On private beta14, two diagnostic cores matched the receipt to the sender roster under Allow All, observed neither playback nor a receipt under Deny All, then received an identified whisper after re-enabling. The connected Slint receive selector persisted Deny All across profile reopen. Three core and four native regression checks passed separately. A physical Reply shortcut and live recipient-number reassignment were not exercised.
**Channel commander on Windows:** Slint rendering tests verified the compact lamp versus separate icon, the detailed-tree icon, and preference persistence in English/dark and Russian/light fixtures. On private beta14 the other guest's menu had no commander action. The server refused the self change with PermissionsClientInsufficient; both flags remained off and the old confirmation could not affect the replacement identity. Four native checks and two core checks passed. A successful authorized commander change on beta14 remains unverified. **Channel commander on Windows:** Slint rendering tests verified the compact lamp versus separate icon, the detailed-tree icon, and preference persistence in English/dark and Russian/light fixtures. On private beta14 the other guest's menu had no commander action. The server refused the self change with PermissionsClientInsufficient; both flags remained off and the old confirmation could not affect the replacement identity. Four native checks and two core checks passed. A successful authorized commander change on beta14 remains unverified.
+2
View File
@@ -4,6 +4,8 @@
## Возврат к разработке на ПК, 2026-11-26 ## Возврат к разработке на ПК, 2026-11-26
Windows, база `149bad2`: закрыт `feature:whisper.block_hotkey` как проверенное исключение. Три режима блокировки из TS6 не регистрируются и не обрабатывают нажатие; действительная привязка ответа и исходные байты профиля v2 сохранены. Причина отражена в диагностике. Прошли три теста загрузки профилей и диспетчеризации, без глобальной регистрации в Windows.
Windows, база `9c0ddd4`: обработчик «Ответить на шёпот» передаёт ядру номер и UID именно того подключения, которое прислало шёпот. Два теста прошли: при двух подключениях с одним UID выбран только отправитель; при смене владельца номера до отправки ядро вернуло `no_targets`. Отказ и событие приёма сохранили ожидаемые уведомления. Проверка использовала тестовый список участников, без системной клавиши и сети. Windows, база `9c0ddd4`: обработчик «Ответить на шёпот» передаёт ядру номер и UID именно того подключения, которое прислало шёпот. Два теста прошли: при двух подключениях с одним UID выбран только отправитель; при смене владельца номера до отправки ядро вернуло `no_targets`. Отказ и событие приёма сохранили ожидаемые уведомления. Проверка использовала тестовый список участников, без системной клавиши и сети.
Публикация: повторный push обновил `origin/feature/desktop-parity` с `b685597` до `20240c1`, включая исправления статуса командира и истории шёпота. Отказ аутентификации ниже относится к первой попытке. Публикация: повторный push обновил `origin/feature/desktop-parity` с `b685597` до `20240c1`, включая исправления статуса командира и истории шёпота. Отказ аутентификации ниже относится к первой попытке.
+19 -9
View File
@@ -59,18 +59,24 @@ pub struct Profile {pub id:String,pub name:String,pub bindings:Vec<Binding>}
pub struct KeybindState {pub require_exact_match:bool,pub active_profile:Option<String>,pub profiles:Vec<Profile>} pub struct KeybindState {pub require_exact_match:bool,pub active_profile:Option<String>,pub profiles:Vec<Profile>}
pub struct KeybindStore {file:PathBuf,state:KeybindState,pub read_only:bool,pub diagnostic:Option<String>,pub dropped_on_load:usize,pub migrated_from:Option<PathBuf>} pub struct KeybindStore {file:PathBuf,state:KeybindState,pub read_only:bool,pub diagnostic:Option<String>,pub dropped_on_load:usize,pub migrated_from:Option<PathBuf>}
fn profile_name(name:&str)->Result<String> {let name=name.trim();if !text(name,1,64){return Err(bad("profile name: 1-64 characters"))}Ok(name.into())} fn profile_name(name:&str)->Result<String> {let name=name.trim();if !text(name,1,64){return Err(bad("profile name: 1-64 characters"))}Ok(name.into())}
fn load_profile(raw:&serde_json::Value)->Result<(Profile,usize)> { #[derive(Default)]
struct IgnoredBindings { count: usize, whisper_block: bool }
fn load_profile(raw:&serde_json::Value, ignored:&mut IgnoredBindings)->Result<Profile> {
let obj=raw.as_object().ok_or_else(||bad("profile: expected object"))?; let obj=raw.as_object().ok_or_else(||bad("profile: expected object"))?;
if obj.keys().any(|k|!matches!(k.as_str(),"id"|"name"|"bindings")){return Err(bad("profile: unknown field"))} if obj.keys().any(|k|!matches!(k.as_str(),"id"|"name"|"bindings")){return Err(bad("profile: unknown field"))}
let id=normalize_id(obj.get("id").map_or(Ok(""),|v|v.as_str().ok_or_else(||bad("invalid profile id")))?,true)?; let id=normalize_id(obj.get("id").map_or(Ok(""),|v|v.as_str().ok_or_else(||bad("invalid profile id")))?,true)?;
let name=profile_name(raw["name"].as_str().ok_or_else(||bad("invalid profile name"))?)?; let name=profile_name(raw["name"].as_str().ok_or_else(||bad("invalid profile name"))?)?;
let mut bindings=Vec::new();let mut dropped=0; let mut bindings=Vec::new();
if let Some(values)=raw["bindings"].as_array(){for value in values.iter().take(MAX_BINDINGS){ if let Some(values)=raw["bindings"].as_array(){for value in values.iter().take(MAX_BINDINGS){
match serde_json::from_value::<Binding>(value.clone()).map_err(ServiceError::from).and_then(Binding::normalize){ match serde_json::from_value::<Binding>(value.clone()).map_err(ServiceError::from).and_then(Binding::normalize){
Ok(b) if !bindings.iter().any(|p:&Binding|p.id==b.id)=>bindings.push(b),Ok(_)=>{},Err(_)=>dropped+=1, Ok(b) if !bindings.iter().any(|p:&Binding|p.id==b.id)=>bindings.push(b),Ok(_)=>{},Err(_)=>{
ignored.count+=1;
ignored.whisper_block |= matches!(value["action"].as_str(),Some("ActivateBlock"|"DeactivateBlock"|"ToggleBlock"));
},
} }
}} }}
Ok((Profile {id,name,bindings},dropped)) Ok(Profile {id,name,bindings})
} }
impl KeybindStore { impl KeybindStore {
pub fn open(root:&Path,default_profile_name:&str)->Result<Self> { pub fn open(root:&Path,default_profile_name:&str)->Result<Self> {
@@ -79,9 +85,10 @@ impl KeybindStore {
let raw:serde_json::Value=match serde_json::from_slice(&bytes){Ok(v)=>v,Err(_)=>{s.diagnostic=Some("invalid keybinds.json; source retained until explicit save".into());return Ok(s)}}; let raw:serde_json::Value=match serde_json::from_slice(&bytes){Ok(v)=>v,Err(_)=>{s.diagnostic=Some("invalid keybinds.json; source retained until explicit save".into());return Ok(s)}};
let version=match raw["version"].as_u64(){Some(n) if n>=1=>n,_=>{s.diagnostic=Some("invalid keybind version; source retained".into());return Ok(s)}}; let version=match raw["version"].as_u64(){Some(n) if n>=1=>n,_=>{s.diagnostic=Some("invalid keybind version; source retained".into());return Ok(s)}};
if version>2{s.read_only=true;s.diagnostic=Some("newer keybinds.json".into());return Ok(s)} if version>2{s.read_only=true;s.diagnostic=Some("newer keybinds.json".into());return Ok(s)}
let mut ignored=IgnoredBindings::default();
if version==1 { if version==1 {
let (profile,dropped)=load_profile(&serde_json::json!({"id":"","name":default_profile_name,"bindings":raw["bindings"]}))?; let profile=load_profile(&serde_json::json!({"id":"","name":default_profile_name,"bindings":raw["bindings"]}),&mut ignored)?;
s.dropped_on_load=dropped;s.state.require_exact_match=true; s.state.require_exact_match=true;
if !profile.bindings.is_empty(){s.state.active_profile=Some(profile.id.clone());s.state.profiles.push(profile);} if !profile.bindings.is_empty(){s.state.active_profile=Some(profile.id.clone());s.state.profiles.push(profile);}
// A unique backup preserves the exact v1 bytes, never an already-normalized rendition. // A unique backup preserves the exact v1 bytes, never an already-normalized rendition.
let stamp=std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_err(|_|bad("system clock before epoch"))?.as_millis(); let stamp=std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_err(|_|bad("system clock before epoch"))?.as_millis();
@@ -93,14 +100,17 @@ impl KeybindStore {
f.write_all(&bytes)?;f.sync_all()?; f.write_all(&bytes)?;f.sync_all()?;
s.persist(s.state.clone())?;s.migrated_from=Some(backup); s.persist(s.state.clone())?;s.migrated_from=Some(backup);
} else { } else {
if let Some(profiles)=raw["profiles"].as_array(){for value in profiles.iter().take(MAX_PROFILES){match load_profile(value){ if let Some(profiles)=raw["profiles"].as_array(){for value in profiles.iter().take(MAX_PROFILES){match load_profile(value,&mut ignored){
Ok((p,n))=>{s.dropped_on_load+=n;if !s.state.profiles.iter().any(|x|x.id==p.id){s.state.profiles.push(p);}},Err(_)=>s.dropped_on_load+=1, Ok(p)=>{if !s.state.profiles.iter().any(|x|x.id==p.id){s.state.profiles.push(p);}},Err(_)=>ignored.count+=1,
}}} }}}
s.state.require_exact_match=raw["requireExactMatch"]==true; s.state.require_exact_match=raw["requireExactMatch"]==true;
let active=raw["activeProfile"].as_str().map(str::to_ascii_lowercase); let active=raw["activeProfile"].as_str().map(str::to_ascii_lowercase);
s.state.active_profile=s.state.profiles.iter().find(|p|Some(&p.id)==active.as_ref()).or_else(||s.state.profiles.first()).map(|p|p.id.clone()); s.state.active_profile=s.state.profiles.iter().find(|p|Some(&p.id)==active.as_ref()).or_else(||s.state.profiles.first()).map(|p|p.id.clone());
} }
if s.dropped_on_load>0{s.diagnostic=Some("invalid keybindings ignored; source/backup retained".into());} s.dropped_on_load=ignored.count;
if ignored.count>0 { s.diagnostic=Some(if ignored.whisper_block {
"Invalid keybindings ignored, including unsupported Block Incoming Whispers shortcuts. The source or backup was retained."
} else { "invalid keybindings ignored; source/backup retained" }.into()); }
Ok(s) Ok(s)
} }
pub fn get(&self)->&KeybindState {&self.state} pub fn get(&self)->&KeybindState {&self.state}
+27
View File
@@ -75,6 +75,33 @@ fn expansion_reserves_exact_chords_and_respects_limit(){
let bs:Vec<_>=(1..=64).map(|n|binding(Action::PushToTalk,&format!("F{n}"))).collect();let regs=expand_registrations(&bs,false);assert_eq!(regs.bindings.len(),64);assert!(regs.variants_wanted>0); let bs:Vec<_>=(1..=64).map(|n|binding(Action::PushToTalk,&format!("F{n}"))).collect();let regs=expand_registrations(&bs,false);assert_eq!(regs.bindings.len(),64);assert!(regs.variants_wanted>0);
} }
#[test] #[test]
fn imported_whisper_block_modes_never_dispatch_or_replace_a_valid_shortcut() {
let dir=Temp::new();
let profile=uuid::Uuid::new_v4().to_string();
let reply=binding(Action::ReplyWhisper,"F8");
let mut rows=vec![serde_json::to_value(&reply).unwrap()];
let modes=[("ActivateBlock","F9"),("DeactivateBlock","F10"),("ToggleBlock","F11")];
for (action,code) in modes {
rows.push(serde_json::json!({"id":uuid::Uuid::new_v4().to_string(),"code":code,"action":action,"global":true}));
}
let bytes=serde_json::to_vec(&serde_json::json!({"version":2,"activeProfile":profile,"profiles":[{"id":profile,"name":"Whisper","bindings":rows}]})).unwrap();
let file=dir.0.join("keybinds.json");
fs::write(&file,&bytes).unwrap();
let store=KeybindStore::open(&dir.0,"Default").unwrap();
assert_eq!(fs::read(file).unwrap(),bytes);
assert_eq!(store.dropped_on_load,modes.len());
assert!(store.diagnostic.as_deref().is_some_and(|message|message.contains("Block Incoming Whispers")));
let mut keys=KeybindRuntime::default();
keys.configure(store.get(),None,&HashSet::new());
assert!(keys.global_bindings().is_empty());
for (_,code) in modes {
assert!(keys.local_down(code,0,false,false).is_empty());
assert!(keys.local_up(code,0).is_empty());
}
assert!(matches!(keys.local_down("F8",0,false,false).as_slice(),[e] if e.binding.id==reply.id && e.phase==Phase::Start));
assert!(matches!(keys.local_up("F8",0).as_slice(),[e] if e.binding.id==reply.id && e.phase==Phase::End));
}
#[test]
fn malformed_and_future_stores_are_not_overwritten_on_open(){ fn malformed_and_future_stores_are_not_overwritten_on_open(){
let t=Temp::new();for bytes in [b"{".as_slice(),br#"{"version":3,"profiles":[]}"#.as_slice()]{fs::write(t.0.join("keybinds.json"),bytes).unwrap();let mut s=KeybindStore::open(&t.0,"Default").unwrap();assert!(s.diagnostic.is_some());assert_eq!(fs::read(t.0.join("keybinds.json")).unwrap(),bytes);if s.read_only{assert!(s.add_profile("No").is_err());}} let t=Temp::new();for bytes in [b"{".as_slice(),br#"{"version":3,"profiles":[]}"#.as_slice()]{fs::write(t.0.join("keybinds.json"),bytes).unwrap();let mut s=KeybindStore::open(&t.0,"Default").unwrap();assert!(s.diagnostic.is_some());assert_eq!(fs::read(t.0.join("keybinds.json")).unwrap(),bytes);if s.read_only{assert!(s.add_profile("No").is_err());}}
} }