From 5d094e34adf3b6c2f7a0322d9ba5094d1e51ccca Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:02:08 +0700 Subject: [PATCH 01/10] ui-widgets: declare the Arabic test font read from ui-contract --- crates/ui-widgets/Cargo.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ui-widgets/Cargo.toml b/crates/ui-widgets/Cargo.toml index 63d0e4bdf9..3b84b7f388 100644 --- a/crates/ui-widgets/Cargo.toml +++ b/crates/ui-widgets/Cargo.toml @@ -14,6 +14,13 @@ test = false [lints] workspace = true +# Files of other crates that this crate's build or tests read. CI selects this crate's tests +# when one of them changes (craft-common-actions' select-platforms). +[package.metadata.craft] +reads = [ + "crates/ui-contract/tests/fonts/NotoSansArabic-test.ttf", +] + [features] suite = ["testing", "craft-ui-contract/suite"] default = [] From c41413e8b5f17ca186a87b1047b4ec488006e769 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:08:04 +0700 Subject: [PATCH 02/10] platform: name the page save callback type; web-host: implement Files::pending_pick --- crates/platform/src/browser_files.rs | 7 +++++-- crates/web-host/src/files.rs | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/platform/src/browser_files.rs b/crates/platform/src/browser_files.rs index a00309b253..3d18b37caa 100644 --- a/crates/platform/src/browser_files.rs +++ b/crates/platform/src/browser_files.rs @@ -38,7 +38,10 @@ pub struct BrowserFiles { /// An embedding page's save ([`BrowserFiles::page_saves`]): given the file name, the bytes and whether the user asked /// for Save As, `None` when no page hosts the app, else the page's answer. -pub type PageSave = Arc Option> + Send + Sync>; +pub type PageSave = Arc; + +/// The callback behind a [`PageSave`]. +pub type PageSaveFn = dyn Fn(&str, &[u8], bool) -> Option> + Send + Sync; /// Tickets of one service, shared with the tasks that answer them. #[derive(Default)] @@ -178,7 +181,7 @@ fn write_name(path: &Path) -> String { /// A write's route: the embedding page when `page` answers (`Ok(true)`), else `download` (`Ok(false)`). pub(crate) fn page_or_download( - page: Option<&(dyn Fn(&str, &[u8], bool) -> Option> + Send + Sync)>, + page: Option<&PageSaveFn>, name: &str, bytes: &[u8], save_as: bool, diff --git a/crates/web-host/src/files.rs b/crates/web-host/src/files.rs index bc9bcf5cca..dcd15a8839 100644 --- a/crates/web-host/src/files.rs +++ b/crates/web-host/src/files.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; -use craft_host::{FileError, Files, PickId, PickRequest, Picked, Wake, WriteIntent}; +use craft_host::{FileError, Files, PendingPick, PickId, PickRequest, Picked, Wake, WriteIntent}; use craft_platform::browser_files::{BrowserFiles as PlatformFiles, PickLimits}; /// The hosting page's save, for [`PlatformFiles::page_saves`]: posts `bytes` to the page `Host::connect` connected @@ -46,8 +46,8 @@ impl Files for BrowserFiles { self.inner.forget(id); } - fn pick_pending(&self) -> bool { - self.inner.pick_pending() + fn pending_pick(&self) -> Option { + self.inner.pending_pick() } fn read(&self, path: &Path) -> Result, FileError> { From 969bfa99fabed92148b55ad58981717df5cbf8cc Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:11:54 +0700 Subject: [PATCH 03/10] ui-patterns: a document dialog's fixed section puts its rows on a card again and heads them with its name, which the merge of next dropped from the section rewrite --- crates/ui-patterns/src/patterns/form_dialogs/rows.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs index 9ff040e87d..4b4b03b869 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs @@ -13,7 +13,7 @@ use super::words::ParamWords; use crate::buttons::{Button, IconButton, ToggleButton}; use crate::choice::{Checkbox, Radio, RadioGroup, Swatch}; use crate::contract::{ - Bind, BodyCx, CanvasGesture, CaptionColumn, Entry, FieldLayout, LabelScheme, NoValue, Outcome, Props as _, Remember as _, Sampler as _, + Bind, BodyCx, CanvasGesture, CaptionColumn, Entry, FieldLayout, LabelScheme, NoValue, Outcome, Pad, Props as _, Remember as _, Sampler as _, Show as _, ShowContainer as _, SideLabel, Sizing, TooltipSpec, clicked, }; use crate::display::Text; @@ -26,6 +26,7 @@ use crate::pickers::{Select, UnitSelect}; use crate::runtime::env::{Env, Label, UnitKind, Units, with_env}; use crate::sections::{HeaderStrength, Section}; +use crate::style::SurfaceKind; use crate::text::{NumberField, RangeAlert, SelectableText, TextField, UnitPlacement}; use crate::value_drag::{AngleDial, PointPicker, SliderScale}; @@ -706,7 +707,14 @@ impl<'p> Pass<'p> { /// One section: its head, then its rows. fn section(&mut self, ui: &mut Ui, head: &Param, body: &[Param]) { let title = plain(&head.label); + let outer = self.heading.replace(title.as_str().to_owned()); match head.option().head() { + // A document dialog's option group: a caption over its rows on a card. + Head::Fixed if self.shaded => { + Section::fixed(title).id_salt(head.key.as_str()).strength(HeaderStrength::Caption).show(ui, |ui, _| { + Stack::new().fill_width().surface(SurfaceKind::Raised).pad(Pad::Control).show(ui, |ui, _| self.body(ui, body)); + }); + } Head::Fixed => { Section::fixed(title).id_salt(head.key.as_str()).show(ui, |ui, _| self.body(ui, body)); } @@ -724,6 +732,7 @@ impl<'p> Pass<'p> { }); } } + self.heading = outer; } /// `param` as the pass shows it, `compact` in a pair. From daed17160c85a78c958177e3293a01590054d175 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:11:59 +0700 Subject: [PATCH 04/10] ui-patterns: a hosted dialog's automation set takes the host's row labels and shown states, every tab's rows and the read-only refusal again, and reports the rows it changed, which the merge of next dropped from the batched set --- .../src/patterns/form_dialogs/dialog.rs | 19 ++++++++++++------- .../patterns/form_dialogs/host_requests.rs | 11 ++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs index cbc7b8c4f3..b95aee9bb3 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs @@ -2000,12 +2000,21 @@ impl StackDialog for HostedParamDialog { self.requests.answer_color(key, color); } - /// Sets the fields on a clone of the values and commits the clone only when every field is accepted. + /// Sets the fields on a clone of the values and commits the clone only when every field is accepted. The rows are + /// those the user sees: the host's labels and shown states over every tab's rows; a read-only dialog refuses all. fn set_json_fields(&mut self, _: &Context, fields: &[(String, Value)]) -> Result<(), String> { - let params = (self.build)(&mut self.fields).params.into_owned(); + let (params, read_only) = { + let mut dialog = (self.build)(&mut self.fields); + self.rows.apply(&mut dialog); + let ParamDialog { params, tabs, read_only, .. } = dialog; + (every_param(params, &tabs).into_owned(), read_only) + }; let mut staged = self.fields.clone(); let mut preview = self.preview_on; for (field, value) in fields { + if read_only { + return Err(FieldRefusal::Inactive.message(field)); + } match (field.as_str(), &self.presets) { ("preview", _) if self.previews => { preview = value.as_bool().ok_or_else(|| FieldRefusal::Rejects(value).message(field))?; @@ -2018,11 +2027,7 @@ impl StackDialog for HostedParamDialog { _ => set_param_field(¶ms, &mut staged, field, value.clone())?, } } - for param in params.iter().filter(|param| matches!(param.kind, ParamKind::Files { .. })) { - if let Some(request) = param.listing_after(&self.fields, &staged) { - self.requests.request_listing(request); - } - } + self.requests.request_set(¶ms, &self.fields, &staged); self.fields = staged; self.preview_on = preview; Ok(()) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs b/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs index ce5933cfee..af852f73f3 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs @@ -223,13 +223,18 @@ impl HostRequests { pub fn set_field(&mut self, params: &[Param], fields: &mut DialogFields, field: &str, value: Value) -> Result<(), String> { let before = fields.clone(); super::set_param_field(params, fields, field, value)?; + self.request_set(params, &before, fields); + Ok(()) + } + + /// Files what a set through automation of the rows `params` from `before` to `after` files ([`set_field`](Self::set_field)). + pub fn request_set(&mut self, params: &[Param], before: &DialogFields, after: &DialogFields) { for param in params.iter().filter(|param| matches!(param.kind, ParamKind::Files { .. })) { - if let Some(request) = param.listing_after(&before, fields) { + if let Some(request) = param.listing_after(before, after) { self.request_listing(request); } } - self.request_edited(edited_rows(params, &before, fields)); - Ok(()) + self.request_edited(edited_rows(params, before, after)); } /// The row keys an edit changed since the last take. From 7002b2ec8f48048ae0a3e55fe6eaeb60a4e3398c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:23:57 +0700 Subject: [PATCH 05/10] ui-contract: drag::register takes a target's reach as one TargetReach; collections report an item's output through one helper --- crates/ui-contract/src/contract/cx/pointer.rs | 3 +- .../ui-contract/src/contract/items/hooks.rs | 14 +----- .../ui-contract/src/contract/items/members.rs | 13 +----- .../ui-contract/src/contract/items/press.rs | 18 +++++++- crates/ui-contract/src/runtime/drag.rs | 46 ++++++++----------- 5 files changed, 42 insertions(+), 52 deletions(-) diff --git a/crates/ui-contract/src/contract/cx/pointer.rs b/crates/ui-contract/src/contract/cx/pointer.rs index f7dc0b3cc3..9f31c12991 100644 --- a/crates/ui-contract/src/contract/cx/pointer.rs +++ b/crates/ui-contract/src/contract/cx/pointer.rs @@ -197,7 +197,8 @@ impl Pointer for CxCore<'_> { let op = drag::current_operation(&self.ctx, craft_behavior::CopyKeys::Alt); let drop = target.accept(&payload, op)?; let ordinal = drag::next_ordinal(&self.ctx, self.id); - drag::register(&self.ctx, self.id, self.response.layer_id, target.mark(&drop), op, self.env.shared_tokens(), true, target.under_modal()); + let reach = drag::TargetReach { window: true, under_modal: target.under_modal() }; + drag::register(&self.ctx, self.id, self.response.layer_id, target.mark(&drop), op, self.env.shared_tokens(), reach); drag::take_drop(&self.ctx, self.id, ordinal, op, TypeId::of::

()).then_some(drop) } diff --git a/crates/ui-contract/src/contract/items/hooks.rs b/crates/ui-contract/src/contract/items/hooks.rs index 7039260b80..f25092d50c 100644 --- a/crates/ui-contract/src/contract/items/hooks.rs +++ b/crates/ui-contract/src/contract/items/hooks.rs @@ -8,8 +8,7 @@ use super::{Held, ITEM_NODE, ItemsHooks, LastLayout, Lead, Placement, Renaming, use super::{request, rows}; use crate::contract::ValueOf; use crate::contract::collection::{ - CollectionEvent, CollectionProps, ColumnLayout, ContextMenuRequest, DropAt, Gestures, HoverLead, ItemsOut, OpenChange, PendingDrop, Rename, - RowState, ShownRow, + CollectionEvent, CollectionProps, ColumnLayout, DropAt, Gestures, HoverLead, ItemsOut, PendingDrop, Rename, RowState, ShownRow, }; use crate::contract::cx::{BodyCx, CxCore, Pointer as _}; use crate::contract::run::{Measuring, ShapeHooks, ShowAt}; @@ -644,16 +643,7 @@ impl ShapeHooks for ItemsHooks<'_, '_, C> { if let Some(row) = shown_rows.last_mut() { row.openers = self.item_openers(&row_ui, &ctx, id, cx.core.resolved.enabled, openers); } - if let Some(ask) = out.open_request() { - self.events.push(CollectionEvent::Open(OpenChange { key: key.clone(), open: ask.open, all: ask.all })); - } - if let Some(rect) = out.menu_request() { - crate::runtime::keys::request_context(&ctx, id, rect, None); - self.ask_menu(ContextMenuRequest { key: key.clone(), at: self.on_screen(rect.left_bottom()), column: None, part: None }); - } - if let Some(event) = out.into_event() { - self.events.push(CollectionEvent::Item(key.clone(), event)); - } + self.report_item_output(&ctx, id, &key, out); if state.renaming { self.rename_row(comp, &mut row_ui, (&ctx, id, rtl), (at, &key), label); } diff --git a/crates/ui-contract/src/contract/items/members.rs b/crates/ui-contract/src/contract/items/members.rs index 72b61d9100..405d60dcc9 100644 --- a/crates/ui-contract/src/contract/items/members.rs +++ b/crates/ui-contract/src/contract/items/members.rs @@ -2,7 +2,7 @@ //! arena, updated, painted and finished at their rows, reported as sub-nodes of the collection. use super::{ITEM_NODE, ItemsHooks, key_hash}; -use crate::contract::collection::{CollectionEvent, ContextMenuRequest, OpenChange, ShownRow}; +use crate::contract::collection::ShownRow; use crate::contract::run; use crate::contract::{Collection, Component as _, Cx, Internal, ItemOpener, ItemOutput as _, Meta as _}; use crate::primitives::sensing::{self, MemberSpec}; @@ -87,16 +87,7 @@ impl<'r, C: Collection> ItemsHooks<'_, 'r, C> { shown.openers = self.item_openers(ui, ctx, id, enabled, openers); } let label = output.label_rect().unwrap_or(row); - if let Some(ask) = output.open_request() { - self.events.push(CollectionEvent::Open(OpenChange { key: key.clone(), open: ask.open, all: ask.all })); - } - if let Some(rect) = output.menu_request() { - crate::runtime::keys::request_context(ctx, id, rect, None); - self.ask_menu(ContextMenuRequest { key: key.clone(), at: self.on_screen(rect.left_bottom()), column: None, part: None }); - } - if let Some(event) = output.into_event() { - self.events.push(CollectionEvent::Item(key.clone(), event)); - } + self.report_item_output(ctx, id, &key, output); if renaming { self.rename_row(comp, ui, (ctx, id, rtl), (at, &key), label); } diff --git a/crates/ui-contract/src/contract/items/press.rs b/crates/ui-contract/src/contract/items/press.rs index df7c599778..cf6819543d 100644 --- a/crates/ui-contract/src/contract/items/press.rs +++ b/crates/ui-contract/src/contract/items/press.rs @@ -3,8 +3,8 @@ use super::drag::SlowClick; use super::lead::PickBy; use super::{ItemsHooks, Placement, RowPress, SECTION}; -use crate::contract::collection::{ActivateOn, CollectionEvent, CollectionProps, ContextMenuRequest, LeadSource, RowPressed, SelectMode}; -use crate::contract::{Collection, Cx, ItemOpener}; +use crate::contract::collection::{ActivateOn, CollectionEvent, CollectionProps, ContextMenuRequest, LeadSource, OpenChange, RowPressed, SelectMode}; +use crate::contract::{Collection, Cx, ItemOpener, ItemOutput}; use crate::runtime::egui::response; use crate::runtime::env::ArenaId; use crate::runtime::focus; @@ -380,6 +380,20 @@ impl ItemsHooks<'_, '_, C> { self.events.push(CollectionEvent::ContextMenu(request)); } + /// Reports what the shown item `key` asked for: opening or closing its children, its menu, and its event. + pub(super) fn report_item_output(&mut self, ctx: &Context, id: Id, key: &C::Key, output: impl ItemOutput) { + if let Some(ask) = output.open_request() { + self.events.push(CollectionEvent::Open(OpenChange { key: key.clone(), open: ask.open, all: ask.all })); + } + if let Some(rect) = output.menu_request() { + crate::runtime::keys::request_context(ctx, id, rect, None); + self.ask_menu(ContextMenuRequest { key: key.clone(), at: self.on_screen(rect.left_bottom()), column: None, part: None }); + } + if let Some(event) = output.into_event() { + self.events.push(CollectionEvent::Item(key.clone(), event)); + } + } + /// The response of each part an item asked to open a menu from (`ItemCx::part_opener`). pub(super) fn item_openers(&self, ui: &Ui, ctx: &Context, id: Id, enabled: bool, openers: Vec) -> Vec<(ItemOpener, egui::Response)> { item_openers(ui, ctx, id, enabled, openers) diff --git a/crates/ui-contract/src/runtime/drag.rs b/crates/ui-contract/src/runtime/drag.rs index 423bc707e1..bfe0156945 100644 --- a/crates/ui-contract/src/runtime/drag.rs +++ b/crates/ui-contract/src/runtime/drag.rs @@ -74,7 +74,7 @@ pub enum DropMark { }, } -crate::stays!(Arc, DropOperation); +crate::stays!(Arc, DropOperation, TargetReach); impl crate::runtime::Shift for DropMark { fn shifted(&self, by: &egui::RecordShift) -> Self { @@ -301,10 +301,16 @@ struct Registration { op: DropOperation, /// The tokens of the target's region. tokens: Arc, + reach: TargetReach, +} + +/// Where a drop target takes drops beyond its own mark. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct TargetReach { /// The target covers the whole window: any target over a component beats it. - window: bool, + pub(crate) window: bool, /// The target takes OS files under a modal layer (`DropTarget::under_modal`). - under_modal: bool, + pub(crate) under_modal: bool, } /// A viewport's registrations: this pass's, and the target that won last pass. @@ -635,24 +641,12 @@ pub(crate) fn show_mark(ctx: &Context, mark: Option) { } /// Records that `owner`'s `ordinal`th target on `layer` accepts at the pointer a drop doing `op`, with its mark in -/// layer space and the tokens of the target's region. A `window` target covers the whole window; an `under_modal` one -/// takes OS files under a modal layer. -pub(crate) fn register( - ctx: &Context, - owner: Id, - layer: Layer, - mark: DropMark, - op: DropOperation, - tokens: Arc, - window: bool, - under_modal: bool, -) { +/// layer space, the tokens of the target's region and its `reach`. +pub(crate) fn register(ctx: &Context, owner: Id, layer: Layer, mark: DropMark, op: DropOperation, tokens: Arc, reach: TargetReach) { crate::runtime::replay::journal( ctx, - || (owner, layer, mark, op, tokens.clone(), (window, under_modal)), - |ctx, (owner, layer, mark, op, tokens, (window, under_modal))| { - register(ctx, *owner, *layer, *mark, *op, tokens.clone(), *window, *under_modal) - }, + || (owner, layer, mark, op, tokens.clone(), reach), + |ctx, (owner, layer, mark, op, tokens, reach)| register(ctx, *owner, *layer, *mark, *op, tokens.clone(), *reach), ); let mark = match areas::layer_map(ctx, layer) { Some(map) => mark.mapped(|point| map.to_screen(point)), @@ -661,7 +655,7 @@ pub(crate) fn register( let scope = overlay::drawing_parent(ctx); PerViewport::::with(ctx, pass::current_viewport(ctx), |targets| { let ordinal = targets.this.iter().filter(|registration| registration.owner == owner).count() as u32; - targets.this.push(Registration { owner, ordinal, layer, scope, mark, op, tokens, window, under_modal }); + targets.this.push(Registration { owner, ordinal, layer, scope, mark, op, tokens, reach }); }); } @@ -747,7 +741,7 @@ pub(crate) fn target_of>( let op = current_operation(ctx, target.copy_keys()); let drop = target.accept(&*payload, at, op)?; let ordinal = next_ordinal(ctx, owner); - register(ctx, owner, zone.layer, target.mark(&drop), op, tokens, false, target.under_modal()); + register(ctx, owner, zone.layer, target.mark(&drop), op, tokens, TargetReach { window: false, under_modal: target.under_modal() }); take_drop(ctx, owner, ordinal, op, payload_type).then_some(drop) } @@ -811,7 +805,7 @@ pub(crate) fn end_pass(ctx: &Context) { // that takes them there. let os = carries_os_files(ctx); let scopes: Vec<(Option, bool)> = PerViewport::::with(ctx, viewport, |targets| { - targets.this.iter().map(|registration| (registration.scope, os && registration.under_modal)).collect() + targets.this.iter().map(|registration| (registration.scope, os && registration.reach.under_modal)).collect() }); let open: Vec = scopes.iter().map(|(scope, through)| *through || overlay::key_layer(ctx, scope.as_slice(), None) != LayerKeys::Blocked).collect(); @@ -823,10 +817,10 @@ pub(crate) fn end_pass(ctx: &Context) { .iter() .enumerate() .filter(|(at, _)| open[*at]) - .max_by_key(|(at, registration)| (!registration.window, areas::layer_position(ctx, registration.layer), *at)) + .max_by_key(|(at, registration)| (!registration.reach.window, areas::layer_position(ctx, registration.layer), *at)) .map(|(_, registration)| registration); - targets.component = best.is_some_and(|registration| !registration.window); - targets.winner_window = best.is_some_and(|registration| registration.window); + targets.component = best.is_some_and(|registration| !registration.reach.window); + targets.winner_window = best.is_some_and(|registration| registration.reach.window); targets.pointer = position; let best = best.map(|registration| ((registration.owner, registration.ordinal), (registration.mark, registration.op, registration.tokens.clone()))); @@ -909,7 +903,7 @@ pub(crate) fn held_elsewhere(ctx: &Context) -> bool { let viewport = pass::current_viewport(ctx); pass::live_viewports(ctx).into_iter().filter(|other| *other != viewport).any(|other| { PerViewport::::with(ctx, other, |targets| { - (targets.winner.is_some() && targets.component) || targets.this.iter().any(|registration| !registration.window) + (targets.winner.is_some() && targets.component) || targets.this.iter().any(|registration| !registration.reach.window) }) }) } From f92a0be4ec12ac64b371a2910b52a412d961c08c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:37:06 +0700 Subject: [PATCH 06/10] atomic: drop the empty line between KEPT_ATTRIBUTES and its doc comment --- crates/atomic/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/atomic/src/lib.rs b/crates/atomic/src/lib.rs index c0bbcf5553..2fa589d099 100644 --- a/crates/atomic/src/lib.rs +++ b/crates/atomic/src/lib.rs @@ -491,7 +491,6 @@ fn name_taken(e: &io::Error, tmp: &Path) -> bool { /// The Windows attributes a replaced file passes on to its stage: hidden and system, the two that /// say who should see the file. A read-only file is never replaced, the archive bit is the /// system's to set on a changed file, and the others describe how the volume stores it. - #[cfg(windows)] const KEPT_ATTRIBUTES: u32 = 0x2 | 0x4; From afbe61c547b767aa90947b23d0be080b7f4bd9f5 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:48:26 +0700 Subject: [PATCH 07/10] automation: the control server ends a connection after its last reply by closing its write side and reading off what the client still sends, so the close no longer resets the connection and loses the reply or the end of the stream --- crates/automation/src/server.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs index b2f9fdd1d0..c6808156d7 100644 --- a/crates/automation/src/server.rs +++ b/crates/automation/src/server.rs @@ -1,7 +1,7 @@ //! The loopback JSON-lines TCP transport: one request per line, one reply per line. -use std::io::{BufReader, Write}; -use std::net::{SocketAddr, TcpListener, TcpStream}; +use std::io::{BufReader, Read, Write}; +use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{Receiver, Sender, channel}; @@ -89,6 +89,7 @@ pub fn serve_with_deadline( let Some(permit) = limiter.try_acquire() else { let _ = configure_stream(&stream); let _ = writeln!(stream, "{}", json!({"id": null, "ok": false, "error": "connection limit reached"})); + close_after_reply(&stream); continue; }; let tx = tx.clone(); @@ -179,4 +180,27 @@ fn serve_connection(stream: TcpStream, token: &str, tx: &Sender, break; } } + close_after_reply(&out); +} + +/// How long a closing connection's leftover input is read and dropped ([`close_after_reply`]). +const CLOSE_LINGER: Duration = Duration::from_millis(250); + +/// Closes `stream` after its last reply without resetting it: the write side ends first, so the client reads the +/// reply and then the end of the stream, and what the client still sends is read and dropped until it closes too, for +/// at most [`CLOSE_LINGER`]. A socket closed with input unread is reset instead, and the client loses the reply +/// (Linux) or reads the reset where the end of the stream should be (Windows). +fn close_after_reply(mut stream: &TcpStream) { + let _ = stream.shutdown(Shutdown::Write); + let deadline = motion::now() + CLOSE_LINGER; + let mut sink = [0; 1024]; + loop { + let left = deadline.saturating_duration_since(motion::now()); + if left.is_zero() || stream.set_read_timeout(Some(left)).is_err() { + return; + } + if matches!(stream.read(&mut sink), Ok(0) | Err(_)) { + return; + } + } } From 68a41a9e813915c83a0f7679914dbcbff7023c23 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:17:56 +0700 Subject: [PATCH 08/10] text: Format Text's font row names the font_picker prop without a link the font-picker feature gates --- crates/text/src/ui/character/format_text.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/text/src/ui/character/format_text.rs b/crates/text/src/ui/character/format_text.rs index 5f697ac1ab..5a5de1ef6c 100644 --- a/crates/text/src/ui/character/format_text.rs +++ b/crates/text/src/ui/character/format_text.rs @@ -138,8 +138,8 @@ const LINE_PRESETS: [LineSpacing; 5] = /// superscript, subscript; line and paragraph spacing; scale and character spacing). A control in `unsupported` is /// disabled with its reason. It keeps no state between passes: each pass reports only the edits of its own input. /// -/// - Font: the family field the Character controls show: craft-font-manager's `FontPicker` over -/// [`font_picker`](Self::font_picker) (with the host's rows), else a `Select` of `families`. A family pick is +/// - Font: the family field the Character controls show: craft-font-manager's `FontPicker` with +/// `font-picker` and `font_picker` (with the host's rows), else a `Select` of `families`. A family pick is /// `Character(Family(..))`, a style row pick `Character(Family(..))` then `Character(Style(..))`, and a host row /// pick `HostFont(key)`. /// - Size, paragraph spacing and character spacing are lengths in points; horizontal scale is a percentage. A scrub From b6b2908123777e725684a4fb9be2ee848be37529 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:27:06 +0700 Subject: [PATCH 09/10] theme: regenerate the VectorCraft token dumps with the six tokens next added --- .../tokens/vectorcraft-modern-dark-high-comfortable.txt | 6 ++++++ .../dumps/tokens/vectorcraft-modern-dark-high-compact.txt | 6 ++++++ .../tokens/vectorcraft-modern-dark-standard-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-dark-standard-compact.txt | 6 ++++++ .../tokens/vectorcraft-modern-light-high-comfortable.txt | 6 ++++++ .../dumps/tokens/vectorcraft-modern-light-high-compact.txt | 6 ++++++ .../vectorcraft-modern-light-standard-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-light-standard-compact.txt | 6 ++++++ .../vectorcraft-modern-medium-dark-high-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-medium-dark-high-compact.txt | 6 ++++++ .../vectorcraft-modern-medium-dark-standard-comfortable.txt | 6 ++++++ .../vectorcraft-modern-medium-dark-standard-compact.txt | 6 ++++++ .../vectorcraft-modern-medium-light-high-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-medium-light-high-compact.txt | 6 ++++++ ...vectorcraft-modern-medium-light-standard-comfortable.txt | 6 ++++++ .../vectorcraft-modern-medium-light-standard-compact.txt | 6 ++++++ 16 files changed, 96 insertions(+) diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt index 4efc3b2289..812c906cf9 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #bbc4d5ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt index 783dfa13a5..f790188e0a 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #bbc4d5ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt index d89eec9a4d..ea748d6c02 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #969fafff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt index bd51c94294..d66b2ac691 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #969fafff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt index 40242a0b51..4b820d4ad7 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #3d4452ff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt index 5542f8faa0..38b4a70b01 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #3d4452ff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt index 69eedb01ea..5fac7f9458 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #58606eff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt index aff055622a..2958fed494 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #58606eff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt index 8e0d025e3b..f38597b671 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #d3dcedff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt index 6f0078e78f..272a5add33 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #d3dcedff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt index f2ce55a499..1280892e8c 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #99a2b2ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt index d7e3d29eb0..da092c68e6 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #99a2b2ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt index ca6e14c288..647ee21631 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #2a303eff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt index 315233d458..df1623ec60 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #2a303eff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt index e15440c537..5ad36953a3 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #4a5160ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt index 7051e2d8e8..5107c75c78 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #4a5160ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 From 12c5d012ed495f344a219e892515c383527d8bb9 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:57:15 +0700 Subject: [PATCH 10/10] ui-contract: a focused text field keeps the Escape it does not use, and every other focused control lends it to the window --- crates/ui-contract/src/runtime/keys/intents.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/ui-contract/src/runtime/keys/intents.rs b/crates/ui-contract/src/runtime/keys/intents.rs index b3ca4df20b..a60d21cc5b 100644 --- a/crates/ui-contract/src/runtime/keys/intents.rs +++ b/crates/ui-contract/src/runtime/keys/intents.rs @@ -4,7 +4,7 @@ use super::route::push; use super::{Nudge, Source, Stage, current}; use crate::runtime::focus::{self}; use craft_behavior::focus::{EscapeFacts, EscapeStep, escape_step}; -use craft_behavior::{AccessRequest, CancelRule, EditCommand, EditorInput, Intent, MoveMods, NavMove, PartRef}; +use craft_behavior::{AccessRequest, CancelRule, EditCommand, EditorInput, Intent, MoveMods, NavMove, OwnerClass, PartRef}; use craft_keymap::{Chord, Key, Mods}; use egui::{Context, Id, Vec2}; use std::sync::Arc; @@ -287,7 +287,7 @@ pub fn intents_of(ctx: &Context, id: Option, rtl: bool) -> Intents { /// /// The window's intents are the keys the runtime routes to no component this pass: an Escape (`Intent::Cancel`) /// or a plain Enter (`Intent::Submit`) while no framework stop is focused, and the arrows' nudge; with a framework -/// stop focused, its unused Escape. A component or a +/// stop focused, its unused Escape, unless it is a text field. A component or a /// scope that runs earlier in the pass takes them first (an open dialog takes the Escape that closes it, a canvas /// session the one that ends it), so an app that hosts the runtime reads them last in its UI to see what no /// component took. `rtl` reads horizontal moves in the window's direction. @@ -305,7 +305,11 @@ pub fn with_canvas_window_intents(ctx: &Context, rtl: bool, take: impl FnOnce(&m } fn offer_window_intents(ctx: &Context, rtl: bool, take: impl FnOnce(&mut Intents) -> bool) -> bool { - let focused = focus::focused_rec(ctx).map(|rec| rec.stop.id); + // A focused text field keeps the Escape it does not use, so typing in a palette's field never closes the + // palette; the document's editor and a canvas control lend it as any other control does. + let focused = focus::focused_rec(ctx) + .filter(|rec| rec.stop.keys.owner != OwnerClass::Text || rec.stop.keys.is_document_editor() || focus::is_canvas_member(ctx, rec)) + .map(|rec| rec.stop.id); let mut window = intents_of(ctx, None, rtl); // The focused stop's leftover Escape stays in its slot until taken. let lent_cancel =