S064: history flyout, page flyouts close with their page, About lists every nacre:// page
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
parent
583a92b854
commit
8386b32064
12 changed files with 188 additions and 21 deletions
|
|
@ -14,12 +14,12 @@ From the user and S035 (superseded):
|
|||
- `src/ui/pages/history.rs`, `src/ui/pages/misc.rs` `about`, `src/ui/pages/mod.rs` `Page` + `from_url`/`url`
|
||||
|
||||
## Steps
|
||||
- [ ] One `Page::ALL_PUBLIC` (or similar) list; About and suggestions use it; About section "Nacre pages".
|
||||
- [ ] History flyout as above, reusing history rows.
|
||||
- [ ] Page-tied flyouts close on tab switch/navigation.
|
||||
- [ ] Unit test: every listed page round-trips `from_url(url())`.
|
||||
- [ ] `tests/smoke/flyouts.txt` (offline): history flyout with a few visits, empty state, about page; dark and light shots. Run it only (D-048).
|
||||
- [ ] PROGRESS entry, INDEX line, tracker, commit `S064: …`, push.
|
||||
- [x] One `Page::ALL_PUBLIC` (or similar) list; About and suggestions use it; About section "Nacre pages".
|
||||
- [x] History flyout as above, reusing history rows.
|
||||
- [x] Page-tied flyouts close on tab switch/navigation.
|
||||
- [x] Unit test: every listed page round-trips `from_url(url())`.
|
||||
- [x] `tests/smoke/flyouts.txt` (offline): history flyout with a few visits, empty state, about page; dark and light shots. Run it only (D-048).
|
||||
- [x] PROGRESS entry, INDEX line, tracker, commit `S064: …`, push.
|
||||
|
||||
## End criteria
|
||||
- `cargo test` green; `flyouts.txt` exit 0; shots show the flyout and the About list.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Dropped with Servo (D-032): S011, S029, S030, S032, S033, S037, S038.
|
|||
- [x] [S061 — A site's own context menu wins; video clicks don't open ads](09%20Fix%20round/S061-site-menus-clickthrough.md) · Opus medium · 🧑
|
||||
- [x] [S062 — Memory saver that actually unloads, sliders, resting tab icons](09%20Fix%20round/S062-memory-saver.md) · Sonnet high
|
||||
- [x] [S063 — Lock down nacre:// pages; passwords unlock on every open](09%20Fix%20round/S063-nacre-pages-lockdown.md) · Opus medium
|
||||
- [ ] [S064 — History flyout, bookmark flyout on tab switch, About lists nacre:// pages](09%20Fix%20round/S064-history-flyout-about.md) · Sonnet high
|
||||
- [x] [S064 — History flyout, bookmark flyout on tab switch, About lists nacre:// pages](09%20Fix%20round/S064-history-flyout-about.md) · Sonnet high
|
||||
- [ ] [S065 — Custom download manager by name and port](09%20Fix%20round/S065-custom-manager-port.md) · Sonnet high
|
||||
- [ ] [S066 — UI alignment pass (/unslop)](09%20Fix%20round/S066-ui-alignment.md) · Opus medium · 🧑
|
||||
|
||||
|
|
|
|||
|
|
@ -507,6 +507,14 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
|
|||
- Not done: typing the master password into the gate isn't scripted (selftest has no egui text input), only the click path and the gate staying shut; window minimised (no frames) keeps the page open until it is drawn without it; no visible run.
|
||||
- Decision for device mode (no master password, nothing to ask): a click gate, so no page can open it unseen; the orchestrator/user may want "set a master password" pushed harder.
|
||||
|
||||
## S064 — History flyout, page-tied flyouts, About lists nacre:// pages (2026-11-18)
|
||||
- Page list: `Page::PUBLIC` (src/tabs.rs: name + constructor, no gallery/source/error/allowcert); the About page's new "Nacre pages" card and the address-bar page suggestions (chrome.rs) both iterate it. Test: every entry round-trips `from_url(url())` and is `nacre://<name>`.
|
||||
- History button opens `Flyout::History` (menus.rs `history`): search, day groups, rows with the page's own text and click rules (`pages::history::visit_text`/`open_visit`, shared with `nacre://history`: click opens, Ctrl/middle click background tab), empty/no-match/incognito states, "open full page" button; Ctrl+H still opens the page. Gotcha: a ScrollArea in a flyout drew one row only until given `min_scrolled_height`.
|
||||
- The bookmark and QR flyouts close when the tab shows another address (navigation, any tab switch path) — checked in `flyouts()`.
|
||||
- Selftest status gained `flyout` (bool); `recursion_limit = 256` in main.rs for the status JSON.
|
||||
- Verified: hidden `flyouts.txt` (needs `python3 -m http.server 8765 --directory tests/smoke/pages`) exit 0, shots read; `cargo test` 92 + webext 1.
|
||||
- Not done: favicons in flyout rows (icon only, as on the page); no visible run.
|
||||
|
||||
## Later
|
||||
- A link followed inside a frame still goes through the tab's navigation policy (WebKit's GTK API has no frame info; S050).
|
||||
- file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043).
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#![recursion_limit = "256"]
|
||||
//! Nacre: a web browser on WebKitGTK, with its interface drawn by egui.
|
||||
|
||||
mod actions;
|
||||
|
|
|
|||
|
|
@ -424,6 +424,7 @@ impl App {
|
|||
let flyout = match rest {
|
||||
"main" => Some(Flyout::Main),
|
||||
"downloads" => Some(Flyout::Downloads),
|
||||
"history" => Some(Flyout::History),
|
||||
"shield" => Some(Flyout::Shield),
|
||||
"media" => Some(Flyout::Media),
|
||||
"siteinfo" => Some(Flyout::SiteInfo),
|
||||
|
|
@ -936,6 +937,7 @@ impl App {
|
|||
"lifecycle": lifecycle,
|
||||
"window_kinds": self.windows.values().map(|w| format!("{:?}", w.kind)).collect::<Vec<_>>(),
|
||||
"tabs": tabs,
|
||||
"flyout": self.windows.values().next().is_some_and(|w| w.ui.flyout.is_some()),
|
||||
"downloads": downloads,
|
||||
"vpn": format!("{:?}", self.shared.vpn_status.borrow()),
|
||||
"route": self.shared.bridge.as_ref().map(|b| format!("{:?}", b.route())),
|
||||
|
|
|
|||
28
src/tabs.rs
28
src/tabs.rs
|
|
@ -35,6 +35,24 @@ pub enum Page {
|
|||
}
|
||||
|
||||
impl Page {
|
||||
/// Every page the UI links to, with the name the address bar completes: the one list the About page and the
|
||||
/// address suggestions use. Not the gallery, source or error pages, nor `nacre://allowcert`.
|
||||
pub const PUBLIC: &'static [(&'static str, fn() -> Page)] = &[
|
||||
("newtab", || Page::NewTab),
|
||||
("settings", || Page::Settings(String::new())),
|
||||
("history", || Page::History),
|
||||
("bookmarks", || Page::Bookmarks),
|
||||
("downloads", || Page::Downloads),
|
||||
("passwords", || Page::Passwords),
|
||||
("apps", || Page::Apps),
|
||||
("site-settings", || Page::SiteSettings(String::new())),
|
||||
("clear-data", || Page::ClearData),
|
||||
("task-manager", || Page::TaskManager),
|
||||
("devtools", || Page::DevTools),
|
||||
("welcome", || Page::Welcome),
|
||||
("about", || Page::About),
|
||||
];
|
||||
|
||||
pub fn from_url(url: &str) -> Option<Page> {
|
||||
let rest = url.strip_prefix("nacre://").or_else(|| url.strip_prefix("nacre:"))?;
|
||||
let (name, arg) = rest.split_once('/').map(|(n, a)| (n, a.to_owned())).unwrap_or((rest, String::new()));
|
||||
|
|
@ -395,6 +413,16 @@ impl Tab {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn listed_pages_round_trip_and_hide_internal_ones() {
|
||||
for (name, make) in Page::PUBLIC {
|
||||
let page = make();
|
||||
assert_eq!(Page::from_url(&page.url()), Some(page.clone()), "{name}");
|
||||
assert_eq!(page.url(), format!("nacre://{name}"));
|
||||
}
|
||||
assert!(Page::PUBLIC.iter().all(|(name, _)| !matches!(*name, "gallery" | "source" | "allowcert")));
|
||||
}
|
||||
|
||||
// S063 (D-049): a page's navigations never reach Nacre's pages, except "Open anyway" of the certificate warning.
|
||||
#[test]
|
||||
fn web_content_cannot_open_internal_pages() {
|
||||
|
|
|
|||
|
|
@ -513,6 +513,12 @@ fn right_button(ui: &mut Ui, f: &mut Frame, settings: &crate::store::settings::S
|
|||
f.ui.toggle(Flyout::Downloads, Some(r.rect));
|
||||
}
|
||||
},
|
||||
"history" => {
|
||||
let r = icon_toggle(ui, glyph("history"), "History (Ctrl+H opens the full page)", open(f, &Flyout::History));
|
||||
if r.clicked() {
|
||||
f.ui.toggle(Flyout::History, Some(r.rect));
|
||||
}
|
||||
},
|
||||
"apps" => {
|
||||
let r = icon_toggle(ui, glyph("apps"), "Apps", open(f, &Flyout::Apps));
|
||||
if r.clicked() {
|
||||
|
|
@ -529,7 +535,6 @@ fn right_button(ui: &mut Ui, f: &mut Frame, settings: &crate::store::settings::S
|
|||
_ => {
|
||||
let (tip, command) = match key {
|
||||
"devtools" => ("Developer tools (F12)", Command::Action(crate::keys::Action::DevTools)),
|
||||
"history" => ("History (Ctrl+H)", Command::ShowPage(Page::History)),
|
||||
"passwords" => ("Passwords", Command::ShowPage(Page::Passwords)),
|
||||
"bookmarks" => ("Bookmarks", Command::ShowPage(Page::Bookmarks)),
|
||||
"pip" => ("Picture in picture", Command::EnterPip),
|
||||
|
|
@ -840,8 +845,9 @@ fn suggestions(f: &Frame, query: &str) -> Vec<Suggestion> {
|
|||
}
|
||||
// Nacre's own pages by name.
|
||||
let lower = query.to_lowercase();
|
||||
for (name, page) in [("settings", Page::Settings(String::new())), ("history", Page::History), ("bookmarks", Page::Bookmarks), ("downloads", Page::Downloads), ("passwords", Page::Passwords), ("apps", Page::Apps)] {
|
||||
for (name, make) in Page::PUBLIC {
|
||||
if lower.len() >= 3 && name.starts_with(&lower) {
|
||||
let page = make();
|
||||
out.push(Suggestion { kind: SuggestionKind::Page, title: page.title(), url: page.url() });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -500,6 +500,7 @@ fn flyout_id(flyout: &Flyout) -> Id {
|
|||
let key = match flyout {
|
||||
Flyout::Main => "main",
|
||||
Flyout::Downloads => "downloads",
|
||||
Flyout::History => "history",
|
||||
Flyout::Shield => "shield",
|
||||
Flyout::Media => "media",
|
||||
Flyout::SiteInfo => "siteinfo",
|
||||
|
|
@ -516,6 +517,12 @@ fn flyout_id(flyout: &Flyout) -> Id {
|
|||
|
||||
/// Show whichever flyout is open, and the one that just closed while it fades.
|
||||
pub fn flyouts(ctx: &egui::Context, f: &mut Frame) {
|
||||
// A flyout about one page goes when the tab shows another page (tab switch, navigation).
|
||||
if let Some(Flyout::EditBookmark(url) | Flyout::Qr(url)) = &f.ui.flyout
|
||||
&& f.tab().is_none_or(|t| t.shown_url() != *url && t.url != *url)
|
||||
{
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
let anchor = f.ui.flyout_anchor;
|
||||
let current = f.ui.flyout.clone().map(|flyout| {
|
||||
let (pos, pivot) = placement(ctx, &flyout, anchor);
|
||||
|
|
@ -559,6 +566,7 @@ fn flyout_body(ui: &mut Ui, f: &mut Frame, flyout: &Flyout) {
|
|||
match flyout {
|
||||
Flyout::Main => main_menu(ui, f),
|
||||
Flyout::Downloads => downloads(ui, f),
|
||||
Flyout::History => history(ui, f),
|
||||
Flyout::Shield => shield(ui, f),
|
||||
Flyout::Media => media(ui, f),
|
||||
Flyout::SiteInfo => site_info(ui, f),
|
||||
|
|
@ -665,6 +673,47 @@ fn main_menu(ui: &mut Ui, f: &mut Frame) {
|
|||
}
|
||||
}
|
||||
|
||||
fn history(ui: &mut Ui, f: &mut Frame) {
|
||||
ui.set_width(380.0);
|
||||
header(ui, "History", |ui| {
|
||||
if icon_button(ui, icons::OPEN_IN_NEW, "Open the full page (Ctrl+H)").clicked() {
|
||||
f.send(Command::ShowPage(Page::History));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
});
|
||||
egui::Frame::NONE.inner_margin(egui::Margin::symmetric(INSET as i8, 0)).show(ui, |ui| super::widgets::search_pill(ui, "history-flyout", &mut f.ui.pages.history_search, "Search history"));
|
||||
let query = f.ui.pages.history_search.clone();
|
||||
let visits: Vec<crate::store::history::Visit> = f.shared.history.borrow().search(&query, 60).into_iter().cloned().collect();
|
||||
if visits.is_empty() {
|
||||
if f.incognito() {
|
||||
empty_state(ui, icons::HISTORY, "No history here", "Incognito windows don't keep history");
|
||||
} else if query.trim().is_empty() {
|
||||
empty_state(ui, icons::HISTORY, "No history yet", "Pages you visit show up here, newest first");
|
||||
} else {
|
||||
empty_state(ui, icons::SEARCH, "Nothing matches", "Try a different word or part of an address");
|
||||
}
|
||||
return;
|
||||
}
|
||||
let max_height = (ui.ctx().content_rect().bottom() - ui.max_rect().top() - 3.0 * theme::GAP_L).clamp(160.0, 480.0);
|
||||
let days = visits.iter().map(|v| util::local_day(v.time)).collect::<std::collections::BTreeSet<_>>().len();
|
||||
let wanted = visits.len() as f32 * (ENTRY + 2.0) + days as f32 * (theme::CONTROL_SMALL + theme::GAP_XS + 2.0);
|
||||
egui::ScrollArea::vertical().max_height(max_height).min_scrolled_height(wanted.min(max_height)).show(ui, |ui| {
|
||||
let mut day = None;
|
||||
for visit in &visits {
|
||||
let this_day = util::local_day(visit.time);
|
||||
if day != Some(this_day) {
|
||||
day = Some(this_day);
|
||||
group(ui, &util::format_day_heading(visit.time), |_| ());
|
||||
}
|
||||
let (title, detail) = super::pages::history::visit_text(visit);
|
||||
let row = entry(ui, icons::LANGUAGE, &title, &detail, "");
|
||||
if super::pages::history::open_visit(ui, f, visit, row) {
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn downloads(ui: &mut Ui, f: &mut Frame) {
|
||||
ui.set_width(380.0);
|
||||
header(ui, "Downloads", |ui| {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use crate::window::{Kind, WindowId};
|
|||
pub enum Flyout {
|
||||
Main,
|
||||
Downloads,
|
||||
History,
|
||||
Shield,
|
||||
Media,
|
||||
SiteInfo,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! nacre://history — visits grouped by day, with search and deleting.
|
||||
|
||||
use egui::Ui;
|
||||
use egui::{Response, Ui};
|
||||
|
||||
use super::super::menus::menu_item;
|
||||
use super::super::widgets::{ButtonKind, button, card, empty_state, icon_button, list_item, more_menu, page_column, page_header, search_pill, section};
|
||||
|
|
@ -11,6 +11,30 @@ use crate::tabs::Page;
|
|||
use crate::ui::icons;
|
||||
use crate::util;
|
||||
|
||||
/// A visit's row text: the title (or address) and "time · host".
|
||||
pub fn visit_text(visit: &Visit) -> (String, String) {
|
||||
let title = if visit.title.is_empty() { visit.url.clone() } else { visit.title.clone() };
|
||||
let host = util::host_of_str(&visit.url);
|
||||
let detail = if host.is_empty() { util::format_clock(visit.time) } else { format!("{} · {host}", util::format_clock(visit.time)) };
|
||||
(title, detail)
|
||||
}
|
||||
|
||||
/// What a click on a visit's row does: open it here (Ctrl: new tab), middle click: new background tab.
|
||||
pub fn open_visit(ui: &Ui, f: &mut Frame, visit: &Visit, row: Response) -> bool {
|
||||
let row = row.on_hover_text(&visit.url);
|
||||
let mut opened = false;
|
||||
if row.clicked() {
|
||||
let new_tab = ui.input(|i| i.modifiers.command);
|
||||
f.send(Command::Open { url: visit.url.clone(), how: if new_tab { Disposition::NewBackgroundTab } else { Disposition::Current }, from: None });
|
||||
opened = true;
|
||||
}
|
||||
if row.middle_clicked() {
|
||||
f.send(Command::Open { url: visit.url.clone(), how: Disposition::NewBackgroundTab, from: None });
|
||||
opened = true;
|
||||
}
|
||||
opened
|
||||
}
|
||||
|
||||
pub fn draw(ui: &mut Ui, f: &mut Frame) {
|
||||
page_column(ui, "history", 860.0, |ui| {
|
||||
let subtitle = if f.incognito() { "Incognito windows don't keep history." } else { "" };
|
||||
|
|
@ -40,9 +64,7 @@ pub fn draw(ui: &mut Ui, f: &mut Frame) {
|
|||
section(ui, &util::format_day_heading(visits[start].time));
|
||||
card(ui, |ui| {
|
||||
for visit in &visits[start..end] {
|
||||
let title = if visit.title.is_empty() { visit.url.clone() } else { visit.title.clone() };
|
||||
let host = util::host_of_str(&visit.url);
|
||||
let detail = if host.is_empty() { util::format_clock(visit.time) } else { format!("{} · {host}", util::format_clock(visit.time)) };
|
||||
let (title, detail) = visit_text(visit);
|
||||
let r = list_item(ui, (&visit.url, visit.time), Some(icons::LANGUAGE), &title, &detail, |ui| {
|
||||
more_menu(ui, |ui| {
|
||||
if menu_item(ui, Some(icons::OPEN_IN_NEW), "Open in new tab", "", false).clicked() {
|
||||
|
|
@ -62,14 +84,7 @@ pub fn draw(ui: &mut Ui, f: &mut Frame) {
|
|||
remove = Some((visit.url.clone(), visit.time));
|
||||
}
|
||||
});
|
||||
let r = r.on_hover_text(&visit.url);
|
||||
if r.clicked() {
|
||||
let new_tab = ui.input(|i| i.modifiers.command);
|
||||
f.send(Command::Open { url: visit.url.clone(), how: if new_tab { Disposition::NewBackgroundTab } else { Disposition::Current }, from: None });
|
||||
}
|
||||
if r.middle_clicked() {
|
||||
f.send(Command::Open { url: visit.url.clone(), how: Disposition::NewBackgroundTab, from: None });
|
||||
}
|
||||
open_visit(ui, f, visit, r);
|
||||
}
|
||||
});
|
||||
start = end;
|
||||
|
|
|
|||
|
|
@ -229,6 +229,16 @@ pub fn about(ui: &mut Ui, f: &mut Frame) {
|
|||
icon_row(ui, icons::INFO, "Licence", "Mozilla Public License 2.0 (Nacre; WebKitGTK is LGPL 2.1+ and BSD)", |_| ());
|
||||
icon_row(ui, icons::WARNING, "What the engine can't do", "No DRM video (Widevine), no Chrome extensions (use scripts and styles instead), no printing (save as PDF instead).", |_| ());
|
||||
});
|
||||
section(ui, "Nacre pages");
|
||||
card(ui, |ui| {
|
||||
for (_, make) in Page::PUBLIC {
|
||||
let page = make();
|
||||
let url = page.url();
|
||||
if icon_row(ui, icons::LINK, &page.title(), &url, |ui| button(ui, ButtonKind::Tonal, None, "Open").clicked()) {
|
||||
f.send(Command::ShowPage(page));
|
||||
}
|
||||
}
|
||||
});
|
||||
let _ = icon_link_row;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
47
tests/smoke/flyouts.txt
Normal file
47
tests/smoke/flyouts.txt
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Needs: python3 -m http.server 8765 --bind 127.0.0.1 --directory tests/smoke/pages &
|
||||
# History flyout, page-tied flyouts and the About page list (S064). Offline. Run with tools/smoke.sh; read the PNGs.
|
||||
wait 3
|
||||
set /theme/mode "dark"
|
||||
flyout history
|
||||
wait 1
|
||||
shot history-empty-dark
|
||||
open http://127.0.0.1:8765/hello.html
|
||||
waitload 30
|
||||
open http://127.0.0.1:8765/color.html
|
||||
waitload 30
|
||||
newtab http://127.0.0.1:8765/links.html
|
||||
waitload 30
|
||||
open http://127.0.0.1:8765/basics.html
|
||||
waitload 30
|
||||
flyout history
|
||||
wait 1
|
||||
shot history-dark
|
||||
set /theme/mode "light"
|
||||
wait 1
|
||||
shot history-light
|
||||
# The bookmark flyout belongs to its page: navigating or switching tabs closes it.
|
||||
do bookmark
|
||||
wait 1
|
||||
status flyout-open
|
||||
expect /flyout true
|
||||
shot bookmark-flyout
|
||||
open http://127.0.0.1:8765/hello.html
|
||||
waitload 30
|
||||
wait 1
|
||||
status after-navigation
|
||||
expect /flyout false
|
||||
do bookmark
|
||||
wait 1
|
||||
expect /flyout true
|
||||
cmd select 0
|
||||
wait 1
|
||||
status after-switch
|
||||
expect /flyout false
|
||||
page nacre://about
|
||||
wait 1
|
||||
shot about-light
|
||||
set /theme/mode "dark"
|
||||
wait 1
|
||||
shot about-dark
|
||||
status done
|
||||
quit
|
||||
Loading…
Reference in a new issue