fix(app-iced): M119 r1 —— 常驻「模拟」标识 + 确认条的键盘通路
复审 r1 的两条 p2,都是「说成真的、其实是假的」与「能走进死路」这个级别的问题。
## P2-1:界面必须自己说清「这是模拟」
原判:生产默认后端是**脚本化 rig**(`ULL_AGENT_SCRIPT` 的 6 种剧情),而「后端未接 / 模型还没
接上」两句诚实文案被我改成了中性话,理由写着「由端点标签说」——**那条端点标签在壳里根本不存在**。
于是默认配置下用户敲一句话得到一段像是模型编的回答。判据:没读过代码的用户,打开右栏、敲一句话,
必须能自己看出来这不是真模型(不接受 tooltip、不接受藏在设置里)。
修法(①恢复诚实文案 + ②常驻可见标记,并用):
| 位置 | 文案 / 形态 | 谁给的 |
|---|---|---|
| 标题右侧**常驻胶囊**(`SurfaceVariant` tonal)| `Key::AgentSimulated`(Simulated / 模拟)| `AgentHost::is_simulated()` → `Session.simulated` → 视图 |
| 标题下副标题 | 「模拟助手 · 还没接真实模型」 | `Key::AgentSubtitle`(原本是「未接」被改成中性的「会话」,现在写回来且更明确)|
| 空会话正文 | 「…当前是模拟助手,没有接真实模型。」 | `Key::AgentEmptyBody` |
| 输入框占位符 | 「给模拟助手发消息…」 | `Key::AgentPlaceholder` |
**标记不是硬编码在视图里**:`AgentHost.simulated` 是事实字段(今天 transport 只有 rig ⇒ 恒 true)。
接真 `AgentTransport` 那天把它传 `false`,四个位置的「模拟」措辞会一起消失——这是为什么用字段而不是
写死一句话。
## P2-2:确认条必须有键盘通路
原判:Allow/Deny 只有鼠标路径 ⇒ 键盘用户在写操作确认处**永久卡死**(`busy` 锁发送、
`Stop` 走主后端、清不掉 presenter 的 pending confirm)。
- 焦点环多两格:`Focus::ConfirmAllow` / `Focus::ConfirmDeny`,**只在有待确认时**存在
(鼠标用户不会 Tab 到不存在的按钮);
- 待确认出现 ⇒ `sync_confirm_focus()` 把焦点直接落到「允许」并**打开键盘巡航**(阻塞态主动亮环),
消失 ⇒ 焦点收回输入框、巡航关闭;
- `Enter` 与 `Space` 都映射到 `Activate`(`Space` 不抢输入框:`keyboard_mode` 那道闸在
鼠标点进输入框时是关的);
- 焦点环不是 10% 状态层——在**实心主色**按钮上那层几乎看不见(出图实测过一版就是没有)。
改成 2dp `Primary` 描边 + 3px 留白,两个按钮恒定加这层 padding,所以焦点变化不移动布局。
测试(`crates/app-iced/src/app/update/agent/tests.rs`):
`a_blocking_confirm_can_be_decided_with_the_keyboard_alone` —— 全程只有键盘消息:
确认到达后断言 `focus == ConfirmAllow && keyboard_mode`,发一条 `KeyPressed(Enter)` 完成允许;
第二轮 `Tab`(走到 Deny)+ `KeyPressed(Space)` 完成拒绝;两轮各记一条审计、焦点都收回 Composer。
另有 `the_default_backend_reports_itself_as_simulated` 钉住 P2-1 的事实来源。
## 视图入参顺带收成结构体
`docked`/`page` 本来是 6 个形参(`ui, agent, rail, failure, catalog, width`),这一轮还要加
`simulated` ⇒ 7 个。按塔台登记的可维护性口径改成 `Session { agent, rail, failure, simulated }`:
两个宿主各 3 个形参,以后再加展示事实只改 `Session`。
## 出图(18 张,浅深各一)
`DevDocs/artifacts/m119/`:新增 `08-agent-simulated-*`(空会话 + 四处「模拟」措辞)与
`09-agent-confirm-focus-*`(确认条 + 焦点环落在「允许」);其余 7 组全部重出(文案与焦点环都变了)。
## 门禁(真实退出码)
| 命令 | 退出码 |
|---|---|
| `cargo fmt --all --check` | 0 |
| `cargo clippy -p unlucky-app-iced -p unlucky-presenter -p unlucky-agent -p unlucky-i18n --all-targets -- -D warnings` | 0(0 warning)|
| `cargo test -p unlucky-app-iced --lib` | 0(601 passed / 0 failed / 2 ignored)|
| `cargo test --workspace --exclude unlucky-app` | 0(58 套 2277 passed / 0 failed / 11 ignored)|
`golden.rs` 400 行(+1 条 `AgentSimulated` 正好顶线);全树受检文件无 >400。
This commit is contained in:
1 parent
b5e96c61ac
commit
a22baebe70
13 files changed
+383
-122
No files matched your search
@@ -35,7 +35,9 @@ use unlucky_presenter::dto::ConfirmRequest;
|
||||
use crate::app::components::buttons::{self, Button};
|
||||
use crate::theme::Ui;
|
||||
|
||||
use super::super::state::Focus;
|
||||
use super::super::{Failure, Message};
|
||||
use super::focused_state;
|
||||
use super::text_role_owned;
|
||||
|
||||
/// 失败横幅:`ErrorContainer` 图标块 + 标题/正文(M3 内联 alert 的形状,与账户页横幅同源)。
|
||||
@@ -57,6 +59,7 @@ pub(super) fn confirm<'a>(
|
||||
ui: &'a Ui,
|
||||
request: &'a ConfirmRequest,
|
||||
catalog: Catalog,
|
||||
focus: Option<Focus>,
|
||||
) -> Element<'a, Message> {
|
||||
// 摘要来自 presenter(已过 `scrub_text`):它是「要改什么」的唯一描述,必须显示,
|
||||
// 否则用户是在盲签。句框走 catalog,摘要本身是正文。
|
||||
@@ -64,21 +67,67 @@ pub(super) fn confirm<'a>(
|
||||
Key::AgentConfirmRequest,
|
||||
&[("summary", request.summary.as_str())],
|
||||
);
|
||||
// 两个按钮都在 Tab 环上(`Focus::ConfirmAllow` / `Focus::ConfirmDeny`):键盘用户
|
||||
// 用 Enter/Space 就能裁决,不必去找鼠标(P2-2 的那条死路)
|
||||
let deny = focus == Some(Focus::ConfirmDeny);
|
||||
let allow = focus == Some(Focus::ConfirmAllow);
|
||||
let actions: Vec<Element<'a, Message>> = vec![
|
||||
buttons::outlined(
|
||||
ring(
|
||||
ui,
|
||||
Button::new(catalog.text(Key::AgentConfirmDeny), Message::Confirm(false))
|
||||
.leading(IconKind::Close),
|
||||
buttons::outlined(
|
||||
ui,
|
||||
focused_state(
|
||||
Button::new(catalog.text(Key::AgentConfirmDeny), Message::Confirm(false))
|
||||
.leading(IconKind::Close),
|
||||
deny,
|
||||
),
|
||||
),
|
||||
deny,
|
||||
),
|
||||
buttons::filled(
|
||||
ring(
|
||||
ui,
|
||||
Button::new(catalog.text(Key::AgentConfirmAllow), Message::Confirm(true))
|
||||
.leading(IconKind::Check),
|
||||
buttons::filled(
|
||||
ui,
|
||||
focused_state(
|
||||
Button::new(catalog.text(Key::AgentConfirmAllow), Message::Confirm(true))
|
||||
.leading(IconKind::Check),
|
||||
allow,
|
||||
),
|
||||
),
|
||||
allow,
|
||||
),
|
||||
];
|
||||
banner(ui, title, String::new(), actions)
|
||||
}
|
||||
|
||||
/// 焦点环:`Primary` 的 2dp 描边(与输入框聚焦同一套语言)。
|
||||
///
|
||||
/// 为什么不能只用 `Interaction::Focused`(10% 状态层):在**实心主色**按钮上那层几乎看不出来
|
||||
/// ——M119 r1 复审要求「焦点确实落在可操作元素上」且要能出图证明,10% 层在浅色图里等于没有。
|
||||
/// 所以键盘焦点在这两个按钮上额外加一圈描边(鼠标用户的界面不受影响:只有 `focused` 才画)。
|
||||
fn ring<'a>(ui: &'a Ui, button: Element<'a, Message>, focused: bool) -> Element<'a, Message> {
|
||||
// 外圈留 3px 空气:环与按钮之间不贴边,才看得成「一圈」而不是「两条重合的描边」。
|
||||
// 两个按钮**都**加这层 padding(`focused` 与否一样),所以焦点变化不移动布局。
|
||||
let gap = ui.space(Space::X1) * 0.75;
|
||||
let outer = ui.metrics().control_height + gap * 2.0;
|
||||
container(button)
|
||||
.padding(gap)
|
||||
.style(move |_theme| container::Style {
|
||||
border: if focused {
|
||||
iced::Border {
|
||||
color: ui.color(Role::Primary),
|
||||
width: crate::theme::STROKE_PX * 2.0,
|
||||
// 与按钮同一种「药丸」:`Full` 的半径 = 边长 / 2(这里用加过 padding 的边长)
|
||||
radius: ui.radius(ShapeScale::Full, outer),
|
||||
}
|
||||
} else {
|
||||
iced::Border::default()
|
||||
},
|
||||
..container::Style::default()
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
||||
/// 横幅本体:图标块 + 标题/正文 + 右侧动作。
|
||||
///
|
||||
/// 形状与 `pages::account::widgets::alert` 同源(面板底走卡片层 + 1dp 描边,
|
||||
|
||||
Reference in new issue
Block a user