diff --git a/crates/app-iced/src/pages/agent/mod.rs b/crates/app-iced/src/pages/agent/mod.rs index e7f53d4..d3d4444 100644 --- a/crates/app-iced/src/pages/agent/mod.rs +++ b/crates/app-iced/src/pages/agent/mod.rs @@ -283,7 +283,7 @@ fn unread_text<'a>(ui: &'a Ui, unread: usize, _catalog: Catalog) -> Element<'a, // ---------------------------------------------------------------- 展开档:拖拽缝 + 面板 fn panel<'a>(ui: &'a Ui, agent: &'a AgentUi, window_width: f32) -> Element<'a, Message> { - let width = agent.width(window_width); + let width = agent.rail_width(window_width); let body = container(conversation::view( ui, diff --git a/crates/app-iced/src/pages/agent/state.rs b/crates/app-iced/src/pages/agent/state.rs index bd1fe85..951111f 100644 --- a/crates/app-iced/src/pages/agent/state.rs +++ b/crates/app-iced/src/pages/agent/state.rs @@ -233,7 +233,11 @@ impl AgentUi { } /// 右栗当前宽度(窗口宽度是判据之一:窗口变窄时展开档会被夹住)。 - pub fn width(&self, window_width: f32) -> f32 { + /// + /// 名字故意不叫 `width`:`tests/no_hardcoded_tokens.rs` 会把任何 `.width(数字)` 当成 + /// 「布局尺寸写死」拦下来,而测试里 `agent.width(1180.0)` 会被误判(那条门禁扫的是控件调用点, + /// 分不清是谁的方法)。 + pub fn rail_width(&self, window_width: f32) -> f32 { rail_width(window_width, self.rail, self.expanded) } diff --git a/crates/app-iced/src/pages/agent/tests.rs b/crates/app-iced/src/pages/agent/tests.rs index 91329f1..ba93c64 100644 --- a/crates/app-iced/src/pages/agent/tests.rs +++ b/crates/app-iced/src/pages/agent/tests.rs @@ -327,7 +327,7 @@ fn the_detached_state_frees_the_rail_slot() { let mut agent = AgentUi::new(); agent.detach(); assert!(docked(&ui, &agent, 1180.0).is_none()); - assert_eq!(agent.width(1180.0), 0.0); + assert_eq!(agent.rail_width(1180.0), 0.0); assert_eq!(agent.content_width(1180.0), 1180.0); } @@ -362,7 +362,7 @@ fn the_resize_gutter_is_part_of_the_budget() { let mut agent = AgentUi::new(); agent.expand(); assert_eq!( - agent.width(1180.0) + RESIZE_GUTTER, + agent.rail_width(1180.0) + RESIZE_GUTTER, 1180.0 - agent.content_width(1180.0) );