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