Page:
Components and Contracts
Pages
AI Use Disclosure
Adding Things
Architecture
Author
Background Worker
Code Layout
Command Line Modes
Common Pieces
Components and Contracts
Configuration
Database
Dev Login
Discord
Features
Frontend Layout
Frontend
Home
Installation
Logging
Look and Feel
Notifications
Performance Principles
Roadmap
Running
SSO Flow
Security
Static Data
Swap Lifecycle
Swarm Cache
Token Refresh and Caching
Updating
No results
2
Components and Contracts
Nate edited this page 2026-11-21 20:21:39 -08:00
Table of contents
Components and contracts
Components are Go partials
Reusable UI is a shared template with a documented data shape,
rendered by the server: templates/fit_workbench.html is the
model (the simulator and the read-only public copies render the
same markup). The shared set is listed in pageSharedTemplates
(core_pages.go).
Before building a new pattern, check whether a partial already
does it; before changing a partial, check every page that
renders it.
Two registries are single sources of truth, and tests hold them to it:
- Navigation:
sectionNavin nav.go drives the sidebar menus AND the section tab strip. The quick-jump palette in app.js (quickJumpPages) must carry the same labels:TestQuickJumpPagesMatchNavfails otherwise. - Home widgets: the module manifest (module_manifest.go) and the overview registry (home_overview.go) define each widget's id, title, default size and layer. A widget renders through the home template by id; its body comes from stored data.
Server → JS contracts
- Data reaches JS as
data-*attributes for small facts and as a JSON payload for structured state (the planner). The contract lives on the Go DTO: invariants are written there (planner payload lists are never null: they are coerced inplanFinishPreset, because Go nil slices marshal tonulland plan.js dereferences them) and mirrored in the JS, which normalizes defensively in one place (setPayload). - Mirror each payload's shape as a JSDoc
@typedefin the JS file that consumes it. Editors light up, no toolchain needed. - When a contract changes, the Go DTO comment, the typedef and the tests change in the same commit.