#Add progress to a Flow
A method can tell its caller what it is doing before its result arrives. Use complete notices for messages, replaceable activities for current work, and read-only views for a domain workspace. The application still checks its result; a count or closed update stream never establishes success.
#Before you start
Use the greeting project from your first Flow. This tutorial adds one notice before returning the same greeting. Progress describes activity. The final result still determines the outcome.
#Add a notice to the greeting
From the project root, copy the installed reporting agreement:
The importer copies exact descriptor bytes and their license without running code or approving work. It refuses an existing destination.
Create flows/hello/FLOW.contract.json with this optional output port:
If that descriptor already exists, add the port without removing its other declarations.
The name updates is local. The whole Flow needs no named invocation contract.
Replace flows/hello/FLOW.ts:
Review the changed source, then run it:
The writer sends one complete reporting notice and closes before returning the result.
An absent observer needs no publication.
Only LAGGED and DISCONNECTED degrade optional observation.
Cancellation and unexpected failures still propagate.
The network flag permits dependency preparation under the usual conditions.
An authored lock can avoid fresh resolution.
Expect the notice on stderr and the greeting result on stdout.
A suitable terminal displays the notice in Jig's workspace.
The invocation still reports status succeeded, outcome done, and output.message containing "Welcome, Ada!".
The short method may finish before a transient activity would be visible.
Change the notice text, then review and run again.
Use --updates off to run without automatic observation.
The result remains available in either case.
If dependency preparation fails, use dependency troubleshooting. For publication or execution failures, use Troubleshooting before deciding on further work. A closed update stream does not establish successful execution or cleanup.
Other hosts can copy the same agreement and its license from the standard library. Direct delivery is the default. Broadcast is an ordinary channel choice. Managed TypeSpec source can borrow the exact descriptor without rebuilding its meaning.
#Use the source reporting helpers
The remaining helper examples describe repository source APIs.
@jigging/reporting is not currently published on npm.
They are not additional installation steps for the greeting above.
To build the TypeScript library, follow the repository's development setup. From that checkout's root, run:
The package's README describes its public exports and agreement. Use built source libraries through a captured workspace dependency. Use a supported Bun lock format when preparing that workspace. This source workflow does not establish a published release or host qualification.
The independent Python helper implements the same reporting agreement for compatible FLOW hosts.
Jig currently runs FLOW.ts and FLOW.md, rather than FLOW.py.
Python library availability does not establish Jig runtime support.
#Publish within the handler
Keep the method's work and checks inside one scope:
Here checkProposal() is the application's existing procedure returning its
Run result. The scope validates offers, bounds queues, paces publication, and
settles its operations before returning. It owns that writer exclusively; do
not independently send, close, transfer, or wrap it again. Running without an
observer is allowed.
Invalid offers still throw when unwired, and offers after scope exit are errors.
Python uses its independently packaged jiggy-reporting helper with the
same descriptor and meanings:
notice(text, severity?) is one complete message; multiline content is allowed.
Use info (default), warning or error to report importance. For example,
reporter.notice("Could not start the AI session.", "error") in TypeScript or
reporter.notice("Could not start the AI session.", severity="error") in Python.
Jig prominently labels attributed Flow-reported errors. Severity does not change
ordering, quotas, optional delivery or execution authority. Offer blocking failures
promptly and retain their reasons in final results independently of observation.
activity(id, label, progress?, {detail?, operationId?}) replaces the complete slot.
The optional detail explains the current procedure; an own-call operation ID
links to host-observed execution without inventing a call or changing its status.
That association stays fixed until clear(id). When moving a shared activity slot
to another call, clear it first or give the new activity its own ID.
Progress has required
completed, optional total, and optional unit, for example
{completed: 3, total: 8, unit: 'files'} in TypeScript. Counts may decrease or
change units; omitted progress removes the old count. clear(id) is idempotent.
Every source ending removes all its transient activities without decorating them
as successful. Keep essential warnings and outcome evidence in results/artifacts.
Local publication limits, 500 ms send wait or 4000 ms final drain expiry stop optional observation; original send and close operations still settle, so cleanup can take longer. Known observer loss may degrade. Unexpected publisher errors and root cancellation remain failures. A body error stays primary with a bounded secondary diagnostic. See exact bounds and lifecycle.
#Observe the work
After reviewing the changed source, ordinary jig run automatically displays
exactly one optional canonical output on stderr. Suitable terminals default to the
TUI workspace with the actual invocation tree and application views; other terminals
use plain output. Complete notices retain Flow attribution. Plain or redirected
stderr shows meaningful label, title and summary changes without repeating counts.
Stdout remains the ordinary final result. --updates off disables automatic
observation; --json also disables it, while host diagnostics remain available.
Explicit --receive updates exposes the existing selected-channel stdout
presentation or JSON/NDJSON. It takes precedence even when supplied by the approved
project entrypoint; --updates off does not cancel that explicit choice. Multiple
canonical ports get one hint instead of a guess. Unsupported contracts remain
ordinary optional channels. NO_COLOR and TERM=dumb alter style, not selection.
Use jig run --display tui for a terminal workspace. Activity collects
current work and the newest notices first. Setup stages expand from one entry.
Execution shows actual calls, opening active or problematic branches and
collapsing returned branches.
You can expand them to see their calls. Your application page composes its
summary and authored sections, retaining records and evidence. Routine
activity history stays collapsed, while attributed causes remain visible
across tabs. ! opens their full explanation, d opens attributed diagnostic
text, and ? shows contextual help.
Diagnostic text with no structured severity stays unclassified.
Give each child call a short, descriptive intent in run.call(...); Execution
uses that supplied label. Without it, the graph shows the reviewed slot name.
Enter on a call shows its original operation ID and host lifecycle.
The terminal renderer is included with Jig. Flows supply semantic reports, facts, counts and collections. They do not import a UI library or choose terminal widgets. Your root landing view is the application's main page.
Execution, Activity, Delivered files and child views sit together under Inspector. Publish the same root view as your application advances or stops, using a separate presentation module to turn domain state into sections. Keep each child Flow's own view useful when that Flow is invoked directly. Large terminals show a navigation rail.
v opens the complete view chooser at any size. Compact tables keep records
together. A context pane appears on wide screens only when it adds
information. Enter expands full details.
Tab changes views. Arrows/j/k select records. c selects a collection. /
edits its filter and s changes sorting.
Filter text is literal: Enter applies it and Escape discards the draft. r
explicitly selects a reference. Enter then opens the chosen record, call or
verified immutable file preview. When the selected entry has one distinct
artifact reference, its available content is previewed directly.
Multiple references still require a choice. Delivered files lists captured evidence independently of application views. Select a file to read its text or patch. Size and capture limits stay secondary.
Brackets/Page keys scroll details. Escape returns from a local panel or record/call reference jump, and stays at the top level. q asks before leaving, with Stay selected. Confirmed live exit continues work inline.
Ctrl-C requests cancellation and waits for cleanup. After execution, cleanup and delivery settle, result inspection is read-only. It stays open until you confirm leaving with q or keyboard Ctrl-C, subject to any explicit enclosing command limit. Initial input, review, file and runtime refusals stay in ordinary output. The workspace opens only once root execution begins.
Leaving restores your terminal and prints retained essential causes before the
final result. --display plain selects nonanimated presentation. --json or
effective --receive keeps exact existing output and takes precedence over
the dashboard. The workspace needs terminal input/stderr and at least 18
columns/4 rows.
Smaller terminals release to plain output. Normal panes need 50 columns/14
rows. Ordinary jig run selects TUI when input and both output streams are
suitable terminals. Otherwise it uses ordinary output.
NO_COLOR keeps TUI controls without color. Activity is bounded session history. Omission is disclosed, and result evidence remains separate. Use saved-result inspection to reopen a packet after the dashboard closes, without starting another Run.
Use jig run --display web for the same semantic views in a browser. Jig prints
a private local link after execution starts; open that link yourself. Each tab
keeps its own selection, filters and expanded evidence. Activity, Execution,
domain views, diagnostics and delivered file contents remain available after
settlement until you choose Close inspection. That action closes all viewers
of this command; during execution, work continues in the ordinary transcript.
Closing a browser tab alone does not close inspection or cancel work. Terminal
q/Escape also leaves when Jig owns terminal input; live Ctrl-C still cancels work.
Web needs terminal stderr but accepts piped stdin and redirected Run stdout.
--json and --receive keep their ordinary machine behavior and take precedence.
--updates off leaves host observations and files available without receiving
application views. Reload by opening the original terminal link; the browser
does not retain its private access capability in storage. Keep the link private.
See the local access and lifetime contract.
#Give a Flow its own workspace
One declaration and one full snapshot are enough:
Use report, facts, explicit count progress, captured content and typed collection blocks.
Compose your domain helper from ordinary records and pure projection functions.
No terminal code or host adapter is needed. Python exposes the same reporter.view(id, options) handle
with update(snapshot) and retire().
Every update replaces the whole view atomically. Stable collection/row IDs preserve selection. Keep essential conclusions in the result and files: optional updates can stop, and frozen views show when their observation ended. A handle owns its ID for the scope, and retired IDs cannot be reused. At most eight views per publisher are retained.
Only one view may offer a landing hint. The root hint selects the initial surface until the operator chooses.
A target separates the reusable definition from its application instance.
For another document set, keep definitionId: 'document-review' and choose another stable instanceKey.
Use a shared subjectKey when different view definitions describe the same application subject.
These keys help navigation without merging views or changing the actual publisher's identity.
Target, landing hint and call association remain fixed during a view's lifetime.
Authors offer complete snapshots as state changes.
The publisher coalesces superseded updates across views and activities while preserving notice, clear and retirement boundaries.
A view supports up to 1,024 rows and 8,192 cells within its encoded byte bound.
Use previewCollection when an explicit bounded excerpt better serves the task.
Its whole rows and shown, total and omitted counts preserve the distinction between retained data and complete data.
Typed references address a current same-publisher record, an actual own call, or a declared file.
For example, {kind: 'call', operationId: 'check-lease'} names this publisher's operation.
{kind: 'artifact', attachment: 'deliverables', path: 'draft.txt'} names verified delivered output.
{kind: 'input-artifact', attachment: 'source', path: 'scan.jpg'} instead names an exact captured input member.
Missing targets remain visibly unavailable, and child-only files require explicit remapping through the parent.
References never execute work, apply a patch, open an external program or grant authority.
Previews and full downloads read immutable captured bytes even if original inputs or delivered destinations later change. Captured input remains distinct from verified delivery and recorded captures. A clipped preview never substitutes for a complete file download. The web display contract defines media bounds, generation checks and Close behavior.
#Show captured media and literal detail
A gallery gives ordinary columns explicit presentation roles:
Every field and supplied row detail remains inspectable.
A content block can feature one captured item with {kind: 'content', reference, title}.
Reports accept format: 'plain', format: 'code' or format: 'diff' to preserve intended literal reading.
These declarations add no markup, browser component or execution callback.
A view may simply present information when its application needs no action.
#Retain an explicit final edition
Live updates remain optional observations.
Use the same application projections in a final display bundle when the application needs retained views.
The TypeScript and Python helpers derive target revision checks from supplied publication context.
Write the encoded bundle through an ordinary declared output.
The operator selects it with --display-bundle NAME=FILE.
Jig accepts the selected edition atomically after verified final delivery.
It never substitutes the last live snapshot or publishes checkpoint-only material as final.
The application owns aggregation and domain state, while each child publisher keeps its original attribution.
Retained views can be read with jig views independently of execution history.
For software consumers, use --receive updates --json, parse complete stdout
lines as JSON, and keep stderr separate. Read begin, ordered data, end, then
terminal. Only terminal.result reports the Run outcome. A disconnected stream
or missing terminal is incomplete delivery. Live reporting has no retention or replay.
Run Checkpoint separately retains settled artifacts.
A simpler string channel with explicit reception remains useful when messages alone suffice. Raw authors must own validation, optional error handling and cleanup themselves. The profile's shared replacement/count meaning is useful when callers need current activity state across implementations; it is not required for every log or output.
#Connect methods while they work
A parent can create a channel and pass its endpoints to exact child slots.
Each child reads its declared endpoints from run.channels. Endpoint transfer
and the child result remain separate operations; await the actual child outcome
rather than treating stream completion as success.
Use a direct channel when one consumer needs the data. Use broadcast only when independent consumers genuinely need the same stream:
Here eventSchema is the application's FLOW Schema/0 item schema. This excerpt
allocates endpoints only: the handler must connect the sender, consume or close
each subscription, and settle owned work. Subscribe before dispatch to receive
the beginning. A slow subscription can fail with LAGGED independently of other
consumers. Later subscriptions receive a suffix, without replay.
Two direct channels can support requests and replies. Named contracts establish item meaning; application code checks correlation and bounds. Each participant owns one writer. Reply EOF alone does not establish completed work.
See the channel specification and SDK endpoint lifecycle for exact transfer, disposal, and cancellation behavior.
#Observe an Agent directly
When a supported native client supplies public updates, a Flow can connect the
Agent capability's optional events writer to a channel using the
public update contract. Filter events inside the Flow
before displaying them; preserve spacing when joining text fragments.
Final-only API clients do not provide this stream.
Observation never authorizes a follow-up turn or changes the Agent's powers. Settle both the observer and the capability call. Add this capability when live Agent output is the lesson you need; application phases often suffice.