Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
069dfb6
Design a compiled, optionally shared, library for morph's UI layer
Yaraslaut Nov 14, 2026
71f5167
Compile morph::morph as a static library, with src/ui as its first so…
Yaraslaut Nov 14, 2026
31bb0d4
Set the GCC -O3 memory target for the compiled UI library
Yaraslaut Nov 14, 2026
7ae22c3
Move the interpreter's non-template code into src/ui/interpreter.cpp
Yaraslaut Nov 14, 2026
ed76d28
Prune interpreter.hpp's includes, and clear clang-tidy on the moved code
Yaraslaut Nov 14, 2026
b32562d
Move the document loader into src/ui/document.cpp
Yaraslaut Nov 15, 2026
0ab834c
Move the expression language into src/ui/expression.cpp
Yaraslaut Nov 15, 2026
998f461
Move the UI service's non-template code into src/ui/service.cpp
Yaraslaut Nov 15, 2026
c2d29c4
Move the UI service client's non-template code into src/ui/service_cl…
Yaraslaut Nov 15, 2026
8077da6
Move the screen host's non-template code into src/ui/host.cpp
Yaraslaut Nov 15, 2026
de9e6b9
Move the workspace's non-template code into src/ui/workspace.cpp
Yaraslaut Nov 15, 2026
0c3d59f
Move the shell parts model's non-template code into src/ui/shell_part…
Yaraslaut Nov 15, 2026
35172e4
Move the shell frame's non-template code into src/ui/shell_frame.cpp
Yaraslaut Nov 15, 2026
a830da0
Move the view backend's out-of-line bodies into src/ui/backend.cpp
Yaraslaut Nov 15, 2026
4b2c35e
Move the theme reader's non-template code into src/ui/theme.cpp
Yaraslaut Nov 15, 2026
c2395ed
Move the explorer's non-template code into src/ui/explorer.cpp
Yaraslaut Nov 15, 2026
66a0b19
Move the navigator's non-template code into src/ui/navigator.cpp
Yaraslaut Nov 15, 2026
a2d1dfe
Prune service.hpp's and theme.hpp's includes, and fix the service spe…
Yaraslaut Nov 15, 2026
c2fda26
Clear the clang-tidy findings the moved bodies exposed
Yaraslaut Nov 15, 2026
c8c7338
Fix the two GCC findings in the moved code
Yaraslaut Nov 15, 2026
0041f8d
Make the moved service, shell and theme sources clang-tidy clean
Yaraslaut Nov 15, 2026
1ab774e
Make the install consumer call into the compiled UI service
Yaraslaut Nov 15, 2026
9388e2f
Point the bridge allowlist entry at the line it now sits on
Yaraslaut Nov 15, 2026
fec9d85
Move ChatService into src/ui/chat_service.cpp
Yaraslaut Nov 15, 2026
5586fab
Take explorer.hpp out of client/source.hpp
Yaraslaut Nov 15, 2026
fd83fb7
Silence GCC 16's -Wrestrict false positive in chat_service.cpp
Yaraslaut Nov 15, 2026
5002761
Clear the clang-format and clang-tidy findings CI reports on the move…
Yaraslaut Nov 15, 2026
05f129d
Read the shipped theme's colours without std::regex
Yaraslaut Nov 15, 2026
7c7803d
Compile the lims declared-requirements table once, in the app module
Yaraslaut Nov 15, 2026
87da69e
Register the org models' actions from their sources, not their headers
Yaraslaut Nov 15, 2026
f0e8adf
Register the lab models' actions from their sources, not their headers
Yaraslaut Nov 15, 2026
f92b140
Register the billing models' actions from their sources, not their he…
Yaraslaut Nov 15, 2026
6007335
Register the ledger models' actions from their sources, not their hea…
Yaraslaut Nov 15, 2026
015f6f5
Register the inventory models' actions from their sources, not their …
Yaraslaut Nov 15, 2026
f530798
Split the lims shell, approval-inbox and screens tests so each transl…
Yaraslaut Nov 15, 2026
2494b5a
Build the lims shell people test on GCC, and make the approval-inbox …
Yaraslaut Nov 15, 2026
fc46583
Make the lims test helpers and split tests clang-tidy clean
Yaraslaut Nov 15, 2026
5106aec
Fold lims text columns in staged WITH columns, so SQLite before 3.46 …
Yaraslaut Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 69 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ option(MORPH_REQUIRE_VETTED_HMAC
# -- so it stays emitted regardless. See docs/spec/core/registry.md,
# "MORPH_CLIENT_ONLY".
#
# On the INTERFACE of the morph target, not per-consumer: the macro changes
# PUBLIC on the morph target, not per-consumer: the macro changes
# which registrars a model header emits, so two translation units disagreeing
# about it would violate ODR. Off by default: the standard build is unaffected.
#
Expand Down Expand Up @@ -244,8 +244,8 @@ endif()
# because CPM passes OPTIONS as normal variables, which a -D on the command
# line cannot override.
#
# The define and the link are INTERFACE: morph is header-only, so the macros
# expand in the consumer's own translation units, and every one of them has
# The define and the link are PUBLIC: the macros expand in the consumer's own
# translation units as well as in the library's, and every one of them has
# to agree on MORPH_TRACY_ENABLED (see profiler.hpp on why that is an ODR
# matter).
option(MORPH_ENABLE_TRACY "Instrument morph's hot paths with Tracy profiler zones (fetches Tracy if not installed)" OFF)
Expand Down Expand Up @@ -315,9 +315,8 @@ endif()
# morph uses there. SYSTEM, so morph's warning set does not apply to
# core-cpp's headers.
#
# morph stays a header-only INTERFACE target, but core::base, core::net and
# core::platform are static libraries, so every consumer of morph now builds
# them -- or links an installed core-cpp's.
# core::base, core::net and core::platform are static libraries, so every
# consumer of morph builds them -- or links an installed core-cpp's.
#
# Found first, as glaze is, and fetched only when no installed core-cpp
# satisfies the bound. MORPH_CORE_CPP_VERSION is that bound, stated once
Expand Down Expand Up @@ -407,38 +406,85 @@ if(NOT WIN32 AND NOT EMSCRIPTEN)
find_package(Threads REQUIRED)
endif()

# ── Header-only library target ───────────────────────────────────────────────
add_library(morph INTERFACE)
# ── Library target ───────────────────────────────────────────────────────────
# A static library: the templates and the macro-sensitive core headers stay in
# headers, and what does not depend on a consumer's configuration is compiled
# once, in src/ui.
include(GenerateExportHeader)
add_library(morph STATIC
src/ui/document.cpp
src/ui/expression.cpp
src/ui/interpreter.cpp
src/ui/library.cpp
src/ui/service.cpp
src/ui/host.cpp
src/ui/backend.cpp
src/ui/explorer.cpp
src/ui/navigator.cpp
src/ui/chat_service.cpp
src/ui/service_client.cpp
src/ui/theme.cpp
src/ui/shell_frame.cpp
src/ui/shell_parts_model.cpp
src/ui/workspace.cpp
)
add_library(morph::morph ALIAS morph)

target_include_directories(morph INTERFACE
target_include_directories(morph PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(morph INTERFACE glaze::glaze core::base core::async core::net)
target_link_libraries(morph PUBLIC glaze::glaze core::base core::async core::net)
target_compile_features(morph PUBLIC cxx_std_23)
if(NOT EMSCRIPTEN)
target_link_libraries(morph INTERFACE core::platform)
target_link_libraries(morph PUBLIC core::platform)
endif()
if(NOT WIN32 AND NOT EMSCRIPTEN)
target_link_libraries(morph INTERFACE Threads::Threads)
target_link_libraries(morph PUBLIC Threads::Threads)
endif()
if(MORPH_REQUIRE_VETTED_HMAC)
target_compile_definitions(morph INTERFACE MORPH_REQUIRE_VETTED_HMAC)
target_compile_definitions(morph PUBLIC MORPH_REQUIRE_VETTED_HMAC)
endif()
if(MORPH_CLIENT_ONLY)
target_compile_definitions(morph INTERFACE MORPH_CLIENT_ONLY)
target_compile_definitions(morph PUBLIC MORPH_CLIENT_ONLY)
endif()
if(MORPH_ENABLE_TRACY)
target_compile_definitions(morph INTERFACE MORPH_TRACY_ENABLED)
target_link_libraries(morph INTERFACE Tracy::TracyClient)
target_compile_definitions(morph PUBLIC MORPH_TRACY_ENABLED)
target_link_libraries(morph PUBLIC Tracy::TracyClient)
endif()

# MORPH_API marks what a consumer calls into the compiled library. A static
# build defines MORPH_STATIC_DEFINE for the library and its consumers, which
# makes the macro empty.
generate_export_header(morph
BASE_NAME MORPH
EXPORT_MACRO_NAME MORPH_API
EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/generated/morph/export.hpp"
)
target_compile_definitions(morph PUBLIC MORPH_STATIC_DEFINE)
apply_warnings(morph)
# Every consumer of this archive carries an AF_SANITIZER block of its own, which is what makes instrumenting a static
# library safe: the link options are PRIVATE and do not propagate out of a static library.
if(DEFINED AF_SANITIZER)
apply_sanitizers(morph ${AF_SANITIZER})
endif()
if(AF_COVERAGE)
apply_coverage(morph)
endif()

target_sources(morph
PUBLIC
FILE_SET morph_generated_headers TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/generated
FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/morph/export.hpp
)

set_target_properties(morph PROPERTIES
VERIFY_INTERFACE_HEADER_SETS ON
)

target_sources(morph
INTERFACE
PUBLIC
FILE_SET HEADERS
BASE_DIRS include
FILES
Expand Down Expand Up @@ -625,7 +671,7 @@ target_sources(morph
# *public* header generated from the prefix: a public header that needs an
# uninstalled detail/ header fails to compile there, whatever this list says.
target_sources(morph
INTERFACE
PUBLIC
FILE_SET morph_detail_headers TYPE HEADERS
BASE_DIRS include
FILES
Expand Down Expand Up @@ -1263,6 +1309,8 @@ if(MORPH_INSTALL)
EXPORT morphTargets
FILE_SET HEADERS DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILE_SET morph_detail_headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILE_SET morph_generated_headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

# Optional components ship only when this configuration actually created
Expand Down Expand Up @@ -1375,24 +1423,14 @@ if(MORPH_INSTALL)
# SameMajorVersion follows docs/spec/VERSIONING.md, which is what decides
# this: there, minor releases are "additive and source-compatible" and
# only a major breaks the stable surface, so an install of 0.2 does
# satisfy a consumer asking for 0.1. ARCH_INDEPENDENT only while every
# installed component is header-only: without it CMake rejects an install
# made on a differently-sized-void* machine, which is exactly right once a
# compiled archive (morph_qt_impl, morph::tui,
# morph::qt_quick) is in the package.
set(_morph_arch_independent ARCH_INDEPENDENT)
if(TARGET morph_qt_impl
OR "tui" IN_LIST MORPH_INSTALLED_COMPONENTS OR "qt_quick" IN_LIST MORPH_INSTALLED_COMPONENTS
OR "client" IN_LIST MORPH_INSTALLED_COMPONENTS)
set(_morph_arch_independent "")
endif()
# satisfy a consumer asking for 0.1. Not ARCH_INDEPENDENT: the package
# holds a compiled archive (morph::morph), which is built for one
# pointer size.
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/morphConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
${_morph_arch_independent}
)
unset(_morph_arch_independent)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/morphConfig.cmake"
Expand Down
2 changes: 1 addition & 1 deletion cmake/morphConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# configure_package_config_file(); see the "Install & export" section of the
# root CMakeLists.txt.
#
# morph is header-only, but it is *not* dependency-free: morph::morph carries
# morph::morph is a compiled static library and is *not* dependency-free: it carries
# glaze::glaze (and Threads) in its interface, and morphTargets.cmake names
# those imported targets literally. Resolving them here rather than leaving it
# to the consumer is not a convenience -- an exported target file that names a
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ component_management:
name: "morph framework (include/morph)"
paths:
- include/morph/**
- src/ui/**
statuses:
- type: project
target: 97%
Expand Down
6 changes: 3 additions & 3 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

`morph` is a typed, asynchronous bridge between a GUI thread and business-object models. Models may live in-process (local mode) or in a remote server process (remote mode). The GUI code is identical in both cases — only the backend implementation changes.

The core library, `morph::morph`, is header-only (C++23, namespace `morph`). It depends on Glaze for JSON reflection and on [core-cpp](https://github.com/contour-terminal/core-cpp) for its event-loop timers, base64 and wakeup primitive; core-cpp's `core::base`, `core::net` and `core::platform` are static libraries, so a project that links `morph::morph` also builds those. The optional parts are separate targets, and some are compiled: the Qt integration (`morph::qt`), the terminal frontend (`morph::tui`), the Qt Quick frontend (`morph::qt_quick`) and the generic client (`morph::client`) are static libraries with sources under `src/`.
The core library, `morph::morph`, is a compiled static library (C++23, namespace `morph`); its templates and the macro-sensitive core headers stay in headers. It depends on Glaze for JSON reflection and on [core-cpp](https://github.com/contour-terminal/core-cpp) for its event-loop timers, base64 and wakeup primitive; core-cpp's `core::base`, `core::net` and `core::platform` are static libraries, so a project that links `morph::morph` also builds those. The optional parts are separate targets, and some are compiled: the Qt integration (`morph::qt`), the terminal frontend (`morph::tui`), the Qt Quick frontend (`morph::qt_quick`) and the generic client (`morph::client`) are static libraries with sources under `src/`.

> **New to morph?** `docs/GETTING-STARTED.md` is the step-by-step tutorial that
> comes before this document: it builds one small app end to end
Expand Down Expand Up @@ -908,15 +908,15 @@ commitment morph makes **starting at 1.0** is fully specified in
`docs/spec/VERSIONING.md` — this section is only a
pointer, not a substitute. In short: the per-topic public namespaces above
(everything outside a `detail` namespace) are the stable surface; because
morph is header-only or static there is no shared-object ABI to preserve, so the promise is *source*
morph is a set of headers and static libraries there is no shared-object ABI to preserve, so the promise is *source*
compatibility, checked against both a symbol's signature and its `docs/spec/`
documented behavior.

## Key design decisions

| Decision | Rationale |
|---|---|
| Header-only core library | Zero build-system friction; include and use. The core stays headers only; core-cpp's static modules are built with it, and only the optional frontends, client and Qt transport are compiled. |
| Mostly-header core library | Templates and the macro-sensitive core headers stay in headers, so consumers compile them under their own configuration; what does not depend on that is compiled once into `morph::morph`, a static library. core-cpp's static modules are built with it, as are the optional frontends, client and Qt transport. |
| core-cpp for timers, base64 and wakeup | One implementation shared with the other Contour Terminal projects, including a WebAssembly subset whose host-driven loop runs `TimeoutScheduler` on the browser's main thread. |
| Per-topic public namespaces with per-topic `detail::` | Minimal public surface — callers see only what they need; internals are clearly walled off. |
| A strand per `ModelId` | Parallelism across models; serial within one model — model authors write single-threaded code. |
Expand Down
17 changes: 10 additions & 7 deletions docs/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
- **[core-cpp](https://github.com/contour-terminal/core-cpp) 0.7**, fetched
through CPM. morph's timers run on its event loop, coroutines build on its
`Task<T>`, and `morph::net` takes its base64 and wakeup primitive from it.
morph itself is header-only, but `core::base`, `core::net` and
`core::platform` are static libraries, so a project that links
`morph::morph` is a static library (templates and the macro-sensitive core
headers stay in headers), and `core::base`, `core::net` and
`core::platform` are static libraries too, so a project that links
`morph::morph` builds them too.
- **Optional:** Qt 6 (WebSocket transport, Qt Quick frontend), libunicode
(terminal frontend, fetched if not installed), SQLite3 (durable offline
Expand Down Expand Up @@ -122,12 +123,14 @@ next to morph's.
target. `MORPH_INSTALL` defaults to `PROJECT_IS_TOP_LEVEL`, so a vendored morph
adds nothing to your project's install.

### A bare include path (not recommended)
### A bare include path (not supported)

`-I<repo>/include` compiles, since morph is header-only, but then nothing
supplies what the interface target would: Glaze at the pinned version, core-cpp
and its static libraries, a C++23 standard library, the thread library, and each
optional subsystem's own dependencies. Prefer `find_package`.
`-I<repo>/include` is not enough: morph::morph is a compiled static library, and
a bare include path neither links it nor supplies what the target carries: the
generated `morph/export.hpp`, Glaze at the pinned version, core-cpp and its
static libraries, a C++23 standard library, the thread library, and each
optional subsystem's own dependencies. Link `morph::morph`, through
`find_package` or `add_subdirectory`.

## API reference

Expand Down
4 changes: 2 additions & 2 deletions docs/spec/VERSIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ including a patch.

## Semantic versioning applies to source compatibility, not ABI

morph's core is **header-only**, and its optional compiled parts (the Qt
integration, the frontends, the generic client) are static libraries
morph's core is a static library over headers that carry its templates, and its optional
compiled parts (the Qt integration, the frontends, the generic client) are static libraries
([ARCHITECTURE.md](../ARCHITECTURE.md)): there is no shared-object ABI to
preserve, and none is promised — every consumer recompiles against the
headers on every release. What semantic versioning
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/core/profiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ that turns it, under that thread's own name.

## One definition everywhere

morph is header-only, so these macros change the bodies of inline functions.
These macros change the bodies of inline functions, and most of morph is templates and inline functions in headers.
A program in which one translation unit is compiled with
`MORPH_TRACY_ENABLED` and another without it holds two definitions of the same
inline function — an ODR violation the linker resolves by keeping one,
Expand Down
6 changes: 3 additions & 3 deletions docs/spec/ui/document.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The UI document — design

Design spec for the UI document's C++ model and its load-time validation
(`include/morph/ui/document.hpp`), and for the typed values every document expression evaluates to
(`include/morph/ui/document.hpp`, loaded by `src/ui/document.cpp`), and for the typed values every document expression evaluates to
(`include/morph/ui/value.hpp`). A server defines a screen as a JSON document (spec 5,
`docs/superpowers/specs/2026-10-07-ui-document-design.md`); `ui::loadDocument` parses it into a
`ui::Document` and refuses it, with the JSON Pointer and the reason, when it breaks a rule of
Expand Down Expand Up @@ -249,8 +249,8 @@ box, any layout key a sheet sizes itself without) are in [`document_page.md`](do
A `DocNode` is a node or a structured part of one. Its properties stay keyed by their document
keys — `props` (expressions), `events` (command lists, a custom node's events as `on.<event>`),
`children` (node lists), `parts` (records such as columns and tabs), `names` (plain strings) and
`keys` — so the interpreter reads a kind's properties by name. One table in `document.hpp`
(`detail::kKinds`) says, per kind, which keys it has and what shape each takes; it is the only
`keys` — so the interpreter reads a kind's properties by name. One table in `src/ui/document.cpp`
(`kKinds`, reached through `detail::findKind`) says, per kind, which keys it has and what shape each takes; it is the only
place a kind is described.

**Every node** takes `id`, `visible`, `enabled` (conditions), `tooltip`, `sizing`, `span`,
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/ui/expressions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Expressions (`expr/1`) — design

Design spec for the expression language of the UI document (`include/morph/ui/expression.hpp`) and
Design spec for the expression language of the UI document (`include/morph/ui/expression.hpp`, implemented in `src/ui/expression.cpp`) and
the MessageFormat 2 subset its `t` reads (`include/morph/ui/message.hpp`). Every bound property,
query body, condition and command argument of a document is an expression: a JSON tree that
`parseExpression` reads into an immutable `ui::Expr`, `checkExpression` checks against the
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/ui/refusals.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ application's, in its catalogues.
|---|---|
| `include/morph/core/action_refusal.hpp` | `morph::model::RefusalArg`, `morph::model::ActionRefusal` |
| `include/morph/core/wire.hpp` | the `err` envelope's `refusal` member (`wire::RefusalBody`), `wire::executeFailure` |
| `include/morph/ui/expression.hpp` | the `refusal` form, `t` with a key expression, the `refusalText` function |
| `include/morph/ui/expression.hpp`, `src/ui/expression.cpp` | the `refusal` form, `t` with a key expression, the `refusalText` function |
| `include/morph/ui/author.hpp` | `refusal()` on query and mutation handles, `tAt`, `refusalText` |

## Contents
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/ui/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ ids to `reloadDocuments` with the shown screen and reports each refusal as a pro
nothing polls, and the digest is read once per connection, by the `open` that loaded the bundle.

**In every build.** The reload is compiled into every client and runs only in development mode; nothing in the build
turns it on or off. The library functions above are header-only and are emitted only where a client calls them.
turns it on or off. The library functions above live in the `morph` library, and a client links them only where it calls them.

## Not yet
- **Several vocabulary versions of one screen.** There is one vocabulary version, `ui/1`; the registry keeps one
Expand Down
Loading
Loading