Repository navigation
Desktop
The desktop app is a thin Tauri 2 shell around the same window, with the engine frozen by PyInstaller as formchem-engine. On macOS the engine ships as a folder inside the app (FormChem.app/Contents/Resources/engine); on Linux and Windows it is a one-file sidecar. The shell shows a splash, starts the engine with FORMCHEM_PORT=0 and FORMCHEM_PORT_PREFER=8221, reads the real port from the engine, reveals the window when the page is ready, and stops the engine on exit.
| Source path | What lives there |
|---|---|
src-tauri/src/main.rs |
Engine start, single instance, files handed over from the system, the windows (overlay title bar on macOS, clipboard access), the updater commands, printing, the formai:// deep link, stopping the engine on exit |
src-tauri/src/engine_start.rs |
The waits for the engine (90 s for its address, 10 s for the window key), the start-up failure sentences, the data folder and the engine log path |
src-tauri/src/reveal.rs |
The splash: its rounded corners and the reveal of the main window once the page is ready |
src-tauri/src/traffic_lights.rs |
The macOS overlay title bar with the traffic lights inset, kept in place on resize, focus and theme changes |
src-tauri/src/win_job.rs |
The Windows job object that ends the engine with the app |
src-tauri/src/packaged.rs |
Finds the engine folder: ../Resources/engine/formchem-engine in the app bundle, or engine/formchem-engine beside the program under tauri dev; without it the shell starts the sidecar |
src-tauri/tauri.conf.json |
Identity ai.nodemode.formchem, the splash window, bundle targets, externalBin, the file associations, the updater endpoint and the formai deep link scheme |
src-tauri/tauri.macos.conf.json |
macOS only: no externalBin, and the engine folder src-tauri/engine shipped as the resource engine
|
src-tauri/tauri.windows.conf.json |
Windows only: the notices and the two document .ico files as resources, and the NSIS installer hook |
src-tauri/Info.plist |
macOS: the document types with their icons (CFBundleDocumentTypes) and FormChem's two exported types |
src-tauri/linux/ |
formchem.desktop (the desktop entry, Exec with %U) and ai.nodemode.formchem.xml (the MIME package), installed by the .deb and .rpm
|
src-tauri/windows/hooks.nsh |
Points the FormChem Document and FormChem Database classes at their document icons after the NSIS install |
src-tauri/icons/documents/ |
The .fchem and .fcdb document icons: PNG 16 to 512, .ico and .icns, made by assets/icon_src/build.py
|
src-tauri/capabilities/ |
Window permissions |
src-tauri/flatpak/ |
The Flatpak manifest (it installs the MIME package and document icons from the deb) and ai.nodemode.formchem.metainfo.xml
|
frontend/src/app/system-open.ts |
The window's side of opening files: reads the files the shell hands over and opens them as File > Open does |
setup/freeze_backend |
PyInstaller build of backend/formchem_engine.py: on macOS a one-folder build copied to src-tauri/engine, flattened and checked; elsewhere a one-file sidecar named formchem-engine-<target triple>
|
setup/lib.sh |
fc_engine_folder, fc_flatten_engine and fc_sign_engine, shared by freeze_backend and build_app
|
build_app, build_app.bat
|
Freeze the engine and build the desktop bundle on this machine |
Before 0.7.0 the engine was one file on every system. A one-file engine unpacks itself (RDKit, Indigo, numpy and Python: several hundred megabytes and hundreds of libraries) into a new temporary folder at every launch, and macOS checks every unpacked library again each time, which is why the owner's Mac took about 30 seconds to open the app. On macOS the engine now ships already unpacked, so nothing is unpacked at launch. Measured on Linux, where the same freeze was timed: the engine reaches its address in 0.46 s from source, 1.5 s frozen as one file and 0.55 s frozen as a folder. The splash stays at least 2.6 s from launch (the family value, running alongside the engine start), so the expected open time on a Mac is about 3 seconds. This has not been measured on a Mac yet.
The one-folder build must be flattened before Tauri can carry it as a resource: every symbolic link is replaced by a copy, and _internal/Python.framework by a plain _internal/Python (the folder grows from about 314 to 426 MB). When APPLE_SIGNING_IDENTITY is set, PyInstaller signs with it and fc_sign_engine signs every Mach-O file left unsigned. ./formchem desktop check fails on macOS if src-tauri/engine has no program, a symbolic link or a .framework, and ./formchem clean removes the folder. On macOS cargo check, cargo build and tauri dev need the folder to exist; ./formchem desktop dev freezes first when it is missing. Linux and Windows keep the one-file sidecar for now (Linux packages put resources in another place than the program, and neither could be bundled and tested for this version).
- The engine is called
formchem-engineeverywhere: the sidecar name inexternalBinand inmain.rs, and the program inside the macOS engine folder. - The macOS engine folder holds no symbolic links and no
.framework. - The title bar on macOS is the overlay style: the traffic lights sit over the window's own title bar, which carries
data-tauri-drag-region. - The updater reads
https://dl.formai.studio/formchem/updates/latest.json; the public key in the repository stays empty, because formcompiler holds the key pair. - Nothing GPL goes into the frozen engine.
- Signing identities are held by formcompiler; local builds are unsigned.
Run it from source with ./formchem desktop dev; ./formchem desktop build makes a local bundle. Released builds come only from formcompiler (see Releasing).
./build_app (or build_app.bat on Windows) builds the desktop app from a fresh checkout in one step and writes everything it does to build_app.log. In order it checks and prepares:
| Step | What it checks or does |
|---|---|
| System | macOS: the Xcode Command Line Tools; Linux: WebKitGTK 4.1 and the build packages |
| Python | 3.12 or newer (it tries python3.14, python3.13, python3.12, then python3); an older venv is recreated |
| Node.js | 20.19 or newer |
| Rust | rustc and cargo from the same install (rustup expected), building for this machine's architecture |
| Notices |
THIRD-PARTY-NOTICES.txt must exist (python3 setup/notices.py after ./formchem install) |
| Engine packages |
backend/requirements*.txt into backend/venv, reinstalled when the files or Python change |
| Window packages |
npm ci in frontend/, rerun when package-lock.json or Node change |
| Tauri CLI |
frontend/node_modules/.bin/tauri must exist, and its major.minor must equal the tauri crate's in src-tauri/Cargo.lock; each @tauri-apps/plugin-* package must share major.minor with its tauri-plugin-* crate |
| Build | the window (npm run build), the engine frozen by PyInstaller with the window, the notices, the template library and the whole backend/app/data folder at app/data (on macOS as a flattened one-folder in src-tauri/engine, signed when APPLE_SIGNING_IDENTITY is set; elsewhere as one file), a --selfcheck of the frozen engine, then the Tauri bundle (.app and .dmg on macOS, .deb, .rpm or AppImage on Linux) |
The Tauri CLI pin. @tauri-apps/cli is a dev dependency in frontend/package.json, pinned at 2.12.6 because the tauri crate in Cargo.lock is 2.12.7: the CLI's major.minor must always equal the crate's, so a crate update to 2.13 needs the CLI at 2.13 in the same change. Before 0.6.0 package.json did not list the CLI at all and the build stopped with "the Tauri CLI did not install"; the message now names package.json. With the pin, the owner's ./build_app on macOS (Apple silicon, Python 3.14) built the app. ./formchem desktop check runs the same version comparison without building.
--reinstall reinstalls both package sets, --clean removes earlier build output (including src-tauri/engine), --bundles picks the bundle kinds and --config merges an extra Tauri config (formcompiler's contract mode).
-
Saving exports. The window shows the system's save dialog (a folder dialog for Each structure) and asks the engine to write the file through
POST /api/files/write, because the webview cannot write files itself; the engine writes outside your home folder only where you chose the place in the dialog. -
Printing goes through the shell's
print_windowcommand, because the macOS webview ignores the page's own print call. - Clipboard. The windows may read and write the clipboard from the page (WebKitGTK on Linux and WebView2 on Windows need this for Edit > Paste). On macOS, Cut, Copy, Paste and Select All in the system Edit menu are the system's own items, so they reach the drawing as well as text fields.
- Menus. The macOS menu bar is built from the same menu definitions as the in-window menus, so Scale, Grid, Dark Page, Export, Copy As and Paste Special appear there too. In the window, menus that do not fit beside the title fold into More menus.
-
Opening files from the system. A file passed on the command line (Linux and Windows), handed over by macOS (
RunEvent::Opened) or sent to a second copy of the app (the single-instance plugin, which hands it over and exits) goes to the running window, which opens it as File > Open does: a drawing or structure file as a drawing, a spectrum as a drawing with the spectrum, an.fcdbin the database workspace. Relative paths are taken from the folder the app was started in andfile://links become paths. The shell accepts the 30 extensions File > Open accepts. Before 0.13.0 the window never read what the shell handed over, so nothing opened. -
The data folder inside the app. From 0.13.0 the frozen engine carries all of
backend/app/dataatapp/data, where each service finds its data relative to its own file. The 0.10.0 to 0.12.0 desktop builds carried only the templates, so Structure from Name knew no common names and HELM failed there. A new data file underbackend/app/dataships without any change to the build scripts. -
Deep links. The shell registers
formai://(on Linux at each start), which the other Form apps use to send a live structure back for editing (Live Structures). -
When the engine does not start. The shell waits 90 s for the engine's address and 10 s more for the window key, then shows a dialog with one sentence for the reason (the engine program is missing, another engine holds the data folder (exit code 2), it stopped with a code, or a wait ran out), the engine's last 12 lines and the path of its log,
[data folder]/Logs/formchem-engine.log. An engine whose error output goes nowhere (the windowed Windows build) writes it toformchem-engine-errors.logbeside the log instead. -
Updates. Help > Check for Updates... asks
dl.formai.studio; Preferences > Network can make it ask at every start. A local build has an empty updater key and says it cannot check.
bundle.fileAssociations in tauri.conf.json lists twelve entries. FormChem's own types are Editor: .fchem (application/x-formchem, UTI ai.nodemode.formchem.document) and .fcdb (application/x-formchem-database, UTI ai.nodemode.formchem.database). The others are Viewer with rank Alternate, so FormChem appears in Open With and never takes them from their owner: .mol, .sdf, .rxn, .cdxml, .cdx, .smi, .pdb, .cif, .mmcif, and .jdx with .jcamp. .helm is not associated (FormChem reads HELM notation in a dialog, not HELM files); .dx and .ent open when handed over but are not associated. Keep OPENABLE in main.rs, OPEN_EXTENSIONS in frontend/src/app/documents.ts, the associations, Info.plist and the MIME package in step.
| Platform | Open With and double-click | Document icons for .fchem and .fcdb
|
|---|---|---|
macOS (.app, .dmg) |
From the generated CFBundleDocumentTypes; files arrive as RunEvent::Opened
|
Yes: Tauri 2 has no icon field on an association, so Info.plist (merged over the generated keys) carries the document types with CFBundleTypeIconFile and the exported types with UTTypeIconFile, and tauri.macos.conf.json ships fchem.icns and fcdb.icns
|
Linux .deb and .rpm
|
The desktop entry lists the twelve MIME types and x-scheme-handler/formai; Exec=formchem %U passes the file; the MIME package defines the types, .fchem and .fcdb also by content |
Yes: hicolor mimetypes icons named ai.nodemode.formchem.document and ai.nodemode.formchem.database, picked up by the shared-mime-info and icon cache triggers |
| Linux AppImage | Only through a desktop integration tool that reads its desktop entry | No: an AppImage cannot install a MIME package or icons itself |
| Linux Flatpak | The manifest installs the MIME package from the deb; the metainfo lists the types for software centres | Yes: the icons are installed under the app-id names, the only names Flatpak exports |
Windows .exe (NSIS) |
Registered by Tauri's installer for each association | Yes: windows/hooks.nsh repoints the FormChem Document and FormChem Database classes at the shipped .ico files after install |
Windows .msi
|
Registered by Tauri's WiX template | No: the template has no association icon and no hook, so the files show the app icon |
What has been run: the Linux deb, rpm and AppImage of 0.13.0 were built, and the unpacked deb under Xvfb opened an .fchem, .mol files given by relative path and as file://, an .fcdb, a .pdb and a .jdx, both at launch and sent to the running app; update-mime-database and gio info typed every sample. The macOS and Windows paths and the Flatpak were read against Tauri's templates and not built.
The owner's ./build_app built the app on macOS (Apple silicon) for 0.6.0; running a built app on macOS or Windows (the dialogs, native menus, overlay title bar, file associations, document icons, deep links and the start time) has not been reported on for any release up to 0.13.0.
FormChem
- Home
- Manual
- Getting Started
- Drawing
- Grid and Page
- Annotations
- Reactions
- Templates
- Printing and pages
- Keyboard Shortcuts
- Stereo and Queries
- Analysis
- Names
- Spectra and NMR
- 3D
- Databases
- Lab Notebook
- Biopolymers
- Live Structures
- Accessibility
- Formats and Export
- Clipboard
- Command Line
- Agents
- Agent Activity
- Terminal
- Extensions
- Project Format
- Architecture
- Desktop
- Troubleshooting
- Development
- Releasing
Documents