Skip to content
flow

ConfigurationRun providers

Run providers

Add entries to the New tab launcher's Run column with a command that prints JSON, and learn the environment, output format, timeouts and failures.

View as Markdown
On this page

The New tab launcher lists commands you can start in one keystroke. Static entries come from the run key of your .flowspace.json files. A run provider adds entries dynamically: a command you register that prints JSON, run each time the launcher opens. Use one to offer every just recipe, mise task or package.json script without listing them by hand.

Where run entries appear

The launcher opens on a tile strip's "+" or ⌘T while Settings › General › Tabs › New tab (tabs.new_tab) is Ask, the default. Under its tab-type tiles it shows:

  • Run: commands that open in a new terminal tab, titled by their label. ⌥1–⌥9 launch the first nine visible rows. The static run entries come first, then each provider's rows. The column's caption names the file or provider each row came from.
  • Web: docs pages, then pages you visited recently (this repository's first). This column needs the Web tabs experiment (features.web_tabs).

Type in the launcher's field to filter rows by label, command or URL. ↑ / ↓ select a row and ↩ launches it.

Register a provider

Add a run_providers entry to any flowspace file: a checked-in .flowspace.json, your ~/.flow/repo_config/REPO/flowspace.json, or ~/.flow/flowspace.json for every repository.

json
{ "run_providers": [{ "name": "just", "command": "~/bin/just-flow" }] }
FieldMeaning
nameShown in the Run column's caption and in error rows. When two files register the same name (compared without surrounding spaces), the earlier file wins.
commandA shell command line.

Providers from several files run side by side; see Settings scopes for the file order.

When providers run

Flow runs every provider each time a launcher opens, and again when its session's directory changes while it shows. Each run:

  • happens in the background, so the launcher never waits on it;
  • is $SHELL -lc COMMAND, with the session's directory as the working directory;
  • gets its own process group, killed after 5 seconds. Once the shell exits, anything still running in that group is killed too: don't leave work in the background. Whatever reached stdout by then is the output.

Results are cached per directory. Sessions on remote hosts never run providers.

Environment

A provider gets your usual environment plus:

VariableValue
FLOW_RUN_CONTRACT1, this contract's version
FLOW_CWDthe session's directory
FLOW_REPO_ROOTthe git work-tree top of that directory, when there is one
FLOW_BRANCHthe current branch, when known
FLOW_PRthe branch's pull request number, when known
FLOW_SESSIONthe session's title
FLOW_HOSTthe ssh destination of a remote session (never set in practice, since remote sessions run no providers)

Output format

Print one JSON object on stdout, at most 1 MiB:

json
{
  "version": 1,
  "run": [
    { "label": "Build", "command": "just build", "detail": "release" }
  ],
  "docs": [
    { "label": "Runbook", "url": "https://wiki.example.com/runbook" }
  ]
}
  • version is required and must be 1.
  • run and docs are optional and take the same entry shapes as the flowspace keys: {label, command, cwd?, detail?} and {label, url}.
  • A relative cwd is relative to the session's directory; a leading ~/ is your home directory.
  • Unknown keys are ignored, and a malformed entry is skipped.
  • stderr is ignored unless the provider fails.

Example provider

A provider that offers every just recipe in the session's directory:

sh
#!/bin/sh
# ~/bin/just-flow: list just recipes for the Flow launcher.
[ "$FLOW_RUN_CONTRACT" = 1 ] || exit 2
cd "$FLOW_CWD" || exit 1
command -v just >/dev/null || { echo '{"version":1}'; exit 0; }
just --summary 2>/dev/null | tr ' ' '\n' | awk '
  BEGIN { printf "{\"version\":1,\"run\":[" }
  NF { printf "%s{\"label\":\"%s\",\"command\":\"just %s\"}", sep, $0, $0; sep = "," }
  END { print "]}" }'

Make it executable (chmod +x ~/bin/just-flow), register it as shown above, then press ⌘T in a repository with a justfile.

Failures

A provider that fails shows as one dim row in the Run column, reading NAME: REASON. That row can't be selected or launched, and the other providers and static entries are unaffected.

FailureReason shown
The shell could not be startedcould not start: …
It ran past 5 seconds (it is killed)timed out after 5s
A non-zero exitexit status N, plus its first stderr line
Nothing on stdoutprinted nothing
More than 1 MiB on stdoutoutput over 1 MiB
Not JSON, or not an objectbad JSON / not a JSON object
version missing or not 1missing version / unsupported version N

Limits

  • Remote sessions run no providers and read only ~/.flow/flowspace.json; their run entries run in the session's own terminal on the host.
  • A session on a paired device lists only the static run entries of that device's checkout, never its providers.
  • docs entries, from a file or a provider, only show while the Web tabs experiment is on.
Sources

Written from these files in the Flow app repo

  • docs/run-providers.md
  • src/run_config.rs
  • src/new_tab.rs
  • src/launcher_ui.rs