Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

uji.jobs

A command the model runs can keep going in the background while you talk to the model. A command becomes a background job in one of three ways:

  • The model sets run_in_background on run_command, which suits dev servers and watch builds.
  • A command still running at its timeout moves to the background instead of stopping. The timeout is 120 seconds unless the model gives its own. A command that starts with sleep stops at its timeout instead.
  • You press Ctrl+Z while the command runs, and the model’s turn carries on at once.

While jobs run, the status line counts them, and the list under the input stays out of the way until you open it. When a job ends, uji shows a notice and tells the model the exit code and the last lines of output. If no turn is running, uji starts one so the model can react; otherwise the report goes with the next turn. A job that you or the model stop starts no turn.

The model reads a job’s output with the job_output tool and stops it with stop_job. /jobs opens a list under the input, running ones first, with a title that counts them and a hint that names the keys. Tapping the count on the status line opens the same list, and tapping it again closes it; typing or Esc closes it too.

The list shows five jobs at a time and names the rest. It picks the first job: Enter opens its output, ↑ and ↓ pick another, and x stops a running job or drops a finished one. Dropping the last job closes the list.

A background job stops after 30 minutes, or after the timeout the model gives with run_in_background, and never runs longer than two hours. At most 8 jobs run in the background at once. Esc stops the turn and its foreground command, and leaves background jobs running. Quitting, /reload, or closing the terminal stops them all. Stopping a job also stops every process it started, such as the server a dev server command launches.

uji.jobs.list()

Returns one table per background job, oldest first, with these fields:

FieldMeaning
idThe job’s number, which the model uses with job_output and stop_job.
commandThe shell command.
staterunning, finished, stopped or timed out.
codeThe exit code, once the job ends.
statusA short description, such as "running for 42s" or "finished, exit 0".
tailThe last lines of output.

uji.jobs.stop(id)

Stops a running job and returns true. Returns false when no job with that id is running.

uji.jobs.show()

Opens the jobs list under the input, running ones first and then the newest, and picks the first. Running it again closes the list. /jobs runs this, and it notices when there are no jobs at all.

uji.jobs.configure(opts)

OptionMeaningDefault
wakeStart a turn when a job ends and no turn is running.true
maxThe most jobs that run in the background at once.8
limitSeconds a background job may run when the model gives no timeout.1800
uji.jobs.configure({ wake = false, limit = 3600 })

Raises an error for an unknown option, a wake that is not true or false, and a max or limit that is not a number above 0.