Skip to content

Editor

Editor Architecture

The editor is three static libraries, a small hooks archive and one executable under engine/src/editor and editor/: conjure_editor_core (alias conjure::editor_core: commands, undo, the newline-delimited JSON protocol over TCP, stdio and the loopback, the dispatcher, play mode, picking, screenshots, the headless runner, themes, user settings, editor_application), conjure_editor_kit (alias conjure::editor_kit: the Widget Kit every panel and module panel draws with) and conjure_editor_ui (alias conjure::editor_ui: the Dear ImGui docking workspace, the panels, the property drawers, the ImGuizmo gizmos), plus conjure_editor_kit_hooks (ImGui's four test-engine hooks, linked into the ImGui target's interface) and editor/src/main.cpp. The libraries are declared from engine/CMakeLists.txt (editor is the last entry of CONJURE_ENGINE_MODULES), join conjure_shared and are absent from Distribution; conjure_editor links conjure::shared and nothing else from the engine. Like conjure_runtime, the executable reads its arguments as UTF-8 (editor/src/editor_arguments.h, the Windows backend re-reads the wide command line) and on Windows embeds an activeCodePage UTF-8 manifest (editor/src/conjure_editor.manifest), so a project path outside the legacy code page survives; it keeps the console subsystem in every configuration it is built in, and its run path is its own directory, where conjure_shared sits. This chapter is for people changing the editor or adding commands and panels.

See engine/src/editor/README.md for additional implementation notes.

Breakdown

Shape of the module

engine/src/editor/CMakeLists.txt declares, guarded by CONJURE_BUILD_EDITOR:

Target Public dependencies Private dependencies
conjure_editor_kit_hooks conjure::platform_defines ImGui's include directories and definitions only; declared whenever the ImGui target exists, which links it as an interface dependency
editor_core conjure::core, conjure::ecs, conjure::platform, conjure::assets, conjure::scene, conjure::modules, conjure::engine the renderer and rhi, physics, scripting and bindings when built; on Windows ws2_32, shell32, ole32 and uuid
editor_kit conjure::editor_core conjure::thirdparty::imgui, conjure::editor_kit_hooks
editor_ui conjure::editor_core, conjure::editor_kit conjure::thirdparty::imgui, conjure::thirdparty::editor_fonts, the renderer and scripting when built; declared only when the ImGui target exists

editor_core never includes ImGui or a socket header in a public header, and the kit never sees editor_context. Two file pairs are platform-specific, both chosen by CMake: core/net/socket_win32.cpp / socket_posix.cpp and core/user_paths_windows.cpp / user_paths_posix.cpp (the per-user state folder of Project trust). The built-in themes (core/themes/*.conjure-theme.json) and the kit's built-in icons (kit/icons/*.svg) are embedded at build time into generated sources in the build tree, so the files are the one copy of their values.

Area Files 📘 Wiki page
process object editor_application, editor_options, headless_runner, project_trust; private user_paths Headless mode and the command model, The AI control protocol
user configuration user_settings (editor_settings.json), editor_ui_host (the hook the UI registers) Headless mode and the command model
play-mode persist persist_list, play_edit_log (with play_controller) The AI control protocol
themes theme, theme_library, private core/theme_colour_math and core/builtin_theme_data.h, core/themes/, core/commands/commands_theme.cpp; in the UI ui/theme_applier, ui/panels/theme_editor_panel Themes, Fonts and code ligatures
services editor_context, undo_stack, selection_set, play_controller, picker, screenshot_service, editor_camera, console_buffer, event_broadcaster Headless mode and the command model
command model command_dispatcher, command_registry, editor_command, builtin_commands, schema_validator, entity_ref, reflection_path, core/commands/* (one file per group), core/component_access.{h,cpp} same
module records command_desc, panel_desc, kit_panel_desc (with kit_icon_desc and kit_drawer_desc), editor_module_consumer same
protocol protocol/protocol_message, protocol_server, protocol_transport, loopback_transport, line_splitter, access_token, audit_log; private stdio_transport, tcp_transport, net/socket The AI control protocol, Access tokens and the audit log
widget kit kit/ (conjure_editor_kit), the hooks archive conjure_editor_kit_hooks; in the UI the Widget gallery ui/panels/widget_gallery_panel The widget kit
workspace ui/editor_layer, editor_workspace (with editor_workspace_layout.cpp and editor_workspace_menus.cpp), editor_panel, property_drawer, gizmo_controller, hierarchy_cache, imgui_frame_scope, ui/start_screen, ui/status_bar, ui/panels/*; private ui_common, ui_forms, project_flow, scene_picture, scene_overlays, module_compat, display_text.h The workspace UI, The toolbar and the status bar
editor_error.h, log_category.h protocol_error_code (23 codes besides NONE), LOG_EDITOR not user-facing

How a command runs

  1. A transport yields a line; protocol_server::poll parses it (PARSE_ERROR, INVALID_REQUEST, MESSAGE_TOO_LARGE answered at once) and caps requests per frame, carrying the backlog over. line_splitter frames the bytes with the 16 MiB limit and reports an oversized line as a marker; the server marks the client closing on MESSAGE_TOO_LARGE, on a failed token handshake and on a first line that is not a request (The gate). After a client's first request a line that is not valid UTF-8 is a PARSE_ERROR that keeps the client connected; the robustness tests verify this behaviour.
  2. command_dispatcher::dispatch: unknown name -> UNKNOWN_COMMAND with didYouMean (none for a name over 128 bytes, whose edit distance would stall the frame; the message quotes at most 128 bytes, cut on a code point boundary); required_access(flags) above what the client was granted -> UNAUTHORISED (Scoped tokens); the compiled JSON schema (schema_validator: type, properties, required, additionalProperties, enum, items, bounds) -> INVALID_ARGS naming the path; REQUIRES_PROJECT, REQUIRES_SCENE, EDITING_ONLY, PLAYING_ONLY -> the matching code before the handler runs. Missing files answer one way everywhere: handlers build the error with support::unusable_path(path, reason) for a path on disk (PATH_NOT_FOUND when nothing is there, IO_ERROR when something is but cannot be read) and support::read_failure(path, error) for a failed read through the virtual file system; classify_error maps core NOT_FOUND and engine PROJECT_NOT_FOUND to PATH_NOT_FOUND. ASSET_NOT_FOUND is kept for an asset reference that names no asset. A new command that reads a file uses the two helpers instead of choosing a code itself; one that hands a registered asset to the importer looks at the source first (asset.reimport), because an import failure carries no code and would come out as INVALID_ARGS.
  3. The handler returns a command_outcome: result, inverse (mandatory for MUTATES without NO_UNDO; skipRecording for a run that changed nothing undoable), an optional normalised replay and a label. The dispatcher records undo, bumps the revision, appends revision to the result and emits scene.changed and command.executed. A mutating handler without an inverse is a logged INTERNAL error, never an abort.
  4. ASYNC handlers park an async_reply; editor_context::tick resolves completions once per frame and delivers them to the client's sink or transport; at most 8 pending per client (BUSY), the --timeout-seconds deadline on the engine clock (TIMEOUT); cancel_all answers everything pending with CANCELLED on project.open and at shutdown.
  5. editor.batch runs children atomically (inverses rolled back on failure) into one undo entry; editor.begin_transaction / end_transaction group a client's commands.

Entities cross the protocol as guids or hierarchy paths (entity_ref); component fields as reflection paths (reflection_path: alias, unique suffix or registered name, then fields and array indices) read and written through ecs::component_to_json / component_from_json and component_access (entity refs as guid strings, the alias table editor.schema publishes). component_access::write_component sends the layer component through scene::set_layer, so the editor never stores an index the scene's captures refuse.

Undo and play mode

undo_stack stores {label, undo[], redo[], coalesceKey, clientId}, depth 1024 and 256 MiB of serialised arguments (oldest evicted first); history.undo dispatches the inverses with recording suppressed. Coalescing merges consecutive single-command entries of equal key and client (inspector drags) and, inside an open transaction, consecutive records of equal key and command (one gizmo drag is one step). Inverses that restore several subtrees (entity.destroy_many) are one editor.batch whose children run in ascending sibling order. Play mode: play.start captures a scene_snapshot, freezes the stack and runs the engine; play.stop restores the snapshot byte for byte (guids preserved) and remaps the selection, its primary included (the backup names the primary last). While the stack is frozen command_dispatcher::record_outcome does not drop what a handler returned: a scene edit goes to play_controller::note_unrecorded_edit (the restore discards it), an ON_DISK command's inverse and replay go to keep_file_edit, and play_controller::stop pushes the kept ones as one undo entry, File changes during play. A batch run while playing records which child was an ON_DISK command (batch_state::fileCommands) and hands those over once it has succeeded. A new command that writes project files gets the flag only when its inverse and replay touch no scene state (prefab.apply replays as an asset.restore while playing for that reason); otherwise it is EDITING_ONLY, as prefab.create, scene.save and scene.save_as are. play.step runs exactly n fixed steps through application::step_fixed and answers once they ran, and a play.stop before then calls application::cancel_fixed_steps, because a forced step runs even while PAUSED. No play session crosses an engine restart: play.start answers BUSY while a project.open is pending, and apply_pending_project_open stops play before it shuts the old engine down. editor_context::selection_payload is the one builder of {guids, primary} (primary null for an empty selection): every selection.changed carries it through emit_selection_changed, the selection's on_changed handler and play.stop alike, and the selection.* answers add entities and count to it.

The protocol

protocol_server::start(options, projectRoot) opens TCP on first_port() (nine fallback ports when the port was not explicit; the chosen port is written to <project>/.conjure/ai_port, and editor_application::apply_pending_project_open moves the file with set_project_root when project.open switches projects) and stdio with --ai-stdio; add_transport plugs in a loopback_transport for tests. When the stdio transport reports its client closed, stdio_closed() turns true and a headless stdio-only editor (no TCP server) quits with 0. Clients are polled on the main thread (transport_kind::TCP and LOOPBACK). tcp_transport serves at most MAX_CLIENTS (8) connections: a further client is accepted, sent one BUSY line with id null (best effort) and closed. A port in a Windows excluded range (WSAEACCES) counts as busy for the fallback search (net::is_port_unavailable_error), and on POSIX every socket is close-on-exec so dotnet and cmake children never inherit the listener. The stdio reader is the one core::jobs::dedicated_thread of the process, reading 64 KiB chunks through a line_splitter whose state is shared through a shared_ptr, left blocked at exit by design. event_broadcaster fans events out with per-client subscriptions and a minimum log level; log events are shed under backlog pressure (events.dropped).

The gate: tokens and the first line

The model: a client that is let in with the full-control token has the reach of the user running the editor, so the connection is what is guarded.

Piece Where What it does
the tokens protocol_server::mToken, mInspectToken, ensure_tokens() grant access_level::FULL_CONTROL and INSPECT; generated (generate_access_token, 32 bytes of std::random_device("/dev/urandom") as 64 hex digits: named, the device is the kernel's on libstdc++, which would otherwise take RDSEED/RDRAND on x86; libc++ takes the name in its urandom, getentropy and arc4random builds; MSVC ignores it and calls rand_s) whenever one is needed and missing, that is, when a TCP transport runs or the other one was set explicitly, so a TCP transport never runs ungated; cleared again when nothing needs one
who presents one requires_token(kind) TCP always; stdio and loopback only when a token was set explicitly (--ai-token, --ai-inspect-token, set_token, set_inspect_token: gates_every_transport())
the comparison access_of(presented) -> constant_time_equals the one place a token is checked for equality: both comparisons always run; the guards that look for a token inside client text (contains_token, the audit log) use constant_time_contains / constant_time_starts_at over a bounded text, never a substring search; "" never matches, not even an empty token. The setters refuse one text for both levels
the handshake check_handshake in poll() a client with access == NONE gets in only through session.hello with one of the tokens; anything else is UNAUTHORISED once, then one INFO line with the client id alone (never the text, which may hold a token) and disconnect(); deliver_event drops events for such a client
a later hello accept_hello(clientId, presented), called by the session.hello handler sets the client's access to what the token grants (raise or lower); refuses a wrong token on a gated transport without touching the access; on an ungated transport a known token still applies and any other text is ignored; an id no transport knows is an in-process client and is trusted
the files write_session_files, write_token_files, remove_session_files <project>/.conjure/ai_token and ai_token_inspect first (core::vfs::write_private_file: 0600 on POSIX, a protected owner-only ACL on Windows, written beside the target and renamed over it), then ai_port; all follow set_project_root and go at stop()
the first line client_state::spoke in poll() a parse failure before any line of the client parsed is answered and followed by disconnect(), on every transport; the line is not logged

A token must never be logged, sent in an event, quoted in an error or written to the audit log: the UNAUTHORISED message names the files, the WARN for a token file that could not be written carries the file system's reason only, the panel prints token set and the files' paths, and session.hello checks a client name with protocol_server::contains_token before logging it. tests/editor/protocol/test_protocol_server.cpp, tests/editor/test_command_dispatcher.cpp and tests/editor/test_ai_protocol_e2e.cpp search the log, the events, the replies and the audit file for both tokens; keep that check when adding a log line here. The per-OS code is not in this module: it is the file system layer's (engine/src/core/vfs/native_platform_<os>.cpp).

Scoped tokens and the audit log

Scope. command_flags::READ_ONLY marks the commands an inspect-only client may run, and required_access(flags) in editor_command.h is the whole rule: INSPECT with the flag, FULL_CONTROL without. command_dispatcher::dispatch_internal applies it right after the name lookup, so batch children pass the same check and a refused request never reaches schema validation or a handler. The granted level is protocol_server::access_of_client(id): client_state::access for a transport client, FULL_CONTROL for an id no transport knows (the UI, --exec, an editor.exec_file task).

Adding a command: leave READ_ONLY off unless the handler changes nothing clients share and neither starts a program nor loads code. Not being a mutation is not enough (editor.quit, play.start, selection.set, view.screenshot are all non-mutating). A command that reads a file must confine the path before it may carry the flag, or it reads .conjure/ai_token for an inspect-only client; script.read is the one such command and ends inside scripts/. Then add the name to the pinned list in tests/editor/test_command_catalogue.cpp, whose fixture runner also checks that every READ_ONLY command leaves the snapshot, the selection, the camera, the play state, the revision and the history as they were.

Audit. command_dispatcher::audit hands every top-level request, and every child of a batch, to protocol_server::record_command, which drops the editor's own clients, adds the transport and the access and passes both tokens to audit_log::record as the secrets to keep out. audit_log (public header protocol/audit_log.h) formats the line, bounds it (MAX_LINE_BYTES), opens <project>/.conjure/ai_audit.log on the first record (through write_private_file, replacing a planted symbolic link, and a file already there that is_private_file refuses, with one WARN), and starts a new file, keeping one previous one, before a line would pass max_file_bytes(). protocol_server::flush flushes it once per frame. Undo inverses, redo replays and batch rollbacks go through dispatch_internal only and are not recorded. A failure to write is one WARN and no more records until the project changes; it never fails a command.

Path arguments: support::project_relative_path(context, text) is the one place that turns a path argument into an on-disk path (relative means relative to the project root). editor.exec_file, project.export, module.discover, script.reload and view.screenshot use it; a new command that takes an on-disk path must too. editor_application::run_export makes --export and --distribution absolute against the working directory first, because a command line is not a protocol client.

Frame integration and headless mode

editor_application pushes a core layer (editor-core) whose on_update calls editor_context::tick: poll transports, cancel disconnected clients' requests, resolve completions, dispatch inbound requests, tick play, screenshots and frame tasks (waits, editor.exec_file, compiles, module builds, tap releases), forward console records as log events, flush. The UI layer (editor-ui) only draws and is pushed after the engine's imgui_layer, which owns the one ImGui context. --headless runs the null platform, rhi and audio with the script runtime on the null host; view.screenshot and view.debug_draw answer NOT_AVAILABLE; script.compile and module.build spawn dotnet / cmake when present. --offscreen asks for a real device without a swapchain; the engine configuration refuses it today and the editor falls back to the null device with a warning. --exec runs a JSON array or NDJSON of requests through headless_runner (a leading UTF-8 byte order mark skipped, ${project} expanded per request to the project open at the time, --keep-going); an asynchronous request is bounded by the dispatcher's --timeout-seconds in wall time, not by a frame count, and editor.quit ends the run with its non-zero exit code. The command file is read and parsed by editor_application::initialise (headless_runner::load_command_file) after make_engine_desc checked the arguments and the project and before boot_engine starts the engine, so an unusable file is BAD_ARGUMENTS without an engine start; run_exec hands the parsed requests to headless_runner::run. A startup scene the engine could not load is kept by engine::application::startup_scene_failure(); run_requests writes it as the first output line, warning {code: "STARTUP_SCENE_FAILED", message}, through editor_application::startup_scene_warning(), and apply_pending_project_open emits the same event to every client after a restart. Neither changes the exit code. editor/src/main.cpp maps the outcome to the exit code: 0 ok, 1 a command (or --export) failed, 2 a startup or project failure (a failed initialise(), unless the arguments are at fault, which includes PROJECT_NOT_TRUSTED, or a project.open whose restart failed for both projects; a windowed editor whose --project cannot be opened starts on the start screen instead, falls_back_to_start_screen), 3 bad arguments (a bad editor flag, an option neither the editor nor the engine knows, which make_engine_desc refuses as BAD_ARGUMENTS before the merge loads the project, a flag that makes the merged configuration INVALID_CONFIG while the project alone validates, or an --exec file that is missing or does not parse), 4 a lost graphics device; a response stream that fails mid-run (--out on a full disk) also ends --exec with 2. When editor_options::stdout_carries_protocol() (--ai-stdio, --exec without --out, --export), main replaces the console log sink with one that writes every line to standard error, so standard output holds protocol lines only. --export <dir> sends project.export {directory}, plus distributionDirectory when --distribution <dir> names the folder conjure_runtime, conjure_shared, shaders/ and THIRD_PARTY_NOTICES.txt come from, with nethost.dll and the Visual C++ runtime DLLs when it holds them (the parser refuses --distribution without --export); without it the reply warns that the runtime was not copied. Export step 5 warns for a folder without the notices, for one without the runtime DLLs when the runtime imports them (Windows, Microsoft's standard library) and for debug runtime DLLs, which it leaves behind.

Project trust

Starting an engine over a project runs the project's code (modules_subsystem loads its module manifests, the scripting subsystem its game assembly), so editor_application does that only for a project somebody answered for. The pieces:

Piece Where What it does
the answers project_trust (conjure/editor/project_trust.h), owned by editor_application, reached by commands through editor_context::trust() session answers in memory; remembered answers in the trust store, read on every question, written through core::vfs::write_private_file, believed only while is_private_file holds
the key project_trust::project_key weakly_canonical(absolute(root)) as UTF-8 with forward slashes; an error (and therefore untrusted) for an empty, unresolvable or non-UTF-8 path
the gate editor_application::require_trusted, called by initialise, request_open_project and apply_pending_project_open PROJECT_NOT_TRUSTED; the last caller drops the restart with a WARN before the running engine is touched
who can be asked editor_application::can_ask_about_trust(options) a window without --exec and --export: initialise then boots without the project and raises the prompt; every other session fails
the startup decision editor_application::resolve_startup_project -> plan_startup static, no engine: open --project, leave it out as unanswered, or PROJECT_NOT_TRUSTED; plan_startup builds the one engine description initialise boots from, over the project let through and no other, so the windowed branch is tested headless
the prompt editor_context::raise_trust_prompt / trust_prompt / close_trust_prompt_for, drawn by editor_workspace::draw_trust_prompt context state that survives rebind; closed by project.trust for that project, by its opening (bind_engine) and by Don't open (dismiss_trust_prompt); the dialog's buttons are Trust and open and Don't open, Escape answers Don't open, and nothing acts behind it: the global shortcuts wait while it is up
the commands commands_project.cpp: project.trust, project.revoke_trust, project.trust_state, and the trust project.create records the first two are NOT_IN_BATCH and need full control, the third is READ_ONLY; load_project gives project.trust the path errors of project.open
the store's place default_trust_store_file() over user_state_directory() (core/user_paths_*.cpp); posix_user_state_directory in core/user_paths.cpp is the POSIX rule as a plain function, compiled and tested on every host only editor/src/main.cpp calls it; a library user that names no file remembers nothing

A new way to open a project must go through require_trusted, and a new command must not record trust as a side effect: project.create is the one exception, and only for a folder it made itself. Nothing of an untrusted project is read except project.json, which is data (make_engine_desc parses it to tell a missing project from an untrusted one). There is no restricted mode because modules_subsystem loads every manifest project::module_manifests() finds and has no switch for it.

User configuration

Per-user preferences live in <user config>/editor_settings.json, never in a project: the active theme, the recent projects, the UI scale and the code ligatures switch (conjure/editor/user_settings.h). editor_application resolves the folder (--user-config, else platform::user_config_directory()) and loads the settings once, when it creates the context; every change is an atomic read-modify-write of the file, because several editors may share it. The UI reaches core through editor_ui_host: the UI layer registers itself with editor_context::set_ui_host while attached, rebind forgets it, and editor.layout.reset answers NOT_AVAILABLE without a host (and PROJECT_NOT_OPEN without a project, since the start screen has no layout). The folder and the settings survive rebind. User settings has the details, and Startup order gives where the settings are loaded and the start-screen fall-back.

Play-mode persist

play_controller owns the play session's pins (persist_list) and its edit log (play_edit_log). play.persist, play.unpersist and play.persisted edit and list the pins; play.stop reads the pinned values before the snapshot restore and applies them after it as one undo entry, built from existing commands only so undo and redo replay it. The UI pins through play_controller directly, as UI state that never moves the scene revision. Play-mode persist and the play edit log describes the model, and Play-mode persist in the UI the inspector's pins, the hierarchy's markers and the Persist panel.

Themes

A theme is data: conjure/editor/theme.h parses a .conjure-theme.json with every problem reported by its member path (a member that fails keeps the base theme's value, so the result is always complete; unknown members are refused), serialises every member, and validates the readability rules with the private core/theme_colour_math (WCAG luminance and contrast, CIELAB, CIEDE2000), which also holds pull_back_mix, the step-down search behind readable_mix, the derived optional roles and the kit's disabled tokens. The six built-ins are the files core/themes/*.conjure-theme.json; core/themes/embed_builtin_themes.cmake writes them into builtin_theme_data.cpp in the build tree at build time, and builtin_themes() parses them once, thread-safely, with Midnight first as the base the others fall back to.

theme_library (conjure/editor/theme_library.h) lists the built-ins and the user themes of <user config>/themes, each with its problems (one that cannot be read, parsed or validated, or that takes a name already taken, is listed and never applied), and resolves the active theme: the requested one when valid, its last valid version while its file is broken, otherwise Midnight with one WARN. revision() moves whenever the active theme changes. editor_context owns the library across rebind, points it at the user folder and lists the folder every THEME_WATCH_INTERVAL_TICKS (30) ticks in tick(), reloading only when a name, size or write time changed. sync_themes() requests user_settings().activeTheme and, when the revision moved, emits theme.changed {active} and calls editor_ui_host::request_theme_refresh(). core/commands/commands_theme.cpp holds editor.theme.list, get, set, save and delete, and editor.preferences.get and set: per-user UI state, never MUTATES. editor.theme.set checks the name first and then answers NOT_AVAILABLE without a UI host; the others work headless. How the UI applies a theme is described in Themes in the UI.

The widget kit

Every editor surface and every module panel draws with conjure_editor_kit, which wraps Dear ImGui for the rest of the editor: tokens resolved from the theme, ten type roles baked into ImGui's font atlas with Fira Code's ligatures, vector icons, the painter, widget_scope, and the controls, fields, containers, popups and data views. It depends on editor_core for the theme and never on editor_context. editor_layer owns its kit_context and makes it current while the workspace draws. ImGui is built with IMGUI_ENABLE_TEST_ENGINE, so the kit's four test-engine hooks live in the archive conjure_editor_kit_hooks, which the ImGui target links as an interface dependency: every link that holds ImGui resolves them, the engine and renderer tests included. tools/check_style.py's kit-only rule keeps ImGui out of every other editor source. Widget Kit describes all of it.

The workspace

conjure_editor_ui draws the window: the menu bar, the toolbar, the docked panels and the status bar, or the start screen while no project is open. editor_layer is the engine layer that draws it inside the frame the engine's imgui_layer opened, and owns the kit context, the theme applier and the editor_workspace. The workspace keeps the layout in <project>/.conjure/editor_layout.ini through the project's file system and builds the default layout when the file has none. The Scene and Game panels draw the editor and game cameras into render targets of their own through the private ui/scene_picture, because the editor presents no scene camera to the back buffer. Panels own only UI state and submit commands through the dispatcher as the UI client, and are destroyed by editor_layer::on_detach, before the renderer goes. editor_layer::on_attach also sets the window icon from ui/editor_icon (the logo's PNGs, generated into ui/editor_icon_data.cpp); the Branding and Application Icons chapter covers the icon end to end. User Interface describes the shell, the panels, the pictures, persist and themes in the UI.

Modules

editor_module_consumer attaches the extension points of loaded modules: editor.command (command_desc), the kit's editor.kit_panel, editor.kit_icon and editor.kit_drawer (conjure/editor/kit_panel_desc.h), and the legacy editor.panel (panel_desc). Commands enter the registry with owner = <module> and MUTATES | NO_UNDO (a module command cannot return an inverse). Each UI record is copied at attach, its texts into strings of its own; panels enter the workspace through sync_module_panels, and icons the kit's registry through editor_layer. A module whose panels use the legacy record is told once at each attach, in an INFO, that they draw in COMPAT and that the record is deprecated. The consumer vetoes unloads while playing and strips every record on detach; after any attach or detach the workspace makes every module panel again from the consumer's records, because a full reload detaches and attaches in one call and the same owner and title then carry the draw function of the new binary. The engine loads its static modules before the editor exists and the module manager refuses a new consumer while anything is loaded, so editor_context::install_module_consumer unloads, adds the consumer and loads again (see Open items).

Open items

Off-screen rendering (--offscreen, view.screenshot with pixels) has its renderer view hook (renderer::submit_view) but still needs an engine configuration that allows a real backend without a window. The game reads mouse positions relative to the editor window, not to the Game panel, because platform input has no viewport offset. A pre-load consumer hook on modules_subsystem would remove the unload / load dance of install_module_consumer; a public importer_registry accessor on asset_database would replace the importer inference of reflection.asset_types; scene::root_index_of and an id-independent ecs::world_hash would simplify entity.restore and the restore comparisons.

Threading Model

Main thread only, except the stdio reader thread and the screenshot encode job: a capture is taken on the main thread and encoded and written on a core::jobs job that posts the completion back (screenshot_service); without a job system the encode runs inline. A JPEG XL screenshot (a .jxl path or "format": "jxl") is encoded inside that job by renderer::encode_jpeg_xl, which spreads libjxl's work over the same job system (waiting from a job is safe) and writes the same bytes with or without workers. Sockets are non-blocking and polled on main.

The theme folder watch lists the folder on the main thread inside tick(), with no job and no file watcher thread. builtin_themes() and the widget kit's catalogue are the process-wide constant state; the built-in themes are parsed once, thread-safely. The UI draws inside the frame of the engine's imgui_layer, on the main thread, and rebuilds the font atlas only outside that frame (Threading Model of the widget kit).

Extension Points

  • Commands: a command_descriptor in core/commands/<group>.cpp with a JSON schema, flags and a handler returning command_outcome (plus a fixture under tests/editor/data/commands/<name>.json); modules add command_desc records.
  • Panels: an editor_panel subclass drawn with the widget kit and listed in the workspace's built-in panel table; modules add kit_panel_desc records, and the legacy panel_desc record, which receives the raw ImGui context, is deprecated (Extension Points of the widget kit).
  • Property drawers: property_drawer_registry::set(kind, drawer); modules add kit_drawer_desc records.
  • Built-in themes: a core/themes/<name>.conjure-theme.json file listing every member, added to CONJURE_EDITOR_THEME_FILES in engine/src/editor/CMakeLists.txt (Midnight stays first) and to the expected names of test_theme.cpp; it must pass validate_theme.
  • Screenshot backends: screenshot_backend (memory_screenshot_backend for tests, the renderer backend over a scene_view and read_back): begin when the request is accepted, prepare_frame on every frame it waits, frame_rendered to tell the service a frame was drawn, capture, and abandon when the engine restarts or shuts down under a waiting request (the renderer may be gone, so nothing may be destroyed through it).
  • Transports: a protocol_transport implementation added through protocol_server::add_transport.

Testing

tests/editor/ (conjure_editor_tests, label editor): one test_<header>.cpp per public header of the three libraries, the command catalogue fixtures under tests/editor/data/commands/ (test_command_catalogue.cpp runs the inverse round trip of every mutating command; a fixture's expectWithoutRenderer replaces expect and expectAnyOf in a build without the renderer, and error.messageContains requires a part of the error message), test_batch_command, the per-area command files, test_protocol_robustness (the corpus of broken lines), test_ai_protocol_e2e (a loopback session), test_headless_runner, test_ai_builds_grid_sweeper (the Grid Sweeper command file, also the integration scenario tests/integration/test_ai_protocol_e2e.cpp), the UI panels drawn inside imgui_frame_scope on the null rhi, the widget kit's tests under tests/editor/kit/ (Testing of the widget kit), and test_editor_process (label process, excluded from the default presets) spawning the real conjure_editor --headless --exec. A case whose name carries [slow] gets the label slow from the same side file of tests/editor/CMakeLists.txt, so only the nightly presets run it. Every undoable fixture must change the snapshot (the serialised scene and the project files) before its undo round trip counts; a fixture whose effect the snapshot cannot see (an empty folder) says "expectChange": false with a _comment naming the case that checks it instead. editor_test_support.h provides headless_editor (a headless editor_application over a scratch project with an in-process client and a scratch --user-config folder of its own, send / ok / fail, snapshots for the inverse round trips), loopback_session (a client of that editor on a loopback transport: the one to use when the token handshake, the scope of a token or the audit log matter, because the in-process client is the editor's own and always has full control), read_json_lines (the audit log as parsed records), write_project (a project written by hand, which the editor does not trust by itself), the fixture file format and the LOOPBACK_TCP precondition probe. Project trust in tests: headless_editor starts with trustProject set and no trust store, so nothing a case trusts is remembered anywhere; a case that opens a second hand-written project calls headless_editor::trust_project first (one made with project.create in a new folder is trusted already), and the process cases pass --trust-store <scratch file> so the real executable never reads or writes the store of whoever runs the tests. docs/generated/editor_protocol.json is the editor.schema dump; regenerate it with conjure_editor_tests --conjure-update-golden when the catalogue changes.

python tools/build.py --build-dir build/mod_editor --target conjure_editor_tests --test -R editor