refactor(notice): make the notice table exhaustive and drop dead wire entries

D5 cleanup, frontend and backend in one commit: removes the six
config_validate::* statuses that never receive a backend send and the
set_config::ok send (enum variants, golden list 41→34, send point in
restart_clash_core), their frontend handlers, and the five i18n keys only
those handlers used. The notice table is now typed as a Record over the
generated NoticeStatus union, so a status without a frontend entry fails
to compile. The info status (sent by the silent updater for breaking
change notices, previously dropped with a console warning) now shows an
info toast — the one deliberate behavior delta.
This commit is contained in:
Tunglies
2026-09-30 20:39:41 +08:00
parent d2180e2d18
commit 98df564af2
21 changed files with 42 additions and 180 deletions
+4 -3
View File
@@ -355,11 +355,11 @@ fn sample_frontend_events(uid: &String) -> Vec<(FrontendEvent<'_>, &'static str,
),
(
FrontendEvent::NoticeMessage {
status: NoticeStatus::SetConfigOk,
status: NoticeStatus::Info,
message: Arc::from("ok"),
},
"verge://notice-message",
json!(["set_config::ok", "ok"]),
json!(["info", "ok"]),
),
(
FrontendEvent::TimerUpdated { profile_index: uid },
@@ -414,7 +414,8 @@ pub fn frontend_wire_contract() -> serde_json::Value {
.collect();
let statuses: Vec<_> = NoticeStatus::ALL
.iter()
.map(|status| serde_json::to_value(status).expect("NoticeStatus serializes"))
// A unit variant with a string rename cannot fail to serialize.
.filter_map(|status| serde_json::to_value(status).ok())
.collect();
json!({ "version": 1, "events": events, "noticeStatuses": statuses })
}