fix(m161): 收更新键/按钮/矮窗口/启动错误/导入结果五笔债

① update.auto_check / update.channel 登记进 core setting schema(1.6.0)
   - 新增 setting/keys/update.rs(两键 + UPDATE_CHANNELS,只允许 stable);
     SettingSchema 加 with_all 供域键表批量登记。
   - 新增 setting/update_prefs.rs:cache/update/prefs.json → launcher.json 的一次性迁移。
     四条硬约束:源指纹闸门(幂等)、不丢 false、新值胜出、旧文件改名 .migrated 后不再被读;
     主配置不可写时不动旧文件。收据 config/update-prefs-migration.json。
   - presenter Runtime 建会话时迁一次并把结局留在 migration();prefs 字段换成
     auto_check + 每次派发从主配置读 channel(不再硬编码 Channel::Stable)。
     保留旧字段 auto_check 的真实来源(原有测试 cases 会断言)。
   - CLI config get/set/dump 先跑同一次迁移(幂等),输出里给 migration 段与收据路径。

② presenter/dto/events.rs 的「本次会话不再弹提示条」注释改成真实语义
   (记的是版本号:同版本压住、更高版本照弹、手动检查清掉)。

③ 检查/下载进行中按钮禁用:pages/update/busy.rs 的 busy/can_check/can_apply;
   设置页两颗按钮改画禁用(不是消失),app 层 on_update_action 再挡一道
   (忙碌时 CheckNow/Apply 不派发);新增两条用例(含「忙完恢回可点」)。

④ 内容库低高度:content_layout::MIN_BODY_HEIGHT=460 + BodyMode(按固定件+三整行算出来,
   用例守着算式);frame::body_height 从 Ui::metrics 算正文可用高,pages::Model 带 window_height。
   ≥460 列表自己滚;<460 主列整列一个滚动条、列表按自然高度铺开。

⑤ 启动错误文案本地化:presenter 删掉 launch_summary / 「启动失败:」前缀 / 五条中文阶段前缀,
   改发 LaunchFailureView{stage,detail};LaunchFinished 改带 exit_code/uptime_ms/failure,
   Toast 由 app 层按 i18n key 现求(与 install_cancelled 同构)。InstancesFailed 拆成
   InstancesFailedStage(列表单行)+ LaunchStageFailed(详情/Toast 全文)。

⑥ 导入结果块:ImportReportView 加 failure_stage(NotStarted/RolledBack/RollbackIncomplete,
   由 core 的 rollback 机器位推出);标题、图标、底色三处分档,预检失败不再说「已回滚」。

顺带:六处注释/文档漂移(update.rs 的分工表与偏好落点、pack 的「已整包回滚」、
build_request 的 Errors、settings/update 的按钮禁用说明等),
以及为守 400 行把 update/cli-config/core-keys/presenter-dto/presenter-launch/i18n-golden
里贴线或越线的文件按模块拆开(纯搬移,行为不变)。
This commit is contained in:
AskaEth committed 2026-11-07 15:02:13 +08:00
1 parent b2d9f3927f
commit 03741ecd2d
69 files changed
+2653 -707

No files matched your search

@@ -107,7 +107,7 @@ fn the_banner_priority_is_ready_then_applying_then_failure_then_available() {
/// 演示模型里更新组能画(`pages_demo` 的 harness 路径):`Model.update` 有默认值,不是 `None` 才画。
#[test]
fn the_demo_model_carries_an_update_snapshot() {
let model = crate::pages::demo_model(Screen::Settings, 1180.0);
let model = crate::pages::demo_model(Screen::Settings, 1180.0, 760.0);
assert_eq!(model.update, crate::pages::update::demo());
assert!(
model.update.available().is_some(),
@@ -115,9 +115,73 @@ fn the_demo_model_carries_an_update_snapshot() {
);
// 其它页不掺演示更新状态(实例页/下载页的基线图不该多出一条提示条)。
assert_eq!(
crate::pages::demo_model(Screen::Instances, 1180.0).update,
crate::pages::demo_model(Screen::Instances, 1180.0, 760.0).update,
Update::default()
);
let catalog: Catalog = Lang::En.catalog();
assert!(!catalog.text(Key::SettingsGroupUpdate).is_empty());
}
/// **忙碌时按钮禁用,且禁用态与状态行同源**(M161 收的债:以前点了没反应)。
///
/// 三条判据:
/// ① `Checking` / `applying` 时 `can_check()` 与 `can_apply()` 都是 false(按钮画成置灰);
/// ② 这两态下设置页的状态行**必须**是「正在检查…」/「正在安装…」——否则用户看到一颗灰按钮
/// 却没有任何解释;
/// ③ 结论回来(失败也算)之后恢回可点:超时/网络失败不许把按钮永久钉死。
#[test]
fn the_buttons_are_disabled_exactly_while_something_is_running() {
use super::super::update::status_line;
let catalog = Catalog::of(Lang::ZhCn);
let available = UpdateStatus::Available {
version: "0.2.3".to_string(),
size: 1024,
notes: String::new(),
forced: false,
};
// 静息:有候选 ⇒ 两颗按钮都能点。
let idle = Update {
status: available.clone(),
..Update::default()
};
assert!(!idle.busy());
assert!(idle.can_check(), "静息时「立即检查」可点");
assert!(idle.can_apply(), "有候选且不忙 ⇒ 「下载并安装」可点");
// 正在查:两颗都置灰,状态行说「正在检查」。
let checking = Update {
status: UpdateStatus::Checking,
..idle.clone()
};
assert!(checking.busy(), "Checking 就是忙碌");
assert!(!checking.can_check(), "查的时候不许再点「立即检查」");
assert!(!checking.can_apply(), "查的时候不许装(presenter 也拒)");
assert_eq!(
status_line(catalog, &checking).0,
catalog.text(Key::SettingsUpdateChecking),
"灰按钮旁边必须有「正在检查…」这句话"
);
// 正在装:`applying` 也算忙碌(此时 status 可能仍是 Available)。
let applying = Update {
applying: true,
..idle.clone()
};
assert!(applying.busy());
assert!(!applying.can_apply(), "装的时候安装键置灰,不是消失");
assert!(!applying.can_check(), "装的时候也不许再来一条检查");
// 结论回来(这里是最坏的结论:失败)⇒ 恢回可点。
let failed = Update {
status: UpdateStatus::Failed {
reason: "连不上".to_string(),
retryable: true,
},
..Update::default()
};
assert!(!failed.busy(), "失败 = 这一轮结束了");
assert!(failed.can_check(), "失败之后必须能重试");
assert!(!failed.can_apply(), "没有候选时安装键不可点");
}
+35 -23
View File
@@ -73,7 +73,7 @@ pub(super) fn body<'a>(ui: &'a Ui, update: &'a Update, lang: Lang) -> Element<'a
channel_label(catalog, &update.channel),
));
stacked = stacked.push(divider(ui));
stacked = stacked.push(auto_check_row(ui, catalog, update.auto_check));
stacked = stacked.push(auto_check_row(ui, catalog, update));
stacked = stacked.push(divider(ui));
stacked = stacked.push(status_block(ui, catalog, update));
@@ -117,23 +117,30 @@ fn info_row<'a>(ui: &'a Ui, label: &'a str, value: String) -> Element<'a, Messag
}
/// 自动检查开关 + 「立即检查」按钮。
fn auto_check_row<'a>(ui: &'a Ui, catalog: Catalog, auto_check: bool) -> Element<'a, Message> {
///
/// **忙碌时「立即检查」置灰**(M161):此前它永远可点,而 presenter 的 `begin_check` 在
/// inflight 时静默 `return None`——用户点了没反应,还以为启动器卡了。禁用态与状态行同源
/// (同一个 [`Update::busy`]):按钮灰着的时候,下面那句状态行一定是「正在检查…」/「正在安装…」。
fn auto_check_row<'a>(ui: &'a Ui, catalog: Catalog, update: &Update) -> Element<'a, Message> {
let check_now = catalog.text(Key::SettingsUpdateCheckNow);
let check = if update.can_check() {
buttons::text(
ui,
Button::new(check_now, Message::Update(UpdateAction::CheckNow)),
)
} else {
buttons::text(ui, Button::disabled(check_now))
};
row![
chip(
ui,
Chip::filter(
catalog.text(Key::SettingsUpdateAutoCheck),
auto_check,
Message::Update(UpdateAction::SetAutoCheck(!auto_check)),
),
),
buttons::text(
ui,
Button::new(
catalog.text(Key::SettingsUpdateCheckNow),
Message::Update(UpdateAction::CheckNow),
update.auto_check,
Message::Update(UpdateAction::SetAutoCheck(!update.auto_check)),
),
),
check,
]
.spacing(ui.space(Space::X3))
.width(Length::Fill)
@@ -171,17 +178,21 @@ fn status_block<'a>(ui: &'a Ui, catalog: Catalog, update: &'a Update) -> Element
});
block = block.push(text_role_owned(ui, TypeRole::BodySmall, false, text, color));
if let Some((_version, _size, notes, forced)) = update.available().filter(|_| !update.applying)
{
let mut actions = row![buttons::filled(
ui,
Button::new(
catalog.text(Key::SettingsUpdateApply),
Message::Update(UpdateAction::Apply),
),
)]
.spacing(ui.space(Space::X2))
.align_y(Alignment::Center);
if let Some((_version, _size, notes, forced)) = update.available() {
// 有候选就**永远画出**这一颗按钮:忙碌时置灰(`can_apply` = false),而不是整颗消失。
// 消失会让人以为「装到一半的功能没了」;灰着 + 状态行那句「正在安装…」才说得清。
let apply_label = catalog.text(Key::SettingsUpdateApply);
let apply = if update.can_apply() {
buttons::filled(
ui,
Button::new(apply_label, Message::Update(UpdateAction::Apply)),
)
} else {
buttons::filled(ui, Button::disabled(apply_label))
};
let mut actions = row![apply]
.spacing(ui.space(Space::X2))
.align_y(Alignment::Center);
if forced {
actions = actions.push(text_role_owned(
ui,
@@ -234,7 +245,8 @@ fn status_block<'a>(ui: &'a Ui, catalog: Catalog, update: &'a Update) -> Element
/// 一条状态行(文案 + 是不是「错」那一类)。
///
/// 四种结论各写各的句子,**不共用**「已是最新」那句:失败/缺产物时那句就是撒谎。
fn status_line(catalog: Catalog, update: &Update) -> (String, bool) {
/// `pub(super)` 只为让 `settings/tests` 能断言「忙碌时状态行与按钮禁用态同源」。
pub(super) fn status_line(catalog: Catalog, update: &Update) -> (String, bool) {
let (key, args, error) = match &update.status {
UpdateStatus::Idle => (Key::SettingsUpdateNever, Vec::new(), false),
UpdateStatus::Checking => (Key::SettingsUpdateChecking, Vec::new(), false),