test build: AI branch working-tree changes (features, notes, i18n)

This commit is contained in:
Jeremy committed 2026-10-16 12:43:58 +01:00
1 parent 167db06104
commit dfb44de0e2
13 files changed
+375 -112

No files matched your search

@@ -63,6 +63,7 @@ fn feature(data: &[u8], url: &str, licence: bool) -> Feature {
}],
packs: vec![],
min_vram_mb: None,
native: None,
}),
cloud: vec![],
}
+96
View File
@@ -0,0 +1,96 @@
//! The Advanced page: add a server, and choose which connected model each tool uses.
//!
//! Like the History page it is a scrolling body with a footer pinned under it, so Back is always
//! in reach. Each tool that has a connected model is a card holding its picker and its test.
use egui::{RichText, Ui};
use super::home::{Act, server_rows};
use super::{FeaturesPort, FeaturesUi, Outcome, Snapshot};
use crate::connections::Row;
use crate::theme::Tokens;
use crate::widgets::{self, Kind};
impl FeaturesUi {
/// The scrolling part: servers, then one card per tool that has a model to choose between.
pub(super) fn advanced_body(&mut self, ui: &mut Ui, snapshot: &Snapshot, port: &mut dyn FeaturesPort, rows: &[Row]) -> (Outcome, Act) {
let t = Tokens::get(ui.ctx());
crate::connections::title(ui, tl!("Advanced"), tl!("Servers, and which model each tool uses"));
ui.add(
egui::Label::new(
RichText::new(tl!("Tools pick the best model that is connected on their own. Change one here, or test that it works."))
.color(t.muted),
)
.wrap(),
);
ui.add_space(18.0);
let mut outcome = Outcome::None;
let mut act = Act::None;
widgets::hud(ui, tl!("Other servers"), t.faint);
ui.add_space(6.0);
// Servers already connected come first, so a connection that worked is visible here.
let connected = self.unmatched(rows);
if let Some(next) = server_rows(ui, &connected) {
act = next;
}
egui::Frame::new().stroke(t.hairline()).inner_margin(14).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if widgets::button(ui, tl!("Add another server"), Kind::Secondary, 0.0).clicked() {
outcome = Outcome::AddServer;
}
ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| {
ui.add(
egui::Label::new(
RichText::new(tl!("Ollama, LM Studio, ComfyUI or any OpenAI-compatible server")).size(12.0).color(t.muted),
)
.wrap(),
);
});
});
});
});
ui.add_space(20.0);
widgets::hud(ui, tl!("Models"), t.faint);
ui.add_space(6.0);
let mut shown = 0;
for feature in self.features.clone() {
if !snapshot.tools.iter().any(|s| s.feature == feature.id && !s.choices.is_empty()) {
continue;
}
shown += 1;
egui::Frame::new().stroke(t.hairline()).inner_margin(14).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.label(widgets::heading(crate::i18n::t(&feature.title), 16.0, t.ink_strong));
ui.add_space(6.0);
if let Some(next) = self.tool_block(ui, &feature, snapshot, port) {
outcome = next;
}
});
ui.add_space(8.0);
}
if shown == 0 {
egui::Frame::new().stroke(t.hairline()).inner_margin(14).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.label(RichText::new(tl!("No tool has a connected model yet.")).color(t.muted));
});
}
ui.add_space(4.0);
(outcome, act)
}
/// The footer pinned under the body: what the last action said, and Back.
pub(super) fn advanced_footer(&mut self, ui: &mut Ui) {
let t = Tokens::get(ui.ctx());
if let Some((text, error)) = &self.notice {
ui.add(egui::Label::new(RichText::new(text).color(if *error { t.bad } else { t.muted })).wrap());
ui.add_space(8.0);
}
if widgets::button(ui, tl!("Back"), Kind::Secondary, 90.0).clicked() {
self.back();
}
}
}
+14 -6
View File
@@ -133,13 +133,10 @@ impl FeaturesUi {
self.history.reload(port);
}
pub(crate) fn history_page(&mut self, ui: &mut Ui, port: &mut dyn FeaturesPort) {
/// The scrolling part of the page: title, filters, overview and the tables.
pub(crate) fn history_body(&mut self, ui: &mut Ui) {
let t = Tokens::get(ui.ctx());
crate::connections::title(ui, tl!("History"), tl!("AI jobs run by your Craft apps"));
let mut back = false;
let mut refresh = false;
let mut export = false;
let mut clear = false;
let h = &mut self.history;
if let Some(message) = &h.error {
@@ -203,12 +200,23 @@ impl FeaturesUi {
);
}
}
}
/// The footer: what the last export or clear said, and the buttons. It stays put under the
/// scrolling body so Back, Export and Clear are always in reach.
pub(crate) fn history_footer(&mut self, ui: &mut Ui, port: &mut dyn FeaturesPort) {
let t = Tokens::get(ui.ctx());
let mut back = false;
let mut refresh = false;
let mut export = false;
let mut clear = false;
let h = &mut self.history;
if let Some((text, error)) = &h.notice {
ui.add_space(6.0);
ui.add(egui::Label::new(RichText::new(text).color(if *error { t.bad } else { t.muted })).wrap());
}
ui.add_space(22.0);
ui.add_space(8.0);
ui.horizontal(|ui| {
back = widgets::button(ui, tl!("Back"), Kind::Secondary, 90.0).clicked();
refresh = widgets::button(ui, tl!("Refresh"), Kind::Secondary, 0.0).clicked();
+86 -92
View File
@@ -12,15 +12,18 @@ use craft_ai_model::{ConnectionId, PRESETS, Preset};
use egui::{RichText, Ui, vec2};
use super::text::{blocker_text, bytes};
use super::{FeaturesPort, FeaturesUi, Install, Outcome, Page, Sample, Snapshot, ToolStatus};
use super::{FeaturesUi, Install, Outcome, Page, Sample, Snapshot, ToolStatus};
use crate::app::Host;
use crate::connections::{ConnectionsUi, KeyView, Row, Screen as ConnScreen};
use crate::i18n::fmt;
use crate::theme::Tokens;
use crate::widgets::{self, Kind};
/// Room kept under a pinned page's scrolling body for its footer (rule, notice, buttons).
const PINNED_FOOTER_H: f32 = 110.0;
/// What a press on the home page asks for.
enum Act {
pub(super) enum Act {
None,
Local(String),
Connect(&'static Preset),
@@ -61,9 +64,10 @@ impl FeaturesUi {
let t = Tokens::get(ui.ctx());
let screen = ui.ctx().content_rect();
// The history is a table and a chart: it gets a wider, taller window than the setup cards.
let history = self.page == Page::History;
let width = (if history { 920.0f32 } else { 760.0 }).min(screen.width() - 80.0);
let height = if history { (screen.height() * 0.84).clamp(360.0, 880.0) } else { (screen.height() * 0.74).clamp(320.0, 640.0) };
let on_history = self.page == Page::History;
let on_advanced = self.page == Page::Advanced;
let width = (if on_history { 920.0f32 } else { 760.0 }).min(screen.width() - 80.0);
let height = if on_history { (screen.height() * 0.84).clamp(360.0, 880.0) } else { (screen.height() * 0.74).clamp(320.0, 640.0) };
ui.set_width(width);
let mut close = false;
@@ -95,12 +99,30 @@ impl FeaturesUi {
self.open_history(port);
}
ui.allocate_ui_with_layout(vec2(width, height), egui::Layout::top_down(egui::Align::Min), |ui| {
egui::ScrollArea::vertical().id_salt("setup-ai").auto_shrink([false, false]).show(ui, |ui| {
if on_history || on_advanced {
// These pages size to what they show, up to the height limit, so a short list does
// not leave an empty gap under its buttons. The footer sits outside the scroll area,
// so it stays in view however long the page.
egui::ScrollArea::vertical().id_salt("setup-ai").max_height(height - PINNED_FOOTER_H).auto_shrink([false, true]).show(ui, |ui| {
ui.set_width(width - 16.0);
self.page_contents(ui, host, conns, &snapshot);
});
});
ui.add_space(14.0);
super::tool::hline(ui);
ui.add_space(12.0);
if on_history && let Some(port) = host.features() {
self.history_footer(ui, port);
} else if on_advanced {
self.advanced_footer(ui);
}
} else {
ui.allocate_ui_with_layout(vec2(width, height), egui::Layout::top_down(egui::Align::Min), |ui| {
egui::ScrollArea::vertical().id_salt("setup-ai").auto_shrink([false, false]).show(ui, |ui| {
ui.set_width(width - 16.0);
self.page_contents(ui, host, conns, &snapshot);
});
});
}
close
}
@@ -125,13 +147,12 @@ impl FeaturesUi {
conns.show(ui, port);
}
}
Page::History => {
let Some(port) = host.features() else { return };
self.history_page(ui, port);
}
Page::History => self.history_body(ui),
Page::Advanced => {
let Some(port) = host.features() else { return };
match self.advanced(ui, snapshot, port) {
let (outcome, act) = self.advanced_body(ui, snapshot, port, &conns.rows);
self.apply(act, conns);
match outcome {
Outcome::AddConnection(preset) => self.begin_connect(conns, Some(preset)),
Outcome::AddServer => self.begin_connect(conns, None),
Outcome::None | Outcome::Close => {}
@@ -178,6 +199,16 @@ impl FeaturesUi {
ui.add_space(14.0);
self.switched_on(ui, snapshot);
ui.add_space(18.0);
let unmatched = self.unmatched(&conns.rows);
if !unmatched.is_empty() {
// Right under "Switched on": a server you just connected is the first thing to look for.
widgets::hud(ui, tl!("Your other connections"), t.faint);
ui.add_space(6.0);
if let Some(next) = server_rows(ui, &unmatched) {
act = next;
}
ui.add_space(8.0);
}
for (heading, local) in [(tl!("On this computer"), true), (tl!("Hosted services"), false)] {
let options: Vec<&SetupOption> = self.options.iter().filter(|o| matches!(o.route, Route::Local { .. }) == local).collect();
@@ -197,24 +228,14 @@ impl FeaturesUi {
ui.add_space(8.0);
}
let unmatched: Vec<&Row> = conns.rows.iter().filter(|r| !self.is_listed(r)).collect();
if !unmatched.is_empty() {
widgets::hud(ui, tl!("Your other connections"), t.faint);
ui.add_space(6.0);
for row in unmatched {
ui.push_id(row.id.as_str(), |ui| {
if let Some(next) = other_row(ui, row) {
act = next;
}
});
ui.add_space(6.0);
}
ui.add_space(8.0);
}
act
}
/// The saved connections that are not one of the hosted services the list has a card for.
pub(super) fn unmatched<'a>(&self, rows: &'a [Row]) -> Vec<&'a Row> {
rows.iter().filter(|r| !self.is_listed(r)).collect()
}
/// Whether a saved connection is one of the hosted services the list already shows a card for.
fn is_listed(&self, row: &Row) -> bool {
self.options.iter().any(|o| match &o.route {
@@ -367,19 +388,48 @@ fn service_status(ui: &mut Ui, preset_key: &str, conns: &ConnectionsUi) -> Optio
act
}
/// A saved connection that is not one of the listed services (a local server, a custom address).
/// Each saved server as a row, with what to do about it. Returns what was pressed, if anything.
pub(super) fn server_rows(ui: &mut Ui, rows: &[&Row]) -> Option<Act> {
let mut act = None;
for row in rows {
ui.push_id(row.id.as_str(), |ui| {
if let Some(next) = other_row(ui, row) {
act = Some(next);
}
});
ui.add_space(6.0);
}
act
}
/// A saved connection that is not one of the listed services (a local server, a custom address):
/// its name, whether it works, where its data goes, and how many models it offers.
fn other_row(ui: &mut Ui, row: &Row) -> Option<Act> {
let t = Tokens::get(ui.ctx());
let mut act = None;
egui::Frame::new().stroke(t.hairline()).inner_margin(10).show(ui, |ui| {
egui::Frame::new().stroke(t.hairline()).inner_margin(12).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
ui.label(RichText::new(&row.label).color(if row.enabled { t.ink_strong } else { t.faint }));
if row.local {
widgets::badge(ui, tl!("This computer"), t.good);
} else {
widgets::badge(ui, tl!("Leaves this computer"), t.warn);
}
ui.vertical(|ui| {
ui.spacing_mut().item_spacing.y = 3.0;
ui.horizontal(|ui| {
ui.label(widgets::heading(&row.label, 15.0, if row.enabled { t.ink_strong } else { t.faint }));
if working(row) {
widgets::badge(ui, tl!("Connected"), t.good);
} else if !row.enabled {
widgets::badge(ui, tl!("Turned off"), t.faint);
} else {
widgets::badge(ui, tl!("Key missing"), t.bad);
}
});
let place = if row.local { tl!("Runs on this computer") } else { tl!("Leaves this computer") };
let models = if row.models == 0 {
tl!("No models found yet").to_owned()
} else {
crate::i18n::tn(row.models as u64, "{n} model", "{n} models")
};
ui.label(RichText::new(format!("{place} · {models}")).size(12.0).color(if row.local { t.muted } else { t.warn }));
});
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if widgets::button(ui, tl!("Remove"), Kind::Secondary, 0.0).clicked() {
act = Some(Act::Remove(row.id.clone()));
@@ -397,59 +447,3 @@ fn other_row(ui: &mut Ui, row: &Row) -> Option<Act> {
fn ready(snapshot: &Snapshot, feature: &str) -> bool {
snapshot.tools.iter().any(|t| t.feature == feature && matches!(t.status, ToolStatus::Ready { .. }))
}
impl FeaturesUi {
/// Which model each tool uses, and the test that proves it. Only tools with a connected model.
fn advanced(&mut self, ui: &mut Ui, snapshot: &Snapshot, port: &mut dyn FeaturesPort) -> Outcome {
let t = Tokens::get(ui.ctx());
crate::connections::title(ui, tl!("Advanced"), tl!("Servers, and which model each tool uses"));
ui.add(
egui::Label::new(
RichText::new(tl!("Tools pick the best model that is connected on their own. Change one here, or test that it works."))
.color(t.muted),
)
.wrap(),
);
ui.add_space(14.0);
let mut outcome = Outcome::None;
widgets::hud(ui, tl!("Other servers"), t.faint);
ui.add_space(4.0);
ui.add(egui::Label::new(RichText::new(tl!("Ollama, LM Studio, ComfyUI or any OpenAI-compatible server")).size(12.0).color(t.muted)).wrap());
ui.add_space(6.0);
if widgets::button(ui, tl!("Add another server"), Kind::Secondary, 0.0).clicked() {
outcome = Outcome::AddServer;
}
ui.add_space(14.0);
super::tool::hline(ui);
ui.add_space(14.0);
widgets::hud(ui, tl!("Models"), t.faint);
ui.add_space(8.0);
let mut shown = 0;
for feature in self.features.clone() {
if !snapshot.tools.iter().any(|s| s.feature == feature.id && !s.choices.is_empty()) {
continue;
}
shown += 1;
ui.label(widgets::heading(crate::i18n::t(&feature.title), 16.0, t.ink_strong));
ui.add_space(4.0);
if let Some(next) = self.tool_block(ui, &feature, snapshot, port) {
outcome = next;
}
ui.add_space(10.0);
super::tool::hline(ui);
ui.add_space(10.0);
}
if shown == 0 {
ui.label(RichText::new(tl!("No tool has a connected model yet.")).color(t.muted));
ui.add_space(8.0);
}
if let Some((text, error)) = &self.notice {
ui.add(egui::Label::new(RichText::new(text).color(if *error { t.bad } else { t.muted })).wrap());
ui.add_space(8.0);
}
if widgets::button(ui, tl!("Back"), Kind::Secondary, 90.0).clicked() {
self.back();
}
outcome
}
}
+1
View File
@@ -11,6 +11,7 @@
//! has no port and the screen never appears there).
pub mod extensions;
mod advanced;
mod history;
mod history_overview;
mod history_table;
+4
View File
@@ -565,3 +565,7 @@ filter Installed Installiert
By model Nach Modell
By app Nach App
Average Durchschnitt
Runs on this computer Läuft auf diesem Computer
No models found yet Noch keine Modelle gefunden
@plural {n} model|{n} models {n} Modell|{n} Modelle
Can't render this file because it contains an unexpected character in line 11 and column 16.
+4
View File
@@ -563,3 +563,7 @@ filter Installed Installées
By model Par modèle
By app Par app
Average Moyenne
Runs on this computer Fonctionne sur cet ordinateur
No models found yet Aucun modèle trouvé pour l’instant
@plural {n} model|{n} models {n} modèle|{n} modèles
Can't render this file because it contains an unexpected character in line 5 and column 50.
+4
View File
@@ -553,3 +553,7 @@ filter Installed Instalados
By model Por modelo
By app Por app
Average Média
Runs on this computer Executa neste computador
No models found yet Nenhum modelo encontrado ainda
@plural {n} model|{n} models {n} modelo|{n} modelos
Can't render this file because it contains an unexpected character in line 251 and column 66.
+6 -2
View File
@@ -506,8 +506,8 @@ filter Installed Установлены
Express-mode API key only. The key cannot be tested without a paid request. Только ключ API в экспресс-режиме. Ключ нельзя проверить без платного запроса.
Staff-enabled API key. Whether a subscription covers it is unverified. Ключ API, включённый сотрудниками. Покрывает ли его подписка, не проверено.
Black Forest Labs Black Forest Labs
Seedance (Volcengine Ark) Seedance (Volcengine Ark)
Text to video with your Ark key. Текст в видео с вашим ключом Ark.
Seedance (BytePlus ModelArk) Seedance (BytePlus ModelArk)
Text to video with your BytePlus ModelArk key. Текст в видео с вашим ключом BytePlus ModelArk.
Meta SAM License, community copy Лицензия Meta SAM, копия сообщества
This file is a community copy of Meta's SAM 3 weights and declares no licence of its own. Meta's release is gated behind the SAM License. Этот файл — копия весов Meta SAM 3, выложенная сообществом, и собственной лицензии не указывает. Оригинальный выпуск Meta доступен только после принятия лицензии SAM.
@@ -649,3 +649,7 @@ filter Installed Установлены
By model По моделям
By app По приложениям
Average В среднем
Runs on this computer Работает на этом компьютере
No models found yet Модели пока не найдены
@plural {n} model|{n} models {n} модель|{n} модели|{n} моделей
Can't render this file because it contains an unexpected character in line 13 and column 44.
+6 -2
View File
@@ -478,8 +478,8 @@ figcraft Interface design and prototyping 界面设计与原型制作
Express-mode API key only. The key cannot be tested without a paid request. 仅支持快速模式的 API 密钥。不发起付费请求就无法测试该密钥。
Staff-enabled API key. Whether a subscription covers it is unverified. 由工作人员开通的 API 密钥。订阅是否涵盖尚未核实。
Black Forest Labs Black Forest Labs
Seedance (Volcengine Ark) Seedance(火山引擎方舟)
Text to video with your Ark key. 使用你的 Ark 密钥进行文生视频。
Seedance (BytePlus ModelArk) Seedance(BytePlus ModelArk)
Text to video with your BytePlus ModelArk key. 使用你的 BytePlus ModelArk 密钥进行文生视频。
Meta SAM License, community copy Meta SAM 许可,社区副本
This file is a community copy of Meta's SAM 3 weights and declares no licence of its own. Meta's release is gated behind the SAM License. 该文件是社区上传的 Meta SAM 3 权重副本,自身未声明许可。Meta 的官方版本需先接受 SAM 许可才能获取。
@@ -621,3 +621,7 @@ figcraft Interface design and prototyping 界面设计与原型制作
By model 按模型
By app 按应用
Average 平均
Runs on this computer 在这台电脑上运行
No models found yet 暂未找到模型
@plural {n} model|{n} models {n} 个模型
Can't render this file because it contains an unexpected character in line 4 and column 3.
+5 -3
View File
@@ -51,16 +51,18 @@ pub(crate) fn show(ui: &mut Ui, notes: &str) {
ui.spacing_mut().item_spacing.x = 4.0;
ui.label(RichText::new("•").color(t.faint));
ui.label(RichText::new(text).color(t.ink));
if let Some(url) = link {
if let Some(url) = link.filter(|u| artcraft_launcher_core::release::safe_web_link(u)) {
let short = url.rsplit('/').next().map_or_else(|| tl!("link").to_string(), |n| format!("#{n}"));
ui.hyperlink_to(RichText::new(short).size(12.0), url);
}
});
}
Line::Text(text) => {
if let Some(url) = text.strip_prefix("**Full Changelog**: ") {
if let Some(url) = text.strip_prefix("**Full Changelog**: ").map(str::trim)
&& artcraft_launcher_core::release::safe_web_link(url)
{
ui.add_space(6.0);
ui.hyperlink_to(tl!("Full changelog"), url.trim());
ui.hyperlink_to(tl!("Full changelog"), url);
} else {
ui.label(RichText::new(text).color(t.muted));
}
+110 -4
View File
@@ -34,8 +34,21 @@ impl Backend for Quiet {
}
}
/// The built-in features, with the local model optionally marked as not runnable by any app yet.
fn catalogue(not_runnable: bool) -> Vec<Feature> {
let mut features = builtin();
if not_runnable {
for recipe in features.iter_mut().filter_map(|f| f.local.as_mut()) {
recipe.usable = false;
}
}
features
}
#[derive(Default)]
struct World {
/// Pretend no app can run the local model yet, to keep the "planned" wording covered.
not_runnable: bool,
inventory: Inventory,
install: Install,
scans: usize,
@@ -56,7 +69,7 @@ struct Features(Rc<RefCell<World>>);
impl FeaturesPort for Features {
fn features(&self) -> Vec<Feature> {
builtin()
catalogue(self.0.borrow().not_runnable)
}
fn rescan(&mut self) {
self.0.borrow_mut().scans += 1;
@@ -68,7 +81,7 @@ impl FeaturesPort for Features {
let w = self.0.borrow();
Snapshot {
scanning: false,
plans: builtin().iter().map(|f| plan(f, &w.inventory)).collect(),
plans: catalogue(w.not_runnable).iter().map(|f| plan(f, &w.inventory)).collect(),
tools: w.tools.clone(),
install: w.install.clone(),
sample: w.sample.clone(),
@@ -275,7 +288,7 @@ fn set_up_ai_lists_what_can_be_set_up_not_the_tools() {
h.get_by_label("Set up one or more of these and the AI tools switch on in every Craft app that has them.");
h.get_by_label("On this computer");
h.get_by_label("Hosted services");
for name in ["SAM 3", "OpenAI", "Black Forest Labs", "Seedance (Volcengine Ark)"] {
for name in ["SAM 3", "OpenAI", "Black Forest Labs", "Seedance (BytePlus ModelArk)"] {
h.get_by_label(name);
}
assert!(h.query_by_label("Start from").is_none() && h.query_by_label("Add a provider").is_none(), "no provider form to start with");
@@ -319,6 +332,7 @@ fn the_local_model_says_what_this_computer_still_needs() {
h.get_by_label("Set up, 3.4 GB");
let f = Features::default();
f.0.borrow_mut().not_runnable = true;
f.0.borrow_mut().inventory = with_sam3();
let h = open(&f);
h.get_by_label("Files in place");
@@ -333,7 +347,7 @@ fn the_local_model_says_what_this_computer_still_needs() {
#[test]
fn completed_download_does_not_claim_the_tool_can_run() {
let (f, mut h) = open_setup();
let (f, mut h) = open_setup_with(true);
{
let mut w = f.0.borrow_mut();
w.inventory = with_sam3();
@@ -343,9 +357,22 @@ fn completed_download_does_not_claim_the_tool_can_run() {
assert!(h.query_by_label("Installed. This tool is ready on this computer.").is_none());
}
#[test]
fn completed_download_of_a_runnable_model_says_the_tool_is_ready() {
let (f, mut h) = open_setup();
{
let mut w = f.0.borrow_mut();
w.inventory = with_sam3();
w.install = Install::Done { feature: "select-subject".into() };
}
settle(&mut h);
h.get_by_label("Installed. This tool is ready on this computer.");
}
#[test]
fn a_local_model_no_app_can_run_yet_says_so_instead_of_promising_a_tool() {
let f = Features::default();
f.0.borrow_mut().not_runnable = true;
f.0.borrow_mut().inventory = bare_comfy();
let h = open(&f);
h.get_by_label("The apps cannot run this model yet. You can download it now, and the tool switches on when they can.");
@@ -354,6 +381,7 @@ fn a_local_model_no_app_can_run_yet_says_so_instead_of_promising_a_tool() {
#[test]
fn a_model_whose_files_are_here_is_not_told_to_download_them() {
let f = Features::default();
f.0.borrow_mut().not_runnable = true;
f.0.borrow_mut().inventory = with_sam3();
let h = open(&f);
h.get_by_label("Files in place");
@@ -364,7 +392,12 @@ fn a_model_whose_files_are_here_is_not_told_to_download_them() {
// ---- local setup ----
fn open_setup() -> (Features, Harness<'static, State>) {
open_setup_with(false)
}
fn open_setup_with(not_runnable: bool) -> (Features, Harness<'static, State>) {
let f = Features::default();
f.0.borrow_mut().not_runnable = not_runnable;
f.0.borrow_mut().inventory = bare_comfy();
let mut h = open(&f);
press(&mut h, "Set up, 3.4 GB");
@@ -759,3 +792,76 @@ fn a_sample_for_one_tool_does_not_show_on_another() {
assert_eq!(h.query_all_by_label_contains("Works.").count(), 1, "only under its own tool");
h.get_by_label("A hosted video sample can cost noticeably more than an image");
}
#[test]
fn advanced_sizes_to_its_content_with_back_pinned_under_it() {
let empty = open_advanced(&Features::default());
let f = Features::default();
ready_image_tool(&f);
let full = open_advanced(&f);
let back = |h: &Harness<'static, State>| h.get_by_role_and_label(Role::Button, "Back").rect().bottom();
// The window is as tall as what it shows: a page with a tool card ends lower than an empty one.
assert!(back(&full) > back(&empty) + 60.0, "empty ends at {}, full at {}", back(&empty), back(&full));
}
#[test]
fn a_connected_server_says_so_on_the_list_and_under_advanced() {
let f = Features::default();
let c = Connections::default();
let mut ollama = saved_preset("ollama");
ollama.models = 3;
c.0.borrow_mut().rows = vec![ollama];
let h = open_with(&f, &c);
h.get_by_label("Ollama");
h.get_by_label("Connected");
h.get_by_label("Runs on this computer · 3 models");
let mut h = open_with(&f, &c);
press(&mut h, "Advanced");
h.get_by_label("Ollama");
h.get_by_label("Connected");
h.get_by_label("Runs on this computer · 3 models");
}
#[test]
fn a_connected_server_with_no_models_yet_says_that_instead_of_a_count() {
let f = Features::default();
let c = Connections::default();
c.0.borrow_mut().rows = vec![saved_preset("ollama")];
let h = open_with(&f, &c);
h.get_by_label("Runs on this computer · No models found yet");
}
#[test]
#[ignore = "writes a picture, for looking at"]
fn picture_servers() {
let f = Features::default();
let c = Connections::default();
let mut ollama = saved_preset("ollama");
ollama.models = 3;
c.0.borrow_mut().rows = vec![ollama];
let mut h = open_with(&f, &c);
settle(&mut h);
h.render().expect("render").save("C:/Users/jerem/AppData/Local/hermes/cache/scratch/srv-home.png").expect("save");
press(&mut h, "Advanced");
settle(&mut h);
h.render().expect("render").save("C:/Users/jerem/AppData/Local/hermes/cache/scratch/srv-adv.png").expect("save");
}
#[test]
fn sam3_with_its_files_in_place_is_ready_and_carries_no_warning() {
let f = Features::default();
f.0.borrow_mut().inventory = with_sam3();
let h = open(&f);
h.get_by_label("Ready");
assert!(h.query_all_by_label("Switches on").count() >= 1);
assert!(h.query_by_label("Files in place").is_none());
assert!(h.query_by_label("Planned for").is_none());
for warning in [
"The files are in place. The apps cannot run this model yet, and the tool switches on when they can.",
"The apps cannot run this model yet. You can download it now, and the tool switches on when they can.",
] {
assert!(h.query_by_label(warning).is_none(), "{warning}");
}
}
+38 -3
View File
@@ -141,9 +141,9 @@ impl Host for Shell {
type State = (Option<LauncherUi>, Shell);
fn harness(features: Features) -> Harness<'static, State> {
fn harness_sized(features: Features, height: f32) -> Harness<'static, State> {
set_test_lang(Lang::EN);
Harness::builder().with_size(egui::vec2(1180.0, 1400.0)).build_ui_state(
Harness::builder().with_size(egui::vec2(1180.0, height)).build_ui_state(
|ui, state: &mut State| {
let (ui_state, shell) = state;
let l = ui_state.get_or_insert_with(|| {
@@ -219,7 +219,11 @@ fn world(log: HistoryLog) -> Features {
}
fn open_history(f: &Features) -> Harness<'static, State> {
let mut h = harness(f.clone());
open_history_sized(f, 1400.0)
}
fn open_history_sized(f: &Features, height: f32) -> Harness<'static, State> {
let mut h = harness_sized(f.clone(), height);
settle(&mut h);
h.get_by_label("Set up AI").click();
settle(&mut h);
@@ -393,3 +397,34 @@ fn nothing_is_drawn_on_top_of_anything_else() {
let second = h.get_by_label("2025-10-09 08:54, wordcraft, Generative Fill, Failed").rect();
assert!((second.top() - first.top() - 54.0).abs() < 0.6, "rows are {} apart", second.top() - first.top());
}
#[test]
fn a_short_history_does_not_leave_a_gap_under_its_buttons() {
let mut records = job("a", T0, "photocraft", "flux", Some(Outcome::Done), None);
records.extend(job("b", T0 + 60_000, "photocraft", "flux", Some(Outcome::Done), None));
let short = open_history(&world(merge(records, 0)));
let mut many = Vec::new();
for i in 0..30u64 {
many.extend(job(&format!("r{i}"), T0 + i * 60_000, "photocraft", "flux", Some(Outcome::Done), None));
}
let long = open_history(&world(merge(many, 0)));
// Two jobs and thirty jobs show the same six rows at most, so the footer of the short page
// sits no lower than the long page's: the window is as tall as its content, not a fixed size.
let footer = |h: &Harness<'static, State>| h.get_by_role_and_label(Role::Button, "Back").rect().bottom();
assert!(footer(&short) < footer(&long) - 100.0, "short footer at {}, long at {}", footer(&short), footer(&long));
}
#[test]
fn the_footer_buttons_stay_in_view_however_long_the_list() {
let mut many = Vec::new();
for i in 0..300u64 {
many.extend(job(&format!("r{i}"), T0 + i * 60_000, "photocraft", "flux", Some(Outcome::Done), None));
}
// A short window, so the body is taller than the room it gets and has to scroll.
let screen_bottom = 640.0;
let h = open_history_sized(&world(merge(many, 0)), screen_bottom);
for label in ["Back", "Refresh", "Export CSV", "Clear history"] {
let r = h.get_by_role_and_label(Role::Button, label).rect();
assert!(r.bottom() < screen_bottom, "{label} is off the bottom at {}", r.bottom());
}
}