# Workspace folder (.lightair)

Source: https://docs.lightair.app/developers/formats/workspace

> The files inside a .lightair workspace folder, the journal that saves every change, the format version, and the copies Lightair makes to move a show.

In short:
- A workspace is a folder ending in `.lightair`, holding plain JSON files, one per scene, and a journal of changes.
- `workspace.json` is the manifest: it carries `formatVersion` (2 today), the canvases, the scene order and the scene on air.
- Every change is appended to `journal/current.log` and folded into the JSON files about once a minute. There is no Save button.
- Stream keys and passwords are never in these files; they stay in the system's credential store.

In the app: File › New Workspace…; File › Open Workspace…; File › Export Workspace with Packages…

A workspace is one show: its canvases, sources, scenes, audio, outputs and the packages it uses. On
disk it's a folder whose name ends in `.lightair`. New workspaces go in the **Workspaces** folder:

| Platform | Folder |
|---|---|
| macOS | `~/Library/Application Support/Lightair/Workspaces/` |
| Windows | `%APPDATA%\Lightair\Workspaces\` |

**File › Open Workspace…** opens a `.lightair` folder from anywhere.

## The files

```text
My Show.lightair/
├─ workspace.json        the manifest: format version, id, name, canvases, scene order
├─ sources.json          every source: cameras, captures, images, browsers, widgets…
├─ audio.json            the mixer's tracks and their effects
├─ mixer.json            buses, mixes and the master
├─ outputs.json          recording and streaming settings (no secrets)
├─ scenes/<id>.json      one file per scene
├─ journal/current.log   changes since the files were last written
├─ assets/               prefabs, images, video and sound kept with the show
├─ packages.json         the packages the show needs
├─ packages-lock.json    the exact version and checksum of each
├─ edits/<id>.json       projects made in the Editor
├─ checkouts.json        takes being edited on a paired phone or tablet
└─ recordings/
   ├─ index.json         the Library's list of recordings, takes, clips and exports
   └─ thumbnails/        a still for each
```

Every file is JSON. A workspace needs `workspace.json`, `sources.json` and a scene file for each
id the manifest lists; Lightair reads a missing `audio.json`, `mixer.json` or `outputs.json` as
the defaults.
The other files and folders appear once the show needs them.

Every entity (the workspace, canvases, sources, scenes, objects, tracks) has a UUIDv7 `id`. Files
refer to each other by id, never by name, so renaming anything breaks nothing.

### workspace.json

The manifest. It's written last when Lightair saves, so the scene files it lists are always
complete.

```json
{
  "formatVersion": 2,
  "id": "0193a2c4-5e1f-7b3a-9c2d-4f8e6a1b2c3d",
  "name": "My Show",
  "canvases": [
    { "id": "0193a2c4-5e1f-7b3a-9c2d-000000000001", "name": "Landscape",
      "width": 1920, "height": 1080, "fps_num": 60, "fps_den": 1 }
  ],
  "program": "0193a2c4-5e1f-7b3a-9c2d-000000000010",
  "scenes": ["0193a2c4-5e1f-7b3a-9c2d-000000000010"],
  "transition": { "kind": "Move", "duration_ms": 500, "direction": "left" },
  "stinger": null
}
```

| Field | Meaning |
|---|---|
| `formatVersion` | The format the files are in. See [Format version](#format-version). |
| `id`, `name` | The workspace's id and name. |
| `canvases` | The output canvases, the first being the primary one: `id`, `name`, `width`, `height` and the frame rate as `fps_num` / `fps_den`. |
| `program` | The id of the scene on air. |
| `scenes` | Scene ids in the order the app lists them. Each scene's contents are in `scenes/<id>.json`. |
| `transition` | How scene switches look: `kind`, `duration_ms` and `direction`. |
| `stinger` | The stinger video the Stinger transition plays, or `null`. |
| `show` | Present when used: overlays drawn over every scene, the soundboard's pads, the rundown, PTZ cameras and the scene the Scene transition plays. |
| `journal` | Present after a save that included rotated journals (see below). |

### sources.json

An array of sources. Each has an `id`, a `name`, a `kind`, its `settings` as a JSON object in that
kind's own shape, and `effects`, the effects applied wherever the source appears. Scenes place
sources; the same source can appear in several scenes.

### scenes/&lt;id&gt;.json

One file per scene, named by its id. A scene has an `id`, a `name` and `objects`, bottom first.
Each object points at a source by id and has a layout for each canvas it appears in (a canvas
with no layout hides it there). A scene can also carry its own transitions and stinger. One file
per scene keeps changes easy to read in a diff, so a workspace works well in git.

When a scene is deleted, its file is removed at the next save.

### packages.json and packages-lock.json

Written when the show uses something from a [package](/developers/extend/packages):

- `packages.json` lists what the show needs: `{"format": 1, "packages": {"<id>": "<version range>"}}`.
  Ranges use Cargo's operators (`^1.2`, `~1.2`, `=1.2.0`, `>=1.0, <2`, `*`).
- `packages-lock.json` pins what it resolved to: for each package (and each dependency) its
  `version`, `sha256` content checksum, `source` (where it was installed from) and `size`.

When the workspace opens on another computer, Lightair uses these to say which packages are
missing and where they came from.

## How saving works

There's no Save button. Each change is a command, and every committed command is appended as one
line of JSON to `journal/current.log`.

- About once a second, what's been appended is made durable on disk.
- About once a minute, after 200 changes, and when you quit, Lightair **compacts**: it writes the
  JSON files again and empties the journal. Each file is written to a temporary file and renamed
  into place, so a crash never leaves half a file.
- To compact without blocking new changes, the journal is first renamed to `journal/<n>.log` and
  a new `current.log` starts. The manifest's `journal` field then records that the snapshot
  includes the journals up to `<n>`, and those are deleted.

When a workspace opens, Lightair reads the JSON files, then replays any journal the snapshot
doesn't include, in order. That's how a crash is recovered: nothing committed is lost and nothing
is applied twice. A last line cut short by the crash is ignored.

:::caution
Don't edit a workspace's files while it's open in Lightair. The app holds the show in memory and
overwrites the files at the next compaction.
:::

## Format version

`formatVersion` in `workspace.json` is the format the files are written in. This version of
Lightair writes and reads up to **2**.

- An older workspace is upgraded when it opens, one version at a time, and saved in the current
  format.
- A workspace from a newer Lightair is refused with the message "this workspace was saved by a
  newer Lightair (format *n*, this version reads up to 2)". Nothing in it is changed.

## Secrets

Stream keys, tokens and passwords are never written to a workspace. They live in the system's
credential store (Keychain on macOS, Credential Manager on Windows), keyed by the destination's
id. A workspace folder can be copied, shared or put in git without exposing them; on another
computer you enter them again.

## Copies of a workspace

### With its packages

**File › Export Workspace with Packages…** copies the open workspace's folder to a new
`.lightair` folder (on the Desktop unless you choose otherwise) and adds a `Packages/` folder
holding an `.airpkg` file, `<id>-<version>.airpkg`, for each package in its lock file. Opened on
another computer, the copy offers to install the packages from there, whatever has happened to
their authors' releases since.

### Portable copy

When a paired phone or tablet asks for a workspace, Lightair sends a portable copy, made fresh
each time:

- the workspace as it is now, its journal replayed into the files (the copy has no `journal/`);
- every file a setting points at outside the workspace, collected into `assets/`, the setting
  rewritten to `assets/<file>` (a second file with the same name becomes `logo 2.png`);
- no secrets: any setting whose name contains `password`, `passwd`, `passphrase`, `secret`,
  `token`, `stream_key`, `streamkey`, `api_key`, `apikey` or `auth`, or is exactly `key`, is
  removed, and so is any such parameter in a web address's query string.

Recordings, Editor projects and other files in the folder aren't part of a portable copy.

## Related

- [Studio take (.lightair-take)](/developers/formats/studio-take)
- [Packages](/developers/extend/packages)
- [File formats](/desktop/reference/file-formats)
