adds schema view and schema generating command

This commit is contained in:
2026-11-03 09:35:41 +01:00
parent cc41decccb
commit 600d4874d2
62 changed files with 4416 additions and 105 deletions
+12 -5
View File
@@ -1,6 +1,6 @@
# Architecture
Swift package at the repo root, macOS 14+, one project per window and one window per process. The behaviour spec is [behaviour.md](behaviour.md), the visual system [design/README.md](design/README.md).
Swift package at the repo root, macOS 14+, one project per window and one window per process. The behaviour spec is [behaviour.md](behaviour.md), the visual system [design/README.md](../design/README.md).
## Layers
@@ -18,7 +18,7 @@ Helder (executable) → HelderUI → HelderServices → HelderCore
## How a window works
- `WorkspaceModel` owns one window (`WorkspaceModel.swift`: state and `perform`; `+Commands`, `+ContextActions`, `+Lifecycle`, `+Refresh` hold the rest): the stores (`SourceControlStore`, `ExplorerStore`, `EditorStore`, `CleanCopyStore`, `TerminalStore`, `LayoutStore`, `OverlayStore`, `ToastStore`, `ReadAloudStore`) and every action that spans more than one of them. A store never reaches into a sibling; `EditorStore` only reads the git state through a closure.
- `WorkspaceModel` owns one window (`WorkspaceModel.swift`: state and `perform`; `+Commands`, `+ContextActions`, `+Lifecycle`, `+Refresh` hold the rest): the stores (`SourceControlStore`, `ExplorerStore`, `EditorStore`, `CleanCopyStore`, `SchemaStore`, `TerminalStore`, `LayoutStore`, `OverlayStore`, `ToastStore`, `ReadAloudStore`) and every action that spans more than one of them. A store never reaches into a sibling; `EditorStore` only reads the git state through a closure.
- **One entry point.** Views, the menu bar and the key router all call `WorkspaceModel.perform(Command)` (`Shell/Command.swift`). Context-menu items arrive as `.context(ContextAction)`; the model asks `SourceControlStore.confirmation(for:)` / `ExplorerStore.confirmation(for:)` first and shows the confirm overlay, and `.confirmPending` runs the action. The name prompt submits with `.submitName`, the pass-on prompt with `.passToAgent`.
- **Overlays never stack.** `OverlayStore.current` is one `Overlay` enum; only the model presents or dismisses it. `OverlayStore.onChange` lets the model run closing behaviour however an overlay went away (the Diff gives back the mode it covered). `OverlayHost` draws the current overlay. `.launcher` is the ⇧⌘O "Open recent project" list; the bare window's launcher is part of the shell, not an overlay. The key router only sees `OverlayKind` (`none`, `diff(busy:)`, `other`): over the Diff the workspace keys keep working unless its own menu or prompt is open (`busy`). Toasts (`ToastStore`) may sit on top. The Diff draws its own right-click menu and pass-on prompt inside itself, so it stays open.
- **Read aloud.** `.readAloudFile` reads the open file's buffer (unsaved edits included) or the file from disk, turns it into prose with `MarkdownSpeech`, and hands it to `ReadAloudStore`; `.readAloudText` speaks the selection (selected Markdown as prose). `ReadAloudStore` lives as long as the window, like `ToastStore`; its `isReading` shows the title bar's Stop, which runs `.stopReading`. `closeProject()` stops the reading.
@@ -26,7 +26,8 @@ Helder (executable) → HelderUI → HelderServices → HelderCore
- **Closing.** A window close, a project switch and ⌘Q all run `prepareToClose()` first: every unsaved file (at most the open one plus a vanished-file buffer) is asked about, and a cancel keeps everything open. Then `closeProject()` waits for running work, writes the session and ends the terminals.
- **Lifecycle.** `start()`: recents → config (applied to every store and the terminals) → git, tree and the `.clean-copy` baseline in parallel → `editor.restore` → watcher → git polling (`git.refreshInterval`) → the PHP class list 1.5 s later. Watcher events: `.cleanCopy` (`.clean-copy` in the root, 150 ms debounce, fired besides `.project`) makes `CleanCopyStore` re-read the file and opens the `.cleanCopy` overlay for new non-blank text (the text found at load is the baseline; another open overlay makes it wait, keeping only the newest); `.project` re-reads git, the tree, the open file and every unsaved buffer (the edits kept), invalidates the symbol index and reloads the class list 2 s after the last change; `.git` re-reads git; `.config` re-resolves and re-applies the config. ⌘R re-reads git and the tree and lets the disk win in the open file. A project switch or window close saves the session, stops the watcher and polling, and ends both terminals.
- **Terminals.** `TerminalStore` owns both panes' handles. Ending a pane goes through the store (`terminateAll`, `restart`, or `release` when a pane's window closes), which signals the child and lets `ChildReaper` collect it, so no zombie or orphan is left. A pane whose child exited restarts on the next key press. Right-click raises `contextMenuRequested`; the model shows the app's own menu (`.terminal` target: Copy with a selection, Paste). Font size follows `layout.textScale` (⌘0/⌘+/⌘−) live.
- **Git view.** ⌘G toggles `LayoutStore.isGitViewOpen` (never persisted, reset on a project switch). `WorkspaceView` draws `GitView` as an overlay over title bar, columns and status bar, under `OverlayHost`, so every overlay and toast sits above it; the columns stay mounted. `KeyContext.gitViewOpen` sends keys to `KeyRouter.gitViewKey` (column keys rest, ⌘↵ commits) and makes a bare Esc `.closeGitView` once no overlay is open; `inGitConsole` (first responder is a `GitConsoleFieldEditor`) keeps ⌘↵ from committing out of the console. `openGitView()` / `closeGitView()` in `+Commands` move the focus request (commit message in, previous `activePanel` out). Design source: `docs/design_handoff_helder_app_v2/README.md`.
- **Git view.** ⌘G toggles `LayoutStore.isGitViewOpen` (never persisted, reset on a project switch). `WorkspaceView` draws `GitView` as an overlay over title bar, columns and status bar, under `OverlayHost`, so every overlay and toast sits above it; the columns stay mounted. `KeyContext.gitViewOpen` sends keys to `KeyRouter.gitViewKey` (column keys rest, ⌘↵ commits) and makes a bare Esc `.closeGitView` once no overlay is open; `inGitConsole` (first responder is a `GitConsoleFieldEditor`) keeps ⌘↵ from committing out of the console. `openGitView()` / `closeGitView()` in `+Commands` move the focus request (commit message in, previous `activePanel` out). Design source: `design/README.md`.
- **Schema view.** ⌘D toggles `LayoutStore.isSchemaViewOpen` (never persisted, reset on a project switch); `openGitView`/`openSchemaView` close each other. It exists only when `SchemaStore.isLaravelApp` (an `artisan` file): the title-bar toggle, `KeyContext.schemaAvailable` for ⌘D and the View menu item follow it. `WorkspaceView` draws `SchemaView` like `GitView`. `SchemaStore.body` picks the command-missing prompt, the no-dump state or the diagram. The watcher's `.project` events and ⌘R carry `RefreshScope.schema`: `refresh(readingDump:)` re-checks the command and re-reads the dump only when its modification date moved, keeping viewport and positions (`SchemaLayout.positions(_:saved:)`). Card positions go to `AppServices.schemaLayouts` when a drag ends; the first dump in a store fits once the canvas has a size. `run()` streams `SchemaServicing.runDump` like the Git console and toasts through `notify`. Esc over the view: selection (`.clearSchemaSelection`), then the search text while `SchemaSearchFieldEditor` has the keyboard (`.clearSchemaSearch`), then `.closeSchemaView`. The canvas lays each card out at 100% and scales it into its on-screen frame, so the click and `.pointerHand()` area stay unscaled; scroll and pinch arrive through a local event monitor (`SchemaScrollCatcher`), since the cards would take them otherwise. Contract: [schema.md](schema.md).
- **Git commands.** Every git write and every typed console command goes through `SourceControlStore.run`, which chains onto `commandTail` so two commands never race for `.git/index.lock`, logs `$ git …` and streams lines via `GitServicing.execute` → `ProcessRunning.stream` into the console (`GitOutputClassifier`, one per run). `execute` never throws and switches off prompts, editors and pagers (`GIT_TERMINAL_PROMPT=0`, `GIT_EDITOR=true`, `GIT_PAGER=cat`), so a run can never wait on input. Typed commands run without literal pathspecs (globs work); buttons always pass explicit paths, never `add -A`. Push/pull/fetch and typed commands get `remoteTimeout` (120 s). Commit always runs git, even when `canCommitNow` is false, so git's refusal is the error the user sees. Branch switching is refused in the store while `isDirty`, without asking git. The status read (`load`) stays on `ProcessRunning.run`.
- **Git and files.** Git gets paths as literal pathspecs (`GIT_LITERAL_PATHSPECS=1`, so `pages/[id].vue` is one file). A changed file over `FileLimits.maxDiffFileBytes` (1 MB) keeps its row but loads no text: `GitFileChange.isTooBig` → `Diff.isTooBig`, and the Diff shows "Too big.". Saves are atomic (temp file, then rename, keeping permissions). Writes, creates, renames and deletes are refused when the entry's folder resolves (symlinks included) outside the project (`containedURL`). The watcher drops `IgnoreRules.walkIgnoredNames`, framework caches (`storage/framework/`, `bootstrap/cache/`, `.phpunit*`) and `files.exclude`.
- **Processes.** Every new window (⇧⌘N, the Dock's New Window, Open Folder or Open Recent with no key window) is a new Helder process via `SystemActing.openNewInstance`: `NSWorkspace` with `createsNewApplicationInstance` in the bundle, `InstanceLauncher` (Foundation `Process`) under `swift run`. The folder travels as `-HelderProject <path>`, which `ProjectLocator.initialRoot` reads as its directory argument; a bare path could reach AppKit as a file to open. Switching projects (⌘O, Open Recent in a window) stays in the process. `AppName` renames the process to the project's title (the launcher is "Helder"), so Mission Control, the Dock and ⌘Tab tell projects apart. Windows are not restorable and `NSQuitAlwaysKeepsWindows` is off, so a launch opens exactly one window.
@@ -43,6 +44,8 @@ Sources/HelderCore/
Files/ FileNode + FileTree, PathUtils, FileType (language, badge), limits + ignore rules, ContextActions (menus)
Git/ GitStatus/Change/GitSnapshot, Porcelain parsing (incl. behind/upstream), GitDerivation (rows, commit text),
GitSections (the four sections, InlineDiff), GitConsole (echo, input parsing, line classifier), GitBranches
Schema/ SchemaDump (tolerant schema.json decoding), SchemaModel, SchemaLayout (default lanes), SchemaGeometry
(lines, fit, zoom, centre), SchemaHighlight + SchemaSearch, ArtisanConsole, SchemaCommandPrompt, SchemaPaths
Highlight/ SyntaxHighlighter and one grammar per language
Markdown/ block/inline tree and parser, MarkdownSpeech (the prose Read aloud speaks)
Search/ result models, Fuzzy, InFileSearch, rg --json parsing
@@ -54,6 +57,7 @@ Sources/HelderServices/
Logging/ Log (unified log) + FileLogger (~/Library/Logs/Helder/helder.log)
Process/ ProcessRunner (`run`, and `stream` for line-by-line output), ExecutableLocator, ChildReaper, InstanceLauncher
Project/ ConfigService, RecentStores, SessionStore, ProjectLocator
Schema/ SchemaServicing + SchemaService (`php artisan helder:schema` via PHPLocator, the dump), SchemaLayoutPersisting
Search/ SearchServicing + RipgrepSearchService, ProjectScanner (rg, or a Swift walk)
Speech/ SpeechServicing + SpeechService (AVSpeechSynthesizer, the system voice), shared by the window
Symbols/ SymbolService
@@ -64,7 +68,10 @@ Sources/HelderUI/
Components/ OverlayShell/OverlayCard/OverlayHeader/OverlayFooter, ContextMenuPanel/Header/Row/Separator,
Keycap, EscChip, Primary/Secondary button styles, focusRing, SegmentButton, Splitter,
ButtonGroup (pane toggles, toolbar), Tooltip, TypeBadge, PanelLabel/PanelHeader, Hairline, selectableRow, Blink
GitView/ the full-screen Git view (⌘G): top bar, commit block, sections with inline diffs, console, branches
GitView/ the full-screen Git view (⌘G): top bar, commit block, sections with inline diffs, console, branches;
GitIcon and the console log/input the Schema view reuses
SchemaView/ the full-screen Schema view (⌘D): top bar, table list, canvas with cards and lines, detail panel,
artisan console, the no-dump and command-missing states
Explorer/ the file tree column and the row glyphs
Editor/ the bar above the code, code/markdown/image panes, Diff overlay, pass-on panel, symbol popup
Terminal/ agent + shell panes over SwiftTerm
@@ -76,7 +83,7 @@ Tests/HelderUITests/Support/ WorkspaceHarness, StoreHarnesses (EditorHarness,
Tests/HelderUITests/Support/Fakes/ one fake per service protocol (FakeGit, FakeFiles, FakeSystem, …)
assets/icon.png the app icon; bundle.sh turns it into Helder.icns
vendor/ripgrep/rg ripgrep 15 for Apple silicon, from the @vscode/ripgrep build (its LICENSE beside it), bundled as Contents/Helpers/rg
docs/design/ design tokens, the design canvas and reference screenshots
design/ the design handoff (README.md) and the HTML prototype
```
## Commands
+59 -15
View File
@@ -20,7 +20,7 @@ The three columns of the body, left to right, are:
2. **Editor** (one file and its code)
3. **Agent and Terminal**, a single column split into two stacked panes: the Claude agent pane on top and a shell terminal below it.
Git is not a column: the full-screen **Git view** (section 3) covers all three regions while it is open.
Git is not a column: the full-screen **Git view** (section 3) covers all three regions while it is open. In a Laravel app the full-screen **Schema view** (section 4) does the same; the two never show together.
Every boundary between panes is a draggable splitter. The vertical splitters between the three columns adjust their widths. The horizontal splitter between the agent pane and the terminal pane adjusts their heights. Splitter positions persist across launches. Panes have sensible minimum widths and heights so they cannot be collapsed to nothing by dragging.
@@ -34,8 +34,8 @@ The top bar contains, left to right:
- The Helder wordmark.
- A breadcrumb showing the path to the active file, for example `console / src / Http / Controller / UserController.php`. The breadcrumb is **display only** for now. It is not clickable and does not navigate.
- Centred on the window, the **pane toggles**: Explorer · File · Claude. Each shows or hides one column, all on by default (see Pane toggles in section 9). The breadcrumb truncates before it reaches them.
- On the right, the toolbar: **`Git N`** (`Cmd+G`) toggles the Git view (section 3); N counts the changed files, a file both staged and unstaged once, and the count is left out when there are none. **Search** (`Cmd+F`) is an action; **Fluid** (`Cmd+L`) and **Hidden** (`Cmd+.`) are toggles. Then `?` for the keyboard shortcuts.
- Centred on the window, the **pane toggles**: Explorer · File · Claude. Each shows or hides one column, all on by default (see Pane toggles in section 10). The breadcrumb truncates before it reaches them.
- On the right, the toolbar: **`Git N`** (`Cmd+G`) toggles the Git view (section 3); N counts the changed files, a file both staged and unstaged once, and the count is left out when there are none. In a Laravel app (an `artisan` file in the root) **Schema** (`Cmd+D`) follows it and toggles the Schema view (section 4); elsewhere it is left out. **Search** (`Cmd+F`) is an action; **Fluid** (`Cmd+L`) and **Hidden** (`Cmd+.`) are toggles. Then `?` for the keyboard shortcuts.
- While Helder reads aloud, a **Stop** toggle appears left of **Git**, in the same style and switched on. A click switches it off and stops the reading; the button then goes away. It also goes away when the reading reaches the end, and a project switch or window close stops the reading.
---
@@ -98,7 +98,51 @@ The bottom-right panel: **local** branches, then **remote · origin**. The curre
---
## 4. Explorer panel
## 4. Schema view
A full-screen view, drawn like the Git view, that shows the database of a Laravel app as a diagram of tables and foreign-key lines. It exists only in a Laravel app: a project with an `artisan` file in its root. Elsewhere there is no **Schema** button, `Cmd+D` does nothing and View › Show Schema is disabled. `Cmd+D`, the **Schema** toggle and View › Show Schema open it; `Cmd+D`, `Esc` and its **Close** button close it. Opening it closes the Git view, and opening the Git view closes it. Dialogs, menus, search and toasts sit above it, and the columns stay mounted under it. It is not persisted: a project always opens with it closed.
Helder reads the diagram from `database/helder/schema.json`, which the app's own Artisan command `app/Console/Commands/HelderSchemaCommand.php` (`php artisan helder:schema`) writes. The file's contract is in [schema.md](schema.md).
While it is open, the columns' row, focus and editor keys rest, as over the Git view; `Cmd+Return` and `Cmd+C` do nothing. `Esc` closes the topmost layer: an overlay first, then the table selection, then the table search's text (only while the search has the keyboard), then the view.
### States
- **No command yet**: the app has no `HelderSchemaCommand.php`. The body shows `[ NO COMMAND YET ]`, a line that names the dump and the command, **Generate command** and **Copy prompt**, and a scrollable, selectable preview of the prompt. **Generate command** closes the view and pastes the prompt into the Claude prompt without sending it (toast `Passed to agent` · `Command prompt`). **Copy prompt** copies it (toast `Copied prompt`). The top bar reads `no command yet`, its Run button is disabled and the command path is hidden.
- **No dump yet**: the command exists, the dump does not. `[ NO DUMP YET ]`, a line about `database/helder/schema.json`, the Run button and `$ php artisan helder:schema`.
- **Diagram**: the table list, the canvas, and the detail panel while a table is selected.
The view flips between these states by itself: the watcher re-checks the command and re-reads the dump when its modification date changes, so a command that Claude writes and runs in the terminal shows its diagram without a click. A re-read keeps the pan, the zoom and the card positions; new tables get a default place.
### Top bar
`[ schema ]`, then (with a dump) the database icon and `driver · database` in amber, then `no command yet`, `no dump yet` or `dumped 14:32 · 16 tables · 23 relations`. On the right: the command path as a text button (it closes the view and opens the command in the editor), the amber Run button (`Run helder:schema`, `Re-run helder:schema` once a dump exists, `Dumping…` while it runs; clicks are ignored then) and **Close** (`⌘D`).
### Running the command
Run executes `php artisan helder:schema` in the project root with Herd's php, else the `php` on `PATH`. The console opens and shows `$ php artisan helder:schema`, then each output line as it arrives: errors in amber, `INFO`/`DONE`/`Wrote …` lines in teal. Exit code 0 re-reads the dump and toasts `Schema dumped · N tables`; any other code keeps the console open and toasts nothing more. A run stops after 120 seconds. A dump that is not valid JSON shows its error in the console and toasts `Could not read the schema`.
### Table list
240pt, left. A search field (`Find a table`) filters by substring; `Return` selects and centres the first match. `[ TABLES ] 16`, or `[ TABLES ] 3 of 16` while filtering. One row per table in name order with its row count. Hovering a row lights the table on the canvas as hovering the card does; a click selects and centres it.
### Canvas
Cards (240pt wide; a 33pt header with the name and row count, then a 22pt row per column with `PK`/`FK`/`UQ`, the name and the type, `?` for nullable) and one cubic line per foreign key, from the key's row to the referenced row: hollow end at the key, filled end at the target. Drag the background or scroll to pan; `Cmd`/`Ctrl` + scroll and pinch zoom around the pointer, 30–200%. The control bottom right zooms out, shows the percentage, zooms in (×1.2) and fits all cards (48pt margin, at most 110%). The first dump fits itself. Drag a card to move it (a press that moves less than 4pt is a click); its position is saved per project in Helder's settings when the drag ends.
Hovering a table lights every line in or out of it in amber, outlines related tables and dims the rest to 30%; hovering a foreign-key row narrows that to one relationship. A click selects a table (click it again or the empty canvas to deselect). Without a focus, the search outlines matching cards and dims the rest. Only colour and opacity change, over 160ms; nothing moves.
### Detail panel
320pt, right, while a table is selected: the name, the row count and a close button; `[ COLUMNS ] N` with each column's type and flags (`PRIMARY · NOT NULL`, `FK → users.id · NULL`, `UNIQUE · NOT NULL`); `[ BELONGS TO ]` (outgoing keys) and `[ HAS MANY ]` (incoming keys), whose rows light the other table on hover and select and centre it on click; or `— No foreign keys in or out.`. Footer: **Pass on to Claude** closes the view and inserts `@schema:<table>` into the Claude prompt; **Copy name** copies it (toast `Copied table name`).
### Console
150pt, at the bottom, from the first run: `[ CONSOLE ] ARTISAN` and the run output, kept at the newest line, at most 400 lines. The chevron hides it until the next run.
---
## 5. Explorer panel
The second column. A standard project file tree.
@@ -112,7 +156,7 @@ The second column. A standard project file tree.
---
## 5. Editor
## 6. Editor
The third and widest column. It shows exactly one file: a bar on top and the code below. Opening another file replaces it. Opening a file always reads it fresh from disk. Edits are written only with `Cmd+S` (or by `editor.autoSave`). Opening a file, the same one included, while the open file has unsaved edits asks **Save**, **Don't Save** or **Cancel**: Save writes and then opens, Don't Save drops the edits and opens, Cancel keeps the current file, its edits and the Explorer selection. A failed save keeps the file open. With `editor.autoSave` on, the file saves silently instead of asking.
@@ -144,7 +188,7 @@ Shared rules: teal is what the file holds now, amber-deep is what it held before
### Editing behavior
- A file with no changes opens directly in a normal editable view with no Diff button, since there is nothing to diff.
- Editing follows the editor settings: indentation, indent width, trim trailing whitespace, insert final newline, word wrap, indent guides, whitespace rendering, and active-line highlight, all read from configuration (section 10).
- Editing follows the editor settings: indentation, indent width, trim trailing whitespace, insert final newline, word wrap, indent guides, whitespace rendering, and active-line highlight, all read from configuration (section 11).
- **Word wrap** follows `editor.wordWrap`: `markdown` (default), `on`, or `off`. When it is on, a line too wide for the pane folds onto the next row instead of scrolling sideways. Only the first row of a folded line carries a line number; the rows below it stay blank. Diff never wraps, because its two panes align row by row.
### Right-click in code
@@ -168,7 +212,7 @@ On a marked line of the live file (any marked line, blank lines and the space af
---
## 6. Agent pane
## 7. Agent pane
The top pane of the fourth column.
@@ -190,7 +234,7 @@ The agent hands the user text to copy through one file, `.clean-copy` in the pro
---
## 7. Terminal pane
## 8. Terminal pane
The bottom pane of the fourth column.
@@ -211,7 +255,7 @@ Right-clicking in the agent pane or the terminal pane shows a menu without a hea
---
## 8. Status bar
## 9. Status bar
A bar across the bottom of the window. All items are **display only** for now; none are clickable.
@@ -220,7 +264,7 @@ A bar across the bottom of the window. All items are **display only** for now; n
---
## 9. Global interactions
## 10. Global interactions
### Go to File (`Cmd+P`)
@@ -246,11 +290,11 @@ Inside the overlay:
The pointer shows what a left click does at that spot. It depends only on what lies under the mouse.
- **Pointing hand** only where a left click runs an action: buttons (title-bar toggles and tools, `?`, Preview, Diff, the Git view's buttons and section headers, dialog buttons, Collapse, search chips), clickable rows (Git view file rows and switchable branches, Explorer rows, search results, recent files and projects, launcher rows, symbol popup rows, context-menu items) and the project name in the title bar. Never on a view that only reacts to a right-click, a tooltip or hover.
- **Pointing hand** only where a left click runs an action: buttons (title-bar toggles and tools, `?`, Preview, Diff, the Git view's buttons and section headers, dialog buttons, Collapse, search chips), clickable rows (Git view file rows and switchable branches, Schema table rows, cards and relation rows, Explorer rows, search results, recent files and projects, launcher rows, symbol popup rows, context-menu items) and the project name in the title bar. Never on a view that only reacts to a right-click, a tooltip or hover.
- **I-beam** where a click places a caret or starts a selection: the code (also below the last line), the Markdown preview, both terminals, the commit message, the Git console and every overlay input.
- **Arrow** everywhere else: labels, headers, folder labels, the gutter, the status bar, scrims, toasts, empty states, and a disabled button such as Commit with nothing staged.
- With an overlay open, every column behind it, and the Git view, shows the arrow; the overlay's own buttons, rows and inputs keep theirs.
- A splitter shows a resize arrow; `Cmd` over a known PHP class name in the code shows the hand. No other pointers are used.
- A splitter shows a resize arrow; `Cmd` over a known PHP class name in the code shows the hand. No other pointers are used: the Schema canvas pans with the arrow, without a grab hand.
### Pane resizing
@@ -266,7 +310,7 @@ When `session.restoreOnLaunch` is on (default), reopening a project restores the
---
## 10. Configuration
## 11. Configuration
Settings are project-scoped and live in a `.helder` folder in the project root.
@@ -279,12 +323,12 @@ Settings that affect behavior described above include indentation and editor dis
---
## 11. States and edge cases summary
## 12. States and edge cases summary
- **No project open**: the window shows an empty state inviting the user to open a project folder.
- **Clean working tree**: the Git view shows its clean message; the Explorer still shows the full tree.
- **Unchanged file open**: normal editable view, no Diff button.
- **Added or deleted file**: views behave as described in section 5.
- **Added or deleted file**: views behave as described in section 6.
- **Binary or unsupported file**: placeholder, no Preview or Diff button.
- **Search with no matches**: per-column no-results messages.
- **Agent command not available**: the agent pane is a terminal, so a missing or failing command surfaces as ordinary terminal output in that pane.
+3 -2
View File
@@ -23,7 +23,7 @@ This guide explains Helder from the user's side: what each part of the window sh
```
1. [Title bar](title-bar.md): breadcrumb, pane toggles and toolbar.
2. [Git](git.md): the full-screen Git view (`Cmd+G`), with the [commit form](git-commit-form.md), a console and the branches.
2. [Git](git.md): the full-screen Git view (`Cmd+G`), with the [commit form](git-commit-form.md), a console and the branches. In a Laravel app, [Schema](schema.md) (`Cmd+D`) draws the database the same way.
3. [Explorer](explorer.md): the project's file tree.
4. [File view](file-view.md): one open file, with [Markdown preview](file-view-markdown.md) and [Diff](file-view-diff.md).
5. [Claude Code](claude-code.md): the agent session.
@@ -41,10 +41,11 @@ This guide explains Helder from the user's side: what each part of the window sh
- [Recent projects](recent-projects.md): switch to or open another project.
- [Notifications](notifications.md): the short messages that confirm or warn.
### Git and files
### Git, schema and files
- [Git](git.md): the full-screen Git view: changes, inline diffs, pull, push, console and branches.
- [Git commit form](git-commit-form.md): write a message, commit, or commit and push.
- [Schema](schema.md): the full-screen database diagram of a Laravel app (`Cmd+D`).
- [Explorer](explorer.md): browse, create, rename and delete files.
### The file view
+16 -4
View File
@@ -20,6 +20,8 @@ Helder is built to run from the keyboard. Press `?` to see a short list of the m
| | ... | |
| | GIT | |
| | ... | |
| | SCHEMA | |
| | ... | |
| | FILE | |
| | ... | |
| +----------------------------------------------+ |
@@ -28,7 +30,7 @@ Helder is built to run from the keyboard. Press `?` to see a short list of the m
```
1. **Header**: a question-mark icon, the title and an `esc` chip.
2. **Group label**: NAVIGATE, AGENT, GIT and FILE.
2. **Group label**: NAVIGATE, AGENT, GIT, SCHEMA and FILE.
3. **Row**: the keys as keycaps, then what they do.
## Features
@@ -37,10 +39,11 @@ Helder is built to run from the keyboard. Press `?` to see a short list of the m
- Open it with `?` when no text field, code view or terminal has the keyboard. You can also click the `?` button in the [title bar](title-bar.md), or choose View > Keyboard Shortcuts or Help > Keyboard Shortcuts.
- Close it with `Esc`, or by clicking the dimmed backdrop.
- It scrolls only when the window is too short to show all of it.
- It holds the main shortcuts, in four groups:
- It holds the main shortcuts, in five groups:
- **Navigate**: search, list movement, column movement, the Explorer row cursor, the column toggles `Cmd+1` to `Cmd+3`, recent projects, open folder, new window, PHP class lookup, and this list.
- **Agent**: pass the selection to the agent.
- **Git**: open or close the Git view, focus the commit message, commit, push.
- **Schema**: open or close the Schema view (Laravel apps), and `Return` in its table search.
- **File**: save, Markdown preview, close, refresh, hidden files, select all, Fluid columns, zoom, and `Esc`.
- The full reference is below.
@@ -48,8 +51,8 @@ Helder is built to run from the keyboard. Press `?` to see a short list of the m
- A text field, the code, or a terminal keeps the keys it needs. Arrows, `Return`, `?`, `Cmd+A` and `Cmd+C` with a selection go to the field, not to Helder.
- Keys with `Ctrl` or `Opt` always go to the field or terminal, except the menu shortcuts that use them.
- While an overlay is open, it owns the keys. `Esc` closes it. The Diff is the exception: the workspace shortcuts keep working over it.
- `Esc` closes the topmost layer: a right-click menu, a dialog, search or the Diff first, then the [Git](git.md) view. With none of those open, `Esc` goes to the terminal.
- While the Git view is open, the column keys rest: arrows, `Return` and `Cmd+Left` / `Cmd+Right` do nothing in the columns under it.
- `Esc` closes the topmost layer: a right-click menu, a dialog, search or the Diff first, then the [Schema](schema.md) view's selection, its search text and the view itself, or the [Git](git.md) view. With none of those open, `Esc` goes to the terminal.
- While the Git or Schema view is open, the column keys rest: arrows, `Return` and `Cmd+Left` / `Cmd+Right` do nothing in the columns under it.
## Keyboard
@@ -104,6 +107,15 @@ See [Git](git.md) and [Git commit form](git-commit-form.md).
| `Return` | Run the command in the console input |
| `Up` | Recall the previous console command |
### Schema view
See [Schema](schema.md). Only in a Laravel app: a project with an `artisan` file.
| Keys | Action |
|---|---|
| `Cmd+D` | Open or close the Schema view |
| `Return` | In the table search: select and centre the first match |
| `Esc` | Deselect the table, then clear the search (while it has the keyboard), then close the view |
### Explorer
See [Explorer](explorer.md).
+131
View File
@@ -0,0 +1,131 @@
# Schema
The Schema view is a full-screen diagram of a Laravel app's database: every table as a card, every foreign key as a line. Hover a table to trace what it points at and what points at it, click it to read its columns, and hand a table to Claude. Open it with `Cmd+D`.
[Guide index](index.md) · Related: [Git](git.md), [Title bar](title-bar.md), [Claude Code](claude-code.md), [Notifications](notifications.md)
## At a glance
```text
+----------------------------------------------------------------------------+
| (1) [ schema ] = mysql . shop dumped 14:32 . 16 tables . 23 relations |
| app/Console/.../HelderSchemaCommand.php [>_ Re-run] [x] |
|----------------------------------------------------------------------------|
| (2) Q Find a table | (3) | (5) users x |
| [ TABLES ] 16 | +-----------------+ | [ COLUMNS ] 8 |
| |users 1,284 | | posts 312 | +-------+ | id bigint |
| posts 312 | | PK id bigint | | users | | PRIMARY . NOT.. |
| comments 9,812 | | FK user_id ----+--->| PK id | | [ HAS MANY ] |
| | +-----------------+ +-------+ | <- posts via .. |
| | (4) drag to pan ... [- 80% + Fit] | [Pass on][Copy] |
|----------------------------------------------------------------------------|
| (6) [ console ] artisan v |
| $ php artisan helder:schema |
| Wrote database/helder/schema.json (18.4 KB) |
+----------------------------------------------------------------------------+
```
1. **Top bar**: the database, when the dump was made, the command path, the Run button and Close.
2. **Table list**: a search field and every table with its row count.
3. **Canvas**: the table cards and the relationship lines.
4. **Hint and zoom control**: how to move around, and zoom out, the zoom level, zoom in and Fit.
5. **Detail panel**: the selected table's columns and relations, while a table is selected.
6. **Console**: the output of `php artisan helder:schema`.
## Features
### When the view exists
- Only in a Laravel app: a project with an `artisan` file in its root. Anywhere else there is no **Schema** button and `Cmd+D` does nothing.
- The diagram comes from `database/helder/schema.json`. The app's own Artisan command `app/Console/Commands/HelderSchemaCommand.php` writes that file. See [the schema.json contract](../schema.md).
### Open and close the view
- `Cmd+D`, the **Schema** toggle in the [Title bar](title-bar.md), or View > Show Schema opens it. The toggle's dot is amber while the view is open.
- The view covers the whole window. The columns stay as they were under it, and terminals keep running.
- Close it with `Cmd+D`, `Esc`, or the **Close** button. The keyboard goes back to the column that had it.
- The Git view and the Schema view never show together: opening one closes the other.
- The view is not remembered: a project always opens with it closed.
### No command yet
A Laravel app without `HelderSchemaCommand.php` opens the view on `[ NO COMMAND YET ]`:
```text
+--------------------------------------------------+
| [ NO COMMAND YET ] |
| - Helder draws the schema from |
| database/helder/schema.json. The Artisan command|
| app/Console/Commands/HelderSchemaCommand.php |
| writes it, and this app does not have it yet. |
| [* Generate command] [Copy prompt] |
| +----------------------------------------------+ |
| | Build an Artisan command that dumps ... | |
| +----------------------------------------------+ |
+--------------------------------------------------+
```
- **Generate command** closes the view and puts a prompt in the Claude prompt. It does not send it: read it, then press `Return` yourself.
- **Copy prompt** copies the same prompt, for another agent or a ticket.
- The box below shows the whole prompt, so you know what Claude gets.
- When Claude writes the command and runs it in the terminal, the view switches to the diagram by itself.
### No dump yet
With the command but no `database/helder/schema.json`, the view shows `[ NO DUMP YET ]` and a **Run helder:schema** button. A dump that already exists loads as soon as the view opens.
### Run the command
- **Run helder:schema** (or **Re-run helder:schema** once there is a dump) runs `php artisan helder:schema` in the project folder. Helder uses Laravel Herd's `php` when it is installed, else the `php` on your `PATH`.
- While it runs, the button reads `Dumping…` and more clicks do nothing. A run stops after 120 seconds.
- The console shows each line as it arrives: errors in amber, the `Wrote …` and `DONE` lines in teal.
- When it succeeds, the diagram reloads and a [notification](notifications.md) reads `Schema dumped · 16 tables`.
- When it fails, the console stays open with the error.
- A `schema.json` that is not valid JSON shows its error in the console and the notification `Could not read the schema`.
### Table list
- Type in **Find a table** to filter the list. `Return` selects and centres the first match. `Esc` clears the search, while the search has the keyboard.
- The label reads `[ TABLES ] 16`, or `[ TABLES ] 3 of 16` while filtering.
- Hover a row to trace that table on the canvas. Click a row to select it and move it to the middle.
### Move around the canvas
- Drag the empty background, or scroll, to pan.
- `Cmd` + scroll, `Ctrl` + scroll, or pinch to zoom around the pointer, from 30% to 200%.
- The control at the bottom right: `−` and `+` zoom around the middle; **Fit** shows every table.
- The first dump fits itself to the window. After that, a new dump keeps your view.
### Arrange the tables
- Drag a card to move it. A press that hardly moves is a click.
- Helder remembers where you put the cards, per project. A new dump keeps them; new tables get a default place.
- The default places put tables that point at nothing on the left, and each other table one lane right of the deepest table it points at.
### Trace a relation
- Hover a table: its lines turn amber, related tables get a grey outline and the rest fade.
- Hover a foreign-key row (`FK`) to trace only that one relation.
- With a search and nothing hovered or selected, matching cards get an amber outline and the rest fade.
### Inspect a table
- Click a card to select it; the detail panel opens on the right. Click it again, or the empty canvas, to close it.
- **[ COLUMNS ]** lists every column with its type and flags, such as `FK → users.id · NULL`.
- **[ BELONGS TO ]** lists the tables this one points at; **[ HAS MANY ]** the tables that point at it. Hover a row to trace that table; click it to select it and move to it.
- **Pass on to Claude** closes the view and puts `@schema:<table>` in the Claude prompt.
- **Copy name** copies the table name.
### Console
- It opens on the first run, at the bottom, and keeps the last 400 lines.
- The chevron hides it until the next run.
### How the view stays up to date
You do not need to refresh by hand. Helder watches the project folder: when the command file appears or goes, or `database/helder/schema.json` changes, the view follows. `Cmd+R` checks again too.
## Keyboard
| Keys | Action |
|---|---|
| `Cmd+D` | Open or close the Schema view (Laravel apps) |
| `Return` | In the table search: select and centre the first match |
| `Esc` | Deselect the table, then clear the search (while it has the keyboard), then close the view |
| `Cmd+G` | Switch to the Git view |
## Related
- [Git](git.md): the other full-screen view.
- [Title bar](title-bar.md): the **Schema** toggle.
- [Claude Code](claude-code.md): where the prompt and `@schema:<table>` land.
- [The schema.json contract](../schema.md): the file the command writes.
- [Keyboard shortcuts](keyboard-shortcuts.md): every shortcut in one list.
+12 -8
View File
@@ -1,6 +1,6 @@
# Title bar
The title bar is the 44-point strip across the top of a project window. It tells you which project, branch and file you are on, and holds the column toggles, the Git toggle and the main tools.
The title bar is the 44-point strip across the top of a project window. It tells you which project, branch and file you are on, and holds the column toggles, the Git and Schema toggles and the main tools.
[Guide index](index.md) · Related: [Window layout](layout.md), [Search](search.md), [Keyboard shortcuts](keyboard-shortcuts.md)
@@ -11,8 +11,8 @@ The title bar is the 44-point strip across the top of a project window. It tells
| o o o Helder. shop . main app > Http > User.php * |
| (1) (2) (3) (4) (5) (6) |
| |
| [.Explorer|.File|.Claude] [Git 3 |Search |.Fluid |.Hidden] [?] |
| (7) (8) (9) (10) (10) (11) |
| [.Explorer|.File|.Claude] [Git 3 |.Schema |Search |.Fluid |.Hidden] [?] |
| (7) (8) (9) (10) (11) (11) (12) |
+----------------------------------------------------------------------------+
```
@@ -21,7 +21,7 @@ The bar is one row in the app. It is drawn on two rows here to fit the page.
While Helder reads aloud, a **Stop** button leads the toolbar:
```text
| [.Stop |Git 3 |Search |.Fluid |.Hidden] [?] |
| [.Stop |Git 3 |.Schema |Search |.Fluid |.Hidden] [?] |
```
1. **Window buttons**: the macOS close, minimize and zoom buttons.
@@ -32,9 +32,10 @@ While Helder reads aloud, a **Stop** button leads the toolbar:
6. **Unsaved dot**: an amber dot when the open file has unsaved edits.
7. **Pane toggles**: each shows or hides one column.
8. **Git N**: opens and closes the Git view.
9. **Search**: a button that opens an overlay.
10. **Fluid** and **Hidden**: on/off toggles.
11. **`?`**: opens the keyboard shortcuts.
9. **Schema**: opens and closes the Schema view, in a Laravel app only.
10. **Search**: a button that opens an overlay.
11. **Fluid** and **Hidden**: on/off toggles.
12. **`?`**: opens the keyboard shortcuts.
## Features
@@ -63,12 +64,13 @@ While Helder reads aloud, a **Stop** button leads the toolbar:
The toolbar sits on the right. Each button shows its shortcut next to its label.
- **Git N** (`Cmd+G`): opens the full-screen [Git](git.md) view. N counts the changed files; a file that is both staged and unstaged counts once. With no changes it reads **Git**. The view covers the title bar, so close it with `Cmd+G`, `Esc` or its own **Close** button.
- **Schema** (`Cmd+D`): opens the full-screen [Schema](schema.md) view, the database diagram. It shows only in a Laravel app: a project with an `artisan` file in its root. Opening it closes the Git view, and the other way round.
- **Search** (`Cmd+F`): opens search over the open file, the project contents and the file names. See [Search](search.md).
- **Fluid** (`Cmd+L`): when on, the columns re-fit on resize and when focus moves. When off, they keep their size. See [Window layout](layout.md).
- **Hidden** (`Cmd+.`): when on, dotfiles appear in the Explorer and in search.
- **`?`**: opens the keyboard shortcuts list. See [Keyboard shortcuts](keyboard-shortcuts.md).
Git, Fluid and Hidden carry a state dot like the pane toggles; Git's dot is on while the view is open. Search has no dot, because it is an action. Hover any button for a tooltip that explains its current state.
Git, Schema, Fluid and Hidden carry a state dot like the pane toggles; the Git and Schema dots are on while their view is open. Search has no dot, because it is an action. Hover any button for a tooltip that explains its current state.
### Read aloud
- **Stop** shows only while Helder reads a file or a selection aloud. Start the reading from the [right-click menu](right-click-menu.md): **Read aloud** on a Markdown file, **Read aloud selection** in the code.
@@ -87,6 +89,7 @@ Drag an empty part of the title bar to move the window, as in any macOS app.
| `Cmd+L` | Fluid column widths on or off |
| `Cmd+.` | Hidden files on or off |
| `Cmd+G` | Open or close the Git view |
| `Cmd+D` | Open or close the Schema view (Laravel apps) |
| `Cmd+1` / `Cmd+2` / `Cmd+3` | Explorer, File or Claude column on or off |
| `?` | Keyboard shortcuts (when no text field has focus) |
| `Cmd+O` | Open a folder (same as clicking the project name) |
@@ -95,6 +98,7 @@ Drag an empty part of the title bar to move the window, as in any macOS app.
- [Window layout](layout.md): what the pane toggles, Fluid and Hidden do to the columns.
- [Git](git.md): the view the Git toggle opens.
- [Schema](schema.md): the view the Schema toggle opens.
- [Search](search.md): the overlay the Search button opens.
- [Keyboard shortcuts](keyboard-shortcuts.md): the overlay the `?` button opens.
- [Recent projects](recent-projects.md): opening another folder.
+2 -2
View File
@@ -2,7 +2,7 @@
- [User guide](guide/index.md): every area of the app at user level, one page each, with ASCII sketches.
- [Architecture](architecture.md): layers, folder map, commands, file ownership, gotchas.
- [Design tokens](design/README.md): the visual source of truth (colours, type, geometry, screens).
- [Design](../design/README.md): the visual source of truth (colours, type, geometry, screens), including the full-screen Git view (⌘G) and Schema view (⌘D).
- [Behaviour spec](behaviour.md): every panel and interaction.
- [Design handoff v2](design_handoff_helder_app_v2/README.md): the design source of the full-screen Git view (⌘G).
- [schema.json contract](schema.md): the file `helder:schema` writes and the Schema view (⌘D) reads.
- [Plak URL scheme](plak.md): the `plak://` contract that the right-click Plak item relies on.
+58
View File
@@ -0,0 +1,58 @@
# schema.json contract
The [Schema view](guide/schema.md) draws a Laravel app's database from `database/helder/schema.json`. The app's own Artisan command, `app/Console/Commands/HelderSchemaCommand.php` (`php artisan helder:schema`), writes that file. Helder does not ship the command: **Generate command** in the view asks Claude to write it from the prompt in `SchemaCommandPrompt.text` (`Sources/HelderCore/Schema/SchemaCommandPrompt.swift`).
[Docs index](index.md) · Related: [Schema view guide](guide/schema.md), [Behaviour § 4](behaviour.md#4-schema-view)
## Paths
| What | Path, relative to the project root |
|---|---|
| Turns the view on | `artisan` (a Laravel app) |
| The command | `app/Console/Commands/HelderSchemaCommand.php` |
| The dump | `database/helder/schema.json` |
| How Helder runs it | `php artisan helder:schema --no-ansi --no-interaction`, with Herd's `php` first, else `php` on `PATH`, 120 s timeout |
## The file (version 1)
```json
{
"version": 1,
"connection": "<connection name>",
"driver": "<DB::connection($connection)->getDriverName()>",
"database": "<DB::connection($connection)->getDatabaseName()>",
"generated_at": "<now()->toIso8601String()>",
"tables": [
{
"name": "<table name>",
"rows": <int or null>,
"columns": [ <Schema::getColumns($table), unchanged> ],
"indexes": [ <Schema::getIndexes($table), unchanged> ],
"foreign_keys": [ <Schema::getForeignKeys($table), unchanged> ]
}
]
}
```
What the command must do besides the JSON:
- Read the structure only with Laravel's schema builder: `Schema::getTables()`, `getColumns`, `getIndexes`, `getForeignKeys`.
- Skip `migrations`, `jobs`, `job_batches`, `failed_jobs`, `cache`, `cache_locks`, `sessions` and `password_reset_tokens`.
- Count rows with `DB::table($table)->count()`; a failed count is `null`.
- Sort the tables by name, and encode with `JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR`.
- Write a temporary file in `database/helder/` and rename it, so Helder never reads half a file.
- Keep `database/helder/.gitignore` with `*` and `!.gitignore`.
- Print the counts with `twoColumnDetail`, then `Wrote database/helder/schema.json (<size> KB)`, and return `SUCCESS`; on an error print it with `error()` and return `FAILURE`.
## How Helder reads it
`SchemaDump` (`Sources/HelderCore/Schema/SchemaDump.swift`) decodes the file; `SchemaModel` turns it into cards and lines.
- Decoding is tolerant. A missing or mistyped key gets its default; a table, column or key without a name is skipped. Booleans may come as `true`, `1` or `"1"`. The older prototype shape (no `version`, `driver`, `database` or `rows`) still loads.
- A file that is not a JSON object is an error: the console shows it and a toast reads `Could not read the schema`.
- The connection label is `driver · database`, else the connection name.
- Primary keys come from the primary index, else the auto-increment column. `UQ` marks a column alone in a unique index that is not the primary key.
- One line per foreign key, from its first column to the referenced column (else the target's primary key, else its first row). A key to a table that is not in the dump draws no line.
- The view re-reads the file when its modification date changes, so rewrite it in place; Helder keeps the user's pan, zoom and card positions across a re-read.
Change the prompt and `SchemaDump` together: the prompt is the only place the contract is written for the agent.