---
title: "Built-in Editor & Terminal Drawer"
source: "https://edawise.com/docs/gui/editor-and-terminal/"
---

# Built-in Editor & Terminal Drawer

`deccy-gui` includes an embedded code editor for inspecting and modifying claimed files, rationale prose, and store settings, along with a collapsible bottom drawer housing a live PTY shell (`Terminal`) and the CLI action log (`Outputs`).

---

## Built-in Code Editor

When you open a file for editing, the built-in code editor replaces the center graph pane while keeping the toolbar, right inspector rail, and bottom drawer available. No external `$EDITOR` or `$VISUAL` process is launched.

### Ways to Open a File in the Editor

1. **From `Details` → `Claims`**: Left-click any claim path, or right-click a claim path and choose `open in editor`.
2. **From `Rationale`**: Click the right-aligned `edit` button at the top of the `Rationale` tab.
3. **From a Graph Card**: Right-click a card and choose `open claims in editor` (opens the first claimed file) or `open rationale in editor`.
4. **From Settings (`⌘,`)**: Click `open settings.json` in the settings dialog (creates `.deccy/settings.json` first if it does not exist).

Opening a file sets a `editing <path>` toast in the feedback bar and focuses the editor buffer.

### Editor Header & Controls

At the top of the editor pane is a `30px` header bar containing:

- **Buffer State Marker**: Shows `saved` in muted text when the buffer matches disk, or `dirty` in accent blue when you have unsaved edits.
- **File Path**: The path of the open file.
- **Unsaved Warning Tag**: Appears as `unsaved — esc again to discard` if you tried to close a dirty buffer.
- **`save` Button**: Writes the buffer to disk (highlighted in primary accent blue when `dirty`).
- **`close` Button**: Closes the editor and returns to the graph view.

### Editing Features

- **Line Numbers & Indentation**: A left gutter displays 1-based logical line numbers (soft-wrapped continuation lines are unnumbered) and indentation guides.
- **Syntax Highlighting**:
  - **Markdown**: `.md`, `.mdx`, and `.markdown` files (used by rationale and Markdown claims).
  - **JSON**: `.json` and `.jsonc` files (such as `.deccy/settings.json`).
  - **Plain Text**: All other file extensions open in plain monospace.
- **Soft Wrap Toggle (`⌥z` / `Alt+Z`)**: Soft wrap starts **off** when a file opens. Press `⌥z` (`Alt+Z` on Linux/Windows) while the editor has focus to toggle soft wrapping on or off; the feedback bar confirms with `wrap on` or `wrap off`.

### Saving Files & Structural Integrity

Press **`⌘s`** (`Ctrl+S` on Linux/Windows) or click **`save`** to write the buffer back to disk:

- On success, the feedback bar shows `saved <path>` and `deccy-gui` immediately triggers a store reload.
- On write failure, the buffer stays `dirty` and the filesystem error is shown in red in the feedback bar.

> **Important:** The editor writes only the raw file you opened — it never rewrites node records on its own.
> - If you edit and save a **claimed file**, its on-disk digest will change and the node will show `drift` after reload. Click **`refresh claims`** in the `Details` tab (or run `deccy claim <id> --refresh`) to update the node's claim snapshot, and **`repin`** any downstream connectors that become stale.
> - If you edit and save a **rationale file** under `.deccy/rationale/`, the node's own digest changes, which may mark connectors pinning that node as `stale` until you click **`repin`**.

### Unsaved Changes Protection

`deccy-gui` guards against accidental data loss whenever the editor buffer is `dirty`:

- **Closing (`Esc` or `close`)**:
  - If the buffer is `saved`, pressing `Esc` or clicking `close` exits the editor immediately.
  - If the buffer is `dirty`, the first `Esc` (or `close` click) keeps the editor open and displays `unsaved — esc again to discard` in both the editor header and the bottom feedback bar. Pressing `Esc` (or clicking `close`) a second time discards the edits and returns to the graph.
- **Opening Another File**: Attempting to open a different file while the current buffer is `dirty` is refused with `unsaved changes: save or close the editor first`.
- **Quitting the App (`⌘q` / `Ctrl+Q`)**: Pressing `⌘q` while the editor is `dirty` warns `unsaved — ⌘q again to quit (esc again to discard)` on the first press; pressing `⌘q` a second time quits immediately.

---

## Bottom Drawer (`Terminal` & `Outputs`)

The bottom drawer starts closed when `deccy-gui` launches.

### Opening, Closing, and Resizing the Drawer

- **Status Bar Toggle**: Click `▴ open drawer` / `▾ close drawer` on the left side of the bottom bar at any time (even before any action has run).
- **Keyboard Toggle (`⌃`` / `Ctrl+``)**: Press `Ctrl+`` from any mode (graph, search, editor, or terminal) to open the drawer directly to the `Terminal` tab and focus it, or to close the drawer if `Terminal` is already open.
- **Resizing**: Drag the handle along the top edge of the drawer. Its height defaults to `240px`, has a minimum of `120px`, and can grow up to `60%` of the window height. The drawer remembers its last height when closed and reopened during the same session.

### `Terminal` Tab

The first time the `Terminal` tab is displayed, `deccy-gui` spawns an interactive shell inside a pseudo-terminal (PTY):

- **Shell Executable**:
  - Uses `$SHELL` when set and non-empty.
  - Falls back to `/bin/zsh` on macOS, `/bin/sh` on Linux/other Unix, and `%COMSPEC%` (or `cmd.exe`) on Windows.
- **Environment & Working Directory**: Starts in the store root directory with `TERM=xterm-256color` and `COLORTERM=truecolor`.
- **Display**: Supports 16-color, 256-color, and 24-bit truecolor ANSI sequences, bold text, inverse video, alternate-screen programs, and a solid block cursor. The PTY row/column grid resizes automatically whenever you resize the drawer or window.
- **Process Exit**: If the shell exits (for example, after `exit` or `Ctrl-D`), the terminal pane appends `[process exited]` in amber.

#### Terminal Focus & Keyboard Routing

- Opening the drawer on the `Terminal` tab (or clicking anywhere inside the terminal pane) focuses the terminal so typing, arrow keys, `Ctrl` sequences, and `Alt` sequences go straight to the shell.
- **Releasing Focus**: Press **`Esc`** or click outside the terminal pane (such as the graph, toolbar, editor, or inspector rail) to return keyboard shortcuts to the viewer or open editor.
- **Paste**: Press `⌘v` on macOS (`Ctrl+V` on Linux/Windows) while the terminal is focused to paste clipboard text into the shell.
- **Line & Word Editing**:
  - On **macOS**, `⌘←` / `⌘→` jump to the start/end of the line (`Ctrl-A` / `Ctrl-E`), `⌘⌫` kills the line (`Ctrl-U`), `⌥←` / `⌥→` move by word (`ESC b` / `ESC f`), and `⌥⌫` deletes the previous word (`Ctrl-W`).
  - On **Linux / Windows**, `Ctrl+←` / `Ctrl+→` and `Alt+←` / `Alt+→` move by word, and `Ctrl+Backspace` / `Alt+Backspace` delete the previous word.
- **Global Shortcuts**: `⌃`` (toggle drawer) and `⌘q` / `Ctrl+Q` (quit) remain active even while the terminal is focused.

*(Note: Mouse text selection inside the terminal grid is not implemented; copy output directly from shell commands or use the `Outputs` tab / inspector buttons.)*

#### Scrollback

- The terminal retains **1,000 lines** of scrollback history.
- Scroll up with the mouse wheel or trackpad over the terminal pane to inspect earlier output; scroll down to return toward the live screen.
- While scrolled back, a **`↓ bottom (<n>)`** button appears on the right side of the drawer's tab bar showing how many lines above the bottom you are. Click `↓ bottom (<n>)`, type any key, or paste into the terminal to jump straight back to the live prompt.

### `Outputs` Tab

The `Outputs` tab is a scrollable monospace log of every `deccy` CLI action triggered from the UI (`validate`, `validate --merge`, `repin`, `refresh claims`, `repin all`) as well as any store reload failures:

- Before the first action runs, the pane displays `no actions yet`.
- Each entry displays:
  - A header line: `$ deccy <arguments> · exit <code>` (or `reload · failed` for reload errors), colored **green** when the exit code is `0` and **red** when non-zero.
  - The captured `stdout` and `stderr` output below the header.
- If a background store reload fails (for example, `.deccy/nodes` becomes unreadable), the drawer opens automatically and records the refusal in `Outputs`.
