app.contract is the root of the app: 942 lines holding the routes, the single App component, and every resource, mutation and task of every package. Its first line states why: "Routes, tabs, and every resource/mutation (Exact allows them only here)".
Why everything lives in the root
In Contract a child component declares no resource, mutation or task. The Exact compiler refuses it with type-child-resource (contract-for-agents.md). So package contracts such as read.contract hold only shapes, pure functions and view components, and the root declares the data and passes it down as props, with actions passed as action props. The cost is one large shared file. Ownership blocks keep it editable by several authors.
Section map
Lines | Section | What it holds |
|---|---|---|
Header | The ownership rule | |
Imports |
| |
| Rewrites a | |
|
| |
| Four tab routes and 21 routes beneath them. See Navigation | |
| The reply of the hidden crypto parity resource | |
|
| |
Package declarations | One | |
Shared actions |
| |
Package actions | One | |
| Values injected into read's components | |
View: route switch | One screen call per route | |
View: tab bar | Four |
Shared state
Three declarations are used by every package (lines 76-78):
Name | Kind | Meaning |
|---|---|---|
| state, | The Seed site the app reads and publishes to. Default |
| state, | Account id of the selected identity, |
| resource | Host clock facts. Wall time is always |
Declarations per package
Each block is described in a child page, with one line per state, derive, resource, mutation and task:
Block | Lines | Page |
|---|---|---|
| ||
| ||
|
Actions
Three shared actions come first: pick(name) selects a tab, follow(url) goes to a location scoped to the reader's server, back pops. Then each package has an actions block: read 281-327, discuss 328-365, activity 366-415, agents 416-550, me 551-669, profile 670-686, vault 688-733. Actions are the only place that writes state, sends a mutation (send m = source(...)), refreshes a resource, or reads the clock. Each package's actions are listed on its screens page, for example Agents screens.
Provide
The provide block is owned by discuss. It exposes discussions, discussNow, discussUtc, readNow and readUtc so that read's DocDiscussionSlot and row components can inject them without the root threading them through DocScreen props. The two now values are time.epochAtZero + readTick, the minute clock.
The view
The root node is main navigationKey=... navigationBack="back" navigate=follow testId="app" accent-color="brand". Inside it, a for t in nav.tabs loop draws one role="tabpanel" per tab, and a for e in t.stack loop draws every entry of that tab's stack. A chain of if e.name == "..." picks the screen component and binds its props to root state and actions. Screens of covered entries stay mounted, which is why screens take eid and often active. The tab bar follows.
In this section
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime