Skip to content

blocks-desktop: styled look from the web tokens, app faces, native composer (#303) - #307

Merged
jirathip-k merged 1 commit into
stagingfrom
issue-303
Nov 21, 2026
Merged

jirathip-k merged 1 commit into
stagingfrom
issue-303

Conversation

@jirathip-k

@jirathip-k jirathip-k commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #303

For humans

The desktop app now looks finished by default: the page has a margin, text uses the same sizes as the web app, and blocks are spaced evenly. An app can pick its own font (one or several in order), and the message box is now a real text field with a send button instead of a placeholder.

For apps

  • blocks_desktop::Look has a new field faces: Vec<egui::FontData>. The first face draws all proportional text, each later face fills in glyphs the earlier ones lack, and egui's default comes last. Code and commands stay monospace. With ..Look::default(), nothing changes for an app.
  • Stage::show now draws inside a page margin (--s4 × style space). It sets type sizes from the web tokens (--fs body, --fs-meta small, --fs × 1.7 title) and item spacing from them (--s2 × space). These styles apply only inside the stage, so the app's own Ui is unchanged.
  • composer is drawn natively: a text field and a send button (the block's label, else "send"), with Cmd/Ctrl+Enter also sending. It sends {...values, text} to action, or to acts.queue while working is set. Chips, queued rows and attachments are not drawn yet.

What changed

  • look.rs: the token mirror of web/src/css/base/root.css, and dress (faces, sizes, spacing). No new colours or tokens.
  • stage.rs: draws the screen in a margin frame and dresses that frame's Ui.
  • draw/composer.rs: the native composer.
  • New snapshots docs/architecture/gpui/look/egui-look-{390,1440}-{light,dark}.png replace the old unstyled ones, drawn by blocks-desk from look/look.json. That file is the spike's sample::look() screen, produced by the crate's own samples().
  • docs/desktop.md (sizes, fonts, composer no longer a gap) and measured.md (what the PNGs are now).

Decisions:

  • Sizes follow the tokens rather than the spike's hand-picked numbers: body 13 vs the spike's 14, small 11 vs 12, title 22.1 vs 22. Spacing (8) and margin (16) match exactly.
  • The app's faces apply to proportional text only, so code stays aligned.
  • The harness's Thai --font stays a last-resort fallback, separate from faces: it fills missing glyphs and does not replace the face.

Tests

  • crates/blocks-desk/tests/look.rs:
    • an_app_face_draws_every_kinds_text_and_without_one_the_bundled_face_does draws every fixtures/blocks screen with an app face (egui's Hack) and without one, then reads each drawn glyph's face metrics. With the face set, no glyph comes from the bundled proportional face. Without it, more than 100 do. It fails when face installation is disabled (checked by hand).
    • sizes_and_the_margin_are_the_web_renderers_tokens parses root.css and checks the drawn body and footnote sizes and the page margin against it.
  • crates/blocks-desk/tests/desk.rs: a_composer_sends_what_was_typed_with_its_values_and_queues_while_a_turn_works runs type then tap through the harness.

Evidence at b6a8608, macOS arm64:

command exit
cargo test --locked -p blocks-desktop -p blocks-desk 0
blocks-desk --check on every fixtures/blocks and fixtures/stress/*-* file at 390x844 and 1440x900 (the CI loop) 0 for all
cargo fmt --all --check 0
just clippy 0
just arch 0
just cap 0

Byte-identical PNGs on Linux and Windows are covered by the desktop CI matrix. I ran only macOS here.

Not done, and out of scope: egui's widget fills (text fields, buttons) are not themed from the scheme, so the composer field and button keep egui's default dark fill on a light page, the same as forms and secrets today.

src/ net +68 (no budget stated in the issue): the token mirror and dress (+41), the composer (+24), the margin frame (+3).

Perf (fix round, head b6a8608)

The desktop (windows-latest) perf step first failed at 4.0029 ms against the 4 ms patch budget. This was runner noise, not a regression, so the code is unchanged and only the failed job was rerun (green: slowest patch 3.47 ms at 1440, 2.73 ms at 390).

slowest patch, 1440 staging 3fe5208 this PR b6a8608
Windows CI 3.26 ms 4.00 ms (first run), 3.47 ms (rerun)
Ubuntu CI 2.70 ms 2.10 ms
macOS CI 1.90 ms 2.28 ms
local macOS, cargo test --release -p blocks-desk --test perf -- --ignored --nocapture 1.28 ms (exit 0) 1.15 ms (exit 0)

@jirathip-k
jirathip-k merged commit 21c6798 into staging Nov 21, 2026
17 of 19 checks passed
@jirathip-k
jirathip-k deleted the issue-303 branch November 21, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant