# Editor, code and environments

> The development workspace of the Product group. Edit your product with a live preview and the assistant, browse the repository on the Code page, and see what runs where on the Environments page.

Source: https://orkosi.com/docs/editor

The **Product** group of the left bar has five pages. **Preview** shows your product as visitors see it and lets you change text and point at things on the page: see [Visual edits](https://orkosi.com/docs/visual-edits). **Product health** checks your live site: see [Product health and launch](https://orkosi.com/docs/product-health). This guide covers the other three: **Code editor**, the workspace where you change the product with a live preview and an assistant, **Code**, where you browse the repository, and **Environments**, where you see what runs in production and in development.

| Page           | Who can open it         |
| -------------- | ----------------------- |
| Preview        | Every role              |
| Code editor    | Owner, admin and member |
| Code           | Every role              |
| Environments   | Every role              |
| Product health | Every role              |

## Product › Code editor
![The development workspace: the assistant on the left, the live preview of the product on the right and the top bar with the branch and the Deploy button](https://orkosi.com/docs-img/editor.webp)

**Product › Code editor** opens the editor on the full screen. **Back to dashboard**, in the top bar, returns to the workspace. If you have changes that are not saved, the editor asks before you leave.

### Edit mode and Code mode
The switch in the top bar chooses between two modes.

- **Edit**: change the text on the page directly in the preview. For a product that has no web page, the editor says so and sends you to Code.
- **Code**: the full editor with files, code, console, preview and assistant.

In Code mode, four buttons in the top bar show and hide the panels: **Files & tools**, **Console**, **Preview** and **Assistant**.

### Where your changes go: the working branch
The branch your development site deploys from is not changed directly by default. On your first change of a session the editor asks **Where should these changes go?**

| Choice                   | What it means                                                                                                                                                                                |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| New branch (recommended) | Your edits stay on their own branch and reach the development branch through a pull request that the checks of the product run on. The shared development site is untouched until it merges. |
| Directly to the branch   | Every save becomes a commit on the development branch and the development site rebuilds. Fastest to share, with no safety net.                                                               |

Tick **Remember for this product** to stop being asked. You can change the choice later from the branch menu in the top bar, which also switches between branches and creates new ones.

### Saving
Next to the branch, the top bar shows the state of your work: the number of unsaved files, **Saving…** while a save is written, **Saved** afterwards, or **Read-only** on the production branch, which is not changed from the editor. A save is a commit on your working branch.

### The assistant
Describe a change in plain words in the assistant panel.

- **Small edits come back as a diff.** You see the changed lines per file. Tick the files you want and press **Accept & commit**, or reject the change. Nothing is written to your code before you accept.
- **Bigger work becomes a task** for the agents. The row under the message box shows the tier that task would run on and its estimate before you send. It appears under **Tasks & agents** in the editor and on [Home › Tasks](https://orkosi.com/docs/tasks).
- The assistant remembers the conversation, reads the errors of the preview by itself, and asks when a request can be read two ways. It can also generate images and video for the site.
- **Point at a file** adds a file to your message so the assistant knows where to look.
- If the assistant could not answer, it says so: nothing was changed and nothing was charged.

The tier picker offers **Quick**, **Standard**, **Quality** and **Premium**, limited to the tiers of your plan. Chat and tasks use credits: see [Billing and credits](https://orkosi.com/docs/billing#costs).

### The live preview
The preview shows the branch you are working on and updates as you type. Its header names the branch and commit it is serving.

- **Show deployed site** switches from the live preview to the deployed development site. **Show live** switches back.
- **Reload preview** and **Open in new tab** are in the same header.
- When the last deploy failed, the header says so and points at the console.

### Files, search, Git, tasks and tools
The **Files & tools** panel has five tabs.

| Tab             | What it is for                                                                                                               |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Files           | The file tree. Open, create, rename, move and delete files.                                                                  |
| Search in files | Find text across the project, and replace it.                                                                                |
| Git             | The branches and the saved versions of the branch you are on, with the option to restore one.                                |
| Tasks & agents  | The tasks that are running for this product and its agents.                                                                  |
| Tools           | **Secrets and settings**: the secret values the product needs. See also [Config vars](https://orkosi.com/docs/hosting-operations#config-vars). |

### The console
| Tab      | What it shows                                                                               |
| -------- | ------------------------------------------------------------------------------------------- |
| Build    | The output of the build that follows a commit.                                              |
| Runtime  | The logs of the running development environment, with a filter.                             |
| Terminal | One command at a time, run in the preview workspace of the product. It is not a full shell. |

### Undo and restore
- After a change by the assistant, **Go back to before this change** returns the files to the version before it. The editor first shows what would change and asks you to confirm.
- The **Git** tab lists the saved versions of your branch. **Restore this version** works on a branch you can change from the editor. For the branch the site deploys from, work on your own branch and deploy.

### Propose to dev and Deploy
Two buttons in the top bar move your work forward.

1. **Propose to dev** opens a pull request from your working branch to the development branch. The button then shows the number of the pull request and the state of its checks. When it has merged, the development site rebuilds with your change, and the button reads **Propose again** for the next round.
2. **Deploy** opens **Deploy to production**. It merges the development branch into the production branch and deploys the production environment. The dialog follows the build and tells you when it is done.

If the two branches conflict, the dialog says so. Ask the assistant to resolve the conflict as a task, then deploy again. If the production environment is not set up yet, deploy is unavailable and the dialog says so.

Deploying is also possible from **Hosting › Deploys**, with rollback. See the [deployment guide](https://orkosi.com/docs/deploy-guide#promote).

## Product › Code
![The Code page: the repository name and branch, the clone command and the tabs Files, Branches, Commits, Issues and Pull requests](https://orkosi.com/docs-img/code.webp)

**Product › Code** is a read view of the repository of your product. Every role can open it.

### Where the repository lives
The code of a product that Orkosi created is kept in a **private GitHub repository inside the platform's GitHub organisation**, one repository per product. It is created during setup. It is not a repository on your own GitHub account, which is why a plain link to it answers "not found" until you have been given access. A product started with [Bring your code](https://orkosi.com/docs/bring-your-code#what-changes) from GitHub is different: it keeps using your repository.

The header of the page shows the repository name, the branch shown and its latest commit, and a `git clone` command with **Copy**.

### Get access on GitHub
1. Open **Settings › Profile** and find the GitHub section.
2. Press **Connect** and sign in to GitHub when it asks.
3. You become a collaborator on every product repository of your workspaces, and on new ones as they are created.

By default the access lets you read the repository and work with its issues and pull requests. It does not let you push directly: code reaches the product through the editor, tasks and pull requests. **Disconnect** in the same section removes the access. Leaving a workspace removes it for the repositories of that workspace.

Once connected, **Open repository** on the Code page opens it on GitHub. Before that, the button reads **Connect GitHub to view**.

### The five tabs
| Tab           | What it shows                                                                                   |
| ------------- | ----------------------------------------------------------------------------------------------- |
| Files         | The folders and files of the branch shown. Click a file to read it.                             |
| Branches      | Every branch, with the default one marked. Pick one to show it on the page.                     |
| Commits       | The history of the branch: what changed, when and by whom.                                      |
| Issues        | The issues of the repository.                                                                   |
| Pull requests | The open and closed pull requests, with their checks. An open one can be merged with **Merge**. |

**Open in editor** opens **Product › Code editor** on the branch you picked. Merging a pull request changes the product, so it is not for viewers.

## Environments: what runs where
**Product › Environments** answers one question: what runs where. Every role can open it.

A product has two environments. **Production** is the site your visitors use. **Development** is the test copy where changes land first. How they relate is explained in the [deployment guide](https://orkosi.com/docs/deploy-guide#environments).

### The two cards
Each environment has a card with:

- **Status**: whether it is live and healthy, or failed.
- **Address**: the address it answers on. **Open** opens it in a new tab.
- **Last deploy**: when it was last deployed.
- **Version**: the short id of the commit it runs.
- **Hosting**: a link to the page where the two environments are managed. See [Hosting](https://orkosi.com/docs/hosting-operations#hosting). The addresses are on **Hosting › Domains**: see [Custom domains](https://orkosi.com/docs/custom-domains).

### Pending changes
The **Deployments** card compares the two environments in one line:

- **Development is ahead of production**: changes are waiting to go live.
- **Production and development run the same version**: nothing is waiting.

Under it are the latest deployments of both environments, each with its status, its version, what started it and how long it took. **View all** opens **Hosting › Deploys**.

### Promote and roll back
- **Promote to production** opens **Hosting › Deploys**, where you publish what is in development. The steps are in the [deployment guide](https://orkosi.com/docs/deploy-guide#promote).
- **Rollback**, on a deployment in the list, returns that environment to its previous release. It asks you to confirm first. See [Rolling back](https://orkosi.com/docs/deploy-guide#rollback).

Promoting and rolling back change what your visitors see, so they are not for viewers.

## When something goes wrong
| What you see                                 | What to do                                                                                                              |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| The preview shows an error                   | Open the **Console**. The assistant also offers to fix the error the preview is showing.                                |
| Live preview failed                          | Press the retry in the preview header, or use **Show deployed site** meanwhile.                                         |
| The top bar says **Read-only**               | You are on the production branch, which the editor does not change. Switch to your working branch from the branch menu. |
| The pull request shows failed checks         | Open it from the top bar to read which check failed, fix the change and save again.                                     |
| Deploy reports a conflict                    | Ask the assistant to resolve the conflict as a task, then deploy again.                                                 |
| A repository link on GitHub says "not found" | Connect your GitHub account in **Settings › Profile**. See [Get access on GitHub](#github-access).                      |
| The Code page has no repository yet          | The repository is created during setup. Open **Settings › Setup** to see where setup stands.                            |
