fix(settings): nav labels wrap like Teams instead of truncating
- Nav labels wrap, item min height 32 with vertical padding instead of fixed 34 - Selected item keeps regular weight, marked by fill and accent icon (Lucide has no filled glyphs, accent colour stands in for Teams' filled icon) - Nav is 280 wide at every size (Teams list pane minimum), compact only shrinks the inset - layout_guard checks at 960x640, 1280x800 and 1920x1080 that every nav label is fully visible Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -171,7 +171,7 @@ mod frames {
171
171
use crate::app_state::{AppHandle, AppState, Mode, Selection};
172
172
use crate::call::{ActiveCall, CallModel, ConsultCall};
173
173
use crate::demo;
174
use crate::settings::metrics;
174
use crate::settings::{item_selector, label, label_selector, metrics};
175
175
use crate::settings_section::SettingsSection;
176
176
use crate::user_activity::UserInput;
177
177
use crate::views::call_transcript::TranscriptPanel;
@@ -263,6 +263,10 @@ mod frames {
263
263
"settings/main/body",
264
264
];
265
265
const SETTINGS_BODY: &str = "settings/main/body";
266
const SETTINGS_NAV: &str = "settings/nav";
267
const SETTINGS_NAV_ABOUT: &str = "settings/nav/about";
268
const NAV_LABEL_SIZE: f32 = 14.;
269
const NAV_LINE_HEIGHT: f32 = 20.;
266
270
const SETTINGS_CONTENT: &str = "settings/main/body/content";
267
271
const MEMBERS_TAGS: &[&str] = &["chat-members-popup", "chat-members-popup/divider"];
268
272
const MEMBERS_CHAT: &str = "demo-chat-release";
@@ -1097,6 +1101,7 @@ mod frames {
1097
1101
size: size(px(width), px(height)),
1098
1102
};
1099
1103
let inset = metrics(width, height).inset;
1104
let label_sizes = NAV_LABEL_SIZES.contains(&(width, height));
1100
1105
for §ion in sections {
1101
1106
visual
1102
1107
.update(|_, cx| state.update(cx, |state, cx| state.open_settings(section, cx)));
@@ -1106,6 +1111,9 @@ mod frames {
1106
1111
.filter(|(key, _)| key.starts_with("settings"))
1107
1112
.chain(inset_violations(&tags, INSET_RULES))
1108
1113
.collect();
1114
if label_sizes {
1115
found.extend(nav_label_violations(&mut visual));
1116
}
1109
1117
let scrolled_exempt = SCROLLED_INSET_ALLOWLIST
1110
1118
.iter()
1111
1119
.any(|(exempt, _)| *exempt == section);
@@ -1134,6 +1142,71 @@ mod frames {
1134
1142
}
1135
1143
}
1136
1144
1145
const NAV_LABEL_SIZES: [(f32, f32); 3] = [(960., 640.), (1280., 800.), (1920., 1080.)];
1146
1147
fn nav_label_violations(visual: &mut VisualTestContext) -> Vec<(String, String)> {
1148
let Some(nav) = visual.debug_bounds(SETTINGS_NAV) else {
1149
return vec![(SETTINGS_NAV.to_owned(), "not rendered".to_owned())];
1150
};
1151
let mut found = Vec::new();
1152
for section in SETTINGS_SECTIONS {
1153
let label_path: &'static str = Box::leak(label_selector(section).into_boxed_str());
1154
let item_path: &'static str = if section == SettingsSection::About {
1155
SETTINGS_NAV_ABOUT
1156
} else {
1157
Box::leak(item_selector(section).into_boxed_str())
1158
};
1159
let (Some(label_bounds), Some(item)) = (
1160
visual.debug_bounds(label_path),
1161
visual.debug_bounds(item_path),
1162
) else {
1163
if section != SettingsSection::Agents {
1164
found.push((label_path.to_owned(), "not rendered".to_owned()));
1165
}
1166
continue;
1167
};
1168
let text = label(section);
1169
let text_width = visual.update(|window, _| {
1170
let run = window.text_style().to_run(text.len());
1171
f32::from(
1172
window
1173
.text_system()
1174
.shape_line(text.into(), px(NAV_LABEL_SIZE), &[run], None)
1175
.width,
1176
)
1177
});
1178
let label_width = f32::from(label_bounds.size.width);
1179
let label_height = f32::from(label_bounds.size.height);
1180
if text_width > label_width + TOLERANCE
1181
&& label_height < 2. * NAV_LINE_HEIGHT - TOLERANCE
1182
{
1183
found.push((
1184
label_path.to_owned(),
1185
format!("{text:?} needs {text_width} px, has {label_width} px on one line: truncated"),
1186
));
1187
}
1188
let outside = |inner: Bounds<Pixels>, outer: Bounds<Pixels>| {
1189
inner.left() < outer.left() - px(TOLERANCE)
1190
|| inner.right() > outer.right() + px(TOLERANCE)
1191
|| inner.top() < outer.top() - px(TOLERANCE)
1192
|| inner.bottom() > outer.bottom() + px(TOLERANCE)
1193
};
1194
if outside(label_bounds, item) {
1195
found.push((
1196
label_path.to_owned(),
1197
format!("label {label_bounds:?} outside item {item:?}"),
1198
));
1199
}
1200
if item.left() < nav.left() || item.right() > nav.right() {
1201
found.push((
1202
item_path.to_owned(),
1203
format!("item {item:?} outside nav {nav:?}"),
1204
));
1205
}
1206
}
1207
found
1208
}
1209
1137
1210
fn scrolled_inset_violation(visual: &mut VisualTestContext) -> Option<(String, String)> {
1138
1211
let body = visual.debug_bounds(SETTINGS_BODY)?;
1139
1212
let content = visual.debug_bounds(SETTINGS_CONTENT)?;
@@ -171,7 +171,7 @@ mod frames {171
use crate::app_state::{AppHandle, AppState, Mode, Selection};171
use crate::app_state::{AppHandle, AppState, Mode, Selection};172
use crate::call::{ActiveCall, CallModel, ConsultCall};172
use crate::call::{ActiveCall, CallModel, ConsultCall};173
use crate::demo;173
use crate::demo;174
use crate::settings::metrics;174
use crate::settings::{item_selector, label, label_selector, metrics};175
use crate::settings_section::SettingsSection;175
use crate::settings_section::SettingsSection;176
use crate::user_activity::UserInput;176
use crate::user_activity::UserInput;177
use crate::views::call_transcript::TranscriptPanel;177
use crate::views::call_transcript::TranscriptPanel;@@ -263,6 +263,10 @@ mod frames {263
"settings/main/body",263
"settings/main/body",264
];264
];265
const SETTINGS_BODY: &str = "settings/main/body";265
const SETTINGS_BODY: &str = "settings/main/body";266
const SETTINGS_NAV: &str = "settings/nav";267
const SETTINGS_NAV_ABOUT: &str = "settings/nav/about";268
const NAV_LABEL_SIZE: f32 = 14.;269
const NAV_LINE_HEIGHT: f32 = 20.;266
const SETTINGS_CONTENT: &str = "settings/main/body/content";270
const SETTINGS_CONTENT: &str = "settings/main/body/content";267
const MEMBERS_TAGS: &[&str] = &["chat-members-popup", "chat-members-popup/divider"];271
const MEMBERS_TAGS: &[&str] = &["chat-members-popup", "chat-members-popup/divider"];268
const MEMBERS_CHAT: &str = "demo-chat-release";272
const MEMBERS_CHAT: &str = "demo-chat-release";@@ -1097,6 +1101,7 @@ mod frames {1097
size: size(px(width), px(height)),1101
size: size(px(width), px(height)),1098
};1102
};1099
let inset = metrics(width, height).inset;1103
let inset = metrics(width, height).inset;1104
let label_sizes = NAV_LABEL_SIZES.contains(&(width, height));1100
for §ion in sections {1105
for §ion in sections {1101
visual1106
visual1102
.update(|_, cx| state.update(cx, |state, cx| state.open_settings(section, cx)));1107
.update(|_, cx| state.update(cx, |state, cx| state.open_settings(section, cx)));@@ -1106,6 +1111,9 @@ mod frames {1106
.filter(|(key, _)| key.starts_with("settings"))1111
.filter(|(key, _)| key.starts_with("settings"))1107
.chain(inset_violations(&tags, INSET_RULES))1112
.chain(inset_violations(&tags, INSET_RULES))1108
.collect();1113
.collect();1114
if label_sizes {1115
found.extend(nav_label_violations(&mut visual));1116
}1109
let scrolled_exempt = SCROLLED_INSET_ALLOWLIST1117
let scrolled_exempt = SCROLLED_INSET_ALLOWLIST1110
.iter()1118
.iter()1111
.any(|(exempt, _)| *exempt == section);1119
.any(|(exempt, _)| *exempt == section);@@ -1134,6 +1142,71 @@ mod frames {1134
}1142
}1135
}1143
}1136
1144
1145
const NAV_LABEL_SIZES: [(f32, f32); 3] = [(960., 640.), (1280., 800.), (1920., 1080.)];1146
1147
fn nav_label_violations(visual: &mut VisualTestContext) -> Vec<(String, String)> {1148
let Some(nav) = visual.debug_bounds(SETTINGS_NAV) else {1149
return vec![(SETTINGS_NAV.to_owned(), "not rendered".to_owned())];1150
};1151
let mut found = Vec::new();1152
for section in SETTINGS_SECTIONS {1153
let label_path: &'static str = Box::leak(label_selector(section).into_boxed_str());1154
let item_path: &'static str = if section == SettingsSection::About {1155
SETTINGS_NAV_ABOUT1156
} else {1157
Box::leak(item_selector(section).into_boxed_str())1158
};1159
let (Some(label_bounds), Some(item)) = (1160
visual.debug_bounds(label_path),1161
visual.debug_bounds(item_path),1162
) else {1163
if section != SettingsSection::Agents {1164
found.push((label_path.to_owned(), "not rendered".to_owned()));1165
}1166
continue;1167
};1168
let text = label(section);1169
let text_width = visual.update(|window, _| {1170
let run = window.text_style().to_run(text.len());1171
f32::from(1172
window1173
.text_system()1174
.shape_line(text.into(), px(NAV_LABEL_SIZE), &[run], None)1175
.width,1176
)1177
});1178
let label_width = f32::from(label_bounds.size.width);1179
let label_height = f32::from(label_bounds.size.height);1180
if text_width > label_width + TOLERANCE1181
&& label_height < 2. * NAV_LINE_HEIGHT - TOLERANCE1182
{1183
found.push((1184
label_path.to_owned(),1185
format!("{text:?} needs {text_width} px, has {label_width} px on one line: truncated"),1186
));1187
}1188
let outside = |inner: Bounds<Pixels>, outer: Bounds<Pixels>| {1189
inner.left() < outer.left() - px(TOLERANCE)1190
|| inner.right() > outer.right() + px(TOLERANCE)1191
|| inner.top() < outer.top() - px(TOLERANCE)1192
|| inner.bottom() > outer.bottom() + px(TOLERANCE)1193
};1194
if outside(label_bounds, item) {1195
found.push((1196
label_path.to_owned(),1197
format!("label {label_bounds:?} outside item {item:?}"),1198
));1199
}1200
if item.left() < nav.left() || item.right() > nav.right() {1201
found.push((1202
item_path.to_owned(),1203
format!("item {item:?} outside nav {nav:?}"),1204
));1205
}1206
}1207
found1208
}1209
1137
fn scrolled_inset_violation(visual: &mut VisualTestContext) -> Option<(String, String)> {1210
fn scrolled_inset_violation(visual: &mut VisualTestContext) -> Option<(String, String)> {1138
let body = visual.debug_bounds(SETTINGS_BODY)?;1211
let body = visual.debug_bounds(SETTINGS_BODY)?;1139
let content = visual.debug_bounds(SETTINGS_CONTENT)?;1212
let content = visual.debug_bounds(SETTINGS_CONTENT)?;@@ -21,6 +21,8 @@ const CONTENT_MAX_WIDTH: f32 = 744.;
21
21
const CLOSE_SIZE: f32 = 32.;
22
22
const COMPACT_BELOW_WIDTH: f32 = 1100.;
23
23
const COMPACT_BELOW_HEIGHT: f32 = 720.;
24
const NAV_WIDTH: f32 = 280.;
25
const PADDING: f32 = 24.;
24
26
25
27
pub enum SettingsDialogEvent {
26
28
Close,
@@ -34,18 +36,11 @@ pub struct DialogMetrics {
34
36
}
35
37
36
38
pub fn metrics(window_width: f32, window_height: f32) -> DialogMetrics {
37
if window_width < COMPACT_BELOW_WIDTH || window_height < COMPACT_BELOW_HEIGHT {
38
DialogMetrics {
39
inset: 24.,
40
nav_width: 216.,
41
padding: 18.,
42
}
43
} else {
44
DialogMetrics {
45
inset: 48.,
46
nav_width: 264.,
47
padding: 24.,
48
}
39
let compact = window_width < COMPACT_BELOW_WIDTH || window_height < COMPACT_BELOW_HEIGHT;
40
DialogMetrics {
41
inset: if compact { 24. } else { 48. },
42
nav_width: NAV_WIDTH,
43
padding: PADDING,
49
44
}
50
45
}
51
46
@@ -288,9 +283,17 @@ mod tests {
288
283
#[test]
289
284
fn small_windows_get_the_compact_inset() {
290
285
assert_eq!(metrics(1280., 800.).inset, 48.);
291
assert_eq!(metrics(1920., 1080.).nav_width, 264.);
292
286
assert_eq!(metrics(960., 640.).inset, 24.);
293
assert_eq!(metrics(1280., 640.).nav_width, 216.);
287
assert_eq!(metrics(1280., 640.).inset, 24.);
288
}
289
290
#[test]
291
fn nav_keeps_the_teams_list_pane_minimum_width() {
292
for (width, height) in [(640., 480.), (960., 640.), (1280., 800.), (1920., 1080.)] {
293
let metrics = metrics(width, height);
294
assert_eq!(metrics.nav_width, 280.);
295
assert_eq!(metrics.padding, 24.);
296
}
294
297
}
295
298
296
299
#[test]
@@ -21,6 +21,8 @@ const CONTENT_MAX_WIDTH: f32 = 744.;21
const CLOSE_SIZE: f32 = 32.;21
const CLOSE_SIZE: f32 = 32.;22
const COMPACT_BELOW_WIDTH: f32 = 1100.;22
const COMPACT_BELOW_WIDTH: f32 = 1100.;23
const COMPACT_BELOW_HEIGHT: f32 = 720.;23
const COMPACT_BELOW_HEIGHT: f32 = 720.;24
const NAV_WIDTH: f32 = 280.;25
const PADDING: f32 = 24.;24
26
25
pub enum SettingsDialogEvent {27
pub enum SettingsDialogEvent {26
Close,28
Close,@@ -34,18 +36,11 @@ pub struct DialogMetrics {34
}36
}35
37
36
pub fn metrics(window_width: f32, window_height: f32) -> DialogMetrics {38
pub fn metrics(window_width: f32, window_height: f32) -> DialogMetrics {37
if window_width < COMPACT_BELOW_WIDTH || window_height < COMPACT_BELOW_HEIGHT {39
let compact = window_width < COMPACT_BELOW_WIDTH || window_height < COMPACT_BELOW_HEIGHT;38
DialogMetrics {40
DialogMetrics {39
inset: 24.,41
inset: if compact { 24. } else { 48. },40
nav_width: 216.,42
nav_width: NAV_WIDTH,41
padding: 18.,43
padding: PADDING,42
}43
} else {44
DialogMetrics {45
inset: 48.,46
nav_width: 264.,47
padding: 24.,48
}49
}44
}50
}45
}51
46
@@ -288,9 +283,17 @@ mod tests {288
#[test]283
#[test]289
fn small_windows_get_the_compact_inset() {284
fn small_windows_get_the_compact_inset() {290
assert_eq!(metrics(1280., 800.).inset, 48.);285
assert_eq!(metrics(1280., 800.).inset, 48.);291
assert_eq!(metrics(1920., 1080.).nav_width, 264.);292
assert_eq!(metrics(960., 640.).inset, 24.);286
assert_eq!(metrics(960., 640.).inset, 24.);293
assert_eq!(metrics(1280., 640.).nav_width, 216.);287
assert_eq!(metrics(1280., 640.).inset, 24.);288
}289
290
#[test]291
fn nav_keeps_the_teams_list_pane_minimum_width() {292
for (width, height) in [(640., 480.), (960., 640.), (1280., 800.), (1920., 1080.)] {293
let metrics = metrics(width, height);294
assert_eq!(metrics.nav_width, 280.);295
assert_eq!(metrics.padding, 24.);296
}294
}297
}295
298
296
#[test]299
#[test]@@ -10,7 +10,9 @@ mod nav;
10
10
mod notifications;
11
11
mod rows;
12
12
13
pub use dialog::{SettingsDialog, SettingsDialogEvent};
14
13
#[cfg(test)]
15
14
pub use dialog::metrics;
15
pub use dialog::{SettingsDialog, SettingsDialogEvent};
16
#[cfg(test)]
17
pub use nav::{item_selector, label, label_selector};
16
18
pub(crate) use rows::switch;
@@ -10,7 +10,9 @@ mod nav;10
mod notifications;10
mod notifications;11
mod rows;11
mod rows;12
12
13
pub use dialog::{SettingsDialog, SettingsDialogEvent};14
#[cfg(test)]13
#[cfg(test)]15
pub use dialog::metrics;14
pub use dialog::metrics;15
pub use dialog::{SettingsDialog, SettingsDialogEvent};16
#[cfg(test)]17
pub use nav::{item_selector, label, label_selector};16
pub(crate) use rows::switch;18
pub(crate) use rows::switch;