S016: R1-09 wavy loading address bar

While the active tab loads, the address pill squeezes into a wavy progress
bar mapping an estimate of the load (Servo reports only stages); hover,
focus or typing springs it back to the field. selftest gets fakeload,
hover and blur for the loading and hover shots in tests/smoke/chrome.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
astar76 2026-11-12 00:08:32 -06:00
commit 87299d3d7b
5 changed files with 128 additions and 5 deletions

View file

@ -148,6 +148,15 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
the change (only the old one), welcome Import with a detected browser, hover/press states, tiny windows. "Make Nacre
your default browser" is not in the done step (no code for it yet).
## S016 follow-up — R1-09 wavy loading address bar (2026-11-12)
- Done: while the active tab loads, the address pill squeezes (DEFAULT spring) into a 4 pt track and becomes
`paint::wavy_progress`; the pointer over it, focus or typing morphs it back; after the load it fills to the end,
then the field returns. Motion off = instant. Servo 0.7 gives only stages, so `chrome::load_estimate` eases to
0.6 (Started) / 0.92 (HeadParsed) over time; test added. selftest: `fakeload <s>|done`, `hover <x> <y>|none`, `blur`.
- Verified: chrome.txt (loading-dark, loading-morph-dark, loading-hover-dark, loading-again-dark, loaded-dark,
loading-light) and launch.txt exit 0 on Xvfb and with SMOKE_VISIBLE=1 (real GPU, 772 px wide tiled window);
52 unit tests. Not seen: a real slow network load (local pages finish too fast; fakeload holds the stage).
## Later
- Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now).
- Packaging and first release (D-001: plan when the user asks).

View file

@ -34,5 +34,5 @@ State tags: `[open]`, `[fixed <commit>]`, `[wontfix: reason]`. Severity: high /
- R1-06 [open] Wants the feel of the old Python Nacre (`nacre` in ~/.local/bin: dark Material-style lists of nacre:// pages, outlined icons), improved with animations and an "unslop" look, very user friendly. Severity: medium. Input for the Phase 4 redesign.
- R1-07 [open] Ad-block removal animation, like the "pie" ad blocker extension: before a blocked ad element (e.g. YouTube in-feed "Sponsored" cards, feed/sidebar ad slots) disappears, show a Material You overlay on it, a tonal shape (cookie/scalloped) with a check mark that pops in, then the element shrinks out and its height/width collapses smoothly so the surrounding content shifts into place (no jump, no blank gap). Applies to cosmetic removals and YouTube ad slots. Today `COSMETIC_JS` in `src/inject.rs` only fades and scales to 0.92 and then sets `display:none`, so content jumps. Respect the Motion setting and `animate_removal`; skip offscreen elements. Severity: medium. (user, during S019) → S012.
- R1-08 [fixed S020] Welcome page: make nacre://welcome the multi-step setup flow from the user's recording (steps, motion and frames in docs/UI-BRIEF.md "Welcome page", `docs/ui-reference/welcome-*.jpg`), improved where possible. Severity: medium. (user, during S019) → S020.
- R1-09 [open] Address bar becomes a wavy progress bar while a page loads: the address pill turns into a Material 3 Expressive wavy (wiggly) progress line that maps the page's load progress; hovering it (or focusing it, or typing) morphs it back to the normal text field; when not loading it's the normal field. Every change between the two states is animated (spring morph, Motion setting respected). Build it as described here; the old browser's loading wave (a line under the pill) is NOT the target. Severity: medium. (user, during S020) → chrome follow-up after S020, before S021.
- R1-09 [fixed] Address bar becomes a wavy progress bar while a page loads: the address pill turns into a Material 3 Expressive wavy (wiggly) progress line that maps the page's load progress; hovering it (or focusing it, or typing) morphs it back to the normal text field; when not loading it's the normal field. Every change between the two states is animated (spring morph, Motion setting respected). Build it as described here; the old browser's loading wave (a line under the pill) is NOT the target. Severity: medium. (user, during S020) → chrome follow-up after S020, before S021.
- R1-10 [open] Tab loading indicator: while a tab loads, its favicon spot shows a cookie-shaped (scalloped, M3 Expressive) progress ring, like the original Python Nacre's that the user liked: the stroke draws forward around the cookie outline, then retracts backwards, and keeps repeating while the whole shape spins smoothly; it morphs back into the favicon when loading ends. Motion setting respected (Motion off = static indicator). Here the original IS the reference: `draw_spinner` in `~/Documents/Apps/Nacre/nacre/widgets.py`, used by `tabs.py` (read only). Severity: medium. (user, after S020) → chrome follow-up with R1-09, before S021.

View file

@ -12,6 +12,9 @@
//! flyout <name> main, downloads, shield, vpn, media, siteinfo, profiles, apps, qr, tabmenu, back,
//! bookmark (edit the current page's bookmark), none
//! type <text> put text in the address bar with its suggestions open
//! fakeload <seconds>|done hold the active tab that far into a load, or end it
//! blur leave the address field (as Escape does)
//! hover <x> <y>|none move the pointer over the window (points), or away
//! do <action> a shortcut action by its settings key, e.g. `do new_tab`
//! cmd <name> [arg] back, forward, reload, bookmark, install_app, pip, exitpip, free_memory,
//! update_lists, check_updates, close_tab, select <n>, zoom <step>,
@ -349,6 +352,42 @@ impl App {
}
self.redraw(window);
},
"fakeload" => {
// Hold the active tab in the middle of a load (local pages load too fast to catch), or end it.
if let Some(tab) = self.windows.get_mut(&window).and_then(|w| w.tabs.get_mut(w.active)) {
match rest.parse::<f64>() {
Ok(secs) => {
tab.load_status = Some(servo::LoadStatus::Started);
tab.load_started = Instant::now().checked_sub(Duration::from_secs_f64(secs));
},
Err(_) => {
tab.load_status = Some(servo::LoadStatus::Complete);
tab.load_started = None;
},
}
}
self.redraw(window);
},
"blur" => {
// Leave the address field as Escape would.
if let Some(win) = self.windows.get_mut(&window) {
win.egui.egui_ctx.memory_mut(|m| m.stop_text_input());
win.ui.omnibox_edit = None;
}
self.run_in(window, Command::FocusPage);
},
"hover" => {
// Put the pointer over the chrome (window points), or take it away with `hover none`.
let mut parts = rest.split_whitespace().filter_map(|p| p.parse::<f32>().ok());
let event = match (parts.next(), parts.next()) {
(Some(x), Some(y)) => egui::Event::PointerMoved(egui::pos2(x, y)),
_ => egui::Event::PointerGone,
};
if let Some(win) = self.windows.get_mut(&window) {
win.egui.egui_winit.egui_input_mut().events.push(event);
}
self.redraw(window);
},
"log" => self.selftest_log(rest),
"quit" => self.quit(),
_ => self.selftest_log(&format!("unknown line: {line}")),

View file

@ -579,18 +579,47 @@ fn omnibox(ui: &mut Ui, f: &mut Frame) {
let zoom = tab.zoom;
let bookmarked = is_web && f.shared.bookmarks.borrow().is_bookmarked(&tab.url);
let installable = is_web && shown.starts_with("http") && url::Url::parse(&shown).is_ok_and(|u| f.shared.apps.borrow().for_url(&u).is_none());
let (tab_id, loading) = (tab.id, tab.loading());
let estimate = load_estimate(tab.load_status, tab.load_started.map(|t| t.elapsed().as_secs_f32()).unwrap_or(0.0));
let id = ui.id().with("omnibox");
let (rect, background) = ui.allocate_exact_size(vec2(ui.available_width().max(160.0), theme::CONTROL), Sense::hover());
let pointer = background.hovered() || ui.rect_contains_pointer(rect);
let focus = theme::effect(&ctx, id.with("focus"), f.ui.omnibox_focused);
let hover = theme::effect(&ctx, id.with("hover"), background.hovered() || ui.rect_contains_pointer(rect));
let hover = theme::effect(&ctx, id.with("hover"), pointer);
// While the page loads the whole pill turns into a wavy progress bar; the pointer, focus or typing bring the
// field back. After the load it fills to the end before the field comes back.
let progress_id = Id::new(("load-progress", tab_id));
let mut progress = theme::spring(&ctx, progress_id, if loading { estimate } else { 1.0 }, theme::EFFECT);
if loading && progress > estimate + 0.25 {
// A new load after a finished one starts from the left again.
theme::spring_jump(&ctx, progress_id, 0.0);
progress = 0.0;
}
let was_wave = ctx.data(|d| d.get_temp::<bool>(id.with("wave-on"))).unwrap_or(false);
let engaged = pointer || f.ui.omnibox_focused || f.ui.omnibox_edit.is_some();
let wave_on = !engaged && (loading || (was_wave && progress < 0.995));
ctx.data_mut(|d| d.insert_temp(id.with("wave-on"), wave_on));
let morph = theme::spring(&ctx, id.with("wave"), if wave_on { 1.0 } else { 0.0 }, theme::DEFAULT);
let m = morph.clamp(0.0, 1.0);
let fill = theme::layer(theme::layer(p.surface_container_highest, p.on_surface, theme::HOVER * hover * (1.0 - focus)), p.surface_container_lowest, focus);
let radius = theme::corner_radius(theme::CONTROL / 2.0);
ui.painter().rect_filled(rect, radius, fill);
// The pill squeezes down to the progress track (spring, may overshoot a little in height).
let squeeze = morph.clamp(0.0, 1.1);
let pill = rect.shrink2(vec2(theme::GAP_S * m, ((theme::CONTROL - WAVE_TRACK) / 2.0 * squeeze).min(theme::CONTROL / 2.0 - 1.0)));
let radius = theme::corner_radius(pill.height() / 2.0);
ui.painter().rect_filled(pill, radius, theme::layer(fill, p.secondary_container, m));
if focus > 0.0 {
ui.painter().rect_stroke(rect, radius, Stroke::new(2.0, p.primary.gamma_multiply(focus)), StrokeKind::Inside);
ui.painter().rect_stroke(pill, radius, Stroke::new(2.0, p.primary.gamma_multiply(focus)), StrokeKind::Inside);
}
if m > 0.0 {
let mut painter = ui.painter().clone();
painter.set_opacity(m);
let phase = if wave_on { ctx.input(|i| i.time) as f32 * 5.0 } else { 0.0 };
crate::ui::paint::wavy_progress(&painter, pill, progress, 3.0 * m, phase, &p);
ctx.request_repaint();
}
let mut inner = ui.new_child(UiBuilder::new().max_rect(rect.shrink2(vec2(theme::GAP_XS, 0.0))).layout(Layout::left_to_right(Align::Center)));
inner.spacing_mut().item_spacing.x = 0.0;
inner.set_opacity(1.0 - m);
let ui = &mut inner;
// Site button: a chip that says what kind of connection this is.
let (glyph, label, color, tip) = match security {
@ -761,6 +790,20 @@ fn chip(ui: &mut Ui, glyph: &str, label: &str, color: Color32, tooltip: &str, on
response.on_hover_text(tooltip)
}
/// Height of the progress track the address pill squeezes into while a page loads.
const WAVE_TRACK: f32 = 4.0;
/// How far a load has got, 0..1. Servo reports only stages, so this eases towards a cap per stage: up to 0.6
/// until the head is parsed, then up to 0.92 until it completes.
fn load_estimate(status: Option<servo::LoadStatus>, seconds: f32) -> f32 {
let ease = |cap: f32, tau: f32| cap * (1.0 - (-seconds / tau).exp());
match status {
Some(servo::LoadStatus::Started) => 0.05 + ease(0.55, 1.5),
Some(servo::LoadStatus::HeadParsed) => 0.6 + ease(0.32, 2.0),
_ => 1.0,
}
}
/// The address with the host in full colour and the rest dimmed, while not editing.
fn address_job(text: &str, emphasize: bool, p: &Palette, font: egui::FontId) -> egui::text::LayoutJob {
let mut job = egui::text::LayoutJob::default();
@ -1096,6 +1139,17 @@ mod tests {
assert_eq!(to, 0);
}
#[test]
fn load_estimate_grows_by_stage_and_never_reaches_the_end_early() {
use servo::LoadStatus::{Complete, HeadParsed, Started};
assert!(load_estimate(Some(Started), 0.0) > 0.0);
assert!(load_estimate(Some(Started), 1.0) < load_estimate(Some(Started), 3.0));
assert!(load_estimate(Some(Started), 100.0) <= 0.6 + 1e-4);
assert!(load_estimate(Some(HeadParsed), 0.0) >= load_estimate(Some(Started), 100.0) - 1e-4);
assert!(load_estimate(Some(HeadParsed), 100.0) < 0.95);
assert_eq!(load_estimate(Some(Complete), 0.0), 1.0);
}
#[test]
fn address_shows_the_host_in_full_colour() {
let p = Palette::new(Color32::from_rgb(0x67, 0x50, 0xA4), true, "tonal_spot", 0.0);

View file

@ -68,7 +68,28 @@ wait 1
shot media-playing-dark
flyout none
cmd select 3
blur
# R1-09: while a page loads the address pill turns into a wavy progress bar; hovering brings the field back.
fakeload 1.2
wait 0.6
shot loading-dark
hover 300 70
wait 0.05
shot loading-morph-dark
wait 0.8
shot loading-hover-dark
hover none
wait 0.8
shot loading-again-dark
fakeload done
wait 1
shot loaded-dark
set /theme/mode "light"
fakeload 3
wait 0.6
shot loading-light
fakeload done
wait 1
wait 1
shot chrome-light
flyout main