10851 lines
824 KiB
Markdown
10851 lines
824 KiB
Markdown
# Helder — complete rebuild handoff
|
||
|
||
You are Claude Code. Your job is to rebuild **Helder** in a new language or framework, with the same behaviour, the same look and the same feel, down to the last string, colour, size and key. This file is the only source you get. It was written from the original Swift code base (about 21,400 lines of Swift, 316 files, three library targets plus an executable, and about 4,000 lines of docs). Where the original docs and the original code disagreed, this file follows the **code**, and says so.
|
||
|
||
Read this whole file before you write one line of code. Then make a plan, ask the user which target language and UI toolkit to use if they have not said so, and build in the order of part E, "Build order".
|
||
|
||
---
|
||
|
||
## A. How to use this handoff
|
||
|
||
- **Words.** The app is Dutch-made but every UI string is English. Copy every string in this file **verbatim**, including punctuation such as `—`, `·`, `…`, `↑`, `↓`, `⌘`, `−` (a real minus sign, U+2212, not a hyphen) and curly quotes where shown.
|
||
- **Names in parentheses** (`EditorStore`, `GitSections.swift`) are the original Swift names. They are given for traceability only. Use the idiom of the new language, but keep the concepts and the boundaries.
|
||
- **"Must" rules** are behaviour the user relies on. Do not "improve" them. In particular: one file open at a time (no tabs), no light mode, no green and no red anywhere in diffs (teal = now, amber-deep = before), git never prompts, the agent pane never auto-submits a pass-on, overlays never stack.
|
||
- **Platform.** The original is macOS 14+ only, Apple silicon, one project per window and one window per process. If the target toolkit is cross-platform, keep macOS as the primary target and keep every macOS behaviour (⌘ keys, Finder, Dock, Mission Control names, `open` of URLs, the system voice).
|
||
- **Column names.** The user and some sections call the columns Col A (the old Git column, now the full-screen Git view), Col B (Explorer), Col C (File / editor) and Col D (Claude on top + Terminal below, called D1 and D2). "Panel management" means the column behaviour plus the resizing logic.
|
||
- **Acceptance.** Section 8 lists every test of the original suite as a plain-English rule. Port them as tests in the new language. A rebuild is done when all of them pass and the app behaves as sections 1–7 describe.
|
||
|
||
---
|
||
|
||
## B. What Helder is
|
||
|
||
Helder ("clear" in Dutch) is a **dark, AI-first macOS workbench for reviewing the code that Claude Code writes**. It is not a general IDE. It opens one project folder per window and shows:
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| (1) Helder console / src / app.php [Explorer][File][Claude] [Git 2] .. ? |
|
||
+----------------+-----------------------------------+-----------------------+
|
||
| (3) EXPLORER | (4) FILE | (5) CLAUDE |
|
||
| > src | 12 function handle() { | > _ |
|
||
| app.php | 13 return true; | |
|
||
| > tests | 14 } +-----------------------+
|
||
| | | (6) TERMINAL |
|
||
| | | $ _ |
|
||
+----------------+-----------------------------------+-----------------------+
|
||
| (7) main +50 -38 Ln 12, Col 4 UTF-8 PHP |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Title bar**: wordmark, project name, breadcrumb of the open file (display only), centred pane toggles (Explorer · File · Claude), toolbar (`Git N`, Search, Fluid, Hidden, `?`), and a Stop toggle while reading aloud.
|
||
2. **Git view** (⌘G): a full-screen view over the whole window: commit form, four colour-coded sections of changed files with inline side-by-side diffs, a git console with every command it runs, and a branch list. Git is **not** a column.
|
||
3. **Explorer**: the project file tree with change letters.
|
||
4. **File / Editor**: exactly one open file under a bar (type badge, path, unsaved dot, `+N`/`−N`, Preview / Diff buttons). Changed lines are marked in the live code; Diff opens a full-screen side-by-side view; Preview renders Markdown; ⌘-click on a PHP class shows its definition and uses.
|
||
5. **Claude** (agent pane): a terminal that runs `claude` (configurable) over a plain shell. "Pass on to Agent" pastes a reference (and optional text) into the agent's composer **without** sending it.
|
||
6. **Terminal**: a plain shell in the project folder.
|
||
7. **Status bar**: branch, working-tree line totals, cursor position, indentation, encoding, language, active view. Display only.
|
||
|
||
Plus: ⌘F search (this file, project contents, file names) as a full-window overlay; recent files (⌘↑/⌘↓); recent projects (⇧⌘O) and a launcher start screen; a file watcher that keeps git, the tree and the open file in step with what the agent writes; Read aloud (system voice) of Markdown and selections; **Clean copy** (the agent writes `.clean-copy`, Helder pops up a "From Claude" card to copy it); **Plak** (send a selection to the user's scratchpad app through a `plak://` URL).
|
||
|
||
The whole UI is dark only. Code is always syntax highlighted (custom highlighter, no external library), in every panel and view.
|
||
|
||
---
|
||
|
||
## C. Architecture of the original (keep the boundaries)
|
||
|
||
```
|
||
Helder (executable) → HelderUI → HelderServices → HelderCore
|
||
└→ SwiftTerm (terminal emulator library, ≥ 1.9.0)
|
||
```
|
||
|
||
| Layer | May use | Rules |
|
||
|---|---|---|
|
||
| **Core** | the standard library only | Pure logic and value types, all thread-safe/immutable (`Sendable`). No UI, no disk, no processes. Parsers, diff, highlighting, Markdown, fuzzy match, config model, menus model, git derivation. |
|
||
| **Services** | Core, Foundation, CoreServices (FSEvents), AVFoundation (speech) | Everything that touches disk or spawns `git`/`rg`, each **behind an interface (protocol)** so the UI layer can be tested on fakes. Processes only through one process-runner interface. |
|
||
| **UI** | Core, Services, UI toolkit, terminal emulator | Observable main-thread stores plus views. Never runs a process or touches project files directly, only through the service interfaces (the two terminal emulators are the one exception). |
|
||
| **App** | UI | The entry point. Keep it tiny. |
|
||
|
||
### How a window works
|
||
|
||
- One **workspace model** (`WorkspaceModel`) owns one window. It owns the stores: `SourceControlStore` (git), `ExplorerStore`, `EditorStore`, `CleanCopyStore`, `TerminalStore`, `LayoutStore`, `OverlayStore`, `ToastStore`, `ReadAloudStore`, and every action that spans more than one store. 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 `perform(Command)`. Context-menu items arrive as `.context(ContextAction)`; the model first asks `SourceControlStore.confirmation(for:)` / `ExplorerStore.confirmation(for:)` and shows the confirm overlay when needed; `.confirmPending` then runs the action. The name prompt submits with `.submitName`, the pass-on prompt with `.passToAgent`.
|
||
- **Overlays never stack.** `OverlayStore.current` is one enum value; only the model presents or dismisses it. An `onChange` hook lets the model run closing behaviour however an overlay went away (the Diff gives back the mode it covered). The key router only sees an `OverlayKind` (`none`, `diff(busy:)`, `other`): over the Diff the workspace keys keep working unless the Diff's own menu or prompt is open (`busy`). Toasts may sit on top of any overlay. The Diff draws its own right-click menu and pass-on prompt inside itself, so it stays open.
|
||
- **Stores report, the model shows.** Stores raise toasts through `notify`/`showToast` hooks that the model wires to `ToastStore`; the model never toasts a second time for the same action.
|
||
- **Focus.** `WorkspaceModel.focusRequest` names where the keyboard should go (a column, the Git view's commit message); the view that takes it calls `focusTaken(_:)`. The editor text view follows `EditorStore.textFocusRequest`, which also moves when the Diff closes.
|
||
|
||
### Source map of the original (for orientation)
|
||
|
||
```
|
||
Core/
|
||
Agent/ AgentReference, BracketedPaste, TerminalLaunch (TERM_PROGRAM=Helder), CleanCopy (file name, new-text rule)
|
||
Config/ HelderConfig (tolerant decoding), config resolution, .env project title
|
||
Diff/ Diff models, LineDiff, DiffViews, ViewMode
|
||
Files/ FileNode + FileTree, PathUtils, FileType (language, badge), limits + ignore rules, ContextActions (menus), Plak
|
||
Git/ models, Porcelain parsing (incl. behind/upstream), GitDerivation (rows, commit text),
|
||
GitSections (four sections, InlineDiff), GitConsole (echo, input parsing, line classifier), GitBranches
|
||
Highlight/ SyntaxHighlighter + Lexer, one grammar per language (CSS, JSON, JavaScript, Markdown, Markup, PHP, Python, Shell, YAML)
|
||
Markdown/ block/inline tree and parser, MarkdownSpeech (the prose Read aloud speaks)
|
||
Search/ result models, Fuzzy, InFileSearch, rg --json parsing
|
||
Session/ SessionState, LayoutState, recents, ColumnLayout, cursor/selection/open options
|
||
Symbols/ PHP symbol models and line parsers
|
||
Services/
|
||
Files/ FileServicing (read, readText → .binary), FileService, FSEventsWatcher + WatchDebounce, DirectoryListing
|
||
Git/ GitServicing, GitService, GitDirectory (worktrees)
|
||
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
|
||
Search/ SearchServicing + RipgrepSearchService, ProjectScanner (rg, or a native walk)
|
||
Speech/ SpeechService (system voice), shared by the window
|
||
Symbols/ SymbolService
|
||
UI/
|
||
State/ WorkspaceModel (+Commands, +ContextActions, +Lifecycle, +Refresh), WorkspaceServices/AppServices, one file per store
|
||
Shell/ AppDelegate, scene + menus, window, window bridge (key monitor), AppName, KeyRouter, Command, SystemActions,
|
||
title bar, status bar, launcher, recent projects, toasts, focus flash
|
||
Components/ overlay shell/card/header/footer, context menu panel/row/separator/header, Keycap, EscChip, Primary/Secondary
|
||
buttons, focus ring, SegmentButton, Splitter, ButtonGroup, Tooltip, TypeBadge, PanelLabel/Header, Hairline,
|
||
selectable row, Blink, PointerPolicy
|
||
GitView/ top bar, commit block, sections with inline diffs, console, branches, git icon
|
||
Explorer/ tree column and row glyphs
|
||
Editor/ bar, code editor (document, layout, drawing, text view), Diff canvas + overlay, Markdown preview, pass-on panel, symbol popup
|
||
Terminal/ agent column, terminal view, colours, pane
|
||
Overlays/ OverlayHost, search, clean copy, shortcuts, recent files, context menu, name prompt, confirm, overlay keys
|
||
Theme/ Palette, Typography, Metrics, FontRegistry
|
||
Resources/Fonts/ IBM Plex Mono 400/500/600/700, IBM Plex Sans 400/500/600/700/400-italic (WOFF2, SIL OFL)
|
||
```
|
||
|
||
---
|
||
|
||
## D. Build, bundle, run (original) and what the rebuild needs
|
||
|
||
### Original scripts (behaviour to reproduce in the new toolchain)
|
||
|
||
| Script | Does |
|
||
|---|---|
|
||
| `build.sh [--release]` | Debug (or release) build. |
|
||
| `test.sh [--filter Name]` | Runs all three test targets; filter by suite (`GitServiceLoadTests`) or one test (`GitServiceLoadTests/aFileUnderTheSizeCapStillCarriesItsText`). Every test runs; there is no skip switch. |
|
||
| `run.sh [project-folder]` | Builds and runs; the optional folder (made absolute **before** changing directory) is passed as env `HELDER_PROJECT` and opens in the first window. |
|
||
| `bundle.sh [--install [--force]]` | Builds release and assembles `build/Helder.app`, ad-hoc signed, with ripgrep inside. `--install` copies to `~/Applications/Helder.app`; it **refuses** to replace an app there whose bundle id differs unless `--force`. |
|
||
|
||
`bundle.sh` in detail:
|
||
- Bundle id `nl.blijnder.helder`, version `0.2.0` (both `CFBundleShortVersionString` and `CFBundleVersion`).
|
||
- Layout: `Contents/MacOS/Helder`, `Contents/Resources/` (resource bundles — fonts — go here, never at the `.app` root, which would break the signature), `Contents/Helpers/rg`.
|
||
- ripgrep source order: `$RG_BINARY`, else `vendor/ripgrep/rg` (ripgrep 15, Apple-silicon build from `@vscode/ripgrep`, its MIT/Unlicense `LICENSE` beside it), else `rg` on `PATH`; else print `warning: no ripgrep found (set RG_BINARY); search falls back to a slow walk`.
|
||
- Icon: `assets/icon.png` (1024×1024 RGB PNG) → iconset sizes 16, 32, 128, 256, 512 at @1x and @2x → `Contents/Resources/Helder.icns`.
|
||
- Info.plist keys: `CFBundleExecutable=Helder`, `CFBundleIdentifier=nl.blijnder.helder`, `CFBundleName=Helder`, `CFBundleDisplayName=Helder`, `CFBundlePackageType=APPL`, `CFBundleIconFile=Helder`, `CFBundleInfoDictionaryVersion=6.0`, `LSMinimumSystemVersion=14.0`, `LSApplicationCategoryType=public.app-category.developer-tools`, `NSHighResolutionCapable=true`, `NSPrincipalClass=NSApplication`.
|
||
- `codesign --force --deep -s -` then `codesign --verify --deep --strict`; prints `built build/Helder.app`, and `installed <path>` after install; refusal message: `refusing to replace <target> (bundle id '<existing>'); pass --force to overwrite it`.
|
||
- Unknown option → `unknown option: <arg>` on stderr, exit 2.
|
||
|
||
`.gitignore`: `.build/`, `build/`, `.swiftpm/`, `screenshots/*`, `!screenshots/.gitignore`.
|
||
|
||
### Data the app owns (keep the same paths so users keep their data)
|
||
|
||
| What | Where |
|
||
|---|---|
|
||
| Recent projects | `~/Library/Application Support/Helder/recent-projects.json` |
|
||
| Log | `~/Library/Logs/Helder/helder.log` |
|
||
| Sessions, column layouts | user defaults, domain `nl.blijnder.helder` in the bundle (`Helder` when run unbundled) |
|
||
| Per-project config | `<project>/.helder/config.json` (user, sparse) and `<project>/.helder/config.default.json` (regenerated on launch) |
|
||
| Per-project recent files | `<project>/.helder/recent.json` (JSON array of project-relative paths, newest first) |
|
||
| Clean copy | `<project>/.clean-copy` (written by the agent, only read by Helder) |
|
||
|
||
Running the app on a scratch folder adds it to the recent-projects list; tests must never touch the real list, defaults or log.
|
||
|
||
---
|
||
|
||
## E. Build order
|
||
|
||
1. Core: models, path utils, file types, config model + resolution, porcelain parser, git derivation/sections, line diff, fuzzy, ripgrep JSON, Markdown parser, MarkdownSpeech, lexer + grammars, PHP symbol parsers, context-menu model, Plak URL builder, clean-copy rule. Port the Core tests (section 8) as you go.
|
||
2. Services: process runner (run + stream, timeouts, env), executable locator, child reaper, git service, file service (atomic save, containment), watcher, project scanner, search service, config service, recents/session stores, symbol service, speech, logger. Port the Services tests (they use real git in temp repos).
|
||
3. UI theme: palette, typography, metrics, fonts, components, pointer policy.
|
||
4. Shell: window, process-per-window, launcher, title bar, status bar, columns + splitters + toggles, key router, menus, overlays host, toasts.
|
||
5. Explorer, Editor (code view, bar, marking, Diff overlay, Markdown preview, symbols, pass-on), Terminals, Git view, Search, Recent files, Clean copy, Read aloud, Plak, dialogs.
|
||
6. Lifecycle (start order, watcher, polling, close/quit flow), session restore, config live reload.
|
||
7. UI-level tests on fakes (section 8).
|
||
|
||
---
|
||
|
||
## F. The spec
|
||
|
||
The sections below are the full specification, area by area. Each section is complete for its area; where two sections touch the same thing, they agree, and the more specific one wins.
|
||
|
||
| Section | Area |
|
||
|---|---|
|
||
| 1 | Visual design system: colours, type, metrics, fonts, components, file-type badges, pointer policy, icon |
|
||
| 2 | Shell: process model, commands, complete key map, menu bar, column layout, title bar, status bar, launcher, recent projects, toasts, overlays, dialogs, focus, close/quit |
|
||
| 3 | Git: commands, status parsing, models, sections, inline diff, console, commit/push/pull, branches, the Git view |
|
||
| 4 | Editor: one-file model, save rules, code view, change marks, LineDiff, Diff overlay, Markdown preview, PHP symbols, pass-on |
|
||
| 5 | Syntax highlighter and every grammar, Markdown parser, MarkdownSpeech, Read aloud |
|
||
| 6 | Files: tree, limits, ignore rules, file service, watcher, Explorer, new/rename/delete, search, recent files, every context menu, Plak, Clean copy |
|
||
| 7 | Terminals, pass-on bytes, process runner, the full config schema, lifecycle and refresh timings, logging |
|
||
| 8 | Acceptance catalogue: all 929 original tests as plain-English rules |
|
||
| Appendix | The original user guide and reference docs, verbatim (sections 1–8 win on conflict) |
|
||
|
||
### Facts that the old docs get wrong (the code is the truth)
|
||
|
||
- **⌘P is Push.** There is no fuzzy "Go to File" overlay; "Go to file" is the Recent files list (⌘↑/⌘↓ from the editor).
|
||
- **Editor settings** are only `editor.autoSave`, `editor.tabSize` and `editor.wordWrap`. There is no `lineNumbers` setting (numbers are always absolute), no trim-trailing-whitespace, final-newline, indent-guides, whitespace or active-line settings.
|
||
- **The agent and terminal panes have no header.** The agent runs as `<shell> -i -c "<ai.command>"` in a login shell.
|
||
- **Merge conflicts** are one unstaged `U` row in **changed**, Stage only, not counted as staged, marked in red: red `U` badge (tooltip `Merge conflict`), a red flag after the path (tooltip `Merge conflict — resolve, then Stage`), a red 3-pt left bar and a red 8 % row fill. Red `#E5534B` is the **one** red in the app; the Explorer shows the `U` letter in that red too.
|
||
- **Delete is permanent** (no Trash) and always asks first.
|
||
- **The terminal right-click menu** has Copy, Paste, Read aloud selection, Plak and (agent pane only) Wait what?.
|
||
- The search overlay is three columns (This file / Project / Files), not the 70/30 split of the old behaviour doc.
|
||
|
||
Each section ends with its own full list of doc-vs-code conflicts.
|
||
|
||
|
||
|
||
---
|
||
|
||
## 1. Visual design system and shared UI components
|
||
|
||
This section defines every visual token (colour, type, geometry, motion), the fonts that ship with the app, every shared UI component, the file-type table (language, label, badge), the mouse-pointer policy, and the app icon. The code is the source of truth; where the design handoff (`docs/design_handoff_helder_app_v2/`) disagrees, the code value is given and the conflict is listed at the end.
|
||
|
||
Ground rules that hold everywhere:
|
||
|
||
- **Dark only.** There is no light mode, by decision (`Palette.swift`, first line). The window uses the dark appearance and the window background is `#101720`.
|
||
- **Units are points** (macOS pt = CSS px at 1x). All colours are sRGB.
|
||
- **One accent: amber.** Amber is reserved for: focus, selection rule, current state, key glyphs, counts, the wordmark period, primary buttons. Nothing else is amber.
|
||
- **Flat.** No gradients, no blur, no texture. Only two shadows exist (menu, overlay). Nothing lifts, scales, slides or fades on hover or selection; only colours change.
|
||
- **Radii: 2 / 4 / 8.** 2 for buttons, inputs, tags, keycaps, badges, code blocks; 4 for panels, cards, menus; 8 for overlays only.
|
||
- **Disabled = 40% opacity and nothing else** (no recolouring), and it takes no clicks and shows the arrow pointer.
|
||
- **Code text is never bold or italic.** Syntax uses six muted colours at weight 400.
|
||
|
||
---
|
||
|
||
### 1.1 Colour tokens (`HelderUI/Theme/Palette.swift`)
|
||
|
||
A colour literal `0xRRGGBB` is read as sRGB with the given alpha (default 1). The same tokens exist as AppKit colours where needed (see 1.2).
|
||
|
||
#### Surfaces ("four, no more" plus focus/flash steps)
|
||
|
||
| Token | Value | Where used |
|
||
|---|---|---|
|
||
| `editor` | `#101720` | Editor canvas, terminal background, launcher backdrop, code blocks, full-screen overlay page (Search, Git view), window background |
|
||
| `panel` | `#18202B` | Title bar, side panels, status bar, overlay cards, context menus; resting fill of every workspace column |
|
||
| `raised` | `#232C39` | Selected row fill, every hairline border/divider, tooltip surface, keycap border, highlighted menu row, splitter at rest |
|
||
| `hover` | `#1E2733` | Row hover fill, button hover fill (only use) |
|
||
| `panelActive` | `#1B242F` | A side column (Explorer, terminal/agent) that has keyboard focus: one step of fill, nothing else |
|
||
| `editorActive` | `#131B25` | The editor column when it has keyboard focus |
|
||
| `refreshFlash` | `#0F1113` | Added on top of a column for a moment on ⌘R (blend mode "plus lighter", see Motion) |
|
||
|
||
Column fill rule (`Palette.column(_:active:)`): not focused → `panel`; focused → `editorActive` for the editor column, `panelActive` for any other column (`Panel` = explorer, editor, terminal).
|
||
|
||
#### Text on dark
|
||
|
||
| Token | Value | Where used |
|
||
|---|---|---|
|
||
| `text1` | `#F4F5F4` | Active file, dialog titles, selected row label, highlighted menu label, hovered secondary button label |
|
||
| `text2` | `#E4E7E6` | Body copy, plain code text, tooltip text |
|
||
| `text3` | `#BAC0C0` | Inactive rows, identifiers, secondary copy, menu labels at rest, action button labels |
|
||
| `text4` | `#6C7783` | Labels, paths, meta, comments, panel labels, esc chip, shortcut text in menus, off-state toggle labels |
|
||
| `text5` | `#3A424C` | Line numbers, disabled, off-state dot in a toggle |
|
||
| `onDeep` | `#F4F5F4` | Label on a destructive (amber-deep) button |
|
||
| `tooltipBorder` | `#3A424C` | Tooltip border |
|
||
| `textMuted` | `#828D9A` | Git view secondary meta between text-3 and text-4: sync label, author, directories, hints |
|
||
|
||
#### Accent (amber)
|
||
|
||
| Token | Value | Where used |
|
||
|---|---|---|
|
||
| `amber` | `#E8913A` | The accent: focus border, selection rule, key glyphs, counts, primary button fill, wordmark period, highlighted menu icon, splitter hover/drag, tooltip state word, git "staged" colour, console error lines |
|
||
| `amberDeep` | `#C4741F` | Destructive button fill; removed-diff colour in the editor |
|
||
| `amberSoft` | `#F0B476` | Numbers in syntax; amber badge; "modify" menu icons |
|
||
| `amberTint` | `#E8913A` @ 0.10 | Fill of an "on" toggle in a button group |
|
||
| `focusRing` | `#E8913A` @ 0.22 | The 2pt ring drawn outside a focused field's amber border |
|
||
| `amberKeycapBorder` | `#E8913A` @ 0.35 | Border of a lit key in the symbol popup |
|
||
| `ink` | `#171C22` | Text on an amber fill (always ink, never white) |
|
||
| `inkKeycapBorder` | `#171C22` @ 0.25 | Keycap border on an amber fill |
|
||
|
||
#### Syntax (six muted colours, weight 400, no italics)
|
||
|
||
| Token | Value | Token roles (`TokenRole`) |
|
||
|---|---|---|
|
||
| `syntaxPlain` | `#E4E7E6` | `plain` (plain text and function names), `symbol` (a project class name; ⌘-clickable, PHP only) |
|
||
| `syntaxVariable` | `#BAC0C0` | `variable` (variables and properties) |
|
||
| `syntaxComment` | `#6C7783` | `comment` |
|
||
| `syntaxKeyword` | `#C3A6CE` | `keyword` (keywords, operators, pseudo-classes) |
|
||
| `syntaxString` | `#8FBFB4` | `string` (strings, values, type paths) |
|
||
| `syntaxNumber` | `#F0B476` | `number` (numbers, tags, hex literals) |
|
||
|
||
#### Diff in the editor / diff overlay ("no green, no red; it reads on shape and the 2pt rule")
|
||
|
||
| Token | Value |
|
||
|---|---|
|
||
| `addedText` | `#8FBFB4` |
|
||
| `addedFill` | `#8FBFB4` @ 0.12 |
|
||
| `addedRule` | `#8FBFB4` |
|
||
| `removedText` | `#C4741F` (also the label/icon colour of a destructive menu item) |
|
||
| `removedFill` | `#C4741F` @ 0.14 |
|
||
| `removedRule` | `#C4741F` |
|
||
|
||
#### Overlays and elevation
|
||
|
||
| Token | Value | Where used |
|
||
|---|---|---|
|
||
| `scrim` | `#101720` @ 0.72 | Flat ink scrim behind every sized overlay; no blur |
|
||
| `menuShadow` | `#171C22` @ 0.10 | Context-menu shadow colour |
|
||
| `overlayShadow` | `#171C22` @ 0.18 | Overlay card shadow colour |
|
||
|
||
#### Type badges
|
||
|
||
| Token | Value |
|
||
|---|---|
|
||
| `badgePurple` | `#C3A6CE` |
|
||
| `badgeAmber` | `#F0B476` |
|
||
| `badgeTeal` | `#8FBFB4` |
|
||
| `badgeGrey` | `#BAC0C0` |
|
||
| `badgeText` | `#101720` (ink text on every badge fill) |
|
||
|
||
`Palette.badge(tint)` maps `purple/amber/teal/grey` to the four fills above.
|
||
|
||
#### Misc markers and menu icon tints
|
||
|
||
| Token | Value | Where used |
|
||
|---|---|---|
|
||
| `changedDot` | `#8FBFB4` | Dot on a file with a git change in Search and Recent files |
|
||
| `menuIconAdd` | `#8FBFB4` | Menu icon for actions that add |
|
||
| `menuIconModify` | `#F0B476` | Menu icon for actions that modify or leave the app |
|
||
| `menuIconRename` | `#BAC0C0` | Menu icon for rename or pass-on actions |
|
||
|
||
#### Git view
|
||
|
||
| Token | Value | Where used |
|
||
|---|---|---|
|
||
| `gitRowHover` | `#1F2834` | Git file row under the pointer |
|
||
| `commitIdleHover` | `#202834` | Idle (not-ready) Commit button under the pointer ("raised one step darker") |
|
||
| `gitModified` | `#F0B476` | Modified status colour |
|
||
| `gitNew` | `#8FBFB4` | New/untracked status colour |
|
||
| `gitDeleted` | `#C3A6CE` | Deleted status colour (staged is `amber`) |
|
||
| `gitStagedTint` | `#E8913A` @ 0.08 | STAGED section header fill |
|
||
| `gitModifiedTint` | `#F0B476` @ 0.06 | CHANGED section header fill |
|
||
| `gitNewTint` | `#8FBFB4` @ 0.06 | NEW · UNTRACKED header fill |
|
||
| `gitDeletedTint` | `#C3A6CE` @ 0.06 | DELETED header fill |
|
||
| `gitCurrentBranch` | `#E8913A` @ 0.08 | Current branch row fill |
|
||
| `inlineRemovedFill` | `#E8913A` @ 0.12 | Inline diff removed line |
|
||
| `inlineAddedFill` | `#8FBFB4` @ 0.12 | Inline diff added line |
|
||
| `inlineRemovedHighlight` | `#E8913A` @ 0.38 | Differing middle of a paired removed line |
|
||
| `inlineAddedHighlight` | `#8FBFB4` @ 0.36 | Differing middle of a paired added line |
|
||
| `inlineFiller` | `#232C39` @ 0.35 | The side of the inline diff that has no line |
|
||
|
||
Console line colour (`Palette.console(kind)`, `GitLineKind`): `command` → `text1`; `output` → `text3`; `error` → `amber`; `hint` → `textMuted`; `staged` and `success` → `gitNew` (#8FBFB4); `unstaged` → `gitModified` (#F0B476).
|
||
|
||
#### CSS colour parsing (`NSColor(css:)`)
|
||
|
||
Used for config-provided colours (terminal theme). Input is trimmed of spaces and lowercased. Accepts:
|
||
- `#RGB` (each digit doubled) and `#RRGGBB`;
|
||
- `rgb(r,g,b)` / `rgba(r,g,b,a)`: any string starting with `rgb` with a `(` and a final `)`; the inner text split on commas, each part trimmed and parsed as a number; exactly 3 or 4 numbers; r/g/b are 0–255, alpha 0–1 (default 1).
|
||
- Anything else (e.g. `teal`) → no colour (nil), and the caller falls back.
|
||
Tested: `#E8913A` → red 232/255; `rgba(232,145,58,0.22)` → alpha 0.22; `teal` → nil.
|
||
|
||
---
|
||
|
||
### 1.2 Editor and terminal colours
|
||
|
||
#### Editor (`HelderUI/Editor/EditorColors.swift`, `EditorFonts`)
|
||
|
||
| Name | Value | Use |
|
||
|---|---|---|
|
||
| `background` | `#101720` | Code canvas |
|
||
| `raised` | `#232C39` | Rules in the code view/diff canvas |
|
||
| `lineNumber` | `#3A424C` | Gutter numbers |
|
||
| `lineNumberActive` | `#BAC0C0` | The caret line's number (one step up) |
|
||
| `amber` | `#E8913A` | Caret |
|
||
| `selection` | `#E8913A` @ 0.22 | Text selection |
|
||
| `flash` | `#E8913A` @ 0.10 | Line flash (after a jump), lasts `flashDuration` = 1 s |
|
||
| `activeLine` | white @ 0.03 | Caret line highlight |
|
||
| `addedText`/`addedFill` | `#8FBFB4` / `#8FBFB4` @ 0.12 | Added line marker / fill |
|
||
| `removedText`/`removedFill` | `#C4741F` / `#C4741F` @ 0.14 | Removed line marker / fill |
|
||
| syntax | same six colours as Palette syntax | |
|
||
|
||
Editor font metrics:
|
||
- Code font: IBM Plex Mono Regular 13pt (`Typography.code`), never bold or italic.
|
||
- Zoom: font size = 13 × scale (scale 1 = actual size).
|
||
- Line height = round(20 × scale) (fixed min = max line height; every row exactly that tall).
|
||
- Baseline inside a row: (lineHeight − (ascender − descender)) / 2 + ascender, so glyphs centre vertically.
|
||
- Tab width: `tabSize` × width of one space in the current font (config default tabSize 4). No explicit tab stops.
|
||
- Text inset: top 10pt; bottom 40pt (room under the last line so it never sits on the pane edge).
|
||
- Base attributes: font, colour `syntaxPlain` (#E4E7E6), the paragraph style above.
|
||
|
||
#### Terminal (`HelderUI/Terminal/TerminalColors.swift`, `HelderCore/Config/HelderConfig.swift` `TerminalTheme`)
|
||
|
||
Default terminal theme (all overridable in project config; each value is a CSS colour parsed as above; an unparseable value falls back to the default's same entry, then to white):
|
||
|
||
| Key | Default |
|
||
|---|---|
|
||
| background | `#101720` |
|
||
| foreground | `#E4E7E6` |
|
||
| cursor | `#E8913A` |
|
||
| cursorAccent (text under a block cursor) | `#101720` |
|
||
| selectionBackground | `rgba(232,145,58,0.22)` |
|
||
| selectionInactiveBackground | `rgba(232,145,58,0.12)` (defined; not applied by the Swift terminal) |
|
||
| black | `#232C39` |
|
||
| red | `#C4741F` |
|
||
| green | `#8FBFB4` |
|
||
| yellow | `#F0B476` |
|
||
| blue | `#8FA9C4` |
|
||
| magenta | `#C3A6CE` |
|
||
| cyan | `#8FC4C4` |
|
||
| white | `#BAC0C0` |
|
||
| brightBlack | `#6C7783` |
|
||
| brightRed | `#E8913A` |
|
||
| brightGreen | `#A6D2C7` |
|
||
| brightYellow | `#F5C79A` |
|
||
| brightBlue | `#A9BFD6` |
|
||
| brightMagenta | `#D6BFDF` |
|
||
| brightCyan | `#A9D6D6` |
|
||
| brightWhite | `#F4F5F4` |
|
||
|
||
ANSI palette order (SGR 0–15): black, red, green, yellow, blue, magenta, cyan, white, brightBlack … brightWhite. Channels are converted to 16-bit (component × 65535).
|
||
|
||
Other terminal appearance defaults (`HelderConfig.Terminal`): font = configured family if set and found (by name, then by family with regular weight), else bundled `IBMPlexMono-Regular`, else the system monospaced font; size = configured `fontSize` or 12pt (`Typography.terminal`), times window zoom; `lineHeight` 1.7 and `letterSpacing` 0 exist in config but are **not applied** (no equivalent in the terminal library); cursor style `bar` with blink on (styles bar/block/underline × blink/steady); `boldIsBright` false (bold keeps its own hue); `scrollback` 8000 (negative clamped to 0); `optionIsMeta` false (Option keeps typing accents); terminal name `xterm-256color`. Restyling a live terminal never touches its buffer or process.
|
||
|
||
---
|
||
|
||
### 1.3 Fonts shipped (`HelderUI/Resources/Fonts/`, `Theme/FontRegistry.swift`)
|
||
|
||
Two families, IBM Plex Mono and IBM Plex Sans, Latin subset, WOFF2. Licence: SIL Open Font License 1.1 (`OFL.txt` ships next to the fonts; "Copyright 2017 IBM Corp."). No Google Fonts at runtime; no system download.
|
||
|
||
| File | PostScript name | Weight |
|
||
|---|---|---|
|
||
| `ibm-plex-mono-latin-400-normal.woff2` | `IBMPlexMono-Regular` | 400 |
|
||
| `ibm-plex-mono-latin-500-normal.woff2` | `IBMPlexMono-Medium` | 500 |
|
||
| `ibm-plex-mono-latin-600-normal.woff2` | `IBMPlexMono-SemiBold` | 600 |
|
||
| `ibm-plex-mono-latin-700-normal.woff2` | `IBMPlexMono-Bold` | 700 |
|
||
| `ibm-plex-sans-latin-400-normal.woff2` | `IBMPlexSans-Regular` | 400 |
|
||
| `ibm-plex-sans-latin-500-normal.woff2` | `IBMPlexSans-Medium` | 500 |
|
||
| `ibm-plex-sans-latin-600-normal.woff2` | `IBMPlexSans-SemiBold` | 600 |
|
||
| `ibm-plex-sans-latin-700-normal.woff2` | `IBMPlexSans-Bold` | 700 |
|
||
| `ibm-plex-sans-latin-400-italic.woff2` | `IBMPlexSans-Italic` | 400 italic |
|
||
|
||
Registration:
|
||
- Fonts are copied as a resource folder `Fonts` inside the resource bundle `Helder_HelderUI.bundle`.
|
||
- At launch, the registry looks for the `Fonts` folder in these bases, in order: the app's resources folder, the app bundle folder, the executable's folder, the folder next to the test bundle. For each base it tries `<base>/Helder_HelderUI.bundle/Fonts` then `<base>/Helder_HelderUI.bundle/Contents/Resources/Fonts`.
|
||
- Every file with extension `woff2`, `woff`, `ttf` or `otf` is registered for the **process only** (not system-wide). "Already registered" counts as success. The PostScript names of the registered faces are collected and logged (`fonts: registered …`).
|
||
- Registration runs once (thread-safe, cached); later calls return the cached name set. If the folder is missing, it logs a warning "bundled fonts not found; using the system fonts" and continues; a single failing file logs "cannot register <file>".
|
||
- **Fallback:** if a face is not available, a role falls back to the system monospaced font (mono faces) or the system UI font (sans faces) at the same size with matching weight (Medium → medium, SemiBold → semibold, Bold → bold, else regular; the italic falls back to regular system).
|
||
- Tests assert: all nine PostScript names register and resolve; `code` role resolves to `IBMPlexMono-Regular`; `row` role to `IBMPlexSans-Regular`; `commitButton` to `IBMPlexSans-SemiBold`.
|
||
|
||
---
|
||
|
||
### 1.4 Typography (`HelderUI/Theme/Typography.swift`)
|
||
|
||
A type role = face, size (pt), optional line-box height (pt; absent = the font's natural height), tracking, and an uppercase flag. Tracking is specified in em and converted to points as `em × size`. Applying a role sets the font, the tracking, the extra line spacing `max(0, lineHeight − natural)` where natural = ascender − descender + leading, and uppercase when flagged.
|
||
|
||
| Role | Face | Size | Weight | Line height | Tracking (em → pt) | Case | Usage |
|
||
|---|---|---|---|---|---|---|---|
|
||
| `sectionTitle` | Mono | 20 | 700 | 24 | −0.02 (−0.4pt) | | (defined; unused) |
|
||
| `dialogTitle` | Mono | 14 | 700 | 14 | 0 | | Overlay header title, confirm dialog title |
|
||
| `panelLabel` | Mono | 10 | 700 | natural | 0.14 (1.4pt) | UPPER | Section and panel labels (text-4), panel counts (amber) |
|
||
| `wordmark` | Mono | 13 | 700 | natural | 0.02 (0.26pt) | | Title-bar "Helder." |
|
||
| `launcherWordmark` | Mono | 14 | 700 | natural | 0.02 (0.28pt) | | Launcher wordmark |
|
||
| `crumbLeaf` | Mono | 12 | 600 | natural | 0 | | Last breadcrumb segment in the title bar |
|
||
| `chip` | Mono | 11 | 400 | natural | 0 | | `esc`/`↵` chip, overlay footer hints, menu shortcut text |
|
||
| `keycapSmall` | Mono | 11 | 600 | natural | 0 | | Small keycap; key hint inside a group button |
|
||
| `toastTitle` | Sans | 13 | 400 | natural | 0 | | Toast text |
|
||
| `toastReference` | Mono | 12 | 400 | natural | 0 | | Path/reference in a toast |
|
||
| `focusFlash` | Mono | 19 | 400 | natural | 0 | | Branch · project card shown when a window becomes key |
|
||
| `focusFlashName` | Mono | 19 | 700 | natural | −0.01 (−0.19pt) | | Name in the focus-flash card |
|
||
| `code` | Mono | 13 | 400 | 20 | 0 | | Editor code, code blocks |
|
||
| `searchHit` | Mono | 12 | 400 | 24 | 0 | | Search hit lines, symbol popup rows |
|
||
| `path` | Mono | 12 | 400 | natural | 0 | | Paths, overlay header detail, title-bar crumbs |
|
||
| `meta` | Mono | 11 | 400 | natural | 0 | | Meta text, context-menu header, status bar |
|
||
| `branch` | Mono | 12 | 500 | natural | 0 | | Branch name (title bar, Git top bar) |
|
||
| `keycap` | Mono | 12 | 600 | natural | 0 | | Keycap; the `?` toolbar glyph |
|
||
| `statusLetter` | Mono | 10 | 600 | natural | 0 | | Git status letter in Search / Recent files |
|
||
| `badge` | Mono | 8 | 600 | natural | 0 | | (defined; unused: the type badge uses Mono 600 10, see conflicts) |
|
||
| `searchQuery` | Mono | 16 | 500 | natural | 0 | | The search query field |
|
||
| `terminal` | Mono | 12 | 400 | 20.4 | 0 | | Terminal font size (line height not applied) |
|
||
| `row` | Sans | 13 | 400 | natural | 0 | | List/tree row label |
|
||
| `rowSelected` | Sans | 13 | 500 | natural | 0 | | Selected row label |
|
||
| `rowSmall` | Sans | 12 | 400 | natural | 0 | | Small rows (search) |
|
||
| `body` | Sans | 14 | 400 | 23.8 | 0 | | Body copy, Markdown preview body, empty states |
|
||
| `tooltip` | Sans | 12 | 400 | 18 | 0 | | Tooltip text (12/1.5) |
|
||
| `button` | Sans | 12 | 500 | natural | 0 | | Primary/secondary buttons, group buttons, Git buttons |
|
||
| `commitButton` | Sans | 12 | 600 | natural | 0 | | (defined; unused in views) |
|
||
| `segment` | Sans | 11 | 400 | natural | 0 | | Editor bar Preview/Diff segment (off) |
|
||
| `segmentOn` | Sans | 11 | 500 | natural | 0 | | Segment (on) |
|
||
| `toolbarLabel` | Sans | 12 | 400 | natural | 0 | | Diff overlay toolbar labels |
|
||
| `menuItem` | Sans | 13 | 400 | natural | 0 | | Context menu row |
|
||
| `menuItemHighlighted` | Sans | 13 | 500 | natural | 0 | | Highlighted menu row |
|
||
| `menuItemEmphasized` | Sans | 13 | 600 | natural | 0 | | Main item of a menu ("Open in editor") |
|
||
| `note` | Mono | 14 | 400 | 23.8 | 0 | | Scratch note / overlay text editor |
|
||
| `markdownH2` | Mono | 24 | 700 | 26.4 | −0.03 (−0.72pt) | | Markdown h1/h2 |
|
||
| `markdownH3` | Mono | 17 | 700 | 20.4 | 0 | | Markdown h3 |
|
||
| `markdownQuote` | Sans Italic | 15 | 400 italic | natural | 0 | | Markdown blockquote |
|
||
| `gitLabel` | Mono | 11 | 700 | natural | 0.14 (1.54pt) | UPPER | `[ git ]` and Git section labels |
|
||
| `gitCount` | Mono | 11 | 600 | natural | 0 | | ↓2 / ↑1 counts, ⌘G hint, section count badge |
|
||
| `commitMessage` | Mono | 14 | 400 | 22.4 | 0 | | Commit message field |
|
||
| `gitCommitButton` | Sans | 13 | 600 | natural | 0 | | Commit split button label |
|
||
| `gitStatusLetter` | Mono | 11 | 700 | natural | 0 | | Git file-row status badge letter |
|
||
| `gitPath` | Mono | 13 | 400 | natural | 0 | | Git file-row path |
|
||
| `gitStats` | Mono | 12 | 500 | natural | 0 | | `+N` / `−N` stats |
|
||
| `inlineDiff` | Mono | 13 | 400 | 22 | 0 | | Git inline diff |
|
||
| `gitEmpty` | Sans | 13 | 400 | 20.8 | 0 | | Git "No changes" empty state |
|
||
| `console` | Mono | 12 | 400 | 19.2 | 0 | | Git console log and input |
|
||
| `branchCurrent` | Mono | 12 | 600 | natural | 0 | | Current branch name |
|
||
|
||
Weights → faces: 400 Regular, 500 Medium, 600 SemiBold, 700 Bold.
|
||
|
||
---
|
||
|
||
### 1.5 Metrics and geometry (`HelderUI/Theme/Metrics.swift`)
|
||
|
||
#### Rows and bars
|
||
|
||
| Constant | Value (pt) | Meaning |
|
||
|---|---|---|
|
||
| `explorerRow` | 24 | Explorer tree row height |
|
||
| `statusBar` | 28 | Status bar height |
|
||
| `contextMenuItem` | 30 | Context menu row height |
|
||
| `panelHeader` | 34 | The one top-bar height: Explorer head, Diff bar, `PanelHeader` default |
|
||
| `editorBar` | 34 | Bar above the code (file, change counts, Preview, Diff) |
|
||
| `titleBar` | 44 | Title bar height |
|
||
| `codeLine` | 20 | Code line height at zoom 1 |
|
||
| `searchHitLine` | 24 | Search hit line height |
|
||
| `diffOverlayLine` | 22 | Diff overlay line height |
|
||
| `launcherRow` | 38 | Launcher row height |
|
||
| `launcherNewRow` | 46 | Launcher "new/open" row height |
|
||
| `searchQueryBar` | 54 | Search query bar height |
|
||
|
||
#### Radii, lines
|
||
|
||
| Constant | Value | Meaning |
|
||
|---|---|---|
|
||
| `radiusSmall` | 2 | Buttons, inputs, tags, keycaps, badges, code blocks |
|
||
| `radiusMedium` | 4 | Panels, cards, menus |
|
||
| `radiusOverlay` | 8 | Overlays only |
|
||
| `hairline` | 1 | Every divider/border |
|
||
| `accentRule` | 2 | Selection rule, focus border, pull-quote rule |
|
||
| `focusRingWidth` | 2 | Focus ring drawn outside the 2pt amber border |
|
||
|
||
#### Columns and gutters
|
||
|
||
| Constant | Value | Meaning |
|
||
|---|---|---|
|
||
| `explorerWidth` | 288 | Default Explorer width |
|
||
| `agentWidth` | 480 | Default Claude/terminal column width |
|
||
| `minEditorWidth` | 280 | Minimum editor width |
|
||
| `explorerIndent` | 16 | Per-depth indent in the tree |
|
||
| `explorerBaseIndent` | 12 | Indent of depth 0 |
|
||
| `codeGutter` | 56 | Editor gutter width |
|
||
| `diffOverlayGutter` | 52 | Diff overlay gutter width |
|
||
| `searchHitGutter` | 64 | Search hit gutter width |
|
||
| `trafficLightInset` | 82 | Room the hidden-inset title bar leaves for the window buttons |
|
||
| `trafficLightOrigin` | (x 14, y 12) | Window buttons' position from the window's top-left |
|
||
| `splitterHitArea` | 7 | Pointer target of a 1pt splitter: 3pt either side of the line |
|
||
|
||
#### Title bar and toolbar
|
||
|
||
| Constant | Value | Meaning |
|
||
|---|---|---|
|
||
| `titleBarGap` | 18 | Gap between title-bar groups |
|
||
| `titleClusterGap` | 10 | Gap inside the wordmark/crumb cluster |
|
||
| `crumbGap` | 7 | Gap between breadcrumb segments |
|
||
| `groupButtonPadding` | top 6, leading 10, bottom 6, trailing 10 | Padding inside a `ButtonGroup` button |
|
||
| `groupButtonGap` | 7 | Gap between dot, label and key inside a group button |
|
||
| `groupButtonDot` | 6 | Diameter of a toggle's state dot |
|
||
| `toolbarIconGap` | 8 | Between the toolbar group and the `?` |
|
||
| `toolbarIconButton` | 26 | The `?` square button side |
|
||
| `statusBarGap` | 16 | Gap between status bar items |
|
||
|
||
#### Window
|
||
|
||
| Constant | Value |
|
||
|---|---|
|
||
| `defaultWindow` | 1680 × 1040 |
|
||
| `minimumWindow` | 1100 × 680 |
|
||
|
||
#### Overlays
|
||
|
||
| Constant | Value | Meaning |
|
||
|---|---|---|
|
||
| `overlayInset` | 34 | Padding around a sized overlay card inside the window |
|
||
| `contextMenuWidth` | 320 | Context menu width |
|
||
| `passOnWidth` | 460 | Pass-on prompt width |
|
||
| `launcherWidth` | 520 | Launcher width |
|
||
| `launcherTopPadding` | 40 | Launcher top padding |
|
||
| `launcherFooter` | 36 | Launcher footer height |
|
||
| `tooltipMaxWidth` | 300 | Tooltip wraps beyond this |
|
||
| `tooltipDelay` | 350 ms | Hover rest time before a tooltip shows |
|
||
| `toastBottom` | 44 | Toasts stack this far above the window bottom |
|
||
|
||
#### Elevation (only two shadows exist)
|
||
|
||
| Constant | Value | Notes |
|
||
|---|---|---|
|
||
| `menuShadowRadius` | 16 | CSS-style blur; SwiftUI is given radius 16/2 = 8 |
|
||
| `menuShadowY` | 4 | y offset |
|
||
| `overlayShadowRadius` | 48 | CSS-style blur; SwiftUI radius 48/2 = 24 |
|
||
| `overlayShadowY` | 16 | y offset |
|
||
|
||
So, in CSS terms: menu shadow `0 4px 16px rgba(23,28,34,0.10)`, overlay shadow `0 16px 48px rgba(23,28,34,0.18)`.
|
||
|
||
#### Motion (colour transitions only)
|
||
|
||
| Constant | Value | Use |
|
||
|---|---|---|
|
||
| `colorTransition` | cubic-bezier(0.22, 1, 0.36, 1), 160 ms | Row hover fill |
|
||
| `smallControlTransition` | cubic-bezier(0.22, 1, 0.36, 1), 120 ms | Buttons, toggles, focus ring, splitter colour |
|
||
| `blinkInterval` | 1.1 s | Stepped on/off blink (caret, terminal cursor, wordmark period); no fade |
|
||
| `refreshFlashDuration` | 0.26 s | ⌘R column flash fade-out (ease-out) |
|
||
| `focusFlashDuration` | 500 ms | How long the branch · project card shows when a window becomes key again |
|
||
|
||
Blink rule: on during the first half (0.55 s) of each 1.1 s cycle, off during the second half; computed from wall-clock time as `floor(t / 0.55)` even → on. Re-evaluated every 0.55 s. Opacity jumps 1 ↔ 0.
|
||
|
||
Refresh flash: on each ⌘R tick, a `#0F1113` layer is laid over the column with "plus lighter" blending at opacity 1, then animated to opacity 0 over 0.26 s ease-out; takes no clicks; each new tick replays it.
|
||
|
||
---
|
||
|
||
### 1.6 Shared components (`HelderUI/Components/`)
|
||
|
||
#### Hairline (`Hairline.swift`)
|
||
- A 1pt rectangle filled `raised` (#232C39). Horizontal = a row divider (full width, 1pt tall); vertical = a column divider (1pt wide, full height).
|
||
- Edge helper: draws a hairline along one edge (top/bottom/leading/trailing) as an overlay, without changing layout.
|
||
- Use for every border between panels, rows and bars.
|
||
|
||
#### Wordmark and blink (`Blink.swift`)
|
||
- Wordmark = text `Helder` in `text1` followed immediately by `.` in `amber`, the period blinking (1.1 s stepped). Baseline-aligned, no spacing, role `wordmark` (Mono 700 13, tracking 0.02em) by default; the launcher uses `launcherWordmark` (Mono 700 14). Never truncated.
|
||
- Blink modifier can be applied to any view (caret, terminal cursor); when inactive, the view is shown steadily.
|
||
|
||
#### Primary button (`Buttons.swift`, `PrimaryButtonStyle`)
|
||
- Fill `amber` (#E8913A), label `ink` (#171C22), role `button` (Sans 500 12), padding 6 vertical × 10 horizontal, radius 2. Pointer: hand.
|
||
- Destructive variant (Delete, Discard): fill `amberDeep` (#C4741F), label `onDeep` (#F4F5F4).
|
||
- No hover or pressed colour change in code (see conflicts). Disabled: via `disabledLook` (40% opacity, no clicks, arrow).
|
||
|
||
#### Secondary button (`SecondaryButtonStyle`)
|
||
- Transparent fill, 1pt `raised` border, radius 2, label `text3`, role `button`, padding 6 × 10. Pointer: hand.
|
||
- Hover or pressed: label `text1`, fill `hover` (#1E2733). Transition 120 ms.
|
||
|
||
#### Focus ring (`focusRing(isFocused, cornerRadius = 2)`)
|
||
- At rest: 1pt `raised` border inside the shape.
|
||
- Focused: 2pt `amber` border inside the shape, plus a ring outside: a rounded rect with radius `cornerRadius + 2`, extending 2pt beyond the shape on every side, filled `focusRing` (amber @ 0.22) behind the field. Transition 120 ms.
|
||
- Rule: never remove the field border.
|
||
|
||
#### Disabled look (`disabledLook(isDisabled)`)
|
||
- Opacity 0.4, hit testing off, and it turns off the pointing hand for every clickable inside it (they show the arrow).
|
||
|
||
#### Button group (`ButtonGroup.swift`) — title-bar toggles and toolbar
|
||
- Buttons edge to edge in one box with a 1pt `raised` border, radius 2; a 1pt `raised` vertical hairline at the leading edge of every button except the first. The group is not clipped (so tooltips can hang below); each button's fill follows the group's rounded outer corners (first button rounds its left corners 2pt, last its right corners).
|
||
- Each item: label, optional key hint, kind = `action` or `toggle(isOn)`, tooltip text, action. Identity can be held by an id while the label changes (e.g. "Git 3").
|
||
- Layout: horizontal, gap 7, padding 6/10/6/10, one line, never wraps.
|
||
- Toggle: a 6pt circle first. Dot = `amber` when on, `text5` when off.
|
||
- Label role `button` (Sans 500 12). Colour: on → `text1`; off → `text4`; action → `text3`.
|
||
- Key hint role `keycapSmall` (Mono 600 11): `text4` when the toggle is off; else `amber`.
|
||
- Fill: on → `amberTint` (amber @ 0.10); else hover → `hover`; else clear. Transitions 120 ms on hover and on kind change.
|
||
- Selected accessibility trait while on. Pointer: hand. Tooltip on every button, placed under it, aligned to the group's chosen edge (leading by default).
|
||
|
||
#### Toolbar icon button (`ToolbarIconButton`) — the `?`
|
||
- 26 × 26 square, 1pt `raised` border, radius 2. Glyph text in role `keycap` (Mono 600 12), `text4` at rest, `text1` on hover; fill `hover` on hover, else clear. 120 ms. Pointer: hand.
|
||
|
||
#### Segment button (`SegmentButton.swift`) — editor bar Preview / Diff
|
||
- Padding 12 horizontal × 5 vertical, radius 2 (clipped), 1pt `raised` border.
|
||
- Off: role `segment` (Sans 400 11), label `text3`, clear fill; hover → label `text1`, fill `hover`.
|
||
- On: role `segmentOn` (Sans 500 11), label `ink`, fill `amber`.
|
||
- Selected accessibility trait when on. Pointer: hand. 120 ms hover transition.
|
||
|
||
#### Keycap (`Keycap.swift`)
|
||
- Text in role `keycap` (Mono 600 12) or `keycapSmall` (Mono 600 11) when small; padding 6 horizontal × 4 vertical; 1pt border; radius 2; never wraps.
|
||
- Styles:
|
||
- normal: glyph `amber`, border `raised`.
|
||
- on amber (inside a primary button): glyph `ink`, border `ink` @ 0.25.
|
||
- on deep (inside a destructive button): glyph `onDeep` (#F4F5F4), border `onDeep` @ 0.4.
|
||
- Glyphs are literal strings, e.g. `⌘G`, `⌘↵`, `⇧⌘O`, `esc`, `↵`, `⌘1`. Use for every shortcut shown in the UI.
|
||
|
||
#### Esc chip (`EscChip`)
|
||
- Text `esc` (or `↵`) in role `chip` (Mono 400 11), `text4`, padding 6 × 4, 1pt `raised` border, radius 2. Sits at the right of an overlay header or footer.
|
||
|
||
#### Panel label and panel header (`PanelLabel.swift`)
|
||
- Panel label: title in role `panelLabel` (Mono 700 10, uppercase, tracking 1.4pt), `text4`; spacer; optional count in the same role in `amber`.
|
||
- Panel header (column header bar): title (panel label style), spacer (min 8), optional trailing content, gap 8; padding 12 horizontal; height 34 (`panelHeader`) by default; hairline at the bottom.
|
||
|
||
#### Selectable row (`SelectableRow.swift`) — every list
|
||
- Selected: fill `raised` (#232C39) + a 2pt `amber` rule on the leading edge, full row height.
|
||
- Hovered (not selected): fill `hover` (#1E2733).
|
||
- Else clear. Hover change animates with `colorTransition` (160 ms). Nothing lifts, scales or fades.
|
||
|
||
#### Context menu (`ContextMenuStyle.swift`)
|
||
- **Panel:** width 320; vertical padding 8 (top and bottom); fill `panel`; 1pt `raised` border; radius 4; menu shadow (`#171C22` @ 0.10, blur 16, y 4). Content is a vertical stack, no spacing.
|
||
- **Header (optional, first):** the path in role `meta` (Mono 11), `text4`, one line, truncated in the middle; padding 14 horizontal; 8 below the text, then a bottom hairline, then another 8 below the hairline.
|
||
- **Row:** height 30; leading padding 16, trailing 14; horizontal gap 10.
|
||
- Icon slot 15pt wide: SF Symbol at 12pt light weight, or the custom **spark** glyph (see below) drawn 13 × 13 as a stroke of width 1.1 × 13/16 ≈ 0.894pt with round joins.
|
||
- Label: role `menuItem` (Sans 400 13) at rest, `menuItemHighlighted` (Sans 500 13) when highlighted, `menuItemEmphasized` (Sans 600 13) for the menu's main item (always, regardless of highlight).
|
||
- Spacer (min 8), then optional shortcut text in role `chip` (Mono 11), `text4`.
|
||
- Highlighted (keyboard or hover): fill `raised`, 2pt `amber` rule on the leading edge, label `text1`.
|
||
- Not highlighted: clear fill, label `text3`.
|
||
- Icon tint rules, in priority order: destructive → `removedText` (#C4741F) in every state (label too); explicit tint (`menuIconAdd` teal #8FBFB4, `menuIconModify` amber-soft #F0B476, `menuIconRename` grey #BAC0C0) is kept in every state including highlighted; otherwise `amber` when highlighted, `text4` at rest.
|
||
- Pointer: hand on the whole row.
|
||
- **Separator:** a 1pt `raised` hairline with 6pt above and 6pt below.
|
||
- **Spark glyph** (`SparkGlyph`, used for every "Pass on" action): a closed 8-point polygon on a 16-unit grid (unit = min(width, height)/16), points in order: (8, 1.5), (9.6, 6.4), (14.5, 8), (9.6, 9.6), (8, 14.5), (6.4, 9.6), (1.5, 8), (6.4, 6.4). A four-pointed star; the app icon uses the same shape.
|
||
|
||
#### Tooltip (`Tooltip.swift`)
|
||
- Surface `raised` (#232C39), 1pt border `tooltipBorder` (#3A424C), radius 2, padding 10 horizontal × 8 vertical. No arrow, no shadow.
|
||
- Text role `tooltip` (Sans 400 12, line height 18), colour `text2`, left aligned.
|
||
- Width: its one-line ideal width if ≤ 300; otherwise exactly 300 wide, wrapping and growing taller.
|
||
- "Stated" form: `<lead><state><rest>` where lead and rest are `text2` and the state word is `amber` (name the current state, then say what a click does), e.g. "Explorer: *shown* — click to hide".
|
||
- Behaviour: when the pointer enters the host, start a 350 ms timer; if not cancelled, show. Leaving the host hides immediately and cancels the timer. A click (tap) on the host cancels the timer and hides. The tip hangs from the host's bottom edge, offset 8pt down, aligned to the host's leading edge (or centre/trailing when asked); it takes no clicks. While shown the host is lifted above its siblings (z-order 1); the host's container must also sit above the views below it (e.g. the title bar sits above the columns).
|
||
|
||
#### Overlay shell and card (`OverlayShell.swift`)
|
||
- **Full-screen placement** (Search, and the Git view pattern): content fills the whole window edge to edge, including title and status bar areas, on `editor` (#101720); no scrim, nothing to click to dismiss; the whole area swallows clicks.
|
||
- **Sized placement:** a full-window `scrim` (#101720 @ 0.72, flat, no blur); a click on the scrim dismisses. On top, an overlay card of the given width, top-aligned and horizontally centred, with 34pt padding (`overlayInset`) around it (so it starts 34pt below the window top).
|
||
- **Overlay card:** fill `panel`, clipped to radius 8, 1pt `raised` border at radius 8, overlay shadow (`#171C22` @ 0.18, blur 48, y 16). Used alone by surfaces that place themselves (launcher, pass-on prompt).
|
||
- **Overlay header:** height 50 by default; padding 18 horizontal; gap 12. Left to right: SF Symbol icon 14pt light (colour `amber` by default, overridable); title in role `dialogTitle` (Mono 700 14) `text1`; optional detail in role `path` (Mono 12) `text4`, one line; spacer (min 12); optional trailing content; the `esc` chip unless hidden. Hairline at the bottom.
|
||
- **Overlay footer:** height 38; padding 18 horizontal; gap 14; hairline at the top. Left: hints in role `chip` (Mono 11); spacer; optional trailing content.
|
||
- **Footer hint format:** pairs (keys, action) joined as `keys action · keys action`, where keys are `amber`, the action text (preceded by one space) is `text4`, and the separator ` · ` is `text4`. Example: `⌘↑↓ navigate · ↵ open`.
|
||
|
||
#### Splitter (`Splitter.swift`)
|
||
- Visual: a 1pt line (vertical for a column divider, horizontal for a row divider), `raised` at rest, `amber` while hovered or dragged; 120 ms colour transition. It sits above neighbours (z 5).
|
||
- Hit area: 7pt across (3pt each side of the line), centred on it.
|
||
- Cursor: left-right resize cursor for a column divider, up-down resize for a row divider. The splitter owns its cursor (its own cursor rect and tracking area for enter/exit/cursor-update, active whenever the app is active), and sets it on enter, on every cursor update, on mouse down and on every drag event.
|
||
- Accepts the first click even when the window is not key.
|
||
- Drag: on mouse down, remember the start point, reset "last" to 0, **disable all cursor rects in the window** (the columns resize under the pointer and would rebuild their I-beam rects), set the resize cursor, report dragging = true. On each drag event, compute the movement from the start (vertical splitter: x − startX; horizontal splitter: startY − y in bottom-up window coords, i.e. positive = downward), report the **delta since the previous call**, then store it. On mouse up: end the drag (re-enable cursor rects and rebuild them, dragging = false); if the mouse is still inside the handle, keep the resize cursor, else schedule a pointer re-read; report hover = inside; call `onEnd` (persist). Mouse exit during a drag does not clear the hover state. If the view leaves the window mid-drag, the drag ends cleanly.
|
||
|
||
#### Type badge (`TypeBadge.swift`)
|
||
- Fixed 28 × 16 chip, radius 2, fill = badge tint colour, text = badge label in Mono 600 10, colour `badgeText` (#101720), one line. The fixed width keeps file names beside it in one column.
|
||
|
||
---
|
||
|
||
### 1.7 File types (`HelderCore/Files/FileType.swift`)
|
||
|
||
**Extension rule (`ext`)**: take the basename (last `/`-separated segment). If the basename starts with `.env` the extension is `env` (so `.env`, `.env.local`, `.env.production`, and even `.envrc` → `env`). Else, if there is no `.`, the extension is empty. Else it is the text after the **last** dot, lowercased (`logo.PNG` → `png`, `.gitignore` → `gitignore`, `a.blade.php` → `php`).
|
||
|
||
**Highlighter language** (`Language`: php, javascript, jsx, typescript, tsx, python, markup, css, json, markdown, bash, yaml):
|
||
|
||
| Extension | Language |
|
||
|---|---|
|
||
| php | php |
|
||
| js, mjs, cjs | javascript |
|
||
| jsx | jsx |
|
||
| ts | typescript |
|
||
| tsx | tsx |
|
||
| py | python |
|
||
| html, xml, svg, vue | markup |
|
||
| css, scss | css |
|
||
| json | json |
|
||
| md | markdown |
|
||
| sh, bash, env | bash |
|
||
| yml, yaml | yaml |
|
||
| anything else | none (plain text, no highlighting) |
|
||
|
||
Markdown = language is markdown (only `.md`).
|
||
|
||
**Status-bar language label**:
|
||
|
||
| Extension | Label |
|
||
|---|---|
|
||
| php | PHP |
|
||
| js, mjs, jsx | JavaScript |
|
||
| ts, tsx | TypeScript |
|
||
| py | Python |
|
||
| html | HTML |
|
||
| css | CSS |
|
||
| json | JSON |
|
||
| md | Markdown |
|
||
| sh | Shell |
|
||
| env | Dotenv |
|
||
| yml, yaml | YAML |
|
||
| (no extension) | Plain Text |
|
||
| any other | the extension uppercased (e.g. `a.rs` → `RS`, `.vue` → `VUE`, `.cjs` → `CJS`, `.bash` → `BASH`) |
|
||
|
||
**Images** (shown as a picture, not text): png, jpg, jpeg, gif, webp, svg, bmp, ico, avif, apng, jfif (case-insensitive via `ext`).
|
||
|
||
**Never opens:** basename `composer.lock` → the viewer flashes "Too big." instead.
|
||
|
||
**Badges** — first by exact basename, then by extension, else fallback:
|
||
|
||
| Match | Badge text | Tint | Fill colour |
|
||
|---|---|---|---|
|
||
| basename `composer.json` | json | purple | #C3A6CE |
|
||
| basename `package.json` | json | amber | #F0B476 |
|
||
| basename `.env` | env | teal | #8FBFB4 |
|
||
| php | php | purple | #C3A6CE |
|
||
| blade (a file ending `.blade`) | php | purple | #C3A6CE |
|
||
| ts | ts | purple | #C3A6CE |
|
||
| tsx | tsx | purple | #C3A6CE |
|
||
| vue | vue | purple | #C3A6CE |
|
||
| js, mjs, cjs | js | amber | #F0B476 |
|
||
| jsx | jsx | amber | #F0B476 |
|
||
| json | json | amber | #F0B476 |
|
||
| yml, yaml | yml | amber | #F0B476 |
|
||
| css | css | teal | #8FBFB4 |
|
||
| scss | scss | teal | #8FBFB4 |
|
||
| pcss | css | teal | #8FBFB4 |
|
||
| html | html | teal | #8FBFB4 |
|
||
| sh | sh | teal | #8FBFB4 |
|
||
| env (any `.env*`) | env | teal | #8FBFB4 |
|
||
| py | py | teal | #8FBFB4 |
|
||
| sql | sql | teal | #8FBFB4 |
|
||
| md | md | grey | #BAC0C0 |
|
||
| txt | txt | grey | #BAC0C0 |
|
||
| lock | lock | grey | #BAC0C0 |
|
||
| svg | svg | grey | #BAC0C0 |
|
||
| any other extension | first 4 characters of the extension (lowercased) | grey | #BAC0C0 |
|
||
| no extension | `·` (middle dot) | grey | #BAC0C0 |
|
||
|
||
Badge text colour is always `#101720`. Tested examples: `src/A.php` → php/purple; `package.json` → json/amber; `composer.json` → json/purple; `.env.local` → env/teal; `Makefile` → `·`/grey; `a.tsx` → language tsx; `a.yml` → "YAML"; `a.rs` → "RS"; `logo.PNG` is an image. Note: `.blade.php` files get the `php` badge through their last extension.
|
||
|
||
---
|
||
|
||
### 1.8 Mouse pointer policy (`Components/PointerPolicy.swift`, `PointerBoundTextView.swift`)
|
||
|
||
#### The rule (user-visible)
|
||
The pointer shows what a left click does at that spot, and depends only on what lies under the mouse. Only five pointers exist: arrow, I-beam, pointing hand, left-right resize, up-down resize.
|
||
|
||
- **Pointing hand** only where a left click runs an action: buttons (title-bar toggles and tools, `?`, Preview, Diff, Git view buttons and section headers, dialog buttons, Collapse, search chips), clickable rows (Git 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 right-click, hover or a tooltip. Apply it to the exact view a click acts on, never a container.
|
||
- **I-beam** where a click places a caret or starts a text selection: the code (including the empty area below the last line), the Markdown preview, both terminals, the commit message, the Git console (log and input), every overlay input.
|
||
- **Arrow** everywhere else: labels, headers, folder labels, the code gutter (line-number ruler), scroll bars, the status bar, scrims, toasts, empty states, a disabled button (e.g. Commit with nothing staged).
|
||
- **Overlay layer:** with an overlay open (any overlay, and the Git view counts as an overlay), every column behind it shows the arrow; the overlay's own buttons, rows and inputs keep their pointers. If an overlay opens over the Git view, the Git view becomes "behind" too.
|
||
- **Splitter:** resize arrow (see 1.6). **⌘ held over a known PHP class name** in the code: pointing hand (instead of the I-beam).
|
||
- **Drag selection:** once a drag-selection starts in a text area, the I-beam stays until mouse-up, wherever the mouse goes (over buttons, other columns, under overlays).
|
||
|
||
#### Decision functions (pure, tested)
|
||
State for text: layer (`workspace` | `overlay`), overlayOpen, isEnabled (false for a disabled field, or a text view kept alive but hidden), isOverText (the point lies on the text area and no other view covers it), isSelecting.
|
||
|
||
- Text: if isSelecting → I-beam. Else if isEnabled AND isOverText AND NOT behindOverlay → I-beam. Else arrow.
|
||
- Clickable: if isSelecting → I-beam. Else if isEnabled AND NOT behindOverlay → pointing hand. Else arrow.
|
||
- behindOverlay(layer, overlayOpen) = overlayOpen AND layer == workspace.
|
||
|
||
Test truth table (all must hold): text in workspace, no overlay → I-beam; text in overlay layer with overlay open → I-beam; not over text → arrow (both layers); workspace text with overlay open → arrow; disabled text → arrow (both layers); selecting → I-beam even when not over text, disabled and behind an overlay. Clickable in workspace → hand; workspace clickable with overlay open → arrow; overlay clickable with overlay open → hand; disabled clickable → arrow; selecting over a clickable → I-beam.
|
||
|
||
Layer assignment: views inside the overlay host, the launcher / recent-projects list, and the Git view (when no overlay is above it) are on the `overlay` layer; everything else is `workspace`. "Overlay open" = an overlay is presented OR the Git view is open.
|
||
|
||
Selection tracking: a global "selection drag" flag set on mouse-down in a text view and cleared when the text view's mouse tracking returns; reading it also clears it when no left mouse button is pressed any more (a mouse-up that went elsewhere). Ending a selection schedules a pointer re-read.
|
||
|
||
#### Implementation mechanics (AppKit specifics and why; re-create the effect in any toolkit)
|
||
These exist because the platform fights the rule in several ways. A re-implementation must reach the same observable result; the traps are worth knowing:
|
||
|
||
1. **Cursor rects ignore overlays.** An I-beam or hand cursor rect for a view in a column would still fire under an overlay. So a view adds its I-beam/hand rect only while the rule currently allows that shape (computed with isOverText = true, not selecting). Whenever overlay state, Git view state, active file, column visibility or zoom changes, the whole window's cursor rects are rebuilt and the cursor re-read on the next main-loop turn (coalesced per window). A rebuild is skipped while cursor rects are disabled (splitter drag).
|
||
2. **Text views set the I-beam themselves on every mouse move** (on macOS 26 the terminal library makes the window send every mouse move to the first responder). So every text view is a "pointer-bound" subclass: its own mouse-move behaviour runs only when the policy gives the I-beam and the view is topmost at the point; its enter behaviour runs only where the I-beam rect is allowed; its cursor-update sets the policy's shape if it is topmost (or a selection is running), else hands the update to a deferred re-read. The scroll view's default I-beam "document cursor" is removed. It accepts the first click in an inactive window. A text view can be marked "pointer inactive" (alive but hidden) and then takes no I-beam. It can be made to fill at least the clip view's height, so the empty area below the text still takes the I-beam and clicks.
|
||
3. **Topmost check.** A view counts as under the pointer only when a hit test at that window point reaches the view or a subview (a splitter's hit area overlaps a text view's edge). Visible area = visible rect ∩ bounds (the SwiftUI host does not clip, so a hosted view's visible rect can span the whole window), minus visible vertical/horizontal scrollers and a visible line-number ruler (these keep the arrow). Empty, null or non-finite rects are never used as cursor rects (adding one raises).
|
||
4. **Region views.** SwiftUI buttons and rows get the hand through a background "region view" that takes no clicks (hit-test returns nothing). Text regions (Markdown preview) use a similar region for the I-beam. A region knows its layer and whether it is clickable (enabled environment AND not under `disabledLook` AND not explicitly disabled).
|
||
5. **The cursor-update monitor trick.** AppKit delivers cursor updates to the hit view; since region views take no hits, the hosting view would answer with the arrow. So at launch a **local event monitor** is installed for cursor-update and mouse-moved events: in the key window (with cursor rects enabled and no selection drag running) it schedules one deferred re-read (`scheduleUpdate`), and **swallows cursor-update events** (returns no event) while passing mouse-moved events on untouched (mouse moves also cover views whose tracking areas AppKit never fires, such as an overlay's text field). In addition, the window's root hosting view class has its `cursorUpdate:` method replaced at runtime with one that schedules the same re-read, because AppKit calls it directly on display cycles that move a tracking area, outside any event the monitor sees.
|
||
6. **Deferred re-read (`scheduleUpdate`/`updateCursor`).** Runs once on the next main-loop turn, coalesced per window number (not a weak window reference: teardown calls it from a deallocating window). It must run **outside** the current event because inside an event SwiftUI's hit test returns its root view, not the view under the mouse. It never resets cursor rects (that would fire new cursor updates → loop). It is re-entrancy guarded. It returns early unless: the window is key, cursor rects are enabled, no selection drag, the mouse is inside the content view, and the window directly under the mouse (screen-wide) is this window. Then: hit-test the point; walk up from the hit view to the first "pointer owner" (text view, region, splitter, terminal); if it is a text target behind an open overlay, stop walking (it yields); else let it set the cursor and finish. This order is why a text field inside a clickable row keeps the I-beam. Otherwise, if the hit view is not inside a scroller, collect every visible region view under the point anywhere in the window (skipping hidden subtrees only; SwiftUI hosts do not clip); keep those in the same clip (scroll) view as the hit view, or all of them when the hit view has no clip view, plus overlay-layer regions when an overlay is open; if an overlay is open prefer overlay-layer regions; take the last (topmost) one and let it set its cursor. If none: arrow.
|
||
7. **Tracking areas for edges.** Region views and the terminals keep a tracking area (cursor-update + enter/exit, active in key window) sized to their visible part (not "in visible rect": in the non-clipping host that spans the window, so the mouse would never enter). It is removed and re-added on every frame change or tracking update (an area added while its view was moving keeps a stale position). Enter, exit and cursor-update all schedule a re-read. It is a separate owner object because the terminal library's own enter/exit handlers cannot be overridden.
|
||
8. **View lifecycle:** a text or region view joining or leaving a window, or changing layer, clickability or active state, requests a full refresh (rebuild rects + re-read).
|
||
|
||
---
|
||
|
||
### 1.9 App icon (`assets/icon.png`)
|
||
|
||
- 1024 × 1024 PNG, 8-bit RGB, **no alpha channel**: the area outside the rounded square is solid white (`#FFFFFF`) in the file.
|
||
- Shape: a macOS-style rounded square (squircle) filling the canvas, corner radius roughly 220px.
|
||
- Background: very dark charcoal with a subtle diagonal gradient, about `#1F2226` at top-left, `#1F2125` top-centre, `#1C1E22` left-middle, to about `#16171A` at bottom-right. Neutral grey, slightly cool; not the app's slate palette.
|
||
- Mark: a centred four-pointed star outline, the same polygon as the spark glyph (points at top, right, bottom, left; concave inner vertices), spanning roughly x/y 270–752px. Stroke bright blue about `#4D8DFF`, roughly 24px wide, with rounded joins and caps. The inside of the star is filled with a muted translucent navy (about `#2A3F64` at the centre), and a soft blue glow radiates from the star into the background (around `#222934` just outside it).
|
||
- Note: the blue is not part of the in-app palette (amber is the only in-app accent).
|
||
- Build: the bundler scales it with `sips` into an iconset (each standard size plus @2x) and converts it with `iconutil` into `Contents/Resources/Helder.icns`.
|
||
|
||
---
|
||
|
||
### 1.10 Design handoff v2 tokens (`docs/design_handoff_helder_app_v2/README.md`, prototype HTML)
|
||
|
||
The handoff describes the design language as the Blijnder **Kade** design system in its dark (slate) application: IBM Plex Mono + IBM Plex Sans, flat fields, 2px radii, amber as the only accent, no shadows except menus and modals. Tokens as written there (for reference; code values above win):
|
||
|
||
- **Slate surfaces:** `#101720` page, editor, diff, message field · `#18202B` bars, panels, expanded row, separators · `#1F2834` row hover · `#232C39` rules, hover fills, disabled button · `#2B3544` menu border · `#3A424C` strong rule, button border, unchanged line numbers.
|
||
- **Text:** `#F4F5F4` primary · `#E4E7E6` code · `#BAC0C0` secondary · `#828D9A` muted · `#6C7783` faint.
|
||
- **Accent:** `#E8913A` amber · `#C4741F` amber-deep (hover) · `#F0B476` amber-soft.
|
||
- **Status:** Modified `#F0B476`, New `#8FBFB4` (teal), Deleted `#C3A6CE` (lilac), Staged `#E8913A`. Teal and lilac are app-level additions outside core Kade.
|
||
- **Type:** Plex Mono 400/500/600/700, Plex Sans 400/500/600. Sizes 10, 11, 12, 13, 14px. Label style: 700, tracking .14em, uppercase, written lowercase in brackets in source (e.g. `[ console ] git`).
|
||
- **Radius:** 2px buttons, badges, inputs; 4px menus; 8px modals.
|
||
- **Shadows:** menus `0 4px 16px rgba(16,23,32,.45)`; modals `0 16px 48px rgba(16,23,32,.5)`.
|
||
- **Spacing:** 4px steps; common 6, 8, 10, 12, 14, 16.
|
||
- **Motion:** colour transitions only, 120–160 ms on `cubic-bezier(0.22,1,0.36,1)`; nothing slides or scales. Blink: `steps(1,end)`, 1.1 s, on 0–49%, off 50–100%.
|
||
- **Icons:** Lucide 0.544.0 at stroke 1.75 (git-branch, cloud, arrow-down-to-line, arrow-up-from-line, minimize-2, chevron-down, chevron-right, eraser, check, file-text, sparkle, files).
|
||
- **Prototype extras:** text selection `rgba(232,145,58,.32)`; caret `#E8913A`; scrollbar 10px, thumb `#232C39` with 2px transparent border, fully round, transparent track; links `#F0B476`, hover `#F4F5F4`; context menu 300px wide, `#18202B`, border `#2B3544`, radius 4, padding 6px 0, rows `padding 9px 16px 9px 14px`, Sans 14, hover `#232C39` + 2px amber left border, header Mono 12 `#828D9A` with `padding 6px 16px 10px`, separator 1px `#232C39` margin 6px 0, icons 16px; modal scrim `rgba(16,23,32,.6)` with card at 120px from the top, 560px wide, radius 8, padding 24, gap 14, title Mono 700 17/1.35 tracking −.01em, body Mono 13/1.6 `#828D9A`, buttons 38px tall, padding 0 14px, Sans 600 14, keycap inside Mono 600 12; search scrim `rgba(16,23,32,.55)`; toast bottom 44px centred, `#232C39`, border `#3A424C`, radius 2, padding 10px 16px, Mono 13/1.4 `#F4F5F4`, prefix `→ ` in amber, hides after 2.4 s; title-bar group buttons padding 6px 11px, off label `#828D9A`, off dot `#3A424C`, on fill `rgba(232,145,58,.10)`; editor gutter marks `rgba(143,191,180,.13)` / `rgba(232,145,58,.13)`, active line number `#BAC0C0`, others `#3A424C`.
|
||
- Git view specifics (sections, rows, console, branches) are in the Git view section of this handoff.
|
||
|
||
---
|
||
|
||
### 1.11 Doc-vs-code conflicts (code wins)
|
||
|
||
1. **Type badge size.** `Typography.badge` is Mono 600 **8pt**, but the badge component uses Mono 600 **10pt** at 28 × 16; the `badge` role is unused. Use 10pt.
|
||
2. **Shadows.** Handoff: menu `0 4px 16px rgba(16,23,32,.45)`, modal `0 16px 48px rgba(16,23,32,.5)`. Code: same offsets/blurs but colour `#171C22` at **0.10** (menu) and **0.18** (overlay) — much lighter.
|
||
3. **Scrim.** Prototype `rgba(16,23,32,.55)` (search) / `.6` (modal). Code: one scrim `#101720` @ **0.72**; and Search is full-screen with no scrim at all.
|
||
4. **Context menu.** Prototype: 300 wide, border `#2B3544`, padding 6 vertical, rows Sans **14** with 9pt padding and 16px icons, header Mono **12** `#828D9A`. Code: **320** wide, border `raised #232C39`, padding **8** vertical, rows **30pt** tall, Sans **13**, icon 12pt in a 15pt slot, header Mono **11** `text4 #6C7783`. `#2B3544` does not exist in the code palette.
|
||
5. **Overlay/modal geometry.** Prototype modal card at 120px from top, 560 wide, padding 24. Code: sized cards sit **34pt** from the top (`overlayInset`), width per overlay.
|
||
6. **Text selection.** Prototype `::selection` amber @ .32; code editor and terminal selection amber @ **0.22**.
|
||
7. **Wordmark.** Prototype lowercase `helder.`; code `Helder.` (capital H).
|
||
8. **Group button.** Prototype padding 6×**11**, off label `#828D9A`; code padding 6×**10**, off label `text4 #6C7783`, action label `text3`.
|
||
9. **Primary button hover.** Handoff asks for amber-deep `#C4741F` on hover (prototype uses brightness .92); the code `PrimaryButtonStyle` has **no hover or pressed state** at all (amber-deep is only the destructive variant's fill).
|
||
10. **Toast type.** Prototype toast text Mono 13/1.4; code `toastTitle` is **Sans** 400 13 (reference parts Mono 12).
|
||
11. **Icons.** Handoff: Lucide 0.544.0, stroke 1.75. Code: SF Symbols at light weight (12pt in menus, 14pt in overlay headers) plus the custom spark polygon.
|
||
12. **Fonts.** Handoff lists Plex Sans 400/500/600; code also ships Plex Sans **700** and **400 italic** (italic used for Markdown quotes).
|
||
13. **Removed-diff colour.** Handoff uses amber `rgba(232,145,58,.12)` for removed lines (Git inline diff — matches `inlineRemovedFill`), but the editor/diff overlay use **amber-deep** `#C4741F` @ 0.14 (`removedFill`) with `#C4741F` text/rule.
|
||
14. **Terminal line height.** Config `terminal.lineHeight` 1.7 and `Typography.terminal` line height 20.4 exist, but neither is applied (terminal library has no setting). Letter spacing likewise ignored.
|
||
15. **Metrics comment.** `radiusSmall` doc says "menu rows" use radius 2, but context-menu rows are drawn square (no radius).
|
||
16. **Unused roles.** `sectionTitle` and `commitButton` (Sans 600 12) are defined but unused; the Git commit button uses `gitCommitButton` (Sans 600 13).
|
||
17. **Language label gaps** (not a doc conflict, but easy to miss): `cjs`, `vue`, `scss`, `bash`, `xml`, `svg` have a highlighter language but no friendly label, so the status bar shows the uppercased extension (`CJS`, `VUE`, `SCSS`, `BASH`, `XML`, `SVG`). `.envrc` and any basename starting `.env` are treated as `env`/Dotenv.
|
||
|
||
|
||
---
|
||
|
||
## 2. Shell, process model, layout, keyboard, menus, bars, launcher, toasts, overlays, focus
|
||
|
||
This section covers everything around the panes: how processes and windows work, the three-column layout, every key binding and how keys are routed, the menu bar, the title bar and status bar, the start screen ("launcher"), the recent-projects overlay, toasts, the overlay rules, the confirm dialog and name prompt, the shortcuts overlay, focus, and the close/quit/switch flows. When the docs and the code disagree, the code is the reference. Section 2.21 lists those conflicts.
|
||
|
||
Shared visual tokens used below (hex values; the theme section is the full reference):
|
||
|
||
| Token | Value | Used for |
|
||
|---|---|---|
|
||
| editor | `#101720` | window background, launcher ground, the editor column ground |
|
||
| panel | `#18202B` | title bar, status bar, cards, toasts |
|
||
| raised | `#232C39` | hairlines, borders, splitter at rest, selected-row fill |
|
||
| hover | `#1E2733` | hover fill |
|
||
| text1 / text2 / text3 / text4 / text5 | `#F4F5F4` / `#E4E7E6` / `#BAC0C0` / `#6C7783` / `#3A424C` | text, brightest to dimmest |
|
||
| amber | `#E8913A` | the one accent |
|
||
| amberTint | `#E8913A` at 10% alpha | fill of a toggle that is on |
|
||
| ink | `#171C22` | text on an amber chip |
|
||
| addedText | `#8FBFB4` | `+N` |
|
||
| removedText | `#C4741F` | `−N` |
|
||
| scrim | `#101720` at 72% alpha | backdrop behind a sized overlay |
|
||
| refreshFlash | `#0F1113` | ⌘R flash (plus-lighter blend) |
|
||
| menuShadow | `#171C22` at 10% | toasts, name prompt (radius 8, y 4) |
|
||
| overlayShadow | `#171C22` at 18% | overlay cards (radius 24, y 16), focus flash |
|
||
|
||
Radii: small 2, medium 4, overlay 8. Hairline 1pt. Accent rule 2pt. Colour transition: cubic-bezier(0.22, 1, 0.36, 1), 0.16 s. Small-control transition: same curve, 0.12 s.
|
||
|
||
Type roles referenced below (font, size, other settings): wordmark mono bold 13 with tracking 0.02em; launcherWordmark mono bold 14 with tracking 0.02em; path mono regular 12; branch mono medium 12; crumbLeaf mono semibold 12; meta mono regular 11; chip mono regular 11; keycap mono semibold 12; keycapSmall mono semibold 11; panelLabel mono bold 10, tracking 0.14em, UPPERCASE; dialogTitle mono bold 14, line height 14; toastTitle sans regular 13; toastReference mono regular 12; focusFlash mono regular 19; focusFlashName mono bold 19, tracking −0.01em; button sans medium 12; row sans regular 13; rowSelected sans medium 13; tooltip sans regular 12, line height 18. "Mono" is IBM Plex Mono and "sans" is IBM Plex Sans.
|
||
|
||
---
|
||
|
||
### 2.1 Process model (AppDelegate, HelderScene, LaunchState, SystemActions, InstanceLauncher, AppName)
|
||
|
||
**One project per window. One window per process.** Every new window is a new OS process of the app. A project switch inside a window stays in the same process.
|
||
|
||
App start (`AppDelegate.applicationWillFinishLaunching`), in this order:
|
||
1. Open the file logger at `~/Library/Logs/Helder/helder.log`.
|
||
2. Register the bundled fonts (IBM Plex Mono 400–700, IBM Plex Sans 400/500/600/700/400-italic).
|
||
3. Make the app a regular foreground app (Dock icon, menu bar). This step is needed even when the binary runs outside a bundle.
|
||
4. Force the dark appearance for the whole app. There is no light mode.
|
||
5. Turn off automatic window tabbing. Tabs would put two projects in one window.
|
||
6. Write the user default `NSQuitAlwaysKeepsWindows = false` in the app's domain. A quit must not leave windows that the next launch reopens.
|
||
7. Write `NSFullScreenMenuItemEverywhere = false`. The View menu has its own full-screen item, so AppKit must not add a second one.
|
||
|
||
After launch: install the global cursor-update monitor (pointer policy) and activate the app, ignoring other apps.
|
||
|
||
- **Last window closed:** the app keeps running (`applicationShouldTerminateAfterLastWindowClosed` returns false). A click on the Dock icon then opens a new window in the same process, and that window starts on the launcher.
|
||
- **Window scene:** one window group with id `"workspace"`, a hidden title bar, a default size of **1680 × 1040**, and a minimum size of **1100 × 680**. The window frame also enforces the minimum.
|
||
- **Initial folder (`LaunchState.claimRoot`):** the first window that the process creates claims the launch folder from `ProjectLocator.initialRoot()`. Every later window in the same process gets nil, which means the launcher.
|
||
- **`ProjectLocator.initialRoot(environment, arguments)`:**
|
||
1. If the environment variable `HELDER_PROJECT` is set **and** names an existing directory, use it as a standardized absolute file URL.
|
||
2. If not, take the first command-line argument after argv[0] that is not `"."`, does not start with `"-"`, and is an existing directory.
|
||
3. If neither exists, return nil, and the window shows the launcher. A bare `.` is ignored on purpose, so a development launch lands on the launcher.
|
||
- **Starting a new instance (`SystemActing.openNewInstance(root?)`):**
|
||
- Arguments: `["-HelderProject", <absolute folder path>]` when a root is given, else `[]`. The `-Key value` form is used so the OS reads the pair as a default and not as a document to open. `initialRoot` finds the path because the path is the first argument that does not start with `-` and is a directory.
|
||
- **Inside an app bundle:** ask the OS to launch the bundle as a *new application instance* (`createsNewApplicationInstance = true`), activated, with those arguments.
|
||
- **Outside a bundle** (a bare executable during development): spawn the executable as a child process with those arguments and the parent's environment, **minus `HELDER_PROJECT`**, because that variable would win over the argument. Keep a reference to the child until it exits so its exit status is reaped.
|
||
- On failure, log `could not start a new instance: <error>` under the category "window". The user sees nothing.
|
||
- **What starts a new process:** New Window (⇧⌘N, File menu, Dock menu), and File > Open Folder… or a File > Open Recent item when no window is key. Open Folder (⌘O), Open Recent with a key window, the launcher rows and the ⇧⌘O list all switch the **current** window.
|
||
- **No window restoration:** each window is not restorable, and `NSQuitAlwaysKeepsWindows` is false. A launch opens exactly one window.
|
||
- **Process display name (`AppName`):** the app renames its own running process. Mission Control, the Dock tooltip and ⌘Tab then show the project's title. The rename uses private LaunchServices symbols that are looked up at runtime from `/System/Library/Frameworks/CoreServices.framework/CoreServices`: `_LSGetCurrentApplicationASN`, `_LSSetApplicationInformationItem`, `_kLSDisplayNameKey`, with session id `-2` (kLSDefaultSessionID).
|
||
- If a symbol is missing, log the warning `LaunchServices rename calls not found; the app keeps its name` and keep the name.
|
||
- If the call fails, log `could not rename the app to <name>: <status>`.
|
||
- A name that equals the current one is not sent again.
|
||
- The name is the window title (see below) while a project is open, `"Helder"` on the launcher, and `"Helder"` again when the last registered window closes.
|
||
- A re-implementation should do the closest equivalent on its platform: per-process display name, window title, or taskbar label.
|
||
- **Window title** (`WorkspaceModel.title`; default `"Helder"`): `ProjectLocator.title(of: root)` gives `APP_NAME` from the project's `.env` file if it is set, else the folder name. The native title text is hidden (`titleVisibility hidden`). The title still feeds the Window menu, Mission Control and the Dock menu.
|
||
- **`.env` parse rules (`ProjectTitle.appName`):** split the text into lines (any newline). Drop leading spaces and tabs. Skip lines that start with `#`. A line must start with `APP_NAME`, then optional spaces or tabs, then `=`. **The last such line wins**, even when its value is empty. Trim the value of spaces. If it is 2 or more characters long and starts and ends with the same quote (`"` or `'`), strip those quotes. Trim again. An empty result gives nil, and the title falls back to the folder name. The title does not fall back to an earlier `APP_NAME` line.
|
||
- **Project name** (`WorkspaceModel.name`): `ProjectLocator.name(of: root)` gives the URL's last path component, or the full path when that component is empty (`/`). The title bar, the focus flash and the context-menu headers use the name. The window and process use the title.
|
||
- **Dock right-click menu (`applicationDockMenu`):** if the current workspace has a project, the menu starts with a disabled item that shows the **title**, then a separator. The last item is always **"New Window"**, which starts a new process on the launcher. The current workspace is the key window's workspace, else the workspace that was key last.
|
||
- **Workspace registry (`WorkspaceRegistry`):** a weak list of (model, window) pairs. A model registers when its view attaches to a window and unregisters on window-will-close. The registry also tracks the model that was key last. ⌘Q and the Dock menu use it.
|
||
|
||
### 2.2 Window setup (WindowBridge / WindowCoordinator)
|
||
|
||
When the root view attaches to its window:
|
||
- Set the window title to `model.title`, hide the title text, make the title bar transparent, and extend the content under the title bar (full-size content view).
|
||
- The window cannot be moved by its background. Background colour `#101720`. Dark appearance. `minSize` 1100×680. Tabbing is disallowed. `isRestorable = false`.
|
||
- **Traffic lights:** place the close, minimize and zoom buttons with the first button's origin at **x 14, y 12 from the window's top-left corner**. Keep the system spacing between the buttons. Make the title-bar container `button height + 2×12` tall, so the whole strip drags the window. Do this again after a resize, at the end of a live resize, after leaving full screen, and when the window becomes key, because the OS resets the positions.
|
||
- **Full screen:** will-enter sets `layout.isFullScreen = true`, and did-exit sets it to false.
|
||
- Install a **local key-down monitor** (section 2.6) and a **local left/right mouse-down monitor** (section 2.12).
|
||
- Install the **close guard** as the window delegate, in front of the framework's own delegate. The guard forwards every other delegate message to that original delegate. It is installed again on every view update, because the framework may set its own delegate again.
|
||
- Register in `WorkspaceRegistry`, and set `model.hooks.closeWindow` to perform a normal close of this window (with the guard).
|
||
- On every view update: set the window title, set `AppName` (the title with a project, else `"Helder"`), and do the Git-view focus hand-off. When the Git view goes from closed to open, clear the window's first responder at once. The commit-message field takes focus one run loop later. As a result, typing never lands in a terminal that the Git view covers.
|
||
- On become-key: record this model as the last key model, then call `model.windowDidBecomeKey()` (focus flash, section 2.11). On resign-key: call `model.windowDidResignKey()`.
|
||
- On will-close: unregister. If no models are left, rename the process to `"Helder"`. Then call `model.windowWillClose()` and remove the monitors and observers.
|
||
|
||
### 2.3 Window content structure (WorkspaceView)
|
||
|
||
Z-order, bottom to top:
|
||
1. **No project** (`root == nil`): the launcher screen (section 2.13) once `isReady`. Before that, only the editor ground colour shows, so a slow disk never flashes the launcher.
|
||
2. **With a project:** a vertical stack of the **title bar** (44pt), the **columns** (fill), and the **status bar** (28pt). Over that stack, in order:
|
||
- the full-window **Git view**, while `layout.isGitViewOpen`. It covers the title bar, the columns and the status bar. The columns stay mounted under it.
|
||
- the **OverlayHost** (the current overlay, section 2.15).
|
||
- the **⇧⌘O recent-projects list**, when `overlay.current == .launcher`.
|
||
3. **ToastStack** (above everything, including overlays, and on the launcher too).
|
||
4. **FocusFlash** (above the toasts, when visible).
|
||
|
||
When the workspace first appears and on every width change, call `layout.windowResized(width)`.
|
||
|
||
Pointer re-evaluation: when the overlay, the Git-view state, the active path, the column visibility or the zoom changes, re-read the pointer under a still mouse. This is part of the pointer policy.
|
||
|
||
---
|
||
|
||
### 2.4 Command set (Command)
|
||
|
||
Views, menus and the key router all call the one entry point `WorkspaceModel.perform(Command)`. A shortcut and its button can therefore never do different things.
|
||
|
||
| Command | Payload | Effect |
|
||
|---|---|---|
|
||
| `showSearch(seed)` | String | Present overlay `.search(seed)`. If the seed is empty, use `editorSelectionFirstLine()` instead: when the editor has a line selection on the active file, the text of its start line trimmed of spaces and tabs, else "". |
|
||
| `showShortcuts` | — | Present `.shortcuts`. |
|
||
| `showRecentProjects` | — | Present `.launcher` (the ⇧⌘O list). Then, as tracked async work, re-read the recent projects from disk into `recentProjects`, because another window may have added one. |
|
||
| `showRecentFiles(initialSelection)` | Int | Present `.recentFiles(initialSelection)`. |
|
||
| `showContextMenu(target, anchor)` | target, window point | Present `.contextMenu` with the header and entries for the target (the context-menu section has the full list). |
|
||
| `dismissOverlay` | — | Set the overlay to `.none`. |
|
||
| `confirmPending` | — | Only if the current overlay is `.confirm(request)`: dismiss it, then run `request.action` at the default anchor. |
|
||
| `submitName(name)` | String | Only if the current overlay is `.namePrompt(request)`: dismiss it, then run the Explorer create or rename (section 2.16). |
|
||
| `passToAgent(text, reference?)` | | Dismiss the overlay. Insert `text` into the agent terminal's composer without submitting it. Show the toast `"Passed to agent"` with the detail = reference. |
|
||
| `launcherMove(step)` | Int | Move the launcher cursor, clamped to [0, count−1]. |
|
||
| `launcherSelect(index)` | Int | Set the launcher cursor, clamped. |
|
||
| `launcherActivate` | — | Row 0 runs `openFolder`. Row i runs `openRecentProject(recents[i−1].path)`. |
|
||
| `toggleGit` | — | Git view open → `closeGitView`, else `openGitView` (section 2.18). |
|
||
| `closeGitView` | — | Close the Git view and give the keyboard back (section 2.18). Does nothing if the view is closed. |
|
||
| `togglePane(panel)` | explorer / editor / terminal | Show or hide that column (section 2.5). The Git view is not affected. |
|
||
| `toggleAutoFit` | — | Flip **Fluid**, refit, save the layout. |
|
||
| `toggleHidden` | — | Flip `showHidden` (dotfiles in the tree and in search). Not persisted. |
|
||
| `focus(panel)` | | `layout.focus(panel)`. If the panel became active: set `focusRequest = .panel(panel)`, and for the editor also ask the editor's text view to take focus. |
|
||
| `focusNeighbour(step)` | ±1 | `focus(layout.neighbour(of: activePanel, step))`. |
|
||
| `moveRowCursor(step)` | ±1 | Only when the active panel is the Explorer: move the tree selection (hidden files count only when Hidden is on). |
|
||
| `openSelectedRow` | — | Only when the active panel is the Explorer: a folder row toggles open or closed, a file row opens the file. |
|
||
| `openRowMenu` | — | Only when the active panel is the Explorer: open the selected row's context menu, anchored beside the column at the row's height. |
|
||
| `open(path, options)` | path, OpenOptions{side?, line?, showDiff} | Open in the editor. On success: select the path in the Explorer and set focusZone `.editor`, which widens the editor when the window is narrow. Nothing moves when the unsaved prompt is cancelled or the save fails. |
|
||
| `save` | — | Only if the active file is dirty: save it (toast `"Saved"`). |
|
||
| `closeFileOrWindow` | — | With an active file: request to close it (asks first when dirty). With no active file: close the window. |
|
||
| `cycleMode` | — | The editor's toggle between code and Markdown preview. |
|
||
| `passSelection(info?)` | TextSelectionInfo{text, startLine, endLine} (1-based, inclusive) or nil | With an active file. If info is given: present `.passOn` with the reference `path:start-end`, where end is max(start, end), the code = info.text, at the default anchor. If nil: the editor builds the request from its line selection. |
|
||
| `selectAllInFile` | — | The editor selects the whole open file in its pane. |
|
||
| `commit` | — | The source-control commit. It always runs git, so git's refusal shows. |
|
||
| `push` / `pull` | — | Push or pull. After a pull, schedule a refresh of the tree and the open files. |
|
||
| `stage(paths)` / `unstage(paths)` | [String] | |
|
||
| `switchBranch(name, remote)` | | On success, schedule a refresh of the tree and the open files. |
|
||
| `submitConsoleInput` | — | Run the Git console line, then refresh the tree and the open files. |
|
||
| `focusCommitMessage` | — | `openGitView()`: opens the view if it is closed, and in all cases requests focus for the message field. |
|
||
| `copyCleanCopy` | — | Only while the clean-copy overlay is open: copy its text, dismiss it, show the toast `"Copied"` with the detail `"<N> characters"`. |
|
||
| `stopReading` | — | Stop the read-aloud. |
|
||
| `openFolder` | — | A project switch (section 2.19): show the system folder picker. On cancel nothing happens. Otherwise open the chosen folder in this window. |
|
||
| `openRecentProject(path)` | | A project switch to that path. |
|
||
| `refresh` | — | ⌘R: increase `refreshTick` (the columns flash), re-read git and the tree, and reload the active file from disk. The disk wins over unsaved edits. |
|
||
| `newWindow` | — | Start a new process on the launcher. |
|
||
| `zoom(step)` | reset / bigger / smaller | Section 2.5.7. |
|
||
| `context(action)` | ContextAction | A context-menu action. If an action needs confirmation (git discard under `git.confirmDiscard`, Explorer delete), present `.confirm`. Otherwise run it. An open context menu is closed first, and its anchor is passed on, so a prompt it opens appears in the same place. |
|
||
|
||
The **default anchor** is (left edge of the editor column + 60, 150) in window coordinates.
|
||
|
||
Focus targets (`FocusTarget`): `.panel(Panel)` or `.commitMessage`. A `FocusRequest` carries a fresh unique id on every request, so two requests for the same target in a row are still seen as new.
|
||
|
||
### 2.5 Columns and layout (LayoutStore, ColumnLayout, Columns view)
|
||
|
||
#### 2.5.1 Structure
|
||
- Left to right: **Explorer** (panel `explorer`), **File/Editor** (panel `editor`, the flexible column), **Claude + Terminal** (panel `terminal`, also called the "agent" column).
|
||
- The right column is split vertically: the agent (Claude) terminal on top and a plain shell below, with a horizontal splitter between them.
|
||
- A 1pt **splitter** sits between each pair of neighbouring *visible* columns: Explorer|Editor is shown when the Explorer is visible and (the Editor or the Agent column) is visible; Editor|Agent is shown when both are visible.
|
||
- `splitterCount = max(0, visibleColumnCount − 1)`.
|
||
- All three columns stay **mounted** at all times. Hiding only hides them, so the terminals keep running, the editor keeps its buffer and scroll position, and the tree keeps its open folders.
|
||
- A hidden column is drawn at 0 layout width but keeps its own internal width. It is fully transparent, takes no hits, is hidden from accessibility, and is moved 100,000pt to the right (off the window), so its native views own no pixels, clicks or cursor. A terminal therefore never resizes to nothing.
|
||
- While the editor is hidden it keeps its last shown width (at least 280), so its text does not re-wrap.
|
||
- Layout in the horizontal stack:
|
||
- The Explorer has width `widths.explorer`.
|
||
- The editor has `minWidth 280`, no maximum, and takes the remaining width.
|
||
- The agent column has width `widths.agent`. **If the agent is visible and the editor is hidden, the agent column is the flex column instead** (minimum 280, no maximum).
|
||
- If neither the editor nor the agent is visible, a spacer fills the rest. If every column is hidden, the middle shows only the editor ground colour.
|
||
- The agent column is keyed by the project (and by its terminal store). A project switch therefore gives fresh terminal panes and processes.
|
||
- The columns' background is `#101720`, and their content is clipped.
|
||
|
||
#### 2.5.2 State (all per window)
|
||
|
||
| Field | Initial | Persisted? |
|
||
|---|---|---|
|
||
| `widths` {explorer, agent} | 288, 480 | per project, when Fluid is off (see 2.5.6) |
|
||
| `agentFraction` | from the session store (default 0.52) | global key `helder.topFrac` |
|
||
| `windowWidth` | 1680 until the first resize | no |
|
||
| `visibility` {explorer, editor, agent} | all true | per project |
|
||
| `isGitViewOpen` | false | **never**. Reset to false on every project restore. |
|
||
| `fluid` | true | per project |
|
||
| `showHidden` | false | **never**. It is a per-window field and is not reset by a project switch (see the conflicts). |
|
||
| `focusZone` | neutral (neutral / editor / terminal) | no, reset on restore |
|
||
| `activePanel` | nil | no, reset on restore |
|
||
| `isFullScreen` | false | no |
|
||
| `zoomLevel` | from `helder.zoom`, clamped | global |
|
||
|
||
#### 2.5.3 Constants (ColumnLayout)
|
||
- `roomyWidth = 1600`
|
||
- `minEditorWidth = 280`
|
||
- `splitterWidth = 1`
|
||
- `explorerRange = 160…520`
|
||
- The agent/shell split fraction is limited to 0.18…0.82, default 0.52.
|
||
|
||
#### 2.5.4 Fluid width formula (`ColumnLayout.fluid(windowWidth W, focus)`)
|
||
- If `W ≥ 1600`: explorer = round(W × 0.164), agent = round(W × 0.273). Focus has no effect. (These are the design's 288 · flex · 480 on a 1760 frame. 1760 gives 289 / 480.)
|
||
- If `W < 1600`: explorer = round(W × 0.15), and agent = round(W × share), where share is **0.5** if focusZone = terminal, **0.2** if focusZone = editor, and **0.3** if neutral. Example: W = 1500 with terminal focus gives agent 750; with editor focus it gives 300. W = 1200 gives 600 or 240.
|
||
- "round" rounds half away from zero.
|
||
|
||
#### 2.5.5 Fitting (`ColumnLayout.fitted(widths, W, visible)`)
|
||
This scales the fixed columns down so that the flex column keeps 280:
|
||
|
||
```
|
||
agentIsFixed = visible.agent && visible.editor
|
||
flexMinimum = (visible.editor || visible.agent) ? 280 : 0
|
||
budget = W − splitterCount×1 − flexMinimum
|
||
total = (visible.explorer ? explorer : 0) + (agentIsFixed ? agent : 0)
|
||
if total > budget and total > 0:
|
||
k = max(0, budget) / total
|
||
explorer = visible.explorer ? floor(explorer × k) : explorer (a hidden column keeps its width)
|
||
agent = agentIsFixed ? floor(agent × k) : agent
|
||
else unchanged
|
||
```
|
||
|
||
**Refit** = (fluid ? fluid(W, focusZone) : current widths), passed through `fitted`, and assigned when the result differs. Refit runs on: restore, show/hide a column, toggle Fluid, window resize, `focus(panel)`, and `setFocusZone`. It does **not** run during a splitter drag. When Fluid is off, a narrowing window writes the shrunk widths back into `widths`, so the columns do not grow back by themselves when the window widens again.
|
||
|
||
#### 2.5.6 Splitter math
|
||
- **Splitter visuals (`Splitter`):** a 1pt line in `raised`, amber while hovered or dragged, with a 0.12 s colour transition. The hit area is **7pt** (3pt past the line on each side). The resize cursor is left-right for a column splitter and up-down for the row splitter. It draws above its neighbours. Cursor rects are turned off for the whole drag. The drag sends the movement since the last event: for a column splitter `x − startX`, for the row splitter `startY − y` in bottom-up window coordinates, so a drag downward is positive. Mouse-up calls `onEnd`.
|
||
- **Explorer splitter drag(delta):** `fluid = false`, `explorer = clamp(explorer + delta, 160…520)`. On end: save the layout.
|
||
- **Agent splitter drag(delta):** the splitter is on the agent column's left edge, so a drag to the right shrinks the column. `fluid = false`, `agent = clamp(agent − delta, 280 … maxAgent)`, where `maxAgent = max(280, W − splitterCount×1 − (explorerVisible ? explorer : 0) − 280)`. On end: save. Example: W 1760, Explorer hidden, drag far left gives agent = 1760 − 1 − 280 = 1479.
|
||
- **Agent/shell row splitter drag(delta, columnHeight h):** if h > 0, `fraction = clamp((fraction × h + delta) / h, 0.18…0.82)`. The value is **saved on every movement** (global key `helder.topFrac`, a Double), not only at the end. The agent pane height is h × fraction. The shell gets the rest, minus the 1pt splitter. Example: a drag of +100 in a column 1000 tall moves the fraction from 0.52 to 0.62.
|
||
- Layout saves happen at drag end, on a pane toggle, and on a Fluid toggle. They do not happen on a resize or during a drag.
|
||
|
||
#### 2.5.7 Zoom
|
||
- `zoomLevel` moves in half steps: reset → 0, bigger → +0.5, smaller → −0.5. It is clamped to **−3…5**. If the clamped value equals the current one, nothing happens. Otherwise the new value is saved to `helder.zoom` (a Double, shared by all projects). A missing value reads as 0.
|
||
- `textScale = 1.2 ^ zoomLevel` (Chromium-style). It multiplies the code, Diff and terminal font sizes. The rest of the UI does not scale.
|
||
|
||
#### 2.5.8 Show/hide (`setVisible`)
|
||
- A change only happens if the value is different.
|
||
- If a column is hidden while it is the active panel, `activePanel = nil`. Then refit and save.
|
||
- A hidden column cannot become active: `focus(panel)` does nothing for a hidden panel.
|
||
- **Hidden-pane focus guard:** after any visibility change, on the next run loop, the guard checks the window's first responder. It takes that view's enclosing scroll view if there is one, else the view itself. If that view's left edge in window coordinates is ≥ the content view's right edge, the view is parked off-screen, so the first responder is cleared. Typing then never lands in an invisible pane.
|
||
- Pane toggles work while the Git view is open and do not close it.
|
||
|
||
#### 2.5.9 Column geometry for hit-testing (`span(of:)`, `panel(atX:)`)
|
||
```
|
||
flexStart = explorerVisible ? explorer + 1 : 0
|
||
agentStart = editorVisible ? max(flexStart, W − agent) : flexStart
|
||
explorer: 0 … explorer
|
||
editor: flexStart … max(flexStart, agentVisible ? agentStart − 1 : W)
|
||
terminal: agentStart … max(agentStart, W)
|
||
(nil for a hidden column)
|
||
```
|
||
`panel(atX: x, splitterMargin m)` returns the first visible column where `lower + m ≤ x ≤ upper − m`, so a click within m of a divider maps to no column. Clicks use m = 4. With every column hidden it returns nil. Example at W 1760: x 10 → explorer, 900 → editor, 1700 → terminal, x 289 with m 4 → nil.
|
||
|
||
#### 2.5.10 Neighbour (`neighbour(of: panel?, step)`)
|
||
Take the list of visible columns in order. If the list is empty, return the panel (or `editor` if the panel is nil). Otherwise find the index of the panel, treating nil as `editor`. If the panel is not in the list, use the index of `editor`, else 0. Return `list[clamp(index + step, 0, count−1)]`. Examples:
|
||
- Nothing focused + step 1 → terminal.
|
||
- Terminal + step 1 → terminal.
|
||
- Explorer + step −1 → explorer.
|
||
- Explorer hidden: editor + step −1 → editor.
|
||
- Editor hidden: explorer + 1 → terminal.
|
||
|
||
#### 2.5.11 Focus and the focus zone
|
||
- `layout.focus(panel)`: only for a visible panel. Sets `activePanel`. Editor → focusZone `editor`. Terminal → `terminal`. Explorer leaves the zone unchanged. Then refit.
|
||
- `setFocusZone(zone)`: used when a file is opened. Sets the zone and refits, without moving `activePanel`.
|
||
|
||
#### 2.5.12 Restore (`restore(root)`) on every project load
|
||
1. Set the root. `activePanel = nil`, `focusZone = neutral`, `isGitViewOpen = false`.
|
||
2. Load the snapshot. `visibility` = saved or all shown. `fluid` = saved or true.
|
||
3. If a saved snapshot exists and is **not** fluid: `explorer = clamp(saved.explorerWidth, 160…520)` and `agent = max(saved.agentWidth, 280)`. If it is fluid, the saved widths are ignored.
|
||
4. Refit.
|
||
|
||
This restore is unconditional. It does not depend on `session.restoreOnLaunch`.
|
||
|
||
#### 2.5.13 Persistence keys and formats
|
||
|
||
| Key / location | Scope | Format |
|
||
|---|---|---|
|
||
| `helder.layout:<absolute root path>` (user defaults) | per project | JSON data `{"explorerWidth": Double, "agentWidth": Double, "fluid": Bool, "explorerVisible": Bool, "fileVisible": Bool, "claudeVisible": Bool}` |
|
||
| `helder.zoom` | global | Double |
|
||
| `helder.topFrac` | global | Double (agent fraction). A missing key gives 0.52. Clamped on load. |
|
||
| `helder.session:<root>` | per project | JSON data `{"active": String?, "tabMode": {path: mode}, "tabSide": {path: "staged"/"unstaged"}}`. Mode raw values: `"updated"` (actual), `"diff"`, `"code"`, `"preview"`. An unknown mode (for example the legacy `"original"`) is dropped from the map; it does not fail the decode. Extra legacy keys such as `openTabs` are ignored. |
|
||
| `~/Library/Application Support/Helder/recent-projects.json` | machine-wide | see 2.14 |
|
||
| `<project>/.helder/recent.json` | per project | JSON array of relative paths, newest first, max 100 |
|
||
|
||
The user-defaults domain is the bundle id `nl.blijnder.helder` when bundled, and `Helder` for a bare executable.
|
||
|
||
**Layout snapshot decoding rules (legacy-tolerant):**
|
||
- `explorerWidth`, `agentWidth` and `fluid` are required. If one is missing, the whole snapshot fails to decode and counts as "no saved layout".
|
||
- Each visibility flag that is missing decodes as **true**.
|
||
- Legacy keys from the old Git-column layout, `sourceControlWidth` and `gitVisible`, are ignored when present and never written.
|
||
|
||
---
|
||
|
||
### 2.6 Keyboard routing (KeyRouter)
|
||
|
||
#### 2.6.1 Mechanics
|
||
- One **local key-down monitor** per window sees every key-down **before** the menu bar and the focused view.
|
||
- It acts only on events for its own window, and only when no sheet is attached.
|
||
- It builds a `KeyPress` and a `KeyContext`, then calls `KeyRouter.route`. The result `.pass` lets the event continue: to the menu bar key equivalents, then the focused view or field. The result `.perform(cmd)` runs the command and **swallows** the event.
|
||
- After a performed `focusNeighbour` whose new active panel is the Explorer, the window's first responder is cleared. The Explorer has no text view, so it holds the keyboard this way.
|
||
|
||
**KeyPress building:**
|
||
|
||
| Key code | Key |
|
||
|---|---|
|
||
| 126 | up |
|
||
| 125 | down |
|
||
| 123 | left |
|
||
| 124 | right |
|
||
| 36, 76 | enter (Return and keypad Enter) |
|
||
| 53 | escape |
|
||
| 47 | character "." (read by key code, so ⌘. works on every keyboard layout) |
|
||
| other | with ⌘ held: the characters ignoring modifiers, lowercased. Without ⌘: the typed characters, lowercased (`?` arrives as `?`). Empty → `other`. |
|
||
|
||
The modifier flags taken are command, shift, option and control.
|
||
|
||
**KeyContext fields:**
|
||
- `hasProject`
|
||
- `overlay` (an `OverlayKind`)
|
||
- `owner`, one of:
|
||
- `workspace`: no text input has the keyboard.
|
||
- `text(in: column?)`: a text field or text view, with the column it sits in. The column is computed from the midX of the view's visible rect in window coordinates. It is nil while the Git view is open.
|
||
- `terminal`: a terminal view.
|
||
- `hasTextSelection`: the focused text view, terminal or Diff canvas has a non-empty selection.
|
||
- `editorTextSelection`: only when the focused text view sits in the editor column and has a selection. It holds the text, plus startLine = the 1-based line of the selection start and endLine = the line of the last selected character.
|
||
- `hasEditorLineSelection`: the editor has a line selection on the active file **with start ≠ end**.
|
||
- `activePanel`
|
||
- `focusZone`
|
||
- `recentFileCount`: the size of the editor's history.
|
||
- `searchSeed`: the first line of the text-view selection, trimmed of spaces and tabs, else "".
|
||
- `gitViewOpen`
|
||
- `inGitConsole`: the first responder is the Git console's field editor.
|
||
- A Diff-canvas first responder counts as owner `workspace`, with its own selection flag.
|
||
|
||
`OverlayKind`: `none`; `diff(busy)` for the full-screen Diff, where busy means the Diff's own context menu or pass-on prompt is open; `other` for every other overlay, including the ⇧⌘O list.
|
||
|
||
#### 2.6.2 The routing algorithm (in order)
|
||
1. If **control or option** is held → **pass**. Such chords always reach the focused view or terminal. Menu shortcuts that use them (⌃⌘F) are handled by the menu.
|
||
2. If **no project** (launcher):
|
||
- shift held → pass
|
||
- up (with or without ⌘) → `launcherMove(−1)`
|
||
- down (with or without ⌘) → `launcherMove(+1)`
|
||
- enter **without** ⌘ → `launcherActivate`
|
||
- anything else → pass. ⌘O falls through to the menu.
|
||
3. Overlay checks:
|
||
- `diff(busy: true)` → **pass everything**, including Esc. The Diff's own menu or prompt handles the keys.
|
||
- `none`: Esc **without** ⌘ → `closeGitView` if the Git view is open, else **pass**, so Esc reaches the terminal or field. ⌘Esc → pass.
|
||
- `other` or `diff(busy: false)`: Esc without ⌘ → `dismissOverlay`.
|
||
4. Then:
|
||
- `other` → **pass** every remaining key. The overlay's own field or key catcher handles it.
|
||
- `diff(busy: false)` → ⌘A → **pass** (select-all stays in the Diff's panes). Every other key falls through to step 5 or 6.
|
||
5. If the **Git view is open** → the Git-view key map (2.6.4).
|
||
6. Else, if ⌘ is held → the command-key map (2.6.3). Otherwise → the plain-key map (2.6.3).
|
||
|
||
#### 2.6.3 Normal context (project open, Git view closed, no overlay or a non-busy Diff)
|
||
|
||
**Plain keys (no ⌘):**
|
||
|
||
| Key | Condition | Result |
|
||
|---|---|---|
|
||
| ↑ | owner = workspace AND activePanel = explorer AND no shift | `moveRowCursor(−1)` |
|
||
| ↓ | same | `moveRowCursor(+1)` |
|
||
| ↵ | same | `openSelectedRow` |
|
||
| `?` | owner = workspace (shift is ignored) | `showShortcuts` |
|
||
| everything else | | pass |
|
||
|
||
**⌘ keys:**
|
||
|
||
| Key | Condition | Result |
|
||
|---|---|---|
|
||
| ⇧ + any | | ⇧⌘O → `showRecentProjects`. All other shifted ⌘ keys → pass (⇧⌘N and ⇧⌘W go to the menu). |
|
||
| ⌘↑ / ⌘↓ | focusZone = editor AND recentFileCount > 0 | `showRecentFiles(initialSelection)`: ⌘↓ → `max(0, min(1, count−1))`, which is the previous file. ⌘↑ → 0, the current file. Otherwise pass. |
|
||
| ⌘→ | owner = workspace AND activePanel = explorer | `openRowMenu` |
|
||
| | else if editorTextSelection exists | `passSelection(that selection)` |
|
||
| | else if hasEditorLineSelection AND owner ≠ terminal | `passSelection(nil)` |
|
||
| | else if owner = workspace | `focusNeighbour(+1)` |
|
||
| | else | pass (the text field or terminal keeps ⌘→) |
|
||
| ⌘← | owner = workspace | `focusNeighbour(−1)`, else pass |
|
||
| ⌘F | | `showSearch(seed: searchSeed)` |
|
||
| ⌘P | | `push` |
|
||
| ⌘S | | `save` |
|
||
| ⌘M | | `cycleMode` |
|
||
| ⌘W | | `closeFileOrWindow` |
|
||
| ⌘G | | `toggleGit` |
|
||
| ⌘1 / ⌘2 / ⌘3 | | `togglePane(explorer / editor / terminal)` |
|
||
| ⌘L | | `toggleAutoFit` |
|
||
| ⌘. | | `toggleHidden` |
|
||
| ⌘A | owner = workspace | `selectAllInFile`, else pass (a field or terminal does its own select-all) |
|
||
| ⌘C | owner = terminal OR hasTextSelection OR hasEditorLineSelection | pass (normal copy) |
|
||
| | otherwise | `focusCommitMessage` (opens the Git view on its message field) |
|
||
| ⌘↵ | | pass. It commits only over the Git view. |
|
||
| ⌘O, ⌘R, ⌘N, ⌘0, ⌘+, ⌘−, others | | pass. The menu handles ⌘O, ⌘R and the zoom keys. ⌘N is unbound. |
|
||
|
||
The ⌘ letter keys above (F, P, S, M, W, G, 1, 2, 3, L, .) work **from anywhere**, including inside a text field or a terminal. Only ⌘A, ⌘C, ⌘← and ⌘→ yield to a field.
|
||
|
||
**Context summary (what reaches the terminal):** with a terminal focused, these reach it: every plain key (arrows, ↵, `?`, letters), Esc (when no overlay and no Git view), every ⌃ or ⌥ chord, ⌘A, ⌘C, ⌘←, ⌘→, ⌘↑ and ⌘↓ (the zone is `terminal`, so recent files do not trigger), and every unbound ⌘ key. These are taken from it: ⌘F, ⌘P, ⌘S, ⌘M, ⌘W, ⌘G, ⌘1–3, ⌘L, ⌘., ⇧⌘O. The menu still takes ⌘O, ⌘R, ⇧⌘N, ⇧⌘W, ⌘0, ⌘+, ⌘− and ⌃⌘F.
|
||
|
||
**Explorer focused** (owner workspace, activePanel explorer): ↑/↓/↵ drive the row cursor. ⌘→ opens the row menu. ⌘← moves focus left (it clamps at the Explorer). `?` opens the shortcuts.
|
||
|
||
**Editor focused** (owner `text(in: editor)`): plain keys, ⌘A, ⌘C, ⌘← and ⌘→ (without a selection) go to the text. ⌘→ with a selection → `passSelection`. ⌘↑/⌘↓ → recent files (focusZone editor, history non-empty).
|
||
|
||
#### 2.6.4 Git view open (`gitViewKey`)
|
||
- No ⌘: `?` with owner = workspace → `showShortcuts`. Everything else → pass. Arrows and ↵ do nothing to the columns under the view, and typing reaches the view's fields.
|
||
- ⇧⌘: same as the normal ⇧⌘ handling (⇧⌘O only).
|
||
- ⌘↵ → `commit`, **unless** `inGitConsole`, in which case pass (the console keeps it). This works from the commit-message field too.
|
||
- ⌘A → pass.
|
||
- ⌘ + character → the same character table as normal: F, P, S, M, W, G, 1, 2, 3, L, . are taken. ⌘A passes. ⌘C passes if owner = terminal or there is a selection, else `focusCommitMessage` (the view is already open, so this only re-focuses the message field).
|
||
- ⌘ + arrows (←, →, ↑, ↓) → pass.
|
||
- Esc (no overlay, no ⌘) → `closeGitView`. With an overlay above the Git view → `dismissOverlay`. With a busy Diff → pass.
|
||
|
||
#### 2.6.5 Overlay key handling (inside overlays)
|
||
The router passes keys to an `other` overlay. Each overlay has its own handler: a focused command field, or an invisible "key catcher" that takes first responder one run loop after it appears. The key set (`OverlayKey`):
|
||
- `up`, `down`
|
||
- `commandUp` (⌘↑, or the text system's move-to-beginning-of-document)
|
||
- `commandDown` (⌘↓, or move-to-end-of-document)
|
||
- `commandLeft` (⌘←, or move-to-beginning/left-end-of-line)
|
||
- `commandRight` (⌘→, or move-to-end/right-end-of-line)
|
||
- `enter` (key codes 36/76, or the insert-newline command)
|
||
- `escape` (key code 53, or cancel-operation)
|
||
- `commandP` (exactly ⌘ + p)
|
||
- `commandEnter` (exactly ⌘ + Return/Enter)
|
||
|
||
In a text field, ⌘P and ⌘↩ arrive as key equivalents. A key catcher handles a key only while it is first responder. It swallows the keys its handler accepts and passes the rest on.
|
||
|
||
---
|
||
|
||
### 2.7 Menu bar (HelderCommands)
|
||
|
||
All items act on the **key window's workspace**. When no window is key, the workspace is absent: items that only perform a command then do nothing, unless listed otherwise.
|
||
|
||
**App menu:** the platform default (About, Hide, Hide Others, Show All, Quit Helder ⌘Q, Services). ⌘Q follows section 2.19.
|
||
|
||
**File menu** (replaces the platform's "New" group and "Save" group):
|
||
|
||
| Item | Shortcut | Behaviour |
|
||
|---|---|---|
|
||
| New Window | ⇧⌘N | New process on the launcher. Works without a window. |
|
||
| Open Folder… | ⌘O | With a workspace: `openFolder` (switches this window). Without one: show the folder picker and open the choice in a **new process**. |
|
||
| Open Recent ▸ | — | Submenu: one item per recent project of the key workspace, **excluding the window's own project**, titled with the project's `name`. A click: with a workspace, `openRecentProject(path)`. Without one, a new process on that path. When the list is empty, a single non-actionable line `No Recent Projects`. With no window the list is always empty. |
|
||
| Open Recent Project… | ⇧⌘O | `showRecentProjects`. **Disabled** when the workspace has no project, or when there is no window. |
|
||
| Close / Close File | ⌘W | The title is `"Close File"` when a file is open, else `"Close"`. With a workspace: `closeFileOrWindow`. Without one: a normal close of the key window. |
|
||
| Close Window | ⇧⌘W | A normal (guarded) close of the key window. |
|
||
| — separator — | | |
|
||
| Save | ⌘S | `save`. **Disabled** when no file is open. |
|
||
|
||
**Edit menu:** the platform default (Undo, Redo, Cut, Copy ⌘C, Paste, Select All ⌘A, and so on). These items act on the focused text view whenever the router passes the key.
|
||
|
||
**View menu** (items inserted before the platform toolbar group):
|
||
|
||
| Item (title switches with state) | Shortcut | Command |
|
||
|---|---|---|
|
||
| Refresh | ⌘R | `refresh`. **Disabled** without a project. |
|
||
| — | | |
|
||
| `Hide Git` if the Git view is open, else `Show Git` | ⌘G | `toggleGit` |
|
||
| `Show Explorer` if the Explorer is hidden, else `Hide Explorer` | ⌘1 | `togglePane(explorer)` |
|
||
| `Show File` / `Hide File` | ⌘2 | `togglePane(editor)` |
|
||
| `Show Claude` / `Hide Claude` | ⌘3 | `togglePane(terminal)` |
|
||
| `Fluid Column Widths` if Fluid is off, else `Lock Column Widths` | ⌘L | `toggleAutoFit` |
|
||
| `Hide Hidden Files` if Hidden is on, else `Show Hidden Files` | ⌘. | `toggleHidden` |
|
||
| — | | |
|
||
| Search | ⌘F | `showSearch(seed: "")` (the model then seeds it from the editor's line selection) |
|
||
| Keyboard Shortcuts | — | `showShortcuts` |
|
||
| — | | |
|
||
| Actual Size | ⌘0 | `zoom(reset)` |
|
||
| Zoom In | ⌘+ | `zoom(bigger)` |
|
||
| Zoom Out | ⌘- | `zoom(smaller)` |
|
||
| — | | |
|
||
| `Exit Full Screen` if in full screen, else `Enter Full Screen` | ⌃⌘F | toggle the key window's full screen |
|
||
|
||
The router consumes the shortcuts it owns (⌘F, ⌘G, ⌘1–3, ⌘L, ⌘., ⌘S, ⌘W, ⌘P) first. The menu item only fires from the keyboard when a field or an overlay let the key through, or when the item is clicked.
|
||
|
||
**Window menu:** the platform's window-size group is replaced by **Minimize** (no shortcut; ⌘M is taken by the editor) and **Zoom** (no shortcut). After them come the platform defaults (Bring All to Front, the window list).
|
||
|
||
**Help menu** (replaced):
|
||
|
||
| Item | Behaviour |
|
||
|---|---|
|
||
| Keyboard Shortcuts | `showShortcuts` |
|
||
| — | |
|
||
| Open Log | Open `~/Library/Logs/Helder/helder.log` in the default app |
|
||
| Reveal Log in Finder | Select that file in Finder |
|
||
|
||
There is no menu item for ⌘N; ⌘N does nothing. There is no Settings window.
|
||
|
||
Menu quirk to reproduce or fix: on the launcher, View > Search, Keyboard Shortcuts and Show Git change the state, but nothing is drawn, because the overlay host and the Git view live only in the project layout. A project switch clears this: it dismisses the overlay and resets the Git view.
|
||
|
||
---
|
||
|
||
### 2.8 Title bar (TitleBarView)
|
||
|
||
**44pt** tall. Background `panel`. A 1pt `raised` hairline on its bottom edge. It is shown only with a project. It holds four parts, laid out by a custom rule:
|
||
|
||
```
|
||
leading inset = 14 in full screen, else 82 (room for the traffic lights)
|
||
trailing inset = 14, gap = 18, every part vertically centred
|
||
clusterX = minX + leading
|
||
toolbarX = maxX − 14 − toolbarWidth
|
||
togglesX = min(midX − togglesWidth/2, toolbarX − 18 − togglesWidth) // centred on the window; moves left only when the toolbar would run into it
|
||
crumbX = clusterX + clusterWidth + 18
|
||
crumbWidth = max(0, togglesX − 18 − crumbX)
|
||
```
|
||
|
||
1. **Cluster** (fixed size; spacing 10; aligned on the first text baseline):
|
||
- **Wordmark:** `Helder` in text1 followed by `.` in amber, role wordmark. The period **blinks** in hard steps: visible for the first 0.55 s of every 1.1 s cycle and invisible for the second, with no fade. The phase comes from the wall clock: on when floor(time / 0.55) is even.
|
||
- **Project name** (`model.name`, the folder name): role path, colour text4, text2 on hover (0.16 s colour transition), one line. Pointing-hand pointer. A click runs `openFolder`. Tooltip: `Open folder…`.
|
||
- `·` in role path, text4.
|
||
- **Branch:** the git branch, or `—` when there is no source control or no branch. Role branch, amber, one line.
|
||
2. **Breadcrumb** (only with an open file; otherwise empty space). The path is split on `/`. Segments are separated by `›` in text4, with spacing 7. Folder segments use role path in text4. The last segment uses role crumbLeaf in text1 and has layout priority, so it is the last to truncate. When the active file is dirty, a `●` follows (system font 10pt, amber, 4pt leading padding) with the tooltip `Unsaved changes`. One line, **truncated at the head**. Display only; clicks do nothing.
|
||
3. **Pane toggles:** a button group of three toggles labelled `Explorer`, `File`, `Claude` (panels explorer/editor/terminal). A click runs `togglePane`. Tooltips: `<Label> column: ` + `shown`/`hidden` (the state word in amber, the rest text2) + `. Click to hide it.` or `. Click to show it.`. Tooltips hang at the leading edge.
|
||
4. **Toolbar** (spacing 8): a button group, then the `?` button. Tooltips hang at the trailing edge.
|
||
- **Stop** appears only while read-aloud is playing. It is first in the group. A toggle that is always on. No key hint. Tooltip: `Read aloud: ` + `playing` + `. Click to stop.` A click runs `stopReading`. The button disappears when the reading ends or stops.
|
||
- **Git**: the label is `Git N` when N > 0, else `Git`. N = the count of **distinct paths** among the git changes, so a file that is both staged and unstaged counts once. Key hint `⌘G`. A toggle that is on while the Git view is open. Tooltip: `Git view: ` + `open` + `. Click to close it (⌘G).` or `Git view: ` + `closed` + `. Click to open it (⌘G).`. The button keeps a stable identity while its label changes.
|
||
- **Search**: key hint `⌘F`. An **action** (no state dot). Tooltip `Search the open file, the project and the file names.` A click runs `showSearch(seed: "")`.
|
||
- **Fluid**: key hint `⌘L`. A toggle. Tooltip on: `Column widths: ` + `fluid` + ` — the columns re-fit on resize and focus. Click to lock them.` Tooltip off: `Column widths: ` + `locked` + ` — the columns keep their size. Click to make them fluid.`
|
||
- **Hidden**: key hint `⌘.`. A toggle. Tooltip on: `Hidden files: ` + `shown` + ` — dotfiles appear in the tree and the search. Click to hide them.` Tooltip off: `Hidden files: ` + `hidden` + ` — dotfiles are excluded from the tree and the search. Click to show them.`
|
||
- **`?` button**: a 26×26 square, a 1pt `raised` border with radius 2, the glyph `?` in role keycap, text4 (text1 on hover, `hover` fill). Tooltip `Keyboard shortcuts.` A click runs `showShortcuts`.
|
||
|
||
**Button group visuals (`ButtonGroup`/`GroupButton`):**
|
||
- The buttons sit edge to edge in one box with a 1pt `raised` border and radius 2. Each button after the first has a 1pt `raised` line on its left. Only the outer corners are rounded.
|
||
- Each button: padding 6 (top/bottom) and 10 (left/right). Content spacing 7. One line.
|
||
- Content: a **6pt state dot** for a toggle (amber when on, text5 when off), then the label (role button; text1 when on, text4 when off, text3 for an action), then the optional key hint (role keycapSmall; text4 when off, amber otherwise).
|
||
- Fill: amberTint when on, `hover` when hovered, else clear. Transitions 0.12 s. Pointing-hand pointer. Tooltips appear after 350 ms, max width 300.
|
||
|
||
The empty title-bar area drags the window, because the traffic-light container was enlarged.
|
||
|
||
### 2.9 Status bar (StatusBarView)
|
||
|
||
**28pt**. Background `panel`. A 1pt `raised` hairline on top. Horizontal padding 14. Item spacing 16. Role meta (mono 11), text4 unless noted. One row, **display only** (nothing is clickable, arrow pointer). The Git view covers it while open.
|
||
|
||
Left to right:
|
||
1. `⑂ <branch>` in amber, one line. The branch of the git state, default `—`.
|
||
2. `+<added>` in addedText. The sum of the added lines over all change rows.
|
||
3. `−<removed>` (U+2212 minus) in removedText.
|
||
4. `<stagedCount> staged · <unstagedCount> unstaged`. stagedCount = the number of change rows that are staged, unstagedCount = the number of rows − stagedCount. These count rows, so a file that is both staged and unstaged counts in both.
|
||
5. A flexible spacer.
|
||
6. Only when a file is open: the relative path (one line, **truncated at the head**, max width = 0.52 × window width, right-aligned), then `·`, then the position `Ln <line>, Col <column>` (1-based, from the editor cursor if its path equals the active path, else `Ln 1, Col 1`), then `·`.
|
||
7. `UTF-8` `·` `LF`. These are always shown, with or without a file.
|
||
8. Only when a file is open: `·` and then the language label in text3.
|
||
|
||
**Language labels (`FileType.languageLabel`):** the extension is the part after the last `.` of the base name, lowercased. Any base name that starts with `.env` counts as extension `env`. Table: php→PHP, js/mjs/jsx→JavaScript, ts/tsx→TypeScript, py→Python, html→HTML, css→CSS, json→JSON, md→Markdown, sh→Shell, env→Dotenv, yml/yaml→YAML. Any other extension → the extension UPPERCASED (for example `cjs`→`CJS`, `vue`→`VUE`). No extension → `Plain Text`.
|
||
|
||
---
|
||
|
||
### 2.10 Toasts (ToastStore, ToastStack)
|
||
|
||
- **Data:** `Toast{id (unique), title, detail?}`. There is only one toast type. `show(title, detail?)` appends the toast and removes that same toast **2300 ms** later, on its own timer. There is no cap on the count and no merging of duplicates.
|
||
- **Stack:** bottom-centred, **44pt above the window's bottom edge** (over the status bar). Vertical spacing 8. The newest toast is at the bottom. Toasts take no clicks or hover (clicks pass through). They sit above every overlay and above the Git view, and they also show on the launcher.
|
||
- **Card:** an HStack with spacing 12:
|
||
- The icon `doc.on.doc` (a copy glyph), 12pt light, amber. It is the **same for every toast, failures included**.
|
||
- The title in role toastTitle, text1.
|
||
- If the detail is non-empty: a chip with the detail text in role toastReference, ink on amber, padding 7×3, radius 2, one line, **truncated in the middle**.
|
||
- Card padding 14×10. Max width 560 (the card sizes to its content up to that width). Background `panel`, radius 4, a 1pt `raised` border, a **2pt amber rule on the left edge** (rounded with the card's left corners), and menuShadow (radius 8, y 4).
|
||
- **Every toast in the app** (title — detail):
|
||
- `Saved` — path. Only for an explicit save; auto-save does not toast.
|
||
- `Save failed` — path.
|
||
- `Created file` / `Created folder` — the new path.
|
||
- `Renamed file` / `Renamed folder` — the new path.
|
||
- `Deleted file` / `Deleted folder` — the path.
|
||
- `Create failed` — the target path (the directory joined with the trimmed name, with leading and trailing slashes dropped).
|
||
- `Rename failed` — the typed name.
|
||
- `Delete failed` — the path.
|
||
- `Copied reference` — the reference.
|
||
- `Copied` — the file name (Copy file name).
|
||
- `Copied` — `<N> characters` (clean copy).
|
||
- `Committed 1 file` / `Committed <N> files` — the commit subject: the trimmed message, cut to 34 characters plus `…` when it is longer.
|
||
- `Commit failed` — the first error line from git (else the last non-hint output line).
|
||
- `Pushed <N> commit(s) to origin/<branch>`, or `Pushed to origin/<branch>` when ahead = 0 — no detail.
|
||
- `Push failed` — the git error line.
|
||
- `Pulled <N> commit(s) from origin/<branch>`, or `Pulled from origin/<branch>` when the count is unknown — no detail. An up-to-date pull shows nothing.
|
||
- `Pull failed` — the git error line.
|
||
- `Switched to <local branch>` — no detail.
|
||
- `— Commit or discard <N> file(s) before you switch.` — no detail.
|
||
- `Passed to agent` — the reference.
|
||
- `Nothing to read` — the path, or no detail for a selection.
|
||
- `Nothing to send` (Plak with a blank selection) — no detail.
|
||
- "commit(s)" and "file(s)" mean singular when N = 1, else plural.
|
||
- Stores never toast directly: they call a `notify(title, detail)` hook that the model connects to the toast store.
|
||
|
||
### 2.11 Focus flash (FocusFlash)
|
||
|
||
- **Trigger:** the window becomes key **after** it resigned key earlier, and a project is open. The first activation after launch never flashes.
|
||
- **Behaviour:** visible for **500 ms**, then hidden. A new trigger cancels the old timer and restarts the 500 ms. There is no fade.
|
||
- **Content, centred in the window, takes no clicks:**
|
||
- An HStack with spacing 11: a branch glyph (system `arrow.triangle.branch`, 18pt light, amber), the branch (or `—`) in role focusFlash amber, a 1×17 `raised` divider with 1pt horizontal padding, and the project **name** (the folder name, not the title) in role focusFlashName, text1, one line.
|
||
- Padding 22×15. Background `panel`, radius 4, a 1pt `raised` border, a 2pt amber rule on the left, overlayShadow (radius 24, y 16).
|
||
|
||
### 2.12 Mouse focus and the refresh flash
|
||
|
||
**Mouse focus:**
|
||
- A local monitor watches left and right mouse-down events in this window.
|
||
- It acts only with a project open, no overlay presented, and the Git view closed.
|
||
- The click must be below the title bar and above the status bar: `height − y > 44` and `y > 28` in bottom-up coordinates.
|
||
- The column is `panel(atX: x, splitterMargin: 4)`, and `pointerFocused(panel)` calls `layout.focus(panel)`. This sets the active column, the zone and the refit, **without** a focus request and without taking first responder.
|
||
- If the column is the Explorer: on the next run loop, if the first responder is a text view or a terminal that sits in **another** column, clear the first responder. Typing then does not land in that other column.
|
||
- The event always continues to its target.
|
||
|
||
**Refresh flash (⌘R):** the **Explorer and Editor columns** each get an overlay of `#0F1113` with a plus-lighter blend. On every `refreshTick` change, its opacity jumps to 1 and eases out to 0 over **0.26 s**. The overlay takes no clicks. The agent column does not flash.
|
||
|
||
---
|
||
|
||
### 2.13 Launcher / start screen (LauncherScreen, LauncherCard, LauncherList)
|
||
|
||
Shown when the window has no project, once `isReady`. There is no title bar, no columns and no status bar. The traffic lights are still drawn.
|
||
|
||
- **Ground:** `#101720`. The card is top-centred with 40pt top padding, 20pt side padding and 20pt bottom padding. It is **520pt wide**.
|
||
- **Card:** background `panel`, radius 8, a 1pt `raised` border, overlayShadow (radius 24, y 16).
|
||
- If the whole card fits the window height, it hugs its content. If not, the rows scroll inside the card between a fixed head and a fixed footer, and the scroll follows the keyboard selection.
|
||
- **Head:** padding 20, a hairline below, HStack spacing 14:
|
||
- a sparkle glyph (16pt light, amber)
|
||
- a VStack with spacing 5: the wordmark (role launcherWordmark, with the blinking period) and the line `Open a project to begin` (role tooltip, text4).
|
||
- **Row 0:** a plus glyph, the text `Open new project…` (role rowSelected, text1), and a trailing chip `↵` in esc-chip style (chip role, text4, padding 6×4). Height **46**, a hairline below. The icon of row 0 is **always amber**.
|
||
- **`RECENT` label** (only when there are recents): role panelLabel, text4, padding top 14, left/right 20, bottom 6. Source text "Recent", shown uppercase.
|
||
- **Recent rows (index 1…):**
|
||
- a folder glyph
|
||
- the project name (role rowSelected; text1 when selected, else text3; one line)
|
||
- the absolute path (role meta; text3 when selected, else text4; one line, truncated at the head), aligned on the first baseline with spacing 10
|
||
- height **38**, tooltip = the full path
|
||
- **All rows:** HStack spacing 12. The icon is 13pt light in a 16×16 frame, amber when selected (or row 0), else text4. A spacer of at least 8. The trailing element. Horizontal padding 20.
|
||
- **Selection look:** the `raised` fill plus a 2pt amber rule on the left. Hover gives the `hover` fill. Pointing-hand pointer.
|
||
- **Hovering** a row **selects** it (`launcherSelect`). A click selects the row and then activates it.
|
||
- **Footer:** the hint `⌘↑↓ navigate · ↵ open` (the keys in amber, the words and the ` · ` separator in text4, role chip), padding 20 left/right, min height 36, a hairline above.
|
||
- **Model (`LauncherList`):**
|
||
- rows = 1 + recents. The window's own root is filtered out.
|
||
- The selection starts at 0. `move(step)` and `select(i)` clamp to [0, count−1].
|
||
- `choice(0) = chooseFolder`. `choice(i) = open(recents[i−1].path)`. An index out of range gives nil (does nothing).
|
||
- The list is rebuilt from `recentProjects` at start and after each project load.
|
||
- **Keys:** see 2.6.2 step 2 (↑/↓ with or without ⌘, ↵, all through the router). ⌘O comes from the menu. ⇧⌘N gives a new window.
|
||
- **Choosing a folder:** the system folder picker allows directories only, a single selection, the button `Open`, and the message `Choose a project folder`. Cancel does nothing.
|
||
- **When the launcher shows:** a start with no folder, every New Window, and the Dock reopening a window after the last one closed.
|
||
|
||
### 2.14 Recent projects (RecentProjectsStore, RecentProjectsOverlay)
|
||
|
||
**Store:**
|
||
- File: `~/Library/Application Support/Helder/recent-projects.json`. The folder is created when needed.
|
||
- Content: a JSON array of `{"path": "<absolute standardized path>", "name": "<basename>"}`. Pretty-printed, slashes not escaped, written atomically. Newest first.
|
||
- `list()`: read and decode. A read or decode error gives `[]`. **Drop entries whose path no longer exists.** Cap at **20**.
|
||
- `add(path)`:
|
||
- Standardize the path to an absolute path.
|
||
- name = basename, or the full path if the basename is empty.
|
||
- Move the entry to the front, de-duplicated by path, capped at 20.
|
||
- Write the file. On failure, log the warning `cannot save recent projects: <error>`.
|
||
- Every project load calls `add` (so the project moves to the top), then re-reads the list.
|
||
- The store is machine-wide and shared by all windows and processes.
|
||
|
||
**⇧⌘O overlay ("Open recent project"):**
|
||
- It works only with a project open (the menu item is disabled otherwise, and the launcher shows its own list).
|
||
- It shows `otherRecentProjects`: `recentProjects` minus the current root. The list is re-read when the overlay opens.
|
||
- **Shell:** a sized overlay, card width **560**, top-aligned, 34pt inset, on the scrim. A click on the scrim closes it.
|
||
- **Header:** height 50, padding 18 left/right, a hairline below.
|
||
- a `folder` glyph in text4 (not amber)
|
||
- the title `Open recent project` (role dialogTitle, text1)
|
||
- **no** esc chip
|
||
- trailing, in a bordered box (padding 6×4, a 1pt `raised` border, radius 2, role path, text4): the text `<N> project ·` or `<N> projects ·`, then the keycaps `⌘↓`, `⌘↑`, `↵` (spacing 4)
|
||
- **List:**
|
||
- a scroll area with height `min(460, max(count, 1) × 38 + 12 + (empty ? 12 : 0))` and 6pt vertical padding
|
||
- rows 38 tall, padding 14 left/right, spacing 10
|
||
- a folder glyph (13pt light; amber when selected, else text4; 16 wide)
|
||
- a VStack with spacing 1: the name (role rowSelected; text1 when selected, else text2) and the path (role meta, text4, truncated at the head)
|
||
- the selected-row look, tooltip = the path, pointing hand
|
||
- Empty: the text `No other recent projects` (role tooltip, text4, padding 12 top/bottom, 14 left/right)
|
||
- **Keys** (key catcher):
|
||
- ↑ or ⌘↑ → selection −1, ↓ or ⌘↓ → +1, clamped. Each of these also **parks the pointer**: it records the mouse location, and later hover events at that same location are ignored. A list that scrolls under a still mouse then does not steal the selection.
|
||
- ↵ → open the selected project.
|
||
- Esc → close (the router also turns Esc into `dismissOverlay`).
|
||
- **Hover** selects (unless the pointer is parked). A click opens.
|
||
- **Open** = dismiss, then `openRecentProject(path)` (a project switch, section 2.19).
|
||
|
||
### 2.15 Overlays (OverlayStore, OverlayHost)
|
||
|
||
- **Exactly one overlay at a time. Overlays never stack.** `present(x)` replaces whatever is open, and `dismiss()` sets `.none`. Setting the same value again does nothing and fires no callback.
|
||
- **Kinds (`Overlay`):** `none`; `search(seed)` (⌘F); `shortcuts` (`?`); `cleanCopy`; `diff(DiffOverlayRequest{path, side?, focusLine?})`; `launcher` (the ⇧⌘O list; the bare-window launcher is **not** an overlay); `recentFiles(initialSelection)`; `passOn(PassOnRequest{reference, code?, anchor})`; `symbol(name)` (⌘-click on a PHP class); `contextMenu(ContextMenuRequest{target, header, entries, anchor})`; `namePrompt(NamePromptRequest{purpose, initialName, anchor})`; `confirm(ConfirmRequest{title, body?, confirmLabel, action})`.
|
||
- **`onChange(old, new)`** fires on **every** change, however it happened, including when one overlay replaces another:
|
||
- If the old overlay was `diff` → the editor closes the Diff, which gives back the view mode the Diff covered.
|
||
- If the new overlay is `none` and clean-copy text is pending → open the clean-copy overlay on the next tick. Pending text waits while any other overlay is open.
|
||
- **Host:** draws the current overlay over the workspace (and over the Git view). `launcher` is drawn by the shell. `diff`, `passOn` and `symbol` are drawn by the editor's overlay content. The columns behind an overlay show the arrow pointer.
|
||
- **Router view (`OverlayKind`):** `none`, `diff(busy)` (the workspace shortcuts keep working over the Diff unless its own menu or prompt is open), `other` (owns every key except Esc).
|
||
- **Sized overlay shell:** a full-window scrim (`#101720` at 72%). A click on it calls dismiss. The card is top-centred, has the given width, and sits 34pt inside the window edges. The card: `panel` background, radius 8, a 1pt `raised` border, overlayShadow.
|
||
- **Overlay header:** height 50 by default, padding 18 left/right, HStack spacing 12. A glyph (14pt light, amber by default), the title (role dialogTitle, text1), an optional detail (role path, text4), a spacer of at least 12, optional trailing content, and the `esc` chip unless turned off. A hairline below.
|
||
- **Overlay footer:** 38pt, padding 18, a hairline above, hints in role chip.
|
||
- **Hint format** (`OverlayFooter.hint`): pairs joined by ` · ` in text4. Each pair is the key glyphs in amber + a space + the action word in text4.
|
||
|
||
### 2.16 Confirm dialog and name prompt
|
||
|
||
**Confirm (`ConfirmOverlay`):**
|
||
- A sized shell, card width **460**, padding 20.
|
||
- The title (role dialogTitle, text1).
|
||
- An optional body: mono regular 12, line height 19.2, text4, wraps, 12pt above.
|
||
- A buttons row, 20pt above, right-aligned, spacing 8:
|
||
- **Cancel** in secondary style: the text `Cancel` and the keycap `esc`.
|
||
- **Confirm** in destructive style (amber-deep): `<confirmLabel>` and the keycap `↵` (on-deep style).
|
||
- Keys: ↵ → confirm, Esc → close. A click on the scrim closes the dialog.
|
||
- The confirm button and ↵ call `confirmPending`. The view does **not** dismiss first, so the pending request is not lost.
|
||
- Requests:
|
||
- Git discard (when `git.confirmDiscard` is on and paths exist, and not all paths are deletions):
|
||
- title `Discard changes to <what>?`, or `Delete <what>?` when all files are new, where `<what>` = the single path or `<N> files`
|
||
- body `New files are removed from disk. This cannot be undone.` if any file is new, else `This reverts to the last commit and cannot be undone.`
|
||
- label `Delete` if all files are new, else `Discard`
|
||
- Explorer delete: title `Delete file?` or `Delete folder?`. Body `<path> will be permanently deleted.` or `<path>/ and everything inside it will be permanently deleted.` Label `Delete`.
|
||
|
||
**Name prompt (`NamePromptOverlay`):**
|
||
- No scrim. A transparent full-window area takes clicks and **closes** the prompt.
|
||
- The panel is **460 wide**, positioned at the anchor (normally where the context menu stood):
|
||
- x = max(8, min(anchor.x, width − 460 − 8))
|
||
- y = max(8, min(anchor.y + 6, height − 150))
|
||
- Panel style: padding 14, spacing 12, `panel` background, radius 4, a 1pt `raised` border, menuShadow.
|
||
- **Header:** HStack spacing 10. A `folder` or `doc` glyph (13pt light, amber). The title in mono bold 13, text1. A spacer. The `esc` chip.
|
||
- Titles: `New file`, `New folder`, `Rename file`, `Rename folder`.
|
||
- **Field:** height 38, editor-colour background, radius 2, the focus ring, 10pt inner padding, mono 13, text `#F4F5F4`, amber caret.
|
||
- Placeholder `file name…` or `folder name…` in `#6C7783`.
|
||
- It takes focus on appear.
|
||
- Initial selection: for a rename, only the stem, from 0 up to the last `.` when that dot exists and is not at index 0. Otherwise the whole text.
|
||
- **Preview row** (spacing 10):
|
||
- a label in role panelLabel, text4, shown uppercase: `creates` (new) or `renames to` (rename)
|
||
- a chip in role path, ink on amber, padding 8×4, radius 2, middle-truncated, one line, showing the target path or `…`
|
||
- **Footer hint:** `↵ create file`, `↵ create folder`, `↵ rename file` or `↵ rename folder`, then ` · esc cancel`.
|
||
- **Target / validity (`promptTarget`):**
|
||
- Trim spaces. Empty → nil (shows `…`).
|
||
- New file: `join(dir, name without leading/trailing slashes)`. Inner slashes are allowed and create intermediate folders.
|
||
- New folder: the same, plus a trailing `/`.
|
||
- Rename: `validatedName` trims whitespace and newlines and strips trailing slashes. It rejects an empty name, a name that contains `/`, `.` and `..`. The name must also differ from the current base name. A case-only change is allowed. Result: `join(dirname(path), clean)`, plus `/` for a folder.
|
||
- `join(dir, name)` = name if dir is empty, else `dir/name`.
|
||
- **Keys:** ↵ submits only when the target is valid. Then it sends the name trimmed of whitespace and newlines. The view does **not** dismiss first. Esc → close.
|
||
- There are **no inline error messages**. An invalid name only disables ↵.
|
||
- **After submit** (`submitName`):
|
||
- Dismiss, then run the Explorer action as tracked work.
|
||
- Success toasts: `Created file`, `Created folder`, `Renamed file`, `Renamed folder`.
|
||
- Failure toasts (for example the target exists; nothing is overwritten): `Create failed`, `Rename failed`.
|
||
- New file → open it (only if the editor is still the same instance). New folder → nothing more. Rename → the editor remaps its open path.
|
||
- Then refresh git.
|
||
|
||
**Unsaved-changes alert** (native modal alert; warning style; used by the close, switch and quit flows and by opening another file):
|
||
- Message: `Save changes to <basename>?`
|
||
- Informative text: `<path> has unsaved edits. They are lost if you close without saving.`
|
||
- Buttons, in order: `Save`, `Don’t Save` (U+2019 apostrophe), `Cancel`. Return = Save. Esc = Cancel.
|
||
|
||
### 2.17 Shortcuts overlay (ShortcutsOverlay, ShortcutCatalog), verbatim
|
||
|
||
- A sized shell, card width **600**.
|
||
- Header: the glyph `questionmark.circle` (amber), the title `Keyboard shortcuts`, the `esc` chip.
|
||
- Body: padding top 18, left/right 20, bottom 22. It grows with its content and scrolls only when the window is too short.
|
||
- Each group title: role panelLabel, text4, shown UPPERCASE, 16pt above it (0 for the first group), 8pt below.
|
||
- Each row: a 92pt-wide key column holding keycaps (each at least 22 wide, spacing 4), spacing 14, then the label in role row, text2. Rows have 6pt vertical padding.
|
||
- Esc closes it. A click on the scrim closes it.
|
||
|
||
Each element of "Keys" below is one keycap:
|
||
|
||
| Group | Keys | Label |
|
||
|---|---|---|
|
||
| Navigate | `⌘` `F` | Search contents and names |
|
||
| Navigate | `⌘` `↑↓` | Move through a list |
|
||
| Navigate | `↵` | Open the selected item |
|
||
| Navigate | `⌘` `←→` | Column left or right |
|
||
| Navigate | `↑↓` | Explorer: move the row cursor |
|
||
| Navigate | `⌘` `1` | Explorer column on or off |
|
||
| Navigate | `⌘` `2` | File column on or off |
|
||
| Navigate | `⌘` `3` | Claude column on or off |
|
||
| Navigate | `⇧` `⌘` `O` | Open a recent project |
|
||
| Navigate | `⌘` `O` | Open a project folder |
|
||
| Navigate | `⇧` `⌘` `N` | Open a new window |
|
||
| Navigate | `⌘` `click` | PHP class: declaration and references |
|
||
| Navigate | `?` | This list of shortcuts |
|
||
| Agent | `⌘` `→` | Pass the selection to the agent |
|
||
| Git | `⌘` `G` | Open or close the Git view |
|
||
| Git | `⌘` `C` | Focus the commit message |
|
||
| Git | `⌘` `↵` | Commit the staged files |
|
||
| Git | `⌘` `P` | Push the current branch |
|
||
| File | `⌘` `S` | Save this file |
|
||
| File | `⌘` `M` | Markdown: code or rendered preview |
|
||
| File | `⌘` `W` | Close this file, or the window when none is open |
|
||
| File | `⌘` `R` | Re-read git and the files from disk |
|
||
| File | `⌘` `.` | Hidden files on or off |
|
||
| File | `⌘` `A` | Select all in this pane |
|
||
| File | `⌘` `L` | Fluid columns on or off |
|
||
| File | `⌘` `+` | Zoom in |
|
||
| File | `⌘` `−` (U+2212) | Zoom out |
|
||
| File | `⌘` `0` | Actual size |
|
||
| File | `Esc` | Close an overlay, then the Git view |
|
||
|
||
Groups in order: Navigate, Agent, Git, File.
|
||
|
||
### 2.18 Focus requests, the Git view hand-off
|
||
|
||
- `focusRequest` names where the keyboard should go. The view that takes the keyboard calls `focusTaken(target)`, which clears the request when it matches. A view that is rebuilt later then does not take focus again.
|
||
- The agent column takes `.panel(.terminal)`: the agent terminal view becomes first responder.
|
||
- The editor's text view follows its own text-focus counter (`requestTextFocus`).
|
||
- The Git commit field takes `.commitMessage`.
|
||
- The Explorer has no text view. The router path clears the first responder for it.
|
||
- **`openGitView()`:**
|
||
- If the view is closed: open it, schedule a git refresh, and run the source control's "view opened" hook (it fetches origin) as tracked work.
|
||
- In all cases: `focusRequest = .commitMessage`.
|
||
- **`closeGitView()`:**
|
||
- Does nothing if the view is closed. Otherwise close it.
|
||
- If `activePanel` is nil → `focusRequest = nil`.
|
||
- Else → `focusRequest = .panel(activePanel)`, and for the editor also `requestTextFocus`.
|
||
- The keyboard goes back to the column that had it before.
|
||
- The source-control store may ask to focus the message: after a failed commit with an empty message, it sets `focusRequest = .commitMessage`.
|
||
|
||
### 2.19 Lifecycle: start, project switch, close, quit
|
||
|
||
**Start (`start()`, runs once per window):**
|
||
1. Load `recentProjects` from the store.
|
||
2. Build the launcher list, excluding the root.
|
||
3. If there is a root: `loadProject()`.
|
||
4. Set `isReady = true`.
|
||
|
||
**Attach (on init with a root, and on every switch):**
|
||
- Increase `generation`.
|
||
- Build the project services.
|
||
- Set `name` and `title`. Clear the row frames.
|
||
- Build new source-control, Explorer, editor, clean-copy and **terminal** stores, and connect their toast and focus hooks.
|
||
- Rebuild the launcher list.
|
||
|
||
**`loadProject()`:**
|
||
1. `layout.restore(root)`.
|
||
2. Resolve the config. If the generation changed, stop. Apply the config to the stores.
|
||
3. Add the root to the recents (which moves it to the top) and re-read them. If the generation changed, stop.
|
||
4. Rebuild the launcher list.
|
||
5. In parallel: git refresh, tree reload, clean-copy baseline.
|
||
6. `editor.restore(restoreSession: config.session.restoreOnLaunch)`. If the generation changed, stop.
|
||
7. Start the file watcher, start git polling, and load the PHP class list after **1.5 s**.
|
||
|
||
**Project switch** (`openFolder`, `openRecentProject`, a launcher row, ⇧⌘O):
|
||
- It runs as the one "lifecycle task". A second switch requested while one runs is **ignored**.
|
||
- `openProject(url)`:
|
||
1. Standardize the URL.
|
||
2. **Dismiss any overlay.**
|
||
3. If url == root, stop here. Only the overlay closes.
|
||
4. `prepareToClose()`. If it returns false (the user cancelled), stop and keep the current project.
|
||
5. `closeProject()`.
|
||
6. root = url, attach, `loadProject()`, `isReady = true`.
|
||
- Because the terminal store is new, the terminals restart in the new folder.
|
||
- The layout, open file and session come from the new project's saved state.
|
||
|
||
**`prepareToClose()`:**
|
||
- Ask about every dirty file in turn, using the unsaved-changes alert (at most the open file plus a buffer whose file vanished). Cancel → return **false**. Save → write; if the save fails, keep the file and stay. Don't Save → drop the edits.
|
||
- Then write the session (`persist`) and return true.
|
||
|
||
**`closeProject()`:**
|
||
1. Stop the watcher and git polling. Clear the pending refreshes.
|
||
2. Cancel the refresh task, the symbol task and every tracked command task, and **wait** for all of them.
|
||
3. Stop read-aloud. Flush pending auto-saves. Write the session. Terminate both terminals.
|
||
|
||
**Window close** (red button, ⇧⌘W, ⌘W with no file open, File > Close):
|
||
- The close guard's first `windowShouldClose` returns **false** and starts `prepareToClose()` asynchronously. Re-entry is blocked while that question is open.
|
||
- If the result is approved: mark the close as approved and close the window for real. A cancel leaves the window open.
|
||
- On will-close: unregister, `windowWillClose()` (runs `closeProject()` once, as the lifecycle task), and remove the monitors.
|
||
|
||
**Quit (⌘Q)** (`applicationShouldTerminate`):
|
||
- With no registered windows → quit now.
|
||
- Otherwise answer "later". Then, for each registered model **in order**, await `prepareToClose()`. The first false **cancels the quit**. Models already prepared are not rolled back; their sessions are already written.
|
||
- If all return true: await `closeProject()` for each, then allow the quit.
|
||
|
||
**Refresh and watcher timings** (from the model, for completeness): watcher events are gathered into one refresh with a **100 ms** debounce. The class list reloads **2 s** after the last project change. ⌘R bypasses the debounce.
|
||
|
||
### 2.20 Every user-visible string in this section's scope (verbatim)
|
||
|
||
`Helder` / `.` (wordmark) · `Open a project to begin` · `Open new project…` · `Recent` (shown `RECENT`) · `⌘↑↓ navigate · ↵ open` · `↵` (row-0 chip) · `Open` and `Choose a project folder` (folder picker) · `Open recent project` · `<N> project ·` / `<N> projects ·` · `No other recent projects` · `Open folder…` (project-name tooltip) · `·` · `—` (no branch) · `›` · `●` · `Unsaved changes` · `Explorer` · `File` · `Claude` · `<Label> column: shown. Click to hide it.` · `<Label> column: hidden. Click to show it.` · `Stop` · `Read aloud: playing. Click to stop.` · `Git` · `Git <N>` · `⌘G` · `Git view: open. Click to close it (⌘G).` · `Git view: closed. Click to open it (⌘G).` · `Search` · `⌘F` · `Search the open file, the project and the file names.` · `Fluid` · `⌘L` · `Column widths: fluid — the columns re-fit on resize and focus. Click to lock them.` · `Column widths: locked — the columns keep their size. Click to make them fluid.` · `Hidden` · `⌘.` · `Hidden files: shown — dotfiles appear in the tree and the search. Click to hide them.` · `Hidden files: hidden — dotfiles are excluded from the tree and the search. Click to show them.` · `?` · `Keyboard shortcuts.` · `⑂ <branch>` · `+<n>` · `−<n>` · `<n> staged · <n> unstaged` · `Ln <l>, Col <c>` · `Ln 1, Col 1` · `UTF-8` · `LF` · language labels (2.9) · `Plain Text` · menu items (2.7): `New Window`, `Open Folder…`, `Open Recent`, `No Recent Projects`, `Open Recent Project…`, `Close`, `Close File`, `Close Window`, `Save`, `Minimize`, `Zoom`, `Refresh`, `Show Git`/`Hide Git`, `Show Explorer`/`Hide Explorer`, `Show File`/`Hide File`, `Show Claude`/`Hide Claude`, `Fluid Column Widths`/`Lock Column Widths`, `Show Hidden Files`/`Hide Hidden Files`, `Search`, `Keyboard Shortcuts`, `Actual Size`, `Zoom In`, `Zoom Out`, `Enter Full Screen`/`Exit Full Screen`, `Open Log`, `Reveal Log in Finder` · Dock: `<title>`, `New Window` · `Keyboard shortcuts` and the catalogue (2.17) · `Cancel`, `esc`, `↵`, `Discard`, `Delete` · confirm titles and bodies (2.16) · name-prompt strings: `New file`, `New folder`, `Rename file`, `Rename folder`, `file name…`, `folder name…`, `creates`, `renames to`, `…`, `↵ create file`, `↵ create folder`, `↵ rename file`, `↵ rename folder`, `esc cancel` · unsaved alert: `Save changes to <basename>?`, `<path> has unsaved edits. They are lost if you close without saving.`, `Save`, `Don’t Save`, `Cancel` · all toast titles (2.10).
|
||
|
||
### 2.21 Conflicts between the docs and the code (the code wins)
|
||
|
||
1. **The ⌘R flash.** `docs/guide/layout.md` says "Every column flashes lighter". In the code only the Explorer and Editor columns flash; the Claude + Terminal column does not.
|
||
2. **Hidden files.** `layout.md` says Hidden "starts off every time you open a project". In the code `showHidden` lives on the window's layout store, and a project switch inside a window **keeps** it. Only a new window or process starts with it off.
|
||
3. **The top bar in behaviour.md §2.** It omits the project name · branch cluster, and it shows the breadcrumb with ` / ` separators. The code shows `Wordmark name · branch`, and the breadcrumb uses `›`.
|
||
4. **The status bar in behaviour.md §8.** It lists indentation (`Spaces: 4`) and "the active view". The code shows neither. The code adds the staged/unstaged counts, the path and `LF`.
|
||
5. **⌘P in behaviour.md §9.** It describes a fuzzy "Go to File (`Cmd+P`)" overlay. In the code ⌘P is **Push**, and there is no fuzzy go-to-file overlay. The recent-files list (⌘↑/⌘↓) replaces it.
|
||
6. **Splitter persistence.** behaviour.md §1 and §9 say "Splitter positions persist across launches". In the code the column widths persist **per project and only when Fluid is off** (saved at drag end). The Claude/shell split persists **globally** and is saved on every drag movement.
|
||
7. **Session restore.** behaviour.md §9 says the pane and splitter layout restore only when `session.restoreOnLaunch` is on. In the code the layout always restores; only the open file and its mode depend on that setting.
|
||
8. **Launch argument.** `start-screen.md` says "a folder path as the first argument". The code uses the first argument that is an existing directory, is not `.`, and does not start with `-`. `HELDER_PROJECT` must be an existing directory, else it is ignored.
|
||
9. **Open Recent with no window.** `recent-projects.md` says "With no Helder window in front, Open Folder and Open Recent open the project in a new window". In the code the Open Recent submenu reads its list from the key window's workspace, so with no window it always shows `No Recent Projects`. Only Open Folder works in that state.
|
||
10. **Missing toasts.** `notifications.md` leaves out the `Nothing to read` and `Nothing to send` toasts. It also does not say that every toast uses the same copy icon, failures included.
|
||
11. **Minus sign.** The shortcut catalogue shows Zoom Out as `⌘ −` (U+2212). The menu shortcut is `-`.
|
||
12. **Agent column minimum.** `layout.md` says the Claude column is "at least 280 points". A splitter drag enforces 280, but window-narrowing fitting can scale the column below 280 (the fixed columns shrink proportionally so that the editor keeps 280).
|
||
|
||
|
||
---
|
||
|
||
## 3. Git: data layer, commands and the Git view
|
||
|
||
This section is the full spec of everything git in Helder: how the app reads git, every command it runs, the models it derives, the refresh rules, and the full-screen Git view (⌘G) with its console and branch list. The code was the source. Where the docs say something else, the code wins, and section 3.20 lists each conflict.
|
||
|
||
Helder runs the real `git` binary as a child process. It never links a git library. The git binary is found by the same executable search as every tool. That search looks in `<app bundle>/Contents/Helpers`, then each directory on `$PATH` (a GUI app gets `/usr/bin:/bin:/usr/sbin:/sbin` when PATH is unset), then `/opt/homebrew/bin`, then `/usr/local/bin`. Duplicate directories are dropped, and the first executable regular file named `git` wins (`ExecutableLocator.standard`). Every git process runs with the project root as its working directory and with stdin set to the null device.
|
||
|
||
---
|
||
|
||
### 3.1 Two ways to run git
|
||
|
||
The app has two ways to call git. They have different environments.
|
||
|
||
| Path | Used for | Environment | Output | Timeout | Throws? |
|
||
|---|---|---|---|---|---|
|
||
| **Read path** (`GitService.run`, through `ProcessRunning.run`) | `rev-parse`, `status`, `show` blobs, `for-each-ref`, `config --get` | The inherited app environment plus `GIT_LITERAL_PATHSPECS=1`. The status call also sets `GIT_OPTIONAL_LOCKS=0`. | Collected whole: stdout, stderr, exit code. Nothing goes to the console. | none | The runner can throw on launch failure. Callers swallow it, except status (see 3.3). |
|
||
| **Console path** (`GitService.execute`, through `ProcessRunning.stream`) | Every write action (add, restore, rm, clean, commit, push, pull, fetch, switch) and every command typed in the console | The inherited app environment merged with the console environment below, which overrides any inherited values. Then `GIT_LITERAL_PATHSPECS` is set to `"1"` when `literalPathspecs` is true. When it is false the variable is **removed**, even if the app inherited it. | Streamed line by line to the console as it arrives (stdout lines with `isError=false`, stderr lines with `isError=true`). The full stdout and stderr are also returned. | optional, per call | Never. A launch failure, a timeout or a cancel becomes exit code `-1`. |
|
||
|
||
**Console environment** (`GitService.consoleEnvironment`). These values make sure a run can never wait for input:
|
||
|
||
| Variable | Value | Why |
|
||
|---|---|---|
|
||
| `GIT_TERMINAL_PROMPT` | `0` | Git never asks for a username or password. |
|
||
| `GCM_INTERACTIVE` | `never` | Git Credential Manager never opens a prompt. |
|
||
| `GIT_EDITOR` | `true` | Any editor run exits at once, so `commit` without `-m` aborts with "Aborting commit due to empty commit message." |
|
||
| `GIT_PAGER` | `cat` | No pager. |
|
||
| `PAGER` | `cat` | No pager. |
|
||
|
||
**Literal pathspecs.** Every button action passes paths as literal pathspecs (`GIT_LITERAL_PATHSPECS=1`), so `pages/[id].vue` never also matches `pages/i.vue`, and `a*.txt` is one file. Commands typed in the console run with `literalPathspecs=false`, so globs work there.
|
||
|
||
**Line splitting while streaming** (`LineBuffer`). Each pipe is read in chunks as they arrive. A line ends at a byte `0x0A` (LF) **or** `0x0D` (CR), so each progress update ("Writing objects: 45%…\r") becomes its own line. **Empty lines are dropped.** Lines are decoded as UTF-8, with invalid bytes replaced. When a pipe closes, any text left without a line break becomes a last line. stdout and stderr are drained on two threads, and a lock makes `onLine` run for one line at a time. The order between stdout and stderr lines is the order in which they were read.
|
||
|
||
**Timeout** (`execute`). The command races a timer. If the timer wins, the process is cancelled: every descendant gets SIGTERM, deepest first, then the child gets SIGTERM. The caller returns at once and does not wait for the pipes to reach EOF, because a grandchild such as `ssh` can hold a pipe open. The result is `exitCode -1, stdout "", stderr "timed out after <N>s"`. `<N>` is the whole number when the timeout is whole (`120`), and the decimal otherwise (`0.5`). The reason text also goes to `onLine(reason, isError: true)`, so it shows in the console.
|
||
|
||
**Launch failures** (`execute`):
|
||
- git not found → `onLine("git not found", true)`, result `(-1, "", "git not found")`.
|
||
- The launch failed for another reason → the reason text, the same way.
|
||
- Cancelled → result `(-1, "", "cancelled")`, and no line is printed.
|
||
|
||
`GitCommandResult.succeeded` is `exitCode == 0`.
|
||
|
||
---
|
||
|
||
### 3.2 Git directory resolution (worktrees and submodules)
|
||
|
||
`GitDirectory.resolve(root)`:
|
||
1. Let `dot = <root>/.git`.
|
||
2. If `dot` is a **file** (not a directory) that reads as UTF-8, trim the whitespace and newlines around its text. If the text starts with `gitdir:`, take the rest after `gitdir:` with spaces trimmed. Resolve it against the root when it is relative, standardise it, and return it.
|
||
3. In every other case, return `dot`.
|
||
|
||
The **watched entries** in the git directory (`GitDirectory.watchedEntries`) are `HEAD`, `index`, `refs/heads`, `refs/remotes`, `logs/HEAD` and `MERGE_HEAD`. A change to one of these paths, or to any path under them (`rel == entry` or `rel` starts with `entry + "/"`), raises a **git** watch event. Any other change inside the git directory is ignored. The watcher watches the project root, and also the resolved git directory when it lies outside the root (worktrees, submodules). Paths are compared after `realpath` resolution (`/private/var`, not `/var`).
|
||
|
||
The app has no worktree list and no worktree switcher. A worktree folder simply works as a repository.
|
||
|
||
---
|
||
|
||
### 3.3 Loading the working state (`GitService.load`)
|
||
|
||
`load()` returns a `GitSnapshot`, or `nil` when the folder is not a repository. It can throw only when status fails after all its retries.
|
||
|
||
**Coalescing.** At most one read is in flight and at most one read waits behind it:
|
||
- If a trailing read is already queued, the caller joins it and gets its result.
|
||
- Else, if a read is in flight, a trailing read is created. It waits for the in-flight read to finish (ignoring its error), then starts a fresh read. The caller joins it.
|
||
- Else, a new read starts.
|
||
|
||
A branch switch fires many watcher events, and this keeps them down to two reads.
|
||
|
||
**One read** (`read()`):
|
||
1. **Is it a repository?** (`isRepository`). Run `git rev-parse --is-inside-work-tree` (read path). If it succeeds and its trimmed stdout is `true`, the answer is yes. Otherwise the answer is still yes when a `.git` entry (file or directory) exists at the root. That fallback keeps a branch switch from blanking the view mid-probe. If the answer is no, return `nil`.
|
||
2. **Status, with retries.** Run
|
||
`git status --porcelain -b --untracked-files=all -z`
|
||
with `GIT_OPTIONAL_LOCKS=0` and `GIT_LITERAL_PATHSPECS=1`. On a non-zero exit, sleep **0.12 s** and retry, up to **6 attempts** in total. This rides out another tool holding `.git/index.lock`. After the last attempt it throws `GitError.commandFailed(arguments: [the status args], exitCode: <code>, stderr: <stderr trimmed of whitespace and newlines>)`.
|
||
3. **Parse** the output (3.4).
|
||
4. **Read the text of each changed file** (3.6), with at most **12** entries in parallel. The result keeps the entry order.
|
||
5. Return `GitSnapshot(branch, ahead, canPush, behind, upstream, changes)`, where `changes` is the flattened list of rows for each entry: the staged row first, then the unstaged row.
|
||
|
||
---
|
||
|
||
### 3.4 Porcelain status grammar (`Porcelain.parseStatus`)
|
||
|
||
The input is porcelain v1 with `-b` and `-z`. Fields are separated by NUL (`\0`). Because of `-z`, git never quotes or escapes paths: spaces, unicode and emoji appear as raw bytes. **No unquoting is done.**
|
||
|
||
The parser splits on `\0` and keeps empty fields, then walks the fields with a "source follows" flag:
|
||
1. If "source follows" is set, this field is the **source path** of the previous entry. Store it as that entry's `originalPath`, clear the flag, and continue.
|
||
2. Skip an empty field.
|
||
3. A field that starts with `## ` is the **branch header**. Parse the text after `## ` (below) and continue.
|
||
4. Any other field is an entry. `X` = character 0 (index column), `Y` = character 1 (worktree column), each `" "` when missing. `path` = the field from character 3 on (characters 0–2 are `XY` and a space). If `X` or `Y` is `R` or `C`, set "source follows". (With `-z`, git prints the destination first and the source as the next NUL field.)
|
||
|
||
When there is no header, the defaults are branch `"HEAD"`, ahead 0, canPush false, behind 0, and upstream nil. Empty output is a clean tree on branch `HEAD`.
|
||
|
||
**Header parsing.** `h` is the header text after `## `.
|
||
|
||
| Function | Rule | Examples |
|
||
|---|---|---|
|
||
| `parseBranch` | If `h` starts with `No commits yet on `, return the rest, trimmed. If `h` starts with `HEAD ` (detached: `HEAD (no branch)`), return `HEAD`. Otherwise take the text before the first `...` (or all of it), take the part before the first space, and trim it. If the result is empty, return `HEAD`. | `main...origin/main [ahead 1]` → `main`; `No commits yet on trunk` → `trunk`; `HEAD (no branch)` → `HEAD`; `` → `HEAD` |
|
||
| `parseAhead` → `(ahead, canPush)` | If `h` starts with `No commits yet on ` or `HEAD `, return `(0, false)`. If regex `\[[^\]]*\bahead (\d+)` matches, return `(N, true)`. Otherwise return `(0, !h.contains("..."))`, because a branch with no upstream can still push all its commits. | `[ahead 3]` → (3, true); `[ahead 1, behind 2]` → (1, true); `main...origin/main` → (0, false); `[behind 2]` → (0, false); `feature/x` → (0, true) |
|
||
| `parseBehind` | Regex `\[[^\]]*\bbehind (\d+)` → N, otherwise 0. | `[ahead 1, behind 2]` → 2 |
|
||
| `parseUpstream` | If `h` starts with `HEAD `, return nil. If `h` has no `...`, return nil. Otherwise take the text after `...` up to the first space. Return nil when it is empty. | `main...origin/main [gone]` → `origin/main`; `main` → nil |
|
||
|
||
`canPush` is parsed and stored, but no UI reads it.
|
||
|
||
**XY code → rows** (`Porcelain.classify`):
|
||
|
||
1. **Conflict** (`isConflict`): `X == "U"` or `Y == "U"` or `XY == "AA"` or `XY == "DD"`. This gives **one unstaged row with status `U` (unmerged)**, which lands in **changed**, offers only **Stage** (staging marks the resolution; Discard skips it) and is not counted as staged. Neither half can be staged on its own. Its inline diff is HEAD (empty for `AA`) against the disk (empty for `DD`), conflict markers included.
|
||
2. Otherwise:
|
||
- If `X` is not `" "` and not `"?"`, add a **staged** row with `status(X)`.
|
||
- If `Y` is not `" "`, add an **unstaged** row with `status(Y)`.
|
||
- If neither row was added, add one staged row with `status(X)`. This is a fallback that should never fire.
|
||
|
||
**Letter map** (`Porcelain.status(for:)`): `A`, `C`, `?` → **A** (added). `D` → **D** (deleted). `R` → **R** (renamed). Every other letter (`M`, `T`, `U`, …) → **M** (modified).
|
||
|
||
So `??` is one unstaged `A` row. `MM` is a staged M row plus an unstaged M row. `AM` is a staged A row plus an unstaged M row. `MD` is a staged M row plus an unstaged D row. `R ` is one staged R row with `originalPath` set.
|
||
|
||
**Upstream detection for push** (`Porcelain.needsUpstream`): true when stderr matches the regex `no upstream branch|set-upstream`, case-insensitive.
|
||
|
||
---
|
||
|
||
### 3.5 Data models
|
||
|
||
**`GitStatus`** (`GitModels.swift`) is the letter on a row: `A` added, `M` modified, `D` deleted, `R` renamed, `U` unmerged. `U` exists, but the parser never produces it.
|
||
|
||
**`GitFileChange`** is one half of one file, as the loader reads it: `path`, `status`, `staged` (true = HEAD→index half, false = index→disk half), `original` text, `updated` text, `originalPath` (rename/copy source or nil), and `isTooBig` (when true, both texts are empty).
|
||
|
||
**`GitSnapshot`**: `branch`, `ahead`, `canPush`, `behind`, `upstream?`, `changes: [GitFileChange]`.
|
||
|
||
**`Change`** is a row in the view. Its `id` is `"s:" + path` for the staged half and `"w:" + path` for the working-tree half. It also has `path`, `status`, `added`, `removed` (line counts), `isDeleted` (= status is D), `staged` and `originalPath`.
|
||
|
||
**`GitWorkingState`**, derived from one snapshot:
|
||
|
||
| Field | Meaning |
|
||
|---|---|
|
||
| `branch` | The branch name. `"—"` (em dash) when empty or not a repository. |
|
||
| `ahead`, `behind`, `canPush`, `upstream` | Copied from the snapshot. |
|
||
| `changes: [Change]` | The rows, in snapshot order. |
|
||
| `rowDiffs[rowID]` | The diff of that row's own half. It drives the inline diff and the Diff overlay. |
|
||
| `fileDiffs[path]` | The whole-file diff from HEAD to disk. It drives the editor's Actual view. |
|
||
| `stagedPaths` | The paths that have a staged row. |
|
||
| `isRepository` | False when the snapshot is nil. |
|
||
| `totals` | The sum of `added` and the sum of `removed` over **all rows**, so a file with two rows counts twice. Shown in the status bar. |
|
||
| `stagedCount` / `unstagedCount` | The number of staged and unstaged **rows**. |
|
||
| `unstagedPaths` | Distinct paths that have an unstaged row, in row order. |
|
||
|
||
`GitWorkingState.empty` = branch `"—"`, everything 0, empty or nil, `isRepository=false`.
|
||
|
||
---
|
||
|
||
### 3.6 Reading file texts for diffs (`GitService.changes(for:)`)
|
||
|
||
Each status entry gets its rows from `classify`. `both` is true when the entry has a staged row **and** an unstaged row.
|
||
|
||
The text sources:
|
||
- **HEAD blob**: `git show HEAD:<path>` (read path).
|
||
- **Index blob**: `git show :0:<path>`. It is read **only when `both` is true**. With a single row, the index equals HEAD (unstaged only) or the disk (staged only), so this saves one process per file.
|
||
- **Disk**: the file at `<root>/<path>`.
|
||
|
||
| Row | `original` | `updated` | `originalPath` |
|
||
|---|---|---|---|
|
||
| Staged | `""` if the status is A; otherwise the HEAD blob | `""` if the status is D; otherwise the index blob when `both`, else the disk text | the entry's source path |
|
||
| Unstaged | `""` if `X == "?"` (untracked); otherwise the index blob when `both`, else the HEAD blob | `""` if the status is D; otherwise the disk text | the entry's source path **only if there is no staged row**, else nil |
|
||
|
||
Quirk: for a staged rename the HEAD blob is read at the **new** path (`HEAD:<newpath>`), which does not exist. So `original` is `""` and a pure rename shows the whole file as added (+N −0). Reproduce this as it is, or fix it on purpose and say so.
|
||
|
||
**Blob read** (`blob`). If `git show` fails, the text is `""`. If the stdout (decoded as UTF-8) is longer than **maxDiffBytes = 1,000,000** UTF-8 bytes, the side is **tooBig**. If the first **8000 characters** of the decoded stdout hold a NUL, the side is `""` (binary). Otherwise the side is the text.
|
||
|
||
**Disk read** (`diskText`). If the size attribute cannot be read (missing file), the text is `""`. If the size is over 1,000,000 bytes, the side is **tooBig**, and the file is never read into memory. Otherwise read the bytes. If the read fails, or there is a NUL byte in the first 8000 bytes (`FileLimits.looksBinary`), the text is `""`. Otherwise the text is the UTF-8 decode of the bytes, with invalid bytes replaced.
|
||
|
||
**Too big.** If **either** side of a row is tooBig, **both** texts are set to `""` and `isTooBig=true`. A file that grew past the cap also drops its small side.
|
||
|
||
---
|
||
|
||
### 3.7 Derivation (`GitDerivation.derive`)
|
||
|
||
This runs **off the main thread** (a detached task with user-initiated priority), because it diffs every changed file.
|
||
|
||
- `nil` snapshot → `GitWorkingState.empty` ("not a repository").
|
||
- For each `GitFileChange`, in order:
|
||
- `diff = LineDiff.build(original, updated, status)`, and `diff.isTooBig = change.isTooBig`.
|
||
- The row is a `Change` with `added = diff.added` and `removed = diff.removed`. These are line counts, so they are 0/0 when the row is too big or binary.
|
||
- `rowDiffs[row.id] = diff`. The row is appended. Its path is added to `stagedPaths` when the row is staged.
|
||
- The whole-file accumulator per path keeps (head, disk, status, rowCount, firstRowID). The first row of a path sets head = original, disk = updated and status = status. A second **staged** row sets head = its original. A second **unstaged** row sets disk = its updated and status = its status. So **the unstaged row owns the file status**: a file staged as modified but deleted on disk reads as deleted. The order of the rows does not matter.
|
||
- For each path: with one row, `fileDiffs[path]` is that row's diff. With two rows, it is `LineDiff.build(head, disk, status)`. `isTooBig` is set when any row of that path was too big.
|
||
|
||
**LineDiff, in short** (it is shared with the editor's Diff). Lines are split on `\n`. An empty text has zero lines, and one trailing `\n` is dropped (checked on the last UTF-8 byte, so `\r\n` endings keep the `\r` in each line). The diff is an LCS over interned line ids. A common prefix and suffix are stripped first. A region with at most 4,000,000 cells uses a DP table. A tie takes the **deletion before the addition**. A larger region is split on anchor lines (lines that occur exactly once on each side, kept in the longest increasing run). With no anchors, the region is a full replace. `split` rows: an unchanged line is one row with both sides. Between two unchanged lines, the run of removed lines and the run of added lines pair up index by index (`left[k]` with `right[k]`), and the side that runs out is nil. `added` and `removed` are the counts of added and removed lines.
|
||
|
||
---
|
||
|
||
### 3.8 Sections (`GitSections.build`)
|
||
|
||
There are four kinds, always in this order: `staged`, `changed`, `untracked`, `deleted`. A section is returned only when it has rows. Rows keep their order.
|
||
|
||
| Row | Section |
|
||
|---|---|
|
||
| `staged == true` (any status) | **staged** |
|
||
| unstaged, status A | **untracked** ("new · untracked") |
|
||
| unstaged, status D | **deleted** |
|
||
| unstaged, status M, R or U | **changed** |
|
||
|
||
`uniquePaths(rows)` gives the distinct paths, keeping the first occurrence in order.
|
||
|
||
---
|
||
|
||
### 3.9 Inline diff algorithm (`InlineDiff.rows`, context = 3)
|
||
|
||
Input: `diff.split`.
|
||
1. A split row is "changed" when its left or right cell has a mark. If no row is changed, return `[]`. The view then shows `— No line changes.`
|
||
2. Keep every row whose index is within ±3 of a changed row (clamped to the bounds).
|
||
3. Walk the rows. Each run of rows that is not kept becomes one `gap(count)` row, placed where the run was. This includes a leading run and a trailing run. Each kept row becomes `line(left, right)`.
|
||
4. Each cell has `number`, `text`, `mark` (removed/added/nil) and an optional `highlight` range.
|
||
5. **Intra-line highlight**: only when the left mark is `removed` **and** the right mark is `added`. Work on characters (grapheme clusters). The prefix is the length of the common leading run. The suffix is the length of the common trailing run, counted only over the characters after the prefix on both sides, so the two never overlap. If both are 0, there is no highlight. Otherwise left = `prefix ..< (a.count − suffix)` and right = `prefix ..< (b.count − suffix)`. An empty range becomes nil, so an insertion highlights only the side that grew.
|
||
|
||
The view caches the inline rows per row id until the next state change. Any new state clears the cache.
|
||
|
||
---
|
||
|
||
### 3.10 The store (`SourceControlStore`): state and derived values
|
||
|
||
This is one store per window. It lives on the main thread.
|
||
|
||
| State | Meaning |
|
||
|---|---|
|
||
| `state: GitWorkingState` | Setting it also rebuilds `sections` and clears the inline cache. |
|
||
| `hasLoaded` | False until the first read lands. A failed read also sets it true. |
|
||
| `sections` | `GitSections.build(state.changes)`. |
|
||
| `collapsedSections: Set<kind>` | Empty by default, so every section starts open. |
|
||
| `expandedRows: Set<String>` | Keys of the form `"<kind>:<rowID>"`, for example `staged:s:src/a.php`. Every row starts closed. |
|
||
| `commitMessage` | Always normalised (3.13). |
|
||
| `author?` | `user.name <user.email>`, read when the view opens. |
|
||
| `branches: GitBranchList` | |
|
||
| `busy: push / pull / nil` | |
|
||
| `lines: [GitConsoleEntry]` | Console lines, each with an increasing int id. |
|
||
| `consoleInput`, `history: [String]` | |
|
||
| `config: HelderConfig.Git` | `confirmDiscard` (default true), `refreshInterval` ms (default 10000), `defaultDiffMode` (default `updated`, used by the editor). Changing `refreshInterval` while polling restarts the poll. |
|
||
|
||
Constants: `maxConsoleLines = 400`, `remoteTimeout = 120` s.
|
||
|
||
Derived values:
|
||
- `fileStatuses[path]` is the Explorer letter. The **unstaged row wins** when a path has both rows.
|
||
- `isDirty = !changes.isEmpty` (any row, staged or not). It locks branch switching.
|
||
- `changedPathCount` is the number of distinct paths.
|
||
- `stagedPathCount` is the number of distinct staged paths.
|
||
- `canCommitNow = stagedPathCount > 0 && commitMessage trimmed of spaces and tabs is not empty`. It only sets the "ready" look of the button.
|
||
- `syncLabel` (`GitConsoleText.syncLabel`). With no upstream it is `no upstream`. Otherwise `remote` is the upstream text up to the first `/`:
|
||
- ahead>0 and behind>0 → `"<a> ahead · <b> behind <remote>"`
|
||
- behind only → `"<b> behind <remote>"`
|
||
- ahead only → `"<a> ahead of <remote>"`
|
||
- neither → `"in sync with <remote>"`
|
||
|
||
**Badges outside the view:**
|
||
- Title bar toggle: `Git N`, where N is the number of **distinct changed paths**. It reads `Git` when N is 0. Its key hint is `⌘G`. Its tooltip is "Git view: **open**. Click to close it (⌘G)." or "Git view: **closed**. Click to open it (⌘G)." The dot of the toggle lights while the view is open.
|
||
- Status bar (while the view is closed): `⑂ <branch>` in amber, `+<totals.added>`, `−<totals.removed>`, then `<stagedCount> staged · <unstagedCount> unstaged` (row counts).
|
||
- Explorer: the status letter per file from `fileStatuses`. Search and Recent files show a dot on each path in `Set(changes.map(path))`.
|
||
|
||
---
|
||
|
||
### 3.11 Command serialisation, logging and refresh after a command
|
||
|
||
**Serialisation** (`run` with `commandTail`). Every console-path command, from a button or typed, is chained after the one before it. The new task first awaits the previous tail and then runs. The tail is replaced by a task that awaits the new command. So commands run strictly one at a time, in the order they were queued, and never race for `.git/index.lock`. The status read is **not** part of this chain.
|
||
|
||
**`runNow(arguments, literalPathspecs, timeout)`**:
|
||
1. Log the echo line, kind `command`: `GitConsoleText.commandLine(args)` = `"$ git"` followed by each argument, joined by single spaces. An argument is quoted only when it is empty or holds whitespace, `"` or `'`. The quoted form is `"` + the argument with each `"` replaced by `\"` + `"`. Examples:
|
||
- `["commit","-m","fix the bar"]` → `$ git commit -m "fix the bar"`
|
||
- `["commit","-m","say \"hi\""]` → `$ git commit -m "say \"hi\""`
|
||
- `["commit","-m","it's"]` → `$ git commit -m "it's"`
|
||
- `["commit","-m",""]` → `$ git commit -m ""`
|
||
- `["add","--","pages/[id].vue"]` → `$ git add -- pages/[id].vue`
|
||
2. Make **one `GitOutputClassifier` per run** (it keeps state across lines). Each streamed line is classified and logged in arrival order. All lines are logged before `runNow` returns.
|
||
3. Return the `GitCommandResult`.
|
||
|
||
**`log(text, kind)`** appends an entry. When the count goes over 400, the oldest entries are dropped so the newest 400 remain.
|
||
|
||
**`afterCommand()`** = `refresh()` and then `reloadBranches()`. Every action runs it when its command (or commands) end, whether they succeeded or failed.
|
||
|
||
**Failure detail for a toast** (`failureDetail`). Take the stderr lines, then the stdout lines (split on newlines, empty lines dropped), and classify them with a fresh classifier. Trim leading and trailing spaces and tabs, and drop lines that are empty after the trim. The detail is the **first line of kind `error`**. Failing that, it is the **last line that is not a `hint`**. Failing that, it is nil. Example: ` ! [rejected] main -> main (non-fast-forward)` gives `! [rejected] main -> main (non-fast-forward)`.
|
||
|
||
---
|
||
|
||
### 3.12 Every git command the app runs
|
||
|
||
| When | Exact argv after `git` | Path | Env extras | Timeout | Logged in the console? |
|
||
|---|---|---|---|---|---|
|
||
| Every load: repository probe | `rev-parse --is-inside-work-tree` | read | LITERAL=1 | – | no |
|
||
| Every load: status | `status --porcelain -b --untracked-files=all -z` | read | LITERAL=1, `GIT_OPTIONAL_LOCKS=0` | – (6 tries, 0.12 s apart) | no |
|
||
| Every load: blobs | `show HEAD:<path>`, `show :0:<path>` | read | LITERAL=1 | – | no |
|
||
| After every command, and when the view opens | `for-each-ref --format=%(refname) refs/heads refs/remotes/origin` | read | LITERAL=1 | – | no |
|
||
| When the view opens | `config --get user.name`, `config --get user.email` | read | LITERAL=1 | – | no |
|
||
| When the view opens, if an origin is known | `fetch origin` | console | console env, LITERAL=1 | 120 s | yes |
|
||
| Stage (row or bulk) | `add -- <path…>` | console | LITERAL=1 | none | yes |
|
||
| Unstage, all staged paths | `restore --staged .` | console | LITERAL=1 | none | yes |
|
||
| Unstage, some paths | `restore --staged -- <paths…> <rename sources…>` | console | LITERAL=1 | none | yes |
|
||
| Unstage fallback (no HEAD) | `rm --cached -r .` or `rm --cached -r -- <paths…>` | console | LITERAL=1 | none | yes |
|
||
| Discard tracked / Restore | `restore -- <paths…>` | console | LITERAL=1 | none | yes |
|
||
| Delete untracked | `clean -f -- <paths…>` | console | LITERAL=1 | none | yes |
|
||
| Commit | `commit -m <message>` (the message may be empty) | console | LITERAL=1 | none | yes |
|
||
| Push | `push`, then on "no upstream" `push -u origin <branch>` | console | LITERAL=1 | 120 s each | yes |
|
||
| Pull | `pull --no-rebase` | console | LITERAL=1 | 120 s | yes |
|
||
| Branch switch | `switch <localName>` | console | LITERAL=1 | none | yes |
|
||
| Console bare `log` | `log --oneline --decorate -n 30` | console | **no** LITERAL | 120 s | yes |
|
||
| Console, anything else | the typed argv | console | **no** LITERAL | 120 s | yes |
|
||
| Watcher (outside this section) | `check-ignore -- <paths…>` | runner | inherited | – | no |
|
||
|
||
The app never runs `add -A`. Even "Stage all" lists the exact paths, so files the view has not shown yet are never taken.
|
||
|
||
---
|
||
|
||
### 3.13 Actions in detail
|
||
|
||
**Stage(paths)**. Do nothing when `paths` is empty. Otherwise run `add -- paths`, then `afterCommand`. It never asks.
|
||
|
||
**Unstage(paths)**. Do nothing when `paths` is empty.
|
||
- `all` is true when `Set(paths) == Set(uniquePaths(all staged rows))`.
|
||
- `sources` are the `originalPath` of each staged row with status R whose path is in `paths`. Sources already in `paths` are left out.
|
||
- pathspec = `["."]` when `all`, else `["--"] + paths + sources`. A staged rename takes its source along, otherwise the old path stays staged as deleted.
|
||
- Run `restore --staged <pathspec>`. If it fails **and stderr contains `HEAD`** (a repository without commits), run `rm --cached -r <pathspec>`.
|
||
- Then `afterCommand`. It never asks.
|
||
|
||
**Discard(paths)** (the `gitDiscard` context action; also used for Delete and Restore).
|
||
1. Drop the paths whose unstaged row status is `U`. This is dead code in practice, because U is never produced.
|
||
2. If nothing is left, stop.
|
||
3. `fresh` = paths whose unstaged status is `A` (untracked). `tracked` = the rest.
|
||
4. If `tracked` is not empty: `restore -- tracked`. Modified files go back to the index (the staged version, else HEAD). Deleted files come back.
|
||
5. If `fresh` is not empty: `clean -f -- fresh`. Git prints `Removing <path>` per file.
|
||
6. `afterCommand`. The model then reloads from disk each of these paths that the editor has loaded.
|
||
|
||
**Confirmation for discard** (`confirmation(for:)`). This is called by the model before any context action runs.
|
||
- It returns nil (run at once) when the action is not `gitDiscard`, or when `config.confirmDiscard` is false, or when `paths` is empty, or when **every** path's unstaged status is D (Restore never asks).
|
||
- Otherwise:
|
||
- `what` = the path when there is one path, else `"<N> files"`.
|
||
- `allNew` is true when every unstaged status is A. `hasNew` is true when any is A.
|
||
- Title: `Delete <what>?` when allNew, else `Discard changes to <what>?`
|
||
- Body: `New files are removed from disk. This cannot be undone.` when hasNew, else `This reverts to the last commit and cannot be undone.`
|
||
- Confirm button: `Delete` when allNew, else `Discard`.
|
||
- The model shows a confirm overlay. Enter or the confirm button runs the action. Esc cancels. The action is marked destructive.
|
||
|
||
**Commit(andPush)**.
|
||
1. `message` = `commitMessage` trimmed of spaces and tabs. `count` = `stagedPathCount`, taken **before** the commit runs.
|
||
2. **Always** run `commit -m <message>`, even when nothing is staged or the message is empty. Git's own refusal is the error the user sees. Typical git output: `no changes added to commit (use "git add" and/or "git commit -a")`, `nothing to commit, working tree clean`, `Aborting commit due to empty commit message.`
|
||
3. `afterCommand`.
|
||
4. On failure: toast `Commit failed`, detail = failureDetail. If the message was empty, ask focus for the message field. **The message stays.** Stop. No push happens.
|
||
5. On success: clear `commitMessage` only if its trimmed value still equals the message that was committed (the user may have typed during the commit). Toast `Committed <count> file` / `files` (singular when count is 1). The detail is the message cut to 34 characters plus `…` when it is longer than 34.
|
||
6. If `andPush`, run `push()` (below). Push ignores the call when a push or pull is already busy.
|
||
|
||
Commit does not check `busy`.
|
||
|
||
**Push**.
|
||
1. If `busy != nil`, return without doing anything.
|
||
2. `busy = push`. Take `branch` and `ahead` from the current state.
|
||
3. Run `push` (timeout 120).
|
||
4. If it failed **and** `needsUpstream(stderr)` **and** branch is not `HEAD` and not `—`, run `push -u origin <branch>` (timeout 120). This becomes the result.
|
||
5. `busy = nil`. `afterCommand`.
|
||
6. On failure: toast `Push failed`, detail = failureDetail of the last run.
|
||
7. On success: toast `Pushed <ahead> commit to origin/<branch>` / `commits`. When `ahead` is 0 the count is left out: `Pushed to origin/<branch>`. The remote name is always the literal `origin/`, whatever the real upstream is.
|
||
|
||
**Pull**.
|
||
1. If `busy != nil`, return.
|
||
2. `busy = pull`. Take `branch` and `behind`.
|
||
3. Run `pull --no-rebase` (timeout 120). This merges diverged branches, where a bare `pull` without `pull.rebase` set would refuse.
|
||
4. `busy = nil`. `afterCommand`.
|
||
5. On failure: toast `Pull failed` plus the detail.
|
||
6. On success:
|
||
- If `behind > 0`: toast `Pulled <behind> commit from origin/<branch>` / `commits`.
|
||
- Else, if stdout does **not** contain `Already up to date`: toast `Pulled from origin/<branch>`.
|
||
- Else: **no toast**.
|
||
7. The model then also schedules a refresh of the tree and the open files.
|
||
|
||
**Fetch when the view opens** (`viewOpened`).
|
||
1. `author = await git.author()` → `"<name> <<email>>"`. With no email it is the name alone. With no name (or an empty value) it is nil.
|
||
2. `reloadBranches()`.
|
||
3. `loadIfNeeded()`, which refreshes only when `hasLoaded` is false.
|
||
4. Stop here if a fetch is already running, or the state is not a repository, or there is no origin. "Origin" means the remote branch list is not empty **or** the upstream starts with `origin/`.
|
||
5. Set the fetching flag. Run `fetch origin` (timeout 120). `afterCommand`. Clear the flag.
|
||
|
||
**Switch branch (name, remote)**.
|
||
1. If `isDirty`: toast `— Commit or discard <N> file before you switch.` / `files` (N = distinct changed paths) and return false. **Git is not run.**
|
||
2. `local` = `name` for a local branch. For a remote branch it is the name with everything up to and including the **first** `/` removed (`origin/feature/a` → `feature/a`).
|
||
3. If `local == state.branch`, return false silently.
|
||
4. Run `switch <local>`. For a remote branch with no local branch, git's DWIM creates a local tracking branch. `afterCommand`.
|
||
5. On failure: return false. There is no toast, and the console shows git's error.
|
||
6. On success: clear `expandedRows`, toast `Switched to <local>`, return true. The model then schedules a refresh of the tree and the open files.
|
||
|
||
**Refresh** (`refresh()`).
|
||
1. Increment a generation counter.
|
||
2. `git.load()`.
|
||
3. On a throw: if this is still the newest generation, make the message `status failed: <error description>`, log a warning, and append it to the console as kind `error`, **only if it differs from the last logged status error**. A poll that keeps failing logs it once. Set `hasLoaded = true`. The old state stays.
|
||
4. On success: if still the newest generation, clear the remembered error, run `derive` off the main thread, check the generation again, then set `state` and `hasLoaded = true`. A result that a newer refresh overtook is dropped.
|
||
|
||
---
|
||
|
||
### 3.14 Refresh triggers and polling
|
||
|
||
| Trigger | What runs |
|
||
|---|---|
|
||
| Project load | After the config: git refresh, tree and clean-copy baseline, in parallel. Then the editor restore, the watcher, `startPolling()`, and the symbols. |
|
||
| Watcher **git** event (an entry from 3.2 changed) | The watcher debounces for **0.2 s**, then the model's `scheduleRefresh(.git)`. |
|
||
| Watcher **project** event (any file in the root, not ignored) | The watcher debounces for **0.25 s**, then `scheduleRefresh([.git, .tree, .symbols, .openFiles])`. |
|
||
| `scheduleRefresh` | Scopes gather into a pending set. One task sleeps for **100 ms** (`refreshDebounce`), runs the gathered scopes (git refresh, tree reload and open-file reload in parallel), then starts again if more were added meanwhile. |
|
||
| File saved in the editor | `scheduleRefresh(.git)` |
|
||
| Git view opens | `scheduleRefresh(.git)` and `viewOpened()` |
|
||
| ⌘R / View › Refresh | Runs `[.git, .tree]` at once, with no debounce. The open file reloads from disk (disk wins). |
|
||
| After each store command | `refresh()` + `reloadBranches()` |
|
||
| After pull, a successful branch switch, or a console command | Also `scheduleRefresh([.tree, .openFiles])` |
|
||
| Explorer delete, new file, new folder, rename | `sourceControl.refresh()` |
|
||
| **Polling** | Every `git.refreshInterval` ms (default **10000**). The loop sleeps first, then refreshes, until cancelled. `0` disables it. A change to the interval while polling restarts the loop. It stops when the project closes. It is a backstop for a missed watcher event. |
|
||
|
||
---
|
||
|
||
### 3.15 The console
|
||
|
||
**Typed input** (`submitConsoleInput`).
|
||
1. `typed` = the input trimmed of spaces and tabs. Clear the input and reset the history cursor.
|
||
2. `parseInput(typed)`. If it returns nil, stop: there is no run and nothing is added to the history.
|
||
3. Append `typed` to the history. Every submission is kept, duplicates and `clear` included.
|
||
4. If the arguments are exactly `["clear"]`, empty the log and stop.
|
||
5. If the arguments are exactly `["log"]`, run `log --oneline --decorate -n 30`. Otherwise run the arguments as typed.
|
||
6. The run uses `literalPathspecs=false` and timeout 120. Then `afterCommand`. The model also schedules tree and open-file refreshes.
|
||
|
||
**`parseInput`** splits like a shell:
|
||
- Outside quotes, whitespace separates tokens.
|
||
- `'…'` is literal. A backslash inside single quotes is literal too.
|
||
- `"…"`: `\"` → `"` and `\\` → `\`. Any other `\x` keeps both the backslash and `x` (`"a\nb"` → `a\nb`).
|
||
- Outside quotes, `\x` → `x` (`my\ file.txt` → `my file.txt`).
|
||
- A quote pair always makes a token, so `""` gives an empty argument.
|
||
- An unclosed quote ends at the end of the input. A trailing lone backslash is kept as `\`.
|
||
- A first token `git` is removed.
|
||
- If no tokens are left, the result is nil (`""`, `" "`, `"git"`, `" git "`).
|
||
- Examples: `log --format='%h %s'` → `["log","--format=%h %s"]`; `commit -m 'it is "fine"'` → `["commit","-m","it is \"fine\""]`.
|
||
|
||
**History** (`recallPreviousInput`, ↑ in the input). When the history is empty, nothing happens. Otherwise cursor = max(0, (cursor ?? history.count) − 1), and the input is set to `history[cursor]`. It steps back from the newest entry and stops at the oldest. **There is no ↓ handling.** Typing does not reset the cursor. Only a submit resets it.
|
||
|
||
**Line classifier** (`GitOutputClassifier`). There is one per run. Its `subcommand` is the first argument that does not start with `-`, where `-c` and `-C` skip their value (`["-c","color.ui=never","status"]` → `status`). For each line (the `isError` flag is **ignored**, because git writes progress to stderr):
|
||
1. Let `trimmed` be the line with leading spaces and tabs removed.
|
||
2. `trimmed` starts with `hint:` → **hint**.
|
||
3. `trimmed` starts with any of `error:`, `fatal:`, `! [rejected]`, `! [remote rejected]`, `Aborting`, `Please commit your changes` → **error**.
|
||
4. Subcommand `push`: when `trimmed` contains ` -> ` and fully matches the regex
|
||
`(?:\+\s*)?(?:[0-9a-f]+\.\.\.?[0-9a-f]+|\*\s+\[new [a-z ]+\])\s+.+ -> .+` → **success**. Examples: `a1b2c3d..e4f5a6b main -> main`, `* [new branch] feature/x -> feature/x`, `+ a1b2c3d...e4f5a6b main -> main (forced update)`.
|
||
5. Subcommand `status`: when `trimmed` is exactly one of these headers, set the section and return **output**:
|
||
- `Changes to be committed:` → staged
|
||
- `Changes not staged for commit:` → unstaged
|
||
- `Untracked files:` → unstaged
|
||
- `Unmerged paths:` → other
|
||
|
||
A line that **starts with a tab** (checked on the raw line) is **staged** in the staged section and **unstaged** in the unstaged section.
|
||
6. Anything else → **output**.
|
||
|
||
A ref update outside `push` (in `fetch`, for example) is output. Tab lines outside `status` are output. The timeout line `timed out after 120s` and `git not found` classify as **output**, not as error.
|
||
|
||
**Colours per kind** (`Palette.console`):
|
||
|
||
| Kind | Colour |
|
||
|---|---|
|
||
| command (`$ git …`) | `#F4F5F4` |
|
||
| output | `#BAC0C0` |
|
||
| error | `#E8913A` (amber) |
|
||
| hint | `#828D9A` |
|
||
| staged | `#8FBFB4` (teal) |
|
||
| success | `#8FBFB4` (teal) |
|
||
| unstaged | `#F0B476` (amber-soft) |
|
||
|
||
---
|
||
|
||
### 3.16 Commit message normalisation and the field
|
||
|
||
`normalizeCommitMessage(v)` = `v.lowercased()` (Unicode-aware), then each match of the regex `[ \t]*[\r\n]+[ \t]*` is replaced with **one space**. It runs on every text change in the field (typing and pasting) and in `setCommitMessage`. When the normalised text differs from the field text, the field text is replaced and the caret goes to min(old caret location, new length). So Enter (a newline) turns into a space: Enter never starts a new line and never commits. Dictation tools capitalise and add line breaks, and this keeps the message one lowercase line. Example: `"Fix The Bug\n And The Test"` → `"fix the bug and the test"`.
|
||
|
||
The draft lives in the store, so it survives closing the view. It does not survive a project switch, because the store is rebuilt.
|
||
|
||
**Message field** (`GitMessageField`):
|
||
- A plain-text multi-line editor in IBM Plex Mono 400, 14 pt, fixed line height 22.4.
|
||
- Text colour `#F4F5F4`, caret `#E8913A`.
|
||
- Undo on. Smart quotes, smart dashes, autocorrect and spell check are off.
|
||
- Insets: 16 pt horizontal and 14 pt vertical (the AppKit line-fragment padding is removed from the horizontal inset).
|
||
- Placeholder `Commit message` in `#6C7783`, drawn at the inset while the text is empty.
|
||
- Vertical scroller that hides itself.
|
||
- **Height** = ceil(wrapped text height at width − 32, + 28), clamped to **56…180 pt**. An empty field or one line is 56. About 7 lines reach 180, after which the field scrolls.
|
||
- Background `#101720`. A 1 pt bottom line is `#232C39`, and it turns `#E8913A` while the field has focus, with a 160 ms colour transition.
|
||
- Focus: each new focus request (when the view opens, when ⌘C asks for it, or after a commit failed with an empty message) makes the field first responder **one run loop later**, with the caret at the end. When the view opens, the window first clears its first responder, so typing never lands in a covered terminal.
|
||
|
||
---
|
||
|
||
### 3.17 Branch list
|
||
|
||
`for-each-ref --format=%(refname) refs/heads refs/remotes/origin` reads one ref per line, with whitespace trimmed:
|
||
- `refs/heads/X` → local `X`.
|
||
- `refs/remotes/origin/Y` → remote `origin/Y`. `origin/HEAD` is skipped.
|
||
- Both lists are sorted (plain string sort).
|
||
- If the command fails (for example outside a repository), both lists are empty.
|
||
|
||
`isTracked(remote)` is true when `localName(remote)` is in the local list. `localName` drops everything up to and including the first `/`.
|
||
|
||
Only the remote named **origin** is listed.
|
||
|
||
---
|
||
|
||
### 3.18 The Git view: layout and every string
|
||
|
||
**Opening and closing.**
|
||
- ⌘G, the title-bar `Git N` toggle and the View menu (`Show Git` / `Hide Git`, ⌘G) toggle the view. ⌘C with no text selected, outside a terminal and outside an editor line selection, opens the view (or only refocuses the field) on the commit message.
|
||
- Opening sets `isGitViewOpen`, schedules a git refresh, runs `viewOpened()` and requests focus on the message field. If the view is already open, it only refocuses the field.
|
||
- Esc (with no overlay open and no ⌘), ⌘G and the Close button close it. On close, focus goes back to the column that was active. If that column is the editor, its text view gets focus. With no active column, nothing gets focus.
|
||
- The view is never persisted. A project always opens with it closed, and a project switch closes it.
|
||
- The view covers the whole window: title bar, columns and status bar. The columns stay mounted under it, so the terminals keep running. Overlays and toasts draw above it: context menus, the confirm dialog, search, the Diff, toasts.
|
||
- The background is `#101720`. The view is a vertical stack: top bar (44) / commit block (auto height) / sections list (fills the rest) / bottom strip (230).
|
||
|
||
**Top bar** (`GitTopBar`). Height 44, horizontal padding 14, item gap 14, background `#18202B`, 1 pt bottom hairline `#232C39`. From left to right:
|
||
1. `[ git ]`: Plex Mono 700, 11 pt, tracking 0.14 em, **uppercase**, so it renders `[ GIT ]`. Colour `#828D9A`.
|
||
2. Branch: the git-branch icon (13 pt), a 6 pt gap, then the branch name in Plex Mono 500, 12 pt, one line, cut at the tail. Both in amber `#E8913A`.
|
||
3. Sync label (3.10) in Plex Mono 400, 12 pt, `#828D9A`.
|
||
4. A spacer.
|
||
5. Three buttons, 28 pt tall each:
|
||
- Horizontal padding 11, icon 14 pt, gap 7.
|
||
- Label in Plex Sans 500, 12 pt, colour `#BAC0C0` (hover `#F4F5F4`).
|
||
- 1 pt border `#232C39` (hover `#3A424C`), radius 2, transparent fill.
|
||
- An optional trailing text in Plex Mono 600, 11 pt, amber.
|
||
|
||
| Button | Icon | Label | Trailing text | Command |
|
||
|---|---|---|---|---|
|
||
| Pull | arrow-down-to-line | `Pull`, or `Pulling…` while a pull is busy | `↓N` when behind > 0 | pull |
|
||
| Push | arrow-up-from-line | `Push`, or `Pushing…` while a push is busy | `↑N` when ahead > 0 | push |
|
||
| Close | minimize-2 | `Close` | `⌘G` | close the view |
|
||
|
||
The buttons are never disabled. A second pull or push is ignored in the store.
|
||
|
||
**Commit block** (`GitCommitBlock`). Background `#18202B`, 1 pt bottom hairline.
|
||
1. The message field (3.16).
|
||
2. The footer row: height 52, padding 16 left and 14 right, gap 16.
|
||
- The author (only when it is known), Plex Mono 12, `#828D9A`, one line.
|
||
- `⌘↵ commits`, Plex Mono 12, `#6C7783`.
|
||
- A spacer.
|
||
- The **split button**: radius 2 (clipped), fixed size.
|
||
- **Main part.** Label `Commit <N> file` / `files`, where N = `stagedPathCount`, or `Nothing staged` when N is 0. Plex Sans 600, 13 pt, horizontal padding 18, minimum width 160, height 32.
|
||
- **Ready** (`canCommitNow`): fill `#E8913A`, hover `#C4741F`, text `#101720`.
|
||
- **Idle**: fill `#232C39`, hover `#202834`, text `#828D9A`.
|
||
- A click always runs `commit` (without push).
|
||
- **Caret part.** 32×32, chevron-down icon at 14 pt, the same fill rules, with a 1 pt `#101720` line on its left edge. A click opens the **commit menu**, a context menu 320 pt wide anchored at (caret right edge − 320, caret bottom + 4), with no header. Its two items:
|
||
- `Commit` (icon: checkmark) runs commit.
|
||
- `Commit and push` (**bold**, icon: arrow-up-to-line) runs commit and push.
|
||
|
||
**Sections list** (`GitSectionsList`). A lazy vertical scroll list with 24 pt bottom padding. The rows and the inline diff lines are one flat list, so a long expanded file builds only the lines on screen.
|
||
- **Empty states**, in Plex Sans 400, 13/20.8, `#828D9A`, padding 16 horizontal and 24 vertical:
|
||
- Loaded but not a repository → `— Not a git repository.`
|
||
- Loaded, a repository, no sections → `— No changes. The working tree is clean.`
|
||
- Not loaded yet → nothing.
|
||
- When the first section is `staged`, the **second** section's header gets 28 pt top spacing and a 1 pt hairline at its top.
|
||
|
||
**Section styles:**
|
||
|
||
| Kind | Label (rendered uppercase) | Colour | Header tint | Bulk actions (left · right) | Row actions (left · right) |
|
||
|---|---|---|---|---|---|
|
||
| staged | `staged` | `#E8913A` | `rgba(232,145,58,.08)` | (blank) · `Unstage all` | (blank) · `Unstage` |
|
||
| changed | `changed` | `#F0B476` | `rgba(240,180,118,.06)` | `Discard all` · `Stage all` | `Discard` · `Stage` |
|
||
| untracked | `new · untracked` | `#8FBFB4` | `rgba(143,191,180,.06)` | `Delete all` · `Stage all` | `Delete` · `Stage` |
|
||
| deleted | `deleted` | `#C3A6CE` | `rgba(195,166,206,.06)` | `Restore all` · `Stage all` | `Restore` · `Stage` |
|
||
|
||
Action commands:
|
||
- Stage → `stage(uniquePaths)`.
|
||
- Unstage → `unstage(uniquePaths)`.
|
||
- Discard, Delete and Restore → the context action `gitDiscard(paths)`, which goes through the confirmation (3.13).
|
||
- For **changed**, Discard uses only the non-`U` paths. When no such path is left, only Stage is shown.
|
||
- Bulk actions use the unique paths of all rows in the section.
|
||
- Destructive (amber-soft text): Discard and Delete. Restore is not destructive.
|
||
|
||
**Section header.**
|
||
- Height 46, padding 14 on both sides, gap 10.
|
||
- Background: the tint, or `#18202B` on hover.
|
||
- A 3 pt bar in the section colour on the left edge, overlaid. A 1 pt bottom hairline.
|
||
- From left to right:
|
||
- Chevron at 14 pt: down and amber when open, right and `#6C7783` when collapsed.
|
||
- The label in Plex Mono 700, 11 pt, 0.14 em, uppercase, in the section colour.
|
||
- A count badge: the number of **rows** in the section (not distinct paths). Plex Mono 600, 11 pt, `#101720` on the section colour, padding 6×3, radius 2.
|
||
- A spacer, then the actions table.
|
||
- A click anywhere except a button toggles the collapse. The pointer is a hand.
|
||
|
||
**Actions table.** Two 100 pt columns with a 6 pt gap, the same in headers and rows, so the buttons line up as columns. With fewer than 2 actions, a 100 pt blank spacer fills the left column, so a lone action is always in the right column.
|
||
- Header button: 100×28. Border `#3A424C`, hover `#6C7783`.
|
||
- Row button: 100×26. Border transparent, hover `#3A424C`.
|
||
- Both: hover fill `#232C39`, radius 2, Plex Sans 500, 12 pt.
|
||
- Text colour: a row button under the pointer is `#F4F5F4`. Otherwise destructive text is `#F0B476` and other text is `#BAC0C0`. A header button keeps its text colour on hover.
|
||
- A button click never toggles the row or the section.
|
||
|
||
**File row.**
|
||
- Height 36, horizontal padding 14, gap 10. 1 pt bottom hairline.
|
||
- Background `#18202B` when expanded, `#1F2834` on hover, otherwise transparent.
|
||
- A 3 pt amber bar on the left edge for rows in the staged section only.
|
||
- From left to right:
|
||
1. Chevron at 13 pt: down and amber when expanded, right and `#6C7783` otherwise.
|
||
2. Status badge: 18×18, radius 2. The letter is in Plex Mono 700, 11 pt, `#101720`. Fill: A `#8FBFB4`, D `#C3A6CE`, M/R `#F0B476`, U `#E5534B` (`gitConflict`). Tooltip: `New file`, `Deleted`, `Modified`, `Renamed`, `Merge conflict`. A `U` row also shows a 13-pt red flag icon (pennant: pole (5,22)→(5,3), triangle (5,4)→(19,9)→(5,14) on the 24-unit icon grid) 8 pt after the path, tooltip `Merge conflict — resolve, then Stage`, no pointing hand of its own; the row's left accent bar is `#E5534B` and its idle fill `gitConflictTint` (`#E5534B` at 0.08); hover and expanded fills win over that tint.
|
||
3. The path, Plex Mono 400, 13 pt, one line, cut at the tail, filling the free width. The directory plus `/` is `#828D9A`. The file name is `#F4F5F4`. A deleted row draws the name in `#828D9A` and strikes the whole path through in `#828D9A`.
|
||
4. Stats in Plex Mono 500, 12 pt: `+N` in `#8FBFB4`, right-aligned in a 52 pt cell. Then `−N` (real minus sign U+2212) in `#F0B476`, right-aligned in a 44 pt cell plus 8 pt trailing padding.
|
||
5. The actions table.
|
||
- A click toggles the inline diff. The pointer is a hand.
|
||
- A right-click opens the context menu at the click point (see below).
|
||
|
||
**Expanded row content**, in order:
|
||
1. An 8 pt blank row.
|
||
2. One of:
|
||
- When the row is too big: the note `Too big.`
|
||
- When there are no inline rows: `— No line changes.` This covers binary files, mode-only changes and identical texts.
|
||
- Otherwise the inline diff rows.
|
||
|
||
Notes are in Plex Mono 11, `#6C7783`, with 64 pt leading padding and a minimum height of 22.
|
||
3. A 12 pt blank row with a bottom hairline.
|
||
|
||
**Inline diff line.**
|
||
- Two equal cells side by side with a 1 pt vertical hairline between them. Left is the old side (HEAD, or the index for an unstaged half of a staged file). Right is the new side. Each line grows vertically to fit the wrapped text.
|
||
- **Cell**: a line-number column 40 pt wide, right-aligned, with 12 pt trailing padding (52 pt in total). Then the code in `#E4E7E6` with 16 pt trailing padding. Plex Mono 13, line height 22. A vertical padding centres one line in its 22 pt box. Tabs are drawn as 4 spaces. The text wraps.
|
||
- **Fill**: a missing cell (the filler side) is `rgba(35,44,57,.35)`. Removed is `rgba(232,145,58,.12)`. Added is `rgba(143,191,180,.12)`. Unchanged is transparent.
|
||
- **Number colour**: removed `#F0B476`, added `#8FBFB4`, unchanged `#3A424C`.
|
||
- **Highlight**: the differing middle of a paired line gets a background of `rgba(232,145,58,.38)` on the left and `rgba(143,191,180,.36)` on the right. The highlight is applied only when its range fits the text.
|
||
- **Gap row**: `⋯ N unchanged line` / `lines` in Plex Mono 11, `#6C7783`, with 64 pt leading padding. Height 28, background `#18202B`, and 6 pt margin above and below.
|
||
|
||
**Row context menu** (target `gitRow(path, isDeleted)`). The header line is the path. The items:
|
||
- `Open in editor` (bold, doc icon) followed by a separator. These two are **left out when the row is deleted** (status D, staged or not). It closes the view and opens the file.
|
||
- `Pass on reference` (spark icon). It closes the view and opens the pass-on prompt with the path.
|
||
- `Copy reference` (copy icon). It copies the path and shows the toast `Copied reference` with the path as detail.
|
||
|
||
**Bottom strip.** Height 230, background `#18202B`, 1 pt top hairline. It holds two equal halves with a 1 pt vertical hairline between them: the console on the left and the branches on the right.
|
||
|
||
**Console panel** (`GitConsolePanel`).
|
||
- **Header**: height 32, padding 16 left and 12 right, gap 12.
|
||
- `[ console ] git` in Plex Mono 700, 10 pt, 0.14 em, uppercase, `#6C7783`.
|
||
- While busy: `→ pushing to origin…` or `→ pulling from origin…` in Plex Mono 12, amber.
|
||
- A spacer.
|
||
- The eraser button: 14 pt icon with 4 pt padding, `#828D9A` (hover `#F4F5F4`). Tooltip `Clear`. It empties the log without running git.
|
||
- A click on the header focuses the input.
|
||
- **Body** (horizontal padding 16):
|
||
- **The log.** A read-only, selectable text view. Each line is one paragraph in its kind's colour. Plex Mono 400, 12 pt, fixed line height 19.2. It wraps at characters. A tab is 4 space widths. Glyphs are centred in the line height. The selection background is `#3A424C`. The log takes the height its lines need, up to the free space, and then scrolls. It scrolls to the newest line on every change and on every resize. A click that leaves no selection focuses the input.
|
||
- **The input row**, directly under the last log line, 19.2 tall. A `$ git` prompt in Plex Mono 12, `#8FBFB4`, an 8 pt gap, then a borderless single-line field (scrolls horizontally, no wrap) in Plex Mono 12, `#F4F5F4`, with an amber caret. Placeholder: `status · add -A · commit -m "…" · push · pull · log` in `#6C7783`. ↵ submits. ↑ recalls. The field never takes focus on its own.
|
||
- A blank area that fills the rest (minimum 12 pt). A click there focuses the input.
|
||
|
||
**Branches panel** (`GitBranchesPanel`).
|
||
- **Header**: height 32, padding 16, gap 12.
|
||
- `[ branches ]` in the same label style as the console header.
|
||
- A spacer.
|
||
- When dirty: `— N uncommitted file · switching locked` / `files`, in `#F0B476`. When clean: `clean · click to switch`, in `#828D9A`. Plex Mono 12, one line.
|
||
- **List**: scrolls with overlay scrollers, so the rows keep their 16 pt right padding. Bottom padding 12. The group labels `local` and `remote · origin` (rendered uppercase) are in Plex Mono 700, 10 pt, 0.14 em, `#6C7783`, padding 8 top, 4 bottom, 16 horizontal. Both group labels show even when their list is empty.
|
||
- **Branch row**: height 28, padding 16 on both sides, gap 10. A 3 pt left bar, amber for the current branch.
|
||
- Background: `#232C39` on hover. The current branch has `rgba(232,145,58,.08)`.
|
||
- Icon at 13 pt: git-branch for local, cloud for remote. Amber for the current branch, else `#6C7783`.
|
||
- Name, cut at the tail. The current branch is Plex Mono 600, 12 pt, `#F4F5F4`. Others are Plex Mono 400, 12 pt, `#BAC0C0`.
|
||
- Meta text in Plex Mono 11, `#6C7783`.
|
||
- Action text in Plex Mono 600, 11 pt, amber.
|
||
- **Row state rules:**
|
||
- `current` = local, and the name equals `state.branch`.
|
||
- `tracked` = remote, and `isTracked`.
|
||
- `isCurrentUpstream` = remote, and `localName == state.branch`.
|
||
- meta = `current` when current, `tracked` when tracked, else empty.
|
||
- `canSwitch` = not current, not isCurrentUpstream, and not dirty.
|
||
- action = `checkout →` when canSwitch and the row is remote and not tracked. `switch →` when canSwitch otherwise. Empty when not canSwitch.
|
||
- `clickable` = not current and not isCurrentUpstream.
|
||
- `locked` = not current and dirty. A locked row is drawn at 40% opacity, with the tooltip `Commit or discard your changes first`.
|
||
- The pointer is a hand only when the row is clickable and not locked.
|
||
- A click on a clickable row (locked ones included) runs `switchBranch(name, remote)`. On a locked row the store answers with the "commit or discard" toast.
|
||
|
||
**Motion.** Only colour transitions: 160 ms, `cubic-bezier(0.22, 1, 0.36, 1)`, on hover and on the focus underline. Nothing slides or scales.
|
||
|
||
**Icons.** Lucide shapes on a 24-unit grid, stroke 1.75 scaled to the size, round caps and joins: git-branch, arrow-down-to-line, arrow-up-from-line, minimize-2, chevron-down, chevron-right, check. Cloud and eraser use the nearest SF Symbols (`cloud`, `eraser`) at 0.82 × size, light weight.
|
||
|
||
---
|
||
|
||
### 3.19 Keyboard inside the Git view
|
||
|
||
The order of the rules (`KeyRouter`):
|
||
1. Control or Option held → the key passes to the focused view.
|
||
2. While the Diff overlay is busy (its own menu or prompt is open), every key passes. With no overlay, a bare Esc closes the Git view (when it is open). With any other overlay, a bare Esc dismisses the overlay first.
|
||
3. Under an overlay other than the Diff, every key passes to the overlay.
|
||
4. With the Git view open (`gitViewKey`):
|
||
- Keys without ⌘: `?` shows the shortcuts sheet, but only when the workspace owns the keyboard (not a text field). Every other key passes to the focused field. Arrows, Enter and Up therefore go to the console input or the message field.
|
||
- ⇧⌘ keys: the normal command map (only ⇧⌘O "recent projects" is bound).
|
||
- ⌘↵ → **commit**, unless the first responder is the console input's field editor (`inGitConsole`), where it passes. It commits from the message field too.
|
||
- ⌘A passes (select all in the focused field).
|
||
- Other ⌘ letters keep their global meaning:
|
||
- ⌘F search, ⌘P **push**, ⌘S save, ⌘M cycle mode, ⌘W close file or window, ⌘G toggle the Git view
|
||
- ⌘1, ⌘2, ⌘3 toggle the columns under the view, ⌘L fluid, ⌘. hidden files
|
||
- ⌘C passes when text is selected, and otherwise asks for the commit message field.
|
||
- ⌘←, ⌘→, ⌘↑ and ⌘↓ (the column and row keys) rest: they pass.
|
||
5. Inside the console input: ↵ submits and ↑ recalls. There is no ↓.
|
||
|
||
---
|
||
|
||
### 3.20 Doc-vs-code conflicts (the code wins)
|
||
|
||
1. **(Resolved in the code since; this item is history.) Conflicts were not `U` rows in "changed".** The docs (guide, behaviour.md) say a conflicted row shows `U`, sits in **changed**, and offers only **Stage**. In the code, `Porcelain.classify` turns every conflict (`U?`, `?U`, `AA`, `DD`) into **one staged row with status M**. So a conflict sits in the **staged** section with an `M` badge and offers **Unstage**. The `U` status, the `Conflict` tooltip and the "skip unmerged" filters in discard are unreachable code.
|
||
2. **Enter in the message field.** The guide says Enter "does not start a new line". The code turns the newline into a **space**, so Enter inserts a space.
|
||
3. **Console history.** The task brief mentions Up/Down. The code has **↑ only**. Once the cursor reaches the oldest entry, there is no way back to the newest entry except to submit.
|
||
4. **⌘P.** behaviour.md §9 names ⌘P as "Go to File". In the code, ⌘P is **push**, everywhere (`KeyRouter.commandCharacter`). The git guide agrees with the code.
|
||
5. **Push toast with nothing ahead.** The docs give `Pushed N commits to origin/<branch>`. With ahead 0 (for example a first push with `-u`), the code shows `Pushed to origin/<branch>`. The remote name is always the literal `origin`.
|
||
6. **Pull toast.** The docs say a toast always reports the result. With behind 0 and stdout containing `Already up to date`, the code shows **no toast**. With behind 0 and other output, it shows `Pulled from origin/<branch>`.
|
||
7. **Design handoff vs code, staging.** The handoff says "Stage all" logs `git add -A`. The code always runs `add -- <paths…>` and never `-A`.
|
||
8. **Design handoff, porcelain version.** The handoff suggests `--porcelain=v2` and `rev-list --left-right --count`. The code uses porcelain **v1** with `-b -z` and reads ahead/behind from the `## ` header.
|
||
9. **Design handoff, inline diff.** The handoff suggests `git diff --unified=3` hunks. The code builds its own LCS line diff from the blob and disk texts, then folds with 3 lines of context.
|
||
10. **Design handoff, padding.** The handoff gives section and row padding `0 14px 0 11px` plus a 3 px border, and branch rows `0 16px 0 13px`. The code uses padding 14 (section and row) and 16 (branch) with the 3 pt bar **overlaid** on the left edge, so the content starts 3 pt further right than in the handoff.
|
||
11. **Design handoff, header count badge.** The handoff implies a file count. The code counts **rows**, so a file with two halves in one section would count twice. That cannot happen within one section, but a staged-plus-modified file does count once in staged and once in changed.
|
||
12. **Renames.** The docs do not mention it, but a staged rename reads `HEAD:<newpath>` and so shows as all lines added (3.6).
|
||
13. **"Discard" wording.** behaviour.md says Discard reverts "modified and deleted files from the index". The code agrees (`git restore -- paths` restores from the index). The confirm body still says "reverts to the last commit", which is wrong when a staged version exists.
|
||
14. **Timeout and launch-failure lines** (`timed out after 120s`, `git not found`) are painted as plain **output**, not as errors. They are still the failure detail of the toast.
|
||
15. **Fetch on open.** The architecture doc and the guide say a repository without an origin skips the fetch. The code also fetches when there are no remote branches but the upstream starts with `origin/`, and it skips when the state is not a repository.
|
||
16. **`isRepository` fallback.** The code calls a folder with a `.git` entry a repository even when `rev-parse` fails. Its status then fails 6 times and the console logs `status failed: …` once. The docs do not say this.
|
||
|
||
|
||
---
|
||
|
||
## 4. The editor column (Col C), change marks, Diff overlay, Markdown preview, PHP symbols, Pass on
|
||
|
||
This section describes the third column ("File" column, Col C) and everything that floats out of it: the full-screen Diff overlay, the Markdown preview, the PHP symbol popup and the Pass-on prompt. It also gives the exact line-diff algorithm. Syntax grammars and the Markdown parser are described in their own section; here only their use is described.
|
||
|
||
Where the docs and the code disagree, the code is the truth. Every disagreement is listed in 4.17.
|
||
|
||
---
|
||
|
||
### 4.1 Overview and colour/size tokens used here
|
||
|
||
| Token | Value | Use in this section |
|
||
|---|---|---|
|
||
| editor background | `#101720` | code pane, gutter, bar, Diff canvas, Markdown preview |
|
||
| panel | `#18202B` | Diff header, code-block and table-header background, popups |
|
||
| raised | `#232C39` | hairlines, dividers, highlight of a popup row |
|
||
| hover | `#1E2733` | Collapse button hover |
|
||
| text1 `#F4F5F4`, text2 `#E4E7E6`, text3 `#BAC0C0`, text4 `#6C7783`, text5 `#3A424C` | text greys |
|
||
| amber | `#E8913A` | caret, flash, links, accent rules, list markers |
|
||
| amberSoft | `#F0B476` | inline code, quote text |
|
||
| amberTint | `#E8913A` @ 10% | lit symbol chip |
|
||
| amberKeycapBorder | `#E8913A` @ 35% | lit symbol chip border |
|
||
| focusRing | `#E8913A` @ 22% | pass-on field focus ring |
|
||
| ink | `#171C22` | text on an amber chip |
|
||
| added text / rule ("teal") | `#8FBFB4` | added lines |
|
||
| added fill | `#8FBFB4` @ 12% | added line tint |
|
||
| removed text / rule ("amber-deep") | `#C4741F` | removed lines, gap rules |
|
||
| removed fill | `#C4741F` @ 14% | removed line tint (Diff left side) |
|
||
| selection (code + Diff) | `#E8913A` @ 22% | text selection background |
|
||
| flash | `#E8913A` @ 10% | jump flash band |
|
||
| active line (read-only panes only) | white @ 3% | caret row |
|
||
| line number | `#3A424C` | gutter numbers |
|
||
| line number of read-only caret row | `#BAC0C0` | |
|
||
| scrim | `#101720` @ 72% | behind the symbol popup |
|
||
| tooltipBorder | `#3A424C` | symbol kind chip border |
|
||
| menu shadow | `#171C22` @ 10%, radius 16, y 4 | pass-on panel |
|
||
| overlay shadow | `#171C22` @ 18%, radius 48, y 16 | symbol popup |
|
||
|
||
Syntax colours (code pane, Diff, fenced code in preview): plain and symbol `#E4E7E6`, variable `#BAC0C0`, comment `#6C7783`, keyword `#C3A6CE`, string `#8FBFB4`, number `#F0B476`. Code is never bold or italic.
|
||
|
||
Metrics: hairline 1 pt; accent rule 2 pt; editor bar height 34; panel header height 34; code gutter width 56; Diff gutter width 52; traffic-light inset 82; context-menu item 30, context-menu width 320; pass-on width 460; search hit line 24; radius small 2, medium 4, overlay 8; focus ring width 2.
|
||
|
||
Type roles (font family, size, line height): code = IBM Plex Mono Regular 13 / 20; path = Mono Regular 12; meta = Mono Regular 11; panelLabel = Mono Bold 10, tracking 0.14 em, UPPERCASE; searchHit = Mono Regular 12 / 24; body = Plex Sans Regular 14 / 23.8; row = Sans Regular 13; rowSelected = Sans Medium 13; tooltip = Sans Regular 12 / 18; toolbarLabel = Sans Regular 12; markdownH2 = Mono Bold 24 / 26.4, tracking −0.03 em; markdownH3 = Mono Bold 17 / 20.4; markdownQuote = Sans Italic 15.
|
||
|
||
---
|
||
|
||
### 4.2 Editor model: one file, no tabs (`EditorStore`, `EditorStore+Disk`)
|
||
|
||
#### State
|
||
|
||
The store holds exactly one open file (`activePath`, nil = empty state). Opening a file replaces the current one. There are no tabs.
|
||
|
||
Per path it keeps a record (`FileState`):
|
||
|
||
| Field | Meaning |
|
||
|---|---|
|
||
| `mode` | the view mode the file asked for (see 4.3) |
|
||
| `side` | which git row opened the file (`staged` / `unstaged` / nil); only the Diff overlay uses it |
|
||
| `buffer` | unsaved edits; nil means the buffer equals disk |
|
||
| `disk` | last text read from disk |
|
||
| `revision` | moves whenever the shown text changes from outside the text view; a global counter, so unique across paths |
|
||
| `image`, `imageUnreadable` | image bytes, or a failed image read |
|
||
| `isBinary` | the read found binary content |
|
||
| `isDeleted` | the file vanished from disk while open |
|
||
|
||
Other store state: `cursor` (path, line, column, 1-based), `selection` (path, start line, end line, anchor), `selectedCode` (the selected text), `flash` (path, line, unique id), `tooBig` notice, `history` (recent files, newest first, max 100, persisted per project), `defaultMode`, `editorConfig` (autoSave, tabSize, wordWrap), `modeBeforeDiff`, `textFocusRequest` and `selectAllRequest` counters, `knownSymbols` (set of PHP class names) with `knownSymbolsVersion`, `symbolName` and `symbolLookup`.
|
||
|
||
Derived:
|
||
- **text(for:)** = buffer, else disk, else "".
|
||
- **isDirty** = a buffer exists AND (file is deleted OR buffer ≠ disk). A deleted file with any buffer is dirty.
|
||
- **dirtyPaths** = the open file first (if dirty), then all other dirty paths sorted by name.
|
||
- Status bar: language label (`"Image"` for an image, else the language label of the file type), `"Spaces: N"` (N = tabSize), cursor line/column (1 when no cursor on the active file), dirty flag.
|
||
|
||
#### Opening a file (`open(path, options, accepted)`)
|
||
|
||
`OpenOptions`: `side` (git row), `line` (jump target), `showDiff` (open straight into the Diff).
|
||
|
||
1. **Too big names**: if the file's basename is `composer.lock` (the only entry in `tooBigNames`), the file does not open. The column shows the flash text **`Too big.`** for 1.6 s, centred over the column (path type role, amber text, padding 16×10, panel background, radius 4, 1 pt raised border, does not take clicks). The current file stays open. `accepted` still runs (so the Explorer still selects the row).
|
||
2. **Dirty current file** (the same path included):
|
||
- If `editor.autoSave` is on and the current file is not deleted: save silently (no toast), then open.
|
||
- Otherwise ask with a modal alert (see below). Cancel: nothing happens, current file and its edits stay, `accepted` is not called (the Explorer selection does not move). Don't Save: drop the buffer, open. Save: write, then open; a failed save keeps the current file open and does not open the new one.
|
||
- With no prompt hook wired, the answer is Cancel (a dirty file never closes silently).
|
||
3. **Show** the file:
|
||
- Push the path onto the recent-files history (moves to front, dedup, cap 100).
|
||
- Set it active; clear selection and selected code.
|
||
- Set the stored mode: **`actual` if git has a diff for the file and it is a text file, else `code`**. This always overrides any earlier stored mode; `git.defaultDiffMode` is effectively ignored here.
|
||
- Store `side` from the options.
|
||
- If `line` is given: cursor = (line, column 1) and start the jump flash (4.6).
|
||
- If `showDiff` and the file is changed: enter Diff mode (opens the overlay).
|
||
- Read from disk with "disk wins": any buffer is dropped (see Reading below).
|
||
- Persist the session soon.
|
||
4. `accepted` runs (the workspace then selects the file in the Explorer and moves keyboard focus zone to the editor).
|
||
|
||
**Unsaved-edits alert** (modal, warning style):
|
||
- Title: `Save changes to <basename>?`
|
||
- Message: `<path> has unsaved edits. They are lost if you close without saving.`
|
||
- Buttons in order: `Save`, `Don’t Save` (curly apostrophe U+2019), `Cancel`.
|
||
|
||
#### Reading from disk (`load(path, discardEdits)`)
|
||
|
||
Each read gets a per-path generation number; a read that finishes after a newer read or save started is dropped.
|
||
|
||
- **Image** kind: read bytes (only for known image extensions, max 25,000,000 bytes); set `image`; `imageUnreadable` = no bytes.
|
||
- **Binary** kind (by extension): nothing is read.
|
||
- **Text** kind: read the file.
|
||
- Content is binary if a NUL byte appears in the first 8000 bytes → `isBinary = true` (placeholder shown).
|
||
- Text is decoded as UTF-8 (lossy).
|
||
- **Apply disk text**: set `disk`, clear `isDeleted`. If a buffer exists: with `discardEdits` the buffer is dropped and the revision bumped; without it, the buffer is kept, unless it equals the new disk text, then it is dropped (the file is clean again). With no buffer: bump the revision when the text changed or the file was deleted before.
|
||
- **File missing** (no-such-file error): with `discardEdits` → buffer nil, disk "", not deleted, revision bumped (empty text shows). Without → mark deleted: `isDeleted = true`, buffer = the last disk text if there was no buffer, disk = "" if none; any pending auto-save is cancelled. The text stays on screen as unsaved edits; the unsaved dot shows.
|
||
- **Other read error**: logged; if the file was never loaded, disk = "" (empty view).
|
||
|
||
Who reads with which flag:
|
||
| Trigger | discardEdits |
|
||
|---|---|
|
||
| open / reopen (always fresh from disk) | yes |
|
||
| ⌘R (Refresh: git + tree + open file) | yes (disk wins, edits dropped without a prompt) |
|
||
| session restore of the active file | yes |
|
||
| watcher event ("files changed") | no (dirty buffer kept) |
|
||
| ⌘M / Preview toggle | no |
|
||
|
||
**Watcher**: on any project change event (debounced 100 ms), the store reloads the open file plus every other dirty path, but only those already loaded (disk text, image or binary flag present). A clean buffer simply shows the new text; a dirty buffer is never overwritten.
|
||
|
||
#### Editing
|
||
|
||
- Every keystroke reports the full text. If the text equals disk and the file is not deleted, the buffer becomes nil (clean); otherwise it is the buffer.
|
||
- Undo/redo are per document (4.4); a load from outside clears the undo history.
|
||
- **Auto-save** (`editor.autoSave`, default false): 600 ms after the last edit, the file is written without a toast. Each new edit restarts the timer (per path). Never scheduled for a deleted file. Pending auto-saves move with a rename, are cancelled on delete, and are flushed (written immediately) before the window closes or the project switches. A pending auto-save of file A still runs after switching to file B.
|
||
|
||
#### Saving (`save(path, announce)`)
|
||
|
||
- ⌘S saves the active file. A file that is not dirty is not written (no toast).
|
||
- Write is atomic when the file exists: write a sibling temp file named `.<name>.helder-<UUID>` created exclusively with the old file's POSIX permissions (default 0644 if unknown), fsync, chmod again, then rename over the target (symlinks are resolved first, so the link target is replaced). On failure the temp file is removed. If the file does not exist (for example deleted while open) it is created fresh, never overwriting.
|
||
- Paths outside the project are refused.
|
||
- On a failed write: toast **`Save failed`** with the path as detail; the buffer and the open file stay.
|
||
- After a successful write: re-read the file; set disk to what was read (or the written text if the read fails), clear `isDeleted`, drop the buffer when it equals disk. Toast **`Saved`** with the path as detail (not for auto-save). Git is told to re-read (status bar and Git view update).
|
||
- **No trimming and no final-newline insertion happens on save.** The exact buffer is written as UTF-8.
|
||
|
||
#### Closing
|
||
|
||
- ⌘W (also the text view's own ⌘W, and the menu item "Close File"; it reads "Close" when no file is open and then closes the window): if dirty, ask Save / Don't Save / Cancel. Cancel keeps it; Save writes then closes (a failed save keeps it open); Don't Save closes.
|
||
- Close drops the buffer, clears cursor and selection for the path, sets no active file (empty state), persists.
|
||
- **Before the window closes or the project switches** (`resolveUnsaved`): flush pending auto-saves, then ask for every dirty path (open file first, then the others sorted). Cancel at any point aborts and no discard is applied. Discards are applied only after all answers.
|
||
|
||
#### Rename and delete from the Explorer
|
||
|
||
- Rename moves every path-keyed piece of state (active path, history, file records, cursor, selection, pending auto-saves; a read in flight for the old name is dropped). Works for a folder (everything inside moves).
|
||
- Delete forgets every piece of state for the file or everything inside the folder; if the active file is gone, the empty state shows.
|
||
|
||
#### Indentation (`Indentation.edit`)
|
||
|
||
`editor.tabSize` default 4 (minimum 1). Tab never inserts a tab character.
|
||
|
||
- **Tab, selection inside one line (or caret)**: the selection is *replaced* by `tabSize` spaces; caret after them. (No alignment to tab stops.)
|
||
- **Tab, selection spanning a newline**: every touched line gets `tabSize` spaces prepended.
|
||
- **Shift+Tab (always line-based, also with only a caret)**: every touched line loses one leading tab character, or else up to `tabSize` leading spaces.
|
||
- Touched lines = from the start of the line holding the selection start to the end of the line holding the selection end; a selection that ends right after a newline (at column 0 of the next line) leaves that last line alone.
|
||
- New selection: start = max(line start, old start + change on first line), end = max(line start, old end + total change).
|
||
- If nothing would change (outdent of unindented lines), nothing happens and the key is swallowed.
|
||
- The change is one undoable edit; the view scrolls to keep the selection visible.
|
||
- A tab character in the file is drawn `tabSize` space widths wide.
|
||
|
||
#### Jump flash
|
||
|
||
When a file is opened at a line (search hit, symbol popup, Go to file with line), the store sets a flash for (path, line) and clears it after 1 s. The view (4.6) centres the line, puts the caret at the start of that line and draws the flash.
|
||
|
||
---
|
||
|
||
### 4.3 View modes and what the column shows (`ViewMode`, `EditorPresentation`, `EditorFileKind`)
|
||
|
||
#### Modes
|
||
|
||
| Mode | Stored raw value | Meaning |
|
||
|---|---|---|
|
||
| actual | `"updated"` | the live editable buffer with changed lines marked |
|
||
| diff | `"diff"` | the full-screen side-by-side overlay (not a pane mode) |
|
||
| code | `"code"` | an unchanged file: the plain editable buffer |
|
||
| preview | `"preview"` | rendered Markdown |
|
||
|
||
`git.defaultDiffMode` config `updated` → actual, `diff` → diff.
|
||
|
||
#### File kind
|
||
|
||
- **image**: by image extension (png, jpg, jpeg, jfif, gif, webp, svg, bmp, ico, avif, apng are readable image types).
|
||
- **binary**: basename `.DS_Store`, or extension in: pdf, zip, gz, tgz, tar, bz2, xz, 7z, rar, jar, war, class, woff, woff2, ttf, otf, eot, mp3, mp4, m4a, mov, avi, wav, ogg, webm, exe, dll, so, dylib, a, o, bin, dat, psd, sqlite, sqlite3, db, phar, heic, tiff, tif, icns, DS_Store.
|
||
- **text**: everything else. A text file whose read found binary content is treated as binary.
|
||
|
||
#### Resolving the presentation (inputs: path, requested mode, diff for the file, defaultMode, isBinary)
|
||
|
||
1. `kind` as above.
|
||
2. `hasDiff` = kind is text AND git has a whole-file diff (HEAD vs disk).
|
||
3. `isMarkdown` by file type.
|
||
4. `wanted` = requested mode, or (hasDiff ? defaultMode : code).
|
||
5. `mode` = preview if wanted is preview and the file is Markdown; else if hasDiff: diff if wanted is diff, otherwise actual; else code.
|
||
6. `paneMode` = actual when mode is diff, else mode (the pane under the overlay shows Actual).
|
||
7. `status` from the diff: Deleted if the diff is a deleted file, Added if an added file, else Modified.
|
||
8. `placeholder`: binary → "cannot display"; paneMode actual and status Deleted → "no updated version"; else none.
|
||
|
||
Rules derived from it:
|
||
- **Bar buttons**: `Preview` when text and Markdown; then `Diff` when hasDiff. Order: Preview, Diff.
|
||
- **Editable** when text, no placeholder, paneMode is code or actual.
|
||
- **Offers Show diff** when paneMode is actual, hasDiff, and status is not Added.
|
||
|
||
#### What the pane shows (`EditorPane`)
|
||
|
||
- Text file: the code view is always kept alive (hidden with zero opacity and no hit testing while Preview or a placeholder shows), so a trip to Preview keeps undo history and colours.
|
||
- Image: the image preview (4.12).
|
||
- Placeholder: centred title in body type, optional note under it in path type, text4.
|
||
- "cannot display": title **`This file cannot be displayed`** (text4), no note.
|
||
- "no updated version": title **`No updated version`** (amber-deep), note **`This file was deleted in the change.`**
|
||
- Preview: the Markdown preview of the live buffer (4.10).
|
||
|
||
#### Empty state (no file open)
|
||
|
||
The bar stays as an empty 34 pt bar (so the column top lines up). The pane shows, centred: **`No file open`** (body, text4), then 18 pt below, three rows 260 pt wide, label left (row type, text2), keycap right:
|
||
| Label | Keycap |
|
||
|---|---|
|
||
| `Open folder` | `⌘O` |
|
||
| `Recent projects` | `⇧⌘O` |
|
||
| `Search files & content` | `⌘F` |
|
||
|
||
---
|
||
|
||
### 4.4 Editor bar (`EditorBar`)
|
||
|
||
Height 34, horizontal padding 14, items 10 apart, background editor colour, 1 pt raised hairline at the bottom. Left to right:
|
||
|
||
1. **Type badge** for the path.
|
||
2. **Path**, project-relative, path type role, text2, one line, truncated at the head; tooltip = full path.
|
||
3. **Unsaved dot**: 7×7 circle in text2 (not amber), shown when dirty. Accessibility label `Unsaved changes`.
|
||
4. **Change counts** (only when git has a diff for the file and the file is text): `+N` in teal when N > 0, `−N` (U+2212 minus) in amber-deep when N > 0; Mono Medium 12; 8 pt apart. Counts are the whole-file diff (HEAD vs disk). A file over the diff cap has an empty diff, so no counts show.
|
||
5. Flexible space.
|
||
6. **Segment buttons** in `barButtons` order: `Preview` (lit when mode is preview; toggles preview) and `Diff` (lit when mode is diff, i.e. while the overlay is open; opens the Diff overlay).
|
||
|
||
---
|
||
|
||
### 4.5 Mode changes
|
||
|
||
- **setMode(diff)**: only if git has a diff for the file. Remember the current mode as `modeBeforeDiff` (unless already diff), store diff, and present the Diff overlay with the file's stored `side` and no focus line.
|
||
- **setMode(other)** while the current mode is diff: dismiss the overlay and give the code view keyboard focus.
|
||
- **⌘M / Preview button** (`togglePreview`): only when the bar offers Preview (Markdown text file). Flips between preview and code (code resolves to actual on a changed file). Then re-reads disk without discarding edits. Over an open Diff it switches to preview and closes the overlay. On a non-Markdown file ⌘M does nothing.
|
||
- **Show diff on a marked line** (`openDiff(atLine:)`): needs a diff. Remember the mode, store diff, present the overlay with **side nil (HEAD vs disk) and the focus line**.
|
||
- **closeDiff** (Esc, Collapse, or any other overlay replacing the Diff): restore `modeBeforeDiff` (actual if that was diff), focus the code view, persist.
|
||
- Every mode change persists the session soon.
|
||
|
||
---
|
||
|
||
### 4.6 The code view (`CodeEditorController`, `CodeEditorController+Drawing`, `CodeTextView`, `CodeDocument`, `CodeLayout`)
|
||
|
||
#### Documents
|
||
|
||
Each file (document id = the path) owns its own text storage, undo history, line index, tokens, last selection and last scroll position. Up to **12** documents are cached (most recently shown first; the 13th is evicted). Switching files swaps documents; it does not re-read or re-colour.
|
||
|
||
- A document's text is replaced only when the store's `revision` for that path moves (external change). Otherwise the user's typing is the truth.
|
||
- On replace in place (same file, new revision): keep the caret location (clamped to the new length, collapsed), keep the scroll position.
|
||
- On switching to a document: save the old one's selection and scroll position. If the new one is fresh (revision differs from what it holds) load its text and scroll to the top-left; otherwise restore its saved selection (clamped) and scroll position. **This is in memory only; scroll and caret are not persisted across launches.**
|
||
|
||
Line index: line starts as UTF-16 offsets. A text ending in a newline has an empty last line. Line/column are 1-based; column = UTF-16 offset in line + 1. The index is updated incrementally per edit.
|
||
|
||
Syntax colouring: full re-colour (off the main thread) on load, on language change and when the known-symbol list changes; the plain text shows at once and colours follow. After typing: wait 40 ms of quiet, re-tokenise, repaint only the token range that differs (an opened block comment repaints everything after it).
|
||
|
||
#### Text and layout
|
||
|
||
- Font IBM Plex Mono Regular 13 pt × zoom scale. Fixed row height = round(20 × scale). Glyphs vertically centred in the row: baseline = (rowHeight − (ascender − descender)) / 2 + ascender.
|
||
- Text inset: 10 pt above the first line; 40 pt of room under the last line. Line fragment padding 6 pt (left/right of each row).
|
||
- No rich text, no smart quotes/dashes, no text replacement, no spell or grammar check, no link detection, no smart insert/delete, no find bar.
|
||
- Text colour default `#E4E7E6`; caret (insertion point) colour **amber**; selection background amber @ 22%.
|
||
- No horizontal scroll bar is ever shown; vertical scroll bar auto-hides. Unwrapped text scrolls sideways by trackpad/wheel.
|
||
|
||
#### Word wrap (`editor.wordWrap`)
|
||
|
||
| Value | Effect |
|
||
|---|---|
|
||
| `markdown` (default) | wrap only Markdown files |
|
||
| `on` | wrap every file |
|
||
| `off` | wrap none |
|
||
|
||
Wrapped: the text width tracks the visible width right of the gutter. Unwrapped: the text view grows as wide as the longest line (at least the visible width).
|
||
|
||
#### Gutter (line numbers)
|
||
|
||
- Fixed width **56 pt** (does not change with zoom), background editor colour, clipped to its bounds.
|
||
- Numbers are always **absolute**; there is no relative or hidden mode.
|
||
- Each number is drawn in the code font (scaled), right-aligned so its right edge is 14 pt left of the gutter's right edge, vertically centred in the row.
|
||
- **Only the first visual row of a wrapped line shows a number**; following rows are blank.
|
||
- Number colour: `#3A424C`; a teal-tinted changed line (Actual) → teal; the caret row in a read-only pane → `#BAC0C0` (the editable buffer never lifts the caret row).
|
||
- **Click** a number: select the whole line including its newline (from the line start to the next line start) and focus the text. **Shift+click**: extend: union of that line and the current selection.
|
||
- Pointer over the gutter: arrow (the I-beam area excludes the gutter).
|
||
|
||
#### Row backgrounds (drawn behind the text, from the left edge of the text area, full width)
|
||
|
||
Per visual row:
|
||
1. If the line has a **tinted mark** (Actual, added line): fill the row with the tone fill (teal @ 12%), then a 2 pt tone rule (teal) at the left edge.
|
||
2. Else if the line is the caret line of a **read-only** pane and there is no selection: fill white @ 3%. (In practice the editable pane never shows this; there is **no active-line highlight** in the editable view.)
|
||
3. **Flash**: if this is the flash line, fill amber @ (10% × strength) and a 2 pt amber rule at the left edge with alpha = strength. Strength = 1 for the first 65% of 1 s, then fades linearly to 0 over the remaining 35%. Redrawn at 30 fps; ends after 1 s.
|
||
4. **Gap rule**: if the line carries a gap mark, a 2 pt amber-deep (`#C4741F`) full-width rule: `above` → at the top of the line's first visual row; `below` → at the bottom of the line's last visual row.
|
||
|
||
No indent guides and no whitespace marks are ever drawn.
|
||
|
||
#### Change marking in Actual (`ChangeMarks.actual`, `DiffViews.actual`)
|
||
|
||
Only when paneMode is actual and git has a whole-file diff (HEAD vs disk). The marks are recomputed only when a cheap fingerprint of the diff changes ("added.removed.rowCount.originalBytes.updatedBytes").
|
||
|
||
- Every line of the updated file that the diff marks as added → tint + teal rule + teal number. (An edited line is a removal plus an addition, so it shows as teal.)
|
||
- **Pure deletions** (a run of removed lines with no added line in the same run, the run delimited by unchanged lines): the next unchanged line after the run gets `gap: above`. A pure deletion at the very start of the file rules above line 1. A pure deletion at the end of the file puts `gap: below` on the last line. A run that also added lines gets no gap rule.
|
||
- Removed lines never show inline.
|
||
- A deleted file has no Actual lines (the "No updated version" placeholder shows instead).
|
||
- An added (new) file: every line teal; Show diff is not offered.
|
||
- The marks reflect git's view; they follow edits once git re-reads after a save (or the watcher).
|
||
- A file over the git diff cap (1,000,000 bytes) gets an empty diff: no marks, no counts, but the Diff button still shows and its overlay says `Too big.`
|
||
|
||
#### Caret, selection, focus
|
||
|
||
- Caret position reported to the status bar = the end of the selection (location + length), clamped.
|
||
- Selection reported to the store as (first line, last line, selected text); last line = the line that contains the selection end offset. Note: a selection that ends at column 0 of the next line (for example a gutter click on line 5) reports lines 5-6.
|
||
- ⌘A (in the text) selects all. ⌘A when the keyboard is elsewhere (but not in a text field) also selects the whole open file, via `selectAllRequest`, and focuses the text.
|
||
- Focus requests (after the Diff closes, after a mode change from diff, when the editor column gets focus) wait one run-loop turn and never steal focus from a text field of another overlay (a field editor).
|
||
- When the column is hidden, the code view takes no focus and no select-all.
|
||
|
||
#### Keys the text view answers itself (only while it is first responder, with exactly ⌘)
|
||
|
||
| Key | Action |
|
||
|---|---|
|
||
| ⌘S | save |
|
||
| ⌘W | close the file (asks when dirty) |
|
||
| ⌘M | toggle Preview |
|
||
| ⌘→ (key code 124, exactly ⌘) | with a non-empty selection: open the pass-on prompt for it; else the native meaning (end of line) |
|
||
| Tab / Shift+Tab | indent / outdent (4.2) |
|
||
| ⌘-click | follow a known class name (4.11) |
|
||
|
||
#### Right-click in the code
|
||
|
||
The native text-view menu is suppressed; right-click does **not** move the caret. Steps:
|
||
1. Focus the text.
|
||
2. Clicked line = the line under the pointer, or the last line if the click is below the text.
|
||
3. If there is a selection: reference = `path:start-end` over the selected lines (or `path:line` if one line), code = selected text. Else reference = `path:clickedLine`.
|
||
4. Show-diff line = the clicked line if the file offers Show diff and that line has any mark (tint or gap). The whole row counts: blank marked lines and the space after the last glyph hit too.
|
||
5. The workspace context menu opens at the pointer (window top-left coordinates).
|
||
|
||
Editor menu entries (no header line):
|
||
| Condition | Entries, in order |
|
||
|---|---|
|
||
| always | `Pass on reference` (no selection) or `Pass on selection` (with selection) — spark icon |
|
||
| always | `Copy reference` — copy icon |
|
||
| with selection | separator, `Read aloud selection` (Markdown files: the selection's prose with markup removed; if no prose remains, the raw text) |
|
||
| with selection | separator, `Plak` (sends the selected text to the Plak scratchpad app) |
|
||
| marked line and Show diff offered | separator, `Show diff` — left/right arrows icon |
|
||
|
||
- `Pass on reference/selection` → opens the Pass-on prompt (4.13) at the click; with selection the code is included.
|
||
- `Copy reference` → clipboard gets the reference; toast **`Copied reference`** with the reference as detail.
|
||
- `Show diff` → if that file is still the active file: Show diff at that line (4.5, 4.8).
|
||
|
||
#### Pointer
|
||
|
||
I-beam over the text; pointing hand while ⌘ is held over a glyph of a known class name; arrow over the gutter and behind overlays.
|
||
|
||
#### Zoom (View menu)
|
||
|
||
- `Actual Size` ⌘0 → level 0; `Zoom In` ⌘+ → level + 0.5; `Zoom Out` ⌘− → level − 0.5.
|
||
- Level is clamped to −3 … +5. Scale = 1.2 ^ level (so each half step is about 9.5%; range about 0.58× to 2.49×). Shared by all projects, persisted in user defaults key `helder.zoom`.
|
||
- Applies to the code view (font and row height, keeps text and undo history), the Diff overlay (font and row height) and the terminals. **Not** the Markdown preview, not the gutter width.
|
||
|
||
---
|
||
|
||
### 4.7 The line-diff algorithm (`LineDiff`, `DiffModels`)
|
||
|
||
#### Splitting into lines
|
||
|
||
- Empty text = zero lines.
|
||
- Otherwise drop exactly one final byte `\n` (if present), then split on `\n`. A `\r` stays part of the line, so CRLF files keep `\r` at each line end and a line-ending change is a change. A difference in only the trailing newline is no change.
|
||
|
||
#### Core
|
||
|
||
1. Intern every distinct line to an integer id (both sides share the table), so comparisons are integer compares.
|
||
2. `region(a0..a1, b0..b1)`:
|
||
- Emit `same` for the common prefix; set aside the common suffix (emitted at the end, in order).
|
||
- n = remaining old lines, m = remaining new lines.
|
||
- If n == 0 or m == 0: emit all deletions (old order) then all additions (new order).
|
||
- Else if n × m ≤ **4,000,000** cells: LCS dynamic program (below).
|
||
- Else: find **anchors** — lines that appear exactly once in the old region and exactly once in the new region; take them in old order and keep the longest subsequence whose new indices strictly increase (patience-style LIS with binary search). No anchors → emit all deletions then all additions. Otherwise recurse on each gap between consecutive anchors, emitting each anchor as `same`.
|
||
3. **Dynamic program**: table dp[i][j] = LCS length of old[i..] and new[j..] (filled from the end; 32-bit ints). Walk from (0,0): if old[i] == new[j] → `same`, advance both; else if dp[i+1][j] ≥ dp[i][j+1] → `delete old[i]` (**on a tie the deletion comes first**); else `add new[j]`. Then remaining deletions, then remaining additions.
|
||
|
||
#### Output (`Diff`)
|
||
|
||
- `rows`: unified rows in op order: sign (same/removed/added), old line number (nil for added), new line number (nil for removed), text.
|
||
- `left`: every old line with its number and mark `removed` if deleted.
|
||
- `right`: every new line with its number and mark `added` if added.
|
||
- `split`: side-by-side rows (below).
|
||
- `added` / `removed`: counts of added / removed lines.
|
||
- `isDeletedFile` / `isAddedFile`: from the git status passed in (deleted / added).
|
||
- `original`, `updated`: the two texts.
|
||
- `isTooBig`: set by git derivation when the change is over the 1 MB cap (both texts are then empty).
|
||
|
||
There are no hunks and no context collapsing: the Diff overlay shows the whole file.
|
||
|
||
#### Side-by-side alignment (`split`)
|
||
|
||
Walk the ops. Buffer removed lines and added lines (each in order) until the next `same` op (or the end). On flush, emit max(removed, added) rows pairing the k-th removed line (left) with the k-th added line (right); the shorter side gets an empty filler (nil). Then emit the `same` row with both sides (unmarked). So unchanged lines line up, a run of removals pairs with the run of additions next to it, extra lines face an empty half.
|
||
|
||
#### Which pairs exist
|
||
|
||
From git (other section): per git row (staged or unstaged) a diff of that half; per file a whole-file diff HEAD vs disk (if the file has one row, that row's diff; if both, rebuilt from HEAD and disk). Actual marks and the bar counts always use the whole-file diff. The Diff overlay uses the row diff of the side that opened the file (`overlayDiff`): if a side is set and that row exists, its diff; else the whole-file diff.
|
||
|
||
---
|
||
|
||
### 4.8 The Diff overlay (`DiffOverlayView`, `DiffCanvas`, `DiffOverlayLayout`)
|
||
|
||
#### Opening
|
||
|
||
- **Diff** button in the bar: overlay with the file's stored side (the git row that opened the file), no focus line → scrolled to the top.
|
||
- **Show diff** in the code's right-click menu on a marked line: side nil (HEAD vs disk), centred on that line.
|
||
- `OpenOptions.showDiff` when opening a changed file.
|
||
- Only a file with a git diff can open it.
|
||
|
||
#### Layout (covers the whole window, all columns)
|
||
|
||
1. **Header**, height 42, panel background, 1 pt raised bottom hairline. Left padding 82 (room for the window's traffic lights) or 16 in full screen; right padding 16; items 14 apart:
|
||
- type badge; path (Mono Medium 12, text1, one line, head truncation);
|
||
- if a diff exists: status word `Added` (teal) / `Modified` (text4) / `Deleted` (amber-deep) in panelLabel type (shown UPPERCASE); `+N` teal and `−N` amber-deep (Mono Medium 12, only when > 0);
|
||
- only when the file has both a staged and an unstaged row: `staged → actual` when the side is unstaged, else `HEAD → staged` (meta type, text4);
|
||
- flexible space; **Collapse** button: icon "arrows pointing inward" (11 pt), label `Collapse` (toolbarLabel), keycap `Esc`; text3, text1 on hover; hover background `#1E2733`; 1 pt raised border, radius 2; padding left 9, right 4, vertical 3; pointing-hand cursor; click = collapse.
|
||
2. **Pane labels**, height 34, bottom hairline, split in two halves by a 1 pt raised divider: left `Original` (panelLabel, text4) + `before` (meta, text5); right `Actual` (panelLabel, amber) + `after` (meta, text5). Padding 16, 10 between title and note.
|
||
3. **Body**:
|
||
- diff is too big → `Too big.` centred (body, text4);
|
||
- diff exists → the canvas;
|
||
- no diff (no changes left) → `— No changes to compare.` centred (body, text3).
|
||
The body follows git live: when git re-reads, the shown diff updates.
|
||
|
||
#### Canvas
|
||
|
||
- Background editor colour. One vertical scroll (auto-hiding scroller) for both halves. **Never wraps.** Rows are painted, not laid out, so only visible rows cost time.
|
||
- Row height = round(22 × zoom scale); top and bottom padding 6 (unscaled). Content height = 12 + rows × rowHeight.
|
||
- Left half width = floor(width / 2); a 1 pt raised divider at x = half; right half starts at half + 1.
|
||
- Per half-row with a line (filler halves are empty background):
|
||
1. if selected on this side: fill selection colour (amber 22%);
|
||
2. if the line is marked (left: removed, right: added): fill the tone fill (amber-deep 14% / teal 12%) and a 2 pt tone rule at the half's left edge;
|
||
3. line number of that side, code font, right edge 14 pt left of the 52 pt gutter; colour = tone if marked else `#3A424C`;
|
||
4. text at x = half start + 52 − horizontal offset, clipped to the half, syntax coloured **per line** (line tokens, no multi-line state), cached per row.
|
||
- Text vertical position: row top + (rowHeight − (ascender − descender + leading)) / 2.
|
||
- **Sideways scroll**: a scroll gesture whose horizontal delta exceeds its vertical delta shifts both halves together. Offset clamped to [0, max(0, widest − room)], widest = longest line (UTF-16 units, either side) × space width + 24, room = half width − 52. No horizontal scroller.
|
||
- **Centering** on a line: find the first split row whose right side has that line number; offset = rowTop − (viewport − rowHeight)/2, clamped to [0, max(0, contentHeight − viewport)] (rowTop = 6 + index × rowHeight). If the viewport has no height yet, centring waits for the first layout. No focus line → scroll to the top. A line not on the right side → no scroll. Re-centring happens only when the diff identity (path, side, focus line, counts, row count, updated byte count) or the zoom changes.
|
||
- The canvas takes keyboard focus when shown, after centring, and when the pass-on prompt closes.
|
||
|
||
#### Selection and copy
|
||
|
||
- Mouse down: focus, remember (side, row); clear any selection. A click without a drag selects nothing.
|
||
- Drag: select whole rows from the start row to the current row, **on the start side only**; autoscrolls.
|
||
- Row from a point: floor((y − 6) / rowHeight), clamped to valid rows; side = left if x < width/2.
|
||
- ⌘C (with a selection): copy the selected side's lines joined with `\n`, skipping rows where that side is a filler; no line numbers.
|
||
- ⌘A: select all rows of the side that holds the selection, else the left (Original) side.
|
||
|
||
#### Right-click inside the Diff
|
||
|
||
- Line = that side's line number of the clicked row; a filler half or outside the rows → line 1. Reference = `path:line`. Not available while the pass-on prompt is open.
|
||
- A menu drawn **inside** the overlay (a second overlay would replace the Diff), at the pointer, kept inside the Diff: x ≤ width − 320 − 8, y ≤ height − (entries × 30 + 60), both ≥ 8. A click outside closes it.
|
||
- Entries: `Pass on reference`, `Copy reference` (no header, no Show diff, no selection code, no Read aloud, no Plak). The first item is highlighted at open; hover highlights.
|
||
- Keys while the menu is open (the canvas forwards them): ↑ / ↓ move the highlight, Enter (return or keypad enter) chooses, Esc closes. All other canvas keys are consumed while the menu is open.
|
||
- `Copy reference` → workspace action (clipboard + toast `Copied reference`).
|
||
- `Pass on reference` → the Pass-on prompt (4.13) drawn inside the Diff, anchored at the menu position. Enter inserts into the agent and shows toast `Passed to agent` with the reference; the prompt closes and focus returns to the canvas.
|
||
- While the menu or prompt is open, the window's own shortcuts stand back (`diffOverlayBusy`).
|
||
|
||
#### Closing
|
||
|
||
- **Esc** closes the innermost layer: the menu, then the prompt, then the Diff itself (collapse).
|
||
- **Collapse** button = Esc on the Diff.
|
||
- Closing restores the previous mode (4.5) and puts keyboard focus back in the code.
|
||
|
||
---
|
||
|
||
### 4.9 Copy reference and reference formats (`AgentReference`, `EditorReference`)
|
||
|
||
| Case | Format |
|
||
|---|---|
|
||
| single line | `path:42` |
|
||
| line range | `path:42-58` |
|
||
| whole file / folder (other menus) | `path` (folder: `path/`) |
|
||
|
||
- Path is project-relative.
|
||
- In the code: selection → lines it touches (start line … line containing the selection end); no selection → clicked line (minimum 1).
|
||
- Markdown preview and image: `path:1`.
|
||
- Diff: `path:<line of the clicked side>`, filler/outside → `path:1`.
|
||
- Toast after copy: `Copied reference` with the reference as detail.
|
||
|
||
---
|
||
|
||
### 4.10 Markdown preview (`MarkdownPreviewView`)
|
||
|
||
- Shown when the mode is preview. Read-only, rendered from the **live buffer** (unsaved edits included), re-parsed on every change. Links resolve relative to the file's folder.
|
||
- Scrollable; content column max width **580** (about 68 characters), padding top 18, left 20, bottom 48, right 20, left-aligned. Text selectable and copyable; I-beam pointer over text. Background editor colour. Not affected by zoom.
|
||
- Right-click anywhere: the editor menu with reference `path:1` and no code (Pass on reference, Copy reference). No Read aloud selection, no Plak, no Show diff.
|
||
|
||
#### Block spacing
|
||
|
||
Margins (top, bottom); between two blocks the gap is the larger of the previous bottom and the next top:
|
||
| Block | Top | Bottom |
|
||
|---|---|---|
|
||
| heading | 1.6 × font size | 0.6 × font size |
|
||
| paragraph, list, table | 14 | 14 |
|
||
| quote, code | 16.8 | 16.8 |
|
||
| rule | 22.4 | 22.4 |
|
||
The first block gets top 0, except a heading: 0.2 × its font size.
|
||
|
||
#### Blocks
|
||
|
||
| Block | Rendering |
|
||
|---|---|
|
||
| heading level 1 and 2 | Mono Bold 24 / 26.4, tracking −0.03 em, text1 |
|
||
| heading level 3 | Mono Bold 17 / 20.4, text1, plus a 1 pt raised rule 8 pt under it |
|
||
| heading level 4 | Mono Bold 15 / 18, text1 |
|
||
| heading level 5, 6 | Mono Bold 13 / 16, text1 |
|
||
| paragraph | Sans Regular 14 / 23.8, extra line spacing 5.8, text2; inside a quote: Sans Italic 15, amberSoft |
|
||
| paragraph that is only one image | a block image (below) |
|
||
| fenced code | panel background, radius 2, 1 pt raised border, full width; inner padding 14 vertical, 16 horizontal; code font 13 with 3 pt line spacing; syntax colours of the fence's language (plain if unknown); scrolls sideways (no indicator), never wraps |
|
||
| quote | 2 pt amber rule on the left, 16 pt gap, then the quoted blocks (quotes may nest) |
|
||
| list | items 7 apart; marker then 10 pt gap then the item text (paragraph style); marker amber in body type, min width 12: unordered `—` (em dash), ordered `1.`, `2.`, … counted from 1 by position (the source start number is ignored). Items are single paragraphs (no nesting). |
|
||
| table | sideways scroll; header row cells in panelLabel (UPPERCASE) text4 on panel background; body cells Sans 13 text3; cell padding 10 vertical, 14 horizontal; 1 pt raised hairline above each body row; per-column alignment left / center / right; whole table 1 pt raised border, radius 2, sized to its content |
|
||
| horizontal rule | 1 pt raised line |
|
||
|
||
#### Inlines
|
||
|
||
| Inline | Rendering |
|
||
|---|---|
|
||
| text | body font (Sans 14), or the heading/table-header role font |
|
||
| strong | Sans Medium 14, text1 |
|
||
| emphasis | Sans Italic 14 (emphasis wins over strong for the font) |
|
||
| strikethrough | single strike line |
|
||
| inline code | thin space (U+2009) + code + thin space, code font 13, amberSoft on panel background |
|
||
| link | amber text, clickable |
|
||
| inline image (inside text) | its alt text, path font, text4 |
|
||
In a quote every run uses Sans Italic 15.
|
||
|
||
#### Links
|
||
|
||
- An empty, unsafe, or `#anchor` URL renders as plain text (no link).
|
||
- A local (project-relative) URL becomes a private scheme `helder-file:<percent-encoded path>`; a click opens that file in the editor (normal open rules, including the unsaved-edits prompt).
|
||
- `http`, `https`, `mailto` open in the system browser / mail app. Any other scheme is ignored.
|
||
|
||
#### Block images
|
||
|
||
- Remote URL: loaded asynchronously, scaled to fit the width; the alt text shows while loading or on failure.
|
||
- Local file: read through the file service (image types only, max 25 MB); shown at most at its natural width; the alt text shows until loaded or on failure.
|
||
- Alt text style: path font, text3; an empty alt shows `—`.
|
||
- Corners radius 2.
|
||
|
||
#### Not rendered
|
||
|
||
Task-list checkboxes (`[ ]`, `[x]`), nested lists, raw HTML, setext headings (`===`/`---` underlines). Other limits belong to the parser section.
|
||
|
||
#### ⌘M
|
||
|
||
⌘M (and the Preview button) toggles source ↔ preview on a Markdown file only. Undo history and unsaved edits are kept because the code view stays alive underneath.
|
||
|
||
---
|
||
|
||
### 4.11 PHP symbols: ⌘-hover and ⌘-click (`SymbolService`, `PHPSymbols`, `SymbolModels`, `SymbolPopupView`)
|
||
|
||
#### Building the class index
|
||
|
||
Built lazily on first use; concurrent callers share one build; a build that started before an invalidation is not cached.
|
||
|
||
1. Pass 1: ripgrep (or the fallback directory walk when ripgrep is missing; `RG_BINARY` may point to ripgrep) over `*.php` files, **`vendor/` included**, honouring the base ignore list minus `vendor` (node_modules, .git, out, dist, build, .cache, coverage, .helder, .next, .nuxt, .turbo, .idea, .vscode) plus `files.exclude`. Pattern:
|
||
`^\s*(namespace\s+[A-Za-z_\\][\w\\]*\s*;|(final\s+|abstract\s+|readonly\s+)*(class|interface|trait|enum)\s+\w+)`
|
||
- A `namespace X;` line sets the current namespace of that file (leading backslash removed). Matches arrive per file in line order.
|
||
- A declaration line: `^[ \t]*((final|abstract|readonly)[ \t]+)*(class|interface|trait|enum)[ \t]+([A-Za-z_]\w*)(rest)`. From `rest`: `extends <list>` (up to `implements`, `{` or end) → parents; `implements <list>` (up to `{` or end) → interfaces. Lists are split on commas; each name is reduced to its last `\`-segment and kept only if it is an identifier. Only that single line is read.
|
||
- Record: name, path, line, kind, namespace, parents, interfaces.
|
||
2. Pass 2: pattern `^\s+use\s+[A-Za-z_\\][\w\\ \t,]*[;{]` (an **indented** `use`). Parsed with `^[ \t]+use[ \t]+(names)[ \t]*[;{]`, rejecting `use function` / `use const`. The traits are added (no duplicates) to the nearest declaration above that line in the same file.
|
||
3. Index = name → list of declarations. Logged with the class count and build time.
|
||
4. **Invalidation**: on every project change event the index is dropped; the known-name list is reloaded **2 s** after the last change (each change restarts the countdown). At launch the list loads **1.5 s** after the project opens.
|
||
|
||
The editor's `knownSymbols` = all names in the index. `knownSymbolsVersion` moves only when the set changes, which re-colours the open document.
|
||
|
||
#### ⌘ held: underline and hand
|
||
|
||
- While the text view is first responder and ⌘ is down, every token the PHP grammar marked as a known class name (role "symbol") gets an **amber underline 1 pt high, 3 pt below the baseline**, across its glyph boxes. Released ⌘ or focus lost → underlines go.
|
||
- While ⌘ is held, the pointer turns into a pointing hand over a glyph whose word is a known name. Only a hit on the glyph box counts (not the empty space after a line).
|
||
- Note: the underline only appears in PHP-coloured text, but the hand and ⌘-click accept any word equal to a known name in **any** file.
|
||
|
||
Word under a point: expand over `[0-9A-Za-z_]` from the offset in both directions; must be an identifier (`^[A-Za-z_]\w*$`), else empty.
|
||
|
||
#### ⌘-click
|
||
|
||
- ⌘ + mouse down on a known name: does not move the caret; sets `symbolName`, clears the lookup, presents the popup at once (shows `Searching…`), then runs the lookup and fills it in (a result for an older name is ignored).
|
||
- **Lookup**: a non-identifier returns empty. Definitions = index entries for the name sorted **project files before `vendor/` files, then by path**, capped at **25**. References = word-boundary search for the name in `*.php`, **`vendor/` excluded** (plus base ignores and `files.exclude`); drop lines that are a declaration of the name (path:line in the definitions) and column-0 import lines (`^use[ \t]+[^;]*;?[ \t\r]*$`). Group by file in result order; at most **300** files (later files are dropped, their hits not counted). Each hit keeps its line number, the line text capped at 1000 characters, and the match offset (UTF-16). Reference count = number of kept hits.
|
||
|
||
#### The popup
|
||
|
||
- Centred in the window over a scrim (`#101720` @ 72%); a click on the scrim closes it.
|
||
- Width min(700, 82% of window width); max height min(72% of window height, 640); height fits content.
|
||
- Panel: panel background, radius 8, 1 pt raised border, a 2 pt amber rule along the whole left edge, overlay shadow.
|
||
- **Header** (height 50, padding 18 horizontal, bottom hairline): title Mono Bold 13 text1 = the fully qualified name (`Namespace\Name`) when there is exactly one declaration, else the short name; right side (only after the lookup) `N reference` / `N references` (Mono Regular 10.5, text4).
|
||
- Body while searching: `Searching…` (tooltip type, text4, padding 16×12).
|
||
- Body after the lookup (scrollable, 6 pt bottom padding):
|
||
- Section label `Defined in` (panelLabel → `DEFINED IN`, text4, padding top 14, sides 16, bottom 6).
|
||
- None → `No declaration in this project`.
|
||
- Each definition row (padding 13 horizontal, 4 vertical): type badge, path (path type, text2, head truncation), kind chip (`class` / `interface` / `trait` / `enum`, Mono 10, text4, padding 5 horizontal, 1 pt `#3A424C` border, radius 2), flexible space, line number (meta, text4). Click opens the file at that line.
|
||
- Then, for each definition (after all definition rows), a relations block (padding top 2, left 34, bottom 6, right 13; rows 3 apart): for `extends`, `implements`, `uses` with names: label `EXTENDS` / `IMPLEMENTS` / `USES` (Sans 10, text4, min width 66) then chips (Mono 11, padding 7 horizontal, radius 3, 1 pt raised border). A chip for a known name: text2; on hover amber text, amberTint fill, amberKeycapBorder border, hand pointer; click re-runs the popup for that name. An unknown name: text4, no action.
|
||
- Section label `Used in` (only when there are references).
|
||
- Per file: header row (type badge, path in text3 head-truncated, hit count right in meta text4; padding 13 horizontal, top 8, bottom 2; hand pointer; click opens the file at its first hit). File headers are not keyboard targets.
|
||
- Per hit: line number (searchHit type, right-aligned in 40 pt, amber when highlighted else text5), 12 pt gap, the first 200 characters of the line (searchHit, text3, one line); row height 24, left padding 13.
|
||
- Highlighted row (definition or hit): raised background and a 2 pt amber left rule. Hover highlights.
|
||
- **Keyboard** (the popup takes focus on appear): ↓ / ↑ move through one flat list — all definitions first, then every hit in order — clamped at the ends; Enter opens the highlighted row; Esc closes. The highlight resets to the first row whenever a new lookup arrives and the list scrolls to keep it visible.
|
||
- **Open a row**: close the popup, open the file at that line (unsaved-edits rules apply), reveal it in the Explorer, centre the line and flash it amber for 1 s.
|
||
|
||
---
|
||
|
||
### 4.12 Image files (`ImagePreview`)
|
||
|
||
- Centred, scaled to fit, never larger than its natural size, 24 pt padding, on a checkerboard of 10 pt squares (panel `#18202B` and raised `#232C39`), radius 2, 1 pt raised border. Accessibility label = file name.
|
||
- Unreadable (no bytes, over 25 MB, or not decodable): `Can’t preview this image` (curly apostrophe; body type, text4). While loading: nothing.
|
||
- Read-only. Right-click: editor menu with `path:1`. No Preview/Diff button, no change marks.
|
||
|
||
---
|
||
|
||
### 4.13 Pass on to Agent (`PassOnPanel`, `PassOn.compose`)
|
||
|
||
#### Triggers
|
||
|
||
- Code: `Pass on reference` / `Pass on selection` in the right-click menu; ⌘→ with a selection (anchor = bottom-left of the first line rect of the selection).
|
||
- Markdown preview / image: `Pass on reference` → `path:1`.
|
||
- Diff: inside the overlay (4.8).
|
||
- Other menus (files, folders, git rows, file names) use the same prompt; described elsewhere.
|
||
|
||
#### Placement
|
||
|
||
A full-window transparent catcher (a click on it cancels) with the 460 pt panel at x = clamp(anchor.x, 8, width − 460 − 8), y = clamp(anchor.y + 6, 8, height − 170). Inside the Diff, the anchor is converted to the Diff's own coordinates.
|
||
|
||
#### Panel anatomy (padding 14, items 12 apart, panel background, radius 4, 1 pt raised border, menu shadow)
|
||
|
||
1. Title row: four-point spark glyph 13×13 stroked amber (line width ≈ 0.89, round joins; points on a 16-unit grid: (8,1.5) (9.6,6.4) (14.5,8) (9.6,9.6) (8,14.5) (6.4,9.6) (1.5,8) (6.4,6.4)), title **`Pass on to agent`** (Mono Bold 13, text1), flexible space, an `esc` chip.
|
||
2. Note field: one line, placeholder **`Add a note (optional)…`**, Mono Regular 13, 10 pt inner side inset, height 38, editor background, radius 2, 2 pt amber border, plus a 2 pt focus ring (amber @ 22%, radius 4) around it. The keyboard starts here.
|
||
3. `Inserts` label (panelLabel → `INSERTS`, text4, 5 pt top offset) and the live preview chip: the exact composed text, path type, ink colour on an amber background, radius 2, padding 8×4. Without code: one line, truncated at the tail. With code: multi-line, scrollable, max height 132.
|
||
4. Footer hint (meta type): `↵` `insert into agent`, `esc` `cancel`.
|
||
|
||
#### Keys
|
||
|
||
- **Enter**: insert the composed text and close.
|
||
- **Esc**: cancel, nothing inserted.
|
||
|
||
#### Composed text (`PassOn.compose(note, reference, code)`)
|
||
|
||
The note is trimmed of whitespace and newlines.
|
||
| Case | Result |
|
||
|---|---|
|
||
| no code, empty note | `<reference>` |
|
||
| no code, note | `<note> => <reference>` |
|
||
| code, empty note | `<reference>` + `\n` + ```` ``` ```` + `\n` + `<code>` + `\n` + ```` ``` ```` |
|
||
| code, note | `<note> <reference>` + the same fenced block |
|
||
|
||
#### Insert
|
||
|
||
The workspace closes the overlay, inserts the text into the agent terminal's input as a bracketed paste (never submitted; if the composer already holds text, the paste starts with a newline; ESC and 8-bit CSI characters are stripped from the payload), and shows toast **`Passed to agent`** with the reference as detail. Focus stays where it was.
|
||
|
||
---
|
||
|
||
### 4.14 Session restore (`SessionState`, `EditorStore.restore/persist`)
|
||
|
||
- Stored per project under key `helder.session:<root>` as JSON: `active` (path), `tabMode` (path → mode raw value), `tabSide` (path → `staged`/`unstaged`). Only the **active** file's mode and side are written. Unknown mode strings are dropped on read.
|
||
- On project open: the recent-files list is always loaded. Only when `session.restoreOnLaunch` (default true): stored modes are applied (`diff` comes back as `actual`), sides are applied, the active file is reopened (unless it is `composer.lock`) and read from disk with disk winning.
|
||
- Nothing is written before the saved session was read. Writes happen after open, close, mode change, rename, delete.
|
||
- **Not restored**: scroll position, caret, selection, undo history, the Diff overlay. Scroll and caret survive only in the in-memory cache of 12 documents while the app runs.
|
||
|
||
---
|
||
|
||
### 4.15 Show diff rules (summary)
|
||
|
||
- Offered only in the code's right-click menu, only when: paneMode is actual, the file has a git diff, the file is not Added, and the right-clicked row belongs to a line with any mark (tinted added line or gap-ruled line). Blank lines and the area after the last glyph count.
|
||
- Not offered: unchanged lines, unchanged files, new files, Preview, images, the Diff's own menu.
|
||
- A left click on a marked line only places the caret.
|
||
- It opens the Diff on HEAD vs disk (side nil), centred on that line as near as the file permits.
|
||
|
||
---
|
||
|
||
### 4.16 Every user-visible string in this section
|
||
|
||
`Too big.` · `No file open` · `Open folder` · `Recent projects` · `Search files & content` · `⌘O` · `⇧⌘O` · `⌘F` · `Unsaved changes` (accessibility) · `+N` · `−N` · `Preview` · `Diff` · `This file cannot be displayed` · `No updated version` · `This file was deleted in the change.` · `Can’t preview this image` · `Image` (status bar language) · `Spaces: N` · `Save changes to <name>?` · `<path> has unsaved edits. They are lost if you close without saving.` · `Save` · `Don’t Save` · `Cancel` · `Saved` · `Save failed` · `Close File` / `Close` (menu) · `Pass on reference` · `Pass on selection` · `Copy reference` · `Read aloud selection` · `Plak` · `Show diff` · `Copied reference` · `Passed to agent` · `Original` · `before` · `Actual` · `after` · `Added` · `Modified` · `Deleted` · `staged → actual` · `HEAD → staged` · `Collapse` · `Esc` · `— No changes to compare.` · `Pass on to agent` · `Add a note (optional)…` · `Inserts` · `↵ insert into agent` · `esc cancel` · `Searching…` · `N reference` / `N references` · `Defined in` · `No declaration in this project` · `extends` / `implements` / `uses` (shown uppercase) · `class` / `interface` / `trait` / `enum` · `Used in` · `—` (list marker, empty alt) · menu items `Actual Size`, `Zoom In`, `Zoom Out`, `Save`, `Refresh`.
|
||
|
||
---
|
||
|
||
### 4.17 Docs versus code (code wins)
|
||
|
||
| Topic | Docs say | Code does |
|
||
|---|---|---|
|
||
| Editor settings | behaviour.md: indentation, trim trailing whitespace, insert final newline, indent guides, whitespace rendering, active-line highlight and `editor.lineNumbers` (absolute/relative/off) are configurable | Only `editor.autoSave`, `editor.tabSize`, `editor.wordWrap` exist. No trimming, no final-newline insertion, no indent guides, no whitespace marks, no active-line highlight in the editable view, numbers always absolute. (file-view.md agrees with the code.) |
|
||
| Default diff mode | behaviour.md: a changed file opens on the Diff when `git.defaultDiffMode` is `diff` | Opening always sets Actual (or Code); the default only matters for a file with no stored mode. file-view-diff.md admits this. |
|
||
| Editor right-click | behaviour.md lists `Copy reference` first and calls the other item `Pass on to Agent` | Order is `Pass on reference`/`Pass on selection` first, then `Copy reference`; the item label is `Pass on …`. |
|
||
| Pass-on composition | behaviour.md: "the typed text followed by the same reference" | Note + ` => ` + reference without code; note + space + reference + fenced code block with a selection. |
|
||
| Diff "no changes" | `No changes to compare.` | `— No changes to compare.` (em dash prefix). |
|
||
| Diff which-half label | `HEAD -> staged`, `staged -> actual` | Uses the arrow `→`. With side nil (Show diff, which compares HEAD vs disk) on a file with both rows, the label still reads `HEAD → staged`, which does not match the pair shown. |
|
||
| Zoom step | about 10% per step | 1.2^0.5 ≈ 9.5% per half step, level clamped −3…+5 (scale ≈ 0.58–2.49). |
|
||
| Session restore | (task brief) scroll and caret restore | Only active file, its mode and side; scroll/caret only in the in-memory 12-document cache. |
|
||
| Ordered lists | numbered items | Numbers by position from 1; the source start number is ignored. |
|
||
| ⌘-click scope | "class names in PHP" | Underline only in PHP, but the hand and ⌘-click work on any word equal to a known class name in any text file. |
|
||
| Symbol relations | relations shown under each declaration | All relation blocks are drawn after all definition rows (only differs with several declarations). |
|
||
| Deleted from disk while open | text stays as unsaved edits | True, but if git tracks the file it now has status Deleted, so the pane shows the `No updated version` placeholder over the kept buffer (save still writes it back). |
|
||
| Gutter click + reference | click a number selects the line | The selection includes the newline, so a reference from it names two lines (`path:5-6`). |
|
||
| TODO file item 1 | pointer flicker with the menu open over a changed file | Still open in the TODO; items 2 (Show diff via right-click) and 3 (no header on the editor menu) are built as described above. |
|
||
|
||
|
||
---
|
||
|
||
## 5. Syntax highlighter, Markdown parser, MarkdownSpeech and Read aloud
|
||
|
||
This section specifies the custom syntax highlighter (no third-party library), its ten grammars, the Markdown block/inline parser used by the Preview, the text-to-prose conversion used by Read aloud, and the speech service. Everything here is pure logic except the speech service. Rebuild it to produce the **same token ranges** and the **same parse trees**; the acceptance examples at the end of each part come from the Swift test suite and must all pass.
|
||
|
||
Source files: `Sources/HelderCore/Highlight/*.swift`, `Sources/HelderCore/Markdown/*.swift`, `Sources/HelderCore/Files/FileType.swift`, `Sources/HelderServices/Speech/SpeechService.swift`, `Sources/HelderUI/State/ReadAloudStore.swift`, plus callers in `HelderUI` (`CodeDocument`, `HighlightDiff`, `DiffCanvas`, `MarkdownPreviewView`, `WorkspaceModel+ContextActions`, `ContextActions`).
|
||
|
||
---
|
||
|
||
### 5.1 Token roles and colours
|
||
|
||
The highlighter paints every character with one of seven roles (`TokenRole`, `SyntaxHighlighter.swift`). The design has six colours; `symbol` shares the plain colour and is only special for ⌘-click.
|
||
|
||
| Role (`TokenRole`) | Used for (general meaning) | Palette token (`Palette.syntax…` / `EditorColors.syntax`) | Hex |
|
||
|---|---|---|---|
|
||
| `plain` | plain text, function names, punctuation | `syntaxPlain` | `#E4E7E6` |
|
||
| `variable` | variables, properties, attribute names, class names (not yet known) | `syntaxVariable` | `#BAC0C0` |
|
||
| `comment` | comments, Markdown punctuation (fences, list/quote markers, rules) | `syntaxComment` | `#6C7783` |
|
||
| `keyword` | keywords, operators, pseudo-classes, headings, YAML keys | `syntaxKeyword` | `#C3A6CE` |
|
||
| `string` | strings, values, namespace/type paths | `syntaxString` | `#8FBFB4` |
|
||
| `number` | numbers, tags/element names, constants, builtins, hex colours | `syntaxNumber` | `#F0B476` |
|
||
| `symbol` | a PHP class name that is in the project's known-symbol set | `syntaxPlain` (same as plain) | `#E4E7E6` |
|
||
|
||
- `symbol` is drawn in the plain colour; while ⌘ is held (and the known-symbol set is non-empty) the editor underlines every `symbol` range, and a ⌘-click on one opens the symbol lookup. Only the PHP grammar ever emits `symbol`.
|
||
- Code is drawn flat: 13 pt IBM Plex Mono 400, never bold or italic, on the editor background `#101720`. (Font and layout belong to the editor section; listed here only so colours are not mis-applied.)
|
||
|
||
#### Token output contract (`SyntaxHighlighter.tokens`)
|
||
|
||
- A token is `(location, length, role)`; **location and length count UTF-16 code units** (so an emoji counts 2). Offsets must line up with the text view's own indexing.
|
||
- The returned list **tiles the whole text end to end**: every unit is covered exactly once, in order, no zero-length tokens; gaps between painted tokens are filled with `plain` runs.
|
||
- **Adjacent runs of the same role are merged.** Internally, `emit(from, to, role)` drops empty ranges and `plain` emits, and extends the previous token when it has the same role and ends exactly at `from`. The fill step then inserts `plain` gaps; a token that would overlap the previous one is clipped to start at the current position, and tokens are clipped to the text length.
|
||
- Empty text → empty list. Unknown language (`nil`) → one `plain` token over the whole text (none if empty).
|
||
|
||
---
|
||
|
||
### 5.2 Extension → grammar map
|
||
|
||
`FileType.ext(path)`: the basename's text after the last `.`, lowercased; any basename starting with `.env` (e.g. `.env`, `.env.local`, `.env.example`) returns `env`. No dot → `""`.
|
||
|
||
`FileType.language(for:)` (enum `Language`: `php, javascript, jsx, typescript, tsx, python, markup, css, json, markdown, bash, yaml`):
|
||
|
||
| Extension | Language | Grammar used |
|
||
|---|---|---|
|
||
| `php` (also `*.blade.php`, since ext is `php`) | `php` | `phpTemplate` if the text contains `<?`, else `php` (see 5.4) |
|
||
| `js`, `mjs`, `cjs` | `javascript` | JavaScript (TS off, JSX off) |
|
||
| `jsx` | `jsx` | JavaScript (TS off, JSX on) |
|
||
| `ts` | `typescript` | JavaScript (TS on, JSX off) |
|
||
| `tsx` | `tsx` | JavaScript (TS on, JSX on) |
|
||
| `py` | `python` | Python |
|
||
| `html`, `xml`, `svg`, `vue` | `markup` | Markup |
|
||
| `css`, `scss` | `css` | CSS (also covers SCSS) |
|
||
| `json` | `json` | JSON (comments allowed) |
|
||
| `md` | `markdown` | Markdown |
|
||
| `sh`, `bash`, `env` | `bash` | Shell |
|
||
| `yml`, `yaml` | `yaml` | YAML |
|
||
| anything else | none | not highlighted (all plain) |
|
||
|
||
Notes:
|
||
- `FileType.isMarkdown(path)` is true only for ext `md` (this gates the Preview and Read aloud). `.markdown` files are **not** Markdown for the app.
|
||
- `svg` is also an image extension, so the viewer shows SVGs as pictures; the markup grammar applies only where the text is shown.
|
||
- `pcss`, `sql`, `txt`, `lock` have badges but no grammar.
|
||
|
||
Status-bar language label (`FileType.languageLabel`), for completeness: `php`→PHP, `js`/`mjs`/`jsx`→JavaScript, `ts`/`tsx`→TypeScript, `py`→Python, `html`→HTML, `css`→CSS, `json`→JSON, `md`→Markdown, `sh`→Shell, `env`→Dotenv, `yml`/`yaml`→YAML; otherwise the ext uppercased, or `Plain Text` when there is no ext. (Note `cjs` is not in the label map → `CJS`.)
|
||
|
||
#### Fence info string → grammar (`MarkdownParser.fenceLanguage`)
|
||
|
||
Lookup is on the info word **lowercased**; unknown or empty → no grammar (plain).
|
||
|
||
| Info word | Language |
|
||
|---|---|
|
||
| `php` | php (always pure PHP inside a fence: the grammar is chosen with empty text, so never `phpTemplate`) |
|
||
| `js`, `javascript`, `mjs` | javascript |
|
||
| `jsx` | jsx |
|
||
| `ts`, `typescript` | typescript |
|
||
| `tsx` | tsx |
|
||
| `py`, `python` | python |
|
||
| `html`, `xml`, `vue` | markup |
|
||
| `css`, `scss` | css |
|
||
| `json` | json |
|
||
| `sh`, `bash`, `shell` | bash |
|
||
| `yml`, `yaml` | yaml |
|
||
| `md`, `markdown` | markdown |
|
||
|
||
Examples: `fenceLanguage("TS") == typescript`, `fenceLanguage("shell") == bash`, `fenceLanguage("") == nil`.
|
||
|
||
---
|
||
|
||
### 5.3 The lexer engine
|
||
|
||
#### 5.3.1 Line-by-line model
|
||
|
||
- The buffer is converted to an array of UTF-16 units. It is split into **lines at LF (unit 10) only**. A CR (13) stays inside the line and is treated as whitespace, so CRLF files work unchanged. The newline unit itself is never part of any line's scan (it gets plain fill).
|
||
- Lines are scanned in order. The loop runs `while lineStart <= count`, so **an empty final line after a trailing newline is also scanned** (it may change state, e.g. close nothing, but must be visited for parity with the line API).
|
||
- One `Lexer` (cursor) is shared across the whole buffer: fields `u` (all units of the buffer), `i` (cursor), `end` (end of the current line, exclusive), `stop` (an optional terminator, see 5.3.4), `symbols` (known PHP class names), `tokens` (output). For each line the driver sets `i = lineStart`, `end = lineEnd` and calls the grammar. Grammars must never read past `end` (helper `peek(k)` and `unit(at:)` return 0 outside `[0, end)`; note `unit(at:)` also returns 0 for negative indices but **can** read earlier lines of the buffer because `u` is the whole buffer — the Python decorator check depends on that, see 5.10).
|
||
- **State carried from one line to the next** is a `HighlightState` = the chosen grammar + a `GrammarState`. Everything else a grammar keeps (e.g. "the next name is a class", "a `/` here starts a regex") is local to one line and resets at each line start.
|
||
|
||
#### 5.3.2 `GrammarState` (carried across lines)
|
||
|
||
| Field | Meaning |
|
||
|---|---|
|
||
| `mode` | the open construct at the line break (table below); `code` when none |
|
||
| `depth` | brace depth: CSS nesting depth, or the braces inside a JS `${…}` / JSX `{…}` expression |
|
||
| `resumes` | stack of `(depth, mode)`: for each open `${` or JSX `{`, the brace depth at which its closing `}` ends it and the mode to return to |
|
||
| `child` | an embedded grammar: `(grammar, its own GrammarState, terminator)` |
|
||
|
||
Modes (`Mode`):
|
||
|
||
| Mode | Used by | Meaning |
|
||
|---|---|---|
|
||
| `code` | all | not inside any construct |
|
||
| `blockComment` | JS, PHP, CSS, JSON | inside `/* … */` |
|
||
| `quoted(quoteChar)` | PHP, Shell | inside a string that runs over lines |
|
||
| `template` | JS | inside a template literal |
|
||
| `triple(quoteChar)` | Python | inside `'''…'''` / `"""…"""` |
|
||
| `heredoc(id, interpolates)` | PHP, Shell | inside a heredoc body; `interpolates` false for PHP nowdoc and quoted shell markers |
|
||
| `markupComment` | Markup | inside `<!-- … -->` |
|
||
| `cdata` | Markup | inside `<![CDATA[ … ]]>` |
|
||
| `markupTag(name)` | Markup | inside `<name …` before its `>`; name lowercased; closing tags stored as `"/" + name` |
|
||
| `markupValue(quote, tag)` | Markup | inside a quoted attribute value |
|
||
| `jsxTag(level, closing)` | JS (JSX) | inside a JSX tag's attributes; `level` = elements open around it |
|
||
| `jsxText(level)` | JS (JSX) | JSX children text inside `level` open elements |
|
||
| `cssValue` | CSS | a declaration value that did not end on its line |
|
||
| `yamlBlock(indent)` | YAML | inside a `|` / `>` block scalar; holds the indent of its key line |
|
||
| `fence(marker, count)` | Markdown | inside a fenced code block closed by ≥`count` × `marker` |
|
||
|
||
`HighlightState.isInsideConstruct` = `mode != code || child != nil || resumes non-empty`. Two `HighlightState`s compare equal field by field (grammar + full GrammarState, recursively including the child's state) — this equality is what an incremental re-highlighter compares.
|
||
|
||
#### 5.3.3 Grammar selection (`Grammar` init from `Language` + text)
|
||
|
||
| Language | Grammar |
|
||
|---|---|
|
||
| nil | none |
|
||
| php | `phpTemplate` (markup with PHP islands) **if the text contains `<?`**, else `php` |
|
||
| javascript / jsx / typescript / tsx | `javascript(typescript, jsx)` with flags (false,false) / (false,true) / (true,false) / (true,true) |
|
||
| markup, css, json, markdown, bash, python, yaml | the same-named grammar |
|
||
|
||
The `text` passed is the whole buffer for `tokens(for:)`, the single line for `lineTokens(for:language:)`, and `""` for a Markdown fence. Consequence: in the diff panes (one line at a time), **each PHP line picks its grammar separately** — a line containing `<?` is markup-with-islands, any other line is pure PHP.
|
||
|
||
#### 5.3.4 Embedding (`Grammars.scan`) and terminators
|
||
|
||
An embedded grammar runs inside a host. Terminators (`Terminator`):
|
||
|
||
| Terminator | Set by | `atStop()` is true when |
|
||
|---|---|---|
|
||
| `phpClose` | markup opening a `<?php` / `<?=` / `<?` island | the cursor is at `?>` |
|
||
| `closingTag(name)` | markup `<script>` → JavaScript, `<style>` → CSS | the cursor is at `</` followed by `name` (ASCII case-insensitive) |
|
||
| `fence` | Markdown fence with a known language | never (the Markdown grammar checks the closing fence itself, per line) |
|
||
|
||
Driver for one line, `scan(grammar, lexer, state)`:
|
||
|
||
1. Loop:
|
||
- If `state.child` exists and its terminator is not `fence`: save the lexer's `stop`, set `stop = child terminator`, run the child grammar (recursively through this same driver, with the child's state), restore `stop`.
|
||
- If the cursor reached the line end: store the child's updated state back into `state.child` and return.
|
||
- Otherwise the child stopped at its terminator. If the terminator is `phpClose`, emit the two units `?>` as `keyword` and advance 2. (For `closingTag` nothing is consumed; the host's own tag handling paints `</script`.) Clear `state.child`.
|
||
- If the cursor is at line end, return.
|
||
- Run the host grammar's own scanner (`scanOwn`).
|
||
- If afterwards `state.child` is set with a non-`fence` terminator, loop again (the child takes over mid-line); otherwise return.
|
||
2. Grammars that can be embedded check `if stop != nil && atStop() { return }` **only at "code" positions** (the start of a token in code mode). Strings, comments, template bodies etc. do not check the stop; e.g. `"?>"` inside a PHP string does not close the island. Exception: a **line comment** (`//`, `#`) with a stop set runs only up to the stop (so `<?php // note ?> after` ends the comment before `?>`, and `<script>// x</script>` ends the comment before `</script`). Without a stop, line comments run to the line end.
|
||
3. Grammars that check the stop: JavaScript, PHP, CSS, Markup. JSON, Python, Shell, YAML and Markdown never run as embedded-with-terminator children (only inside Markdown fences, which have no stop).
|
||
|
||
#### 5.3.5 Character classes (`Unit`)
|
||
|
||
All tests are on UTF-16 units.
|
||
- digit `0-9`; upper `A-Z`; lower `a-z`; alpha = upper or lower (ASCII only); hex digit = digit or `a-f`/`A-F`.
|
||
- **identStart** = ASCII letter, `_`, or **any unit ≥ 0x80** (so non-ASCII letters, surrogate halves of emoji, accented letters all count as identifier letters and stay in one token). identPart = identStart or digit. `$` is **not** identPart (JS adds it explicitly).
|
||
- **space** = space (32), tab (9), CR (13), form feed (12), vertical tab (11). (Not LF — LF never occurs inside a line. Not NBSP.)
|
||
- **operator** set (`Unit.isOperator`): `+ - * / % = & | ^ ! ~ < > ? :`.
|
||
- `lower(c)` lowercases ASCII only; case-insensitive literal matches compare against a lowercase literal.
|
||
|
||
#### 5.3.6 Shared lexer helpers (`Lexer`)
|
||
|
||
| Helper | Behaviour |
|
||
|---|---|
|
||
| `identifier(extra)` | advance while identPart or `extra(c)` |
|
||
| `skipSpaces()` / `nextNonSpace(from)` | skip space units / first non-space unit from a position, or 0 |
|
||
| `lineComment()` | from cursor to line end (no stop) or to the first position where `atStop()` (with stop); emits `comment` |
|
||
| `blockComment(from: start, close)` | advance until the `close` literal; if found, consume it, emit `comment` from `start`, return true; if the line ends first, emit `comment` from `start` to line end, return false (caller then sets the multi-line mode) |
|
||
| `quoted(from: start, quote, escapes = true, role = string)` | advance; if `escapes` and the unit is `\`, skip 2 units; a unit equal to `quote` closes (included). Returns true when closed. If the line ends first, clamp the cursor to the line end (an escape at the very end never runs past it), emit, return false. Emits `role` from `start` (the opening quote is included because callers pass the quote position). |
|
||
| `number()` | see below; emits `number` |
|
||
| `operatorRun(isOp = Unit.isOperator)` | consume a run of operator units; emit `keyword` |
|
||
|
||
`number()`:
|
||
1. If the unit is `0` and the next unit is one of `x X o O b B`: consume both, then consume hex digits and `_` (the same set for hex, octal and binary).
|
||
2. Else consume digits and `_`; then if `.` followed by a digit, consume `.` and digits/`_`; then if `e`/`E` followed by a digit, or by `+`/`-` and a digit, consume those 2 units and the following digits.
|
||
3. Finally consume any trailing ASCII letters (suffixes such as `n`, `f`, `px`).
|
||
4. Emit `number` over the whole run.
|
||
|
||
Acceptance (Lexer tests): each of `0x1F`, `0b1010`, `1_000_000`, `3.14`, `1e10`, `2.5E-3`, `10n` followed by ` rest` is consumed exactly and emitted as one `number` token of that length. `'abc` with cursor after the quote: not closed, cursor ends at 4. `'ab\` : not closed, cursor 4 (never past the end). Emitting `keyword` 0–2 then 2–4 yields one token 0–4. `é` and both halves of `😀` are identStart/identPart; `-` is not identStart.
|
||
|
||
#### 5.3.7 Public API and how the app uses it
|
||
|
||
| API | Behaviour |
|
||
|---|---|
|
||
| `tokens(for text, language, knownSymbols = [])` | whole buffer, state carried line to line, filled and merged |
|
||
| `lineTokens(for line, language, knownSymbols)` | one line on its own with a fresh state (grammar chosen from that line's text); used by the **diff panes**, where every line stands alone (`" end */ let x"` in JS gives a keyword and no comment) |
|
||
| `lineTokens(for line, state: inout, knownSymbols)` | one line (without its newline) from a given state; advances the state. Contract: scanning a buffer line by line with carried state gives exactly the same non-plain tokens (offset by the line starts) as `tokens(for:)` on the whole buffer. |
|
||
| `HighlightState(language:, text:)` | initial state; `isInsideConstruct`; equality |
|
||
|
||
Incremental re-highlighting — **what the code actually does** (`CodeDocument`, `HighlightDiff`):
|
||
- The editor does **not** use the per-line state API. On file load, language change or known-symbols change it re-tokenises the whole buffer (`highlightAll`). After each edit it waits **40 ms** (debounce), then re-tokenises the **whole buffer** on a background thread with `tokens(for:)`. A generation counter discards results that a newer edit has superseded; results are also discarded if the buffer length changed meanwhile.
|
||
- Only the colours that may have changed are repainted: `HighlightDiff.repaintRange(old, new, edited, delta, newLength)`:
|
||
1. `editedEndOld = editedEnd − delta`.
|
||
2. Common prefix: count leading tokens equal in old and new **and** ending at or before `edited.location`.
|
||
3. Common suffix (among the rest): count trailing pairs where the old token starts at or after `editedEndOld`, `old.location + delta == new.location`, same length and same role.
|
||
4. Start with `[edited.location, editedEnd)`. For each old token in the middle: start = min(start, its location if before the edit, else location + delta); end = max(end, its end + delta if it ends after `editedEndOld`, else min(its end, edited.location)). For each new token in the middle: widen to cover it.
|
||
5. Clamp to `[0, newLength]`. Repaint: set plain colour over the range, then the colour of each non-plain token intersecting it. An opened block comment therefore repaints everything after it.
|
||
- Unknown language: the full range is painted plain.
|
||
- The Markdown Preview highlights each fenced code block's text with `tokens(for: codeText, language:)` (only when the fence's language is known; otherwise plain). The PHP grammar in a fence is chosen with the block's own text (`Grammar(.php, text: code)`) in the Preview — so a fenced PHP block containing `<?` is markup-with-islands in the Preview, while the same block inside the Markdown *source* view uses pure PHP (5.3.3). Keep this difference.
|
||
- Performance requirement: linear in text length; a ~5,000-line PHP file must tokenise in well under one second even unoptimised. Every branch of every grammar must advance the cursor (no hangs on hostile input such as `<?php "'`/*<!--<<<EOT\n${{[(\\\n\0é😀\t\r\n?> </script> ``` ---\n` followed by 20 backslashes; the token lengths must sum to the text length for every language).
|
||
|
||
---
|
||
|
||
### 5.4 PHP grammar (`PHPGrammar`)
|
||
|
||
#### Keywords (matched **lowercased**: PHP keywords are case-insensitive)
|
||
|
||
```
|
||
abstract and array as break callable case catch class clone const
|
||
continue declare default die do echo else elseif empty enddeclare
|
||
endfor endforeach endif endswitch endwhile enum eval exit extends
|
||
final finally fn for foreach from function global goto if
|
||
implements include include_once instanceof insteadof interface isset list
|
||
match namespace new or parent print private protected public readonly
|
||
require require_once return self static switch throw trait try unset
|
||
use var while xor yield
|
||
int float string bool void mixed never iterable object
|
||
```
|
||
|
||
- Constants (lowercased match): `true false null` → `number`.
|
||
- Class introducers (next name is a class): `class interface trait enum extends implements instanceof insteadof new`.
|
||
- Scope keywords: `self static parent` → always `keyword` (even before `::`).
|
||
- Open tags: `<?php` (case-insensitive), `<?=`, `<?` (tried in that order).
|
||
|
||
#### Line-local flags
|
||
|
||
`classNext`, `namespaceNext`, `afterArrow`, `afterDoubleColon` — all false at line start.
|
||
|
||
#### Scan (code mode), in order of precedence
|
||
|
||
First, if `mode` is not `code`: `blockComment` → continue the comment (close `*/` → `code`); `quoted(q)` → continue an interpolated string from the line start (interpolates unless `q` is `'`); `heredoc(id, interp)` → heredoc line (below). Then the stop check. Whitespace is skipped (does not reset flags).
|
||
|
||
| Input at cursor | Action |
|
||
|---|---|
|
||
| `#[` | consume 2 (plain), `classNext = true` (the attribute name reads as a class) |
|
||
| `#` | line comment |
|
||
| `//` | line comment |
|
||
| `/*` | block comment; unclosed → mode `blockComment` |
|
||
| `'`, `"`, `` ` `` | string via `interpolated` (interpolates unless `'`); unclosed → mode `quoted(q)` |
|
||
| `<<<` | heredoc start |
|
||
| `<?` | open tag (`<?php`/`<?=`/`<?`) → `keyword` |
|
||
| `?>` | `keyword` (pure-PHP mode; in an island the stop check fires first) |
|
||
| `$` followed by identStart or `$` | consume all `$`, then identifier → `variable` (`$x`, `$$x`) |
|
||
| digit, or `.` + digit | number |
|
||
| `->` or `?->` | `keyword`; `afterArrow = true` (skip the flag reset) |
|
||
| `::` | `keyword`; `afterDoubleColon = true` (skip the flag reset) |
|
||
| identStart, or `\` + identStart | name (below) |
|
||
| operator, `.` or `@` | operator run over operators + `.` + `@` → `keyword` |
|
||
| anything else | skip 1 |
|
||
|
||
After every handled token except the two `continue` cases (`->`/`?->`, `::`) and `#[`, both `afterArrow` and `afterDoubleColon` are reset to false.
|
||
|
||
#### Names (`name`)
|
||
|
||
1. Scan the name: identPart units, and `\` followed by identStart (each such `\` starts a new segment; `lastSegment` = start of the final segment).
|
||
2. If the next unit is `\` (a group import, `use App\Models\{A, B}`): consume that `\`, paint the whole name including it as `string`, return.
|
||
3. `qualified` = there was at least one `\` segment boundary.
|
||
4. If `namespaceNext`: paint the whole name `string`, clear `namespaceNext`, return.
|
||
5. Paint the prefix `[start, lastSegment)` as `string` (the namespace path, including the trailing backslash).
|
||
6. Let `word` = last segment; `callsNext` = next non-space unit is `(`.
|
||
7. If `afterArrow`: the segment is `plain` if `callsNext` (method call), else `variable` (property). Return.
|
||
8. If `afterDoubleColon`: `class` (any case) → `keyword`; else if not `callsNext` and it is a constant name → `number`; else plain. Return.
|
||
9. If not qualified: lowercased in constants → `number`, return; in scope keywords → `keyword`, return; in keywords **and not immediately followed by `::`** → `keyword`, `classNext = word in introducers`, `namespaceNext = (word == "namespace")`, return.
|
||
10. `followedByScope` = the next two units are exactly `::` (no space). `isConstant` = constant name (≥2 units, first is `A-Z`, no `a-z` anywhere). `looksLikeClass` = first unit uppercase, not a constant, not `callsNext`.
|
||
11. If `classNext` or `followedByScope` or `looksLikeClass` → `symbol` if `word` is in the known-symbols set, else `variable`. Else if `isConstant` and not `callsNext` → `number`. Else plain (function names, lowercase identifiers).
|
||
12. `classNext = false`.
|
||
|
||
#### Interpolated strings (`interpolated(start, close, interpolates)`)
|
||
|
||
- `\` skips 2 units (only when `close != 0`, i.e. not in heredoc bodies) — applies to single quotes too.
|
||
- The `close` unit ends the string (included) → return true.
|
||
- If interpolating: `$` + identStart → paint the string so far, then `$name` plus optionally one `->prop` (only if identStart follows `->`) as `variable`. `{$` → paint the string so far, then consume up to the matching `}` counting `{`/`}` depth → whole `{$…}` as `variable`.
|
||
- Line end → paint the rest as `string`, return false.
|
||
|
||
#### Heredoc / nowdoc
|
||
|
||
- Start at `<<<`: skip spaces; optional `'` or `"`; then the identifier (identPart units). If no identifier: paint `<<<` as `keyword`, advance 3. Else consume an optional matching closing quote, paint the whole marker `<<<"ID"` as `string`, mode `heredoc(id, interpolates: quote != ')`. Note: the **rest of the opening line** is then treated as heredoc body (painted as string).
|
||
- Each body line: skip leading spaces; if the line then starts with `id` and the next unit is not identPart → closing marker: paint from the line start through the marker as `string`, mode `code`, and the rest of the line (e.g. `;`) is scanned as code. Otherwise the whole line is a body: `interpolated(close: 0)` (no backslash escapes; `$var` and `{$…}` interpolate when allowed).
|
||
|
||
#### PHP template (`phpTemplate`)
|
||
|
||
The Markup grammar with PHP islands (5.6). `<?php`, `<?=` or `<?` anywhere in text, inside a tag, or inside a quoted attribute value starts an island: the open tag is painted `keyword`, then the PHP grammar runs as a child until `?>` (painted `keyword`).
|
||
|
||
#### Acceptance examples (PHP)
|
||
|
||
Sample:
|
||
```
|
||
<?php
|
||
namespace App\Domain;
|
||
|
||
use Illuminate\Support\Str;
|
||
|
||
#[Attribute]
|
||
final class Agent extends Model implements HasLabel
|
||
{
|
||
use HasFactory;
|
||
public const STATUS_ACTIVE = 'active';
|
||
|
||
public function label(?string $prefix = null): string
|
||
{
|
||
// line comment
|
||
return Str::upper("{$this->name} $prefix") . self::STATUS_ACTIVE . 0x1F;
|
||
}
|
||
}
|
||
```
|
||
- `<?php`, `final`, `function`, first `string` → keyword.
|
||
- `App\Domain` → string; `Illuminate\Support\` → string.
|
||
- `Agent`, `Model`, `HasLabel`, `HasFactory`, `Attribute`, `Str` → variable; each becomes `symbol` when its name is in the known-symbols set.
|
||
- `$prefix` → variable; both `STATUS_ACTIVE` → number; `null` → number; `0x1F` → number.
|
||
- `{$this->name}` → variable (one run); `// line comment` → comment.
|
||
- `<?php $a->save(); $a->name;` → `save` plain, `name` variable, `->` keyword.
|
||
- `<?php $a = "hi $name!"; $b = 'hi $name';` → `"hi ` string, first `$name` variable, `'hi $name'` one string.
|
||
- `<?php # hash\n$a;` → `# hash` comment. `<?php /* one\n two */ $x;` → `two */` comment, `$x` variable.
|
||
- `<?php $sql = "select *\n from users\n where id = 1";\n$next = 2;` → ` from users` string; `$next` variable.
|
||
- `<?php\n$a = <<<EOT\n Hello $name\n EOT;\n$b = <<<'RAW'\n $raw\nRAW;\n$c = 1;` → ` Hello ` string, `$name` variable, `$raw` string (nowdoc), `$c` variable, first `1` number.
|
||
- Template `<div class="<?= $cls ?>">\n<?php if ($x): ?>\n <b>hi</b>\n<?php endif; ?>\n</div>` → `div` number, `$cls` variable, `?>` keyword, `if` keyword, `hi` plain, `endif` keyword.
|
||
- `<p><?php // note ?> after</p>` → `// note ` comment, `?>` keyword, `after` plain.
|
||
- Blade without `<?`: `@if($user)\n {{ $user->name }}\n@endif` → `$user` variable (pure PHP).
|
||
- `<?php static::make(); self::X; parent::boot(); Carbon::now();` → `static`, `self`, `parent` keyword; `Carbon` symbol when known.
|
||
- `<?php new \App\Models\Agent();` → `\App\Models\` string, `Agent` symbol when known.
|
||
- `<?php $a = NEW Foo;` → `NEW` keyword.
|
||
|
||
---
|
||
|
||
### 5.5 JavaScript / TypeScript / JSX grammar (`JavaScriptGrammar`)
|
||
|
||
#### Word lists (case-sensitive)
|
||
|
||
Keywords (always):
|
||
```
|
||
as async await break case catch class const continue debugger
|
||
default delete do else enum export extends finally for from
|
||
function get if implements import in instanceof interface let new
|
||
of package private protected public return set static super switch
|
||
this throw try typeof var void while with yield
|
||
```
|
||
TypeScript-only keywords (when `typescript`):
|
||
```
|
||
abstract declare is keyof module namespace readonly type infer
|
||
satisfies override unique asserts accessor
|
||
```
|
||
TypeScript builtins (when `typescript`) → `number` colour:
|
||
```
|
||
string number boolean any void never unknown object symbol bigint
|
||
```
|
||
(`void` is also a keyword; the keyword check comes first, so it is a keyword.)
|
||
|
||
Constants → `number`: `true false null undefined NaN Infinity`.
|
||
Class introducers: `class extends implements new instanceof interface`.
|
||
Value keywords (after which `/` divides): `this super`.
|
||
|
||
#### Line-local flags
|
||
|
||
`expectsValue = true` (a `/` here starts a regex, a `<` may start JSX), `classNext = false` — reset at every line start.
|
||
|
||
#### Scan
|
||
|
||
Mode dispatch first: `blockComment` → continue to `*/`; `template` → template text (then `expectsValue = false`); `jsxTag(level, closing)` → JSX tag (then `expectsValue = true`); `jsxText(level)` → JSX children (then `expectsValue = true`). Then the stop check; whitespace skipped (flags untouched).
|
||
|
||
| Input | Action |
|
||
|---|---|
|
||
| `//` | line comment |
|
||
| `/*` | block comment; unclosed → `blockComment` |
|
||
| `/` when `expectsValue` and a regex parses | regex literal → `string`; `expectsValue = false` |
|
||
| `"` or `'` | single-line string with escapes (unterminated ends at the line end, no carried state); `expectsValue = false` |
|
||
| `` ` `` | paint the backtick `string`, mode `template` |
|
||
| digit, or `.` + digit | number; `expectsValue = false` |
|
||
| identStart, `$`, or `#` + identStart | word (below) |
|
||
| `{` | if `resumes` is non-empty, `depth += 1`; `expectsValue = true` |
|
||
| `}` | if the top resume's depth equals `depth`: pop it, mode = its mode (back into the template / JSX). Else if `resumes` non-empty: `depth -= 1`. `expectsValue = true` |
|
||
| `(` `[` `,` `;` | `expectsValue = true` |
|
||
| `)` `]` | `expectsValue = false` |
|
||
| `<` when JSX on and (`expectsValue` or next is `/`) | try to open JSX; if not a tag, operator run |
|
||
| `.` | consume a run of dots; a run of 2+ (spread `...`) → `keyword`, `expectsValue = true`; a single dot plain, `expectsValue = false` |
|
||
| other operator | operator run → `keyword`; `expectsValue = true` |
|
||
| anything else | skip 1 (flags unchanged except below) |
|
||
|
||
After every case except a keyword word, `classNext = false`.
|
||
|
||
Word: consume identPart and `$`. Then:
|
||
- keyword (or TS keyword when TS) → `keyword`; `classNext = word in introducers`; `expectsValue = !(word is this/super)`; (no classNext reset).
|
||
- constant, or TS builtin when TS → `number`.
|
||
- else if `classNext` → `variable`.
|
||
- else if constant name (≥2 units, first `A-Z`, no `a-z`; e.g. `MAX_SIZE`) → `number`.
|
||
- else plain. Then `classNext = false`, `expectsValue = false`.
|
||
|
||
Regex: from the `/`, scan forward on the same line; `\` skips 2; `[` enters a class, `]` leaves it; an unescaped `/` outside a class closes. Fails (nothing consumed; the `/` then becomes an operator) if the line ends first or the body is empty. On success consume the closing `/` and trailing ASCII letters (flags) and paint all as `string`.
|
||
|
||
Template text: from the cursor, `\` skips 2 (clamped); `` ` `` closes (paint `string` incl. backtick, mode `code`); `${` → paint the text before it `string`, consume `${` (left **plain**), push resume `(depth: current depth, mode: template)`, mode `code`. Line end → paint the rest `string` and stay in `template` (multi-line).
|
||
|
||
#### JSX (only when `jsx`)
|
||
|
||
Open (`<` at cursor, `level` = current nesting): `closing` if the next unit is `/`.
|
||
- Fragment `<>` or `</>`: consume; mode = children(closing ? level−1 : level+1). Nothing painted.
|
||
- Else the next unit must be ASCII alpha (else fail). The name = identPart, `.`, `-`, `:` units → `number`. Mode `jsxTag(level, closing)`. The `<` / `</` stay plain.
|
||
|
||
`children(n)` = `jsxText(n)` if n > 0, else `code`.
|
||
|
||
Inside a tag:
|
||
- `>` → mode children(closing ? level−1 : level+1).
|
||
- `/>` → mode children(level).
|
||
- `{` → push resume `(depth, jsxTag(level, closing))`, mode `code` (an attribute expression).
|
||
- `"` or `'` → string **without escapes** → `string`.
|
||
- identStart → identifier with `-` and `:` → `variable` (attribute name).
|
||
- anything else (e.g. `=`) → skip.
|
||
Tags may wrap over lines (mode carried).
|
||
|
||
Children text: plain; `<` that opens a valid tag/fragment → that; `{` → push resume `(depth, jsxText(level))`, mode `code`. An apostrophe in children text opens no string.
|
||
|
||
#### Acceptance examples (JS family)
|
||
|
||
- `const a = 'x' + "y" // note\nlet b = 1.5e3` → painted runs exactly: `const:keyword, =:keyword, 'x':string, +:keyword, "y":string, // note:comment, let:keyword, =:keyword, 1.5e3:number`.
|
||
- ``const s = `a ${fn(1)} b\nstill string ${x}`\nconst after = 2`` → `` `a `` string, `1` number, `still string ` string, `after` plain, `2` number.
|
||
- `` `${ {a: 1}.a } tail` `` → ` tail`` ` string (the interpolation returns at its own brace).
|
||
- `const r = /ab+c/gi` → `/ab+c/gi` string. `const q = a / b / c` → `/` keyword.
|
||
- `/**\n * Docs\n */\nfunction f() {}` → ` * Docs` comment, `function` keyword.
|
||
- `class A extends B { m() { return new C() } }` → `A`, `B`, `C` variable; `m` plain.
|
||
- `if (x === undefined || y === true) MAX_SIZE` → `undefined`, `true`, `MAX_SIZE` number.
|
||
- TS: `interface A { readonly n: number }\ntype B = keyof A` → `readonly` keyword, `number` number, `keyof` keyword; in plain JS `type` is plain.
|
||
- JSX/TSX: `return <Card title="x" onClick={() => go(1)}>\n Hi\n</Card>` → `Card` number (both), `title` variable, `"x"` string, `=>` keyword, `1` number.
|
||
- `const a = <div\n className="x"\n/>\nlet b` (jsx) → `className` variable, `let` keyword.
|
||
- `if (a <b) {}` (jsx) → `<` keyword.
|
||
- `const a = 'open\nconst b = 1` → second `const` keyword.
|
||
- `const a = <p>Don't {name} if</p>\nconst b = 'x'` (jsx) → `Don't ` plain, `if` plain, second `p` number, `'x'` string.
|
||
- Multi-line nested JSX (`<ul className="x">{items.map((item) => (<li key={item.id}>{item.label}</li>))}</ul>` spread over lines inside `( … )`, then `let after = 1`) → `ul` number (both), `=>` keyword, second `li` number, `key` variable, `let` keyword.
|
||
- `return <>it's <b>x</b></>\nlet y` (tsx) → `it's ` plain, `let` keyword.
|
||
- `x = <Br />; let z` (jsx) → `let` keyword.
|
||
- `const s = "😀"; const n = 42` → the number token starts at the UTF-16 offset of `42` with length 2.
|
||
- `/* a\r\n b */\r\nlet x = 1\r\n` → `b */` comment, `let` keyword, `1` number.
|
||
|
||
---
|
||
|
||
### 5.6 Markup grammar: HTML, XML, SVG, Vue (`MarkupGrammar`)
|
||
|
||
Literals: comment `<!--` … `-->`; CDATA `<![cdata[` (case-insensitive) … `]]>`; PHP open tags `<?php`, `<?=`, `<?`.
|
||
|
||
Mode dispatch first: `markupComment` → continue to `-->`; `cdata` → continue to `]]>`; `markupTag(name)` → tag attributes (return to the driver if a child was set); `markupValue(quote, tag)` → continue the value (return if a child was set).
|
||
|
||
Code (text) mode:
|
||
1. Stop check (not normally used — markup is only a top-level or fence grammar).
|
||
2. With PHP islands: `<?` → open island (return so the driver runs PHP).
|
||
3. `<` → open tag (below).
|
||
4. `&` → consume identPart and `#` units; if then `;` and at least one unit was consumed → paint `&…;` `variable` (entity). Otherwise leave plain.
|
||
5. Other text → skip to the next `<` or `&` (plain).
|
||
|
||
Open tag at `<`:
|
||
- `<!--` → comment; unclosed → mode `markupComment` (multi-line).
|
||
- `<![CDATA[` → comment; unclosed → mode `cdata` (multi-line).
|
||
- `<!` → comment up to `>`; `<?` (only reachable without PHP islands, e.g. `<?xml … ?>`) → comment up to `?>`. **These two do not carry over lines**: if the line ends first, the line's rest is comment and the next line is normal.
|
||
- `<` or `</` + ASCII alpha → element name (identPart, `-`, `:`, `.`) → `number`; mode `markupTag(name lowercased, prefixed "/" for a closing tag)`.
|
||
- else `<` is a plain character.
|
||
|
||
Inside a tag (attributes), may span lines:
|
||
- With islands: `<?` → island (return).
|
||
- space or `=` → skip.
|
||
- `>` → mode `code`; if the tag name is `script` → child JavaScript (no TS, no JSX) until `</script`; if `style` → child CSS until `</style`. (A `<script lang="ts">` or `type=…` is still plain JS.) Closing tags (`/script`) start nothing.
|
||
- `/>` → mode `code` (no child, even for script).
|
||
- `"` or `'` → quoted value (below), starting at the quote.
|
||
- `/` → skip.
|
||
- else an attribute run up to space, `=`, `>`, `/`, `"`, `'`: painted `string` if the unit just before it is `=` (an unquoted value), else `variable` (attribute name — includes Vue `:class`, `@click`, `v-if`).
|
||
|
||
Quoted value: with islands, `<?` inside the value → paint the value so far `string`, mode `markupValue(quote, tag)`, open the island; after `?>` the value continues. The closing quote ends it (incl.) → mode `markupTag(tag)`. Line end → paint `string`, mode `markupValue` (multi-line value).
|
||
|
||
Island: `<?php` (case-insensitive) / `<?=` / `<?` → `keyword`; child PHP with a fresh state until `?>`.
|
||
|
||
#### Acceptance examples (Markup)
|
||
|
||
- `<a href="/x" data-id=1 hidden>Tom & Jerry</a>` → painted runs exactly: `a:number, href:variable, "/x":string, data-id:variable, 1:string, hidden:variable, &:variable, a:number`.
|
||
- `<!DOCTYPE html>\n<!-- a\n b -->\n<![CDATA[ x ]]>\n<p>` → `<!DOCTYPE html>` comment, ` b -->` comment, `<![CDATA[ x ]]>` comment, `p` number.
|
||
- `<script>\nconst a = 1 // c\n</script>\n<style>\n.b { color: red; }\n</style>\n<p>const</p>` → first `const` keyword, `// c` comment, second `script` number, `.b` number, `color` variable, the `const` inside `<p>` plain.
|
||
- `<script>// x</script><p>` → `// x` comment, `p` number.
|
||
- `<img\n alt="a\n b"\n src="x">\nafter` → ` b"` string, `src` variable, `after` plain.
|
||
- Vue: `<template><div :class="a" @click="go"/></template>\n<script setup>\nimport x from 'y'\n</script>` → `:class`, `@click` variable; `import` keyword.
|
||
|
||
---
|
||
|
||
### 5.7 CSS / SCSS grammar (`CSSGrammar`)
|
||
|
||
Line-local `context` ∈ {selector, property, value}. At line start: if mode is `cssValue` → context `value` and mode reset to `code`; else `statementContext`.
|
||
|
||
`statementContext(depth)`: at depth 0 → `selector`. Inside a block, look ahead on the rest of the line from the cursor: a `{` before any `;` or `}` → `selector`; a `;` or `}` first, or neither → `property`.
|
||
|
||
`lineStart` = the cursor position when the scan began (the line start, or the resume point after `<style>` on the same line).
|
||
|
||
| Input | Action |
|
||
|---|---|
|
||
| mode `blockComment` | continue to `*/` |
|
||
| stop check | return at `</style` |
|
||
| space | skip |
|
||
| `/*` | block comment; unclosed → `blockComment` |
|
||
| `//` at `lineStart` or after a space unit | line comment (SCSS) |
|
||
| `"` or `'` | single-line string with escapes |
|
||
| `{` | `depth += 1`; context = statementContext |
|
||
| `}` | `depth = max(0, depth − 1)`; context = statementContext |
|
||
| `;` | context = statementContext |
|
||
| `@` + identStart | at-rule: identifier with `-` → `keyword`; context = `value` |
|
||
| `$` + identStart | SCSS variable: identifier with `-` → `variable`; if the next non-space is `:` → context `value` |
|
||
| `!important` (case-insensitive after `!`) | `keyword` |
|
||
| otherwise | by context (below) |
|
||
|
||
- **selector** → selector part.
|
||
- **property** → if identStart or `-`: identifier with `-`; if the next non-space is `:` → `variable` (property name), skip spaces, consume the `:` (plain), context `value`; else `number` (reads as an element name). Otherwise → selector part (e.g. `&:hover`, `.x`).
|
||
- **value** → value part.
|
||
|
||
At the line end: if context is `value`, depth > 0 and mode is `code` → mode `cssValue` (a value continues on the next line).
|
||
|
||
Selector part:
|
||
- `:` or `::` + identifier (with `-`) → `keyword` (pseudo-class / element).
|
||
- `&`, `>`, `+`, `~` → one-unit `keyword`.
|
||
- `[` … `]` (single line, includes `]`; to line end if none) → `number`.
|
||
- `.`, `#`, `*`, `%` + identifier (with `-`) → `number`.
|
||
- identStart or `-` → identifier (with `-`) → `number` (element names).
|
||
- else skip 1 (e.g. `,`, `(`).
|
||
|
||
Value part:
|
||
- `#` + hex digit → `#` + identifier → `number` (colours).
|
||
- digit, or one of `. - +` followed by a digit or by `.digit` → consume the first unit, then digits and dots; then a `%`, or else an identifier (unit) → `number`.
|
||
- `url(` (case-insensitive) → `url(` plain; the body up to (not including) `)` → `string`.
|
||
- `--` + … → identifier with `-` → `variable` (custom property).
|
||
- identStart or `-` → identifier with `-`; `string` unless the next unit is `(` (a function name stays plain). Note a lone `-` (e.g. the minus in `calc(100% - var(--gap))`) is painted `string` by this rule.
|
||
- else skip 1.
|
||
|
||
Acceptance:
|
||
- `.btn:hover > a, #main { color: #fff; margin: 0 4px 1.5em; display: flex !important; }` → `.btn` number, `:hover` keyword, `>` keyword, `#main` number, `color` variable, `#fff` number, `4px` number, `1.5em` number, `flex` string, `!important` keyword.
|
||
- `@media (max-width: 600px) {\n nav { background: url(img/x.png); width: calc(100% - var(--gap)); }\n}` → `@media` keyword, `img/x.png` string, `calc` plain, `100%` number, `--gap` variable, `nav` number.
|
||
- `.card {\n $pad: 4px;\n padding: $pad;\n &:hover {\n color: red;\n }\n}` → `$pad` variable, `padding` variable, `&` keyword, `:hover` keyword, `color` variable.
|
||
- `a {\n grid-template-areas:\n "head head"\n main;\n color: red;\n}` → `"head head"` string, `main` string, `color` variable.
|
||
- `/* a\n b */\n// scss\na { b: c; }` → ` b */` comment, `// scss` comment.
|
||
|
||
---
|
||
|
||
### 5.8 JSON grammar (`JSONGrammar`)
|
||
|
||
JSON with comments (tsconfig style). No stop checks.
|
||
|
||
| Input | Action |
|
||
|---|---|
|
||
| mode `blockComment` | continue to `*/` |
|
||
| `//` | line comment |
|
||
| `/*` | block comment; unclosed → `blockComment` |
|
||
| `"` | string: `\` skips the next unit; ends at the next `"` (included) or the line end (no carried state). Painted `variable` if the next non-space unit after it is `:` (a key), else `string` |
|
||
| digit, or `-` + digit | number (a leading `-` is painted `number` and merges with the number) |
|
||
| ASCII alpha | identifier; `true`/`false`/`null` → `number`; other words plain |
|
||
| else | skip 1 |
|
||
|
||
Acceptance: `{"name": "helder", "n": -1.5e2, "ok": true, "none": null, "list": ["a"]}` → `"name"` variable, `"helder"` string, `-1.5e2` number, `true` number, `null` number, `"a"` string. `{"k": "a \" b"}` → `"a \" b"` one string. `{\n // line\n /* block */ "a": 1\n}` → `// line` comment, `/* block */` comment.
|
||
|
||
---
|
||
|
||
### 5.9 Markdown source grammar (`MarkdownGrammar`)
|
||
|
||
Line-based; only fences carry state.
|
||
|
||
Per line:
|
||
1. If mode is `fence(marker, count)`: **fenced line**. Skip leading spaces; count a run of `marker` units; if the run is ≥ `count` and only spaces follow to the line end → closing fence: paint the whole line `comment`, mode `code`, clear the child. Otherwise, if there is a child grammar, run it over the line with its own carried state (store it back); else the line is plain.
|
||
2. Else skip leading spaces, look at the first unit `c`:
|
||
- `` ` `` or `~` run of ≥3 → **opening fence**: info = the rest of the line trimmed; the language word = the info up to the first whitespace; paint the whole line (from the true line start, indentation included) `comment`; mode `fence(c, runLength)`; if `fenceLanguage(word)` maps to a language, child = that grammar (chosen with empty text) with a fresh state and terminator `fence`.
|
||
- `#` run of 1–6 followed by a space unit or the line end → **heading**: whole line (from the line start) `keyword`. (`#hashtag` stays plain; 7+ `#` is not a heading.)
|
||
- **rule**: first unit is `-`, `*` or `_`, and the rest of the line contains only that unit and spaces, at least 3 of it → whole line `comment`.
|
||
- Then: each `>` (with following spaces skipped) → that `>` `comment` (nested quotes repeat).
|
||
- Then list marker: `-`, `*`, `+`, or digits followed by `.` or `)`, **followed by a space unit** → the marker (not the space) `comment`.
|
||
- Then inline scan over the rest:
|
||
- `\` → skip 2 units (escaped char).
|
||
- a run of N backticks → find the next run of **exactly** N backticks on the line; if found, the whole span incl. both runs → `keyword` (code span); else skip the run.
|
||
- `](` → from the `(` to the next `)` inclusive (or to the line end) → `variable` (link target; the link text stays plain).
|
||
- `<` + ASCII alpha → scan to `>` or a space; if it stops at `>` and the inner text contains `:` → `<…>` `variable` (autolink); else skip the `<`.
|
||
- else skip 1.
|
||
Emphasis, bold and tables are not coloured in the source.
|
||
|
||
Note: the source grammar accepts `~~~` fences, indented fences, and info strings with extra words (`` ```php title ``); the Preview parser (5.11) does not.
|
||
|
||
Acceptance:
|
||
- `## Title\ntext` → `## Title` keyword; `#hashtag` → plain.
|
||
- ```` ```php\n$x = new Agent();\n```\nafter $x ```` → ```` ```php ```` comment, first `$x` variable, `new` keyword, second `$x` plain.
|
||
- `~~~text\nif x\n~~~` → `if x` plain.
|
||
- ```` ```js\n/* a\nb */ let c\n``` ```` → `b */` comment, `let` keyword.
|
||
- ``Use `npm test` and [docs](https://x.test) or <https://y.test>.`` → `` `npm test` `` keyword, `(https://x.test)` variable, `docs` plain, `<https://y.test>` variable.
|
||
- `- one\n1. two\n> quote\n---` → `-` comment, `1.` comment, `>` comment, `---` comment.
|
||
|
||
---
|
||
|
||
### 5.10 Python grammar (`PythonGrammar`)
|
||
|
||
Keywords:
|
||
```
|
||
and as assert async await break case class continue def del
|
||
elif else except exec finally for from global if import in is
|
||
lambda match nonlocal not or pass print raise return try while
|
||
with yield
|
||
```
|
||
Builtins and constants → `number`:
|
||
```
|
||
True False None abs all any ascii bin bool bytearray bytes
|
||
callable chr classmethod compile complex delattr dict dir divmod
|
||
enumerate eval filter float format frozenset getattr globals hasattr
|
||
hash help hex id input int isinstance issubclass iter len list
|
||
locals map max memoryview min next object oct open ord pow
|
||
property range repr reversed round set setattr slice sorted
|
||
staticmethod str sum super tuple type vars zip __import__
|
||
```
|
||
|
||
Line-local `classNext = false`.
|
||
|
||
Scan:
|
||
1. Mode `triple(q)` → continue the triple string from the cursor (`\` skips 2; three `q` in a row close it, included) → `string`; on close mode `code`.
|
||
2. Space → skip.
|
||
3. String opener: up to **2** prefix units from `rRbBuUfF`; if any prefix was taken and the unit before the cursor is identPart, it is not a string (it is inside a word). Then a `"` or `'` must follow. Three of the same quote → triple string (unclosed → mode `triple(q)`); else a single-line string with escapes (`lx.quoted`; unterminated ends at the line end, no state). The prefix belongs to the string token. `classNext = false`.
|
||
4. `#` → line comment.
|
||
5. `@` + identStart, **at the start of a line** (only spaces between it and the previous LF or the buffer start; this looks back into the whole buffer) → decorator: identifier with `.` → `keyword` (e.g. `@app.route`). A mid-line `@` (matrix multiply) is not an operator here → plain.
|
||
6. digit or `.` + digit → number.
|
||
7. identStart → identifier: keyword → `keyword`, `classNext = (word == "class")` (no reset); else if `classNext` → `variable`; else builtin → `number`; else plain.
|
||
8. operator except `:` → operator run (excluding `:`) → `keyword`.
|
||
9. else skip 1.
|
||
After every case except keywords and whitespace, `classNext = false`.
|
||
|
||
Acceptance:
|
||
- `def run(x):\n if x is None: # guard\n return len(x)\n return True` → `def` keyword, `run` plain, `None` number, `# guard` comment, `len` number, `True` number.
|
||
- `x = '''one\ntwo # not a comment\nthree'''\ny = 1` → `two # not a comment` string, `1` number.
|
||
- `v = f"a{b}"`, `v = rb'raw'`, `v = u"x"` → the whole literal (prefix included) is one string.
|
||
- `@app.route('/')\ndef f(): return a @ b` → `@app.route` keyword; second `@` plain.
|
||
- `class Agent(Base):` → `Agent` variable.
|
||
|
||
---
|
||
|
||
### 5.11 Shell grammar, also `.env` (`ShellGrammar`)
|
||
|
||
Keywords → `keyword`:
|
||
```
|
||
if then else elif fi for while until do done case esac in
|
||
function select time return local export readonly declare unset shift
|
||
break continue exit source alias typeset let eval
|
||
```
|
||
Builtins → `number`:
|
||
```
|
||
echo cd pwd printf read test set trap wait kill exec true
|
||
false type hash getopts umask ulimit command builtin jobs fg bg
|
||
pushd popd dirs history shopt mapfile
|
||
```
|
||
Word breaks: space, tab, `|`, `&`, `;`, `(`, `)`, `<`, `>`, `{`, `}`, `` ` ``, CR. Shell operators: `<`, `>`, `=`, `!`, `&`, `|`.
|
||
|
||
Scan (`lineStart` = position where the scan began):
|
||
|
||
| Input | Action |
|
||
|---|---|
|
||
| mode `quoted(q)` | continue the string from the cursor |
|
||
| mode `heredoc(id, interp)` | heredoc line |
|
||
| space | skip |
|
||
| `#` at `lineStart` or after a word-break unit | line comment (so `a#b` is not a comment) |
|
||
| `'` or `"` | string; unclosed → mode `quoted(q)` (multi-line) |
|
||
| `$` | variable |
|
||
| `<<` not followed by a third `<` | heredoc start (`<<<` falls to the operator rule → keyword run) |
|
||
| shell operator | operator run over shell operators → `keyword` |
|
||
| other word-break unit | skip |
|
||
| else | word |
|
||
|
||
Word (`atCommandStart` = at `lineStart` or after a word-break unit):
|
||
1. Consume identPart units (the identifier part).
|
||
2. If the identifier is non-empty, at command start, followed by `=`, and does not start with a digit → paint it `variable` (assignment `NAME=`; the `=` is then a keyword operator). Return.
|
||
3. Continue consuming while not a word break and not `"`, `'`, `$`.
|
||
4. If the word extends past the identifier (e.g. `apt-get`, `done-thing`, `-n`, `[`) or the identifier is empty → plain (advance at least 1). Else: keyword → `keyword`; builtin, or all digits → `number`; else plain. Keywords are coloured anywhere, not only at command start.
|
||
|
||
Variable at `$`: consume `$`; then `{` → up to and including the next `}` on the line (or to line end); identStart → identifier; a digit or one of `@ * # ? $ ! -` → that one unit; anything else (e.g. `$(`) → nothing painted (the `$` stays plain). Painted `variable`.
|
||
|
||
Strings: single quotes — no escapes, no interpolation. Double quotes — `\` skips 2; `$` followed by identStart or `{` interpolates (painted `variable` within the string); `$1`, `$@` inside double quotes are **not** interpolated. Close quote included.
|
||
|
||
Heredoc start at `<<`: optional `-`; spaces; optional `'`/`"`; identifier. No identifier → `<<` `keyword`, advance 2. Else paint `<<`/`<<-` plus spaces `keyword`, then the (quoted) marker `string`; mode `heredoc(id, interpolates: not quoted)`. As in PHP, the rest of the opening line (e.g. ` > out.txt`) is then painted as heredoc body.
|
||
|
||
Heredoc line: skip leading spaces; if the marker follows and **ends exactly at the line end** → whole line `string`, mode `code`. Else body `string`, with `$…` variables painted `variable` when interpolating.
|
||
|
||
Acceptance:
|
||
- `if [ -n "$HOME" ]; then echo "dir: ${HOME}/x" 'no $sub'; fi` → `if` keyword, `$HOME` variable, `echo` number, `${HOME}` variable, `'no $sub'` string, `fi` keyword.
|
||
- `echo a#b # real` → `a#b` plain, `# real` comment.
|
||
- `cat <<EOF\nhi $USER\nEOF\ncat <<'RAW'\n$keep\nRAW\necho done` → `hi ` string, `$USER` variable, `$keep` string, `echo` number.
|
||
- `APP_NAME=Helder\n# comment\nDB_PASSWORD="s3cret"` → `APP_NAME` variable, `# comment` comment, `"s3cret"` string.
|
||
- `msg="one\ntwo"\necho x` → `two"` string, `echo` number.
|
||
- `apt-get install -y done-thing` → `apt-get` plain, `done-thing` plain.
|
||
|
||
---
|
||
|
||
### 5.12 YAML grammar (`YAMLGrammar`)
|
||
|
||
Per line: `indent` = count of leading space units (tab counts as one).
|
||
|
||
Block scalar continuation: if mode is `yamlBlock(parent)`: a blank/space-only line → return (stay in the block, nothing painted); `indent > parent` → paint from the first non-space to the line end `string`, return; otherwise mode `code` and scan the line normally.
|
||
|
||
Line-local `flow = 0` (flow collections are tracked only within one line).
|
||
|
||
| Input | Action |
|
||
|---|---|
|
||
| space | skip |
|
||
| `#` at line start or after a space | line comment |
|
||
| `-` followed by a space or the line end | skip (list indicator, plain) |
|
||
| `"` or `'` | quoted scalar on one line (`\` escapes inside `"` only); painted `keyword` if immediately followed by `:` + (space or line end) (a quoted key), else `string` |
|
||
| `&` or `*` | anchor / alias: up to a space or `,` `]` `}` → `keyword` |
|
||
| `!` | tag up to a space → `number` |
|
||
| `[` or `{` | `flow += 1` |
|
||
| `]` or `}` | `flow = max(0, flow − 1)` |
|
||
| `,` when `flow > 0` | skip |
|
||
| `\|` or `>` that is a block indicator | consume the rest of the line (indicator and any trailing comment stay **plain**); mode `yamlBlock(indent: this line's indent)` |
|
||
| else | plain scalar |
|
||
|
||
Block indicator: after the `|`/`>`, any of `-`, `+`, digits, then spaces, then the line end or `#`.
|
||
|
||
Plain scalar (`inFlow = flow > 0`): scan until `:` followed by a space or the line end, or `#` preceded by a space (not at the scalar start), or (in flow) `,` `]` `}`. Track the end of the last non-space unit. If nothing was consumed, skip 1. If it stopped at a key colon → the text (trimmed of trailing spaces) `keyword`, consume the `:`. Else the trimmed value, lowercased: `true`, `false`, `null`, `~` → `keyword`; matches the whole regex `[+-]?(?:0x[0-9a-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)` → `number`; else plain. (`yes`/`no`/`on`/`off` are plain. `---` is plain.)
|
||
|
||
Acceptance:
|
||
- `name: helder # app\nport: 8080\ndebug: true\nempty: ~\nurl: http://x.test:80\n"quoted key": 'v'` → `name` keyword, `# app` comment, `8080` number, `true` keyword, `~` keyword, `http://x.test:80` plain, `"quoted key"` keyword, `'v'` string.
|
||
- `script: |\n echo: hi\n\n more\nnext: 1` → `echo: hi` string (the leading indentation is not painted, so ` echo: hi` spans two roles), `more` string, `next` keyword.
|
||
- `base: &base\n - item: !!str 1\nuse: *base` → `&base` keyword, `item` keyword, `!!str` number, `*base` keyword.
|
||
- `tags: [a, 2, true]` → `2` number, `true` keyword.
|
||
|
||
#### Whole-highlighter acceptance (all grammars)
|
||
|
||
For each of these samples, tokens must tile the text, no adjacent tokens share a role, and line-by-line scanning with carried state equals whole-buffer scanning:
|
||
`<?php\nnamespace App;\n/* a\n block */\nclass A extends B {\n public function run(): string { return "x $y"; }\n}\n` (php) · ``const a = `x ${b} y`\n/* c\n d */ let e = /re/g\n`` (javascript) · `export const App = () => (\n <div className="x">\n {n.map((i) => <b key={i}>{i}</b>)}\n </div>\n)\n` (tsx) · `<html>\n<!-- c\n -->\n<script>\nlet a = 1\n</script>\n<style>a { color: red }</style>\n` (markup) · `a {\n color: #fff;\n margin: 0 4px;\n}\n` (css) · `{\n "a": [1, true, null]\n}\n` (json) · ```` # T\n\n```php\n$x = 1;\n```\n- item `code`\n ```` (markdown) · `#!/bin/sh\nif [ -f x ]; then echo "$HOME"; fi\ncat <<EOF\nhi $USER\nEOF\n` (bash) · `def f(x):\n """doc\n string"""\n return None\n` (python) · `a: 1\nb: |\n text\nc: true # note\n` (yaml).
|
||
Also: after `lineTokens("/* open")` the JS state is inside a construct; after `lineTokens("close */")` it is not, and equals a fresh JS state.
|
||
|
||
---
|
||
|
||
### 5.13 Markdown model (`MarkdownModels.swift`)
|
||
|
||
Blocks (`MarkdownBlock`):
|
||
|
||
| Case | Fields |
|
||
|---|---|
|
||
| `heading` | `level: Int` (1–6), `content: [Inline]` |
|
||
| `paragraph` | `[Inline]` |
|
||
| `code` | `language: Language?` (nil when the info string is unknown or empty), `text: String` (lines joined with `\n`) |
|
||
| `quote` | `[Block]` (recursively parsed) |
|
||
| `list` | `ordered: Bool`, `items: [[Inline]]` (one inline list per item; no nesting, no start number) |
|
||
| `table` | `header: [[Inline]]` (cells), `alignments: [TableAlignment?]` (`left`/`center`/`right`/nil per column), `rows: [[[Inline]]]` (each row padded or cut to the header width) |
|
||
| `rule` | — |
|
||
|
||
Inlines (`MarkdownInline`):
|
||
|
||
| Case | Fields |
|
||
|---|---|
|
||
| `text` | `String` |
|
||
| `code` | `String` |
|
||
| `strong` | `[Inline]` |
|
||
| `emphasis` | `[Inline]` |
|
||
| `strikethrough` | `[Inline]` |
|
||
| `link` | `text: [Inline]`, `url: String`, `title: String?` |
|
||
| `image` | `alt: String`, `source: ImageSource`, `title: String?` |
|
||
|
||
`ImageSource`: `local(path)` (a project-relative path, read through the file service) or `remote(URL)`.
|
||
|
||
---
|
||
|
||
### 5.14 Markdown block parser (`MarkdownParser.parse(text, baseDir = "")`)
|
||
|
||
`baseDir` is the document's folder (project-relative), used for local image paths.
|
||
|
||
1. Normalise `\r\n` → `\n`, then lone `\r` → `\n`. Split on `\n`.
|
||
2. Keep a pending paragraph (list of trimmed lines). `flush` = if non-empty, append `paragraph(inline(lines joined with one space))`.
|
||
3. For each line `i`, test **in this order**:
|
||
|
||
| # | Test | Result |
|
||
|---|---|---|
|
||
| a | the whole line matches ```` ```\s*([\w+-]*)\s* ```` | flush; collect following lines until a line that wholly matches ```` ```\s* ```` (or EOF); skip the closing line; append `code(language: fenceLanguage(info), text: lines joined "\n")` |
|
||
| b | line is blank (all whitespace) | flush |
|
||
| c | whole line matches `(#{1,6})\s+(.*)` | flush; `heading(level = count of #, inline(trimmed rest))` |
|
||
| d | rule: the non-whitespace characters number ≥3, are all the same, and that character is `-`, `*` or `_` | flush; `rule` |
|
||
| e | line contains `\|` and a next line exists, and `tableAlignments(next line)` is non-nil **and** has as many entries as `splitRow(line)` | flush; skip both lines; then each following line that contains `\|` and is not blank is a body row: `splitRow`, then for each header column take that cell or `""`; append `table(header cells inlined, alignments, rows)` |
|
||
| f | line has prefix `\s*>` | flush; take consecutive lines with prefix `\s*>\s?`, strip that prefix (the `>` and at most one whitespace char); stop at the first line without it; append `quote(parse(joined with "\n", baseDir))` |
|
||
| g | consecutive lines with prefix `\s*[-*+]\s+` | flush; `list(ordered: false, items: each rest-of-line inlined)` |
|
||
| h | consecutive lines with prefix `\s*\d+[.)]\s+` | flush; `list(ordered: true, …)` |
|
||
| i | otherwise | append the trimmed line to the paragraph |
|
||
|
||
4. Flush at the end.
|
||
|
||
Details and edge cases (code wins):
|
||
- Fences: backticks only, exactly three at the line start (no indentation; a 4-backtick fence is not a fence); the info is one word of word characters, `+`, `-` (so ```` ```js title ```` is **not** a fence and becomes paragraph text). Unknown info → `language: nil`. A missing closing fence takes the rest of the document. The closing fence may have trailing spaces.
|
||
- Headings need no indentation and at least one whitespace after the hashes; closing `#`s are kept in the text; setext headings are not supported (a `---` under text is a rule; a `===` line is paragraph text).
|
||
- Lists: indentation is ignored (an indented item joins the same flat list); the item text is the rest of the line **untrimmed** before inline parsing; a blank line or any non-item line ends the list; there are no continuation lines; `-`, `*`, `+` mix in one list; an ordered run after a bullet run is a new list.
|
||
- Quotes: no lazy continuation; nested quotes come from recursion.
|
||
- Tables: cells are split on `|` without regard to code spans; `\|` is a literal pipe; a pipe-bearing line without a delimiter row is paragraph text.
|
||
- Raw HTML is not interpreted; it stays literal text.
|
||
|
||
`splitRow(line)`: trim; drop one leading `|`; drop one trailing `|` unless it is preceded by `\`; split on `|`, where `\|` yields a literal `|` in the cell; trim every cell.
|
||
|
||
`tableAlignments(line)`: nil if the line has no `|` and does not wholly match `\s*:?-+:?\s*`. Else for each `splitRow` cell: it must wholly match `:?-+:?` (else nil); leading and trailing `:` → center; trailing only → right; leading only → left; none → nil.
|
||
|
||
#### Inline parser (`MarkdownInlineParser.parse(source, baseDir)`)
|
||
|
||
A fixed order of regex rewrite passes over one string. Each pass replaces its match with a **placeholder** `U+E000 <index> U+E001` pointing at the node it built, so later passes can wrap earlier nodes but never re-read their text. Swift's `replacing` replaces all non-overlapping matches left to right.
|
||
|
||
| Pass | Pattern | Node |
|
||
|---|---|---|
|
||
| 1 | `` `([^`]+)` `` | `code(content)` |
|
||
| 2 | `!\[([^\]]*)\]\(([^)]*)\)` | image (below) |
|
||
| 3 | `\[([^\]]+)\]\(([^)]*)\)` | link (below) |
|
||
| 4 | `\*\*([^*]+)\*\*` | `strong(expand(inner))` |
|
||
| 5 | `__([^_]+)__` | `strong(expand(inner))` |
|
||
| 6 | `\*([^*]+)\*` | `emphasis(expand(inner))` |
|
||
| 7 | `(^\|[^a-zA-Z0-9_])_([^_]+)_(?=[^a-zA-Z0-9_]\|$)` | keep group 1, then `emphasis(expand(group 2))` (no intra-word underscores) |
|
||
| 8 | `~~([^~]+)~~` | `strikethrough(expand(inner))` |
|
||
|
||
Then `expand` the final string: a placeholder whose number is a valid held index becomes that node; everything else (including look-alike private-use characters with an invalid index) is literal text; consecutive literal characters form one `text` node.
|
||
|
||
Image: `alt = plainText(expand(group 1))`; `(url, title) = destination(group 2)`; `safe = safeURL(url)`; if nil or empty → replace with the alt **as plain text** (re-entered into the string, so later passes may still format it). If `isLocalURL(safe)` → `local(resolveRelative(baseDir, safe))`; else if it parses as a URL → `remote(URL)`; else the alt text. Hold `image(alt, source, title)`.
|
||
|
||
Link: `(url, title) = destination(group 2)`; unsafe or empty → replace with the raw link text (group 1); else hold `link(text: expand(group 1), url: safe, title)`.
|
||
|
||
`destination(raw)`: whole-match `\s*(?:<([^>]*)>|([^\s)]*))(?:\s+["'(]([^"')]*)["')])?\s*`; url = group 1 or 2, trimmed; title = group 3, nil if empty. No match → (raw trimmed, nil).
|
||
|
||
`safeURL(url)`: trim spaces; if it starts (case-insensitive) with `http:`, `https:`, `mailto:`, `#`, `/`, `./` or `../` → keep; else if it starts with a scheme `^[a-z][a-z0-9+.-]*:` → nil (unsafe: `javascript:`, `data:`, `file:` …); else keep (relative path).
|
||
|
||
`isLocalURL(url)`: true unless it starts (case-insensitive) with `http:`, `https:`, `data:`, `mailto:` or `#`.
|
||
|
||
`resolveRelative(baseDir, url)`: cut at the first `#`, then at the first `?`; percent-decode; a leading `/` means the project root, else prefix `baseDir + "/"`; split on `/` dropping empty segments, drop `.`, `..` pops one segment (never below the root); join with `/` (no leading slash).
|
||
|
||
`plainText(nodes)` (alt text): text and code content, children of strong/emphasis/strikethrough/link, image alt; concatenated.
|
||
|
||
#### Acceptance examples (Markdown parser)
|
||
|
||
- `# Title\n\nSome **bold** and *italic* and [a](https://x.com).` → `heading(1, [text "Title"])`, `paragraph([text "Some ", strong[text "bold"], text " and ", emphasis[text "italic"], text " and ", link([text "a"], "https://x.com", nil), text "."])`.
|
||
- `###### six` → level 6; `## two ` → level 2; `#nospace` → paragraph `#nospace`; `####### seven` → paragraph.
|
||
- ``I have 0 cats and `**code**` and 1 dog.`` → `[text "I have 0 cats and ", code "**code**", text " and 1 dog."]`.
|
||
- `A <script>alert(1)</script> tag.` → one text node, unchanged.
|
||
- `[click](javascript:alert(1))` → `[text "click)"]`; `[click](javascript:x)` → `[text "click"]`.
|
||
- ```` ```js\nconst a = 1\n\n b\n```\nafter ```` → `code(javascript, "const a = 1\n\n b")`, `paragraph[text "after"]`. ```` ```\nx ```` → `code(nil, "x")`. ```` ```brainfuck\n+\n``` ```` → `code(nil, "+")`.
|
||
- `- a\n* b\n+ c` → one unordered list of `a`, `b`, `c`. `1. a\n2) b` → ordered list `a`, `b`.
|
||
- `---`, `* * *`, `__ _` → `rule`; `-*-` → not a rule.
|
||
- `> # Hi\n> > deep\nout` → `quote([heading(1,"Hi"), quote([paragraph "deep"])])`, `paragraph "out"`.
|
||
- `a\n b \n\nc` → `paragraph "a b"`, `paragraph "c"`.
|
||
- `# A\r\nb\rc` → `heading(1,"A")`, `paragraph "b c"`.
|
||
- `""` and `\n\n \n` → no blocks.
|
||
- `| a | b |\n|---|---|\n| 1 | `x` |\n| 2 | **y** |` → `table(header [[a],[b]], alignments [nil,nil], rows [[[1],[code x]], [[2],[strong y]]])`.
|
||
- `| l | c | r |\n| :-- | :-: | --: |\n| 1 | 2 | 3 |` → alignments `[left, center, right]`.
|
||
- `| a | b |\n|---|---|\n| x \| y | 2 | extra |\n| short |\n\nAfter.` → rows `[[["x | y"],["2"]], [["short"], []]]`, then `paragraph "After."`.
|
||
- `a | b\nnot a table` → `paragraph "a | b not a table"`.
|
||
- `` with baseDir `docs/how-to` → `image("Forge", local "docs/how-to/forge-app-config.png", nil)`.
|
||
- `` with baseDir `docs/how-to` → `image("c", local "docs/img/a b.png", "A title")`.
|
||
- `` → `local "img/a.png"`. `` → `remote`.
|
||
- `[a](https://x.com "Home")` → `link([a], "https://x.com", "Home")`.
|
||
- `[](https://x.com)` → `link([image("i", local "i.png", nil)], "https://x.com", nil)`. `**see [a](#top)**` → `strong([text "see ", link([a], "#top", nil)])`.
|
||
- `snake_case_name and _this_` → `[text "snake_case_name and ", emphasis[text "this"]]`. `__bold__ ~~gone~~` → `[strong[bold], text " ", strikethrough[gone]]`.
|
||
- `destination`: `https://x.com` → (`https://x.com`, nil); `https://x.com "Home"` → title `Home`; `<a b.png> 'T'` → (`a b.png`, `T`); `x.png (Paren)` → (`x.png`, `Paren`); ` spaced ` → (`spaced`, nil).
|
||
- `plainText([text "a ", strong[code "b"], link([text " c"], "#", nil)])` → `a b c`.
|
||
- `x \u{E000}99\u{E001} y` → one text node, unchanged. `a ** b ` c [d](` → one text node, unchanged.
|
||
- `safeURL` keeps `https://x`, `mailto:a@b`, `#top`, `./a`, `../a`, `img/x.png`, and ` /a ` → `/a`; returns nil for `javascript:alert(1)`, `JAVASCRIPT:x`, `data:text/html,x`, `file:///etc/passwd`.
|
||
|
||
---
|
||
|
||
### 5.15 MarkdownSpeech (`MarkdownSpeech.swift`)
|
||
|
||
#### `plainText(blocks)` — the prose to read
|
||
|
||
Produces one line per spoken unit, joined with `\n`; empty lines are dropped.
|
||
|
||
| Block | Lines |
|
||
|---|---|
|
||
| heading, paragraph | one sentence of its inline text |
|
||
| quote | the lines of its inner blocks (recursively) |
|
||
| list | one sentence per item |
|
||
| table | one sentence for the header row, then one per body row: the cells' text, **empty cells dropped**, joined with `", "` |
|
||
| code block, rule | nothing (skipped) |
|
||
|
||
Inline text: `text` and `code` → their text verbatim (inline code is read); strong/emphasis/strikethrough → children; link → its text only (**the URL is never read**); image → its alt text.
|
||
|
||
Sentence: collapse every whitespace run to one space and trim; empty → empty (dropped). If the last character is one of `.` `!` `?` `:` `;` keep it, else append `.` (so the voice pauses between blocks).
|
||
|
||
#### `spoken(text)` — the `$` rule
|
||
|
||
Applied to every text just before it is spoken (by `ReadAloudStore.read`). For each character: a `$` **not** followed by a numeric character (Unicode "is number") is replaced by the word `dollar`, with a space added before it if the output so far ends in a non-whitespace character, and a space added after it if there is a next character that is not whitespace. Any other character, and a `$` before a digit, is kept (the voice reads `$5` as "five dollars").
|
||
|
||
#### Acceptance
|
||
|
||
- `# Title\n\nFirst paragraph\n\nSecond one!` → `Title.\nFirst paragraph.\nSecond one!`
|
||
- ``Some **bold**, *soft*, ~~old~~ and `code` in [the docs](https://x.com).`` → `Some bold, soft, old and code in the docs.`
|
||
- `- one\n- two:\n\n> quoted` → `one.\ntwo:\nquoted.`
|
||
- `| Name | Role |\n|---|---|\n| Ann | dev |` → `Name, Role.\nAnn, dev.`
|
||
- ```` Before\n\n```php\necho 1;\n```\n\n---\n\nAfter ```` → `Before.\nAfter.`; ```` ```\nonly code\n``` ```` → empty.
|
||
- `spoken("echo $user")` → `echo dollar user`; `spoken("$ x")` → `dollar x`; `spoken("a$$")` → `a dollar dollar`; `spoken("It costs $5.")` → unchanged; `spoken("No money here.")` → unchanged.
|
||
|
||
---
|
||
|
||
### 5.16 Speech service and Read aloud
|
||
|
||
#### Speech service (`SpeechServicing` / `SpeechService`, macOS `AVSpeechSynthesizer`)
|
||
|
||
- One instance is shared by the app (built once, used by every window's store). The synthesizer is created lazily.
|
||
- `speak(text)`: first `stop()` (cut off whatever is playing), then speak a new utterance of `text` with **all defaults**: the system default voice for the current language, default rate, pitch and volume. No voice, rate or language is configured anywhere. Remember this utterance as `current`.
|
||
- `stop()`: clear `current`; stop speaking **immediately** (not at a word boundary).
|
||
- `onFinish` callback: called on the main thread when an utterance finishes reading to its end **and** it is still the `current` one. A late "finished" from a replaced or stopped utterance never fires it; `stop()` never fires it. (Cancellation callbacks are not handled.)
|
||
|
||
#### `ReadAloudStore` (one per window)
|
||
|
||
- `isReading` (observable, initially false) drives the title-bar **Stop** button: shown only while `isReading`; styled as an "on" toggle; tooltip "Read aloud: playing. Click to stop."; clicking runs the `stopReading` command.
|
||
- On init it sets `speech.onFinish = { isReading = false }`.
|
||
- `read(text) -> Bool`: if `text` is empty or all whitespace → return false and do nothing (`isReading` unchanged, any current reading continues). Else `speech.speak(spoken(text))`, `isReading = true`, return true. A new read replaces the one that is playing.
|
||
- `stop()`: `speech.stop()`, `isReading = false`. Also called when the project closes.
|
||
|
||
#### Where Read aloud starts (context menus) and what text is read
|
||
|
||
| Menu item | Where | Text handed to `read` | Empty result |
|
||
|---|---|---|---|
|
||
| **Read aloud** (`readAloudFile(path)`) | Explorer file row, **only for Markdown (`.md`)**, in its own group (separator before it) after the pass-on/copy items | The editor buffer if that file is the active, loaded editor file (unsaved edits included), else the file read from disk; then `MarkdownSpeech.plainText(MarkdownParser.parse(text))`. No fallback to raw text. | toast `Nothing to read` with the file path as detail (e.g. a file with only code blocks) |
|
||
| **Read aloud selection** (`readAloudText`) | Editor right-click, only with a non-empty selection, after Copy reference (separator before it) | For a Markdown file: the selection converted to prose; if that prose is empty (e.g. one code block), the raw selection. For any other file: the raw selection. Computed when the menu is built. | no toast (the result is ignored) |
|
||
| **Read aloud selection** (`readAloudTerminalSelection`) | Agent pane and terminal pane right-click, only with a selection | The selection trimmed of whitespace/newlines, converted to prose **always** (Markdown parse regardless of content); if the prose is empty, the trimmed raw selection | toast `Nothing to read` (no detail) |
|
||
|
||
- The rendered Markdown Preview has no Read aloud selection (its selection is not Helder's text); use Read aloud on the file in the Explorer.
|
||
- The menu icon for all three is a speaker (`speaker.wave.2`).
|
||
- The `$` rule (`spoken`) applies to all three, because it lives in `ReadAloudStore.read`.
|
||
|
||
---
|
||
|
||
### 5.17 Doc-vs-code conflicts and notes (code wins)
|
||
|
||
1. **Incremental highlighting.** The `HighlightState` doc comment says an editor keeps the state after every line and re-tokenises from the edited line until the state matches. The editor does not do that: it re-tokenises the whole buffer (40 ms debounce, background thread) and limits only the **repaint** with `HighlightDiff.repaintRange`. The per-line API exists and is tested (line-by-line equals whole-buffer) but is used only for standalone diff lines. Either approach is acceptable if token output is identical; the per-line API must exist with the stated equality contract.
|
||
2. **YAML `?` indicator.** The comment on `isIndicator` says "A `-` or `?` followed by a space", but only `-` is handled; `?` goes to the plain-scalar path.
|
||
3. **Blank selection toast.** `docs/behaviour.md` says blank text "reads nothing and shows the toast 'Nothing to read'". That holds for the agent/terminal panes and for Read aloud on a file. For the **editor** "Read aloud selection" the code shows no toast when the text is blank (for example a whitespace-only selection).
|
||
4. **Markdown fences, source vs Preview.** The guide says a fenced block uses "three or more backticks or tildes" (true for the source view's colours) and that "Fenced code in the Preview needs backticks; a `~~~` fence shows as plain text" (true). Beyond the docs: the Preview parser also needs **exactly** three backticks at column 0 and a single-word info string; ```` ```js title ```` or an indented fence is paragraph text in the Preview while the source view colours it as a fence.
|
||
5. **PHP inside Markdown.** In the Markdown source view a ```` ```php ```` fence is always pure PHP; in the Preview the fenced block is highlighted with its own text, so a block containing `<?` is markup-with-islands. Keep both behaviours.
|
||
6. **Speech settings.** The docs say "the system voice". The code sets no voice, rate or language at all; everything is the platform default.
|
||
7. **`$5` "five dollars".** That is the platform voice reading `$5`; the code only leaves a `$` before a digit unchanged.
|
||
8. **Guide colour wording.** The Markdown guide says headings, list markers, quote markers, rules, code spans and link targets "get their own colours". They share the six syntax colours: headings and code spans `keyword`, markers/rules/fences `comment`, link targets and autolinks `variable`.
|
||
9. **Read aloud scope.** The docs list what is read ("headings, paragraphs, list items, quotes and table cells … code blocks skipped"). The code also reads **inline code** and image **alt text**, and it drops empty table cells.
|
||
10. **`.markdown` files.** The fence map knows `markdown`, but `FileType` maps only `.md` to Markdown, so `.markdown` files get no highlighting, no Preview and no Read aloud.
|
||
|
||
|
||
---
|
||
|
||
## 6. Files, Explorer, watcher, search, recent files, context menus, Plak, Clean Copy, dialogs
|
||
|
||
This section covers the project file model and its services, the Explorer column (column B), the file watcher, Search (⌘F), Recent files (⌘↑/⌘↓), every right-click menu, Plak, the Clean Copy popup, and the dialogs that the file actions open. When the code and the docs disagree, the **code** is the rule. The conflicts are listed at the end.
|
||
|
||
Conventions in this section:
|
||
- Every path inside the project is **project-relative**, uses `/`, and has no leading slash. `""` is the project root.
|
||
- "Toast" means a notification from the toast stack (another section). It has a **title** and an optional mono **detail** line. Each toast is written here as `title` / `detail`.
|
||
- Colours are given by palette token name and hex (see the theme section for the full palette). The tokens used here:
|
||
|
||
| Token | Hex | Token | Hex |
|
||
|---|---|---|---|
|
||
| editor | `#101720` | text1 | `#F4F5F4` |
|
||
| panel | `#18202B` | text2 | `#E4E7E6` |
|
||
| raised | `#232C39` | text3 | `#BAC0C0` |
|
||
| hover | `#1E2733` | text4 | `#6C7783` |
|
||
| panelActive | `#1B242F` | text5 | `#3A424C` |
|
||
| amber | `#E8913A` | ink | `#171C22` |
|
||
| amberDeep / removedText | `#C4741F` | amberSoft | `#F0B476` |
|
||
| addedText / changedDot / menuIconAdd | `#8FBFB4` | menuIconModify | `#F0B476` |
|
||
| menuIconRename | `#BAC0C0` | scrim | `#101720` @ 72% |
|
||
| badgePurple | `#C3A6CE` | badgeAmber | `#F0B476` |
|
||
| badgeTeal | `#8FBFB4` | badgeGrey | `#BAC0C0` |
|
||
| badgeText | `#101720` | menuShadow | `#171C22` @ 10% |
|
||
| overlayShadow | `#171C22` @ 18% | | |
|
||
|
||
---
|
||
|
||
### 1. File model (FileNode, TreeRow, FileTree)
|
||
|
||
**FileNode** — one entry of the tree.
|
||
|
||
| Field | Meaning |
|
||
|---|---|
|
||
| name | Last path segment. The root node's name is the project folder name (or the full root path if the folder name is empty). |
|
||
| kind | `directory` or `file` |
|
||
| path | Project-relative path; `""` for the root. It is also the node's identity. |
|
||
| children | `nil` for a file. For a folder: an array, which is empty for an empty folder (a folder is never built with `nil` children). |
|
||
| isHidden | True when the **name** starts with `.`. |
|
||
|
||
**TreeRow** — one visible row of the Explorer in render order: `path`, `kind`, `depth` (0 = top-level entry; the Explorer indents 16 pt per level).
|
||
|
||
**Building the tree from a flat list of file paths** (`FileTree.build(rootName, paths, emptyDirs)`):
|
||
1. For each file path, split on `/` (empty segments are dropped, so `a//b` is treated as `a/b`). Make sure each ancestor folder exists, and register the file under its parent. Use sets, so a duplicate path does not create a duplicate node.
|
||
2. For each entry in `emptyDirs` (folders that hold no file and that `rg --files` never lists), make sure that folder and all of its ancestors exist.
|
||
3. Build recursively from the root. The children of each folder are **all subfolders sorted by name, then all files sorted by name**.
|
||
4. **Sort order:** case-insensitive, locale-aware compare with locale `en_US` (Swift `String.compare(_:locale:)`, which matches JavaScript `localeCompare`). It is not byte order. The tests check that sorting "ignores case, like localeCompare".
|
||
5. An empty listing gives an empty root.
|
||
|
||
**find(path, tree):** `""` returns the root. Otherwise it walks the segments, matching each child by exact name. It returns nil when a segment is missing.
|
||
|
||
**replacingChildren(of: path, with: children, in: tree):** returns a copy of the tree in which the node at `path` gets the new children. A subtree is only descended into when `path` has the node's path as a prefix. The tree is unchanged when the path does not exist.
|
||
|
||
**visibleRows(tree, expanded, showHidden):** a depth-first walk from the root's children. A child is skipped when `!showHidden && child.isHidden`; a hidden folder hides its whole subtree. A row is emitted for each remaining child. The walk goes into a child only when the child is a folder **and** its path is in `expanded`. Depth starts at 0.
|
||
|
||
---
|
||
|
||
### 2. File types and badges (FileType)
|
||
|
||
**ext(path):** take the basename. If the basename **starts with `.env`**, return `env` (this covers `.env`, `.env.local`, `.env.example`). Otherwise return the text after the **last** `.`, lowercased, or `""` when there is no dot. Note: `.gitignore` gives `gitignore`.
|
||
|
||
**Language map (used by the highlighter, read-aloud and Markdown checks):**
|
||
|
||
| ext | language |
|
||
|---|---|
|
||
| php | php |
|
||
| js, mjs, cjs | javascript |
|
||
| jsx | jsx |
|
||
| ts | typescript |
|
||
| tsx | tsx |
|
||
| py | python |
|
||
| html, xml, svg, vue | markup |
|
||
| css, scss | css |
|
||
| json | json |
|
||
| md | markdown |
|
||
| sh, bash, env | bash |
|
||
| yml, yaml | yaml |
|
||
|
||
`isMarkdown(path)` is true only when the language is markdown, which means ext `md` only. `.markdown` is **not** Markdown.
|
||
|
||
**Status-bar language label:** php→`PHP`, js/mjs/jsx→`JavaScript`, ts/tsx→`TypeScript`, py→`Python`, html→`HTML`, css→`CSS`, json→`JSON`, md→`Markdown`, sh→`Shell`, env→`Dotenv`, yml/yaml→`YAML`. Any other extension → the extension uppercased. No extension → `Plain Text`.
|
||
|
||
**Image extensions:** `png jpg jpeg gif webp svg bmp ico avif apng jfif`. `tooBigNames` = `composer.lock`: the viewer never opens it and flashes `Too big.` instead.
|
||
|
||
**Badge** (the small chip in Explorer rows, search results, recent files and the editor bar): ink text (`badgeText #101720`) on a tinted fill. Name rules are checked first, then the extension:
|
||
|
||
| By basename | text | tint |
|
||
|---|---|---|
|
||
| `composer.json` | json | purple |
|
||
| `package.json` | json | amber |
|
||
| `.env` | env | teal |
|
||
|
||
| ext | text | tint |
|
||
|---|---|---|
|
||
| php, blade | php | purple |
|
||
| ts | ts | purple |
|
||
| tsx | tsx | purple |
|
||
| vue | vue | purple |
|
||
| js, mjs, cjs | js | amber |
|
||
| jsx | jsx | amber |
|
||
| json | json | amber |
|
||
| yml, yaml | yml | amber |
|
||
| css, pcss | css | teal |
|
||
| scss | scss | teal |
|
||
| html | html | teal |
|
||
| sh | sh | teal |
|
||
| env | env | teal |
|
||
| py | py | teal |
|
||
| sql | sql | teal |
|
||
| md | md | grey |
|
||
| txt | txt | grey |
|
||
| lock | lock | grey |
|
||
| svg | svg | grey |
|
||
| anything else | first 4 chars of ext, or `·` when there is no ext | grey |
|
||
|
||
Note: `blade` only matches a file whose last extension is `blade`. `x.blade.php` gets `php` by its ext.
|
||
|
||
**TypeBadge view:** fixed 28 × 16 pt, mono semibold 10, ink text, fill by tint (purple `#C3A6CE`, amber `#F0B476`, teal `#8FBFB4`, grey `#BAC0C0`), corner radius 2, one line. The fixed width keeps the names beside it in one column.
|
||
|
||
---
|
||
|
||
### 3. Path utilities (PathUtils)
|
||
|
||
| Function | Rule |
|
||
|---|---|
|
||
| basename(p) | Last non-empty `/` segment, or `""`. |
|
||
| dirname(p) | Everything before the last `/`; `""` when there is no slash. |
|
||
| join(dir, name) | `name` if dir is `""`, else `dir + "/" + name`. |
|
||
| ancestors(p) | Every ancestor folder, outermost first: `a/b/c.txt` → `[a, a/b]`. `[]` for a single segment. |
|
||
| isHidden(p) | True when **any** segment starts with `.`. |
|
||
| isInside(candidate, path, isDirectory) | `candidate == path`, or (isDirectory and candidate starts with `path + "/"`). |
|
||
| remap(candidate, from, to, isDirectory) | If candidate == from → to. If isDirectory and candidate starts with `from + "/"` → `to` + the rest. Else unchanged. |
|
||
| validatedName(name) | Trim whitespace and newlines, then strip trailing `/` characters. Return nil if the result is empty, contains `/`, or is `.` or `..`. Else return the cleaned name. Used for **rename**. |
|
||
| newEntryPath(inDirectory dir, name) | Strip all leading and trailing `/` from name, then join(dir, name). Inner slashes are **kept** (so `tests/Unit/MathTest.php` creates nested folders). |
|
||
| reference(path, isDirectory) | A folder gets a trailing `/`. |
|
||
|
||
---
|
||
|
||
### 4. File limits and ignore rules (FileLimits, IgnoreRules)
|
||
|
||
**FileLimits — every number:**
|
||
|
||
| Constant | Value | Use |
|
||
|---|---|---|
|
||
| maxIndexedFileBytes | 300 000 bytes | Walk search skips files above this size (also the content-index limit). |
|
||
| maxIndexedFiles | 6000 | Content index cap (symbols section). |
|
||
| maxImageBytes | 25 000 000 bytes | `readImage` returns nil above this. |
|
||
| maxDiffFileBytes | 1 000 000 bytes | Git treats a bigger file as having no text (git section). |
|
||
| maxWalkDepth | 12 | Depth limit of the fallback walk and of the empty-folder scan. |
|
||
| Binary test | A NUL byte in the **first 8000 bytes** marks a file as binary (as git does). A NUL after byte 8000 still reads as text. |
|
||
|
||
Image MIME map: png→`image/png`, jpg/jpeg/jfif→`image/jpeg`, gif→`image/gif`, webp→`image/webp`, svg→`image/svg+xml`, bmp→`image/bmp`, ico→`image/x-icon`, avif→`image/avif`, apng→`image/apng`.
|
||
|
||
**walkIgnoredNames** (folders that the fallback walk, the empty-folder scan and the watcher never enter), verbatim:
|
||
|
||
```
|
||
node_modules, .git, out, dist, build, .next, .nuxt, .cache, coverage, vendor, .idea, .vscode, .helder, .turbo
|
||
```
|
||
|
||
`isWalkIgnored(name)` = name is in this set **or** name == `.DS_Store`.
|
||
|
||
**ripgrepBaseIgnore** (always passed to ripgrep as `--glob !<name>`, in this order):
|
||
|
||
```
|
||
node_modules, .git, out, dist, build, .cache, vendor, coverage, .helder, .next, .nuxt, .turbo, .idea, .vscode, .DS_Store
|
||
```
|
||
|
||
`.DS_Store` is in this list because `followGitignore` defaults to false, so ripgrep runs with `--no-ignore`.
|
||
|
||
- `symbolDeclarationIgnore` = the base list without `vendor` and `.DS_Store`. Declarations inside `vendor/` are indexed, so framework classes stay clickable.
|
||
- `symbolReferenceIgnore` = the base list without `.DS_Store` (it still skips `vendor`).
|
||
|
||
**Watcher ignore:**
|
||
- `isWatchIgnored(rel)`: true when **any** `/` segment of the relative path is in walkIgnoredNames. (`.DS_Store` is not in this check.)
|
||
- **Framework cache prefixes** (`watchIgnoredPrefixes`), verbatim: `storage/framework/`, `bootstrap/cache/`, `.phpunit.result.cache`, `.phpunit.cache/`. A path is dropped when `rel == prefix`, or `rel` starts with prefix, or `prefix == rel + "/"` (the folder itself).
|
||
- `isWatchIgnored(rel, exclude)` = segment rule, OR prefix rule, OR any non-empty `files.exclude` glob matches `rel` (see the glob rules below).
|
||
|
||
**ripgrepArguments(files, base):** for each base name append `--glob`, `!<name>`. Then for each non-empty `files.exclude` glob append `--glob`, `!<glob>`. Then, if `files.followGitignore` is **false**, append `--no-ignore`.
|
||
|
||
**Settings** (from `.helder/config.json`, key `files`):
|
||
|
||
| Key | Default | Effect |
|
||
|---|---|---|
|
||
| `files.exclude` | `[]` | Glob patterns hidden from the tree, the search, and the watcher. |
|
||
| `files.followGitignore` | `false` | `true` makes ripgrep honour `.gitignore`, the walk skip git-ignored paths, and the watcher drop changes to git-ignored files. With `false`, git-ignored files (such as `.env`) are shown and searched. |
|
||
|
||
**Glob semantics (`globMatches(glob, path)`)** — gitignore-style, the same as ripgrep `--glob`:
|
||
1. Strip all trailing `/` from the pattern. If it starts with `/`, it is **rooted**: drop the `/`. An empty pattern never matches.
|
||
2. **anchored** = rooted, or the pattern contains `/`.
|
||
3. Candidates = every ancestor of the path plus the path itself. A matching folder therefore matches everything under it.
|
||
4. Expand `{a,b}` alternatives. Nested braces expand recursively. An unclosed `{` is kept literally.
|
||
5. For each alternative and each candidate: the subject is the whole candidate when anchored, otherwise only the candidate's **basename**. Match the pattern against the subject:
|
||
- `**` crosses folders. `**/` can also match zero folders (`a/**/b` matches `a/b`).
|
||
- `*` matches any run of characters except `/`.
|
||
- `?` matches exactly one character that is not `/`.
|
||
- `[...]` is a character class. `!` or `^` right after `[` negates it. `a-c` is a range. A `]` as the first class character is literal. A class never matches `/`. An unclosed `[` matches a literal `[`.
|
||
- `\x` matches the literal character x.
|
||
- Use memoisation (pattern index × subject index), so a pathological glob stays fast.
|
||
|
||
Test cases that must hold:
|
||
|
||
| glob | path | match |
|
||
|---|---|---|
|
||
| `*.log` | `debug.log` | yes |
|
||
| `*.log` | `logs/deep/debug.log` | yes |
|
||
| `*.log` | `debug.log.txt` | no |
|
||
| `node_modules` | `a/node_modules/pkg/index.js` | yes |
|
||
| `node_modules` | `node_modules_extra/x` | no |
|
||
| `src/*.ts` | `src/a.ts` | yes |
|
||
| `src/*.ts` | `src/deep/a.ts` | no |
|
||
| `src/*.ts` | `lib/src/a.ts` | no |
|
||
| `/build` | `build/x.js` | yes |
|
||
| `/build` | `app/build/x.js` | no |
|
||
| `docs/` | `docs/readme.md` | yes |
|
||
| `**/fixtures/*.json` | `fixtures/a.json` | yes |
|
||
| `**/fixtures/*.json` | `tests/unit/fixtures/a.json` | yes |
|
||
| `a/**/b` | `a/b` | yes |
|
||
| `a/**/b` | `a/x/y/b` | yes |
|
||
| `storage/**` | `storage/logs/x.log` | yes |
|
||
| `file?.txt` | `file1.txt` | yes |
|
||
| `file?.txt` | `file10.txt` | no |
|
||
| `[abc].md` | `b.md` | yes |
|
||
| `[!abc].md` | `b.md` | no |
|
||
| `[a-c]x` | `cx` | yes |
|
||
| `*.{js,ts}` | `x.ts` | yes |
|
||
| `*.{js,ts}` | `x.css` | no |
|
||
| `` (empty) | `a` | no |
|
||
| `*.min.*` | `dist-like/app.min.js` | yes |
|
||
|
||
---
|
||
|
||
### 5. Locating ripgrep (ExecutableLocator, ProjectScanner.ripgrep)
|
||
|
||
1. If the environment variable `RG_BINARY` is set, is not empty, and names an executable file, use it.
|
||
2. Otherwise search for `rg` in this directory order, without duplicates: the app bundle's `Contents/Helpers` (the build script bundles ripgrep there), then each entry of `PATH` (default `/usr/bin:/bin:/usr/sbin:/sbin` for a GUI app), then `/opt/homebrew/bin`, then `/usr/local/bin`. The first candidate that exists, is not a folder, and is executable wins.
|
||
3. A name that contains `/` is checked as given.
|
||
4. No ripgrep → every list and search uses the **walk scanner** (section 7).
|
||
|
||
`isAvailable()` = a ripgrep binary was found. It is checked on each call.
|
||
|
||
---
|
||
|
||
### 6. File service (FileService)
|
||
|
||
**tree():**
|
||
- If ripgrep is available, run `listFiles(nil)` and `emptyDirectories()` in parallel. If either result is non-empty → `FileTree.build(rootName, files, emptyDirs)`.
|
||
- Otherwise (no ripgrep, or both lists empty) → a full **walk**: start at the root, skip `isWalkIgnored` names, skip symlinks, recurse into folders while depth < 12 (a deeper folder is shown but empty), folders first then files, each sorted with `localizedStandardCompare` (case-insensitive, natural order).
|
||
- The walk ignores `files.exclude` and `followGitignore`. Only the ripgrep path honours the config.
|
||
|
||
**children(of: dir):** returns `[]` when the path escapes the root. Without ripgrep → walk(dir). With ripgrep → `listFiles(under: dir)` plus `emptyDirectories(under: dir)`, build a tree, and return the children of `dir`. It is read fresh on every call.
|
||
|
||
**emptyDirectories(under scope):** a recursive scan from scope (or the root). It skips `isWalkIgnored` names and symlinks. A folder is "empty" when its whole subtree holds no regular file. A folder that holds only an ignored folder counts as empty. It recurses while depth < 12. A folder at the depth limit is recorded as empty. It returns relative paths.
|
||
|
||
**Directory listing rule:** regular files and real folders only, dotfiles included, **symlinks left out** (ripgrep without `--follow` leaves them out too). Sorted by byte order of the names. Callers re-sort.
|
||
|
||
**read(path):** UTF-8 text, or `""` for a binary file. **readText(path):** `.text(String)` or `.binary`, so that an empty file and a binary file can be told apart. Lossy UTF-8 decoding. Throws `outsideProject` for an escaping path.
|
||
|
||
**readImage(path):** nil unless the ext is in the image MIME map, the path is inside the root, and the size ≤ 25 000 000 bytes.
|
||
|
||
**write(path, contents):**
|
||
- The file does not exist → check containment (`containedURL`) and write without overwriting.
|
||
- The file exists → resolve symlinks, then do an **atomic replace**: create a sibling temp file `.<name>.helder-<UUID>` with `O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC`, using the old file's POSIX mode (default `0644`). Write, fsync, fchmod to the old mode, close, then `rename(temp, target)`. On any error, unlink the temp file and rethrow. A symlinked file is written at its target, and the link stays a link.
|
||
|
||
**createFile(path):** refuse `""` and escaping paths (`outsideProject`). Refuse an existing path (`alreadyExists`). Create the parent folders. Write empty data without overwriting; a race to "exists" also throws `alreadyExists`.
|
||
|
||
**createDirectory(path):** the same refusals, then create with intermediate folders.
|
||
|
||
**rename(path, to: name):**
|
||
1. `validatedName(name)` or throw `invalidName`.
|
||
2. next = join(dirname(path), clean). Refuse `path == ""` and paths that fail containment (`outsideProject`).
|
||
3. Same absolute path → no-op; return path.
|
||
4. **Case-only rename:** when both paths are equal case-insensitively and `lstat` gives the same device and inode (a case-insensitive disk), use plain `rename(2)`. A normal "move" call refuses this as "already exists".
|
||
5. Otherwise, if the target exists → `alreadyExists(next)`. Then `renamex_np(from, to, RENAME_EXCL)`; `EEXIST` → `alreadyExists`. On a case-sensitive disk, a case-only rename to a free name works, and one that would clobber another file is refused.
|
||
6. Return the new relative path. A rename stays in the same folder.
|
||
|
||
**delete(path):** containment check, and the root can never be deleted (`outsideProject`). A missing path is a silent success. Otherwise **permanent removal** (`removeItem`): it does **not** use the Trash. A folder is removed with everything in it. Deleting a symlink removes only the link.
|
||
|
||
**Containment:**
|
||
- `absoluteURL(path)`: the standardised root plus path, nil when the result is not the root or under `root + "/"`. It checks the spelling only.
|
||
- `containedURL(path)`: absoluteURL, and also the **parent folder with every symlink resolved** must be inside the resolved root (or equal to it). The entry itself is not resolved. A path that does not exist yet keeps its resolved existing ancestor. All create, rename and delete calls go through `containedURL`, so creating, renaming or deleting through a symlinked folder that leads outside is refused. Editing an existing file through a symlink is allowed (write uses absoluteURL for the existence check).
|
||
|
||
**Errors:** `outsideProject`, `alreadyExists(path)`, `invalidName(name)`.
|
||
|
||
---
|
||
|
||
### 7. Project scanning: ripgrep and the walk fallback (ProjectScanner)
|
||
|
||
**ScanFilter** = the base names (`ripgrepBaseIgnore`) plus the current `files` config.
|
||
|
||
**LineQuery patterns:** `smartCaseLiteral(text)` (a fixed string; case-insensitive unless the text holds an uppercase letter), `regex(pattern)` (case-sensitive), `word(text)` (a case-sensitive literal that must stand as a whole word). Options: `fileExtension`, `maxPerFile`, `maxColumns`, `maxFiles` (only the walk honours maxFiles).
|
||
|
||
**ripgrep file list — exact argv:**
|
||
|
||
```
|
||
rg --files --hidden [--glob !<base> ...] [--glob !<exclude> ...] [--no-ignore] -- <target>
|
||
```
|
||
|
||
The target is the absolute root path, or `root/<scope>` when a scope is given. Each output line is made relative to the root (strip `root + "/"` when present). The result is sorted with plain string sort.
|
||
|
||
**ripgrep search — exact argv**, in this order:
|
||
|
||
```
|
||
rg --json
|
||
[--fixed-strings --smart-case] (smartCaseLiteral)
|
||
[ ] (regex: no flag)
|
||
[--fixed-strings --word-regexp] (word)
|
||
--hidden
|
||
[--max-count <maxPerFile>]
|
||
[--max-columns <maxColumns>]
|
||
[--glob *.<ext>] (fileExtension)
|
||
--glob !<base> ... --glob !<exclude> ... [--no-ignore]
|
||
-e <needle> -- <absolute root>
|
||
```
|
||
|
||
The process runs in the root folder with no extra environment. Exit 1 ("nothing found") and exit 2 ("some files unreadable") still keep their stdout. A launch failure logs `ripgrep failed: <error>` (category `search`) and gives an empty result.
|
||
|
||
**Content search (⌘F project column)** = `smartCaseLiteral(query)`, maxPerFile 50, **maxColumns 2000**, maxFiles 400. It returns `[]` when the query trimmed of whitespace and newlines is shorter than 2 characters. The raw query (untrimmed) is the needle. (The search model passes the trimmed term.)
|
||
|
||
**JSON parsing (RipgrepJSON.parseLine):**
|
||
- Fast reject: the line must contain `"match"`.
|
||
- Decode `{type, data:{path:{text}, lines:{text}, line_number, submatches:[{start}]}}`. Keep only `type == "match"`.
|
||
- An event whose path or line comes as `bytes` (base64, not UTF-8) has no `text` and is skipped.
|
||
- Strip one trailing `\n`, then one trailing `\r`, from the line text.
|
||
- line = `line_number` or 0. byteOffset = `submatches[0].start` or 0.
|
||
|
||
**ContentGrouper** (collects matches into per-file groups):
|
||
- The path is made relative to the root.
|
||
- Groups keep **first-seen order**. A **new** file beyond **400** groups is dropped, but a known file still collects hits.
|
||
- Each group stops at **50 hits**.
|
||
- The line text is capped at **1000 UTF-16 units**, never inside a surrogate pair (back up before a trailing surrogate).
|
||
- The byte offset becomes a UTF-16 offset: ≤0 → 0; ≥ the UTF-8 length → the UTF-16 length; otherwise back up to the start of a UTF-8 character and count UTF-16 units. It is then clamped to the capped text length.
|
||
|
||
**Walk scanner (no ripgrep):**
|
||
- **Walk order:** depth-first with a stack. Within a folder, entries are in byte order; files are visited inline, and subfolders are pushed reversed, so they are visited in name order. Symlinks are never followed (they are not listed).
|
||
- **Skips:** any entry whose **name** is in the base list (at any depth); any entry whose relative path matches a non-empty `files.exclude` glob; and, when `followGitignore` is true, any path in git's ignored set. A folder is compared as `rel + "/"`.
|
||
- **Git ignored set:** `git ls-files -z --others --ignored --exclude-standard --directory`, split on NUL. It is empty outside a repository or on failure.
|
||
- **files(under scope):** every file visited, sorted.
|
||
- **matches:** skip a file whose extension ≠ `fileExtension` when one is set. Read text only when the size ≤ 300 000 bytes and there is no NUL in the first 8000 bytes. Split on `\n` (empty pieces kept) and number the lines from 1. Find the first match per line:
|
||
- smart-case literal: case-insensitive unless the text has an uppercase letter. An empty text gives no matcher.
|
||
- regex: ICU regex; an invalid pattern gives no results.
|
||
- word: `(?<!\w)` + escaped text + `(?!\w)`.
|
||
- Report the UTF-8 byte offset and the absolute path `root + "/" + rel`. Stop a file at maxPerFile. Stop the walk once `maxFiles` files have hits.
|
||
- A walk line keeps a trailing `\r`. ripgrep's parser strips it.
|
||
|
||
**SearchServicing.listFiles(under dir):** a non-empty dir that is not strictly under the root returns `[]`. The filter is re-read from the current config on each call.
|
||
|
||
---
|
||
|
||
### 8. File watcher (FSEventsWatcher, EventRouter)
|
||
|
||
**Events:**
|
||
|
||
| Event | Meaning | Debounce (quiet period; each new change restarts it) |
|
||
|---|---|---|
|
||
| `project` | A project file changed. Also invalidates the symbol index. | **0.25 s** |
|
||
| `git` | Git state moved. | **0.2 s** |
|
||
| `config` | `.helder/config.json` changed. | **0.1 s** |
|
||
| `cleanCopy` | `.clean-copy` in the project root changed. It also counts as a project change. | **0.15 s** (the agent's write is not atomic, so the file is read only after it stopped changing) |
|
||
|
||
**FSEvents setup:** one stream. Flags: `UseCFTypes | FileEvents | NoDefer`. Since: "now". **Latency 0.05 s** (FSEvents gathers changes for this long before it calls back). Callbacks run on one serial queue (`nl.blijnder.helder.watcher`). `start` first stops any earlier stream, so calling it again moves the watch to the new root. `stop` stops, invalidates and releases the stream, and cancels all pending debounced events. On failure it logs `cannot watch <root>` or `cannot start watching <root>` (category `watch`).
|
||
|
||
**Watched paths:** the **resolved** root (realpath; FSEvents reports `/private/var`, not `/var`; a path that does not exist yet keeps its resolved parent). Also the resolved git directory when it lies **outside** the root (worktrees, submodules). The git directory is `<root>/.git`, or, when `.git` is a **file**, the path after `gitdir:` (trimmed, resolved relative to the root).
|
||
|
||
**Routing one path:**
|
||
1. If the path, relative to the root, equals `.clean-copy` → schedule `cleanCopy`. This is **in addition to** step 2.
|
||
2. Classify the path:
|
||
- The flag `MustScanSubDirs` is set (a dropped event batch) → `project`.
|
||
- The path is inside the git directory → `git` only when the relative path equals, or is under, one of: `HEAD`, `index`, `refs/heads`, `refs/remotes`, `logs/HEAD`, `MERGE_HEAD`. Anything else in the git directory → dropped.
|
||
- The path is outside the root, or is the root itself → dropped.
|
||
- rel == `.helder/config.json` → `config`.
|
||
- `isWatchIgnored(rel, exclude: files.exclude)` → dropped. Otherwise → `project`.
|
||
3. Bookkeeping before scheduling:
|
||
- `project`: if it is a rescan, rel is empty, or the basename is `.gitignore` → clear the git-ignore cache and mark the batch as "fire unchecked". Otherwise add rel to the batch's changed paths.
|
||
- `git`: clear the git-ignore cache.
|
||
- `config`: re-read `.helder/config.json` (sparse overrides merged with the defaults) to refresh `files.exclude` and `followGitignore`; clear the ignore cache.
|
||
4. Schedule (debounce) the event.
|
||
|
||
**When `project` fires (`fireProject`):** take and reset the batch.
|
||
- If `followGitignore` is false, or the batch is unchecked, or the batch is empty → fire.
|
||
- If any path is cached as "not ignored" → fire.
|
||
- Paths not yet in the cache: if there are none (every path is cached as ignored) → **do not fire**.
|
||
- Otherwise run `git check-ignore -- <paths…>` in batches of **200** paths. Exit 0 or 1 is valid; any other exit or a failure → verdict unknown. Count the output lines (one line per ignored path). All ignored → true; none → false; a mix → nil.
|
||
- Verdict true → cache all as ignored, **do not fire**. Verdict false → cache all as not ignored, fire. nil → fire.
|
||
- Net effect: with `followGitignore` on, a burst that touches only git-ignored files fires nothing.
|
||
|
||
**What the workspace does with each event (WorkspaceModel.handle):**
|
||
|
||
| Event | Action |
|
||
|---|---|
|
||
| project | Schedule a refresh of scope {git, tree, symbols, openFiles}. |
|
||
| git | Schedule a refresh of {git}. |
|
||
| config | Reload the config immediately. |
|
||
| cleanCopy | Run the clean-copy check (section 16). |
|
||
|
||
**Scheduled refresh:** the scopes are merged into a pending set. One task waits **100 ms** (`refreshDebounce`), then runs the union. If more scopes came in meanwhile, it runs again afterwards. The `symbols` scope invalidates the symbol index and schedules a symbol reload **2000 ms** later (each change restarts this countdown). `tree` → `explorer.reload()`. `git` → git refresh. `openFiles` → the editor checks its open files against the disk.
|
||
|
||
**⌘R (refresh):** runs {git, tree} plus "reload the active file from disk" in parallel. Disk wins over unsaved edits. The columns flash.
|
||
|
||
---
|
||
|
||
### 9. Explorer column (ExplorerColumn, ExplorerStore)
|
||
|
||
**Layout:**
|
||
- Header: height 34 pt, horizontal padding 12, hairline below. On the left the text `Explorer`; on the right the project name, truncated in the middle, one line, at least 8 pt gap. Both use the panel-label role (mono bold 10, tracking 0.14 em, **uppercase**, so they show as `EXPLORER` and e.g. `CONSOLE`) in text4.
|
||
- Background: `panel` (#18202B); `panelActive` (#1B242F) when the Explorer is the active panel.
|
||
- The tree is a lazily rendered vertical list of the visible rows. Top padding 6, bottom padding 14. Its minimum height is the viewport height, so the bare space under the rows can be right-clicked.
|
||
- A left click anywhere in the column makes the Explorer the active panel, without taking keyboard focus.
|
||
- If the store has no tree yet when the column appears, it loads it once (`loadIfNeeded`).
|
||
|
||
**Row anatomy (TreeRowView)**, left to right, spacing 7:
|
||
|
||
| Part | Detail |
|
||
|---|---|
|
||
| Indent | Leading padding = 12 + depth × 16 pt. |
|
||
| Chevron slot | 10 × 10. A folder has a chevron: a stroked path (3.5,2)→(7,5)→(3.5,8) in a 10-unit box, line width 1.4, round caps and joins, scaled 0.9, **rotated 90° when open**. Colour amber when open, text4 when closed. A file has an empty 10 × 10 slot. |
|
||
| Icon | A folder has a 16 × 16 folder glyph (open or closed shape, see below). A file has its TypeBadge (28 × 16). |
|
||
| Name | The basename. Sans regular 13 (`row`), or sans medium 13 when selected. One line, tail truncation. **Struck through** in text4 when the git status is deleted. |
|
||
| Spacer | |
|
||
| Change letter | Only for files with a git status: the status letter (`A`, `M`, `D`, `R`, `U`), mono semibold 10, 8 pt leading padding. Colour **amberDeep (#C4741F) for `D`**, otherwise addedText teal (#8FBFB4). Folders never show a letter. |
|
||
|
||
- Row height **24 pt**, trailing padding 12.
|
||
- Name colour: text4 when deleted; otherwise text1 when the row is selected **or** it is an open folder; otherwise text3.
|
||
- Selected look: `raised` fill plus a 2 pt amber rule on the left edge. Hover: `hover` fill (a 0.16 s colour transition).
|
||
- Pointer: the pointing hand. Tooltip: the full relative path for a **file**; none for a folder.
|
||
- **Folder glyph** (drawn on a 16-unit grid scaled to the frame, stroke width 1.1, round joins, stroke text4):
|
||
- Closed: polygon (1.5,4.5)→(5.5,4.5)→(6.7,5.9)→(14,5.9)→(14,13)→(1.5,13), closed. Fill `#7A838C` at 12%.
|
||
- Open: back path (2,12.5)→(2,4.5)→(5.6,4.5)→(6.8,5.9)→(13.5,5.9)→(13.5,7.4), fill `#7A838C` at 16%. Front polygon (1.4,12.6)→(3.3,7.5)→(14.7,7.5)→(12.8,12.6), closed, fill `#7A838C` at 22%.
|
||
|
||
**Git status per file** (`fileStatuses`): for each change row, the unstaged status wins over the staged one (the staged one is used only when there is no unstaged row). The letter is the raw value: added `A`, modified `M`, deleted `D`, renamed `R`, unmerged `U`.
|
||
|
||
**Selection highlight:** a row is highlighted when any of these is true:
|
||
1. Its context menu is open (the menu's target equals this row's target).
|
||
2. The Explorer is the active panel **and** the row is the keyboard cursor (`selectedPath`).
|
||
3. It is a file **and** it is the file open in the editor.
|
||
|
||
**Hover moves the cursor:** hovering a row sets `selectedPath` to it. The list scrolls to `selectedPath` when it changes, **except** when the change came from hover (the path equals the hovered path), so that a cursor that follows the pointer never scrolls the list under it.
|
||
|
||
**Clicking a row:** sets `selectedPath`. A folder → toggle it. A file → open it in the editor (with the unsaved-changes check from the editor section).
|
||
|
||
**Toggle(folder):** add it to or remove it from `expanded`, then re-read that folder's children from disk (`refreshChildren`) on **both** expand and collapse, so files the agent added appear. A refreshChildren result is dropped when a full reload started meanwhile (generation counter).
|
||
|
||
**reload():** reads the whole tree and **keeps the expansion**. A newer reload makes an older result be dropped (generation counter).
|
||
|
||
**A new project starts fully collapsed.** The set of expanded folders is not persisted.
|
||
|
||
**Reveal and select:** opening a file from anywhere (Explorer, search, recent files, Git view, new file) expands every ancestor of the path and sets `selectedPath` to it (`select(path)`). This runs only after the editor accepted the open (it does not run when the unsaved-changes prompt is cancelled or its save fails).
|
||
|
||
**Hidden files:** the ⌘. toggle (title bar **Hidden**, menu item `Show Hidden Files` / `Hide Hidden Files`) flips `showHidden` for the window. It starts **off** on every launch and is **not persisted**. Off → any entry whose name starts with `.` is not shown, and neither is its subtree. It also feeds the search overlay. Title-bar tooltip: `Hidden files: hidden — dotfiles are excluded from the tree and the search. Click to show them.`, and when on: `Hidden files: shown — dotfiles appear in the tree and the search. Click to hide them.` (the middle word is emphasised).
|
||
|
||
**Not shown in the tree:** symlinks; the base ignore names (via ripgrep) or the walk-ignored names (via the walk); `.DS_Store`; `files.exclude` matches; git-ignored paths only when `followGitignore` is true (ripgrep path only).
|
||
|
||
#### Explorer keyboard
|
||
|
||
These keys work only when the keyboard owner is the workspace (no text field or terminal focused), no overlay is open, the Git view is closed, and the active panel is the Explorer. Keys with ⌃ or ⌥ are never handled.
|
||
|
||
| Key | Action |
|
||
|---|---|
|
||
| ↑ / ↓ (no ⇧) | Move the cursor one visible row. When no row is selected, the first row is selected. The cursor clamps at both ends (no wrap). |
|
||
| ↵ (no ⇧) | On a folder: toggle it. On a file: open it. |
|
||
| ⌘→ | Open the **row menu** of the cursor row (see below). With no cursor row, nothing happens. (When the Explorer is not active, ⌘→ moves the focus to the next column; see the layout section.) |
|
||
| ⌘← | Move the focus to the column on the left. |
|
||
| ⌘. | Toggle hidden files (works anywhere). |
|
||
| ⌘R | Reload tree, git and the open file (menu bar). |
|
||
|
||
**Row menu anchor (⌘→):** x = the right edge of the Explorer column's span (fallback 220). y = the row's reported top + 4. When the row never reported a frame: 44 (title bar) + 34 (panel header) + index × 24 + 4. Each row reports its window frame as it appears and moves, and reports nil when it leaves the screen.
|
||
|
||
**Mouse right-click anchor:** on a row → x = the column's right edge, y = the click y (the menu opens beside the column and never covers the rows). On the empty space → the click point. Right-click also makes the Explorer active and, for a row, sets `selectedPath` to it. A right-click is a right mouse-down **or ⌃+left-click**. The right-click catcher never takes left clicks or hover.
|
||
|
||
---
|
||
|
||
### 10. Create, rename and delete flows
|
||
|
||
**Entry points:** New file and New folder (folder menu, and New file only in the project-root menu), Rename file or folder (file or folder menu), Delete file or folder (file or folder menu). See section 13.
|
||
|
||
**The name prompt** (`NamePromptOverlay`), for New file, New folder, Rename file and Rename folder:
|
||
- It opens where the context menu stood. The menu's anchor is reused: x = min(anchor.x, window width − 460 − 8), y = min(anchor.y + 6, window height − 150), each at least 8. When opened without a menu: x = editor column start + 60, y = 150.
|
||
- **There is no dimming.** A transparent full-window layer cancels the prompt on click.
|
||
- Panel: width **460**, padding 14, vertical spacing 12, `panel` fill, radius 4, hairline border `raised`, menu shadow (radius 8, y 4).
|
||
- Row 1: an icon (`folder` or `doc` SF symbol, 13 pt light, amber), then the title (mono bold 13, text1), a spacer, then an `esc` chip.
|
||
- Row 2: a text field, height 38, mono regular 13, horizontal inset 10, `editor` fill, radius 2, with a focus ring. It takes the keyboard on open. Placeholder `file name…` or `folder name…`.
|
||
- Row 3: the preview label (panel-label role, text4: `creates` or `renames to`) and the preview chip (mono 12, **ink text on amber**, padding 8 × 4, radius 2, middle truncation). The chip shows the target path, or `…` while the name cannot be used.
|
||
- Row 4: footer hint `↵ <action> · esc cancel` (amber keys, text4 words, mono 11). Action = `create file`, `create folder`, `rename file`, `rename folder`.
|
||
|
||
| Purpose | Title | Placeholder | Preview label | Initial text |
|
||
|---|---|---|---|---|
|
||
| New file | `New file` | `file name…` | `creates` | empty |
|
||
| New folder | `New folder` | `folder name…` | `creates` | empty |
|
||
| Rename file | `Rename file` | `file name…` | `renames to` | current basename |
|
||
| Rename folder | `Rename folder` | `folder name…` | `renames to` | current basename |
|
||
|
||
**Rename initial selection:** only the **stem** is selected: from 0 to the last `.`, when there is a dot and it is not at index 0. A dotfile (`.env`), a name without a dot, or a non-rename selects the whole text.
|
||
|
||
**Preview target (`promptTarget`)** — also decides whether ↵ is allowed. Trim spaces (not newlines). Empty → nil (`…`).
|
||
- New file → `newEntryPath(dir, trimmed)`.
|
||
- New folder → `newEntryPath(dir, trimmed) + "/"`.
|
||
- Rename → `validatedName(trimmed)` must be non-nil **and differ from the current basename**; then `join(dirname(path), clean)`, with a trailing `/` for a folder. Otherwise nil.
|
||
|
||
**Keys:** ↵ submits only when the preview is not nil; the submitted name is trimmed of whitespace and newlines. Esc cancels. There are **no error messages inside the prompt**.
|
||
|
||
**On submit:** the prompt closes first, then:
|
||
- **New file:** path = `newEntryPath(dir, trimmed)`. If trimmed is empty or the path equals the folder → `invalidName`. Create the empty file (parent folders are created; refuse to overwrite). Reveal the path (expand its ancestors). Reload the tree. Toast `Created file` / `<path>`. Then **open the new file in the editor** (only if the editor is still the same, i.e. no project switch happened).
|
||
- **New folder:** the same, then also add the new folder to `expanded` (the parent and the new folder expand). Toast `Created folder` / `<path>`. Nothing is opened.
|
||
- **Rename:** validate (throw `invalidName`), rename on disk. If the new path equals the old one → no toast, nothing else. Otherwise remap the expanded set and the cursor over the rename (a folder moves everything under it), reload, toast `Renamed file` or `Renamed folder` / `<new path>`. Then the editor remaps every path-keyed state (open file, recent history, buffers, cursor, selection), so an open file stays open under its new name.
|
||
- After any success: refresh git.
|
||
- **On failure:** log `<purpose> failed: <error>` (category `fs`). Toast `Rename failed` / `<typed name>`, or `Create failed` / `newEntryPath(dir, name trimmed of spaces)`. Existing entries are never overwritten.
|
||
|
||
**Delete:**
|
||
- **Always asks first.** No setting turns this off. No other Explorer item asks.
|
||
- Confirm dialog (ConfirmOverlay), with the exact strings:
|
||
|
||
| Target | Title | Body | Button |
|
||
|---|---|---|---|
|
||
| File | `Delete file?` | `<path> will be permanently deleted.` | `Delete` |
|
||
| Folder | `Delete folder?` | `<path>/ and everything inside it will be permanently deleted.` | `Delete` |
|
||
|
||
- On confirm: permanent delete (no Trash). Remove every expanded entry inside the path (it is treated as a folder for this). Clear the cursor if it is inside the path. Reload. Toast `Deleted file` or `Deleted folder` / `<path>`. Then the editor forgets every state inside the path (the open file closes, the file drops out of recent files, buffers and cursor are cleared), and git refreshes.
|
||
- On failure: log `delete failed: <error>`; toast `Delete failed` / `<path>`; the editor is not touched.
|
||
|
||
**Confirm dialog (ConfirmOverlay)** — shared with the Git view's discard:
|
||
- A sized overlay card, width **460**, top-aligned, 34 pt inset from the window edges, on a flat scrim (`#101720` @ 72%). Card: `panel`, radius 8, hairline `raised`, overlay shadow (radius 24, y 16). A click on the scrim cancels.
|
||
- Content padding 20. Title: mono bold 14 (`dialogTitle`), text1. Body (optional): mono 12, line height 19.2, text4, 12 pt above it, wraps.
|
||
- Buttons row, 20 pt above, right-aligned, spacing 8: a secondary button `Cancel` with an `esc` keycap, then a destructive (amber-deep) button with the confirm label and a `↵` keycap (onDeep style).
|
||
- ↵ confirms, Esc cancels. While it is open, nothing else takes keys.
|
||
- Confirm runs the stored action with the default anchor.
|
||
|
||
---
|
||
|
||
### 11. Search overlay (⌘F) (SearchModel, SearchOverlay)
|
||
|
||
**Opening:** ⌘F (from anywhere with a project, including over the Git view and over the full-screen Diff), the title-bar **Search** button (tooltip `Search the open file, the project and the file names.`), or the menu item `Search`.
|
||
|
||
**Seed (the initial query):**
|
||
1. If the focused text view has a non-empty selection: the first line of the selected text, trimmed of spaces and tabs (not newlines).
|
||
2. Otherwise (and always from the title-bar button or the menu, which pass an empty seed): the editor's own line selection. Take the **whole text of the first selected line** of the active file, trimmed of spaces. This applies only when the selection belongs to the active file.
|
||
3. Otherwise empty.
|
||
|
||
**Placement:** full screen, edge to edge, over the title bar and the status bar. `editor` background. No scrim and no card; there is nothing to click to close it. It sits above the Git view; toasts sit above it.
|
||
|
||
**Model inputs:** the search service, the seed, the active file path (or nil), the active file's **buffer text** (unsaved edits included), the `showHidden` flag, the debounce (120 ms), and a file ranker.
|
||
|
||
**On start:** schedule the content search for the seed; load the full file list (`listFiles(nil)`) once; rank the file names; recompute. The in-file hits are computed right away in the constructor.
|
||
|
||
**term** = the query trimmed of spaces (not newlines).
|
||
|
||
**Three indexes, one query:**
|
||
|
||
| Column | Shown | Minimum length | Matching |
|
||
|---|---|---|---|
|
||
| This file | only when a file is open | 1 character | Case-insensitive substring, first hit per line (InFileSearch). Lines are split on `\n`. Line numbers start at 1. The offset is in UTF-16. Capped at **200** hits. |
|
||
| Project | always | **2 characters** | ripgrep fixed-string, smart-case (exact case when the query has a capital letter). Debounced **120 ms**. |
|
||
| Files | always | 1 character | Fuzzy rank over all paths. Hidden paths (any segment starting with `.`) are left out unless showHidden is on. |
|
||
|
||
**Content search lifecycle:** on each term change, cancel the pending search. Term < 2 characters → clear the content immediately, no search. Otherwise wait 120 ms (a cancel during the wait aborts it), run `searchContent(term)`, and apply the result only if the task was not cancelled and the term is still the same. A slow stale search never overwrites a newer one.
|
||
|
||
**Change rules (compute once):** derived lists are computed once per change, not on each read.
|
||
- `setQuery(v)`: if v equals the current query → nothing. Reset all three row selections to 0. If only whitespace changed (the term is the same) → stop here. Otherwise recompute the in-file hits, re-rank the file names, schedule the content search, and recompute the content-derived lists.
|
||
- New content results → recompute the content-derived lists only (no re-rank).
|
||
- Choosing a type chip → refilter only (no re-rank). It also resets the selections.
|
||
- Toggling showHidden while the overlay is open → re-rank once and recompute. (The overlay takes the flag when it is created.)
|
||
|
||
**Recompute content:**
|
||
1. shownContent = all content groups, minus groups whose path is hidden when showHidden is off.
|
||
2. Chip counts = extension counts over (shownContent paths + **all** file-name match paths, before the type filter). Files with no extension are not counted. Sort by count descending, then extension ascending. Cap at **12**. Chips exist only when there is **more than one** type; otherwise there are none.
|
||
3. If the chosen type is no longer among the chips → clear the type filter (show every type).
|
||
4. Refilter.
|
||
|
||
**Refilter:**
|
||
- visible = shownContent, filtered to `ext == chosen` when a type is chosen.
|
||
- groups: for each visible group, rows = the first **12** hits (`shownHitsPerFile`), each with a running keyboard index across all groups; `hitCount` = all of the group's hits (≤ 50).
|
||
- hitRows = all rows flattened. totalHits = the sum of hitCount over the visible groups.
|
||
- fileMatches = all file matches, filtered by the chosen type. shownFileMatches = the first **40**.
|
||
|
||
**Fuzzy file ranking (exact algorithm):**
|
||
1. term = query trimmed of spaces; empty → no results.
|
||
2. For each path (skip hidden paths unless showHidden):
|
||
- `match(q, text)`: lowercase both; walk the text characters left to right, greedily matching the next query character; collect the matched character offsets. All query characters matched → the offsets; otherwise nil. It is a subsequence match, greedy and leftmost.
|
||
- If the term matches the **basename** → rank 0, nameIndices = offsets in the basename, position = first offset.
|
||
- Else if it matches the **full path** → rank 1, nameIndices nil, position = first offset in the path.
|
||
- Else no match.
|
||
3. Sort by (rank, position, path length in characters), ascending. Ties keep no particular order (the sort is not guaranteed stable).
|
||
|
||
**Summary text** (to the right of the chips): `"<n> here · "` only when a file is open, then `"<totalHits> hit"` (+`s` unless 1), `" · "`, `"<fileMatches.count> file"` (+`s` unless 1). Example: `0 here · 39 hits · 2 files`. The file count is the filtered match count, not capped at 40.
|
||
|
||
**Empty messages** (verbatim; the message replaces the column's rows):
|
||
|
||
| Column | Condition | Text |
|
||
|---|---|---|
|
||
| This file | term empty | `Type to search this file.` |
|
||
| This file | no hits | `No matches in this file.` |
|
||
| Project | term length < 2 | `Type at least two characters.` |
|
||
| Project | no groups | `No content matches.` |
|
||
| Files | term empty | `Type to search file names.` |
|
||
| Files | no matches | `No file names match.` |
|
||
|
||
Note: "No content matches." also shows during the 120 ms debounce, before the first result arrives.
|
||
|
||
**Layout:**
|
||
- **Query bar:** height 54. Leading padding 82 (room for the traffic lights), or 18 in macOS full screen. Trailing padding 18. Hairline below. Spacing 12. Contents: a magnifying-glass icon (13 pt, text4); the query field (mono medium 16, placeholder `Search this file, the project, and file names…`, takes the keyboard, no initial selection); the chips; the summary (mono 11, text4, one line, 12 pt leading padding, hairline on its leading edge).
|
||
- **Chips:** spacing 4. Each chip shows the extension (mono semibold 10), padding 6 × 4, radius 2, hairline border. It is "on" when no type is chosen **or** it is the chosen one. On: amber fill and border, ink text. Off: clear fill, `raised` border, text3 text. Pointing hand. Tooltip: `"<count> result(s) · click to show only this type"`, or for the chosen chip `"<count> result(s) · click to show every type"` (the word is `result`, with `s` unless the count is 1). Click = toggle: clicking the chosen chip again shows every type.
|
||
- **Columns** (fixed widths that never follow the focus), with total = window width:
|
||
- With This file: thisFile = round(total × 0.30), files = round(total × 0.25), project = total − the others.
|
||
- Without: files = round(total × 0.35), project = the rest.
|
||
- The project column is drawn 1 pt narrower per hairline divider (1 divider without This file, 2 with). 1 pt vertical hairlines separate the columns.
|
||
- **Column header:** padding 14 horizontal (16 for Project), 12 top, 10 bottom, `panel` background. It holds an optional TypeBadge (This file only: the open file's badge), the title (panel-label role: uppercase mono bold 10, middle truncation), and an optional count (mono semibold 10). Focused column: the title is amber; the count is ink on an amber pill (padding 6 × 3, radius 2). Unfocused: text4, no pill.
|
||
- This file: title = the open file's basename; count = the hit count (hidden when 0).
|
||
- Project: title `Project`; count = totalHits (hidden when 0).
|
||
- Files: title `Files`; count = fileMatches.count (**always shown**, 0 included).
|
||
- **Empty message style:** sans 12 / line height 18, text4, padding 14 horizontal, left-aligned.
|
||
- **Hit line** (This file and Project): height 24. Line number: mono 12, right-aligned in a 50 pt box plus 14 pt trailing padding (a 64 pt gutter), amber when selected, else text5. Then the line text, one line, tail truncation, 14 pt trailing padding. Selected: `raised` fill plus the 2 pt amber rule.
|
||
- **Highlight run in a hit line:** start = clamp(matchOffset, 0, length). The run length = the **UTF-16 length of the term**, clamped to the line end. Text before and after: text2 when selected, else text3. The run: on the selected row, ink text on an amber background; elsewhere amberSoft text, no background.
|
||
- **Project group header:** padding top 14, leading 16, bottom 6, trailing 16, spacing 8. TypeBadge, the full path (mono 12, text3, middle truncation), spacer, then the hit count (mono 12, text4). Hover fill. Pointing hand. Click → open the file at its **first shown hit's line**. A group header is not keyboard-selectable.
|
||
- **Files row:** padding 14 horizontal, 4 vertical, minimum height 26, spacing 8. TypeBadge; a stack with spacing 1: the basename with fuzzy-matched letters in **bold amber** (sans medium 12 bold) and the other letters text1 when selected, else text3; the row uses sans medium 13 when selected, else sans 12. Under it, `dir + "/"` (mono 11, text4, head truncation) only when the directory is not empty. On the right, a `•` (mono semibold 10, teal `#8FBFB4`) when the path has a git change. Matched letters are only marked for basename matches (rank 0); path-only matches show no marking.
|
||
- **Footer** (height 38, hairline above, padding 18): `⌘← / ⌘→ column ⌘↑ / ⌘↓ row ↵ open`, with keys in amber, ` / ` and the words in text4, three spaces between groups, mono 11. On the right an `esc` chip.
|
||
|
||
**Keyboard** (handled by the query field):
|
||
|
||
| Key | Action |
|
||
|---|---|
|
||
| ⌘← / ⌘→ | Previous / next column. It stops at the ends (no wrap). Column order: This file, Project, Files. The initial focused column is **Project**. |
|
||
| ↑ / ⌘↑ | Previous row in the focused column (clamped at 0). |
|
||
| ↓ / ⌘↓ | Next row (clamped at count − 1). |
|
||
| ↵ | Open the target (see below). |
|
||
| Esc | Close. |
|
||
| ⌘P, ⌘↵ | Not handled here (passed on). |
|
||
|
||
The focused column shows its focus only by its amber title and count pill.
|
||
|
||
**↵ target:**
|
||
- This file: the active path at the selected hit's line; nil if there are no hits.
|
||
- Files: the selected file (no line). If Files is empty → fall back to the selected project hit.
|
||
- Project: the selected hit (path + line). If Project is empty → fall back to the **first** file match (no line).
|
||
|
||
**Mouse:** hovering a row selects it **and** focuses its column. When the keyboard moved a row, the pointer location is "parked"; hover is ignored while the pointer stays at that exact screen point, so rows that scroll under a still pointer do not steal the selection. Clicking a row opens it. Each column scrolls to keep its selected row visible.
|
||
|
||
**Opening a result:** close the overlay, then open the file with an optional line. The editor jumps to the line with a flash (editor section), and the Explorer reveals and selects the file.
|
||
|
||
**What is searched:** the whole project, dotfiles included (`--hidden`). Hidden results are filtered out in the UI unless Hidden is on. The same base excludes, `files.exclude` and `followGitignore` as the tree. Without ripgrep, the walk is used, with the 300 000-byte and binary limits.
|
||
|
||
---
|
||
|
||
### 12. Recent files (⌘↑ / ⌘↓) (RecentFilesOverlay, RecentFilesStore)
|
||
|
||
**Storage:** per project, in `<root>/.helder/recent.json`: a JSON array of relative paths, newest first, pretty-printed, slashes not escaped, written atomically. The folder is created when needed. Max **100**. A load error gives an empty list. A save error logs a warning `cannot save recent files: <error>` (category `recent`).
|
||
|
||
**Updating:** each open in the editor moves the path to the front, de-duplicated, capped at 100. It is saved soon after, together with the session. A rename remaps the entries (a folder rename moves everything under it). An Explorer delete removes every entry inside the path. A file deleted outside Helder **stays** in the list. The list is loaded on project open (session restore).
|
||
|
||
**Opening:** ⌘↓ or ⌘↑, only when the keyboard focus zone is the **editor** and the history has at least one entry. No ⇧. (The key is free of all overlays and of the Git view.)
|
||
- ⌘↓ starts on row 1 (the previous file), or row 0 if there is only one entry: `max(0, min(1, count − 1))`.
|
||
- ⌘↑ starts on row 0 (the current file).
|
||
|
||
**Overlay:** a sized card, width **560**, top-aligned at the 34 pt inset, on the scrim (a click on the scrim closes it).
|
||
- Header (height 50, padding 18, hairline below): a `doc` icon in **text4** (not amber), the title `Recent files` (mono bold 14), no esc chip. On the right, a bordered box (`raised` hairline, radius 2, padding 6 × 4, mono 12, text4) that holds `"<n> file(s) ·"` and the keycaps `⌘↓`, `⌘↑`, `↵`.
|
||
- List: vertical padding 6. Height = min(460, max(count, 1) × 38 + 12 + (12 if empty)).
|
||
- Empty: `No files opened yet` (sans 12/18, text4, padding 12/14).
|
||
- Row: height 38, padding 14, spacing 10. TypeBadge; a stack with spacing 1: the basename (sans medium 13, text1 when selected, else text3) and `dir + "/"` (mono 11, text4, head truncation; empty text for a top-level file); a spacer; a teal `•` when the file has a git change. Selected look: raised fill plus the amber rule.
|
||
|
||
**Keys:** ↑/⌘↑ and ↓/⌘↓ move the selection, clamped (no wrap). ↵ opens the selected file. Esc closes. Hover selects (with the same pointer-parking rule as search). A click opens. Opening = close, then open the file (no line). There is no search field and no fuzzy matching.
|
||
|
||
---
|
||
|
||
### 13. Context menus
|
||
|
||
**General behaviour (ContextMenuOverlay):**
|
||
- Helder draws its own menu. Panel: width **320**, vertical padding 8, `panel` fill, radius 4, hairline `raised` border, menu shadow (radius 8, y 4).
|
||
- **Header** (optional; only when the header text is not empty): mono 11, text4, one line, middle truncation, 14 pt horizontal padding, 8 pt below, a hairline, then 8 pt more.
|
||
- **Item row:** height 30, leading padding 16, trailing 14, spacing 10. Icon (a 15 pt wide slot; an SF Symbol at 12 pt light, or the custom "spark" glyph 13 × 13 with stroke 1.1 × 13/16). Label: sans 13 (regular; **medium** when highlighted; **semibold** when emphasised). Pointing hand.
|
||
- **Highlighted item:** `raised` fill, 2 pt amber rule on the left, label text1, icon amber **unless** the icon has a tint (a tinted icon keeps its tint).
|
||
- Unhighlighted: label text3, icon text4 or its tint.
|
||
- **Destructive item** (Delete, Discard): the label and the icon are **always** amberDeep `#C4741F`, in every state.
|
||
- **Separator:** a 1 pt hairline with 6 pt above and below.
|
||
- The **first selectable item is pre-highlighted** when the menu opens.
|
||
- **Keys:** ↑/⌘↑ and ↓/⌘↓ move the highlight. It **wraps around** and **skips separators**. ↵ runs the highlighted item. Esc closes. Hover highlights. A click runs the item.
|
||
- **Outside click:** any left, right or other mouse-down in the **same window** outside the menu closes it, and the click **still reaches** what was clicked. A click in another window leaves it open.
|
||
- **Position:** estimated height = entries × 34 + 60. x = min(anchor.x, window width − 320 − 8), y = min(anchor.y, window height − height), each at least 8.
|
||
- The row whose menu is open stays highlighted until the menu closes.
|
||
- No item is ever greyed out. An item that does not apply is left out.
|
||
- Running an item: the menu closes first and hands its anchor on, so a prompt that the item opens appears in the same place.
|
||
|
||
**Icons and tints per action:**
|
||
|
||
| Action | Icon (SF Symbol) | Tint |
|
||
|---|---|---|
|
||
| Pass on reference / selection, Pass on file name | custom spark | rename (grey `#BAC0C0`) |
|
||
| Copy reference, Copy (terminal) | `doc.on.doc` | plain |
|
||
| Copy file name | `doc.on.doc` | modify (amberSoft `#F0B476`) |
|
||
| Paste (terminal) | `doc.on.clipboard` | plain |
|
||
| New file | `doc.badge.plus` | add (teal `#8FBFB4`) |
|
||
| New folder | `folder.badge.plus` | add (teal) |
|
||
| Rename file / folder | `pencil` | rename (grey) |
|
||
| Show in Finder | `folder` | modify (amberSoft) |
|
||
| Delete file / folder | `trash` | danger (amberDeep), destructive |
|
||
| Discard (git) | `arrow.uturn.backward` | danger, destructive |
|
||
| Open in editor | `doc.text` | plain, **emphasised (bold)** |
|
||
| Commit | `checkmark` | plain |
|
||
| Commit and push | `arrow.up.to.line` | plain, **emphasised (bold)** |
|
||
| Show diff | `arrow.left.arrow.right` | rename (grey) |
|
||
| Bouwen | `hammer` | rename (grey) |
|
||
| Wait what? | `questionmark.bubble` | rename (grey) |
|
||
| Read aloud / Read aloud selection | `speaker.wave.2` | plain |
|
||
| Plak | `note.text.badge.plus` | plain |
|
||
|
||
"plain" = text4 at rest, amber when highlighted.
|
||
|
||
**Header text per target:** file → its path; Git row → its path; project root → `<project name>/`; editor, folder, terminal, commit menu → no header.
|
||
|
||
#### 13.1 Explorer file — header: the file path
|
||
|
||
```
|
||
Pass on reference
|
||
Copy reference
|
||
Pass on file name
|
||
Copy file name
|
||
—— (only for .md files:)
|
||
Read aloud
|
||
——
|
||
Rename file
|
||
Show in Finder
|
||
Delete file (destructive)
|
||
```
|
||
|
||
The reference = the path. The file name = the basename.
|
||
|
||
#### 13.2 Explorer folder — no header
|
||
|
||
```
|
||
(only for a direct child of ontwikkelingen/, except ontwikkelingen/ontwikkeld:)
|
||
Bouwen
|
||
——
|
||
Pass on reference
|
||
Copy reference
|
||
——
|
||
New file
|
||
New folder
|
||
——
|
||
Rename folder
|
||
Show in Finder
|
||
Delete folder (destructive)
|
||
```
|
||
|
||
- The reference is the folder path **with a trailing `/`** (e.g. `app/Http/`).
|
||
- The **Bouwen** rule: the path splits into exactly 2 segments, the first is `ontwikkelingen`, and the second is non-empty and not `ontwikkeld`. Deeper folders do not get it.
|
||
|
||
#### 13.3 Explorer empty space (project root) — header `<project name>/`
|
||
|
||
```
|
||
New file (in the root; a name with slashes creates the folders)
|
||
Show in Finder (the project folder)
|
||
```
|
||
|
||
There is no New folder here.
|
||
|
||
#### 13.4 Editor (code in the file view) — no header
|
||
|
||
The reference is `path:line` for the clicked line when there is no selection (the line under the click; below the last line → the last line; at least 1), or `path:start-end` (`path:start` when start == end) for the lines the selection touches. `code` = the selected text.
|
||
|
||
Without a selection:
|
||
```
|
||
Pass on reference
|
||
Copy reference
|
||
```
|
||
With a selection (code not empty):
|
||
```
|
||
Pass on selection
|
||
Copy reference
|
||
——
|
||
Read aloud selection
|
||
——
|
||
Plak
|
||
```
|
||
On a marked (changed) line, when the file offers Show diff, add at the end:
|
||
```
|
||
——
|
||
Show diff
|
||
```
|
||
- Order with a selection on a marked line: Pass on selection, Copy reference, ——, Read aloud selection, ——, Plak, ——, Show diff.
|
||
- Show diff applies when the whole row under the pointer is a marked line (a blank line and the space after the text count) and the file offers Show diff (not a new file where every line is marked). It opens the Diff of the open file centred on that line, only if that file is still the active one.
|
||
- Read aloud selection on a Markdown file reads the selection's prose (Markdown parsed, then turned into plain text). If no prose is left (for example one code block), it reads the raw selection.
|
||
- The **Markdown preview** and **image** views use the same menu with reference `path:1`, code nil (Pass on reference, Copy reference only).
|
||
|
||
#### 13.5 Diff (full-screen) — header empty
|
||
|
||
```
|
||
Pass on reference (path:line; line from the clicked side: left = old, right = new; an empty half → line 1)
|
||
Copy reference
|
||
```
|
||
- The menu is drawn inside the Diff, with its own highlight state. The click-away layer covers the Diff. Position: entries × 30 + 60 for the height estimate, clamped inside the Diff.
|
||
- Pass on opens the pass-on prompt inside the Diff. Esc closes the innermost layer: the menu, then the prompt, then the Diff.
|
||
- Implementation quirk: this menu always draws the header component, even with empty text, so an empty header line and hairline appear (see Conflicts).
|
||
|
||
#### 13.6 Git row (Git view) — header: the path
|
||
|
||
```
|
||
Open in editor (bold; left out for a deleted file)
|
||
—— (left out with it)
|
||
Pass on reference
|
||
Copy reference
|
||
```
|
||
|
||
Open in editor and Pass on reference close the Git view first. (Commit menu, for completeness: no header, `Commit`, `Commit and push` (bold). Owned by the git section.)
|
||
|
||
#### 13.7 Terminal panes (Claude Code pane = agent, Command line pane = shell) — no header
|
||
|
||
With a selection:
|
||
```
|
||
Copy
|
||
Paste
|
||
——
|
||
Read aloud selection
|
||
——
|
||
Plak
|
||
—— (agent pane only:)
|
||
Wait what?
|
||
```
|
||
Without a selection:
|
||
```
|
||
Paste
|
||
```
|
||
|
||
**What each action does:**
|
||
|
||
| Action | Effect | Toast |
|
||
|---|---|---|
|
||
| Pass on reference / selection | Opens the pass-on prompt (agent section) at the menu's anchor, with the reference, plus the code for a selection. **Closes the Git view first.** | — |
|
||
| Pass on file name | Opens the pass-on prompt with only the basename. | — |
|
||
| Copy reference | Copies the reference text (`path`, `path/`, `path:N`, `path:A-B`) to the general pasteboard as plain text. | `Copied reference` / `<text>` |
|
||
| Copy file name | Copies the basename. | `Copied` / `<name>` |
|
||
| Show in Finder | Opens a Finder window with the item selected (absolute path). The root target `""` reveals the project folder. Nothing happens if the path escapes the root. | — |
|
||
| New file / New folder | Name prompt (section 10). | |
|
||
| Rename | Name prompt with the current name. | |
|
||
| Delete | Confirm, then delete (section 10). | |
|
||
| Bouwen | Inserts `/bouwen <folder name>` into the agent composer, **not submitted**. | `Passed to agent` / `/bouwen <name>` |
|
||
| Read aloud (file) | The open, loaded file is read from its **buffer** (unsaved edits included); any other file is read from disk. The Markdown is turned into prose and spoken. A new read replaces the one playing. | `Nothing to read` / `<path>` when there is nothing to read |
|
||
| Read aloud selection (editor) | Speaks the precomputed text. | — |
|
||
| Read aloud selection (terminal) | Selection trimmed; prose of the parsed Markdown, or the raw text if no prose is left. | `Nothing to read` (no detail) when nothing is spoken |
|
||
| Plak (editor) | Sends the selected code (trimmed). | `Nothing to send` if blank |
|
||
| Plak (terminal) | Fetches the pane's selection when the item runs; sends it trimmed. | `Nothing to send` if blank |
|
||
| Copy (terminal) | Copies the pane's selection. | — |
|
||
| Paste (terminal) | Types the pasteboard text into that pane as a normal paste. Nothing happens with an empty pasteboard. | — |
|
||
| Wait what? | Selection trimmed of whitespace and newlines. If not empty, inserts ``/wait-what `<text>` `` into the agent composer, not submitted. | `Passed to agent` / `/wait-what` |
|
||
| Open in editor | Closes the Git view, opens the file. | — |
|
||
| Show diff | Opens the Diff at the line. | — |
|
||
|
||
**Confirmation guard:** before running any menu action, the workspace asks the git store (`git.confirmDiscard`) and then the Explorer whether it needs a confirmation. Only Delete (Explorer, always) and Discard/Delete (Git view, by setting) do.
|
||
|
||
---
|
||
|
||
### 14. Plak (Plak, SystemActions.sendToPlak)
|
||
|
||
Plak is the user's separate macOS scratchpad app. Helder sends text to it through a URL scheme. There is no callback; Helder cannot know whether it worked.
|
||
|
||
**Rule:**
|
||
1. The caller trims the text (whitespace and newlines). If it is empty → toast `Nothing to send` and stop.
|
||
2. If the text is **≤ 100 000 UTF-8 bytes** → open `plak://append?text=<encoded>`.
|
||
- Build it as a URL with scheme `plak`, host `append`, one query item `text`. Then replace every `+` in the percent-encoded query with `%2B`. Standard query encoding leaves `+` bare, and Plak would read it literally. A space must be `%20`, never `+`. Newline → `%0A`, `&` → `%26`, `#` → `%23`.
|
||
- If no URL can be built → log `could not build the append URL` (category `plak`); nothing is sent.
|
||
3. If the text is **> 100 000 bytes** → go through the pasteboard:
|
||
1. Save every item of the general pasteboard (each type with its data).
|
||
2. Put the text on the pasteboard (clear, then set a plain string).
|
||
3. Note the pasteboard change count.
|
||
4. Open `plak://paste`.
|
||
5. **1 second later**: only if the change count is still the same (nothing else was copied in that second): clear the pasteboard and, if there were saved items, write them back.
|
||
4. Plak starts if it is not running, shows its window scrolled to the new block, and takes the focus. Helder does not wait for it.
|
||
|
||
`plak://` contract: an empty or missing `text` adds nothing but still shows Plak. `plak://paste` adds the pasteboard contents (text or images). Plak detects PHP, JSON, XML and CSV as a code block or table; anything else is plain text.
|
||
|
||
---
|
||
|
||
### 15. Pasteboard and Finder (SystemActions)
|
||
|
||
- **copy(text):** clear the general pasteboard, set a plain string.
|
||
- **pasteboardText():** the plain string, or nil.
|
||
- **revealInFinder(url):** Finder opens with the item selected.
|
||
- **chooseFolder:** a folder picker, folders only, single selection, button `Open`, message `Choose a project folder`.
|
||
- **Unsaved-close alert** (editor section; listed here as a dialog): warning style, title `Save changes to <basename>?`, text `<path> has unsaved edits. They are lost if you close without saving.`, buttons `Save`, `Don’t Save` (typographic apostrophe), `Cancel`. ↵ = Save, Esc = Cancel.
|
||
|
||
---
|
||
|
||
### 16. Clean Copy (CleanCopy, CleanCopyStore, CleanCopyOverlay)
|
||
|
||
**The channel:** one file, `.clean-copy`, in the project root. The agent overwrites the whole file each time. Helder **only reads** it and never clears or deletes it. Both terminals run with `TERM_PROGRAM=Helder`, so the agent knows it runs inside Helder. The file shows in Git and in the Explorer like any other file.
|
||
|
||
**Detection:** the watcher fires `cleanCopy` 0.15 s after the last change to `<root>/.clean-copy`. It also fires `project`.
|
||
|
||
**Baseline:** on project open, read the file's current text and store it as `lastSeen` (nil when the file is missing). The baseline **never opens** the popup.
|
||
|
||
**On a change (`fileChanged`):**
|
||
1. Read the file. If the read fails (missing or unreadable) → do nothing (lastSeen stays as it was).
|
||
2. `isNew` = the text holds more than whitespace and newlines **and** text ≠ lastSeen.
|
||
3. Set lastSeen = text (always, even when it is not new).
|
||
4. If new → `pending` = text (the newest text replaces older pending text).
|
||
5. Only if new, and the project did not switch meanwhile → `showCleanCopy`.
|
||
|
||
**showCleanCopy:**
|
||
- No overlay open → move pending into the popup (text = received = pending; pending cleared) and present the **From Claude** popup.
|
||
- The Clean Copy popup is already open → if the user has **not edited** (text == received), take the pending text (the popup shows it). If the user **has** edited, keep the edits and **drop** the new text. In both cases pending is cleared.
|
||
- Any other overlay open (search, a dialog, a menu, the Diff, recent files, the pass-on prompt, …) → **wait**. Whenever the overlay becomes `none` and something is pending, `showCleanCopy` runs again on the next main-loop turn. Only the newest text shows.
|
||
- The popup opens in that project's window even when the window is in the background. Helder does **not** come to the front.
|
||
|
||
**Popup layout:** a sized card, width **780**, top-aligned at the 34 pt inset, on the scrim (a click on the scrim closes it without copying). It fills the available height.
|
||
- Header (height 50, padding 18, hairline below): a `doc.on.clipboard` icon (amber, 14 light), the title **`From Claude`** (mono bold 14, text1), the detail `.clean-copy` (mono 12, text4), a spacer, then a primary (amber) button `Copy` with a small `⌘↩` keycap (onAmber style), then the `esc` chip.
|
||
- Text area: a plain-text editor, mono 14 with line height 23.8, text colour `#E4E7E6`, **amber caret** `#E8913A`, inset 20 × 18, vertical scroller (auto-hide), undo on, no smart quotes or dashes, no spell check or autocorrect. On open it takes the keyboard with the caret at the **end**, scrolled to it. Edits update the store's text.
|
||
- Footer (height 34, hairline above, padding 20): `copied as plain text · <n> characters`. n = the character count of the current text (grapheme clusters), live. Mono 11, text4.
|
||
|
||
**Keys:** ⌘↩ (Return or keypad Enter) = Copy; Esc = close without copying. These are caught before the menu bar sees them.
|
||
|
||
**Copy:** only while the popup is open: put the current text (with edits) on the pasteboard as plain text, close the popup, toast `Copied` / `<n> characters`.
|
||
|
||
---
|
||
|
||
### 17. Overlay rules relevant here
|
||
|
||
- **Exactly one overlay at a time.** Presenting one replaces the current one. The overlays: none, search, shortcuts, cleanCopy, diff, launcher, recentFiles, passOn, symbol, contextMenu, namePrompt, confirm.
|
||
- Esc (no ⌘) closes the open overlay. With none open and the Git view open, Esc closes the Git view. Otherwise it passes to the focused view (the terminal).
|
||
- While any overlay other than the Diff is open, it owns every key except Esc. (Over the Diff, the workspace shortcuts keep working; when the Diff's own menu or prompt is open, they own all keys.)
|
||
- With an overlay open, everything behind it shows the arrow pointer.
|
||
|
||
---
|
||
|
||
### 18. Doc-versus-code conflicts (code wins)
|
||
|
||
| # | Topic | Docs say | Code does |
|
||
|---|---|---|---|
|
||
| 1 | Explorer right-click (behaviour.md §4) | A file offers only **Copy reference** (plus Read aloud). | The full file menu: Pass on reference, Copy reference, Pass on file name, Copy file name, [Read aloud], Rename file, Show in Finder, Delete file. |
|
||
| 2 | Code right-click (behaviour.md §5) | Two items, Copy reference first, then "Pass on to Agent". | Pass on reference/selection comes **first**, then Copy reference. The label is "Pass on reference" or "Pass on selection". |
|
||
| 3 | Go to File ⌘P (behaviour.md §9) | ⌘P opens a fuzzy file-open overlay. | There is no ⌘P file overlay. ⌘P **pushes** (git). File names are fuzzy-searched in the Search **Files** column. Recent files are ⌘↑/⌘↓ (guide go-to-file.md agrees with the code). |
|
||
| 4 | Search split (behaviour.md "Open assumptions") | Content 70% left, file names 30% right. | 30/45/25 with This file, otherwise 65/35 (behaviour.md §9 and search.md agree with the code). |
|
||
| 5 | Explorer status-letter colours (explorer.md) | `A`, `M`, `R` teal; `D` amber-deep. | Matches, but there is also a `U` (unmerged) letter, shown in teal. The docs leave it out. |
|
||
| 6 | Hidden files persistence | layout docs may imply a saved flag; explorer.md says "holds for the whole window". | `showHidden` is per window and in memory only. It resets to off on each launch. |
|
||
| 7 | Recent files "Deleted files drop out" (go-to-file.md) | Deleted files drop out. | Only files deleted through Helder's Explorer drop out. A file deleted on disk by another program stays in the list. |
|
||
| 8 | Search ignore list (search.md) | Lists 14 folders. | It also skips `.DS_Store` (ripgrep base list). |
|
||
| 9 | Explorer ignore list (explorer.md) | One list for "never shows". | Via ripgrep: `ripgrepBaseIgnore`. Via the walk fallback: `walkIgnoredNames` plus `.DS_Store`, and the walk **ignores `files.exclude` and `followGitignore`**. |
|
||
| 10 | Diff context menu (right-click-menu.md) | "It has no header." | Header text is empty, but the Diff menu still draws the header component (an empty line with a hairline under it). |
|
||
| 11 | Project column empty state | "No content matches." when nothing matches. | It also shows during the 120 ms debounce, before results arrive. |
|
||
| 12 | Context-menu height estimate | — | The main overlay estimates 34 pt per entry; the Diff menu estimates 30 pt per entry (only affects clamping near the window edge). |
|
||
| 13 | right-click-menu.md "Copy file name and Show in Finder have an amber icon" | amber | The tint is amberSoft `#F0B476` (`menuIconModify`), not the main amber. |
|
||
| 14 | Clean copy toast (clean-copy.md) | The toast says "Copied". | Title `Copied`, detail `<n> characters`. |
|
||
| 15 | Name prompt validation (dialogs.md) | A rename refuses a name with `/`. | Trailing slashes are stripped first, so `name/` is accepted as `name`. New file/folder accept inner slashes and create the folders. |
|
||
| 16 | `followGitignore` with no ripgrep | Docs: hides git-ignored files from the tree. | The tree's walk fallback never honours it. Only the walk **search and file list** (via `git ls-files`) do. |
|
||
|
||
|
||
---
|
||
|
||
## 7. Terminals, pass-on, processes, configuration, lifecycle and logging
|
||
|
||
This section covers Column D (the agent terminal on top, the shell terminal below), how text is passed into the agent, every way Helder runs a child process, the per-project configuration system, the window/project lifecycle and refresh rules, the project title, and the log file. Where code and docs disagree, this section describes the CODE; the conflicts are listed at the end.
|
||
|
||
---
|
||
|
||
### 7.1 Column D layout (AgentColumn)
|
||
|
||
| Item | Behaviour |
|
||
|---|---|
|
||
| Structure | A vertical stack: agent pane on top, a horizontal splitter, shell pane below. |
|
||
| Agent pane height | `column height × layout.agentFraction`. The shell pane takes the rest. |
|
||
| `agentFraction` | Default `0.52`, clamped to `0.18 … 0.82`. Persisted app-wide (not per project) under key `helder.topFrac`. Dragging the splitter by `delta` px sets `(agentFraction × height + delta) / height`, clamped, and saves it. |
|
||
| Column background | Palette panel colour `#18202B`. |
|
||
| Pane chrome | NO header bar on either pane (the old "claude / agent session" and "zsh + path" headers are gone). Each pane is the live terminal with 12 px padding on all sides; the padding area is painted in `terminal.theme.background` (fallback `#101720`). |
|
||
| Identity | The column is keyed on the identity of the current `TerminalStore`. A project switch creates a new store, so the column is rebuilt with fresh terminal views and fresh processes. |
|
||
| Focus request | When the workspace's focus request targets the terminal panel (e.g. `⌘3` focus / focus neighbour), the AGENT pane's view becomes first responder and the request is marked taken. |
|
||
| Hiding the column | Hiding Column D (title-bar toggle / `⌘3`) only hides it; both processes keep running and keep their output. |
|
||
|
||
---
|
||
|
||
### 7.2 Terminal kinds and launch (TerminalKind, TerminalLaunch, TerminalStore)
|
||
|
||
Two kinds: `agent` (top) and `shell` (bottom). Each pane runs one child process in a pseudo-terminal (PTY, via forkpty).
|
||
|
||
#### Launch computation (TerminalLaunch.make)
|
||
|
||
| Field | Value |
|
||
|---|---|
|
||
| Executable | `config.terminal.shell` if non-null, else `$SHELL` from Helder's own environment, else `/bin/zsh`. Same shell for both panes. |
|
||
| Arguments, agent pane with `ai.autoLaunch == true` | `["-i", "-c", <ai.command>]`. The whole `ai.command` string is ONE argument (e.g. `"claude --model opus"`), interpreted by the shell. |
|
||
| Arguments, agent pane with `ai.autoLaunch == false` | `[]` (plain interactive login shell). |
|
||
| Arguments, shell pane | `[]` always. |
|
||
| argv[0] | `"-" + basename(executable)`, e.g. `-zsh`. The leading dash makes every pane (agent included) a LOGIN shell, so `.zprofile`/`.profile` run (Homebrew, nvm) even when Helder was started from Finder with launchd's bare PATH. |
|
||
| Working directory | Project root path; with no project, `$HOME`; else `/`. |
|
||
| Environment | See below. |
|
||
|
||
So the agent is started as: login shell (via argv0 dash) + `-i` (interactive, so rc files such as `.zshrc` are sourced) + `-c <command>` (the shell runs the command and exits when it exits). The command is NOT typed into a prompt: no prompt line and no echoed command appear. When the agent exits, the shell exits too, and the pane shows the exit line.
|
||
|
||
#### Child environment (TerminalLaunch.environment)
|
||
|
||
Start from Helder's own process environment, then:
|
||
|
||
| Variable | Rule |
|
||
|---|---|
|
||
| `npm_config_prefix` | Removed (it makes nvm refuse to load). |
|
||
| `npm_config_globalconfig` | Removed. |
|
||
| `LANG` | Set to `en_US.UTF-8` only when none of `LC_ALL`, `LC_CTYPE`, `LANG` is set (a GUI launch inherits no locale; without it multibyte output is mojibake). |
|
||
| `COLORTERM` | Set to `truecolor` when not already set. |
|
||
| `TERM` | Always `xterm-256color`. |
|
||
| `TERM_PROGRAM` | Always `Helder` (lets the agent detect it runs inside Helder). |
|
||
| `TERM_PROGRAM_VERSION` | Always removed. |
|
||
|
||
The terminal emulator itself also reports term name `xterm-256color`.
|
||
|
||
#### When a pane spawns
|
||
|
||
- `TerminalStore.config` starts as the built-in defaults with `isConfigured = false`. Setting `config` (any time) sets `isConfigured = true`. A pane does NOT spawn until `isConfigured` is true, i.e. until the workspace has resolved and applied the project config (`applyConfig`).
|
||
- On the first view update with `isConfigured && !hasStarted`, the store's `start(kind, on: view)` runs: attach the view, compute the launch with the CURRENT config, log `spawn <kind>: <executable> <args joined by space> in <cwd>` (scope `pty`, level info), then spawn with argv0 as above.
|
||
- Right after the agent pane starts, it is made first responder (on the next main-loop turn), so the user can type to Claude at once.
|
||
- The terminal views live in the store, not in the UI tree, so UI rebuilds never restart a process.
|
||
- If the command is missing or fails, the error simply appears as terminal output in the pane (no special UI).
|
||
|
||
#### Exit and restart-on-keypress
|
||
|
||
- When the child ends on its own, the pane writes (fed to the terminal as output):
|
||
`\r\n` + `ESC[90m` + `[process exited] · press any key to restart` + `ESC[0m` + `\r\n`
|
||
i.e. the grey (bright-black, SGR 90) line `[process exited] · press any key to restart`.
|
||
- The store marks that pane exited (`agentExited` / `shellExited`). Log: exit code non-nil and non-zero → warn `"<kind> exited unexpectedly with code <n>"`; otherwise info `"<kind> exited"` (scope `pty`).
|
||
- The next keystroke sent from that pane (any key that produces bytes) does NOT reach the dead PTY: it is swallowed and the pane is started again with the current config (`start`, which also clears the exited flag and, for the agent, the composer flag). So changes to `ai.command`, `ai.autoLaunch` and `terminal.shell` take effect on this restart.
|
||
- An exit Helder itself requested (terminate) never reports as an exit and shows no line.
|
||
- `TerminalStore.restart(kind)` (terminate + start) exists but nothing in the app UI calls it; only tests.
|
||
|
||
#### Terminate, release, reap (TerminalStore, ChildReaper)
|
||
|
||
| Operation | Behaviour |
|
||
|---|---|
|
||
| terminate(handle) (private) | Read the pane's child pid (only if > 0), call the view's terminate (closes the PTY I/O and sends `SIGTERM` to the child pid; stops monitoring without an exit report), then on a background task run `ChildReaper.reap(pid)`. |
|
||
| `terminateAll()` | Terminate agent and shell, then drop both handles. Called by `closeProject()` (project switch, window close, quit). |
|
||
| `release(handle)` | Called when a pane's window posts "will close". Only acts if that handle is still the store's agent or shell (drop it, then terminate). So after `terminateAll` it does nothing: each child is ended once. |
|
||
| Moving a view between containers | Does NOT kill the child; only window close does. |
|
||
| `ChildReaper.reap(pid, grace = 2 s)` | Loop: `waitpid(pid, WNOHANG)`. Returns when the pid is reaped, or when `waitpid` returns -1 with errno other than EINTR (not our child / already reaped — so a recycled pid is never signalled). If the child is still alive (result 0) and 2 s have passed since the start, send `SIGKILL` once. Sleep 20 ms between polls. Returns early if the task is cancelled. Does not block a thread. |
|
||
|
||
---
|
||
|
||
### 7.3 Terminal view behaviour (HelderTerminalView)
|
||
|
||
| Feature | Behaviour |
|
||
|---|---|
|
||
| Initial frame | 480 × 320 before layout. |
|
||
| Input from keyboard | Sent to the PTY. In the AGENT pane every outgoing keystroke is first reported to the store for composer tracking (7.5). |
|
||
| Programmatic send (pass-on) | Writes bytes straight to the PTY, but only if the process is running (else silently nothing). It never counts as typing. After writing, the pane becomes first responder (the keyboard moves to the agent pane). |
|
||
| ⌥← / ⌥→ | Only while `optionIsMeta` is OFF, the window is this pane's window, the pane is first responder, and the modifiers are exactly Option (no Shift/Control/Command): clear the selection and send `ESC b` (0x1B 0x62) for ← or `ESC f` (0x1B 0x66) for → (word jump, like Terminal.app). Implemented as a local key-down monitor installed while the view is in a window, consuming the event. |
|
||
| Other keys | While the terminal is first responder, arrows, Enter, ⌘A, ⌘C, ⌘← and ⌘→ go to the terminal (the app key router passes them). |
|
||
| Mouse reporting | Enabled only while the running program asked for it (mouse mode ≠ off); re-evaluated before and after every chunk of output. Reason: while reporting is on, the emulator clears the selection on every output, so a redrawing program like Claude Code could never keep a selection. |
|
||
| Copy on select | Whenever the selection changes and is active and non-empty, its text is put on the general pasteboard at once (no ⌘C needed). Both panes. |
|
||
| First click | Accepts the first mouse click even when the window is inactive (places selection / reaches program). |
|
||
| Pointer | I-beam over the text grid; arrow over the scrollbar. A drag that started on the grid keeps the I-beam until mouse-up. |
|
||
| Native context menu | Suppressed. A right-click reports (kind, hasSelection, click point in top-left window coordinates) to the store; the workspace shows its own context menu there (7.4). |
|
||
| Window title / cwd reports from the shell | Ignored. Size changes need no handling. |
|
||
| Clipboard-style paste (`paste(text)`) | If the program enabled bracketed paste mode: send `BracketedPaste.wrap(text, composerHasText: false)`. Otherwise send the text with `\r\n` → `\r` and then `\n` → `\r`. Then take the keyboard (via send). |
|
||
| Selected text | The selection text if a selection is active, else none. The store treats an empty selection as none. |
|
||
|
||
#### Appearance (TerminalAppearance, TerminalColors)
|
||
|
||
Applied at creation and re-applied live whenever `config.terminal` or the window zoom changes. Restyling never touches the buffer or the process.
|
||
|
||
| Setting | Mapping |
|
||
|---|---|
|
||
| Font | Size = (`terminal.fontSize` or the Typography terminal default **12 pt**) × window zoom scale. Family: if `terminal.fontFamily` is a non-blank string (trimmed), try it as a font name; else as a family name (regular traits, weight 5); else fall back to bundled **IBM Plex Mono Regular** (PostScript `IBMPlexMono-Regular`); else the system monospaced font. Font is only replaced when name or size differ. |
|
||
| Zoom | `textScale = 1.2 ^ zoomLevel`; zoomLevel in −3 … 5, steps of 0.5 (`⌘+` +0.5, `⌘−` −0.5, `⌘0` reset to 0); persisted. Applies to both terminals and the code. |
|
||
| Background / foreground | `theme.background` / `theme.foreground`. |
|
||
| Caret colour / text under caret | `theme.cursor` / `theme.cursorAccent`. |
|
||
| Selection background | `theme.selectionBackground` (alpha honoured). |
|
||
| `theme.selectionInactiveBackground` | Decoded but NOT applied anywhere. |
|
||
| ANSI palette | 16 colours in SGR order: black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite. Converted to sRGB 16-bit channels (component × 65535). |
|
||
| Colour parse fallback | Each entry that fails to parse uses the same entry of the built-in default theme, then white. |
|
||
| Cursor | `cursorStyle` × `cursorBlink`: bar→blinking/steady bar, block→blinking/steady block, underline→blinking/steady underline. |
|
||
| `boldIsBright` | Emulator "use bright colours for bold" flag. Off (default): bold keeps its own hue. |
|
||
| `optionIsMeta` | Emulator Option-as-Meta flag. On: Option sends Meta (needed for a CLI's ⌥↵), no accents, and ⌥←/→ word jump is disabled. |
|
||
| `scrollback` | `max(0, scrollback)` lines; changed live when it differs. |
|
||
| `lineHeight`, `letterSpacing` | Not applied (the emulator has no such setting). |
|
||
|
||
CSS colour parser (used for every theme value): trimmed, lowercased. `#rgb` (expanded) or `#rrggbb`; or anything starting with `rgb` with `(a,b,c)` or `(a,b,c,alpha)` → sRGB r/255, g/255, b/255, alpha (default 1). Anything else (`#rrggbbaa`, `hsl()`, named colours, percentages) fails to parse → fallback.
|
||
|
||
---
|
||
|
||
### 7.4 Terminal right-click menu (ContextActions `.terminal`)
|
||
|
||
No header line. Entries, in order (separators shown as `—`):
|
||
|
||
| Situation | Entries |
|
||
|---|---|
|
||
| Shell pane, with selection | **Copy**, **Paste**, —, **Read aloud selection**, —, **Plak** |
|
||
| Agent pane, with selection | **Copy**, **Paste**, —, **Read aloud selection**, —, **Plak**, —, **Wait what?** |
|
||
| Either pane, no selection | **Paste** |
|
||
|
||
Icons (SF Symbol names) and tint: Copy `doc.on.doc` plain; Paste `doc.on.clipboard` plain; Read aloud selection `speaker.wave.2` plain; Plak `note.text.badge.plus` plain; Wait what? `questionmark.bubble`, "rename" tint (the amber pass-on accent group).
|
||
|
||
| Action | Exact behaviour |
|
||
|---|---|
|
||
| Copy | If the pane has a non-empty selection, put it on the pasteboard. |
|
||
| Paste | Read the pasteboard text; if non-empty, call the pane's clipboard-style paste (bracketed only if the program asked for it; see 7.3). For the agent pane, marks the composer as holding text. |
|
||
| Read aloud selection | Take the selection, trim whitespace/newlines; convert Markdown to plain prose (markup removed). If the prose is empty, speak the raw trimmed text instead. If nothing could be read (blank), toast **"Nothing to read"**. |
|
||
| Plak | Take the selection (or ""), trim whitespace/newlines; if blank, toast **"Nothing to send"**; else send to the Plak app (`plak://append?text=…` with `+` encoded as `%2B`, or via the pasteboard + `plak://paste` above 100 000 UTF-8 bytes). |
|
||
| Wait what? | Agent pane only. Take the selection, trim; if non-empty, pass to the agent the text `` /wait-what `<trimmed selection>` `` (slash command, selection in single backticks) using the normal pass-on path (bracketed paste, not submitted) and show toast **"Passed to agent"** with detail **`/wait-what`**. If blank, nothing happens. |
|
||
|
||
---
|
||
|
||
### 7.5 Pass on to agent (AgentReference, PassOn, BracketedPaste, TerminalStore.insertIntoAgent)
|
||
|
||
#### Reference format (AgentReference)
|
||
|
||
| Input | Text |
|
||
|---|---|
|
||
| Path only (file or folder) | `path` |
|
||
| Single line, or start == end | `path:42` |
|
||
| Line range | `path:42-58` |
|
||
|
||
Paths are relative to the project root. Folder references from the Explorer get a trailing `/`.
|
||
|
||
#### Composed text (PassOn.compose(note, reference, code?))
|
||
|
||
`note` is trimmed (whitespace + newlines).
|
||
|
||
| Case | Result |
|
||
|---|---|
|
||
| No code, empty note | `reference` |
|
||
| No code, with note | `note => reference` |
|
||
| With code | `[note + " "]reference` + `\n` + "```" + `\n` + code + `\n` + "```" |
|
||
|
||
Examples: `a.php:3`; `fix this => a.php:3`; `why a.php:3-4\n```\nx\ny\n```` .
|
||
|
||
#### Bracketed paste bytes (BracketedPaste.wrap(text, composerHasText))
|
||
|
||
- Start marker `ESC [ 2 0 0 ~` (`\u{1b}[200~`), end marker `ESC [ 2 0 1 ~` (`\u{1b}[201~`).
|
||
- Payload sanitising: remove every `ESC` (U+001B) and every 8-bit CSI (U+009B) from the text, so text containing `ESC[201~` cannot end the paste early and run the rest as typed input. Example: `note\u{1b}[201~\rrm -rf ~\r\u{1b}[200~ \u{9b}201~tail` → `\u{1b}[200~note[201~\rrm -rf ~\r[200~ 201~tail\u{1b}[201~`.
|
||
- Output = start + (`"\n"` if `composerHasText`) + sanitised payload + end.
|
||
- Never followed by `\r`: the text is never submitted. The user presses Enter.
|
||
|
||
#### Insert into the agent (TerminalStore.insertIntoAgent + WorkspaceModel.passToAgent)
|
||
|
||
1. If there is no agent pane, nothing is sent (the toast in step 5 still shows).
|
||
2. Send `BracketedPaste.wrap(text, composerHasText: agentComposerHasText)` to the agent pane. This ALWAYS uses bracketed markers, regardless of whether the program enabled bracketed paste mode. If the agent process is not running, the bytes are dropped silently.
|
||
3. Set `agentComposerHasText = true`.
|
||
4. The agent pane takes the keyboard (first responder).
|
||
5. The model shows toast **"Passed to agent"** with the reference (or command) as its mono detail line. The toast is shown even when no agent pane/process exists.
|
||
|
||
Pass-on sources that use this path: the pass-on prompt (`.passToAgent(text, reference)`, which first dismisses the overlay), the Diff's own pass-on prompt, the Explorer "Bouwen" item (`/bouwen <folder name>`, toast detail `/bouwen <folder name>`), and "Wait what?".
|
||
|
||
#### Composer tracking (agentComposerHasText)
|
||
|
||
Purpose: when the composer already holds text, the next insert begins with a newline so stacked references each start on a fresh line.
|
||
|
||
| Event | Effect |
|
||
|---|---|
|
||
| Each user keystroke chunk to the agent | Contains `\r` → false (Enter sent/submitted). Else if its first Unicode scalar ≥ 0x20 → true (printable text; note DEL 0x7F/Backspace also counts). Chunks starting with control bytes such as `ESC` (arrow keys, sequences) change nothing. |
|
||
| insertIntoAgent | → true |
|
||
| Paste via menu into agent | → true |
|
||
| Agent pane (re)attached/started | → false |
|
||
|
||
---
|
||
|
||
### 7.6 Process running (ProcessRunner, ExecutableLocator, InstanceLauncher)
|
||
|
||
All non-terminal child processes (git, ripgrep, …) go through `ProcessRunning`.
|
||
|
||
#### ExecutableLocator
|
||
|
||
- `standard` search order: (1) the app bundle's `Contents/Helpers` folder (bundled `rg`), (2) each directory in Helder's `PATH` in order (default `/usr/bin:/bin:/usr/sbin:/sbin` when unset), (3) `/opt/homebrew/bin`, (4) `/usr/local/bin`. Duplicates removed, first occurrence kept.
|
||
- `locate(name)`: a name containing `/` is checked as given (must be an executable file). Otherwise the first `dir/name` that exists, is not a directory and is executable. Else nil.
|
||
|
||
#### run / stream semantics
|
||
|
||
| Aspect | Behaviour |
|
||
|---|---|
|
||
| Lookup failure | Throws `executableNotFound(name)`. |
|
||
| Launch failure | Throws `launchFailed(message)`. |
|
||
| Exit code | Non-zero is a normal result (`exitCode`, `stdout`, `stderr`; `succeeded` = exit 0), never an error. |
|
||
| Environment | `nil` inherits Helder's environment; a dictionary REPLACES it entirely. |
|
||
| Directory | Optional working directory. |
|
||
| stdin | Always the null device (closed), so a child can never wait on input. |
|
||
| Pipes | stdout and stderr are drained on separate threads concurrently (no deadlock on large output on both). Output decoded as UTF-8 (lossy). |
|
||
| Completion | Returns after the process terminated AND both pipes reached EOF. |
|
||
| Timeouts | None inside the runner. Callers impose timeouts by cancelling the task (e.g. git remote ops: 120 s). |
|
||
| Cancellation | Resumes the caller at once with a cancellation error; if the process is running, sends `SIGTERM` to every descendant (deepest first: grandchildren list reversed) and then to the child. Descendants found by walking the process tree breadth-first via the OS child-pid list (up to 64 children per pid). Reason: a grandchild such as `ssh` may hold the pipe open long after the child is gone. A cancel before launch throws cancellation without launching. Finish and cancel race safely: only the first resumes. |
|
||
| `stream(…, onLine)` | Same as run, but each line is handed to `onLine(line, isError)` as it arrives (isError = stderr). Lines split on `\n` OR `\r` (so progress updates end a line); empty lines dropped; a trailing partial line is emitted at EOF. Calls to `onLine` are serialised (never concurrent) though both pipes feed it. The full stdout/stderr are still returned. |
|
||
| Default stream (fakes/other implementers) | Run to completion, then emit all stdout lines, then all stderr lines (same split rule). |
|
||
|
||
#### InstanceLauncher (new windows under a non-bundle launch)
|
||
|
||
- Every new window is a new Helder process. Inside an `.app` bundle this uses the OS "open application, create new instance, activate" with arguments `-HelderProject <folder>` (or none for the launcher).
|
||
- Outside a bundle (development `swift run`): spawn the executable with arguments `["-HelderProject", path]` (or `[]`), with Helder's environment MINUS `HELDER_PROJECT` (which would win over the argument). The process object is kept alive in a locked set until it exits, so its exit status is always collected. Launch error → log error scope `window`: `could not start a new instance: <message>`.
|
||
|
||
---
|
||
|
||
### 7.7 Configuration system (HelderConfig, ConfigResolution, ConfigService)
|
||
|
||
#### Files in `<project>/.helder/`
|
||
|
||
| File | Who writes it | Purpose |
|
||
|---|---|---|
|
||
| `config.json` | The user | Sparse overrides; the only file read. |
|
||
| `config.default.json` | Helder, on EVERY resolve (project open AND every `config.json` change) | Documentation: all keys with defaults; never read. |
|
||
| `.gitignore` | Helder, when its content differs | Exactly `# Helder — local, machine-specific state (do not commit).\n*\n` (the folder ignores itself). |
|
||
| `recent.json` | Recent-files store | Not part of config. |
|
||
|
||
`resolve()`: create `.helder/` (with intermediates), write `config.default.json`, write `.gitignore` if different; any failure logs warn scope `config`: `cannot write <folder path>: <message>` and continues. Then read `config.json` and resolve. A read-only or missing folder still yields defaults. `current()` returns the last resolved config (defaults before the first resolve).
|
||
|
||
`config.default.json` format: JSON pretty-printed, keys sorted alphabetically, slashes not escaped, followed by one trailing newline. `terminal.shell`, `terminal.fontFamily`, `terminal.fontSize` are written as explicit `null`. (Pretty-print style is Apple's: `"key" : value` with space before the colon, 2-space indent.)
|
||
|
||
#### Resolution rules
|
||
|
||
- `config.json` missing, empty, not valid JSON, or not a JSON object (e.g. `[]`) → all defaults.
|
||
- Otherwise merged key by key, recursively per section: a key that is missing, `null`, of the wrong type, or (for enums) an unknown value keeps its default. A wrong section (e.g. `"editor": 5`) keeps that whole section's defaults. The rest of the file still applies.
|
||
- Exception for optional keys (`terminal.shell`, `terminal.fontFamily`, `terminal.fontSize`): an explicit `null` means "use default behaviour" (= nil, which is also the default); a wrong type keeps the default.
|
||
- Unknown keys anywhere are ignored (no error).
|
||
- Legacy keys: `git.confirmStage`, `git.confirmUnstage` are ignored. `git.defaultDiffMode: "original"` (or any unknown value) → `"updated"`.
|
||
- No validation of ranges (e.g. negative `tabSize` or `scrollback` is accepted; scrollback is clamped to ≥ 0 when applied).
|
||
|
||
#### Complete schema
|
||
|
||
| Key | Type | Default | Allowed / notes | Honoured? |
|
||
|---|---|---|---|---|
|
||
| `ai.command` | string | `"claude"` | Shell command string run via `$SHELL -i -c`. | Yes, at each pane spawn (project open, restart after exit). |
|
||
| `ai.autoLaunch` | bool | `true` | false → agent pane is a plain login shell. | Yes, at each spawn. |
|
||
| `editor.autoSave` | bool | `false` | Save 0.6 s after last keystroke (editor section). | Yes, live. |
|
||
| `editor.tabSize` | int | `4` | Spaces per indent step. | Yes, live. |
|
||
| `editor.wordWrap` | string enum | `"markdown"` | `"off"`, `"on"`, `"markdown"`. | Yes, live. |
|
||
| `git.confirmDiscard` | bool | `true` | Ask before Discard/Delete in Git view. | Yes, live. |
|
||
| `git.defaultDiffMode` | string enum | `"updated"` | `"updated"`, `"diff"`; unknown → `"updated"`. | Yes, live. |
|
||
| `git.refreshInterval` | int (ms) | `10000` | `0` (or ≤ 0) disables polling. | Yes; a changed value restarts the running poll at once. |
|
||
| `files.exclude` | array of strings | `[]` | Glob patterns for tree, search, watcher. Empty strings ignored. | Yes (watcher re-reads at once; tree/search on next reload/search). |
|
||
| `files.followGitignore` | bool | `false` | true → also hide git-ignored files. | Yes (as above). |
|
||
| `terminal.shell` | string or null | `null` | Path of shell for both panes; null → `$SHELL` → `/bin/zsh`. | Yes, at each spawn. |
|
||
| `terminal.fontFamily` | string or null | `null` | Font name or family; null/blank → IBM Plex Mono. | Yes, live. |
|
||
| `terminal.fontSize` | number or null | `null` | Points before zoom; null → 12. | Yes, live. |
|
||
| `terminal.lineHeight` | number | `1.7` | — | NO (ignored). |
|
||
| `terminal.letterSpacing` | number | `0` | — | NO (ignored). |
|
||
| `terminal.cursorStyle` | string enum | `"bar"` | `"bar"`, `"block"`, `"underline"`. | Yes, live. |
|
||
| `terminal.cursorBlink` | bool | `true` | | Yes, live. |
|
||
| `terminal.boldIsBright` | bool | `false` | | Yes, live. |
|
||
| `terminal.scrollback` | int | `8000` | Lines. | Yes, live. |
|
||
| `terminal.optionIsMeta` | bool | `false` | | Yes, live. |
|
||
| `terminal.theme.*` | CSS colour strings | see below | Each key independent. | Yes, live (except `selectionInactiveBackground`). |
|
||
| `session.restoreOnLaunch` | bool | `true` | Reopen last file and its view. | Read at project open. |
|
||
|
||
`terminal.theme` defaults:
|
||
|
||
| Key | Default | Key | Default |
|
||
|---|---|---|---|
|
||
| `background` | `#101720` | `foreground` | `#E4E7E6` |
|
||
| `cursor` | `#E8913A` | `cursorAccent` | `#101720` |
|
||
| `selectionBackground` | `rgba(232,145,58,0.22)` | `selectionInactiveBackground` | `rgba(232,145,58,0.12)` (ignored) |
|
||
| `black` | `#232C39` | `brightBlack` | `#6C7783` |
|
||
| `red` | `#C4741F` | `brightRed` | `#E8913A` |
|
||
| `green` | `#8FBFB4` | `brightGreen` | `#A6D2C7` |
|
||
| `yellow` | `#F0B476` | `brightYellow` | `#F5C79A` |
|
||
| `blue` | `#8FA9C4` | `brightBlue` | `#A9BFD6` |
|
||
| `magenta` | `#C3A6CE` | `brightMagenta` | `#D6BFDF` |
|
||
| `cyan` | `#8FC4C4` | `brightCyan` | `#A9D6D6` |
|
||
| `white` | `#BAC0C0` | `brightWhite` | `#F4F5F4` |
|
||
|
||
Generated `config.default.json` (current code, keys sorted):
|
||
|
||
```json
|
||
{
|
||
"ai" : { "autoLaunch" : true, "command" : "claude" },
|
||
"editor" : { "autoSave" : false, "tabSize" : 4, "wordWrap" : "markdown" },
|
||
"files" : { "exclude" : [ ], "followGitignore" : false },
|
||
"git" : { "confirmDiscard" : true, "defaultDiffMode" : "updated", "refreshInterval" : 10000 },
|
||
"session" : { "restoreOnLaunch" : true },
|
||
"terminal" : {
|
||
"boldIsBright" : false, "cursorBlink" : true, "cursorStyle" : "bar",
|
||
"fontFamily" : null, "fontSize" : null, "letterSpacing" : 0, "lineHeight" : 1.7,
|
||
"optionIsMeta" : false, "scrollback" : 8000, "shell" : null,
|
||
"theme" : { …22 colour keys as above, sorted… }
|
||
}
|
||
}
|
||
```
|
||
(The real file is fully expanded one key per line.)
|
||
|
||
#### Live reload
|
||
|
||
- The file watcher classifies a change to exactly `.helder/config.json` (relative to the root) as a `config` event, debounced 100 ms (every new change restarts the wait). The rest of `.helder/` is ignored by the watcher (so rewriting `config.default.json` does not loop).
|
||
- On a `config` event the watcher also re-reads `files.*` for its own filtering at once.
|
||
- The model then runs `reloadConfig()`: re-resolve (which also rewrites `config.default.json` and `.gitignore`), and if the project did not change meanwhile, store it and `applyConfig()`.
|
||
- `applyConfig()` pushes: whole config → terminal store (appearance applied live to both panes; launch settings used at the next spawn); `git` section → source control (poll restarts if interval changed while polling); `editor` section → editor (only if changed); `git.defaultDiffMode` → editor default view mode (only if changed).
|
||
|
||
---
|
||
|
||
### 7.8 Project title (ProjectTitle, ProjectLocator)
|
||
|
||
- `name` = the root folder's last path component (or the full path if that is empty). Used in recents, Explorer header, focus flash.
|
||
- `title` = `APP_NAME` from `<root>/.env` (read as UTF-8; unreadable/missing → none), else `name`.
|
||
- `APP_NAME` parsing: split the file into lines; for each line strip leading spaces/tabs; skip lines starting with `#`; the line must start with `APP_NAME`, then optional spaces/tabs, then `=`; the value is everything after `=`. The LAST matching line wins. The value is trimmed of spaces; if it is at least 2 chars and starts and ends with the same quote (`"` or `'`), the quotes are removed; trimmed again; empty → none. No escape handling, no `export` prefix support, inline `# comments` are kept as part of the value.
|
||
- Examples: `APP_NAME="Loopt Shop"` → `Loopt Shop`; `APP_NAME='x'` → `x`; `# APP_NAME=nope\nAPP_NAME=` → none.
|
||
- The title is computed when a project attaches (not live on `.env` change). It becomes the window title (title text hidden in the custom title bar) and the process display name (Dock, ⌘Tab, Mission Control) through a private LaunchServices rename; the launcher (no project) uses `Helder`; when the last window closes the name goes back to `Helder`. The Dock menu shows the title as a disabled first item, a separator, then **New Window**. Initial `title` before any project is `Helder`.
|
||
- If the LaunchServices calls are missing: log warn scope `app` `LaunchServices rename calls not found; the app keeps its name`; a failed rename logs `could not rename the app to <name>: <status>`.
|
||
|
||
---
|
||
|
||
### 7.9 Window and project lifecycle (WorkspaceModel + Lifecycle, WindowCoordinator, AppDelegate)
|
||
|
||
#### Process / app start (AppDelegate)
|
||
|
||
On will-finish-launching, in order: install the file log sink (7.10); register bundled fonts; set regular activation policy; force dark appearance; disable automatic window tabbing; set user default `NSQuitAlwaysKeepsWindows = false`; set `NSFullScreenMenuItemEverywhere = false`. On did-finish-launching: install the cursor-update monitor, activate the app. The app does NOT quit when the last window closes.
|
||
|
||
Initial root: `$HELDER_PROJECT` if it is an existing directory; else the first command-line argument (after argv[0]) that is not `.`, does not start with `-`, and is an existing directory. Note `-HelderProject <path>` puts the path as a separate argument, which this rule picks up. Only the FIRST window of a process claims this root; later windows in the same process start on the launcher. Windows are not restorable.
|
||
|
||
#### Window configuration
|
||
|
||
Title from model; title hidden; transparent title bar; full-size content; not movable by background; background `#101720`; dark appearance; min size from metrics; tabbing disallowed; not restorable. Traffic lights placed at (14, 12), re-laid out on resize, end of live resize, exit full screen, become key.
|
||
|
||
#### `start()` (once per model)
|
||
|
||
1. Guard: only the first call does anything.
|
||
2. Load recent projects; build the launcher list (excluding the current root).
|
||
3. If a root exists: `loadProject()`.
|
||
4. `isReady = true` (the window never flashes the launcher while loading).
|
||
|
||
#### `attach(root)` (construction with a root, and every project switch)
|
||
|
||
Increment `generation` (lets stale async work detect a switch); build per-project services; set `name` and `title`; clear Explorer row frames; create SourceControlStore (wired to toasts and commit-message focus), ExplorerStore, EditorStore (wired to overlays, toasts, file-saved → git refresh, unsaved prompt, symbols), CleanCopyStore, a NEW TerminalStore for the root (not yet configured → panes wait), wire the terminal right-click menu; rebuild the launcher list.
|
||
|
||
#### `loadProject()` order
|
||
|
||
1. Restore the per-project column layout.
|
||
2. Resolve config (writes `.helder` files). If the project changed meanwhile, stop.
|
||
3. `applyConfig()` → this configures the terminal store, so both panes spawn now.
|
||
4. Add root to recent projects; reload the list. Stop if the project changed.
|
||
5. In parallel: git refresh, Explorer tree reload, `.clean-copy` baseline load. Await all.
|
||
6. Editor session restore (honours `session.restoreOnLaunch`). Stop if the project changed.
|
||
7. Start the file watcher on the root.
|
||
8. Start git polling every `git.refreshInterval` ms (none if ≤ 0). Each poll: sleep interval, then refresh git; loop.
|
||
9. Schedule the PHP class-list load after 1.5 s.
|
||
|
||
#### Refresh rules
|
||
|
||
| Trigger | What runs |
|
||
|---|---|
|
||
| Watcher `project` event (debounce 250 ms in the watcher) | Scheduled refresh of git + tree + symbols + open files. |
|
||
| Watcher `git` event (debounce 200 ms) | Scheduled refresh of git. |
|
||
| Watcher `config` event (debounce 100 ms) | `reloadConfig()` immediately (not scheduled). |
|
||
| Watcher `cleanCopy` event (debounce 150 ms) | Clean-copy handling. |
|
||
| File saved in editor | Scheduled git refresh. |
|
||
| Pull, branch switch, git console command | Scheduled tree + open-files refresh. |
|
||
| Git poll timer | Git refresh. |
|
||
| `⌘R` (menu View > Refresh, disabled without project) | `refresh()`: increment `refreshTick` (each column flashes once so a no-change refresh is visible); in parallel re-read git + tree, and reload the ACTIVE file from disk (disk wins over unsaved edits). |
|
||
|
||
Scheduled refresh: scopes are unioned into a pending set; one task at a time; it waits the debounce (100 ms), takes and clears the pending set, runs it, then re-checks for scopes that arrived meanwhile. The `symbols` scope invalidates the symbol index and re-schedules the class-list load 2 s after the last change (each change restarts the countdown). `openFiles` makes every loaded buffer pick up disk text (unsaved edits are kept). A pass captures the stores before awaiting, so a pass that outlives a project switch only touches the old project.
|
||
|
||
#### Focus flash
|
||
|
||
When a window becomes key again after having resigned key (never on launch) and a project is open: show the centred `⑂ branch │ project` card (branch `—` when unknown) for **500 ms**, no fade, no hit testing.
|
||
|
||
#### Project switch (`openProject(url)`, from ⌘O "Open Folder…" or Open Recent inside a window)
|
||
|
||
Runs as a "lifecycle task" (only one at a time; a second request while one runs is ignored). Steps: dismiss overlay; if `url` equals the current root, stop; `prepareToClose()` (asks about unsaved files; cancel → stay); `closeProject()`; set root; `attach`; `loadProject`; `isReady = true`.
|
||
|
||
#### `prepareToClose()`
|
||
|
||
Ask about every unsaved file (Save / Don't Save / Cancel). Cancel → return false (window/project stays). Otherwise write the editor session; return true.
|
||
|
||
#### `closeProject()` order
|
||
|
||
1. Stop the watcher; stop git polling.
|
||
2. Clear pending refresh scopes; cancel the refresh task and symbol task (and invalidate the refresh id); cancel every tracked command task.
|
||
3. Await the cancelled refresh, symbol and command tasks to finish.
|
||
4. Stop reading aloud.
|
||
5. Flush pending auto-saves; write the session.
|
||
6. `terminal.terminateAll()` (SIGTERM both children, reap, SIGKILL after 2 s).
|
||
|
||
#### Window close
|
||
|
||
- The window's close is guarded: the first close request returns "not now", runs `prepareToClose()`; if approved, marks approved and closes the window again (second close passes). Re-entrant requests while asking are refused. `⌘W` closes the active file if one is open, else the window; `⇧⌘W` always closes the window.
|
||
- On "will close": unregister the window, reset the process name to `Helder` if no windows remain, call `windowWillClose()` (runs `closeProject()` as the lifecycle task unless one is already running), remove monitors. Each terminal view also hears "will close" and calls `release` (no-op when `terminateAll` already ran).
|
||
|
||
#### Quit (⌘Q)
|
||
|
||
If no workspace windows: quit now. Else reply "later" and, for each window in turn, run `prepareToClose()`; the first cancel aborts the quit. When all approve, run `closeProject()` for each, then confirm the quit.
|
||
|
||
---
|
||
|
||
### 7.10 Logging (Log, FileLogger)
|
||
|
||
| Aspect | Value |
|
||
|---|---|
|
||
| Unified log | Subsystem `nl.blijnder.helder`, category `app`, message `[<scope>] <message>`, public. Levels: debug→debug, info→notice (so it persists), warn→warning, error→error. |
|
||
| File sink | Installed at app start: `~/Library/Logs/Helder/helder.log`. Minimum level debug (everything). |
|
||
| Line format | `<ISO-8601 UTC with milliseconds, e.g. 2026-07-15T10:00:00.000Z> <LEVEL left-padded to width 5 on the right> <pid right-aligned width 5> <scope padded to width 9> <message>\n`. Example: `2026-07-15T10:00:00.000Z INFO 42 git loaded`. Levels upper-case: `DEBUG`, `INFO `, `WARN `, `ERROR`. Padding never truncates. |
|
||
| Multi-line messages | Every `\n` or `\r\n` in the message becomes `\n` + 4 spaces, so continuation lines are indented: `… WARN 1 console line one\n line two\n line three\n`. |
|
||
| Writing | Synchronous (survives a crash right after), under a lock, opened per line with append+create (mode 0644) so lines from several Helder processes sharing the file never interleave. Never throws; an unwritable folder is ignored silently. The directory is created on first write; the current file size is read once then tracked. |
|
||
| Rotation | Before a write that would make the file exceed 2 MiB (2 × 1024 × 1024 bytes): delete `helder.3.log`, rename `helder.2.log`→`helder.3.log`, `helder.1.log`→`helder.2.log`, `helder.log`→`helder.1.log`; size resets to 0. Keeps at most 3 old files. Each step best effort (another process may rotate first). |
|
||
| Menu | Help > **Open Log** (opens the file with the default app), **Reveal Log in Finder**. |
|
||
|
||
Log scopes/messages owned by this section: `pty` spawn/exit lines (7.2), `config` write failure (7.7), `window` new-instance failure (7.6), `app` rename failures (7.8), `watch` `cannot watch <root>` / `cannot start watching <root>` (error).
|
||
|
||
---
|
||
|
||
### 7.11 Menu items owned by this area
|
||
|
||
| Menu | Item | Shortcut |
|
||
|---|---|---|
|
||
| File | **New Window** | ⇧⌘N |
|
||
| File | **Open Folder…** | ⌘O |
|
||
| File | **Open Recent** submenu (other projects; `No Recent Projects` when empty) | — |
|
||
| File | **Open Recent Project…** (disabled without project) | ⇧⌘O |
|
||
| File | **Close** / **Close File** (label depends on whether a file is open) | ⌘W |
|
||
| File | **Close Window** | ⇧⌘W |
|
||
| View | **Refresh** (disabled without project) | ⌘R |
|
||
| View | **Actual Size** / **Zoom In** / **Zoom Out** | ⌘0 / ⌘+ / ⌘− |
|
||
| Help | **Open Log**, **Reveal Log in Finder** | — |
|
||
| Dock | `<project title>` (disabled), separator, **New Window** | — |
|
||
|
||
Open Folder / Open Recent with no key window open the choice in a NEW process instead.
|
||
|
||
---
|
||
|
||
### 7.12 Doc-vs-code conflicts (code wins)
|
||
|
||
1. **Terminal right-click menu.** `docs/guide/claude-code.md`, `command-line.md` and `docs/architecture.md` (Terminals) say the menu holds only Copy and Paste. Code also has Read aloud selection, Plak, and (agent only) Wait what? — as `docs/behaviour.md` §7 correctly describes.
|
||
2. **Keyboard after a pass.** `pass-on-to-agent.md` says "The keyboard stays where it was". Code moves first responder to the agent pane on every send (as `claude-code.md` says).
|
||
3. **Pane headers.** `behaviour.md` §6 says the agent pane has a `claude` header with an `agent session` label, §7 says the shell pane has a header with shell name and path. Code: no header on either pane (guides agree with code).
|
||
4. **Settings read only at open.** `configuration.md` says `ai.command`, `ai.autoLaunch`, `terminal.shell` and `git.refreshInterval` apply only when the project is reopened. Code: the three launch settings apply at the next spawn, including restart-after-exit (any key); `git.refreshInterval` restarts the running poll immediately on config change.
|
||
5. **Stale `.helder/config.default.json` in the repo.** The checked-in sample still has `git.confirmStage` and `git.confirmUnstage`; the code no longer has them and would regenerate the file without them.
|
||
6. **"Regenerated on launch"** (`behaviour.md` §10): code regenerates it on every resolve — at project open AND every time `config.json` changes.
|
||
7. **`selectionInactiveBackground`** is documented as the selection colour in an unfocused pane; code never applies it.
|
||
8. **`terminal.lineHeight` / `letterSpacing`**: `configuration.md` lists effects ("Line height, as a multiple…"); code ignores both (`claude-code.md` and architecture Gotchas say so correctly).
|
||
9. **Splitter defaults.** `command-line.md` says Claude starts "with about half the column" and each pane keeps "about a fifth": code default 0.52, clamp 0.18–0.82 (consistent in spirit). Splitter position is global, not per project (doc agrees).
|
||
10. **Toast when no agent.** `claude-code.md`: "Nothing is sent when the agent process is not running." True, but the "Passed to agent" toast is still shown.
|
||
11. **Restart.** Architecture lists `restart` as a way to end a pane; the app never calls it — restart only happens on a keypress after exit.
|
||
|
||
|
||
---
|
||
|
||
## 8. Acceptance Test Catalogue
|
||
|
||
This section turns the existing Swift test suite into a language-neutral catalogue. The rebuild must pass every rule below. Each bullet is one test case of the original suite. Names in `CamelCase` are the names of the original suite or type; use them as anchors, not as required identifiers. Strings in backticks are exact values from the tests. `\n`, `\r`, `\0`, `\t` and `\u{1b}` are the escape characters newline, carriage return, NUL, tab and ESC. `ESC[200~` and `ESC[201~` are the bracketed-paste start and end markers.
|
||
|
||
The catalogue covers all 926 test cases of the suite (every `@Test` function, in every suite, in every file under `Tests/`). A parameterised test is one bullet that lists every argument case.
|
||
|
||
### 8.1 Test architecture
|
||
|
||
#### Three targets
|
||
|
||
The tests mirror the three modules of the app:
|
||
|
||
| Target | Tests | Dependencies | Character |
|
||
|---|---|---|---|
|
||
| `HelderCoreTests` | Pure logic: parsers, diff, highlight grammars, config merge, menus, layout maths | Core only | Fast, no I/O, no async waits |
|
||
| `HelderServicesTests` | Services that touch the outside world: processes, git, the file system, FSEvents, ripgrep, logging, config files | Services | Integration tests on real temp folders, real git, real processes |
|
||
| `HelderUITests` | Observable stores and the workspace model (`WorkspaceModel`, `EditorStore`, `ExplorerStore`, `SourceControlStore`, `TerminalStore`, `LayoutStore`, `OverlayStore`, `ToastStore`, `KeyRouter`, etc.) | UI (and Core, Services for types) | Wired only to fakes |
|
||
|
||
The framework is Swift Testing (`@Suite`, `@Test`, `#expect`, parameterised tests with `arguments:`).
|
||
|
||
#### Rule: UI tests never touch disk, git, user defaults or the log
|
||
|
||
Every store test in `HelderUITests` runs on in-memory fakes, one per service protocol. No UI test reads or writes a real file, runs real git, reads or writes `UserDefaults`, or writes to the real log file. The one exception is three terminal tests tagged `realProcess` (see Tags), which spawn a real shell in a pseudo-terminal.
|
||
|
||
#### Fakes for UI tests (`Tests/HelderUITests/Support/Fakes/`)
|
||
|
||
All fakes keep their state behind a lock (`Locked<Value>`: a value behind an `NSLock`, read synchronously via `current`, changed via `mutate { }`) so they are thread-safe and still readable synchronously from a test. `FakeError` is an empty error type that fakes throw.
|
||
|
||
| Fake | Protocol | Simulates | Records |
|
||
|---|---|---|---|
|
||
| `FakeConfig` | `ConfigServicing` | A config whose answer the test can change with `set(_:)`, as if `.helder/config.json` was edited. `resolve()` returns the current config; `current()` returns it without counting. | `resolves`: number of `resolve()` calls |
|
||
| `FakeFiles` | `FileServicing` | An in-memory project: a `FileNode` tree and a map path -> text. Also images (path -> bytes) and a set of paths that read as binary. `remove(path)` makes a file disappear as if another program deleted it. `failWrites = true` makes every write, create, create-directory, rename and delete throw. `holdNextRead(path)` returns a `ReadGate`: the next read of that path takes the contents at once but returns only when the test calls `open()` (so a slow read can be made to land last; `isWaiting` turns true once a read waits). `rename` returns `dirname(path)/newName`. `children(of:)` returns the children of that folder in the tree. `readText` returns `.binary` for binary paths, else `.text(contents)`; a missing file throws "no such file". | `treeLoads`, `childReads` (folders asked), `writes` (path, text), `created`, `createdDirectories`, `renamed` (path, new name), `deleted` |
|
||
| `FakeGit` | `GitServicing` | `load()` returns queued snapshots first (each after its own delay), then the current one; `setLoadError` makes every load throw. `execute(args, ...)` answers with a scripted `FakeGitRun` (exit code, lines with an is-error flag, a delay after the lines): first the run scripted for the exact argument list, else for its first argument (the command), else success (exit 0, no lines). It streams the lines to `onLine` before the delay. `branches()` and `author()` return set values. | `loads`, `executed` (every argument list in order), `events` (`start <args joined by space>` and `end <args>` per execute, in time order) |
|
||
| `FakeLayouts` | `LayoutPersisting` | Column layouts per project root and a zoom level, in memory instead of UserDefaults. | `saved` (root -> snapshot), `zoomLevel` |
|
||
| `FakeRecentFiles` | `RecentFilesStoring` | The per-project recent-files list. | `paths` |
|
||
| `FakeRecentProjects` | `RecentProjectsStoring` | The machine-wide recent-projects list; `add` pushes a project with name = basename of the path, by the real recent-list rules. Never the user's real list. | `projects` |
|
||
| `FakeSearch` | `SearchServicing` | Canned content-search answers per query, an optional delay per query, a fixed list of files, and an availability flag. | `contentQueries` (asked, in order), `answeredQueries` (in the order they finished) |
|
||
| `FakeSession` | `SessionStoring` | Sessions per root and the global agent-split layout, in memory instead of UserDefaults. | `sessions`, `layout` |
|
||
| `FakeSpeech` | `SpeechServicing` | Speech; `finish()` plays the voice reaching the end (calls `onFinish`). | `spoken` texts, `stops` count |
|
||
| `FakeSymbols` | `SymbolServicing` | Declared PHP class names and lookups set by the test; an unknown lookup returns an empty lookup for that name. | `invalidations`, `nameLoads` |
|
||
| `FakeSystem` | `SystemActing` | Dialogs, pasteboard and Finder. `chosenFolder` is what the folder picker returns; `unsavedCloseChoice` is the answer to the "unsaved changes" question (default cancel); `clipboard` is the pasteboard text. | `copied`, `revealed` (Finder URLs), `plakked` (text sent to Plak), `unsavedCloseQuestions` (paths asked), `newInstances` (folder per "open new instance" call, nil = launcher). `openLog` and `revealLog` do nothing. |
|
||
| `FakeTerminal` | `TerminalSessionHandle` | A terminal pane without a PTY. `selectedText` is settable. | `sent` texts, `starts` (launch + argv0), `terminations`, `pasted` |
|
||
| `FakeWatcher` | `FileWatching` | A file watcher the test fires by hand with `emit(event)`. | `root` it was started on, `stopped` |
|
||
|
||
#### Harnesses (`Tests/HelderUITests/Support/`)
|
||
|
||
- **`WorkspaceHarness`**: builds a complete `WorkspaceModel` wired only to fakes. Defaults: root `/fake/project` (can be nil, for the launcher), `HelderConfig.defaults`, no git snapshot, the sample tree, no file contents, no recent projects, a fresh `FakeSession`. It builds `AppServices` with the fake recent projects, session, layouts, system and speech; a `makeWorkspace` factory that returns `WorkspaceServices` with the fake git, files, search, symbols, config and recent files; and a `makeWatcher` factory that makes a new `FakeWatcher` per call and keeps them all (`watchers.made`, `watchers.last`). The model uses `WorkspaceTimings.immediate` (refresh debounce 0, symbol loads after launch and after change 0, instead of 100 ms / 1500 ms / 2000 ms). A `FakeTerminal` is attached as the agent pane. Helpers: `start()` = `model.start()` then `model.settle()`; `perform(command)` = `model.perform(command)` then `settle()`; `toastTitles` = titles of current toasts.
|
||
- **Sample tree** (`sampleTree()`): root `project` with `.github/` (`.github/ci.yml`), `src/` (`src/Http/` with `src/Http/Kernel.php`, and `src/app.php`), an empty folder `empty/`, `.env`, `README.md`. Helpers `dir(path, children)` and `file(path)` build nodes with name = basename.
|
||
- **`StoreHarnesses`**:
|
||
- `TestDerivation.derive(snapshot)`: a simple stand-in for the real git derivation: one row per change, added = 1 if the updated text is non-empty, removed = 1 if the original text is non-empty, no diffs; staged paths from staged rows; `isRepository = true`; nil snapshot gives an empty state.
|
||
- `Recorder`: collects a store's toasts (title, detail) and exposes the `FakeSystem` calls (copied, revealed).
|
||
- `makeDiff(original, updated, added = 1, removed = 0, isAddedFile, isDeletedFile)`: a hand-built whole-file diff with no rows.
|
||
- `GitStateBox`: a mutable git working state an `EditorStore` follows; `change(path, diff)` sets `fileDiffs[path]`.
|
||
- `OverlayRecorder`: records overlays presented and the number of diff-overlay dismissals.
|
||
- `EditorHarness(files:, recent:)`: an `EditorStore` with root `/fake`, `FakeFiles`, the git box, a `FakeSession`, `FakeRecentFiles`, and the overlay hooks recorded. `strand(path, disk, buffer)` puts unsaved edits on a file that is not open.
|
||
- `menuLabels(request)`: the labels of a context-menu request's action entries, separators left out.
|
||
- **`snapshot(rows, branch = "main")`** builds a `GitSnapshot` (ahead 0, cannot push) with one change per (path, status, staged), original text `a`, updated text `b`.
|
||
|
||
#### Integration helpers for services tests (`Tests/HelderServicesTests/Support/`)
|
||
|
||
- **`TempDirectory`**: a throwaway folder `<tmp>/helder-test-<UUID>` (symlinks resolved), removed on deinit. `write(path, text|data)` creates parent folders; `mkdir`, `read`, `exists`, `url`.
|
||
- **`TempGitRepo(bare: false)`**: a throwaway git repo. Locates git via the standard executable locator (throws "executable not found" if absent). Non-bare: `git init -q -b main`, then local config `user.name = Helder Tests`, `user.email = tests@helder.invalid`, `commit.gpgsign = false`. Bare: `git init -q --bare -b main` (serves as a push remote). `write`, `read`, `commit(files, message = "commit")` (writes files, `git add -A`, `git commit -q --allow-empty -m message`), `run(args...)` runs git synchronously and returns stdout, throwing a `commandFailed(arguments, exitCode, stderr)` on non-zero exit. Removed on deinit.
|
||
- **`CaseSensitiveVolume`**: creates an 8 MB "Case-sensitive APFS" disk image (volume name `HelderCS`) with `hdiutil create`, attaches it with `-nobrowse` at a temp mount point, and detaches (`-force`) and deletes it on deinit. Used to test case-only renames on a case-sensitive file system.
|
||
- **`FixedConfig`**: a config service that always returns the same config (default: defaults).
|
||
- **`NoRipgrepSearch`**: a search service that reports ripgrep unavailable, which sends the file service down its own directory walk.
|
||
- **`ScriptedRunner`**: a `ProcessRunning` that records each call (executable, arguments, environment) and answers from a closure; for tests of argument construction and error paths.
|
||
- **`Ripgrep`**: finds the ripgrep binary from `$RG_BINARY` or `vendor/ripgrep/rg` in the package; `isPresent`; `locator` (finds only that ripgrep); `absent` (a locator that finds nothing). Tests that need ripgrep are enabled only if it is present.
|
||
- **`LineLog`**: collects streamed output lines (text, is-error) from any thread: `texts`, `errors`, `outputs`.
|
||
- **`Gate`** (actor): holds every waiter until `open()`; later waiters pass straight through.
|
||
- **`eventually(timeout: 5 s)`** and **`eventuallyAsync`**: poll a condition every 20 ms / 5 ms until it holds or the timeout passes; return whether it held.
|
||
|
||
#### Waiting: eventually and settle, never sleep
|
||
|
||
- UI tests never sleep a fixed time to wait for async work. They either call `settle()` (on `WorkspaceModel`: waits until every scheduled lifecycle task, refresh, symbol load, running command and project switch is done, then waits for the editor's own `settle()`), or poll with `eventually { condition }` (main-actor, every 10 ms, default timeout 5 s).
|
||
- Services tests poll with `eventually` / `eventuallyAsync`.
|
||
- Exceptions: the FSEvents watcher tests (`.serialized`) sleep 0.6 s / 1 s to let the real FSEvents stream start or prove no event arrives; a few process tests sleep 200-300 ms to let a child start before a cancel or terminate; one source-control test sleeps 100 ms to prove something does not happen; one git-console test uses a 30 s sleep inside a scripted runner to simulate a hang that the test cancels.
|
||
- Time limits: tests with real processes that could hang carry a 1-minute time limit.
|
||
|
||
#### Tags
|
||
|
||
- `realProcess`: the test spawns a real process in a pseudo-terminal (three `TerminalStoreSession` tests). These can be excluded in fast runs.
|
||
- Conditional enablement: ripgrep-dependent tests run only if a ripgrep binary is present.
|
||
|
||
---
|
||
|
||
### 8.2 HelderCoreTests
|
||
|
||
#### Agent / AgentReferenceTests
|
||
|
||
- `formatsFileLineAndRange`: a reference with path `src/A.php` and no line prints `src/A.php`; with start line 42 prints `src/A.php:42`; with lines 42...58 prints `src/A.php:42-58`; with lines 7...7 prints `src/A.php:7`.
|
||
- `composesPassOnText`: `PassOn.compose(note: "", reference: "a.php:3")` = `a.php:3`; note `" fix this "` gives `fix this => a.php:3` (note trimmed, joined with ` => `); note `why`, reference `a.php:3-4`, code `x\ny` gives `why a.php:3-4\n` + "```" + `\nx\ny\n` + "```" (note, space, reference, newline, fenced code block; no `=>` when code is present).
|
||
- `wrapsInBracketedPaste`: wrapping `a.php:1` with an empty composer gives `ESC[200~a.php:1ESC[201~`; with text already in the composer gives `ESC[200~\na.php:1ESC[201~` (a leading newline inside the paste).
|
||
- `pastedTextCannotEndThePasteAndSubmit`: the hostile input `note ESC[201~ \r rm -rf ~ \r ESC[200~ <space> U+009B 201~tail` (exactly `"note\u{1b}[201~\rrm -rf ~\r\u{1b}[200~ \u{9b}201~tail"`) wraps to `ESC[200~note[201~\rrm -rf ~\r[200~ 201~tailESC[201~`: every ESC (U+001B) and every C1 CSI (U+009B) inside the text is stripped, so the output contains exactly 2 ESC characters (the wrapper's own).
|
||
- `terminalEnvironmentFillsTheGuiGaps`: from env `{npm_config_prefix: /opt/homebrew, PATH: /usr/bin}` the terminal environment removes `npm_config_prefix`, sets `LANG = en_US.UTF-8` and `COLORTERM = truecolor`. From env `{LC_ALL: nl_NL.UTF-8}`, `LANG` is not set (a locale already exists).
|
||
- `bothPanesTellTheChildItRunsInHelder`: for every terminal kind (agent, shell), with base env `TERM_PROGRAM = Apple_Terminal`, `TERM_PROGRAM_VERSION = 455`, the launch environment has `TERM_PROGRAM = Helder` and no `TERM_PROGRAM_VERSION`.
|
||
- `agentRunsTheCommandThroughAnInteractiveShell`: the agent launch with default config, root `/p`, env `SHELL=/bin/bash` has executable `/bin/bash`, arguments `["-i", "-c", "claude"]`, working directory `/p`. A shell launch with no root and empty env has no arguments.
|
||
|
||
#### Config / HelderConfigTests
|
||
|
||
- `defaultsMatchTheOldApp`: defaults are: `ai.command = "claude"`, `ai.autoLaunch = true`, `editor.autoSave = false`, `editor.tabSize = 4`, `editor.wordWrap = markdown`, `git.confirmDiscard = true`, `git.defaultDiffMode = updated`, `git.refreshInterval = 10000`, `files.exclude = []`, `files.followGitignore = false`, `terminal.shell = nil`, `terminal.fontFamily = nil`, `terminal.fontSize = nil`, `terminal.lineHeight = 1.7`, `terminal.cursorStyle = bar`, `terminal.scrollback = 8000`, `terminal.optionIsMeta = false`, `terminal.theme.background = #101720`, `terminal.theme.red = #C4741F`, `terminal.theme.selectionBackground = rgba(232,145,58,0.22)`, `session.restoreOnLaunch = true`.
|
||
- `anOlderOriginalDefaultDiffModeDecodesAsUpdated`: JSON `{"git":{"defaultDiffMode":"original"}}` decodes with `defaultDiffMode = updated`, which maps to view mode `actual`.
|
||
- `theRemovedStageConfirmKeysStillDecode`: JSON `{"git":{"confirmStage":true,"confirmUnstage":true,"confirmDiscard":false,"refreshInterval":5000}}` decodes without error: `confirmDiscard = false`, `refreshInterval = 5000`; the resolved-overrides path also gives 5000.
|
||
- `sparseOverridesMergeKeyByKey`: overrides `{"editor":{"tabSize":2},"terminal":{"fontSize":14,"theme":{"red":"#FF0000"}},"files":{"exclude":["*.log"]}}` give tabSize 2, wordWrap still markdown, fontSize 14, theme red `#FF0000`, theme green still `#8FBFB4`, exclude `["*.log"]`, and the `ai` section equal to the defaults.
|
||
- `wrongTypesAndUnknownValuesKeepTheDefault`: overrides `{"editor":{"tabSize":"two","wordWrap":"sometimes"},"git":{"refreshInterval":0},"unknown":true}` give tabSize 4, wordWrap markdown, refreshInterval 0 (a valid 0 is kept); the unknown key is ignored.
|
||
- `explicitNullClearsAnOptionalSetting`: overrides `{"terminal":{"shell":null,"fontFamily":"Menlo"}}` give shell nil, fontFamily `Menlo`.
|
||
- `invalidInputGivesTheDefaults` (parameterised): each of these overrides resolves to exactly the defaults: no data (nil); empty string; `{ not json`; `[]`.
|
||
- `defaultsFileRoundTripsAndWritesNulls`: the generated defaults JSON contains the text `"shell" : null` (nulls are written out, pretty-printed with ` : `), and decoding it gives exactly the defaults.
|
||
|
||
#### Config / ProjectTitleTests
|
||
|
||
- `readsAppNameAndStripsQuotes`: from `.env` text `APP_ENV=local\nAPP_NAME="Loopt Shop"\n` the app name is `Loopt Shop`; from `APP_NAME='x'` it is `x`.
|
||
- `ignoresCommentsAndEmptyValues`: `# APP_NAME=nope\nAPP_NAME=` gives no app name (nil). The title for folder `odynt` with no `.env` contents is `odynt`.
|
||
|
||
#### Diff / DiffViewsTests (`DiffViews.actual` over `LineDiff.build(..., status: modified)`)
|
||
|
||
- `rewrittenLine` ("a rewritten line is tinted in place and draws no gap rule"): original `a\nold\nb`, updated `a\nnew\nb` gives lines `a`, `new`, `b`; line 2 has style `added`; no line has a gap mark.
|
||
- `deletionMarksNextLine`: original `a\ngone\nb`, updated `a\nb`: line index 1 is `b`, with gap `above` and no style.
|
||
- `deletionAtEnd`: original `a\nb\ntail`, updated `a\nb`: line index 1 (`b`) has gap `below`; line 0 has no gap.
|
||
- `deletionAtStart`: original `gone\na`, updated `a`: the result is exactly one line `{no: 1, text: "a", gap: above}`.
|
||
- `insertion`: original `a\nb`, updated `a\nNEW\nb`: line index 1 has style `added`; no gaps anywhere.
|
||
- `unchanged`: `a\nb\n` vs `a\nb\n`: no style and no gap on any line.
|
||
- `deletedFile`: original `a\nb`, updated empty, status deleted: the Actual view has no lines.
|
||
- `onlyOneRule`: original `keep\ngone\ntail\n`, updated `keep\ntail\n`: exactly one line has a gap; no line has a style.
|
||
- `plain`: `DiffViews.plain("x\ny\n")` = `[{1, "x"}, {2, "y"}]` (one trailing newline dropped); `plain("")` = `[{1, ""}]`.
|
||
|
||
#### Diff / DiffViewsLineEndingTests
|
||
|
||
- `crlfPlain`: `plain("a\r\nb\r\n")` gives texts `a\r`, `b\r` (one line per LF, carriage returns kept).
|
||
|
||
#### Diff / LineDiffTests
|
||
|
||
- `identical`: `a\nb\nc\n` vs same: added 0, removed 0, every row sign `same`.
|
||
- `singleChange`: `a\nb\nc` vs `a\nB\nc`: added 1, removed 1, signs `[same, removed, added, same]`.
|
||
- `lineNumbers`: `a\nold\nb` vs `a\nnew\nb\nc` gives rows exactly: (same, old 1, new 1, `a`), (removed, old 2, new nil, `old`), (added, old nil, new 2, `new`), (same, old 3, new 3, `b`), (added, old nil, new 4, `c`).
|
||
- `newFile`: original empty, updated `x\ny`, status added: added 2, removed 0, left side empty, right side 2 lines, `isAddedFile` true, `isDeletedFile` false.
|
||
- `deletedFile`: original `x\ny\nz`, updated empty, status deleted: removed 3, added 0, right side empty, `isDeletedFile` true, `isAddedFile` false.
|
||
- `sideMarks`: `keep\nold\nkeep` vs `keep\nnew\nkeep`: on the left, `old` is marked removed; on the right, `new` is marked added; `keep` on the left has no mark.
|
||
- `splitAlignment`: `a\nold\nb` vs `a\nnew\nb`: every split row has at least one side; the rows that pair identical text pair `a` and `b`; split row 1 is left `{2, "old", removed}` beside right `{2, "new", added}`.
|
||
- `splitFillers`: `a\nx\ny\nb` vs `a\nz\nb`: split rows are `[a|a], [x|z], [y|nil], [b|b]`.
|
||
- `trailingNewline`: `a\nb` vs `a\nb\n`: no change (added 0, removed 0).
|
||
- `crlf`: `a\r\nb\r\n` vs `a\nb\n`: removed 2, added 2 (carriage returns are part of the line).
|
||
- `unicode`: `café\n😀` (precomposed é) vs `cafe\u{301}\n😀` (decomposed): the last row is (same, 2, 2, `😀`); lines compare whole.
|
||
- `tieOrder`: `a\nb` vs `b\na`: signs `[removed, same, added]` (on a tie a removal comes before an addition).
|
||
- `carriesTexts`: a diff of `bye` vs empty (deleted) keeps original `bye` and updated empty.
|
||
- `lines`: `lines("")` = `[]`; `lines("a\n")` = `["a"]`; `lines("a\n\n")` = `["a", ""]`; `lines("\n")` = `[""]`; `lines("a\r\nb\r\n")` = `["a\r", "b\r"]`.
|
||
- `largeFileSingleEdit`: 60,000 lines `line 0`...`line 59999`, with line 30000 changed to `line 30000 edited`: added 1, removed 1, right line index 30000 is marked added (must run fast; no full matrix).
|
||
- `largeRewrite`: 40,000 lines `old N` vs 40,000 lines `new N`: removed 40,000, added 40,000.
|
||
- `largeHeadAndTail`: 5,000 `head N` lines + 30,000 middle lines + 5,000 `tail N` lines, where the middle is `x (N mod 7)` vs `y (N mod 7)`: the first 5,000 and last 5,000 left lines carry no mark; added = 30,000.
|
||
- `anchorsSplitLargeRegions`: 3,000 `shared N` lines interleaved with `a-noise` vs the same interleaved with `b-noise`: exactly 3,000 rows are `same`, added 3,000, removed 3,000 (over the cell budget, unique anchor lines still pair the shared lines).
|
||
|
||
#### Diff / ViewModeTests
|
||
|
||
- `rawValuesMatchTheOldSessionStrings`: view mode `actual` has raw value `updated`; default diff mode `updated` maps to `actual`; `diff` maps to `diff`.
|
||
- `anOriginalModeIsNotAViewMode`: raw value `original` is not a view mode (nil).
|
||
|
||
#### Files / ContextActionsTests, suite TerminalContextMenuTests
|
||
|
||
- `copyAppearsOnlyWithASelection`: terminal agent with selection: labels `Copy`, `Paste`, `Read aloud selection`, `Plak`, `Wait what?`. Terminal shell without selection: only `Paste`.
|
||
- `waitWhatAppearsOnlyForASelectionInTheAgentPane`: agent without selection has no `Wait what?`; shell with selection has no `Wait what?`.
|
||
- `theActionsNameTheirPane`: shell with selection gives exactly: action copyTerminalSelection(shell) `Copy`, action pasteIntoTerminal(shell) `Paste`, separator, action readAloudTerminalSelection(shell) `Read aloud selection`, separator, action plakTerminalSelection(shell) `Plak`.
|
||
- `plakAppearsOnlyWithASelectionInBothPanes`: `Plak` present for agent and shell with selection; absent for both without.
|
||
- `readAloudAppearsOnlyWithASelection`: `Read aloud selection` absent for agent and shell without selection.
|
||
- `theMenuHasNoHeader`: the header for a terminal menu (agent, no selection) and for a directory `src` (project `app`) is empty.
|
||
|
||
#### Files / ContextActionsTests, suite EditorContextMenuTests (reference `src/a.php`, start line 12)
|
||
|
||
- `theEditorMenuHasNoHeader`: header is empty for an editor target with no code, and with code `x` and show-diff line 12.
|
||
- `fileGitRowAndRootMenusKeepTheirHeader`: file `src/a.php` header is `src/a.php`; git row `src/a.php` (not deleted) header is `src/a.php`; project root header is `app/` for project `app`.
|
||
- `aMarkedLineEndsWithShowDiffAtThatLine`: editor target, no code, show-diff line 12: entries exactly passOnReference(`src/a.php:12`, code nil) `Pass on reference`, copyReference(`src/a.php:12`) `Copy reference`, separator, showDiff(`src/a.php`, line 12) `Show diff`.
|
||
- `anUnchangedLineHasNoShowDiff`: editor target with no show-diff line: only `Pass on reference` and `Copy reference` (same actions as above), no separator.
|
||
|
||
#### Files / ContextActionsTests, suite BouwenContextMenuTests
|
||
|
||
- `anOntwikkelingFolderStartsWithBouwen`: directory `ontwikkelingen/2026-10-02-001-x`: the first three entries are bouwen(`2026-10-02-001-x`) `Bouwen`, separator, passOnReference(`ontwikkelingen/2026-10-02-001-x/`, nil) `Pass on reference` (directory references end with `/`).
|
||
- `otherPathsHaveNoBouwen`: no Bouwen entry for directory `ontwikkelingen`, directory `ontwikkelingen/ontwikkeld`, directory `ontwikkelingen/a/b`, directory `src/ontwikkelingen/a`, or file `ontwikkelingen/a`. (Only a direct child folder of top-level `ontwikkelingen`, other than `ontwikkeld`.)
|
||
|
||
#### Files / ContextActionsTests, suite ReadAloudContextMenuTests
|
||
|
||
- `aMarkdownFileCanBeReadAloud`: for file `docs/guide.md`, entries at positions 4, 5, 6 are separator, readAloudFile(`docs/guide.md`) `Read aloud`, separator.
|
||
- `otherFilesCannot`: file `src/app.php` and directory `docs` have no read-aloud entry.
|
||
- `aGitRowOpensInTheEditorThenPassesOnItsPath`: git row `src/a.php` (not deleted): exactly openFile(`src/a.php`) `Open in editor`, separator, passOnReference(`src/a.php`, nil) `Pass on reference`, copyReference(`src/a.php`) `Copy reference`. Git row `gone.php` (deleted): only `Pass on reference` and `Copy reference`. The openFile action is emphasized (bold).
|
||
- `theCommitMenuOffersCommitAndABoldCommitAndPush`: commit-menu header is the empty string; entries exactly commit(andPush false) `Commit`, commit(andPush true) `Commit and push`; commit-and-push is emphasized, plain commit is not.
|
||
- `aSelectionCanBeReadAloudAfterCopyReference`: reference `src/a.php` lines 3-4, code `$a = 1;`, show-diff line 3: exactly passOnReference(`src/a.php:3-4`, code `$a = 1;`) `Pass on selection`, copyReference(`src/a.php:3-4`) `Copy reference`, separator, readAloudText(`$a = 1;`) `Read aloud selection`, separator, plak(`$a = 1;`) `Plak`, separator, showDiff(`src/a.php`, line 3) `Show diff`.
|
||
- `noSelectionNoReadAloud`: editor on `README.md` line 1 with code nil or empty has no read-aloud entry.
|
||
- `selectedMarkdownIsReadAsProse`: selected `## Setup\nRun **this**` in `README.md` gives exactly one entry readAloudText(`Setup.\nRun this.`) `Read aloud selection`. Selected "```\nls\n```" gives readAloudText with the text unchanged ("```\nls\n```").
|
||
|
||
#### Files / ContextActionsTests, suite PlakContextMenuTests
|
||
|
||
- `anEditorSelectionIsSentAsRawCode`: selected `## Setup\nRun **this**` gives exactly plak(`## Setup\nRun **this**`) `Plak` (raw, not prose).
|
||
- `noSelectionNoPlak`: code nil or empty gives no Plak entry.
|
||
|
||
#### Files / FileLimitsTests
|
||
|
||
- `binary`: bytes `00 01 02` look binary; `plain text` does not; 8000 bytes of `A` followed by a NUL does not (only the first 8000 bytes are checked).
|
||
- `ripgrepArguments`: excludes `["*.log", ""]`, base `["node_modules"]`, followGitignore false give exactly `["--glob", "!node_modules", "--glob", "!*.log", "--no-ignore"]` (empty pattern skipped). With no excludes, no base and followGitignore true the argument list is empty.
|
||
- `symbolIgnores`: the symbol-declaration ignore list does not contain `vendor`; the symbol-reference ignore list does.
|
||
- `watchIgnored`: `node_modules/x/y.js` and `a/.git/HEAD` are watch-ignored; `src/gitlike/x` is not; `.DS_Store` is walk-ignored.
|
||
- `watchIgnoredWithExcludes`: with no excludes, `storage/framework/views/abc.php`, `bootstrap/cache/packages.php`, `.phpunit.result.cache` and `node_modules/x.js` are ignored, `storage/logs/laravel.log` is not. With exclude `*.log` it is. With exclude `public/hot`, `public/hot/x.js` is ignored. `app/Models/User.php` with excludes `["*.log", ""]` is not ignored.
|
||
- `glob` (parameterised; pattern, path, expected match):
|
||
- `*.log`, `debug.log`, true
|
||
- `*.log`, `logs/deep/debug.log`, true
|
||
- `*.log`, `debug.log.txt`, false
|
||
- `node_modules`, `node_modules`, true
|
||
- `node_modules`, `a/node_modules/pkg/index.js`, true
|
||
- `node_modules`, `node_modules_extra/x`, false
|
||
- `src/*.ts`, `src/a.ts`, true
|
||
- `src/*.ts`, `src/deep/a.ts`, false
|
||
- `src/*.ts`, `lib/src/a.ts`, false
|
||
- `/build`, `build/x.js`, true
|
||
- `/build`, `app/build/x.js`, false
|
||
- `docs/`, `docs/readme.md`, true
|
||
- `**/fixtures/*.json`, `fixtures/a.json`, true
|
||
- `**/fixtures/*.json`, `tests/unit/fixtures/a.json`, true
|
||
- `a/**/b`, `a/b`, true
|
||
- `a/**/b`, `a/x/y/b`, true
|
||
- `storage/**`, `storage/logs/x.log`, true
|
||
- `file?.txt`, `file1.txt`, true
|
||
- `file?.txt`, `file10.txt`, false
|
||
- `[abc].md`, `b.md`, true
|
||
- `[!abc].md`, `b.md`, false
|
||
- `[a-c]x`, `cx`, true
|
||
- `*.{js,ts}`, `x.ts`, true
|
||
- `*.{js,ts}`, `x.css`, false
|
||
- empty pattern, `a`, false
|
||
- `*.min.*`, `dist-like/app.min.js`, true
|
||
- `pathologicalGlob`: pattern `*a*a*a*a*a*a*a*a*b` against 200 `a` characters returns false quickly (no exponential backtracking).
|
||
|
||
#### Files / FileNodeTests
|
||
|
||
- `foldersFirst`: building a tree with root name `proj` from paths `README.md`, `src/a.ts`, `logo.bin`, `app/x.php` gives root name `proj`, root path empty, children `app`, `src`, `logo.bin`, `README.md` (folders first, each group sorted by name).
|
||
- `caseInsensitiveSort`: paths `b.txt`, `A.txt`, `a.md`, `C.txt` sort to `a.md`, `A.txt`, `b.txt`, `C.txt`.
|
||
- `nesting`: paths `a/b/c.txt`, `a/d.txt`: `a/b` is a directory with child `c.txt`; `a/b/c.txt` is a file whose children are nil.
|
||
- `emptyFolders`: paths `src/a.ts` with empty dirs `empty`, `src/nested/deep`: root children `empty`, `src`; `empty` has an empty (not nil) child list; `src/nested` has child `deep`.
|
||
- `duplicates`: paths `a.txt`, `a.txt`, empty, `/b.txt`, `c//d.txt` with empty dirs empty and `c` give root children `c`, `a.txt`, `b.txt`; `c` has child `d.txt`.
|
||
- `emptyListing`: no paths gives a root `{name p, directory, path "", children []}`.
|
||
- `visibleRows`: paths `.env`, `src/a.ts`, `src/.hidden`, `b.txt`: with nothing expanded and hidden files off, visible paths are `src`, `b.txt`. With `src` expanded and hidden on: `src`, `src/.hidden`, `src/a.ts`, `.env`, `b.txt` with depths 0, 1, 1, 0, 0.
|
||
- `replacingChildren`: replacing the children of `src` with a single file `src/z.ts` leaves `src` with `z.ts` and `lib` with `b.ts`.
|
||
|
||
#### Files / FileTypeTests
|
||
|
||
- `badgesFollowTheOldTable`: `src/A.php` -> badge `php` purple; `package.json` -> `json` amber; `composer.json` -> `json` purple; `.env.local` -> `env` teal; `Makefile` -> `·` grey.
|
||
- `languagesAndLabels`: `a.tsx` language is tsx; label for `a.yml` is `YAML`; label for `a.rs` is `RS` (unknown extension uppercased); `logo.PNG` is an image (case-insensitive).
|
||
- `ripgrepArgumentsHonourTheConfig`: exclude `*.log`, base `node_modules` give `["--glob", "!node_modules", "--glob", "!*.log", "--no-ignore"]`.
|
||
- `pathHelpers`: ancestors of `a/b/c.txt` are `a`, `a/b`; remapping `a/b/c.txt` from folder `a/b` to `a/x` gives `a/x/c.txt`; validated name of `" ../ "` is nil; validated name of `new.md/` is `new.md`.
|
||
|
||
#### Files / PlakTests
|
||
|
||
- `spacesAndNewlinesArePercentEncoded`: the append URL query for `a b\nc` is `a%20b%0Ac`.
|
||
- `ampersandPlusAndHashAreEncoded`: `a&b+c#d` encodes as `a%26b%2Bc%23d`.
|
||
- `theURLTargetsAppend`: append URL for `x` is `plak://append?text=x`; the paste URL is `plak://paste`.
|
||
- `shortTextIsAppended`: delivery for `hi` is append with URL `plak://append?text=hi`; text of exactly the append limit (100,000) is not delivered by paste.
|
||
- `textOverTheLimitGoesThroughThePasteboard`: text of limit + 1 characters is delivered by paste (pasteboard + `plak://paste`).
|
||
- `theLimitCountsUTF8Bytes`: `é` repeated limit/2 + 1 times (over 100,000 UTF-8 bytes) is delivered by paste.
|
||
|
||
#### Git / GitBranchesTests
|
||
|
||
- `parse`: the refs list `refs/heads/main`, `refs/heads/feature/b`, `refs/heads/feature/a`, `refs/remotes/origin/HEAD`, `refs/remotes/origin/main`, `refs/remotes/origin/feature/c`, `refs/remotes/upstream/main` (plus trailing blank line) gives local `feature/a`, `feature/b`, `main` and remote `origin/feature/c`, `origin/main` (sorted; only `origin`; `origin/HEAD` dropped).
|
||
- `empty`: empty output gives the empty branch list.
|
||
- `localName` (parameterised; remote -> local): `origin/main` -> `main`; `origin/feature/a` -> `feature/a`; `main` -> `main`.
|
||
- `tracked`: with local `main`, `feature/a` and remote `origin/main`, `origin/feature/a`, `origin/other`: the first two remotes are tracked, `origin/other` is not.
|
||
|
||
#### Git / GitConsoleTests
|
||
|
||
- `commandLine` (parameterised; arguments -> echo):
|
||
- `["status"]` -> `$ git status`
|
||
- `["commit", "-m", "fix the bar"]` -> `$ git commit -m "fix the bar"`
|
||
- `["commit", "-m", "say \"hi\""]` -> `$ git commit -m "say \"hi\""` (inner quotes backslash-escaped)
|
||
- `["commit", "-m", "it's"]` -> `$ git commit -m "it's"`
|
||
- `["commit", "-m", ""]` -> `$ git commit -m ""`
|
||
- `["add", "--", "pages/[id].vue"]` -> `$ git add -- pages/[id].vue` (brackets not quoted)
|
||
- `parseInput` (parameterised; typed input -> arguments):
|
||
- `status` -> `["status"]`
|
||
- ` git status ` -> `["status"]` (leading `git` dropped, trimmed)
|
||
- `git commit -m "fix the bar"` -> `["commit", "-m", "fix the bar"]`
|
||
- `commit -m 'it is "fine"'` -> `["commit", "-m", "it is \"fine\""]`
|
||
- `commit -m "say \"hi\""` -> `["commit", "-m", "say \"hi\""]`
|
||
- `commit -m "a\nb"` (literal backslash n) -> `["commit", "-m", "a\\nb"]` (backslash n kept as two characters)
|
||
- `commit -m ""` -> `["commit", "-m", ""]`
|
||
- `log --format='%h %s'` -> `["log", "--format=%h %s"]`
|
||
- `add my\ file.txt` -> `["add", "my file.txt"]`
|
||
- `commit -m "unclosed` -> `["commit", "-m", "unclosed"]`
|
||
- `parseNothing` (parameterised): input empty, ` `, `git`, ` git ` each give nil (nothing to run).
|
||
- `syncLabel` (parameterised; ahead, behind, upstream -> label):
|
||
- 0, 2, `origin/main` -> `2 behind origin`
|
||
- 1, 2, `origin/main` -> `1 ahead · 2 behind origin`
|
||
- 1, 0, `origin/main` -> `1 ahead of origin`
|
||
- 0, 0, `origin/feature/x` -> `in sync with origin`
|
||
- 0, 0, `upstream/main` -> `in sync with upstream`
|
||
- 3, 0, nil -> `no upstream`
|
||
- `generic` (parameterised; each line is classified the same for a `pull` on stderr and for a `push` on stdout):
|
||
- `hint: Updates were rejected` -> hint
|
||
- `error: failed to push some refs` -> error
|
||
- `fatal: not a git repository` -> error
|
||
- ` ! [rejected] main -> main (fetch first)` -> error
|
||
- ` ! [remote rejected] main -> main (pre-receive hook declined)` -> error
|
||
- `Aborting` -> error
|
||
- `Please commit your changes or stash them before you switch branches.` -> error
|
||
- `Already up to date.` -> output
|
||
- `progressIsOutput`: for push, stderr lines `Writing objects: 100% (3/3), 280 bytes | 280.00 KiB/s, done.` and `To github.com:x/y.git` are output.
|
||
- `pushSuccess` (parameterised; for `push -u origin main`, on stderr, each is success): ` a1b2c3d..e4f5a6b main -> main`; ` * [new branch] feature/x -> feature/x`; ` + a1b2c3d...e4f5a6b main -> main (forced update)`.
|
||
- `refUpdateOutsidePush`: for `fetch`, ` a1b2c3d..e4f5a6b main -> origin/main` is output.
|
||
- `statusSections`: for arguments `-c color.ui=never status`, in order: `On branch main` output; `Changes to be committed:` output; ` (use "git restore --staged <file>..." to unstage)` output; `\tmodified: a.txt` staged; `Changes not staged for commit:` output; `\tmodified: b.txt` unstaged; `Untracked files:` output; `\tnew.txt` unstaged. (The classifier is stateful.)
|
||
- `tabLinesOutsideStatus`: for `commit`, after `Changes to be committed:`, the line `\tmodified: a.txt` is output.
|
||
|
||
#### Git / GitDerivationTests
|
||
|
||
- `tooBig`: snapshot with `dump.sql` staged (not too big), `dump.sql` unstaged (too big), `a.txt` unstaged `1\n` -> `2\n`: changes are `dump.sql`, `dump.sql`, `a.txt`; row diff `s:dump.sql` not too big; row diff `w:dump.sql` too big; file diff `dump.sql` too big; file diff `a.txt` not too big.
|
||
- `behindAndUpstream`: snapshot ahead 1, can push, behind 2, upstream `origin/main` passes behind 2 and upstream `origin/main` through. A nil snapshot has upstream nil and behind 0.
|
||
- `notARepository`: nil snapshot: not a repository, branch `—` (em dash), no changes.
|
||
- `rows`: one unstaged modified change `a.txt` from `1\n2\n3\n` to `1\nX\n3\n4\n`, branch main, ahead 1, can push: is a repository, branch `main`, ahead 1, can push; changes exactly `[Change(a.txt, modified, added 2, removed 1, unstaged)]`; row diff `w:a.txt` has added 2; file diff `a.txt` updated text is `1\nX\n3\n4\n`; staged paths empty.
|
||
- `twoRowsWholeFile`: staged row `a.txt` `1\n2\n3\n` -> `1\nSTAGED\n3\n` and unstaged row `1\nSTAGED\n3\n` -> `1\nSTAGED\n3\n4\n`: change ids `s:a.txt`, `w:a.txt`; staged paths `{a.txt}`; whole-file diff original `1\n2\n3\n` (HEAD) and updated `1\nSTAGED\n3\n4\n` (disk); row diff `s:a.txt` updated `1\nSTAGED\n3\n`; row diff `w:a.txt` original `1\nSTAGED\n3\n`.
|
||
- `unstagedOwnsStatus`: staged modified `old\n` -> `new\n` plus unstaged deleted `new\n` -> empty: whole-file diff is a deleted file with original `old\n`; the last change reads deleted.
|
||
- `reversedRowOrder`: unstaged modified `index\n` -> `disk\n` listed first, staged added empty -> `index\n` second: whole-file diff original empty, updated `disk\n`, and not marked as an added file.
|
||
- `renameSource`: a staged renamed change `new.txt` with original path `old.txt`: the change keeps original path `old.txt`; the file diff for `new.txt` equals row diff `s:new.txt`.
|
||
- `newFile`: unstaged added `n.txt` empty -> `fresh\n`: file diff is an added file; totals (added 1, removed 0); unstaged paths `[n.txt]`.
|
||
|
||
#### Git / GitDerivationTests file, suite SourceControlTextTests
|
||
|
||
- `commitMessage`: `Fix The Bug\n In Parser \r\n` normalizes to `fix the bug in parser ` (lowercased, line breaks and their surrounding runs collapsed to one space, trailing single space kept).
|
||
|
||
#### Git / GitSectionsTests
|
||
|
||
- `build`: rows in order gone.txt (deleted, unstaged), new.txt (added, unstaged), b.txt (modified, unstaged), staged-delete.txt (deleted, staged), a.txt (modified, unstaged), staged-add.txt (added, staged) give sections in order staged, changed, untracked, deleted with ids `staged`, `changed`, `untracked`, `deleted`; staged rows `staged-delete.txt`, `staged-add.txt`; changed `b.txt`, `a.txt`; untracked `new.txt`; deleted `gone.txt` (each keeps its input order).
|
||
- `changed` (parameterised): an unstaged row of status modified, renamed, or unmerged each lands in the single section `changed`.
|
||
- `emptySections`: no rows gives no sections; one unstaged deleted row gives only `deleted`.
|
||
- `uniquePaths`: rows a (staged), b, a (unstaged) give unique paths `a`, `b`.
|
||
- `noChanges`: an inline diff of `a\nb\n` vs same has no rows.
|
||
- `gaps`: 20 lines `line N\n` with line 10 changed to `line 10 edited`: 9 rows; first row gap(6), last row gap(7); row 1 is a line pair numbered 7/7 with no mark (default context 3).
|
||
- `noLeadingGap`: 5 lines, line 2 changed, context 1: 4 rows; last row gap(2).
|
||
- `mergedContext`: lines `1`...`10`, with `3` -> `x` and `8` -> `y`, context 2: no gap rows; 10 rows total.
|
||
- `highlight`: `let a = 1\n` vs `let a = 22\n`: exactly one line row: left {1, `let a = 1`, removed, highlight 8..<9}, right {1, `let a = 22`, added, highlight 8..<10}.
|
||
- `highlightOneSide`: `foo()` vs `foo(bar)`: left highlight nil; right highlight 4..<7.
|
||
- `noCommonPart`: `abc` vs `xyz`: left removed, right added, neither highlighted.
|
||
- `noOverlap`: `aa` vs `aaa`: left highlight nil; right highlight 2..<3 (prefix and suffix never overlap).
|
||
- `unpaired`: `a\n` vs `a\nb\n`: the last row is left nil, right {2, `b`, added, no highlight}.
|
||
|
||
#### Git / PorcelainTests
|
||
|
||
- `columns`: index `M` working space -> [modified, staged]; index space working `M` -> [modified, unstaged]; `A` space -> [added, staged]; `D` space -> [deleted, staged]; `R` space -> [renamed, staged].
|
||
- `untracked`: `??` -> [added, unstaged].
|
||
- `twoRows` (parameterised; index, working -> staged status, unstaged status): `M`,`M` -> modified, modified; `A`,`M` -> added, modified; `M`,`D` -> modified, deleted. Each gives two rows: staged first, unstaged second.
|
||
- `conflict` (parameterised): `UU`, `AA`, `DD`, `UD` each give one row [unmerged, unstaged].
|
||
- `conflictIsChanged` (GitSectionsTests): `UU`, `AA`, `DD` classified and built into sections give only the **changed** section with one `.unmerged` row.
|
||
- `conflictIsNotStaged` (GitDerivationTests): one conflict `both.txt` plus one staged `ready.txt`: staged count 1, unstaged count 1, staged paths [`ready.txt`], unstaged paths [`both.txt`].
|
||
- `aConflictIsNotAStagedFile` (SourceControlStoreTests): staged path count 1 and `fileStatuses["both.txt"] == .unmerged`.
|
||
- `ahead` (parameterised; header -> ahead, canPush):
|
||
- `main...origin/main [ahead 3]` -> 3, true
|
||
- `main...origin/main [ahead 1, behind 2]` -> 1, true
|
||
- `main...origin/main` -> 0, false
|
||
- `main...origin/main [behind 2]` -> 0, false
|
||
- `feature/x` -> 0, true (no upstream yet: can push)
|
||
- `No commits yet on main` -> 0, false
|
||
- `HEAD (no branch)` -> 0, false
|
||
- `behind` (parameterised): `main...origin/main [ahead 1, behind 2]` -> 2; `main...origin/main [behind 5]` -> 5; `main...origin/main [ahead 3]` -> 0; `main...origin/main` -> 0; `feature/x` -> 0; `HEAD (no branch)` -> 0.
|
||
- `upstream` (parameterised): `main...origin/main [ahead 1, behind 2]` -> `origin/main`; `feature/x...origin/feature/x` -> `origin/feature/x`; `main...origin/main [gone]` -> `origin/main`; `main` -> nil; `No commits yet on main` -> nil; `HEAD (no branch)` -> nil.
|
||
- `branch` (parameterised): `main...origin/main [ahead 1]` -> `main`; `main` -> `main`; `feature/x...origin/feature/x` -> `feature/x`; `No commits yet on trunk` -> `trunk`; `HEAD (no branch)` -> `HEAD`; empty -> `HEAD`.
|
||
- `parseStatus`: `## main...origin/main [ahead 2]\0 M src/a.ts\0?? new file.txt\0MM both.php\0` gives branch `main`, ahead 2, can push, behind 0, upstream `origin/main`, entries (space, `M`, `src/a.ts`), (`?`, `?`, `new file.txt`), (`M`, `M`, `both.php`).
|
||
- `renameSkipsSource`: `## main\0R new.ts\0old.ts\0 M other.ts\0` gives entry paths `new.ts`, `other.ts`; the first has index `R`.
|
||
- `renameCarriesSource`: same input: entry 0 equals (`R`, space, `new.ts`, original path `old.ts`); entry 1 has no original path.
|
||
- `copySkipsSource`: ` C copy.ts\0orig.ts\0` gives paths `copy.ts` only.
|
||
- `noHeader`: ` M a.txt\0` gives branch `HEAD`, cannot push, 1 entry.
|
||
- `aheadAndBehind`: `## main...origin/main [ahead 1, behind 2]\0` equals (branch main, ahead 1, can push, behind 2, upstream origin/main, no entries).
|
||
- `empty`: empty output equals (branch HEAD, ahead 0, cannot push, no entries).
|
||
- `unquotedPaths`: ` M dir/naïve file 😀.md\0` keeps the path `dir/naïve file 😀.md` exactly.
|
||
- `needsUpstream`: stderr `fatal: The current branch x has no upstream branch.` needs an upstream; `rejected` does not.
|
||
- `rowIDs`: row id for `a.txt` staged is `s:a.txt`; unstaged is `w:a.txt`.
|
||
|
||
#### Highlight: shared helpers and vocabulary
|
||
|
||
Token roles are: `plain`, `keyword`, `string`, `number`, `variable`, `comment`, `symbol` (a known PHP class, underlined/linkable). Tokens have a UTF-16 location, a length and a role.
|
||
|
||
Two helpers (`HighlightTestSupport`) state the rules below:
|
||
|
||
- `role(fragment, in: text, language, occurrence = 0, symbols = [])`: find the n-th occurrence (0-based) of `fragment` in `text`; highlight the whole text (with `symbols` as the known class names); return the role of the tokens that cover the fragment, or nil if the fragment is missing or covered by tokens of different roles. "X reads as R" below means `role(X) == R`. "Occurrence 1" means the second appearance.
|
||
- `paintedRuns(text, language)`: the non-plain tokens as `text:role` strings.
|
||
|
||
Language keys: `css` (CSS/SCSS), `json`, `javascript`, `typescript`, `jsx`, `tsx`, `markdown`, `markup` (HTML/XML/Vue), `php` (PHP and Blade), `python`, `bash` (shell and `.env`), `yaml`.
|
||
|
||
#### Highlight / CSSGrammarTests
|
||
|
||
- `basics`: in `.btn:hover > a, #main { color: #fff; margin: 0 4px 1.5em; display: flex !important; }`: `.btn` number; `:hover` keyword; `>` keyword; `#main` number; `color` variable; `#fff` number; `4px` number; `1.5em` number; `flex` string; `!important` keyword.
|
||
- `atRulesAndFunctions`: in `@media (max-width: 600px) {\n nav { background: url(img/x.png); width: calc(100% - var(--gap)); }\n}`: `@media` keyword; `img/x.png` string; `calc` plain; `100%` number; `--gap` variable; `nav` number.
|
||
- `scssNesting`: in `.card {\n $pad: 4px;\n padding: $pad;\n &:hover {\n color: red;\n }\n}`: `$pad` variable; `padding` variable; `&` keyword; `:hover` keyword; `color` variable.
|
||
- `multiLineValue`: in `a {\n grid-template-areas:\n "head head"\n main;\n color: red;\n}`: `"head head"` string; `main` string; `color` variable.
|
||
- `comments`: in `/* a\n b */\n// scss\na { b: c; }`: ` b */` comment (block comment spans lines); `// scss` comment.
|
||
|
||
#### Highlight / JSONGrammarTests
|
||
|
||
- `keysAndValues`: in `{"name": "helder", "n": -1.5e2, "ok": true, "none": null, "list": ["a"]}`: `"name"` variable; `"helder"` string; `-1.5e2` number; `true` number; `null` number; `"a"` string.
|
||
- `escapedQuote`: in `{"k": "a \" b"}` the whole `"a \" b"` is string.
|
||
- `comments`: in `{\n // line\n /* block */ "a": 1\n}`: `// line` comment; `/* block */` comment.
|
||
|
||
#### Highlight / JavaScriptGrammarTests
|
||
|
||
- `basics`: painted runs of `const a = 'x' + "y" // note\nlet b = 1.5e3` are exactly `const:keyword`, `=:keyword`, `'x':string`, `+:keyword`, `"y":string`, `// note:comment`, `let:keyword`, `=:keyword`, `1.5e3:number`.
|
||
- `templateLiteral`: in ``const s = `a ${fn(1)} b\nstill string ${x}`\nconst after = 2``: `` `a `` string; `1` number; `still string ` string; `after` plain; `2` number.
|
||
- `nestedBraces`: in ``` `${ {a: 1}.a } tail` ```, `` tail` `` is string.
|
||
- `regexVersusDivision`: `/ab+c/gi` in `const r = /ab+c/gi` is string; `/` in `const q = a / b / c` is keyword.
|
||
- `blockComment`: in `/**\n * Docs\n */\nfunction f() {}`: ` * Docs` comment; `function` keyword.
|
||
- `classNames`: in `class A extends B { m() { return new C() } }`: `A`, `B`, `C` variable; `m` plain.
|
||
- `constants`: in `if (x === undefined || y === true) MAX_SIZE`: `undefined`, `true`, `MAX_SIZE` number.
|
||
- `typescript`: in `interface A { readonly n: number }\ntype B = keyof A`: as typescript `readonly` keyword, `number` number, `keyof` keyword; as plain javascript `type` is plain.
|
||
- `jsx` (parameterised over jsx and tsx): in `return <Card title="x" onClick={() => go(1)}>\n Hi\n</Card>`: `Card` number; `title` variable; `"x"` string; `=>` keyword; `1` number; `Card` occurrence 1 number.
|
||
- `multiLineTag`: in `const a = <div\n className="x"\n/>\nlet b` (jsx): `className` variable; `let` keyword.
|
||
- `lessThan`: in `if (a <b) {}` (jsx), `<` is keyword.
|
||
- `unterminatedString`: in `const a = 'open\nconst b = 1`, `const` occurrence 1 is keyword.
|
||
- `childrenText`: in `const a = <p>Don't {name} if</p>\nconst b = 'x'` (jsx): `Don't ` plain; `if` plain; `p` occurrence 1 number; `'x'` string.
|
||
- `nestedChildren`: in the multi-line jsx `const list = (\n <ul className="x">\n {items.map((item) => (\n <li key={item.id}>{item.label}</li>\n ))}\n </ul>\n)\nlet after = 1`: `ul` number; `=>` keyword; `li` occurrence 1 number; `key` variable; `ul` occurrence 1 number; `let` keyword.
|
||
- `fragments`: in `return <>it's <b>x</b></>\nlet y` (tsx): `it's ` plain; `let` keyword.
|
||
- `selfClosing`: in `x = <Br />; let z` (jsx), `let` is keyword.
|
||
|
||
#### Highlight / LexerTests (internal lexer)
|
||
|
||
- `numbers` (parameterised): each literal `0x1F`, `0b1010`, `1_000_000`, `3.14`, `1e10`, `2.5E-3`, `10n`, followed by ` rest`, is consumed whole by the number scanner and gives one number token from 0 with the literal's length.
|
||
- `unterminatedString`: scanning `'abc` from after the quote reports not closed and stops at index 4 (line end).
|
||
- `escapeAtLineEnd`: scanning `'ab\` reports not closed and stops at index 4 (does not run past the end).
|
||
- `mergesAdjacentRuns`: emitting keyword 0..2 then keyword 2..4 gives one token (0, length 4, keyword).
|
||
- `unicodeIdentifiers`: `é` may start an identifier; every UTF-16 unit of `😀` is an identifier part; `-` may not start an identifier.
|
||
|
||
#### Highlight / MarkdownGrammarTests
|
||
|
||
- `headings`: `## Title` in `## Title\ntext` is keyword; `#hashtag` alone is plain.
|
||
- `fencedCode`: in "```php\n$x = new Agent();\n```\nafter $x": "```php" comment; `$x` variable; `new` keyword; `$x` occurrence 1 (after the fence) plain.
|
||
- `unknownFence`: in `~~~text\nif x\n~~~`, `if x` is plain.
|
||
- `fenceCarriesState`: in "```js\n/* a\nb */ let c\n```": `b */` comment; `let` keyword.
|
||
- `inline`: in ``Use `npm test` and [docs](https://x.test) or <https://y.test>.``: `` `npm test` `` keyword; `(https://x.test)` variable; `docs` plain; `<https://y.test>` variable.
|
||
- `punctuation`: in `- one\n1. two\n> quote\n---`: `-`, `1.`, `>`, `---` comment.
|
||
|
||
#### Highlight / MarkupGrammarTests
|
||
|
||
- `basics`: painted runs of `<a href="/x" data-id=1 hidden>Tom & Jerry</a>` are exactly `a:number`, `href:variable`, `"/x":string`, `data-id:variable`, `1:string`, `hidden:variable`, `&:variable`, `a:number`.
|
||
- `comments`: in `<!DOCTYPE html>\n<!-- a\n b -->\n<![CDATA[ x ]]>\n<p>`: `<!DOCTYPE html>` comment; ` b -->` comment; `<![CDATA[ x ]]>` comment; `p` number.
|
||
- `embedded`: in `<script>\nconst a = 1 // c\n</script>\n<style>\n.b { color: red; }\n</style>\n<p>const</p>`: `const` keyword; `// c` comment; `script` occurrence 1 number; `.b` number; `color` variable; `const` occurrence 1 (inside `<p>`) plain.
|
||
- `scriptCloseInsideComment`: in `<script>// x</script><p>`: `// x` comment; `p` number.
|
||
- `multiLineTag`: in `<img\n alt="a\n b"\n src="x">\nafter`: ` b"` string; `src` variable; `after` plain.
|
||
- `vue`: in `<template><div :class="a" @click="go"/></template>\n<script setup>\nimport x from 'y'\n</script>`: `:class` variable; `@click` variable; `import` keyword.
|
||
|
||
#### Highlight / PHPGrammarTests
|
||
|
||
Shared source:
|
||
|
||
```
|
||
<?php
|
||
namespace App\Domain;
|
||
|
||
use Illuminate\Support\Str;
|
||
|
||
#[Attribute]
|
||
final class Agent extends Model implements HasLabel
|
||
{
|
||
use HasFactory;
|
||
public const STATUS_ACTIVE = 'active';
|
||
|
||
public function label(?string $prefix = null): string
|
||
{
|
||
// line comment
|
||
return Str::upper("{$this->name} $prefix") . self::STATUS_ACTIVE . 0x1F;
|
||
}
|
||
}
|
||
```
|
||
|
||
- `keywords`: `<?php`, `final`, `function`, `string` (first) keyword.
|
||
- `namespacePath`: `App\Domain` string; `Illuminate\Support\` string.
|
||
- `classNames` (parameterised over `Agent`, `Model`, `HasLabel`, `HasFactory`, `Attribute`, `Str`): each reads as variable with no known symbols, and as symbol when it is in the known-symbols set.
|
||
- `importedClass`: `Str` with symbols {`Str`} is symbol.
|
||
- `variablesAndConstants`: `$prefix` variable; `STATUS_ACTIVE` (both occurrences) number; `null` number; `0x1F` number.
|
||
- `arrowAccess`: in `<?php $a->save(); $a->name;`: `save` plain; `name` variable; `->` keyword.
|
||
- `interpolation`: in `<?php $a = "hi $name!"; $b = 'hi $name';`: `"hi ` string; `$name` (first) variable; `'hi $name'` string. In the shared source `{$this->name}` is variable.
|
||
- `comments`: `// line comment` comment; `# hash` in `<?php # hash\n$a;` comment; in `<?php /* one\n two */ $x;` `two */` comment and `$x` variable.
|
||
- `multiLineString`: in `<?php $sql = "select *\n from users\n where id = 1";\n$next = 2;`: ` from users` string; `$next` variable.
|
||
- `heredoc`: in `<?php\n$a = <<<EOT\n Hello $name\n EOT;\n$b = <<<'RAW'\n $raw\nRAW;\n$c = 1;`: ` Hello ` string; `$name` variable; `$raw` string (nowdoc); `$c` variable; `1` (first) number.
|
||
- `template`: in `<div class="<?= $cls ?>">\n<?php if ($x): ?>\n <b>hi</b>\n<?php endif; ?>\n</div>`: `div` number; `$cls` variable; `?>` keyword; `if` keyword; `hi` plain; `endif` keyword.
|
||
- `lineCommentEndsAtCloseTag`: in `<p><?php // note ?> after</p>`: `// note ` comment; `?>` keyword; `after` plain.
|
||
- `bladeReadsAsPHP`: in `@if($user)\n {{ $user->name }}\n@endif` (no `<?php`), `$user` variable.
|
||
- `scopeKeywords`: in `<?php static::make(); self::X; parent::boot(); Carbon::now();`: `static`, `self`, `parent` keyword; `Carbon` with symbols {`Carbon`} symbol.
|
||
- `qualifiedName`: in `<?php new \App\Models\Agent();`: `\App\Models\` string; `Agent` with symbols {`Agent`} symbol.
|
||
- `caseInsensitiveKeywords`: `NEW` in `<?php $a = NEW Foo;` keyword.
|
||
|
||
#### Highlight / PythonGrammarTests
|
||
|
||
- `basics`: in `def run(x):\n if x is None: # guard\n return len(x)\n return True`: `def` keyword; `run` plain; `None` number; `# guard` comment; `len` number; `True` number.
|
||
- `tripleQuoted`: in `x = '''one\ntwo # not a comment\nthree'''\ny = 1`: `two # not a comment` string; `1` number.
|
||
- `prefixes` (parameterised): each of `f"a{b}"`, `rb'raw'`, `u"x"` in `v = <literal>` reads as one string (prefix included).
|
||
- `decorators`: in `@app.route('/')\ndef f(): return a @ b`: `@app.route` keyword; `@` occurrence 1 plain.
|
||
- `className`: `Agent` in `class Agent(Base):` variable.
|
||
|
||
#### Highlight / ShellGrammarTests
|
||
|
||
- `basics`: in `if [ -n "$HOME" ]; then echo "dir: ${HOME}/x" 'no $sub'; fi`: `if` keyword; `$HOME` variable; `echo` number; `${HOME}` variable; `'no $sub'` string; `fi` keyword.
|
||
- `hashInWord`: in `echo a#b # real`: `a#b` plain; `# real` comment.
|
||
- `heredoc`: in `cat <<EOF\nhi $USER\nEOF\ncat <<'RAW'\n$keep\nRAW\necho done`: `hi ` string; `$USER` variable; `$keep` string; `echo` number.
|
||
- `dotenv`: in `APP_NAME=Helder\n# comment\nDB_PASSWORD="s3cret"`: `APP_NAME` variable; `# comment` comment; `"s3cret"` string.
|
||
- `multiLineString`: in `msg="one\ntwo"\necho x`: `two"` string; `echo` number.
|
||
- `dashedWords`: in `apt-get install -y done-thing`: `apt-get` plain; `done-thing` plain.
|
||
|
||
#### Highlight / SyntaxHighlighterTests
|
||
|
||
The ten samples used by the parameterised tests:
|
||
|
||
1. php: `<?php\nnamespace App;\n/* a\n block */\nclass A extends B {\n public function run(): string { return "x $y"; }\n}\n`
|
||
2. javascript: ``const a = `x ${b} y`\n/* c\n d */ let e = /re/g\n``
|
||
3. tsx: `export const App = () => (\n <div className="x">\n {n.map((i) => <b key={i}>{i}</b>)}\n </div>\n)\n`
|
||
4. markup: `<html>\n<!-- c\n -->\n<script>\nlet a = 1\n</script>\n<style>a { color: red }</style>\n`
|
||
5. css: `a {\n color: #fff;\n margin: 0 4px;\n}\n`
|
||
6. json: `{\n "a": [1, true, null]\n}\n`
|
||
7. markdown: "# T\n\n```php\n$x = 1;\n```\n- item `code`\n"
|
||
8. bash: `#!/bin/sh\nif [ -f x ]; then echo "$HOME"; fi\ncat <<EOF\nhi $USER\nEOF\n`
|
||
9. python: `def f(x):\n """doc\n string"""\n return None\n`
|
||
10. yaml: `a: 1\nb: |\n text\nc: true # note\n`
|
||
|
||
- `tokensTileTheText` (parameterised over the 10 samples): tokens start at 0, each starts where the previous ended, each has length > 0, and the last ends at the UTF-16 length of the text.
|
||
- `adjacentRunsAreMerged` (parameterised over the 10 samples): no two neighbouring tokens have the same role.
|
||
- `incrementalMatchesWholeBuffer` (parameterised over the 10 samples): highlighting line by line (split on `\n`) with a carried `HighlightState` (initialised from language and full text), offsetting each line by its start, gives exactly the same non-plain tokens as highlighting the whole buffer.
|
||
- `unknownLanguageIsPlain`: `a = 1` with no language is one plain token (0, 5).
|
||
- `emptyBuffer`: an empty text has no tokens (php whole-buffer; javascript single line).
|
||
- `utf16Offsets`: in `const s = "😀"; const n = 42` (javascript) the first number token starts at the UTF-16 location of `42` and has length 2.
|
||
- `crlfLines`: in `/* a\r\n b */\r\nlet x = 1\r\n` (javascript): `b */` comment; `let` keyword; `1` number.
|
||
- `lineStandsAlone`: highlighting the single line ` end */ let x` (javascript, no state) contains a keyword token and no comment token.
|
||
- `stateReportsOpenConstruct`: after line `/* open` the state is inside a construct; after `close */` it is not, and the state equals a fresh javascript state.
|
||
- `hostileInput` (parameterised over every language): the text `<?php "'`/*<!--<<<EOT\n${{[(\\\n<NUL>é😀\t\r\n?> </script> ``` ---\n` followed by 20 backslashes tokenizes without hanging, and the token lengths sum to the UTF-16 length.
|
||
- `performanceSanity`: a 12-line PHP controller block (namespace, docblock, final class extending Controller implementing HasMiddleware, a `show` method with a query chain, a line comment, interpolated strings, an array with `42`), repeated 5000/12 + 1 times, tokenizes as php with known symbol `User` in under 1 second (even in a debug build).
|
||
|
||
#### Highlight / YAMLGrammarTests
|
||
|
||
- `basics`: in `name: helder # app\nport: 8080\ndebug: true\nempty: ~\nurl: http://x.test:80\n"quoted key": 'v'`: `name` keyword; `# app` comment; `8080` number; `true` keyword; `~` keyword; `http://x.test:80` plain; `"quoted key"` keyword; `'v'` string.
|
||
- `blockScalar`: in `script: |\n echo: hi\n\n more\nnext: 1`: ` echo: hi` has mixed roles (nil: the indentation is not part of the string); `echo: hi` string; `more` string; `next` keyword.
|
||
- `listsAndAnchors`: in `base: &base\n - item: !!str 1\nuse: *base`: `&base` keyword; `item` keyword; `!!str` number; `*base` keyword.
|
||
- `flow`: in `tags: [a, 2, true]`: `2` number; `true` keyword.
|
||
|
||
#### Markdown / MarkdownInlineParserTests
|
||
|
||
Inline node kinds: text, strong, emphasis, strikethrough, code, link(text, url, title), image(alt, source local(path)|remote(URL), title).
|
||
|
||
- `destination` (parameterised; raw destination -> URL, title):
|
||
- `https://x.com` -> `https://x.com`, no title
|
||
- `https://x.com "Home"` -> `https://x.com`, `Home`
|
||
- `<a b.png> 'T'` -> `a b.png`, `T`
|
||
- `x.png (Paren)` -> `x.png`, `Paren`
|
||
- ` spaced ` -> `spaced`, no title
|
||
- `plainText`: nodes [text `a `, strong[code `b`], link(text [text ` c`], url `#`)] flatten to alt text `a b c`.
|
||
- `placeholderLookAlike`: the text `x U+E000 99 U+E001 y` (private-use characters that look like the parser's internal placeholders) parses to a single text node with the text unchanged.
|
||
- `unmatchedMarkers`: `a ** b ` + "`" + ` c [d](` parses to one text node, unchanged.
|
||
|
||
#### Markdown / MarkdownParserTests
|
||
|
||
Block kinds: heading(level, content), paragraph, code(language, text), list(ordered, items), rule, quote(blocks), table(header, alignments, rows).
|
||
|
||
- `headingsAndInline`: `# Title\n\nSome **bold** and *italic* and [a](https://x.com).` gives heading 1 [text `Title`], then paragraph [text `Some `, strong[`bold`], text ` and `, emphasis[`italic`], text ` and `, link([`a`], `https://x.com`, no title), text `.`].
|
||
- `headingLevels` (parameterised): `###### six` is a level-6 heading; `## two ` is level 2. In each case also: `#nospace` is a paragraph `#nospace`; `####### seven` is a paragraph `####### seven`.
|
||
- `codeSpans`: `I have 0 cats and ` + "`**code**`" + ` and 1 dog.` gives paragraph [text `I have 0 cats and `, code `**code**`, text ` and 1 dog.`].
|
||
- `rawHTML`: `A <script>alert(1)</script> tag.` is one paragraph with that literal text.
|
||
- `unsafeLinks`: `[click](javascript:alert(1))` gives paragraph [text `click)`]; `[click](javascript:x)` gives paragraph [text `click`] (link dropped, text kept).
|
||
- `fencedCode`: "```js\nconst a = 1\n\n b\n```\nafter" gives code(javascript, `const a = 1\n\n b`) then paragraph `after`. An unclosed "```\nx" gives code(no language, `x`). "```brainfuck\n+\n```" gives code(no language, `+`).
|
||
- `lists`: `- a\n* b\n+ c` gives one unordered list with items `a`, `b`, `c`; `1. a\n2) b` gives one ordered list with items `a`, `b`.
|
||
- `rules`: `---`, `* * *`, `__ _` are rules; `-*-` is not.
|
||
- `quotes`: `> # Hi\n> > deep\nout` gives quote[heading 1 `Hi`, quote[paragraph `deep`]], then paragraph `out`.
|
||
- `paragraphs`: `a\n b \n\nc` gives paragraph `a b`, paragraph `c`.
|
||
- `lineEndings`: `# A\r\nb\rc` gives heading 1 `A`, paragraph `b c`.
|
||
- `empty`: empty text and `\n\n \n` give no blocks.
|
||
- `table`: `| a | b |\n|---|---|\n| 1 | ` + "`x`" + ` |\n| 2 | **y** |` gives a table with header [`a`], [`b`], alignments [none, none], rows [[`1`], [code `x`]] and [[`2`], [strong `y`]].
|
||
- `alignment`: delimiter row `| :-- | :-: | --: |` gives alignments left, center, right.
|
||
- `raggedRows`: `| a | b |\n|---|---|\n| x \| y | 2 | extra |\n| short |\n\nAfter.` gives a table with rows [[`x | y`], [`2`]] (extra cell dropped, escaped pipe unescaped) and [[`short`], []] (missing cell empty), then paragraph `After.`.
|
||
- `notATable`: `a | b\nnot a table` is one paragraph `a | b not a table`.
|
||
- `localImage`: `` with base folder `docs/how-to` gives image(alt `Forge`, local `docs/how-to/forge-app-config.png`, no title).
|
||
- `imageTitle`: `` with base `docs/how-to` gives image(alt `c`, local `docs/img/a b.png` (percent-decoded, `..` walks up), title `A title`).
|
||
- `rootImage`: `` with base `docs/how-to` gives local `img/a.png` (leading slash = project root).
|
||
- `remoteImage`: `` gives image with remote URL `https://x.com/a.png`.
|
||
- `linkTitle`: `[a](https://x.com "Home")` gives link url `https://x.com`, title `Home`.
|
||
- `nesting`: `[](https://x.com)` gives link whose text is image(alt `i`, local `i.png`) and url `https://x.com`. `**see [a](#top)**` gives strong[text `see `, link([`a`], `#top`)].
|
||
- `intrawordUnderscore`: `snake_case_name and _this_` gives [text `snake_case_name and `, emphasis[`this`]]. `__bold__ ~~gone~~` gives [strong[`bold`], text ` `, strikethrough[`gone`]].
|
||
- `safeURLs` (parameterised; input -> kept): `https://x` -> `https://x`; `mailto:a@b` -> `mailto:a@b`; `#top` -> `#top`; `./a` -> `./a`; `../a` -> `../a`; `img/x.png` -> `img/x.png`; ` /a ` -> `/a` (trimmed).
|
||
- `unsafeURLs` (parameterised; each gives nil): `javascript:alert(1)`, `JAVASCRIPT:x`, `data:text/html,x`, `file:///etc/passwd`.
|
||
- `fenceLanguages`: fence info `TS` -> typescript; `shell` -> bash; empty -> none.
|
||
|
||
#### Markdown / MarkdownSpeechTests (`speech(md)` = plain speech text of the parsed markdown)
|
||
|
||
- `eachBlockIsItsOwnSentence`: `# Title\n\nFirst paragraph\n\nSecond one!` -> `Title.\nFirst paragraph.\nSecond one!` (a period is added unless the block already ends in punctuation; blocks join with `\n`).
|
||
- `inlineMarkupIsStrippedAndLinksKeepTheirText`: `Some **bold**, *soft*, ~~old~~ and ` + "`code`" + ` in [the docs](https://x.com).` -> `Some bold, soft, old and code in the docs.`
|
||
- `listItemsQuotesAndTableRowsAreRead`: `- one\n- two:\n\n> quoted` -> `one.\ntwo:\nquoted.`; `| Name | Role |\n|---|---|\n| Ann | dev |` -> `Name, Role.\nAnn, dev.`
|
||
- `codeBlocksAndRulesAreSkipped`: "Before\n\n```php\necho 1;\n```\n\n---\n\nAfter" -> `Before.\nAfter.`; a document with only a code block gives empty text.
|
||
- `aDollarSignIsSpokenAsDollar`: spoken(`echo $user`) = `echo dollar user`; spoken(`$ x`) = `dollar x`; spoken(`a$$`) = `a dollar dollar`.
|
||
- `aDollarBeforeADigitAndTextWithoutDollarStay`: `It costs $5.` stays; `No money here.` stays.
|
||
|
||
#### Search / FuzzyTests, suite FuzzyTests
|
||
|
||
- `matchesSubsequencesCaseInsensitively`: `uc` in `UserController.php` matches at indices [0, 4]; `xyz` does not match (nil).
|
||
- `ranksBasenameMatchesFirst`: query `userl` over `src/user/list.php`, `app/UserList.php`, `.env` (hidden off) gives `app/UserList.php` (rank 0, basename match) then `src/user/list.php` (rank 1).
|
||
|
||
#### Search / FuzzyTests, suite FuzzyPortedTests
|
||
|
||
- `emptyQuery`: query of two spaces over `a.ts` (hidden on) gives no results; matching an empty query in `abc` gives an empty index list (not nil).
|
||
- `hiddenPaths`: query `env` over `.env` gives nothing with hidden off, and `.env` with hidden on.
|
||
- `inFileHits`: in-file search `Bal` in `😀 balance\nnone\nBALANCE` gives hits (line 1, text `😀 balance`, match offset 3 in UTF-16) and (line 3, `BALANCE`, offset 0).
|
||
|
||
#### Search / RipgrepJSONTests, suite RipgrepJSONTests
|
||
|
||
- `parsesMatch`: the JSON line `{"type":"match","data":{"path":{"text":"/p/a.ts"},"lines":{"text":"const balance = 2\n"},"line_number":2,"absolute_offset":12,"submatches":[{"match":{"text":"balance"},"start":6,"end":13}]}}` parses to (path `/p/a.ts`, line 2, text `const balance = 2` without the newline, byte offset 6 from the first submatch start).
|
||
- `skipsOtherEvents` (parameterised; each gives nil): `{"type":"begin",...}`, `{"type":"end",...}`, `{"type":"summary",...}`, `not json`, empty.
|
||
- `skipsBytes`: a match whose path is given as base64 `bytes` (`L3AvYQ==`) is skipped; a match whose line is given as `bytes` (`eA==`) is skipped.
|
||
- `defaults`: `{"type":"match","data":{"path":{"text":"/p/a"},"lines":{"text":"x\r\n"}}}` parses to (path `/p/a`, line 0, text `x` (CRLF stripped), offset 0).
|
||
- `relativePath`: `/p/src/a.ts` under root `/p` -> `src/a.ts`; under root `/p/` -> `src/a.ts`; `/other/a.ts` under `/p` -> `/other/a.ts` unchanged.
|
||
|
||
#### Search / RipgrepJSONTests, suite ContentGrouperTests (root `/p`)
|
||
|
||
- `groups`: matches `/p/b.ts` line 1, `/p/a.ts` line 3, `/p/b.ts` line 7 give groups `b.ts`, `a.ts` (first-seen order), with `b.ts` hits on lines 1, 7.
|
||
- `utf16Offset` (parameterised; text, byte offset -> UTF-16 offset): `const balance`, 6 -> 6; `é balance`, 3 -> 2; `😀 balance`, 5 -> 3.
|
||
- `capsLongLines`: a 1500-character line with byte offset 1400 is capped to the max line length (1000 UTF-16 units) and the offset clamped to 1000.
|
||
- `capKeepsSurrogates`: a line of 999 `a` + `😀 tail` is capped to exactly the 999 `a` (the cap never splits a surrogate pair).
|
||
- `fileLimit`: adding one match for each of max files + 5 (400 + 5) distinct files, then a second match for `f0`, keeps exactly 400 groups and `f0` has 2 hits.
|
||
- `hitLimit`: 50 + 3 hits in one file keep exactly 50 (max hits per file).
|
||
|
||
#### Session / ColumnLayoutTests (minimum editor width 280; one splitter = 1 point)
|
||
|
||
- `roomyWindowUsesTheDesignRatios`: fluid layout for window width 1760 with focus on terminal gives explorer 289, agent 480.
|
||
- `tightWindowFollowsFocus`: window 1200: focus terminal gives agent 600; focus editor gives agent 240.
|
||
- `fittingKeepsTheEditorMinimum`: fitting explorer 400, agent 600 into window 1000 with all columns visible gives explorer + agent <= 1000 - 2 - 280.
|
||
- `aHiddenColumnIsNeitherCountedNorScaled`: widths explorer 400, agent 900, explorer hidden, window 1000: explorer stays 400; agent <= 1000 - 1 - 280 and >= 1000 - 2 - 280.
|
||
- `withTheEditorHiddenTheAgentIsTheFlexColumn`: explorer 900, agent 900, editor hidden, window 1000: agent stays 900; explorer <= 1000 - 1 - 280.
|
||
- `withoutAFlexColumnTheFixedOnesOnlyHaveToFitTheWindow`: explorer 400, agent 480 with editor and agent hidden: window 1000 leaves widths unchanged; window 300 gives explorer <= 300 and agent still 480.
|
||
- `splittersSitOnlyBetweenVisibleColumns`: all visible -> 2 splitters; editor hidden -> 1; all hidden -> 0.
|
||
- `theAgentLimitCountsOnlyVisibleColumns`: widths explorer 300, agent 480, window 1600: max agent width with all visible = 1600 - 2 - 300 - 280; with explorer hidden = 1600 - 1 - 280.
|
||
|
||
#### Session / SessionStateTests
|
||
|
||
- `anOlderSessionWithOpenTabsAndAnOriginalModeStillDecodes`: JSON `{"active":"b.php","openTabs":["a.php","b.php"],"tabMode":{"a.php":"original","b.php":"preview","c.php":"updated"},"tabSide":{"b.php":"staged"}}` decodes with active `b.php`, modes {`b.php`: preview, `c.php`: actual} (the `original` mode is dropped; `openTabs` ignored), sides {`b.php`: staged}.
|
||
- `aSessionRoundTripsUnderItsStoredKeys`: a session (active `a.php`, modes {a.php: preview}, sides {a.php: unstaged}) encodes to a JSON object with exactly the keys `active`, `tabMode`, `tabSide`, and decodes back equal.
|
||
|
||
#### Symbols / PHPSymbolsTests
|
||
|
||
- `declarationKinds` (parameterised; line -> kind, name): `class Agent` -> class, `Agent`; `interface Searchable {` -> interface, `Searchable`; `trait HasVault` -> trait, `HasVault`; `enum Status: string` -> enum, `Status`.
|
||
- `parents`: `final class VaultSearch extends Base implements Searchable, Arrayable, Jsonable {` gives parents [`Base`] and interfaces [`Searchable`, `Arrayable`, `Jsonable`].
|
||
- `qualifiedParents`: `class A extends \App\Base implements \App\Contracts\Runs` gives parents [`Base`], interfaces [`Runs`].
|
||
- `interfaceAndEnum`: `interface A extends B, C` gives parents [`B`, `C`]; `enum Status: string implements HasLabel` gives interfaces [`HasLabel`].
|
||
- `noClause`: `class Plain {` gives (class, `Plain`, parents [], interfaces []).
|
||
- `modifiers` (parameterised; each gives name `A`): `final class A extends B`; `abstract class A`; `final readonly class A`; ` class A`; `\tabstract final class A`.
|
||
- `notDeclarations` (parameterised; each gives nil): `$x = Agent::class;`; `// class Agent lives here`; `use App\Models\Agent;`; `return $a instanceof Agent;`; `classy Thing`.
|
||
- `wrappedImplements`: `class A extends B implements` gives interfaces [] and parents [`B`].
|
||
- `namespaces`: `namespace App\Console\Commands;` -> `App\Console\Commands`; `namespace App;` -> `App`; ` namespace \App\X ;` -> `App\X`; `use App\Models\Agent;` -> nil; `class A {` -> nil; `namespace App {` -> nil.
|
||
- `traitUse`: ` use HasFactory;` -> [`HasFactory`]; ` use HasFactory, Notifiable, SoftDeletes;` -> all three; `\tuse App\Support\HasVault;` -> [`HasVault`]; ` use A, B { A::run insteadof B; }` -> [`A`, `B`].
|
||
- `notTraitUse` (parameterised; each gives []): `use App\Models\Agent;` (not indented); ` use function App\tap;`; ` use const App\X;`; ` $f = function () use ($x) {};`.
|
||
- `importLines`: import lines are `use App\Models\Agent;`, `use App\Support\Str as S;`, `use function App\Support\tap;`. Not import lines: ` use HasFactory;`, `\tuse HasFactory;`, `$f = function () use ($agent) {};`, `// use Agent for this`.
|
||
- `wordAt` (parameterised; line, UTF-16 offset -> word): `return new Agent($x);` at 12 -> `Agent`; at 11 -> `Agent`; at 16 -> `Agent`; at 17 -> empty; ` ` at 1 -> empty; `$x = 42;` at 6 -> empty (digits are not a class word); `Agent` at 0 -> `Agent`; `Agent` at 5 -> `Agent`; `Agent` at 9 -> empty; `Agent` at -1 -> empty.
|
||
- `sortDefinitions`: definitions at `vendor/z.php`, `b.php`, `a.php` sort to `a.php`, `b.php`, `vendor/z.php` (project before vendor, then by path); 40 definitions are capped to 25 (max definitions).
|
||
|
||
---
|
||
|
||
### 8.3 HelderServicesTests
|
||
|
||
#### Files / FSEventsWatcherTests (real FSEvents, run one at a time)
|
||
|
||
Setup for each: the watcher uses debounces project 0.3 s, git 0.2 s, config 0.1 s. After `start(root)` the test waits 0.6 s and clears the event log, so setup writes do not leak in. "Settle" = wait 1 s. Event kinds: `project`, `git`, `config`, `cleanCopy`.
|
||
|
||
- `aBurstOfProjectChangesFiresOneDebouncedEvent`: writing `src/file0.txt` ... `src/file4.txt` eventually gives at least one project event; after settling there is exactly 1 project event and 0 git events.
|
||
- `theCleanCopyFileFiresItsOwnEventNextToTheProjectEvent`: writing `notes/.clean-copy` (a nested file of that name) gives 0 cleanCopy events after settling. Writing the clean-copy file at the root (`CleanCopy.fileName`, i.e. `.clean-copy`) with `copy me` eventually gives a cleanCopy event and a project event.
|
||
- `changesInsideIgnoredFoldersAreDropped`: with `node_modules/pkg` and `vendor` existing, writing `node_modules/pkg/index.js`, `vendor/autoload.php` and `.helder/recent.json` gives 0 project events.
|
||
- `theConfigFileFiresAConfigEventOnly`: with `.helder` existing, writing `.helder/config.json` (`{"editor":{"tabSize":2}}`) eventually gives exactly 1 config event, and after settling 0 project events.
|
||
- `aCommitFiresAGitEvent`: in a temp repo with one commit, an empty commit `second` eventually gives a git event.
|
||
- `aCommitInAWorktreeFiresAGitEvent`: a worktree (branch `side`) added outside the repo folder; watching the worktree, an empty commit in the worktree eventually gives a git event (the watcher follows the worktree's git directory, which lives under the main repo's `.git/worktrees/`).
|
||
- `stopSilencesTheWatcher`: after `stop()`, writing `after.txt` gives 0 project events.
|
||
- `laravelCachesAndConfiguredExcludesAreDropped`: with `.helder/config.json` = `{"files":{"exclude":["*.log"]}}`, writing `storage/framework/views/abc.php`, `storage/logs/laravel.log` and `.phpunit.result.cache` gives 0 project events; then writing `app/User.php` eventually gives exactly 1.
|
||
- `gitIgnoredChangesAreDroppedWhenTheProjectFollowsGitignore`: repo committing `.gitignore` = `tmp/\n` and config `{"files":{"followGitignore":true}}`: writing `tmp/a.txt`, `tmp/b.txt` gives 0 project events; then writing `tmp/c.txt` and `src/kept.txt` eventually gives exactly 1.
|
||
- `gitIgnoredChangesStillFireWhenTheProjectShowsIgnoredFiles`: repo with `.gitignore` = `tmp/\n` and default config: writing `tmp/a.txt` eventually gives exactly 1 project event.
|
||
- `startingAgainMovesTheWatchToTheNewRoot`: starting the same watcher on a second folder: writing `old.txt` in the first gives 0 project events; writing `new.txt` in the second eventually gives exactly 1.
|
||
|
||
#### Files / FSEventsWatcherTests file, suite EventRouterTests (root `/p`, git dir `/p/.git`, no flags)
|
||
|
||
- `projectFilesAreProjectEvents`: `/p/src/a.ts` and `/p/.env` are project events.
|
||
- `ignoredFoldersAtAnyDepthAreDropped`: `/p/node_modules/x/y.js`, `/p/packages/web/dist/app.js`, `/p/.helder/recent.json`, `/p` itself and `/elsewhere/a.ts` give no event.
|
||
- `frameworkCachesAndExcludedGlobsAreDropped`: `/p/storage/framework/cache/data/x` and `/p/bootstrap/cache/services.php` give none; `/p/storage/logs/laravel.log` is project; with exclude `storage/logs` it gives none.
|
||
- `theConfigFileIsAConfigEvent`: `/p/.helder/config.json` is config; `/p/.helder/config.default.json` gives none.
|
||
- `onlyTheGitStateEntriesAreGitEvents`: git events: `/p/.git/HEAD`, `/p/.git/index`, `/p/.git/refs/heads/feature/x`, `/p/.git/refs/remotes/origin/main`, `/p/.git/logs/HEAD`, `/p/.git/MERGE_HEAD`. No event: `/p/.git/objects/ab/cdef`, `/p/.git/index.lock`, `/p/.git/refs/tags/v1`.
|
||
- `aWorktreeGitDirectoryOutsideTheRootIsWatchedToo`: with git dir `/repo/.git/worktrees/wt`, `/repo/.git/worktrees/wt/HEAD` is git; `/p/.git` (a worktree's `.git` file) gives none.
|
||
- `aDroppedEventBatchRescansTheProject`: path `/p/node_modules` with the must-scan-subdirectories flag is a project event (a dropped batch forces a rescan).
|
||
- `realPathResolvesTheTempSymlinkEvenForAMissingFile`: `/var/nonexistent-helder-file` resolves to `/private/var/nonexistent-helder-file`; `/tmp` resolves to `/private/tmp`.
|
||
|
||
#### Files / FileServiceSafetyTests (walk-only file service, real temp folders)
|
||
|
||
- `aSaveKeepsTheFilePermissions`: `run.sh` with mode 0750 saved with `echo new\n` keeps mode 0750 and has the new text.
|
||
- `aSaveThroughASymlinkWritesTheTargetAndKeepsTheLink`: `config.php` -> symlink to `real/config.php`; saving `new\n` to `config.php` writes the target and the link still points to `real/config.php`.
|
||
- `aSaveReplacesTheFileInOneStepAndLeavesNoTempFileBehind`: saving `a.txt` changes its file number (inode: atomic replace), and the folder then contains only `a.txt`.
|
||
- `aSaveOfANewFileCreatesIt`: saving `fresh.txt` with `x\n` creates it.
|
||
- `deleteThroughASymlinkedFolderIsRefused`: in a project where `link` is a symlink to an outside folder holding `outside.txt`, deleting `link/outside.txt` throws "outside project" and the file stays.
|
||
- `renameThroughASymlinkedFolderIsRefused`: renaming `link/outside.txt` to `moved.txt` throws "outside project"; `outside.txt` stays, `moved.txt` does not appear.
|
||
- `creatingThroughASymlinkedFolderIsRefused`: create file `link/new.txt`, create directory `link/sub`, and write (new file) `link/new.txt` each throw "outside project"; nothing appears outside.
|
||
- `editingAnExistingFileThroughASymlinkIsAllowed`: writing `edited\n` to the existing `link/outside.txt` succeeds and changes the outside file.
|
||
- `deletingTheSymlinkItselfRemovesOnlyTheLink`: deleting `link` removes the link; `outside.txt` stays.
|
||
- `aCaseOnlyRenameOnACaseSensitiveVolumeNeverClobbersAnotherFile`: on a case-sensitive volume with `readme.md` (`lower\n`) and `README.md` (`upper\n`), renaming `readme.md` to `README.md` throws "already exists `README.md`"; both files keep their text.
|
||
- `aCaseOnlyRenameOnACaseSensitiveVolumeStillWorksWhenTheNameIsFree`: on a case-sensitive volume, renaming `notes.md` to `Notes.md` returns `Notes.md` and the folder holds only `Notes.md`.
|
||
|
||
#### Files / FileServiceTests, suite FileServiceTreeTests
|
||
|
||
Fixture: `src/a.ts` (`export const a = 1\n`), `README.md`, `node_modules/pkg/index.js`, `.git/HEAD`, `logo.bin` (bytes `00 01 02 00 99`). "Walk" = file service with a search service that has no ripgrep; "ripgrep" = with a real ripgrep search service (enabled only when ripgrep is present).
|
||
|
||
- `theWalkListsFoldersBeforeFilesAndSkipsIgnoredFolders`: root name = folder name, root path empty; root children `src`, `logo.bin`, `README.md`; `src` children exactly [file `a.ts` at `src/a.ts`].
|
||
- `theWalkSortsNamesCaseInsensitively`: files `b.txt`, `A.txt`, `c.txt` and folders `Zeta`, `alpha` list as `alpha`, `Zeta`, `A.txt`, `b.txt`, `c.txt`.
|
||
- `theWalkShowsEmptyFoldersAndDotfiles`: with `empty/` and `.env` added: `empty`, `src`, `.env`, `logo.bin`, `README.md`; the first child is folder `empty` with an empty child list.
|
||
- `theWalkStopsAtTheDepthLimit`: a chain of folders `d0/d1/.../d14` (max walk depth 12, + 2) with `leaf.txt` at the bottom: following first children from the root reaches exactly depth 13 (max walk depth + 1).
|
||
- `theRipgrepTreeAddsTheEmptyFoldersRipgrepCannotList` (ripgrep): with `empty/` and `src/nested/deep/`: root `empty`, `src`, `logo.bin`, `README.md`; `src` children `nested`, `a.ts`; `src/nested` child `deep`.
|
||
- `theRipgrepTreeShowsGitignoredFilesByDefault` (ripgrep): repo with `.gitignore` = `secret.txt\n` and `secret.txt`: root children `.gitignore`, `secret.txt`.
|
||
- `childrenOfTheRootAndOfASubfolder`: children of root `src`, `logo.bin`, `README.md`; children of `src` exactly [file `a.ts`].
|
||
- `childrenAreReadFreshOnEveryCall`: after listing `src`, adding `src/b.ts`, removing `src/a.ts`, adding folder `src/fresh`, the next listing is exactly [folder `fresh` (empty children), file `b.ts`].
|
||
- `childrenOutsideTheProjectAreEmpty`: children of `../` are empty.
|
||
- `ripgrepChildrenIncludeAFreshEmptyFolder` (ripgrep): with new folder `src/fresh`, children of `src` are [folder `fresh` (empty), file `a.ts`]; root children do not include `node_modules`.
|
||
- `emptyDirectoriesAreFoldersWithoutAnyFileBelow`: with `empty/`, `src/nested/deep/`, `node_modules/also-empty/`: empty directories are {`empty`, `src/nested`, `src/nested/deep`}; under `src` they are {`src/nested`, `src/nested/deep`}.
|
||
- `aFolderHoldingOnlyAnIgnoredFolderCountsAsEmpty`: with only `app/node_modules/x.js`, empty directories are [`app`].
|
||
|
||
#### Files / FileServiceTests, suite FileServiceEntryTests (walk-only)
|
||
|
||
- `writeThenReadRoundTrips`: writing `hello world\n` to `note.txt` then reading gives the same text.
|
||
- `aBinaryFileReadsAsEmpty`: `read` of `logo.bin` (bytes `89 00 01`) gives the empty string.
|
||
- `readTextTellsAnEmptyFileFromABinaryOne`: `readText` of an empty file is text ``; of `logo.bin` is binary; of `note.txt` is text `hello\n`.
|
||
- `aNulByteAfterTheFirst8000BytesStillReadsAsText`: 8000 `a` bytes then a NUL read as text (8000 `a` + NUL).
|
||
- `readingOutsideTheProjectThrows`: reading `../etc/passwd` throws "outside project".
|
||
- `createFileMakesAnEmptyFileAndItsFolders`: creating `src/new/fresh.ts` makes an empty file and its folders.
|
||
- `createFileRefusesToOverwrite`: creating existing `keep.txt` throws "already exists `keep.txt`"; its text `precious\n` is kept.
|
||
- `createFileRefusesTheRootAndPathsOutsideIt`: creating `../escape.txt` or the empty path throws "outside project"; no escape file appears.
|
||
- `createDirectoryMakesNestedFolders`: creating `a/b/c` makes a directory.
|
||
- `createDirectoryRefusesATakenName`: with folder `taken` and file `file`: creating directory `taken` throws "already exists `taken`"; `file` throws "already exists `file`"; `../out` throws "outside project".
|
||
- `renameMovesAFileWithinItsFolder`: renaming `src/old.ts` to `new.ts` returns `src/new.ts`; new exists with text `x\n`; old is gone.
|
||
- `renameMovesAFolderWithEverythingInside`: renaming folder `old` to `new` returns `new`; `new/a.ts` holds `a\n`.
|
||
- `renameCanChangeOnlyTheCase`: renaming `notes.md` to `Notes.md` returns `Notes.md`; the folder holds only `Notes.md`.
|
||
- `renameToTheSameNameIsANoOp`: renaming `a.txt` to ` a.txt/ ` returns `a.txt` (name trimmed and trailing slash removed).
|
||
- `renameRefusesATakenName`: renaming `a.txt` to existing `b.txt` throws "already exists `b.txt`"; both files keep their text.
|
||
- `renameRefusesAPathShapedOrEmptyName` (parameterised): renaming `a.txt` to each of `sub/a.txt`, `../a.txt`, ` `, `..`, `.` throws "invalid name <that name>"; `a.txt` is untouched.
|
||
- `renameRefusesTheRootAndEscapes`: renaming the root (empty path) or `../x` throws "outside project".
|
||
- `renameOfAMissingEntryThrows`: renaming `missing.txt` throws some error.
|
||
- `deleteRemovesAFolderButNeverTheRoot`: deleting `folder` removes it; deleting the empty path throws "outside project" and the root still exists.
|
||
- `readImageReturnsBytesOnlyForImages`: `pic.png` returns its bytes `89 50 4E 47`; `notes.txt` returns nil; `missing.png` returns nil.
|
||
|
||
#### Git / GitServiceConsoleTests (real git unless "scripted")
|
||
|
||
Helper `repoWithRemote`: a bare repo as remote plus a repo with `a.txt` (`a\n`) committed as `init`, remote `origin` pointing at the bare repo.
|
||
|
||
- `executeStreamsTheLinesAndReturnsTheExitCode`: in a repo with `a.txt` committed then changed to `b\n`, `execute(["status"])` succeeds; streamed stdout lines include `On branch main` and `\tmodified: a.txt`; result stdout contains `modified: a.txt`.
|
||
- `aFailingCommandReturnsItsCodeAndStreamsStderr`: `execute(["checkout", "no-such-branch"])` fails with an exit code > 0, and a streamed stderr line starts with `error:`.
|
||
- `aCommitWithoutAMessageAbortsInsteadOfOpeningAnEditor`: with a staged change, `execute(["commit"], literal pathspecs, timeout 10 s)` fails, its exit code is not -1 (not a timeout: git ran and aborted), and `git log --format=%s` is still only `commit\n`.
|
||
- `executeSwitchesOffPromptsEditorsAndPagers` (scripted): two `execute(["log"])` calls, the first with default (literal pathspecs on), the second with literal pathspecs off and no timeout. Both run executable `git` with arguments `["log"]` and environment `GIT_TERMINAL_PROMPT=0`, `GCM_INTERACTIVE=never`, `GIT_EDITOR=true`, `GIT_PAGER=cat`, `PAGER=cat`. The first has `GIT_LITERAL_PATHSPECS=1`; the second has no `GIT_LITERAL_PATHSPECS`.
|
||
- `aHangingCommandGivesUpAfterTheTimeout` (scripted; the runner sleeps 30 s): `execute(["fetch"], timeout 0.2)` returns exactly (exit code -1, stdout empty, stderr `timed out after 0.2s`); the stderr stream received exactly `timed out after 0.2s`; the call returns in under 5 s.
|
||
- `aTimeoutDoesNotWaitForAGrandchildHoldingStderr` (1-minute limit): `execute(["-c", "alias.hang=!sleep 30 >&2 & sleep 30", "hang"], timeout 0.5)` returns (−1, ``, `timed out after 0.5s`) in under 1.5 s (a background grandchild holding stderr open must not block the return).
|
||
- `aMissingGitIsALaunchFailureNotAThrow`: with a locator that finds nothing, `execute(["status"])` returns (−1, ``, `git not found`) and streams the stderr line `git not found`.
|
||
- `branchesListsLocalAndOriginBranches`: with branches `feature/a` (pushed), `main` (pushed), `local-only` (not pushed) and `origin/HEAD` set to main: local = `feature/a`, `local-only`, `main`; remote = `origin/feature/a`, `origin/main`.
|
||
- `branchesOutsideARepositoryAreEmpty`: in a plain temp folder, branches are empty.
|
||
- `authorReadsNameAndEmailFromConfig`: in a temp repo, author is `Helder Tests <tests@helder.invalid>`.
|
||
- `authorIsNilWithoutAName` (scripted: every call exits 1): author is nil.
|
||
- `authorIsTheNameAloneWithoutAnEmail` (scripted: `... user.name` returns `Ada\n`, everything else exits 1): author is `Ada`.
|
||
- `loadReadsBehindAndUpstream`: commit `second` pushed with upstream, then reset hard to HEAD~1 and commit `local`: snapshot ahead 1, behind 1, upstream `origin/main`.
|
||
- `aBranchWithoutUpstreamHasNone`: a repo with one commit and no remote: upstream nil, behind 0.
|
||
|
||
#### Git / GitServiceTests, suite GitServiceLoadTests (repo with `a.txt` = `1\n2\n3\n` committed as `init`)
|
||
|
||
A change row is (path, status, staged, original text, updated text, isTooBig = false, originalPath = nil).
|
||
|
||
- `aFolderOutsideGitLoadsAsNil`: loading a plain temp folder returns nil (not an error).
|
||
- `aModifiedFileCarriesHeadAndDiskText`: `a.txt` changed to `1\nX\n3\n`: branch `main`; rows for `a.txt` are exactly [(`a.txt`, modified, unstaged, `1\n2\n3\n`, `1\nX\n3\n`)].
|
||
- `anUntrackedFileIsAnUnstagedAddition`: new `new.txt` = `fresh\n`: [(new.txt, added, unstaged, ``, `fresh\n`)].
|
||
- `aStagedFileHasOneStagedRow`: `a.txt` changed to `1\n2\n3\n4\n` and staged: [(a.txt, modified, staged, `1\n2\n3\n`, `1\n2\n3\n4\n`)].
|
||
- `aFileStagedThenEditedHasTwoRowsEachWithItsOwnPair`: stage `1\nSTAGED\n3\n`, then edit to `1\nSTAGED\n3\n4\n`: [(a.txt, modified, staged, `1\n2\n3\n`, `1\nSTAGED\n3\n`), (a.txt, modified, unstaged, `1\nSTAGED\n3\n`, `1\nSTAGED\n3\n4\n`)] (staged row: HEAD vs index; unstaged row: index vs disk).
|
||
- `aStagedNewFileEditedAgainIsAnAdditionPlusAModification`: `fresh.txt` = `one\n` staged, then edited to `one\ntwo\n`: [(fresh.txt, added, staged, ``, `one\n`), (fresh.txt, modified, unstaged, `one\n`, `one\ntwo\n`)].
|
||
- `aDeletedFileHasNoDiskText`: `a.txt` removed from disk: [(a.txt, deleted, unstaged, `1\n2\n3\n`, ``)].
|
||
- `aStagedRenameIsOneRowUnderTheNewPath`: `git mv a.txt b.txt`: changes paths exactly [`b.txt`], status renamed, staged.
|
||
- `aBinaryFileReadsAsEmptyText`: untracked `logo.bin` bytes `00 01 02`: its row's updated text is empty.
|
||
- `aheadCountsCommitsTheRemoteLacks`: pushed with upstream, then a new commit `second`: ahead 1, can push.
|
||
- `aWorktreeWithAGitFileLoads`: a worktree on new branch `side` with `a.txt` changed: snapshot branch `side`, change paths [`a.txt`].
|
||
- `aFailingStatusIsRetriedThenThrowsWithGitsStderr` (scripted: `rev-parse` answers `true\n`; every other call exits 128 with stderr `fatal: Unable to create '.git/index.lock': File exists.\n`; 3 status attempts, retry delay 0.01 s): load throws `commandFailed(arguments: <status arguments>, exitCode: 128, stderr: "fatal: Unable to create '.git/index.lock': File exists.")` (stderr trimmed); the status command ran exactly 3 times; the last call had env `GIT_OPTIONAL_LOCKS=0`.
|
||
- `overlappingLoadsShareOneReadPlusOneTrailingRead` (scripted; `rev-parse` waits on a gate, status fails with `stop here`; 1 attempt): start one load; once the runner saw a call, start 5 more loads; the service reports `coalescedLoads == 5`; open the gate; after all finish, `rev-parse` ran exactly 2 times (the first read, plus one trailing read shared by the 5 waiting loads).
|
||
- `anUntrackedFileOverTheSizeCapLoadsWithoutText`: max diff bytes 1000; untracked `dump.sql` of 200 x `insert;\n` (1600 bytes): [(dump.sql, added, unstaged, ``, ``, isTooBig true)].
|
||
- `aCommittedFileOverTheSizeCapLoadsWithoutTextOnEitherSide`: committed `big.txt` 300 x `line\n` (1500 bytes) changed to 301 x: [(big.txt, modified, unstaged, ``, ``, isTooBig true)].
|
||
- `aFileThatOutgrewTheCapDropsTheSmallSideToo`: committed `grew.txt` = `small\n`, changed to 300 x `line\n`: the row is too big and both texts are empty.
|
||
- `aFileUnderTheSizeCapStillCarriesItsText`: untracked `small.txt` = `ok\n` with cap 1000: updated `ok\n`, not too big.
|
||
- `aStagedRenameCarriesItsSourcePath`: after `git mv a.txt b.txt`, the change's original path is `a.txt`.
|
||
|
||
#### Git / GitServiceTests, suite GitServiceReadTests
|
||
|
||
- `isRepositoryAcceptsAWorktreeGitFile`: a worktree (where `.git` is a file) is reported as a repository.
|
||
|
||
#### Git / GitServiceTests, suite GitServiceLiteralPathTests
|
||
|
||
(The suite defines a fixture repo with names git would read as globs or options: `pages/[id].vue`, `pages/i.vue`, `pages/d.vue`, `a*.txt`, `ab.txt`, `a?.txt`, `ac.txt`, `-dash.txt`, `with space.txt`; the one remaining test does not use it.)
|
||
|
||
- `everyGitCallRunsWithLiteralPathspecs` (scripted: `rev-parse` answers `true\n`, everything else succeeds empty): after `load()`, at least one call was made and every call had env `GIT_LITERAL_PATHSPECS=1`.
|
||
|
||
#### Git / TempGitRepoTests
|
||
|
||
- `createsCommitsAndCleansUp`: a temp repo commits `README.md` = `hello\n` as `first`; after changing it to `hello\nworld\n`, `git status --porcelain` is ` M README.md\n` and `git log --format=%s` is `first\n`; releasing the repo deletes its folder.
|
||
|
||
#### Logging / FileLoggerTests (fixed date 1784109600 s since 1970 = 2026-07-15T10:00:00Z; max file size 2 MiB = 2,097,152 bytes; file name `helder.log`)
|
||
|
||
- `aLineHoldsTimestampPaddedLevelPidScopeAndMessage`: level info, scope `git`, message `loaded`, pid 42 formats to exactly `2026-07-15T10:00:00.000Z INFO 42 git loaded\n` (ISO-8601 UTC with milliseconds, space, level padded, pid right-aligned, space, scope padded to a fixed column, message, newline). The exact string is normative.
|
||
- `continuationLinesAreIndentedSoTheyNeverLookLikeANewEntry`: level warn, scope `console`, message `line one\nline two\r\nline three`, pid 1 formats to exactly `2026-07-15T10:00:00.000Z WARN 1 console line one\n line two\n line three\n` (each continuation line indented by 4 spaces; CRLF treated as a line break).
|
||
- `writingCreatesTheFolderAndAppendsLines`: a logger on the missing folder `a/b` writing info `boot`/`hello` and warn `boot`/`careful` creates `a/b/helder.log` with 2 lines; line 1 contains `INFO` and ends with `boot hello`; line 2 contains `WARN` and ends with `careful`; the logger's file URL is `a/b/helder.log`.
|
||
- `linesBelowTheFloorAreDropped`: minimum level warn: debug `debug line` and info `info line` are not written; an error line is (contains `ERROR`).
|
||
- `anUnwritableFolderIsSilentlyIgnored`: a logger whose folder path runs through a regular file (`wall/sub`) writes an error without crashing or throwing, and no log file appears.
|
||
- `theFileRotatesPastTheCapAndKeepsWriting`: 700 info lines of 4000 `x` each: `helder.1.log` exists; a later line `still logging` lands in the live `helder.log`, whose size is at most the cap.
|
||
- `rotationKeepsAtMostThreeOldFiles`: 105 lines of 100,000 `y` each: `helder.3.log` exists, `helder.4.log` does not.
|
||
- `aLoggerPicksUpTheSizeOfAnExistingFile`: an existing `helder.log` of cap - 10 bytes; a new logger writing `tips it over` rotates first (`helder.1.log` exists) and the live file contains `tips it over`.
|
||
- `concurrentWritersNeverInterleaveWithinALine`: 8 concurrent writers each write 50 debug lines `message j` with scope `t<i>`: the file has exactly 400 lines, each containing ` DEBUG ` and `message `.
|
||
- `logForwardsToTheInstalledSink`: with the logger installed as the global log sink, `Log.info(scope, "forwarded")` reaches the file; the sink is then removed.
|
||
|
||
#### Process / ChildReaperTests (children spawned with posix_spawn, so only the reaper waits on them)
|
||
|
||
- `aTerminatedChildIsReapedInsteadOfLeftAsAZombie` (1-minute limit): spawn `/bin/sleep 30`, send SIGTERM, reap with a 5 s grace: the pid no longer exists (not even as a zombie).
|
||
- `aChildThatIgnoresSigtermIsKilledAfterTheGracePeriod` (1-minute limit): spawn `/bin/sh -c "trap '' TERM; while :; do sleep 1; done"`, send SIGTERM, reap with 0.3 s grace: the pid is gone (killed with SIGKILL after the grace) in under 10 s.
|
||
- `aPidThatIsNotOurChildIsLeftAlone`: reaping pid 1 with 0.1 s grace leaves pid 1 alive.
|
||
|
||
#### Process / ProcessRunnerTests
|
||
|
||
- `capturesStdoutAndExitCode`: `echo hello world` gives exactly (0, `hello world\n`, ``) and succeeded.
|
||
- `nonZeroExitIsAResultNotAnError`: `sh -c "echo oops >&2; exit 3"` returns exit 3, stderr `oops\n`, not succeeded (no throw).
|
||
- `runsInTheGivenDirectory`: `pwd` in `/usr/lib` prints `/usr/lib\n`.
|
||
- `passesTheEnvironment`: `sh -c 'printf %s "$HELDER_TEST"'` with env `HELDER_TEST=yes`, `PATH=/usr/bin:/bin` prints `yes`.
|
||
- `stdinIsClosed`: `cat` with no arguments returns at once with (0, ``, ``).
|
||
- `largeOutputOnBothPipesDoesNotDeadlock`: a script printing 20,000 lines to stdout and 20,000 to stderr interleaved returns all 20,000 of each.
|
||
- `unknownExecutableThrows`: running `helder-no-such-tool` throws "executable not found `helder-no-such-tool`".
|
||
- `cancellationTerminatesTheChild`: cancelling a `sleep 10` run after 200 ms throws a cancellation error, within 5 s.
|
||
- `locatorFindsToolsOnThePath`: the standard locator finds `sh` at a path ending in `/sh`; a locator with no folders finds no `sh`, but resolves the absolute path `/bin/sh` to itself.
|
||
|
||
#### Process / ProcessRunnerTests file, suite ProcessRunnerStreamTests
|
||
|
||
- `streamsEachLineWithItsStreamAndKeepsTheFullOutput`: `sh -c "echo one; echo two >&2; printf 'three'"` streams stdout lines `one`, `three` (a final unterminated line is still emitted) and stderr line `two`; the result is exactly (0, `one\nthree`, `two\n`).
|
||
- `aCarriageReturnEndsALineAndEmptyLinesAreDropped`: stderr `Counting 10%\rCounting 100%\r\n\ndone\n` streams `Counting 10%`, `Counting 100%`, `done`; the result stderr keeps the raw text.
|
||
- `linesArriveBeforeTheProcessEnds`: `sh -c "echo first; sleep 1; echo second"`: the two lines arrive more than 0.5 s apart (streamed live, not at the end).
|
||
- `largeStreamedOutputOnBothPipesDoesNotDeadlock`: 5,000 lines on each pipe: 5,000 stdout lines streamed, 5,000 stderr lines streamed, the last stdout line is `line4999`, the result stdout has 5,000 lines.
|
||
- `stdinIsClosedWhileStreaming`: streaming `cat` returns (0, ``, ``).
|
||
- `cancellationTerminatesAStreamingChild`: cancelling a streaming `sleep 10` after 200 ms throws a cancellation error within 5 s.
|
||
- `cancellationDoesNotWaitForAGrandchildHoldingAPipe` (1-minute limit): `sh -c "sleep 30 >&2 & echo $! > /tmp/<marker>; sleep 30"`, cancelled after 300 ms, throws a cancellation error within 2 s; 200 ms later the grandchild (pid read from the marker file) no longer exists (the whole process group is killed).
|
||
- `theDefaultStreamEmitsStdoutThenStderrAfterTheRun`: a runner that only implements `run` (returning exit 2, stdout `a\r\nb\n`, stderr `c\n\nd`) streams, through the protocol's default, lines `a`, `b`, `c`, `d` with error flags false, false, true, true, and returns exit code 2.
|
||
|
||
#### Project / ConfigServiceTests
|
||
|
||
- `aFreshProjectGetsTheDefaultsFileAndTheDefaults`: resolving in an empty folder returns the defaults and writes `.helder/config.default.json`, which decodes to the defaults.
|
||
- `aSparseConfigMergesOverTheDefaults`: `.helder/config.json` = `{"ai":{"command":"claude --model opus"},"editor":{"tabSize":2}}` gives `ai.command = "claude --model opus"`, autoLaunch still true, tabSize 2, autoSave still false, confirmDiscard still true.
|
||
- `theDefaultsFileIsRewrittenWithTheBuiltInValues`: a stale `.helder/config.default.json` with `{"ai":{"command":"stale"}}` is rewritten on resolve so it decodes with `ai.command = "claude"`.
|
||
- `currentReturnsTheLastResolvedConfig`: before any resolve, `current()` is the defaults; after writing `{"editor":{"tabSize":8}}` and resolving, `current().editor.tabSize` is 8.
|
||
- `anUnwritableProjectStillYieldsTheDefaults`: where `.helder` is a regular file, resolve still returns the defaults.
|
||
|
||
#### Project / ProjectServicesTests
|
||
|
||
- `configServiceWritesDefaultsAndReadsOverrides`: with `.helder/config.json` = `{"editor":{"tabSize":2}}`, resolve gives tabSize 2, writes `.helder/config.default.json`, and writes `.helder/.gitignore` with exactly `# Helder — local, machine-specific state (do not commit).\n*\n`.
|
||
- `recentProjectsAreNewestFirstAndDeduplicated`: a recent-projects store (JSON file `recent.json`) after adding folder a, folder b, folder a lists exactly [a, b] (standardized paths; newest first; no duplicates).
|
||
|
||
#### Search / ProjectScannerTests
|
||
|
||
Default filter = base ignores (`node_modules`, `.git`, `out`, `dist`, `build`, `.cache`, `vendor`, `coverage`, `.helder`, `.next`, `.nuxt`, `.turbo`, `.idea`, `.vscode`, `.DS_Store`) with default file settings. "Walk" = the built-in scanner without ripgrep. The PHP declaration pattern is `^\s*(namespace\s+[A-Za-z_\\][\w\\]*\s*;|(final\s+|abstract\s+|readonly\s+)*(class|interface|trait|enum)\s+\w+)`.
|
||
|
||
- `contentSearchPassesTheOldAppsRipgrepFlags`: a smart-case literal query `needle`, max 50 per file, max 2000 columns, target `/p`: arguments start with `--json`, `--fixed-strings`, `--smart-case`, `--hidden`, `--max-count`, `50`, `--max-columns`, `2000`, `--glob`; end with `-e`, `needle`, `--`, `/p`; contain `!node_modules` and `--no-ignore`.
|
||
- `aRegexSearchOverPHPFilesIsCaseSensitive`: a regex query `^class` limited to extension `php`, with the symbol-declaration ignores: arguments start `--json`, `--hidden`, `--glob`, `*.php`; contain no `--smart-case` and no `!vendor`; end `-e`, `^class`, `--`, `/p`.
|
||
- `aWordSearchUsesWordRegexp`: a word query `Agent` over php contains `--word-regexp` and ends `-e`, `Agent`, `--`, `/p`.
|
||
- `fileListingHonoursExcludesAndGitignore`: base `vendor`, excludes `["*.log", ""]`, followGitignore true, target `/p/src`: arguments exactly `--files`, `--hidden`, `--glob`, `!vendor`, `--glob`, `!*.log`, `--`, `/p/src` (no `--no-ignore`).
|
||
- `aMissingRipgrepBinaryYieldsNoResultsInsteadOfThrowing`: a ripgrep scanner whose binary is `/nonexistent/rg` lists no files (no throw).
|
||
- `rgBinaryInTheEnvironmentWinsOverTheLocator`: with a locator that finds nothing: env `RG_BINARY=/bin/sh` gives `/bin/sh`; `RG_BINARY=/nonexistent` gives none; no env gives none.
|
||
- `theWalkListsFilesAndDotfilesButNotTheBaseIgnores`: with `src/a.ts`, `.env`, `.DS_Store`, `node_modules/p/i.js`, `lib/vendor/v.php`: files are `.env`, `src/a.ts`; under `src` they are `src/a.ts`.
|
||
- `theWalkSkipsGitignoredFilesOnlyWhenAsked`: repo with `.gitignore` = `secret.txt\nlogs/\n`, `secret.txt`, `logs/today.txt`, `keep.txt`: by default `.gitignore`, `keep.txt`, `logs/today.txt`, `secret.txt`; with followGitignore `.gitignore`, `keep.txt`.
|
||
- `theWalkHonoursExcludeGlobs`: with `a.log`, `deep/b.log`, `keep.txt` and exclude `*.log`: only `keep.txt`.
|
||
- `aLowercaseQueryMatchesAnyCase`: `a.ts` = `const x = 1\nconst Balance = 2\n`, query `balance` gives exactly one match (absolute path of `a.ts`, line 2, text `const Balance = 2`, byte offset 6).
|
||
- `anUppercaseQueryIsCaseSensitive`: `a.ts` = `balance\nBalance\n`, query `Balance` matches only line 2.
|
||
- `theByteOffsetCountsUTF8Bytes`: `a.txt` = `héllo wörld\n`, query `wörld` gives byte offset 7.
|
||
- `theWalkStopsAtTheLimitPerFileAndAtTheFileLimit`: files `a.txt`, `b.txt`, `c.txt` each with 5 `hit` lines, query `hit`, max 2 per file, max 2 files: matches `a.txt:1`, `a.txt:2`, `b.txt:1`, `b.txt:2`.
|
||
- `theWalkSkipsBinaryAndOversizedFiles`: `bin.dat` = `needle` + NUL, `big.txt` = `needle\n` + 400 `x`, `ok.txt` = `needle\n`, max file bytes 100: only `ok.txt` matches.
|
||
- `aRegexQueryReadsOnlyTheRequestedExtension`: `A.php` = `<?php\nnamespace App;\nfinal class A extends B\n` and `notes.md` = `class NotPHP\n`; the declaration-pattern regex over php gives texts `namespace App;`, `final class A extends B`.
|
||
- `aWordQueryNeedsWordBoundaries`: `a.php` = `new Agent();\nnew AgentList();\n$x = Agent::class;\n`; word `Agent` matches lines 1, 3 at byte offsets 4, 5.
|
||
- `ripgrepAndTheWalkFindTheSameLines` (ripgrep): with `src/a.php` (`class Agent extends Base`, `use HasFactory;`), `src/b.php` (`$a = new Agent();`), `vendor/c.php` (`class Agent {}`): for the word query `Agent` over php, the declaration regex over php, and the smart-case literal `agent`, ripgrep and the walk return the same matches (sorted by path, line).
|
||
- `ripgrepAndTheWalkListTheSameFiles` (ripgrep): with `src/a.ts`, `.env`, `.DS_Store`, `node_modules/p/i.js`, empty `empty/`: both list the same files; ripgrep under `src` lists `src/a.ts`.
|
||
|
||
#### Search / RipgrepSearchServiceTests
|
||
|
||
Fixture: `a.ts` = `const x = 1\nconst balance = 2\n`, `b.ts` = `nothing relevant\n`.
|
||
|
||
- `availabilityFollowsTheLocatorAndRgBinary`: with no ripgrep, not available; with a locator that finds nothing but env `RG_BINARY=/bin/sh`, available.
|
||
- `ripgrepIsFoundWhereTheOldAppShipsIt` (ripgrep): the service with the test locator is available.
|
||
- `aQueryUnderTwoCharactersFindsNothing` (parameterised over ``, `a`, ` b `): both with and without ripgrep, content search returns nothing (the query is trimmed; under 2 characters gives no search).
|
||
- `ripgrepFindsContentWithLineAndOffset` (ripgrep): `balance` gives exactly [group `a.ts` with hit (line 2, `const balance = 2`, offset 6)].
|
||
- `theWalkFindsContentWithLineAndOffset`: the same result without ripgrep.
|
||
- `theWalkCapsHitsPerFile`: `many.txt` with 60 `needle` lines gives 50 hits.
|
||
- `ripgrepContentSearchSkipsExcludedFiles` (ripgrep): with `node_modules/p/index.js` and `build.log` holding `balance` and exclude `*.log`: only `a.ts`.
|
||
- `ripgrepListsFilesIncludingDotfiles` (ripgrep): with `.env`, `.DS_Store`, `node_modules/p/index.js`: files `.env`, `a.ts`, `b.ts`.
|
||
- `ripgrepListsOneSubtreeWithRootRelativePaths` (ripgrep): under `src` with `src/deep/c.ts`: `src/deep/c.ts`.
|
||
- `ripgrepShowsGitignoredFilesUnlessTheConfigFollowsGitignore` (ripgrep): repo with `.gitignore` = `secret.txt\n`, `secret.txt`, `keep.txt`: default lists `.gitignore`, `keep.txt`, `secret.txt`; with followGitignore `.gitignore`, `keep.txt`.
|
||
- `ripgrepHonoursExcludeGlobs` (ripgrep): with `logs/today.log` and exclude `*.log`: `a.ts`, `b.ts`.
|
||
- `theWalkListsFilesWithoutRipgrep`: with `.env`, `vendor/x.php`, `src/c.ts`: files `.env`, `a.ts`, `b.ts`, `src/c.ts`; under `src`: `src/c.ts`.
|
||
- `listingOutsideTheProjectIsEmpty`: listing under `..` (walk) and `../..` (ripgrep) gives nothing.
|
||
|
||
#### Symbols / SymbolServiceTests (each parameterised test runs with engine ripgrep, when present, and engine walk)
|
||
|
||
Project fixture:
|
||
- `app/Models/Agent.php`: `<?php`, blank, `namespace App\Models;`, blank, `use Illuminate\Database\Eloquent\Model;`, blank, `final class Agent extends Model implements HasLabel` (line 7), `{`, ` use HasFactory, Notifiable;`, blank, ` public function run(): void {}`, `}`.
|
||
- `app/Http/AgentController.php`: `<?php`, blank, `namespace App\Http;`, blank, `use App\Models\Agent;`, blank, `class AgentController`, `{`, ` public function show(): Agent` (line 9), ` {`, ` return new Agent();` (line 11), ` }`, `}`.
|
||
- `vendor/laravel/Model.php`: `<?php\nnamespace Illuminate\Database\Eloquent;\nabstract class Model {}\nclass Agent {}\n`.
|
||
- `vendor/laravel/Uses.php`: `<?php\n$x = new Agent();\n`.
|
||
|
||
- `aNonIdentifierLooksUpNothing`: looking up `not a name` gives the empty lookup for `not a name`; `$agent` gives the empty lookup for `$agent`.
|
||
- `namesIncludeProjectAndVendorDeclarations`: names are exactly {`Agent`, `AgentController`, `Model`}.
|
||
- `lookupListsTheProjectDeclarationFirstWithItsNamespaceAndTraits`: definitions of `Agent` are exactly: (Agent, `app/Models/Agent.php`, line 7, class, namespace `App\Models`, parents [`Model`], interfaces [`HasLabel`], traits [`HasFactory`, `Notifiable`]), then (Agent, `vendor/laravel/Model.php`, line 4, class, namespace `Illuminate\Database\Eloquent`, no parents/interfaces/traits).
|
||
- `referencesSkipImportsDeclarationsAndVendor`: references of `Agent` are exactly one group `app/Http/AgentController.php` with hits (line 9, ` public function show(): Agent`, offset 28) and (line 11, ` return new Agent();`, offset 19); reference count 2 (the `use` import, the declaration line and vendor are skipped).
|
||
- `invalidateMakesTheNextCallSeeANewClass`: names do not contain `Fresh`; after writing `app/Fresh.php` = `<?php\nenum Fresh: string {}\n` they still do not (cached); after `invalidate()` they do.
|
||
- `concurrentCallersShareOneIndex`: 8 concurrent `names()` calls all return the same set.
|
||
|
||
---
|
||
|
||
### 8.4 HelderUITests
|
||
|
||
A few UI tests build real AppKit views (a code-editor controller in an offscreen `NSWindow`, the diff canvas, pointer regions). These are view-geometry tests; a rebuild in another toolkit should keep the rule and adapt the mechanics (for example "a point in row N at x points from the text's left edge").
|
||
|
||
#### Components / PointerPolicyTests
|
||
|
||
Pointer state: layer (workspace column or overlay), overlay open, enabled, over text, selecting (drag in progress). Shapes: iBeam, arrow, pointingHand.
|
||
|
||
- `textUnderThePointerTakesTheIBeam`: workspace layer, no overlay, enabled, over text -> iBeam; overlay layer with overlay open, over text -> iBeam.
|
||
- `everythingThatIsNotTextKeepsTheArrow`: not over text -> arrow, in a column and in the overlay.
|
||
- `anOpenOverlayGivesTheColumnsBehindItTheArrow`: workspace layer over text while an overlay is open -> arrow.
|
||
- `aDisabledOrHiddenTextViewKeepsTheArrow`: disabled -> arrow, in a column and in the overlay.
|
||
- `aDragSelectionKeepsTheIBeamUntilMouseUpWhereverItGoes`: selecting while not over text -> iBeam; selecting with overlay open, disabled, not over text -> iBeam.
|
||
- `aClickableInAColumnTakesTheHand`: a clickable in a column (no overlay, enabled) -> pointingHand.
|
||
- `anOpenOverlayGivesTheClickablesBehindItTheArrow`: a column clickable with an overlay open -> arrow.
|
||
- `aClickableInsideTheOverlayKeepsTheHand`: an overlay clickable with the overlay open -> pointingHand.
|
||
- `aDisabledClickableKeepsTheArrow`: disabled clickable -> arrow, in a column and in the overlay.
|
||
- `aDragSelectionKeepsTheIBeamOverAClickable`: selecting over a clickable -> iBeam (also with overlay open and disabled).
|
||
- `textAndClickablesShareTheOverlayGate`: "behind overlay" is true for workspace + overlay open; false for workspace + no overlay; false for the overlay layer itself.
|
||
- `aRegionOutOfViewHasAnEmptyFiniteAreaAndNoCursorRect`: a pointer region (frame 210 x 24) whose visible rect (500, 500, 10, 10) misses its bounds has an empty visible area with finite origin, and it is not a usable cursor rect.
|
||
- `removingAStripFromANullRectStaysFinite`: removing a 10 x 10 strip from the null rect gives a rect with a finite origin; the null rect is not a usable cursor rect.
|
||
- `aRegionsAreaNeverExceedsItsBounds`: a region (frame 49 x 27) whose reported visible rect is (−629, −904.5, 1512, 940) (an unclipping host) has a visible area equal to its bounds.
|
||
|
||
#### Editor / CodeEditorShowDiffTests
|
||
|
||
Setup: a code editor (700 x 400 window) showing `a.php` with text `one\n\nthree\nfour`; line marks: line 2 (blank) and line 3 tinted as added; show-diff offered unless stated.
|
||
|
||
- `aBlankAddedLineOffersShowDiff`: a right-click point in line 2, 40 points from the text's left edge, offers show-diff at line 2.
|
||
- `theSpaceAfterTheLastGlyphCounts`: a point in line 3 at x = 500 (past the last glyph) offers line 3.
|
||
- `anUnchangedLineOffersNothing`: line 1 at x = 10 and line 4 at x = 500 offer nothing.
|
||
- `aFileWithoutShowDiffOffersNothingOnAMarkedLine`: with show-diff not offered, line 3 at x = 10 offers nothing.
|
||
|
||
#### Editor / DiffCanvasSelectionTests
|
||
|
||
Setup: a diff canvas (800 x 400) with split rows: [`old one` | `new one`], [nothing | `added` (added)], [`old two` | `new three`]. Mouse points sit in the middle of a row (top padding + (row + 0.5) x row height), x = 200 for the left side, x = 600 for the right.
|
||
|
||
- `draggingSelectsWholeLinesOnOneSide`: mouse down on row 0 right, drag to row 2 on the left: the selection stays on the right side and the selected text is `new one\nadded\nnew three`.
|
||
- `theOtherSidesBlankRowsAreSkipped`: mouse down on row 2 left, drag to row 0 left: `old one\nold two` (the empty left cell of row 1 is skipped).
|
||
- `aClickWithoutADragSelectsNothing`: mouse down on row 1 right with no drag: no selection.
|
||
- `selectAllTakesTheSelectedSideElseTheOriginal`: select-all with no prior selection gives the left (original) side `old one\nold two`; after a click-drag on the right, select-all gives `new one\nadded\nnew three`.
|
||
|
||
#### Editor / EditorFocusAndBinaryTests, suite EditorBinaryTests
|
||
|
||
- `aFileWithBinaryContentCannotBeDisplayedWhateverItsName`: `data.txt` marked binary in the fake files; opening it and settling puts it in the binary paths and its presentation kind is binary.
|
||
- `anEmptyTextFileIsStillText`: opening an empty `empty.txt`: no binary paths; presentation kind text.
|
||
|
||
#### Editor / EditorFocusAndBinaryTests, suite EditorFocusTests
|
||
|
||
- `closingTheDiffHandsTheKeyboardBackToTheText`: `a.php` (`new`) changed from `old`; open it, set mode diff; collapsing the diff increases the text-focus request counter and dismisses the diff overlay once.
|
||
- `movingFocusToTheEditorColumnAsksForTheTextView`: in a started workspace with `a.php`, performing focus(editor) increases the editor's text-focus request by exactly 1.
|
||
|
||
#### Editor / EditorLayoutTests, suite EditorPresentationTests
|
||
|
||
Presentation inputs: path, requested mode (nil, code, actual, preview, diff), the file's diff (nil = unchanged). Outputs: mode, pane mode (what shows behind an overlay), bar buttons, editable, offers show-diff, placeholder, kind (text, image, binary), status.
|
||
|
||
- `anUnchangedFileShowsItsEditableCodeViewAndNoButtons`: `a.php`, no request, no diff: mode code, no bar buttons, editable.
|
||
- `aChangedFileOffersOnlyTheDiffButton`: `a.php` with a diff: mode actual, bar buttons [diff], offers show-diff.
|
||
- `anUnchangedFileOffersNoShowDiff`: `a.php` without a diff does not offer show-diff.
|
||
- `showDiffNeedsActualInThePane`: `README.md` requested preview with a diff: pane mode preview; no show-diff.
|
||
- `unchangedMarkdownOffersOnlyPreview`: `README.md` without a diff: bar buttons [preview].
|
||
- `changedMarkdownOffersPreviewThenDiff`: `README.md` requested preview with a diff: bar buttons [preview, diff]; mode preview; not editable.
|
||
- `aFileOverTheDiffCapStillShowsItsLiveText`: `dump.sql` requested actual with a too-big diff (empty texts, 0 added): no placeholder; editable.
|
||
- `aDiffRequestOnAnUnchangedFileFallsBackToCode`: `a.php` requested diff, no diff: mode code.
|
||
- `aCodeModeOnAChangedFileResolvesToActual`: `a.php` requested code with a diff: mode actual.
|
||
- `theDiffOverlayLeavesActualInThePaneBehindIt`: `a.php` requested diff with a diff: mode diff; pane mode actual.
|
||
- `anAddedFileOffersNoShowDiff`: an added-file diff, requested actual: no placeholder; no show-diff; status added.
|
||
- `aDeletedFileHasNoUpdatedVersion`: a deleted-file diff, requested actual: placeholder "no updated version"; not editable.
|
||
- `aBinaryFileGetsAPlaceholderAndNoButtons`: `font.woff2` with a diff: placeholder "cannot display"; no bar buttons; has no diff.
|
||
- `anImageIsNeitherTextNorDiffed`: `logo.png` with a diff: kind image; no bar buttons; not editable.
|
||
|
||
#### Editor / EditorLayoutTests, suite LineIndexTests
|
||
|
||
- `linesAreFoundByUTF16Offset`: for `ab\ncd\n`: line count 3; offset 0 -> line 1; 2 -> line 1; 3 -> line 2; 6 -> line 3; column of offset 4 is 2 (1-based); line 2 starts at offset 3.
|
||
- `anEmptyTextIsOneEmptyLine`: empty text has line count 1; offset 0 -> line 1.
|
||
- `wrappedRowsShowTheNumberOnlyOnTheirFirstRow`: text 30 `x` + `\nshort` with visual row starts 0, 10, 20, 31 gives gutter labels 1, none, none, 2.
|
||
|
||
#### Editor / EditorLayoutTests, suite ChangeMarksTests
|
||
|
||
- `actualTintsAddedLinesAndRulesTheEdgeOfAPureDeletion`: lines (1 `a`), (2 `b` added), (3 `c` gap above), (4 `d` gap below) give marks: none for line 1; line 2 (tint, tone added); line 3 (no tint, no tone, gap above); line 4 gap below.
|
||
|
||
#### Editor / EditorLayoutTests, suite EditorRealDiffTests
|
||
|
||
- `actualMarksComeFromTheRealDiff`: diff `a\nb\nc\n` -> `a\nc\n`: the mark for line 2 has gap above.
|
||
|
||
#### Editor / EditorLayoutTests, suite DiffOverlayLayoutTests (row height 22, top padding 6, so content height = 12 + rows x 22)
|
||
|
||
- `theClickedLineLandsInTheMiddleOfTheViewport`: 200 rows, updated line 100, viewport 440: the row's middle (6 + index x 22 + 11) minus the offset is 220.
|
||
- `aLineNearTheTopGoesAsNearTheMiddleAsTheFilePermits`: row index 1 of 200, viewport 440: offset 0.
|
||
- `aLineNearTheEndStopsAtTheBottom`: row index 199 of 200, viewport 440: offset = 12 + 200 x 22 − 440.
|
||
- `fillerRowsOnTheUpdatedSideAreSkipped`: rows [left 1 `a` removed | nothing], [nothing | right 1 `b` added]: updated line 1 is row index 1.
|
||
|
||
#### Editor / EditorLayoutTests, suite IndentationTests
|
||
|
||
- `tabOnOneLineInsertsSpacesAtTheCaret`: text `ab`, caret at 1, tab size 4: edit = insert 4 spaces at 1; new caret at 5.
|
||
- `tabOverSeveralLinesIndentsEveryTouchedLine`: text `a\nb\nc`, selection (0, 3), tab size 2: replacement ` a\n b` over range (0, 3).
|
||
- `aSelectionEndingAtColumnZeroLeavesThatLineAlone`: same text, selection (0, 4) (ends at the start of line 3), tab size 2: replacement ` a\n b`.
|
||
- `shiftTabOutdentsTheCurrentLine`: text `x\n ab`, caret at 7, tab size 4, outdent: replacement `ab`, new caret at 3.
|
||
- `shiftTabOnAnUnindentedLineChangesNothing`: text `ab`, caret 1, outdent: no edit.
|
||
|
||
#### Editor / EditorLayoutTests, suite EditorReferenceTests
|
||
|
||
- `aSelectionNamesItsFirstAndLastLine`: in `a\nb\nc\nd\n`, selection (2, 3) covers lines 2...3; the reference for `x.php` (clicked line 9) is `x.php:2-3`.
|
||
- `aSingleLineSelectionIsASingleLineReference`: selected lines 4...4 give `x.php:4`.
|
||
- `withoutASelectionTheClickedLineIsTheReference`: no selection, clicked line 42 gives `x.php:42`.
|
||
|
||
#### Editor / EditorLayoutTests, suite IncrementalLineIndexTests (an index updated by an edit must equal a full rescan of the new text)
|
||
|
||
- `typingANewlineMatchesAFullRescan`: `ab\ncd\nef`, insert `\n` at 4.
|
||
- `deletingAcrossLinesMatchesAFullRescan`: `ab\ncd\nef\ngh`, delete range (1, 6).
|
||
- `pastingSeveralLinesMatchesAFullRescan`: `ab\ncd`, replace range (3, 1) with `x\ny\nz`.
|
||
|
||
#### Editor / EditorLayoutTests, suite HighlightDiffTests
|
||
|
||
- `typingInsidePlainTextRepaintsOnlyTheEditedRange`: old tokens [keyword 0..3, number 10..12], new tokens [keyword 0..3, number 11..13], edit (5, 1), delta +1, new length 14: repaint range (5, 1).
|
||
- `growingAStringRepaintsTheWholeToken`: old [string 4, length 4], new [string 4, length 5], edit (6, 1), delta +1, length 20: repaint (4, 5).
|
||
- `openingABlockCommentRepaintsEverythingAfterIt`: old [keyword 10..13, keyword 30..33], new [comment 0..40], edit (0, 2), delta +2, length 40: repaint (0, 40).
|
||
|
||
#### Editor / EditorLayoutTests, suite SymbolTargetsTests
|
||
|
||
Lookup for `User`: one definition (`app/User.php`, line 7, class, namespace `App`); references in `a.php` lines 3 and 9; reference count 2.
|
||
|
||
- `theKeyboardWalksDeclarationsThenEveryReferenceLine`: targets are (`app/User.php`, 7), (`a.php`, 3), (`a.php`, 9).
|
||
- `oneDeclarationIsNamedInFull`: title is `App\User`.
|
||
- `severalDeclarationsFallBackToTheShortName`: with a second definition (`b/User.php`, namespace `B`) the title is `User`; with no lookup the title is `User`.
|
||
|
||
#### Editor / EditorScrollOriginTests
|
||
|
||
Setup: a code editor (700 x 900 window) showing `notes.md` with 60 lines; every third line is `N: ` + a long sentence repeated 3 times, the rest `N: short line`.
|
||
|
||
- `aNewDocumentStartsRightOfTheGutter` (parameterised over wrap on and off): the scroll view's horizontal origin equals minus the left content inset (the text starts right of the gutter, not under it).
|
||
- `wrappedTextFitsTheWidthRightOfTheGutter`: with wrap on, after layout, the text view's width equals the scroll view's content width minus the left inset.
|
||
|
||
#### Editor / EditorStoreSafetyTests (on `EditorHarness`; "auto-saving" = editor config with autoSave on)
|
||
|
||
- `autoSaveKeepsAPendingSaveWhenTheTabChanges`: auto-saving with `a.txt` = `a`, `b.txt` = `b`: open a, edit to `a edited`, open b, edit to `b edited`, settle: disk has `a edited` and `b edited` (switching files never drops a pending auto-save).
|
||
- `pendingAutoSavesAreWrittenBeforeTheUnsavedPrompt`: auto-saving, open a, edit `typed`: resolving unsaved returns true, disk has `typed`, and the unsaved prompt was never asked.
|
||
- `anOlderReadThatLandsLastIsDropped`: `a.txt` = `old` open; hold the next read of a; start a general files-changed refresh (it waits on the gate); change disk to `new`; force a reload of `a.txt`; then open the gate: the editor text is `new` (the older, stale read that finished last is discarded).
|
||
- `forgettingAFileDropsEveryPieceOfItsState`: open `a.php` (with a diff) on the staged side, open image `logo.png`; forgetting both leaves no file states, modes, sides or images.
|
||
- `renamingCarriesImagesAlong`: open image `img/logo.png` (bytes 1, 2); remapping folder `img` to `assets` gives the image at `assets/logo.png` and none at `img/logo.png`.
|
||
- `aReopenedFileNeverReusesAnOldRevision`: open `a.txt` (`one`), note its revision; forget it; disk to `two`; reopen: the revision differs and the text is `two`.
|
||
- `aFileDeletedOnDiskKeepsItsTextAsUnsavedEdits`: open `a.txt` (`precious`); the file disappears; after a refresh it is marked deleted and dirty, its text is still `precious`, and nothing was written.
|
||
- `autoSaveNeverResurrectsADeletedFile`: auto-saving; after the file disappears, editing to `precious, edited` writes nothing.
|
||
- `savingADeletedFileWritesItBackOnPurpose`: after the file disappears, an explicit save writes `precious` back; the file is no longer deleted or dirty.
|
||
- `aFileThatComesBackIsCleanAgain`: `a.txt` = `same` disappears, then comes back with `same`: after refresh it is neither deleted nor dirty.
|
||
- `theUnsavedPromptAsksForEveryDirtyFileTheOpenOneFirst`: stranded edits on `a.txt` (disk `a`, buffer `a2`); `b.txt` open and edited to `b2`; prompt answers save for a, discard for others: resolve returns true; active file stays `b.txt`; asked order `b.txt`, `a.txt`; disk a = `a2`, b = `b`; no dirty paths.
|
||
- `cancellingThePromptKeepsEveryEdit`: same setup; prompt answers discard for a, cancel otherwise (b is asked first and cancels): resolve returns false; texts remain `a2` and `b2`.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreOpenFileTests
|
||
|
||
- `openingAFileMakesItTheActiveFileAndReadsItFromDisk`: opening `a.php` (`<?php\n`): active `a.php`, text `<?php\n`, history [`a.php`].
|
||
- `openingASecondFileReplacesTheActiveOne`: open `a.php` then `b.php`: active `b.php`, text `b`, history [`b.php`, `a.php`] (most recent first; one file open at a time).
|
||
- `theOpenFileComesFirstAmongTheDirtyPaths`: stranded edits on `c` then `a`; open `b` and edit: dirty paths are `b`, `a`, `c` (open file first, then the others sorted).
|
||
- `composerLockNeverOpensAndFlashesTooBig`: opening `composer.lock` leaves no active file and sets "too big" for `composer.lock`.
|
||
- `closingTheFileLeavesNoFileOpen`: open `a`, open `b`, close `b`: no active file.
|
||
- `aLineJumpSetsTheCursorAndFlashesTheLine`: opening `a.php` at line 3 sets the cursor (a.php, line 3, column 1) and flashes line 3.
|
||
- `renamingAFolderCarriesTheFileAndItsBufferAlong`: `src/a.php` open and edited to `y`; remapping `src` -> `lib` makes the active file `lib/a.php` with text `y`.
|
||
- `deletingTheActiveFileShowsTheEmptyState`: open a, open b, forget b: no active file.
|
||
- `deletingAnotherFileLeavesTheOpenOneAlone`: open a, open b, forget a: active stays `b`.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreSwitchTests ("dirty" = `a.txt` open and edited to `a edited`, `b.txt` = `b`)
|
||
|
||
- `reopeningACleanFileReadsWhatChangedOnDisk`: open a (`one`), open b, disk a -> `agent wrote this`, reopen a: text `agent wrote this`.
|
||
- `switchingAwayFromADirtyFileAsks`: opening b asks about [`a.txt`].
|
||
- `cancelKeepsTheFileAndItsEdits`: answer cancel: `open` returns false and the accepted callback is not called; active stays a with `a edited`; history [`a.txt`].
|
||
- `discardDropsTheEditsAndOpensTheNewFile`: answer discard: `open` returns true; active `b.txt`; no dirty paths; a's text back to `a`; nothing written.
|
||
- `saveWritesThenOpens`: answer save: disk a = `a edited`; active `b.txt`; accepted callback called.
|
||
- `aFailedSaveKeepsTheDirtyFileOpen`: answer save, writes fail: accepted not called; active stays a; a dirty; toasts [`Save failed`].
|
||
- `reopeningTheSameDirtyFileAsksThenReadsDisk`: answer discard; disk a -> `agent wrote this`; reopening a asks [`a.txt`], then text is `agent wrote this` and clean.
|
||
- `withAutoSaveTheDirtyFileIsSavedWithoutAsking`: autoSave on; open a, edit, open b: never asked, no toasts, disk a = `a edited`, active b.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreDirtyTests
|
||
|
||
- `anEditMakesTheFileDirtyAndTypingBackCleansIt`: `a.txt` = `one`: edit `two` -> dirty; edit back `one` -> clean, no buffer kept.
|
||
- `saveWritesTheBufferThroughTheFileServiceAndCleansTheFile`: edit `two`, save: writes [`two`]; clean; disk text `two`; the file-saved callback got [`a.txt`].
|
||
- `saveWithoutChangesWritesNothing`: saving an unedited file writes nothing.
|
||
- `aFailedSaveKeepsTheBufferAndSaysSo`: edit `two`, writes fail: save throws; file still dirty; toasts [`Save failed`].
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreUnsavedCloseTests ("dirty" = `a.txt` `one` edited to `two`)
|
||
|
||
- `closingADirtyFileAsksAndCancelKeepsItOpen`: request-close with cancel returns false; asked [`a.txt`]; still active and dirty.
|
||
- `saveWritesThenCloses`: answer save: returns true; disk `two`; no active file.
|
||
- `discardClosesWithoutWriting`: answer discard: returns true; nothing written; no buffers; no active file.
|
||
- `discardingThenReopeningShowsTheDiskTextToTheView`: discard-close, reopen: text `one` and a new revision (so the view reloads).
|
||
- `withoutAPromptADirtyFileNeverClosesSilently`: with no prompt handler installed, request-close returns false.
|
||
- `aCleanFileClosesWithoutAsking`: a clean file closes (true) without asking.
|
||
- `resolvingUnsavedSeesABufferThatIsNoLongerOpen`: stranded `a.txt` (disk `one`, buffer `two`), `b.txt` open; answer save: resolve returns true; asked [`a.txt`]; disk a = `two`.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreReloadTests
|
||
|
||
- `aWatcherChangeUpdatesACleanBuffer`: clean `a.txt`; disk -> `agent wrote this`; files changed [`a.txt`]: text updated and revision changed.
|
||
- `aWatcherChangeNeverClobbersADirtyBuffer`: edited to `my edit`; disk -> `agent wrote this`; general refresh: text stays `my edit`, disk text `agent wrote this`, dirty.
|
||
- `forcedReloadLetsDiskWinOverTheBuffer`: edited `my edit`; disk changes; reload active from disk: text `agent wrote this`, clean.
|
||
- `aDiskChangeThatMatchesTheBufferCleansIt`: edited `same`; disk -> `same`; files changed: clean, no buffer.
|
||
- `anImageIsReadAsBytesNotText`: opening `logo.png` (bytes 1, 2, 3) stores the image bytes and no disk text.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreModeTests
|
||
|
||
- `aChangedFileLandsInActual`: opening a changed `a.php` gives mode actual and presents no overlay.
|
||
- `commandMDoesNothingOnAFileWithoutPreview`: toggling preview on unchanged `b.php` keeps mode code; on changed `a.php` keeps actual; no overlay.
|
||
- `aDiffDefaultStillLandsInActualWithoutPoppingTheOverlay`: with default mode diff, opening changed `a.php` gives actual; no overlay.
|
||
- `unchangedMarkdownTogglesBetweenCodeAndPreview`: `README.md` unchanged: toggle -> preview, toggle -> code.
|
||
- `changedMarkdownTogglesBetweenActualAndPreviewAndNeverTheDiff`: changed `README.md`: toggle -> preview, toggle -> actual; no overlay.
|
||
- `enteringDiffPresentsTheOverlayWithTheFilesGitSide`: changed `a.php` opened on side staged; set mode diff: presented exactly [diff(path `a.php`, side staged)].
|
||
- `closingTheDiffReturnsToTheModeItCovered`: changed `README.md`: preview, then diff, then close diff -> preview.
|
||
- `togglingPreviewOverTheDiffClosesTheOverlay`: changed `README.md` in diff: toggle preview dismisses the diff overlay once and gives mode preview.
|
||
- `showDiffOnAMarkedLineOpensTheDiffOnHeadVersusDiskAtThatLine`: changed `a.php` opened on side unstaged; open diff at line 42: presented [diff(path `a.php`, side none (HEAD vs disk), focus line 42)]; collapse diff -> mode actual, 1 dismissal.
|
||
- `showDiffOpensStraightIntoTheOverlay`: opening changed `a.php` with show-diff gives mode diff and 1 presented overlay.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreSessionTests (session key = root `/fake`)
|
||
|
||
- `sessionRoundTripsTheActiveFileItsModeAndSide`: `a.md` changed; restore; open `b.php`, open `a.md` on side unstaged, set preview, persist: stored session = (active `a.md`, modes {a.md: preview}, sides {a.md: unstaged}). A new store on the same fakes restores: active `a.md`, mode preview, side unstaged, history [`a.md`, `b.php`], text `a`.
|
||
- `aRestoredDiffModeComesBackAsActual`: stored session (active `a.php`, mode diff) on a changed file restores as actual, with no overlay.
|
||
- `withRestoreOffOnlyTheRecentFilesComeBack`: recent [`x.php`], stored session active `z.php`, restore off: no active file; history [`x.php`]. After opening `a.php`: the stored session's active is still `z.php` (not overwritten) and recent files are [`a.php`, `x.php`].
|
||
- `nothingIsWrittenBackBeforeTheSessionWasRead`: without restore, opening `a.php` leaves recent files [`old.php`] untouched.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStorePassOnTests
|
||
|
||
- `theCaretLineIsTheReferenceWithoutASelection`: `src/a.php` with cursor at line 42 column 3: current reference `src/a.php:42`.
|
||
- `aSelectionIsPassedAsARangeWithItsCode`: selection lines 42...58 with code `code`: pass-on-selection request = (reference `src/a.php:42-58`, code `code`, anchor zero); composing note `fix` gives `fix src/a.php:42-58\n` + "```" + `\ncode\n` + "```".
|
||
- `withoutASelectionCommandRightPassesNothing`: with no selection, the pass-on-selection request is nil.
|
||
- `theRightClickMenuIsPassOnThenCopyReferenceWithoutAHeader`: the context menu for reference `src/a.php` line 42, no code: header empty; entries exactly `Pass on reference` (passOnReference `src/a.php:42`, nil), `Copy reference` (copyReference `src/a.php:42`).
|
||
- `aMarkedLineAddsShowDiffBelowASeparator`: same with show-diff line 42: the two entries, separator, `Show diff` (showDiff `src/a.php`, 42).
|
||
- `anEmptyNotePassesTheBareReference`: note ` ` gives `src/a.php:42`.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreSymbolTests
|
||
|
||
- `aSymbolLookupOpensThePopupAtOnceAndFillsItLater`: with a lookup for `User` (definition `app/User.php` line 7): looking up `User` presents [symbol(name `User`)] at once with no lookup result yet; after settling the result's first definition path is `app/User.php`.
|
||
- `knownSymbolsComeFromTheSymbolService`: declared {`User`, `Order`}: after loading, known symbols are {`User`, `Order`}.
|
||
|
||
#### Editor / EditorStoreTests, suite EditorStoreStatusTests
|
||
|
||
- `theStatusBarReadsPositionLanguageAndIndentation`: tab size 2, `a.php` open, cursor line 3 column 7: cursor line 3, column 7, language `PHP`, indentation label `Spaces: 2`, active mode code.
|
||
|
||
#### Explorer / ExplorerStoreTests
|
||
|
||
Setup: an Explorer store on `FakeFiles` with the sample tree, root `/tmp/project`, toasts recorded, tree loaded once. Rows hide dotfiles unless "show hidden" is on.
|
||
|
||
- `aFreshTreeStartsCollapsedAndHidesDotfiles`: visible rows `src`, `empty`, `README.md`; with hidden on `.github`, `src`, `empty`, `.env`, `README.md`.
|
||
- `expandingAFolderShowsItsChildrenOneLevelDeeperAndReReadsIt`: toggling `src` open gives `src`, `src/Http`, `src/app.php`, `empty`, `README.md`; row 1 has depth 1; the folder's children were read from disk once (child reads [`src`]).
|
||
- `collapsingKeepsTheFolderButHidesItsChildren`: toggling `src` twice gives `src`, `empty`, `README.md`; child reads [`src`, `src`] (each toggle re-reads).
|
||
- `expandingPicksUpFilesAddedSinceTheTreeWasRead`: the disk tree gains `empty/new.txt`; expanding `empty` shows `empty/new.txt`.
|
||
- `anEmptyFolderStillHasARow`: the row `empty` exists with kind directory.
|
||
- `reloadKeepsTheExpansion`: expand `src`, reload: expanded {`src`}; tree loads 2.
|
||
- `loadIfNeededReadsTheTreeOnlyOnce`: after the initial load, load-if-needed does not read again (tree loads 1).
|
||
- `selectingAFileRevealsItsFolders`: selecting `src/Http/Kernel.php` expands {`src`, `src/Http`} and the selected row has depth 2.
|
||
- `theCursorWalksTheVisibleRowsAndClamps`: with nothing selected, moving by +1 selects `src` (the first row); moving +5 clamps at `README.md`; with selection `.env` (hidden, so not visible) moving +1 selects `src`.
|
||
- `newFileLandsInItsFolderAndExpandsIt`: creating ` Router.php ` in `src/Http` returns `src/Http/Router.php` (trimmed); created [`src/Http/Router.php`]; expanded includes `src`, `src/Http`; tree reloaded (2 loads).
|
||
- `newFolderExpandsTheParentAndItself`: creating folder `Jobs/` in `src` returns `src/Jobs`; created directories [`src/Jobs`]; expanded includes `src`, `src/Jobs`.
|
||
- `aBlankNameCreatesNothing`: creating a file named ` ` throws a file-service error; nothing created.
|
||
- `renamingAFolderCarriesTheExpansionAndCursorAlong`: with `src/Http/Kernel.php` selected, renaming `src` to `lib` returns `lib`; renamed to [`lib`]; expanded {`lib`, `lib/Http`}; selection `lib/Http/Kernel.php`.
|
||
- `anInvalidRenameNeverReachesTheDisk`: renaming `README.md` to `a/b` throws a file-service error; nothing renamed.
|
||
- `deletingAFolderDropsTheCursorAndExpansionInsideIt`: with `src/Http/Kernel.php` selected, deleting `src`: deleted [`src`]; expanded empty; selection nil.
|
||
- `submittingTheNamePromptCreatesRenamesAndToasts`: submitting `notes.md` for a new file at root returns `notes.md`; `docs` for a new folder returns `docs`; `GUIDE.md` as rename of `README.md` returns `GUIDE.md`; renaming `GUIDE.md` to `GUIDE.md` returns nil (same name). Toast titles: `Created file`, `Created folder`, `Renamed file`.
|
||
- `aFailedCreateOrRenameSaysSoAndReturnsNil`: with writes failing: new file `a.txt` in `src` returns nil; rename `README.md` -> `b.txt` returns nil. Toast titles `Create failed`, `Rename failed` with details `src/a.txt`, `b.txt`.
|
||
- `thePromptPreviewShowsTheTargetPath`: new file in `src` named ` a.php ` -> `src/a.php`; new folder at root `jobs` -> `jobs/`; rename folder `src/Http` to `Web` -> `src/Web/`; rename `src/a.php` to the same `a.php` -> nil; new file named ` ` -> nil.
|
||
- `deleteAlwaysAsksFirstAndNothingElseDoes`: delete folder `src` asks title `Delete folder?`, body `src/ and everything inside it will be permanently deleted.`; delete file `README.md` asks `Delete file?`; copy reference and rename ask nothing.
|
||
- `aConfirmedDeleteRemovesAndToasts`: performing delete of `README.md` returns true (handled); deleted [`README.md`]; toast `Deleted file`.
|
||
- `copyActionsGoToTheClipboardWithAToast`: copy reference `src/` and copy file name `app.php` are handled; clipboard got `src/`, `app.php`; toasts `Copied reference`, `Copied`.
|
||
- `showInFinderRevealsTheAbsolutePath`: reveal `src/app.php` and reveal `` (root) are handled; revealed paths are `<root>/src/app.php` and `<root>`.
|
||
- `promptAndAgentActionsAreLeftToTheWorkspace`: new file, rename and pass on reference are not handled by the store (return false).
|
||
- `eachTargetGetsItsOwnMenu`: (project name `console`) file `src/app.php` menu labels: `Pass on reference`, `Copy reference`, `Pass on file name`, `Copy file name`, `Rename file`, `Show in Finder`, `Delete file`. Folder `src`: `Pass on reference`, `Copy reference`, `New file`, `New folder`, `Rename folder`, `Show in Finder`, `Delete folder`. Project root: `New file`, `Show in Finder`. Folder header empty; root header `console/`. A directory row `src` maps to target directory(`src`).
|
||
|
||
#### Overlays / ContextMenuTintTests, suite ContextMenuTintTests
|
||
|
||
Icon tints: add (teal), modify (amber soft), rename (grey), plain (no colour; amber on highlight), danger (amber deep).
|
||
|
||
- `addingActionsAreTeal`: new file and new folder -> add.
|
||
- `finderAndCopyFileNameAreAmberSoft`: reveal in Finder and copy file name -> modify.
|
||
- `passOnShowDiffAndRenameAreGrey`: pass on reference, pass on file name, bouwen, show diff, rename -> rename.
|
||
- `theGitViewItemsKeepThePlainIcon`: open file and commit-and-push -> plain.
|
||
- `copyReferenceKeepsThePlainIconThatTurnsAmberOnHighlight`: copy reference -> plain; the plain tint has no colour.
|
||
- `destructiveActionsAreAmberDeep`: git discard and delete -> danger.
|
||
|
||
#### Overlays / ContextMenuTintTests file, suite MenuDismissalTests (menu bounds x 100, y 100, 320 x 200)
|
||
|
||
- `aClickOutsideTheMenuClosesIt`: a click at (20, 20) in the same window closes it.
|
||
- `aClickOnTheMenuLeavesItOpen`: a click at (150, 150) does not.
|
||
- `aClickInAnotherWindowLeavesItOpen`: a click at (20, 20) in another window does not.
|
||
|
||
#### Overlays / OverlayListTests, suite ShortcutCatalogTests
|
||
|
||
- `theGroupsAreNavigateAgentGitFileInThatOrder`: group titles `Navigate`, `Agent`, `Git`, `File`.
|
||
- `everyShortcutTheAppHandlesIsListed`: every one of these key strings appears as a row: `⌘F`, `⌘↑↓`, `↵`, `⌘←→`, `↑↓`, `⇧⌘O`, `⌘O`, `⌘→`, `⌘P`, `⌘C`, `⌘↵`, `⌘G`, `⌘M`, `⌘S`, `⌘.`, `⌘A`, `⌘L`, `Esc`, `⌘W`, `⌘R`, `⇧⌘N`, `?`, `⌘click`, `⌘0`, `⌘+`, `⌘−`, `⌘1`, `⌘2`, `⌘3` (keys of a row joined without separator).
|
||
- `theNewRowsKeepTheOldFourGroups`: `⇧⌘N`, `⌘click`, `?` are in Navigate; `⌘W`, `⌘R`, `⌘0`, `⌘+`, `⌘−` are in File.
|
||
- `everyRowHasKeysAndADescription`: every row has at least one non-empty key and a non-empty label.
|
||
|
||
#### Overlays / OverlayListTests, suite ListCursorTests
|
||
|
||
- `movesStopAtBothEnds`: step(0, −1, count 3) = 0; step(2, +1, 3) = 2; step(1, +1, 3) = 2; step(4, 0, count 0) = 0.
|
||
- `commandDownStartsOnThePreviousFileAndCommandUpOnTheCurrentOne`: recent-files start moving down with 5 files = 1; with 1 file = 0; moving up with 5 = 0.
|
||
|
||
#### Overlays / OverlayListTests, suite MenuCursorTests (entries: Copy reference, separator, Rename file, Delete file)
|
||
|
||
- `theFirstItemIsPreHighlighted`: with a leading separator added, the first highlighted index is 1.
|
||
- `arrowsSkipSeparatorsAndWrapAround`: step(0, +1) = 2; step(2, −1) = 0; step(3, +1) = 0 (wrap); step(0, −1) = 3 (wrap).
|
||
|
||
#### Overlays / OverlayListTests, suite NamePromptTextTests
|
||
|
||
- `aNewFilePreviewsItsPathInTheFolder`: new file in `src`: title `New file`; preview of ` a.php ` is `src/a.php`; preview of empty is `…`; ` ` cannot be submitted.
|
||
- `aNewFolderPreviewEndsInASlash`: new folder at root: title `New folder`; preview `docs` -> `docs/`.
|
||
- `aRenameSelectsTheStemAndRefusesTheSameName`: rename `docs/notes.md` (initial `notes.md`): title `Rename file`; preview label `renames to`; initial selection (0, 5) (the stem `notes`); `notes.md` cannot be submitted; `todo.md` can; preview `docs/todo.md`.
|
||
- `aDotfileRenameSelectsTheWholeName`: rename `.env`: initial selection (0, 4).
|
||
|
||
#### Overlays / OverlayListTests, suite SearchHighlightTests
|
||
|
||
- `theMatchRunCoversTheQueryLengthFromTheHitOffset`: hit `use App\UserRepository;` at offset 8, length 4: runs `use App\`, `User`, `Repository;`.
|
||
- `anOffsetPastTheLineIsClamped`: hit `abc` at offset 99, length 4: the line text is `abc` (no crash).
|
||
|
||
#### Overlays / SearchComputeOnceTests (search model with a counting file-name ranker; FakeSearch; active file `a.php` with text `user\nnone`; debounce 20 ms)
|
||
|
||
- `aQueryChangeRanksTheFileNamesOnceHoweverOftenTheResultsAreRead`: files `user.php`, `user.js`, `readme.md`; after start, setting query `user` and then reading summary, extension chips, file matches, shown file matches, the files empty message and the target 5 times each ranks exactly once.
|
||
- `choosingATypeFiltersWithoutRankingAgain`: with `user.php`, `user.js` and query `user`, choosing type `js` gives file matches [`user.js`] with 0 more ranking calls.
|
||
- `arrivingContentResultsDoNotRankTheFileNamesAgain`: content results for `user` = group `b.js`; after the search finishes, groups [`b.js`] and 0 more ranking calls.
|
||
- `theHiddenToggleRanksAgainOnce`: files `.env`, `env.php`, query `env`: turning show-hidden on ranks exactly once more; file matches {`.env`, `env.php`}.
|
||
- `theThisFileHitsFollowTheQuery`: query `user` gives in-file hits on line [1]; query `zzz` gives none.
|
||
|
||
#### Overlays / SearchComputeOnceTests file, suite SearchChipTooltipTests
|
||
|
||
- `aChipSaysHowManyResultsItHasAndWhatAClickDoes`: count 3, not chosen -> `3 results · click to show only this type`; count 1 -> `1 result · click to show only this type`.
|
||
- `theChosenChipOffersEveryTypeBack`: count 2, chosen -> `2 results · click to show every type`.
|
||
- `chipsCarryTheirResultCounts`: content for `user` = group `a.php`; files `user.php`, `user.js`: chips are (php, 2), (js, 1) (content groups plus file-name matches, ordered by count).
|
||
|
||
#### Overlays / SearchModelTests (FakeSearch, debounce 20 ms; `group(path, lines)` = hits `let user = N` at offset 4)
|
||
|
||
- `keystrokesWithinTheDebounceRunOnlyTheLastSearch`: setting `us`, `use`, `user` in a row runs only the content query `user`; content [`a.php`].
|
||
- `aSlowStaleSearchNeverOverwritesTheNewerResult`: `ab` answers `old.php` after 300 ms, `abc` answers `new.php` at once; set `ab`, wait until it is asked, set `abc`; after both answer, content is [`new.php`].
|
||
- `contentSearchStartsAtTwoCharacters`: query `u` asks nothing; project empty message `Type at least two characters.`.
|
||
- `shorteningTheQueryBelowTwoCharactersClearsTheResults`: after results for `us`, setting `u` clears the content.
|
||
- `theSeedIsSearchedWhenTheOverlayStartsAndTheFileListLoads`: seed `user`, files `src/UserController.php`, `public/store.js`: start runs content query `user`; shown file matches [`src/UserController.php`].
|
||
- `eachGroupShowsTwelveLinesButCountsEveryHit`: groups `a.php` lines 1-18 and `b.js` lines 5-7: hit counts 18, 3; shown rows 12, 3; hit rows indexed 0...14; total hits 21.
|
||
- `dotfileHitsStayHiddenUntilTheToggleIsOn`: groups `.env` and `config/app.php` for `key`: shown groups [`config/app.php`]; with hidden on [`.env`, `config/app.php`].
|
||
- `aTypeChipFiltersBothColumnsAndAClickOnItAgainShowsEveryType`: groups `a.php`, `b.js`, files `user.php`, `user.js`: chips {php, js}; choosing js filters groups to [`b.js`] and files to [`user.js`]; choosing js again clears the filter and shows 2 groups.
|
||
- `aChosenTypeTheNewResultsNoLongerCarryFallsBackToEveryType`: choose js on `user` results, then query `users` whose results are `a.php`, `c.py`: the filter is cleared.
|
||
- `thereAreNoChipsForASingleFileType`: only `a.php` results: no chips.
|
||
- `theSummaryCountsThisFileHitsAndFiles`: active `README.md` with `no match here`, group `a.php` with 2 hits, file `User.php`: summary `0 here · 2 hits · 1 file`.
|
||
- `withoutAnOpenFileThereIsNoThisFileColumn`: columns [project, files]; summary has no `here`.
|
||
- `columnMovesStopAtTheEdgesAndStartOnProject`: with an active file: starts on project; −1 twice stops at thisFile; +1 three times stops at files.
|
||
- `rowMovesStayInsideTheFocusedColumn`: 3 project hits, files `user.php`, `users.php`: +5 -> project selection 2; −9 -> 0; move to files column, +1 -> file selection 1, project selection still 0.
|
||
- `enterOpensTheSelectedHitAtItsLine`: group `a.php` lines 4-6, move +1: target (`a.php`, line 5).
|
||
- `enterInTheFilesColumnOpensTheFileWithoutALine`: file `src/UserController.php`, query `usercon`, files column: target (`src/UserController.php`, no line).
|
||
- `enterInAnEmptyProjectColumnFallsBackToTheFirstFileName`: no content results, file `user.php`, query `user`: target (`user.php`, no line).
|
||
- `enterInThisFileJumpsToTheLineInTheOpenFile`: active `notes.md` = `one\nuser two\nthree user`, query `user`, thisFile column, +1: in-file hits on lines 2, 3; target (`notes.md`, 3).
|
||
- `aNewQueryResetsEverySelection`: after moving +2, a new query `users` resets project selection to 0.
|
||
- `emptyColumnsSayOnePlainSentence`: with an active file and no query: thisFile `Type to search this file.`; files `Type to search file names.`. After query `zzz`: thisFile `No matches in this file.`; project `No content matches.`; files `No file names match.`.
|
||
- `withThisFileTheColumnsTakeThirtyFortyFiveAndTwentyFivePercent`: total 1000 with three columns: 300, 450, 250.
|
||
- `withoutThisFileTheColumnsTakeSixtyFiveAndThirtyFivePercent`: total 1000 with project and files: 650, 350; no thisFile width.
|
||
|
||
#### Shell / KeyRouterTests
|
||
|
||
The key router maps a key press plus a context to either "perform command X" or "pass" (leave the key to the focused view or the menu bar). `⌘x` below = command + character x. Context fields: overlay (none, `other`, `launcher`, `diff(busy)`), owner (none, `text(in: panel or none)` = a text field/view has focus, `terminal`), search seed, has text selection, has editor line selection, editor text selection, active panel, focus zone, recent file count, git view open, in git console, has project. Defaults: no overlay, no owner, project open.
|
||
|
||
- `commandLettersMapToTheirCommand` (parameterised; each both with no owner and with the editor text view focused): `⌘p` -> push; `⌘s` -> save; `⌘m` -> cycle mode; `⌘g` -> toggle git; `⌘l` -> toggle auto-fit; `⌘.` -> toggle hidden; `⌘w` -> close file or window; `⌘1` -> toggle pane explorer; `⌘2` -> toggle pane editor; `⌘3` -> toggle pane terminal.
|
||
- `searchIsSeededWithTheSelection`: `⌘f` with search seed `needle` -> show search(seed `needle`).
|
||
- `shiftCommandOOpensTheRecentProjectsAndPlainOIsLeftToTheMenu`: `⇧⌘o` -> show recent projects; `⌘o`, `⌘r`, `⇧⌘n` -> pass.
|
||
- `commandASelectsTheOpenFileOutsideAFieldAndCommandLTogglesFluid`: `⌘a` -> select all in file; `⌘l` -> toggle auto-fit; `⌘a` in the editor text view or in the terminal -> pass.
|
||
- `commandCFocusesTheCommitBoxOutsideTheTerminalUnlessThereIsSomethingToCopy`: `⌘c` -> focus commit message; pass when the editor text has a selection, when there is an editor line selection, in the terminal (with or without selection).
|
||
- `commandEnterCommitsOnlyOverTheGitView`: `⌘↵` -> pass normally and in the editor; -> commit when the git view is open.
|
||
- `commandEnterInTheGitConsoleStaysWithTheConsole`: in the git console field (text owner, git view open, in console): `⌘↵` -> pass; `⌘p` -> push.
|
||
- `arrowsMoveTheRowCursorOnlyInAListWithoutAField`: active panel explorer: `↓` -> move row cursor +1; `↑` -> −1; `↵` -> open selected row. `↓` with active panel editor -> pass; with a text field in the explorer -> pass; `↵` in the terminal -> pass.
|
||
- `commandRightOpensTheRowMenuPassesASelectionOrMovesFocus`: `⌘→` in the explorer -> open row menu; in the editor text with selection (text `x`, lines 3-4) -> pass selection(that selection); with an editor line selection -> pass selection(none); in the editor panel without selection -> focus neighbour +1; with the editor text view focused and no selection -> pass.
|
||
- `commandLeftMovesFocusButNotOutOfATextField`: `⌘←` -> focus neighbour −1; with an editor text owner -> pass.
|
||
- `commandUpAndDownOpenRecentFilesFromTheEditor`: focus zone editor, 3 recent files: `⌘↓` -> show recent files(initial selection 1); `⌘↑` -> (initial 0); with 1 recent file `⌘↓` -> (initial 0); focus zone terminal -> pass; editor with no recent files -> pass.
|
||
- `questionMarkOpensHelpButTypesInAField`: `?` (shift) -> show shortcuts; in the editor text or terminal -> pass.
|
||
- `escapeClosesAnOverlayAndOtherwiseReachesTheTerminal`: Esc with an overlay -> dismiss overlay (also with a text owner); Esc in the terminal with no overlay -> pass.
|
||
- `commandGTogglesTheGitViewFromAnywhere`: `⌘g` -> toggle git with no owner, from the terminal, and from a field in the open git view.
|
||
- `escapeClosesTheGitViewOnlyWhenNoOverlayIsOpen`: git view open: Esc -> close git view (also from a field); with an other overlay -> dismiss overlay; with a diff overlay not busy -> dismiss overlay; with a busy diff overlay -> pass; Esc with nothing open -> pass.
|
||
- `overTheGitViewCommitPushAndSearchWorkFromItsFields`: from a field in the git view: `⌘↵` -> commit; `⌘p` -> push; `⌘f` -> show search(seed ``); `⌘g` -> toggle git; `⌘2` -> toggle pane editor.
|
||
- `overTheGitViewTheColumnKeysRestAndTypingReachesTheField`: git view open (explorer active, editor focus zone, 3 recent files): `↓`, `↵`, `⌘→`, `⌘←`, `⌘↓`, `⌘a` -> pass. In a git-view field: typing `x` and `?` -> pass; `⌘c` with a text selection -> pass.
|
||
- `anOpenOverlayOwnsEveryOtherKey`: with an other overlay (explorer active): `⌘g`, `↓`, `⌘→` -> pass.
|
||
- `commandNIsLeftUnbound`: `⌘n` -> pass.
|
||
- `theBareLauncherTakesArrowsAndEnter`: no project: `↓` -> launcher move +1; `⌘↑` -> launcher move −1; `↵` -> launcher activate; `⌘o` -> pass.
|
||
- `theRecentProjectListOwnsItsKeysButEsc`: launcher overlay: `↓` and `↵` -> pass; Esc -> dismiss overlay.
|
||
- `theWorkspaceShortcutsKeepWorkingOverTheDiff`: diff overlay not busy, editor active: `⌘m` -> cycle mode; `⌘p` -> push; `⌘s` -> save; `⌘c` -> focus commit message; `⌘↵` -> pass; `⌘↓` (editor focus zone, 2 recent) -> show recent files(initial 1); Esc -> dismiss overlay.
|
||
- `overTheDiffCopyAndSelectAllStayWithItsPanes`: over the diff, `⌘c` with a text selection -> pass; `⌘a` -> pass.
|
||
- `theDiffsOwnMenuOrPromptTakesEveryKey`: busy diff: `↓`, `↵`, Esc, `⌘m` -> pass.
|
||
- `controlAndOptionChordsAlwaysReachTheFocusedView`: control+c -> pass; command+option+g -> pass.
|
||
|
||
#### Shell / LauncherListTests (recents `/code/a` named a, `/code/b` named b)
|
||
|
||
- `theFirstRowOpensTheFolderPicker`: the list has 3 rows; the initial choice is "choose folder".
|
||
- `arrowsMoveThroughTheRowsAndStopAtTheEnds`: −1 keeps selection 0; +1 selects open(`/code/a`); +5 stops at open(`/code/b`).
|
||
- `theOpenProjectIsNotOfferedAgain`: excluding `/code/a` leaves recents [`/code/b`].
|
||
- `hoverSelectionIsClamped`: selecting 99 gives selection 2.
|
||
|
||
#### Theme / FontRegistryTests, suite FontRegistryTests
|
||
|
||
- `bundledPlexFacesRegister`: registering the bundled fonts returns every IBM Plex face name, and each loads at size 12.
|
||
- `typeRolesResolveToPlex`: the code type role uses `IBMPlexMono-Regular`; the row role uses `IBMPlexSans-Regular`.
|
||
|
||
#### Theme / FontRegistryTests file, suite CommitLabelTests
|
||
|
||
- `theCommitLabelIsPlexSansSemiBold`: the commit button font is `IBMPlexSans-SemiBold`.
|
||
|
||
#### Theme / PaletteTests
|
||
|
||
- `parsesTheConfigColourFormats`: CSS colour `#E8913A` parses with red = 232/255 (± 0.001); `rgba(232,145,58,0.22)` parses with alpha 0.22; `teal` (a name) does not parse.
|
||
|
||
#### Terminal / TerminalStoreSessionTests, suite TerminalStoreSessionTests
|
||
|
||
GUI environment: `SHELL=/bin/zsh`, `HOME=/Users/me`, `PATH=/usr/bin:/bin`, `npm_config_prefix=/opt/homebrew`.
|
||
|
||
- `theAgentPaneRunsTheConfiguredCommandThroughAnInteractiveShellInTheProject`: root `/code/app`, `ai.command = "claude --continue"`: agent launch executable `/bin/zsh`, arguments `["-i", "-c", "claude --continue"]`, working directory `/code/app`.
|
||
- `theAgentPaneIsAPlainShellWhenAutoLaunchIsOff`: with autoLaunch off, the agent launch has no arguments.
|
||
- `theShellPaneUsesTheConfiguredShellOverTheLoginOne`: shell pane executable `/bin/zsh`; with `terminal.shell = /opt/homebrew/bin/fish` it is `/opt/homebrew/bin/fish` with no arguments.
|
||
- `theChildEnvironmentGetsAUTF8LocaleTruecolorAndNoNpmPrefix`: shell launch env has `TERM=xterm-256color`, `COLORTERM=truecolor`, `LANG=en_US.UTF-8`, no `npm_config_prefix`, `PATH=/usr/bin:/bin`.
|
||
- `withoutAProjectThePanesStartInTheHomeFolder`: no root: shell working directory `/Users/me`.
|
||
- `everyPaneStartsAsALoginShellSoTheProfileRepairsPath`: login argv0 for `/bin/zsh` is `-zsh`; for `/opt/homebrew/bin/fish` is `-fish`.
|
||
- `startingAPaneAttachesItAndSpawnsItsLaunch`: starting the agent on a fake pane attaches it; the pane got one start with the agent launch and argv0 `-zsh`.
|
||
- `panesWaitUntilTheProjectConfigArrives`: a new store is not configured; after setting the config it is.
|
||
- `anExitIsReportedPerPane`: shell exits with code 1: shell exited, agent not.
|
||
- `restartKillsTheOldProcessAndSpawnsAFreshOne`: agent started, received input `half typed`, exited with 0; restart: 1 termination, 2 starts, not exited, composer has no text.
|
||
- `restartWithoutAPaneDoesNothing`: restarting the shell with no pane leaves no shell pane.
|
||
- `aMultiLinePasteIsWrappedAsOneBracketedPasteAndNeverSubmits`: inserting "fix this\n```\nlet x = 1\n```" into the agent sends exactly one string `ESC[200~fix this\n` + "```" + `\nlet x = 1\n` + "```" + `ESC[201~`, and nothing sent ends with `\r`.
|
||
- `aPasteAfterTypingStartsOnAFreshLine`: after the agent received input `h`, inserting `a.php:3` sends `ESC[200~\na.php:3ESC[201~`.
|
||
- `controlSequencesDoNotCountAsComposerText`: input `ESC[A` (arrow up) does not mark the composer as having text.
|
||
- `closingTheWindowTerminatesBothPanes`: terminate all ends both panes once and detaches both.
|
||
- `aClosingWindowReleasesItsPaneOnceEvenAfterTerminateAll`: releasing the agent pane terminates it once and detaches it; then terminate all and releasing the shell: agent still terminated only once, shell once.
|
||
- `pastingIntoTheAgentMarksItsComposerAsFilled`: pasting `hello` then `` into the agent pastes only [`hello`] and marks the composer as having text.
|
||
- `anEmptySelectionReadsAsNone`: shell selection is nil when nil or empty; `ls -la` when selected.
|
||
|
||
#### Terminal / TerminalStoreSessionTests file, suite TerminalPseudoTerminalTests (tag `realProcess`, 1-minute limit)
|
||
|
||
- `aRealChildRunsInAPseudoTerminalAndItsExitIsReported`: a real terminal view running `/bin/echo helder-smoke` (TERM xterm-256color, cwd `/tmp`) shows `helder-smoke` on screen, the shell pane is reported exited, and the screen shows `[process exited]` (within 20 s).
|
||
- `closingThePanesReapsTheChildSoNoZombieIsLeft`: running `/bin/sleep 30`, the pid exists; after terminate all, the pid no longer exists at all (ESRCH) within 20 s.
|
||
- `restartingAPaneReapsTheOldChild`: shell pane (SHELL `/bin/sh`) started; after restart the pid differs and the old pid is gone (ESRCH); after terminate all the new pid is gone too.
|
||
|
||
#### Terminal / TerminalStoreSessionTests file, suite TerminalZoomTests
|
||
|
||
- `theTerminalFontFollowsTheWindowZoom`: terminal font size 10 gives a 10 pt font; with zoom scale 1.2 it gives 12 pt (± 0.001).
|
||
|
||
#### State / CleanCopyTests (on `WorkspaceHarness`; the clean-copy file is `.clean-copy` at the project root; "the agent writes X" = the fake file gets text X, the model handles a clean-copy watch event, then settles)
|
||
|
||
- `theTextFoundOnProjectOpenIsTheBaselineAndNeverPops`: the project opens with `.clean-copy` = `left over from yesterday`: no overlay; a clean-copy event without a change still opens no overlay.
|
||
- `aChangedFileOpensThePopupWithItsText`: baseline `old`; the agent writes `git commit -m "fix"`: overlay clean-copy, popup text `git commit -m "fix"`.
|
||
- `aFileThatAppearsAfterOpenPops`: no file at open; the agent writes `first`: overlay clean-copy.
|
||
- `theSameTextAgainDoesNotPop`: writes `once`, dismiss, writes `once` again: no overlay.
|
||
- `anEmptyOrBlankFileDoesNotPop`: baseline `old`; writes `` then ` \n\t`: no overlay.
|
||
- `copyPutsTheEditedTextOnThePasteboardClosesAndToasts`: writes `draft`; the user edits the popup to `draft, edited`; the copy command copies exactly [`draft, edited`], closes the overlay, toasts [`Copied`].
|
||
- `escClosesWithoutCopying`: writes `draft`; dismiss: nothing copied; no overlay.
|
||
- `newTextReplacesAnUneditedPopup`: writes `one` then `two`: overlay still clean-copy with text `two`.
|
||
- `newTextLeavesAnEditedPopupAlone`: writes `one`; the user edits to `one, mine`; writes `two`: text stays `one, mine` and nothing is pending.
|
||
- `textWaitsForAnotherOverlayAndOnlyTheLatestShows`: with the shortcuts overlay open, writes `one` then `two`: the shortcuts overlay stays; after dismissing it the clean-copy overlay eventually appears with text `two`.
|
||
- `theFileIsNeverWrittenOrDeleted`: after write `keep` and copy, the file still holds `keep`; nothing deleted or written by the app.
|
||
|
||
#### State / LayoutStoreTests
|
||
|
||
A session store that loads an agent split of 0.9 is used unless stated. Agent split range 0.18 to 0.82, default 0.52. Explorer width range 160 to 520. Window splitter = 1 point each.
|
||
|
||
- `restoresAClampedAgentSplit`: a saved split of 0.9 restores as 0.82.
|
||
- `draggingLocksTheColumns`: at width 1760 the layout is fluid; dragging the explorer by +1000 turns fluid off and clamps the explorer to 520.
|
||
- `explorerDragsStayInsideTheirRange`: dragging −1000 gives 160; +5000 gives 520.
|
||
- `theAgentColumnNeverSqueezesTheEditorBelowItsMinimum`: at 1760, dragging the agent by −5000 (wider) leaves the editor (1760 − 2 − explorer − agent) at least 280.
|
||
- `roomyWindowsUseTheDesignProportions`: at 1760 the widths are explorer 289, agent 480.
|
||
- `focusChangesTheFluidWidthsOnlyBelow1600`: at 1500, focus terminal -> agent 750; focus editor -> agent 300. At 1800, focus terminal -> agent = round(1800 x 0.273).
|
||
- `autoFitBackOnRefitsImmediately`: at 1760 drag explorer +100 (not fluid); toggling fluid back on gives fluid and explorer 289 at once.
|
||
- `lockedColumnsShrinkToKeepTheEditorWhenTheWindowNarrows`: lock the columns at 1760 (drag by 0), resize to 1100 then 900: explorer + agent <= 900 − 2 − 280.
|
||
- `hidingTheExplorerDropsItsFocus`: focus explorer, hide explorer: no active panel; focusing the hidden explorer leaves no active panel.
|
||
- `theGitViewOpensClosesAndToggles`: closed at first; open -> open; close -> closed; toggle -> open; toggle -> closed.
|
||
- `theGitViewIsNeitherSavedNorKeptAcrossAProjectSwitch`: restore `/p`, open the git view: nothing saved for `/p`; restore `/q`: git view closed and all panes visible.
|
||
- `aProjectsColumnsSurviveARestart`: for `/p` at 1760: drag explorer +40, end drag, hide terminal. A new store on the same persistence (resized to 1760, restored `/p`): not fluid, terminal hidden, same explorer and agent widths.
|
||
- `projectsKeepSeparateLayouts`: hide explorer in `/a`; in `/b` explorer is visible; back in `/a` it is hidden.
|
||
- `dragsSaveOnlyWhenTheyEnd`: during a drag in `/p` nothing is saved; after end drag a snapshot with fluid false is saved.
|
||
- `theAgentSplitFollowsTheDragAndStaysClamped`: with a fake session (default 0.52), dragging the split by +100 over height 1000 gives 0.62 and saves 0.62; dragging +5000 gives 0.82.
|
||
- `aWindowXMapsToTheColumnUnderIt`: at 1760: x 10 -> explorer; 900 -> editor; 1700 -> terminal; x 289 with splitter margin 4 -> none (on the splitter). With the explorer hidden x 10 -> editor.
|
||
- `neighbourColumnsClampAtTheEdgesAndSkipAHiddenColumn`: neighbour of none +1 -> terminal; terminal +1 -> terminal; explorer −1 -> explorer; editor −1 -> explorer; with the explorer hidden, editor −1 -> editor.
|
||
- `everyPaneStartsShownAndTogglesOnItsOwn`: all visible; hide explorer and terminal: visibility (explorer false, editor true, agent false), columns [editor]; toggle terminal again: visible.
|
||
- `hidingAFocusedPaneDropsItsFocusAndAHiddenPaneTakesNone`: focus terminal, hide it: no active panel; focusing it again: none; focus editor, hide explorer: active stays editor.
|
||
- `allThreePaneFlagsSurviveARestart`: hide all three in `/p`; a new store restoring `/p` has all three hidden.
|
||
- `anOlderSnapshotWithOnlyTheGitFlagStillLoads`: JSON `{"sourceControlWidth":240,"explorerWidth":300,"agentWidth":500,"fluid":false,"gitVisible":false}` decodes with all panes visible, explorer 300, agent 500, not fluid.
|
||
- `aSnapshotFromTheGitColumnDaysKeepsItsPaneFlags`: JSON with `"explorerVisible":false,"fileVisible":true,"claudeVisible":false` plus the old git keys and `fluid: true` decodes to visibility (explorer false, editor true, agent false), fluid.
|
||
- `aSnapshotWithoutTheGitKeysLoads`: `{"explorerWidth":300,"agentWidth":500,"fluid":false,"explorerVisible":true,"fileVisible":false,"claudeVisible":true}` decodes to visibility (true, false, true), explorer 300.
|
||
- `aSavedSnapshotNoLongerWritesTheGitKeys`: encoding a snapshot (288, 480, fluid) writes no `sourceControlWidth` and no `gitVisible` keys.
|
||
- `aSnapshotRoundTripsItsPaneFlags`: a snapshot with visibility (false, true, false) encodes and decodes equal.
|
||
- `withTheEditorHiddenTheAgentColumnFillsTheRest`: at 1760 hide the editor: columns [explorer, terminal]; no editor span; terminal span from explorer + 1 to 1760; x 1000 -> terminal.
|
||
- `withTheAgentHiddenTheEditorReachesTheWindowEdge`: hide the terminal: explorer span 0 to explorer width; editor span explorer + 1 to 1760; no terminal span; x 1700 -> editor.
|
||
- `withEveryPaneHiddenNothingIsUnderThePointer`: all hidden: no columns; x 500 -> none; neighbour of editor +1 -> editor.
|
||
- `neighboursSkipEveryHiddenPane`: with the editor hidden: explorer +1 -> terminal; terminal −1 -> explorer.
|
||
- `theAgentMayGrowIntoTheRoomAHiddenExplorerLeaves`: at 1760 with the explorer hidden, dragging the agent −5000 gives agent width 1760 − 1 − 280.
|
||
|
||
#### State / OverlayStoreTests
|
||
|
||
- `overlaysNeverStack`: presenting search(seed `foo`) then launcher leaves current = launcher; dismiss -> none and not presented.
|
||
- `everyChangeIsReportedWithTheOverlayItReplaced`: present launcher, launcher again (no change reported), shortcuts, dismiss: changes reported (old -> new) are none -> launcher, launcher -> shortcuts, shortcuts -> none.
|
||
|
||
#### State / TerminalStoreTests
|
||
|
||
- `insertIntoAgentIsABracketedPasteOnItsOwnLine`: inserting `a.php:1` then `b.php:2-3` sends `ESC[200~a.php:1ESC[201~` then `ESC[200~\nb.php:2-3ESC[201~` (the second starts a fresh line because the composer now has text).
|
||
- `enterEmptiesTheComposer`: input `x` fills the composer; input `\r` empties it; inserting `ref` then sends `ESC[200~refESC[201~`.
|
||
- `withoutAnAgentNothingIsSent`: inserting with no agent pane attached does not mark the composer.
|
||
|
||
#### State / ToastStoreTests
|
||
|
||
- `toastsStackInArrivalOrder`: showing `Saved` (detail `a.php`) then `Pushed` gives titles `Saved`, `Pushed`; the first has detail `a.php`.
|
||
|
||
#### State / WorkspaceCloseTests, suite WorkspaceCloseTests ("dirty" = workspace started, `a.php` = `<?php` opened and edited to `<?php // unsaved`)
|
||
|
||
- `closingAWindowWithUnsavedEditsAsksFirst`: answer cancel: prepare-to-close returns false; questions asked [`a.php`]; still dirty.
|
||
- `savingFromTheCloseQuestionWritesBeforeTheWindowGoes`: answer save: returns true; disk has `<?php // unsaved`; the stored session for `/fake/project` has active `a.php`.
|
||
- `aCancelledProjectSwitchKeepsTheProjectAndItsEdits`: answer cancel, open project `/fake/other`: root unchanged, text still edited, agent pane not terminated.
|
||
- `aProjectSwitchAsksAboutUnsavedEditsAndSavesThem`: answer save: root becomes `/fake/other`; disk has the edited text.
|
||
- `workStillRunningAtASwitchStaysWithTheOldProject`: git shows `a.php` modified; `a.php` open; hold the next read of `a.php`; perform git discard of `a.php` and confirm; once the read waits, switch to recent project `/fake/other`; open the gate; settle: root `/fake/other`, a new editor instance, and the new editor has no state for `a.php` (the old project's late result never leaks into the new one).
|
||
|
||
#### State / WorkspaceCloseTests file, suite WorkspaceShortcutTests
|
||
|
||
- `theRowMenuAnchorsToTheReportedRowFrame`: focus explorer, move row cursor +1, report the selected row's frame (250, 312, 200 x 26), open the row menu: a context menu opens anchored at y 316 and x = the right edge of the explorer column.
|
||
- `commandASelectsTheOpenFile`: with `a.php` open, select-all-in-file changes the editor's select-all request.
|
||
- `zoomStepsAndIsRemembered`: zoom bigger twice gives zoom level 1 (steps of 0.5) and saves 1; zoom reset gives text scale 1 (scale = 1.2 ^ level).
|
||
|
||
#### SourceControl / SourceControlStoreTests
|
||
|
||
Setup: a source-control store on `FakeGit` with the simple test derivation, toasts recorded, refreshed once. Console lines have a text and a kind (command, output, staged, unstaged, hint, error, success). The sample snapshot (branch `main`) has seven rows, in order:
|
||
|
||
1. `src/b.php` modified, unstaged
|
||
2. `src/a.php` added, staged
|
||
3. `README.md` modified, unstaged
|
||
4. `src/a.php` modified, unstaged
|
||
5. `config/app.json` modified, staged
|
||
6. `src/c.php` deleted, unstaged
|
||
7. `new.txt` added, unstaged
|
||
|
||
- `refreshDerivesTheRowsFromGit`: loaded; is a repository; staged path count 2; changed (distinct) path count 6; dirty.
|
||
- `aProjectWithoutGitReadsAsNotARepository`: a nil snapshot: loaded; not a repository; not dirty.
|
||
- `anOlderSlowerRefreshCannotOverwriteANewerOne`: first load returns `old.txt` after 150 ms, second returns `new.txt` at once; start the slow refresh, wait until it loaded, run a second refresh: the final changes are [`new.txt`].
|
||
- `theDerivationRunsOffTheMainThread`: the derivation closure is called once, not on the main thread.
|
||
- `aFailedStatusReadStillLoadsAndLogsItsErrorOnce`: loads throw an error described `index.lock exists`; two refreshes: loaded; console lines exactly [`status failed: index.lock exists`] of kind error (logged once, not per refresh). After the error clears, a refresh shows the tree dirty.
|
||
- `loadIfNeededReadsGitOnlyOnce`: after the initial refresh, load-if-needed does not load again (loads 1).
|
||
- `theExplorerLetterComesFromTheUnstagedRow`: Explorer statuses: `src/a.php` modified (from its unstaged row, not added), `config/app.json` modified, `src/c.php` deleted.
|
||
- `rowsFallIntoTheFourSectionsStagedFirst`: sections staged, changed, untracked, deleted; staged `src/a.php`, `config/app.json`; changed `src/b.php`, `README.md`, `src/a.php`; untracked `new.txt`; deleted `src/c.php`.
|
||
- `sectionsStartOpenAndRowsStartClosed`: section changed is open; toggling closes it; toggling again opens it. The first changed row is not expanded; toggling it gives expanded rows {`changed:w:src/b.php`}; toggling again empties the set.
|
||
- `anExpandedRowShowsItsOwnHalfOrTooBig`: with the real derivation, `a.txt` (`1\n2\n` -> `1\nX\n`) and a too-big `big.bin`: the detail of the first row is a non-empty list of inline diff rows; the detail of the second is "too big".
|
||
- `stagingLogsTheExactCommandThenItsOutput`: `add` streams stderr `warning: LF will be replaced`; staging `src/b.php` runs exactly [`add`, `--`, `src/b.php`]; console texts `$ git add -- src/b.php`, `warning: LF will be replaced` with kinds command, output; git reloaded (loads 2).
|
||
- `stagingEveryUnstagedPathStillListsThePaths`: staging all unstaged paths runs `add -- <every path>`, never `-A`.
|
||
- `twoQuickActionsRunOneAfterTheOther`: `add -- src/b.php` takes 150 ms; two stage actions started at once run strictly in sequence: events `start add -- src/b.php`, `end add -- src/b.php`, `start add -- README.md`, `end add -- README.md`; console texts the two command echoes in that order.
|
||
- `unstagingARenameTakesItsSourceAlong`: staged rename `new.txt` from `old.txt` plus staged `other.txt`; unstaging `new.txt` runs [`restore`, `--staged`, `--`, `new.txt`, `old.txt`].
|
||
- `discardLeavesAConflictAlone`: rows `both.txt` unmerged and `src/b.php` modified: discarding [`both.txt`] runs nothing; discarding [`both.txt`, `src/b.php`] runs only [`restore`, `--`, `src/b.php`].
|
||
- `unstagingLogsRestoreStaged`: unstaging [`config/app.json`] runs `restore --staged -- config/app.json`; unstaging both staged paths [`src/a.php`, `config/app.json`] (all staged) runs `restore --staged .`.
|
||
- `withoutCommitsUnstagingFallsBackToRmCached`: `restore` exits 128 with stderr `fatal: could not resolve HEAD`; unstaging `config/app.json` runs `restore --staged -- config/app.json` then `rm --cached -r -- config/app.json`; console texts the first echo, the fatal line, the second echo, with kinds command, error, command.
|
||
- `outputIsClassifiedPerCommand`: console input `status` whose stdout is `Changes to be committed:`, `\tmodified: a.php`, `Untracked files:`, `\tnew.txt`, `hint: use git add`: kinds command, output, staged, output, unstaged, hint.
|
||
- `linesFromAnotherThreadArriveInOrderBeforeTheActionEnds`: console input `log -n 50` streaming `line 1` ... `line 50`: console texts `$ git log -n 50` followed by all 50 lines in order.
|
||
- `discardingModifiedFilesAsksWithTheRevertCopy`: discard [`src/b.php`]: title `Discard changes to src/b.php?`, body `This reverts to the last commit and cannot be undone.`, confirm label `Discard`. Discard of 2 files: title `Discard changes to 2 files?`.
|
||
- `deletingNewFilesAsksWithTheDeleteCopy`: discard [`new.txt`]: title `Delete new.txt?`, body `New files are removed from disk. This cannot be undone.`, label `Delete`. Mixed [`new.txt`, `src/b.php`]: title `Discard changes to 2 files?`, body the new-files text.
|
||
- `restoringDeletedFilesNeverAsks`: discarding (restoring) deleted `src/c.php` asks nothing.
|
||
- `theConfigCanSwitchTheQuestionOff`: with confirmDiscard off, discarding `src/b.php` asks nothing; copy reference never asks.
|
||
- `discardRestoresTrackedFilesAndCleansNewOnes`: `clean` streams `Removing new.txt`; discarding `src/b.php`, `new.txt`, `src/c.php` runs `restore -- src/b.php src/c.php` then `clean -f -- new.txt`; console texts `$ git restore -- src/b.php src/c.php`, `$ git clean -f -- new.txt`, `Removing new.txt`.
|
||
- `commitAlwaysRunsGitEvenWithNothingStagedOrNoMessage`: only an unstaged change; `commit` exits 1 with `no changes added to commit (use "git add" and/or "git commit -a")`; committing with message `fix it` and then with an empty message runs `commit -m "fix it"` and `commit -m ""`; the first console text is `$ git commit -m "fix it"` and `$ git commit -m ""` appears; the message field was focused once (for the empty message); toasts `Commit failed` twice.
|
||
- `aSuccessfulCommitClearsTheMessageAndCountsDistinctFiles`: message `add the payment service ` (trailing space): can commit; runs `commit -m "add the payment service"` (trimmed); the message is cleared; toast `Committed 2 files`.
|
||
- `aFailedCommitKeepsTheMessage`: `commit` exits 1 with `error: hook failed`: message `wip` is kept.
|
||
- `theReadyLookNeedsAStagedFileAndAMessage`: with staged files: empty message -> cannot commit; ` ` -> cannot; `fix it` -> can. With no staged files and `fix it` -> cannot.
|
||
- `theMessageFieldGrowsWithWrappedLinesWithinItsBounds`: height of `` and of `fix it` at width 800 = the minimum; 30 x `word ` at width 300 is between minimum and maximum; 400 x `word ` at width 300 = the maximum.
|
||
- `dictatedMessagesBecomeOneLowercaseLine`: setting `Fix The Bug\n And The Test` stores `fix the bug and the test`.
|
||
- `commitAndPushPushesOnlyAfterASuccessfulCommit`: message `ship it`, commit-and-push runs `commit -m "ship it"` then `push`. When commit fails (`error: hook failed`), only the commit runs.
|
||
- `aPushWithoutUpstreamRetriesWithTheBranch`: branch `feature`; `push` exits 128 with `fatal: The current branch feature has no upstream branch.`; `push -u origin feature` streams ` * [new branch] feature -> feature`: runs `push` then `push -u origin feature`; the console contains `$ git push -u origin feature`; the last line kind is success; not busy afterwards; toast `Pushed to origin/feature`.
|
||
- `aRejectedPushIsAnErrorInTheConsoleAndAToast`: `push` exits 1 with ` ! [rejected] main -> main (fetch first)` and `hint: Updates were rejected`: runs only `push`; kinds command, error, hint; toast `Push failed`.
|
||
- `aFailureToastShowsTheErrorLineNotTheTrailingHint`: push fails with lines `To origin.git`, ` ! [rejected] main -> main (non-fast-forward)`, `error: failed to push some refs to 'origin.git'`, `hint: See the 'Note about fast-forwards' in 'git push --help' for details.`: the toast detail is `! [rejected] main -> main (non-fast-forward)` (the first error line, trimmed). Pull fails with `something went wrong`, `hint: try again`: toast title `Pull failed`, detail `something went wrong`.
|
||
- `aPullToastsTheCommitsItWasBehind`: behind 3 of `origin/main`: pull runs `pull --no-rebase`; toast `Pulled 3 commits from origin/main`.
|
||
- `aDivergedPullMergesInsteadOfAskingHowToReconcile`: ahead 1, behind 2: the first console text is `$ git pull --no-rebase`; it contains `Merge made by the 'ort' strategy.`; toast `Pulled 2 commits from origin/main`.
|
||
- `switchingIsRefusedWhileDirtyWithoutAskingGit`: with the dirty sample, switching to `develop` returns false, runs nothing, toasts `— Commit or discard 6 files before you switch.`.
|
||
- `aCleanTreeSwitchesClearsExpandedRowsAndToasts`: clean tree, branches local `develop`, `main`, remote `origin/main`: switching to `develop` returns true; runs `switch develop`; first console text `$ git switch develop`; branches reloaded (local `develop`, `main`); expanded rows cleared; toast `Switched to develop`.
|
||
- `aRemoteBranchSwitchesByItsLocalName`: switching to remote `origin/feature/login` runs `switch feature/login`.
|
||
- `theCurrentBranchIsNoSwitch`: on `main`, switching to `main` or to remote `origin/main` returns false and runs nothing.
|
||
- `clearEmptiesTheLogWithoutGit`: after staging, console input `clear` empties the log and runs no git command.
|
||
- `aBareLogRunsTheShortLogAndALeadingGitIsOptional`: console input `git log` runs `log --oneline --decorate -n 30`; input `commit -m "two words"` runs `commit -m "two words"`; first console text `$ git log --oneline --decorate -n 30`; the input field is cleared.
|
||
- `upRecallsThePreviousCommands`: recall with no history leaves the input empty; after submitting `status` and `branch -a`, recall gives `branch -a`, then `status`, then stays at `status`.
|
||
- `theLogKeepsTheLast400Lines`: `log` streaming `line 1` ... `line 450` (plus the echo): the console keeps 400 lines, the last `line 450`, the first `line 51`; all line ids are unique.
|
||
- `openingTheViewFetchesOnlyWithAnOrigin`: clean tree, author `Jonathan van Rij <jonathan@blijnder.nl>`: opening the view reads the author and runs nothing (no origin). With branches remote `origin/main`, opening again runs `fetch origin`; first console text `$ git fetch origin`.
|
||
- `anUpstreamOnOriginIsEnoughToFetch`: ahead 1 with upstream `origin/main`: opening the view runs `fetch origin`; sync label `1 ahead of origin`.
|
||
- `pollingReReadsGitOnTheIntervalUntilStopped`: interval 20 ms: polling starts; git loads reach at least 3; after stop, not polling; 100 ms later at most one more load happened.
|
||
- `aZeroIntervalDisablesPolling`: interval 0: starting polling does nothing.
|
||
|
||
#### State / WorkspaceModelTests, suite WorkspaceModelLifecycleTests (all on `WorkspaceHarness`, root `/fake/project`, immediate timings)
|
||
|
||
- `startingAProjectLoadsEverythingOnceAndWatchesIt`: git shows `a.php` modified; after start: ready; config resolved once; git loaded once; tree loaded once; source-control changes [`a.php`]; the Explorer has a tree; the last watcher was started on the project root; the project is first in recent projects; git polling is on.
|
||
- `startingTwiceDoesNotLoadTwice`: starting twice loads git once.
|
||
- `theSessionIsRestoredOnlyWhenTheConfigSaysSo`: stored session for `/fake/project` with active `README.md` (`# hi`): with `session.restoreOnLaunch = false` nothing is open; with defaults `README.md` is open with text `# hi`.
|
||
- `theConfigReachesEveryStore`: config with confirmDiscard false, defaultDiffMode diff, tabSize 2: source control has confirmDiscard false; editor default mode diff; editor tab size 2; terminal configured.
|
||
- `aConfigChangeIsReappliedEverywhere`: after start, the config changes to ai.command `other-agent`, confirmDiscard false, tabSize 8 and a config event arrives: model config command `other-agent`; terminal config command `other-agent`; source control confirmDiscard false; editor tab size 8.
|
||
- `withoutAProjectTheWindowIsTheLauncher`: no root, recents [`/code/a`]: root nil; ready; launcher recents equal the given list; git never loaded; no watcher made.
|
||
- `openingAProjectFromTheLauncherSwitchesTheWindow`: from the launcher, open `/fake/other`: root `/fake/other`; name `other`; an editor exists; git loaded once; recent projects [`/fake/other`].
|
||
- `switchingProjectsEndsTheOldProjectCleanly`: with `a.php` open, switching to `/fake/other` stops the first watcher, makes a second watcher, terminates the agent pane once, and saves the old session with active `a.php`.
|
||
- `closingTheWindowSavesAndEndsTheTerminals`: with `a.php` open, window-will-close terminates the agent once, saves the session (active `a.php`), and stops git polling.
|
||
- `reopeningTheSameProjectOnlyClosesTheLauncher`: with the recent-projects overlay open, opening the same root closes the overlay and does not reload git (loads 1).
|
||
- `theClassListLoadsAfterLaunch`: declared symbols {`User`}: after start the editor's known symbols are {`User`}.
|
||
|
||
#### State / WorkspaceModelTests, suite WorkspaceModelRefreshTests
|
||
|
||
- `aBurstOfFileEventsBecomesOneRefresh`: 5 project events and 1 git event, then settle: git loads 2, tree loads 2, symbol invalidations 1 (one coalesced refresh).
|
||
- `aProjectEventRereadsOpenFilesAndTheClassList`: `a.php` open (`one`); disk -> `two`, declared {`Order`}; project event: editor text `two`, known symbols {`Order`}.
|
||
- `aProjectEventKeepsUnsavedEdits`: `a.php` edited to `typing`; disk -> `agent`; project event: text stays `typing`.
|
||
- `aGitEventRefreshesOnlyGit`: a git event: git loads 2, tree loads still 1.
|
||
- `watcherEventsArriveFromAnyThread`: the fake watcher emits a git event from a background thread: git loads eventually reach 2.
|
||
- `commandRLetsTheDiskWinAndFlashes`: `a.php` edited to `typing`, disk `agent`; the refresh command: refresh tick 1; text `agent`; git loads 2; tree loads 2.
|
||
- `openingTheGitViewRefreshesGitOnce`: toggle git then focus commit message, settle: git loads 2 (one extra read, not two).
|
||
- `savingAFileRefreshesGit`: `a.php` edited to `two`, save command: writes [`two`]; git loads 2; toasts [`Saved`].
|
||
|
||
#### State / WorkspaceModelTests, suite WorkspaceModelActionTests
|
||
|
||
- `openingAFileRevealsItAndWidensTheEditor`: open `src/Http/Kernel.php` at line 4: active path that file; cursor line 4; Explorer expanded {`src`, `src/Http`}; Explorer selection that file; layout focus zone editor.
|
||
- `aTooBigFileIsSelectedButNotOpened`: open `composer.lock`: nothing active; too big = `composer.lock`; Explorer selection `composer.lock`.
|
||
- `copyReferenceUsesThePasteboardAndToastsOnce`: with a context menu open for file `a/b.php`, copy reference `a/b.php`: copied [`a/b.php`]; overlay closed; toasts [`Copied reference`].
|
||
- `deleteAsksFirstThenForgetsTheFile`: `README.md` open; delete it: a confirm overlay with title `Delete file?` and nothing deleted yet. Confirm: overlay closed; deleted [`README.md`]; nothing active; toasts [`Deleted file`].
|
||
- `discardAsksUnderTheConfigThenReloadsTheFile`: git shows `a.php` modified, `a.php` = `edited` open; git discard of `a.php`: confirm overlay with label `Discard`, no git yet. Disk becomes `committed`; confirm: git ran `restore -- a.php`; editor text `committed`.
|
||
- `stagingRunsGitStraightAway`: stage [`a.php`] runs `add -- a.php` at once; no overlay.
|
||
- `revealInFinderResolvesAgainstTheProject`: reveal `` and `src/app.php`: revealed the root path and `<root>/src/app.php`.
|
||
- `aNewFileFromThePromptIsCreatedAndOpened`: context menu on folder `src` at (10, 20); new file: a name prompt anchored at (10, 20). Submitting `Router.php`: created [`src/Router.php`]; it is open; toasts [`Created file`].
|
||
- `renamingCarriesTheOpenFileOver`: `src/app.php` open; rename: name prompt with initial name `app.php`; submit `main.php`: active `src/main.php`; Explorer selection `src/main.php`; toasts [`Renamed file`].
|
||
- `commitAndPushToastOnce`: staged `a.php`, message `fix it`; commit runs `commit -m "fix it"`; push runs `push`; toasts exactly [`Committed 1 file`, `Pushed to origin/main`].
|
||
- `commitWithoutAMessageStillAsksGitThenFocusesTheMessage`: commit exits 1 with `Aborting commit due to empty commit message.`: runs `commit -m ""`; focus request targets the commit message; toasts [`Commit failed`].
|
||
- `theRowMenuOpensTheFileAndClosesTheGitView`: git view open, context menu on git row `a.php`, open file `a.php`: git view closed; no overlay; `a.php` active.
|
||
- `thePassOnPromptInsertsIntoTheAgent`: pass on reference `a.php:3`, then pass to agent (text and reference `a.php:3`): the agent received exactly 1 send; overlay closed; toasts [`Passed to agent`].
|
||
- `bouwenInsertsTheCommandIntoTheAgent`: bouwen `2026-10-02-001-x` sends exactly the bracketed paste of `/bouwen 2026-10-02-001-x` (empty composer); toasts [`Passed to agent`].
|
||
- `aDirtyTabAsksBeforeItCloses`: `a.php` edited; close-file-or-window with cancel: asked [`a.php`], still active. With discard: nothing active.
|
||
- `cancellingTheUnsavedPromptLeavesTheExplorerAndFocusAlone`: `a.php` edited, focus zone terminal, cancel; opening `b.php`: asked [`a.php`]; active stays `a.php`; Explorer selection `a.php`; focus zone still terminal.
|
||
- `aFailedSaveLeavesTheExplorerOnTheDirtyFile`: answer save, writes fail; opening `b.php`: active stays `a.php`; Explorer selection `a.php`.
|
||
- `savingOnTheUnsavedPromptThenRevealsTheNewFile`: answer save; opening `b.php`: disk a = `two`; active `b.php`; Explorer selection `b.php`.
|
||
- `commandWWithoutAnOpenFileClosesTheWindow`: with no file open, close-file-or-window calls the close-window hook.
|
||
|
||
#### State / WorkspaceModelTests, suite WorkspaceModelFocusTests
|
||
|
||
- `focusCommandsRequestFirstResponder`: focus explorer: active panel explorer; focus request target panel explorer. Focus neighbour +1: request target panel editor.
|
||
- `commandCOpensTheGitViewOnItsMessageField`: focus commit message opens the git view with a focus request on the commit message; after the field reports it took focus, doing it again still leaves the git view open and requests the commit message again.
|
||
- `commandGTogglesTheGitViewAndClosingGivesTheKeyboardBack`: focus terminal, toggle git: open, focus request commit message, all panes still visible. Toggle git again: closed, focus request panel terminal.
|
||
- `closingTheGitViewWithNoActiveColumnDropsTheFieldRequest`: toggle git, close git view: closed and no focus request; closing again keeps it closed.
|
||
- `paneTogglesLeaveTheGitViewAlone`: with the git view open, toggling the explorer hides it and the git view stays open.
|
||
- `aPaneToggleHidesItsColumnAndAHiddenColumnTakesNoFocus`: focus terminal, hide terminal: hidden, no active panel. Focus editor, then focus terminal: active stays editor, request panel editor. Toggle terminal: visible.
|
||
- `rowCursorKeysDriveOnlyTheExplorer`: with the editor focused, moving the row cursor does not change the Explorer selection. With the explorer focused, +10 twice selects `README.md` (clamped last row); open selected row opens `README.md`.
|
||
- `commandRightOnARowOpensItsMenuBesideTheColumn`: focus explorer, +1 (selects `src`), open row menu: a context menu for directory `src`, anchored at x = right edge of the explorer column.
|
||
- `comingBackToTheWindowFlashesBranchAndProjectButLaunchDoesNot`: the first become-key does not show the focus flash; after resign-key and become-key it shows, and it eventually hides again.
|
||
|
||
#### State / WorkspaceModelTests, suite WorkspaceModelOverlayTests
|
||
|
||
- `escClosesOnlyTheOneOpenOverlay`: show shortcuts, then search(seed `x`): current is search `x`; dismiss: none.
|
||
- `aContextMenuActionReplacesTheMenuWithItsPrompt`: context menu on `src/a.php` at (300, 120), pass on reference: overlay is pass-on(reference `src/a.php`, anchor (300, 120)).
|
||
- `theDiffOverlayGivesBackTheModeItCovered`: changed `a.md` open; preview, then diff: overlay is diff(path `a.md`, side none); dismiss: mode back to preview.
|
||
- `showDiffOpensTheDiffOfTheOpenFileAtThatLine`: changed `a.php` open; show diff at line 3: overlay diff(path `a.php`, side none, focus line 3).
|
||
- `theRecentProjectListLeavesOutTheOpenProject`: recents [`/elsewhere`]; show recent projects: overlay launcher; other recent projects [`/elsewhere`].
|
||
- `activatingTheNewProjectRowAsksForAFolder`: launcher, chosen folder `/fake/chosen`; launcher-activate (first row): root becomes `/fake/chosen`.
|
||
- `searchTakesTheTypedSeed`: show search(seed `typed`) shows search `typed`.
|
||
|
||
#### State / WorkspaceModelTests, suite TerminalContextMenuModelTests
|
||
|
||
- `aRightClickInATerminalOpensTheAppMenuAtThePointer`: a right-click in the agent pane with a selection at (900, 300) opens a context menu with labels `Copy`, `Paste`, `Read aloud selection`, `Plak`, `Wait what?`, no header, anchored at (900, 300).
|
||
- `copyPutsTheSelectionOnThePasteboard`: agent selection `npm test`; copy: copied [`npm test`].
|
||
- `waitWhatInsertsTheSelectionAsAWaitWhatCommand`: agent selection ` the reviewer was unsure\n`; wait-what sends exactly the bracketed paste of ``/wait-what `the reviewer was unsure` `` (trimmed, in backticks); toasts [`Passed to agent`].
|
||
- `readAloudSelectionReadsTheSelectionAsProse`: agent selection ` Run **npm test** first.\n` speaks [`Run npm test first.`]; reading is active.
|
||
- `readAloudSelectionReadsTheShellSelection`: shell selection "```\nls -la\n```" speaks it unchanged.
|
||
- `readAloudSelectionWithBlankTextSaysSo`: agent selection ` \n`: nothing spoken; toasts [`Nothing to read`].
|
||
- `plakSendsTheTrimmedSelection`: agent selection ` npm test\n`: Plak got [`npm test`].
|
||
- `plakSendsTheShellSelection`: shell selection `ls -la`: Plak got [`ls -la`].
|
||
- `plakWithBlankSelectionSaysSo`: agent selection ` \n`: nothing sent; toasts [`Nothing to send`].
|
||
- `plakSendsTheEditorSelection`: plak `\n $a = 1;\n` sends [`$a = 1;`].
|
||
- `plakWithBlankEditorTextSaysSo`: plak ` \n `: nothing sent; toasts [`Nothing to send`].
|
||
- `pasteSendsThePasteboardToThatTerminal`: clipboard `git status`; paste into shell: shell pasted [`git status`]; agent pasted nothing.
|
||
- `menuIconsUseThePlainTint`: copy and paste terminal actions use the plain tint; icons: copy `doc.on.doc`, paste `doc.on.clipboard`; read aloud selection plain tint, icon `speaker.wave.2`; Plak (terminal and editor) plain tint, icon `note.text.badge.plus`. (SF Symbol names; a rebuild picks equivalent icons.)
|
||
- `aProjectSwitchKeepsTheTerminalMenuWired`: after switching project the terminal store still has its context-menu handler.
|
||
|
||
#### State / WorkspaceModelTests, suite ReadAloudModelTests
|
||
|
||
- `aMarkdownFileIsReadAsPlainText`: `README.md` = "# Hello\n\nSome **bold** [link](https://x.com)\n\n```\ncode\n```"; read aloud file: spoken [`Hello.\nSome bold link.`]; reading active.
|
||
- `theOpenFileIsReadWithItsUnsavedEdits`: `README.md` on disk `On disk`, open and edited to `Typed`: spoken [`Typed.`].
|
||
- `aFileWithoutProseReadsNothingAndSaysSo`: a code-only `README.md`: nothing spoken; not reading; toasts [`Nothing to read`].
|
||
- `aSelectionIsReadAsItIs`: read aloud text `let a = 1` speaks [`let a = 1`].
|
||
- `aDollarSignIsReadAsDollar`: `echo $HOME costs $5` speaks [`echo dollar HOME costs $5`].
|
||
- `stopEndsTheReading`: read `words`, then stop reading: speech stops 1; not reading.
|
||
- `readingToTheEndClearsTheState`: read `words`; the voice finishes: not reading.
|
||
- `aProjectSwitchStopsTheReading`: reading `words`, switch project: not reading; speech stops 1.
|
||
- `readAloudUsesTheSpeakerIcon`: read aloud file icon `speaker.wave.2`; read aloud text plain tint.
|
||
|
||
|
||
---
|
||
|
||
|
||
---
|
||
|
||
## Appendix — original user guide and reference docs (verbatim)
|
||
|
||
These are the original user-facing docs, copied as they were in the repo. They show the intended feel, the ASCII sketches and the wording of each area. **Where they disagree with sections 1–8, sections 1–8 win** (those were checked against the code, and each lists its doc-vs-code conflicts). Links inside them point at files that are not part of this handoff; follow the section of the same name above instead.
|
||
|
||
---
|
||
|
||
### Appendix: guide/index.md
|
||
|
||
#### Helder user guide
|
||
|
||
This guide explains Helder from the user's side: what each part of the window shows, and what you can do there. Each page covers one area and has an ASCII sketch of it.
|
||
|
||
[Docs index](../index.md)
|
||
|
||
##### The window
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| (1) Helder console / src / app.php [Explorer][File][Claude] [Git 2] .. ? |
|
||
| (2) |
|
||
+----------------+-----------------------------------+-----------------------+
|
||
| (3) EXPLORER | (4) FILE | (5) CLAUDE |
|
||
| > src | 12 function handle() { | > _ |
|
||
| app.php | 13 return true; | |
|
||
| > tests | 14 } +-----------------------+
|
||
| | | (6) TERMINAL |
|
||
| | | $ _ |
|
||
+----------------+-----------------------------------+-----------------------+
|
||
| (7) main +50 -38 Ln 12, Col 4 UTF-8 PHP |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
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.
|
||
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.
|
||
6. [Command line](command-line.md): a shell in the project folder.
|
||
7. [Status bar](status-bar.md): branch, totals and cursor details.
|
||
|
||
##### All areas
|
||
|
||
###### Window and project
|
||
|
||
- [Layout](layout.md): columns, splitters, pane toggles, Fluid and Hidden.
|
||
- [Title bar](title-bar.md): the bar across the top.
|
||
- [Status bar](status-bar.md): the bar across the bottom.
|
||
- [Start screen](start-screen.md): the window before a project is open.
|
||
- [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](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.
|
||
- [Explorer](explorer.md): browse, create, rename and delete files.
|
||
|
||
###### The file view
|
||
|
||
- [File view](file-view.md): open, read and edit one file.
|
||
- [File view: Markdown](file-view-markdown.md): Markdown source and rendered preview.
|
||
- [File view: Diff](file-view-diff.md): the full-screen side-by-side comparison.
|
||
- [Code symbols](code-symbols.md): PHP symbol lookup.
|
||
- [Pass on to Agent](pass-on-to-agent.md): send code references to Claude.
|
||
|
||
###### Agent and terminal
|
||
|
||
- [Claude Code](claude-code.md): the agent pane.
|
||
- [Command line](command-line.md): the shell pane.
|
||
- [Clean copy](clean-copy.md): text Claude hands you to copy, through `.clean-copy`.
|
||
|
||
###### Finding things
|
||
|
||
- [Search](search.md): search file contents and names at once.
|
||
- [Go to file](go-to-file.md): the Recent files list, to jump back to a file you had open.
|
||
|
||
###### Menus, dialogs and keys
|
||
|
||
- [Right-click menu](right-click-menu.md): every context menu in one place.
|
||
- [Dialogs](dialogs.md): confirmations and name prompts.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every shortcut, grouped by area.
|
||
- [Configuration](configuration.md): every setting in `.helder/config.json`.
|
||
|
||
---
|
||
|
||
### Appendix: guide/title-bar.md
|
||
|
||
#### 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.
|
||
|
||
[Guide index](index.md) · Related: [Window layout](layout.md), [Search](search.md), [Keyboard shortcuts](keyboard-shortcuts.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| 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) |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
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] [?] |
|
||
```
|
||
|
||
1. **Window buttons**: the macOS close, minimize and zoom buttons.
|
||
2. **Wordmark**: "Helder" with a blinking amber dot.
|
||
3. **Project name**: the project folder's name. Click it to open another folder.
|
||
4. **Branch**: the current git branch, in amber.
|
||
5. **Breadcrumb**: the path of the open file, folder by folder.
|
||
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.
|
||
|
||
##### Features
|
||
|
||
###### Wordmark, project and branch
|
||
- The wordmark sits right after the window buttons. In full screen the window buttons are gone, and everything moves left.
|
||
- The project name is dim and turns brighter on hover. Click it to open a folder picker and switch this window to another project. See [Recent projects](recent-projects.md).
|
||
- A middle dot separates the project name from the branch.
|
||
- The branch shows in amber. It shows `—` when the folder has no git branch.
|
||
|
||
###### Breadcrumb
|
||
- Shows the path of the open file, with `›` between the parts, for example `resources › views › form.blade.php`.
|
||
- Folder names are dim. The file name is bright and bold.
|
||
- An amber dot after the file name means the file has unsaved edits. Hover it to read "Unsaved changes".
|
||
- When the path is too long, it cuts off at the start, so the file name stays visible.
|
||
- With no file open, the space is empty.
|
||
- The breadcrumb is for reading only. Clicking it does nothing.
|
||
|
||
###### Pane toggles
|
||
- Three buttons in one box: **Explorer**, **File**, **Claude**.
|
||
- Each shows or hides its column. A dot on the button shows that the column is on. `Cmd+1`, `Cmd+2` and `Cmd+3` do the same.
|
||
- The hover tooltip says whether the column is shown, and what a click does.
|
||
- The toggles sit in the centre of the window. They only move left when the toolbar would run into them.
|
||
- Hiding a column keeps everything inside it. See [Window layout](layout.md).
|
||
|
||
###### 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.
|
||
- **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.
|
||
|
||
###### 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.
|
||
- It sits left of **Git**, in the same style, and its dot is on. The tooltip says "Read aloud: playing. Click to stop."
|
||
- Click it to switch it off: the reading stops and the button goes away.
|
||
- The button also goes away when the reading reaches the end. Switching projects or closing the window stops the reading.
|
||
|
||
###### Moving the window
|
||
Drag an empty part of the title bar to move the window, as in any macOS app.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+F` | Search |
|
||
| `Cmd+L` | Fluid column widths on or off |
|
||
| `Cmd+.` | Hidden files on or off |
|
||
| `Cmd+G` | Open or close the Git view |
|
||
| `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) |
|
||
|
||
##### Related
|
||
|
||
- [Window layout](layout.md): what the pane toggles, Fluid and Hidden do to the columns.
|
||
- [Git](git.md): the view the Git 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.
|
||
- [Status bar](status-bar.md): the matching bar at the bottom of the window.
|
||
- [Right-click menu](right-click-menu.md): where Read aloud starts.
|
||
|
||
---
|
||
|
||
### Appendix: guide/layout.md
|
||
|
||
#### Window layout
|
||
|
||
A Helder window holds one project. It has a title bar on top, three columns in the middle and a status bar at the bottom. The [Git](git.md) view (`Cmd+G`) covers all of it when open.
|
||
|
||
[Guide index](index.md) · Related: [Title bar](title-bar.md), [Status bar](status-bar.md), [Keyboard shortcuts](keyboard-shortcuts.md), [Configuration](configuration.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| ooo Helder. shop . main app>User.php [Git 3|Expl|File|Claude] [Search] [?]|
|
||
| (1) |
|
||
+-----------------+-------------------------------------+--------------------+
|
||
| EXPLORER | User.php +12 -3 | (claude running) |
|
||
| | | |
|
||
| > app | 1 <?php | > _ |
|
||
| v Http | 2 | (4) |
|
||
| User.. | 3 class User | |
|
||
| > config | 4 { | |
|
||
| > routes | 5 ... +--------------------+
|
||
| .env | | $ zsh |
|
||
| | | |
|
||
| (2) | (3) | (5) |
|
||
+-----------------+-------------------------------------+--------------------+
|
||
| main +50 -38 1 staged . 2 unstaged app/User.php . Ln 3, Col 1 . PHP |
|
||
+----------------------------------------------------------------------------+
|
||
^ ^ (6)
|
||
(7) (7)
|
||
```
|
||
|
||
1. **Title bar**: wordmark, project and branch, breadcrumb, the pane toggles, and the toolbar with the Git toggle. See [Title bar](title-bar.md).
|
||
2. **Explorer column**: the project file tree. See [Explorer](explorer.md).
|
||
3. **File column**: the one open file. See [File view](file-view.md).
|
||
4. **Claude pane**: the agent terminal, top of the right column. See [Claude Code](claude-code.md).
|
||
5. **Shell pane**: a plain terminal, bottom of the right column. See [Command line](command-line.md).
|
||
6. **Status bar**: branch, change counts and file facts. See [Status bar](status-bar.md).
|
||
7. **Splitters**: the thin lines between columns. Drag them to resize.
|
||
|
||
##### Features
|
||
|
||
###### The three columns
|
||
- From left to right: **Explorer**, **File**, and **Claude + Terminal**.
|
||
- Git is not a column. The full-screen [Git](git.md) view opens over the window with `Cmd+G` and leaves the columns as they were.
|
||
- The File column is the flexible one. It takes the width the other columns leave.
|
||
- The right column holds two terminals stacked on top of each other: Claude on top, a shell below.
|
||
|
||
###### Splitters and resizing
|
||
- A splitter is a 1-point line. It turns amber when you hover or drag it, and the pointer becomes a resize arrow.
|
||
- Drag a vertical splitter to change a column's width.
|
||
- Drag the horizontal splitter in the right column to share the height between Claude and the shell.
|
||
- Columns have limits, so you cannot drag them away:
|
||
- Explorer: 160 to 520 points wide.
|
||
- File: at least 280 points wide.
|
||
- Claude + Terminal: at least 280 points, and never so wide that File drops below 280.
|
||
- The Claude pane takes between 18% and 82% of the right column's height.
|
||
- Dragging a column splitter switches **Fluid** off. The widths you set then stay put.
|
||
|
||
###### Fluid column widths (`Cmd+L`)
|
||
- With **Fluid** on, Helder sizes the columns for you. It re-fits them when you resize the window and when focus moves.
|
||
- At a window width of 1600 points or more, the columns keep fixed shares: Explorer about 16%, Claude about 27%, File the rest.
|
||
- Below 1600 points, Explorer takes 15%, and the right column follows your focus:
|
||
- 30% when neither side has focus.
|
||
- 20% when the File column has focus, or when you just opened a file.
|
||
- 50% when a terminal has focus.
|
||
- With **Fluid** off, the columns keep the widths you dragged them to.
|
||
- When the window gets too narrow, the fixed columns shrink together, so File keeps at least 280 points.
|
||
- Toggle it with `Cmd+L`, the **Fluid** button in the title bar, or View > Fluid Column Widths / Lock Column Widths.
|
||
|
||
###### Showing and hiding columns
|
||
- Each column has a toggle in the title bar: **Explorer**, **File**, **Claude**. A dot on the button shows that the column is on.
|
||
- `Cmd+1`, `Cmd+2` and `Cmd+3` toggle Explorer, File and Claude. The View menu has Show/Hide items for all three.
|
||
- Hiding only hides. The terminals keep running, the open file keeps its edits and scroll position, and the tree keeps its open folders.
|
||
- When a column hides, File takes the free width. With File hidden, the Claude + Terminal column fills the rest.
|
||
- With every column hidden, the middle of the window is empty.
|
||
- A hidden column cannot take focus. If you hide the column you are typing in, the keyboard goes back to the window, so nothing lands in a pane you cannot see.
|
||
|
||
###### Hidden files (`Cmd+.`)
|
||
- **Hidden** shows or hides dotfiles such as `.env` in the Explorer and in search.
|
||
- It starts off every time you open a project.
|
||
- Toggle it with `Cmd+.`, the **Hidden** button, or View > Show Hidden Files.
|
||
|
||
###### Focus and the active column
|
||
- Click inside a column to make it the active column. The Explorer gets a lighter background when active.
|
||
- `Cmd+Left` and `Cmd+Right` move focus to the next visible column. This works when the keyboard is not inside a text field, the code, or a terminal. In those places the keys keep their normal meaning.
|
||
- In the Explorer, `Up` and `Down` move the row cursor and `Return` opens the row. See [Explorer](explorer.md).
|
||
- Clicking an Explorer row takes the keyboard out of a text field in another column.
|
||
|
||
###### The mouse pointer
|
||
- A pointing hand means a left click runs an action: a button, a clickable row, the project name.
|
||
- An I-beam means a click places the cursor or selects text: the code, the Markdown preview, the terminals and every input.
|
||
- Everywhere else the pointer is an arrow, also over a disabled button and over the columns behind an open dialog or search.
|
||
|
||
###### Refresh (`Cmd+R`)
|
||
- Re-reads git, the file tree and the open file from disk. The disk wins over unsaved edits in the open file.
|
||
- Every column flashes lighter for a moment, so you can see the refresh happened even when nothing changed.
|
||
- Helder also watches the disk and refreshes by itself. `Cmd+R` is for when you want to be sure.
|
||
|
||
###### Zoom
|
||
- View > Zoom In (`Cmd++`), Zoom Out (`Cmd+-`) and Actual Size (`Cmd+0`).
|
||
- Zoom changes the text size of the code, the Diff and both terminals. The rest of the interface stays the same size.
|
||
- Each step is a half step; one whole step is 20% larger. You can go 3 steps down and 5 steps up.
|
||
- The zoom level is shared by all projects and kept between launches.
|
||
|
||
###### Full screen
|
||
- View > Enter Full Screen (`Ctrl+Cmd+F`).
|
||
- In full screen the title bar moves its content left, into the space the window buttons used.
|
||
|
||
###### Windows: one project per window
|
||
- Every window shows exactly one project. There are no tabs.
|
||
- Each window runs as its own Helder app. The Dock and `Cmd+Tab` show the project's title, so you can tell projects apart.
|
||
- **New Window** (`Shift+Cmd+N`, File menu, or the Dock menu) opens a fresh window on the [start screen](start-screen.md).
|
||
- **Open Folder** (`Cmd+O`) and **Open Recent** switch the current window to another project. Helder asks about unsaved files first. See [Recent projects](recent-projects.md).
|
||
- A launch opens one window. macOS does not reopen old windows.
|
||
- The Dock's right-click menu shows the current project's title and a **New Window** item.
|
||
|
||
###### Coming back to a window
|
||
- When you switch back to a Helder window, a small card shows the branch and the project name in the middle of the window for half a second.
|
||
- This tells you at a glance which project you are in. It does not show on launch.
|
||
|
||
###### Closing and quitting
|
||
- `Cmd+W` closes the open file. With no file open, it closes the window.
|
||
- `Shift+Cmd+W` closes the window.
|
||
- Before a window closes, or the app quits with `Cmd+Q`, Helder asks about every file with unsaved edits. It saves the session too. Cancel keeps the window open.
|
||
|
||
###### What Helder remembers
|
||
Per project, always:
|
||
- Which of the three columns are shown.
|
||
- Whether **Fluid** is on.
|
||
- The column widths, when **Fluid** is off.
|
||
|
||
Per project, when `session.restoreOnLaunch` is on (default):
|
||
- The open file and its view (code or Markdown preview). A file that was in the Diff opens on the live file.
|
||
|
||
For all projects together:
|
||
- The zoom level.
|
||
- The height split between Claude and the shell.
|
||
|
||
Not remembered: **Hidden** files (starts off), which column had focus, and whether the Git view was open.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+G` | Open or close the Git view |
|
||
| `Cmd+1` / `Cmd+2` / `Cmd+3` | Show or hide the Explorer, File or Claude column |
|
||
| `Cmd+L` | Fluid column widths on or off |
|
||
| `Cmd+.` | Hidden files on or off |
|
||
| `Cmd+Left` / `Cmd+Right` | Focus the column to the left or right (outside text and terminals) |
|
||
| `Cmd+R` | Refresh git, the tree and the open file |
|
||
| `Cmd++` / `Cmd+-` / `Cmd+0` | Zoom in, zoom out, actual size |
|
||
| `Ctrl+Cmd+F` | Enter or exit full screen |
|
||
| `Shift+Cmd+N` | New window |
|
||
| `Cmd+W` | Close the file, or the window when no file is open |
|
||
| `Shift+Cmd+W` | Close the window |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `session.restoreOnLaunch` | `true` | Reopens the last open file and its view when the project opens |
|
||
|
||
##### Related
|
||
|
||
- [Title bar](title-bar.md): the pane toggles and the Git, Fluid and Hidden buttons live here.
|
||
- [Git](git.md): the full-screen Git view.
|
||
- [Status bar](status-bar.md): the bar along the bottom edge.
|
||
- [Start screen](start-screen.md): what a window shows before a project is open.
|
||
- [Recent projects](recent-projects.md): switch this window to another project.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every shortcut in one list.
|
||
- [Configuration](configuration.md): all per-project settings.
|
||
|
||
---
|
||
|
||
### Appendix: guide/status-bar.md
|
||
|
||
#### Status bar
|
||
|
||
The status bar is the thin 28-point strip along the bottom of a project window. It shows git totals on the left and facts about the open file on the right.
|
||
|
||
[Guide index](index.md) · Related: [Window layout](layout.md), [Git](git.md), [File view](file-view.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| <> main +50 -38 1 staged . 2 unstaged app/User.php . Ln 3, Col 9 . |
|
||
| (1) (2) (3) (4) (5) (6) |
|
||
| |
|
||
| UTF-8 . LF . PHP |
|
||
| (7) (8) (9) |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
The bar is one row in the app. It is drawn on two rows here to fit the page.
|
||
|
||
1. **Branch**: the current git branch, in amber, after a branch symbol.
|
||
2. **Lines added**: the total added lines in the working tree, in teal.
|
||
3. **Lines removed**: the total removed lines, in amber-deep.
|
||
4. **Staged and unstaged**: how many changes are staged and how many are not.
|
||
5. **File path**: the project-relative path of the open file.
|
||
6. **Cursor position**: the line and column of the cursor.
|
||
7. **Encoding**: always `UTF-8`.
|
||
8. **Line ending**: always `LF`.
|
||
9. **Language**: the language of the open file, for example `PHP` or `Markdown`.
|
||
|
||
##### Features
|
||
|
||
###### Git summary (left)
|
||
- The branch, the added and removed line totals, and the staged and unstaged counts.
|
||
- These follow git. They update when you stage, unstage or commit in the [Git](git.md) view, or when files change on disk.
|
||
- The full-screen Git view covers the status bar while it is open.
|
||
|
||
###### File facts (right)
|
||
- The path, the cursor position and the language appear only while a file is open.
|
||
- The path cuts off at the start when it is long, so the file name stays visible. It never takes more than about half the window.
|
||
- The cursor position reads `Ln 1, Col 1` until you move the cursor in the file.
|
||
- `UTF-8` and `LF` are always shown, with or without a file.
|
||
|
||
###### Display only
|
||
Nothing in the status bar is clickable. It only shows information.
|
||
|
||
##### Related
|
||
|
||
- [Git](git.md): where the branch and change counts come from.
|
||
- [File view](file-view.md): the file whose path, position and language are shown.
|
||
- [Title bar](title-bar.md): shows the project, branch and file path at the top.
|
||
- [Window layout](layout.md): where the status bar sits in the window.
|
||
|
||
---
|
||
|
||
### Appendix: guide/start-screen.md
|
||
|
||
#### Start screen
|
||
|
||
The start screen is what a Helder window shows when no project is open. It is a single card near the top of an empty, dark window, with no title bar, columns or status bar.
|
||
|
||
[Guide index](index.md) · Related: [Recent projects](recent-projects.md), [Window layout](layout.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| o o o |
|
||
| +------------------------------------------------+ |
|
||
| | * Helder. (1) | |
|
||
| | Open a project to begin | |
|
||
| +------------------------------------------------+ |
|
||
| | + Open new project... [<-] | (2) |
|
||
| +------------------------------------------------+ |
|
||
| | RECENT (3) | |
|
||
| | [] shop ~/code/shop | (4) |
|
||
| | [] helder ~/code/helder | |
|
||
| | [] blog ~/sites/blog | |
|
||
| +------------------------------------------------+ |
|
||
| | Cmd+Up/Down navigate . Return open (5) | |
|
||
| +------------------------------------------------+ |
|
||
| |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Head**: an amber spark, the Helder wordmark and the line "Open a project to begin".
|
||
2. **Open new project...**: opens the macOS folder picker.
|
||
3. **Recent**: the label above your recent projects. It only shows when there are recent projects.
|
||
4. **Recent project rows**: a folder icon, the project name and its full path.
|
||
5. **Key hints**: how to move and open with the keyboard.
|
||
|
||
##### Features
|
||
|
||
###### When you see it
|
||
- When you start Helder without a project folder.
|
||
- When you open a **New Window** (`Shift+Cmd+N` or the Dock menu).
|
||
- After the last window closes and you click the Dock icon again.
|
||
|
||
###### Opening a project
|
||
- Click **Open new project...**, or select it and press `Return`. A folder picker opens. Choose a folder and click **Open**.
|
||
- Click a recent project, or select it and press `Return`, to open it in this window.
|
||
- `Cmd+O` (File > Open Folder...) also opens the folder picker.
|
||
- After you pick a project, the window turns into the full workspace. See [Window layout](layout.md).
|
||
|
||
###### Moving the selection
|
||
- The first row, **Open new project...**, is selected when the screen opens.
|
||
- `Up` and `Down` (with or without `Cmd`) move the selection. It stops at the first and last row.
|
||
- Hovering a row selects it too. The selected row is highlighted and its icon turns amber.
|
||
- Hover a recent project to see its full path in a tooltip.
|
||
|
||
###### Long lists
|
||
- The card grows with the list. When the list is longer than the window, the rows scroll inside the card.
|
||
- Helder keeps up to 20 recent projects. A project whose folder no longer exists is left out.
|
||
|
||
###### Starting Helder on a folder
|
||
Helder opens a folder straight away, without this screen, when you start it with:
|
||
- the `HELDER_PROJECT` environment variable set to a folder, or
|
||
- a folder path as the first argument.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Up` / `Down` | Move the selection |
|
||
| `Cmd+Up` / `Cmd+Down` | Move the selection |
|
||
| `Return` | Open the selected row |
|
||
| `Cmd+O` | Open the folder picker |
|
||
| `Shift+Cmd+N` | Open another new window |
|
||
|
||
##### Related
|
||
|
||
- [Recent projects](recent-projects.md): the same recent list, inside a project window.
|
||
- [Window layout](layout.md): what the window shows once a project is open.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every shortcut in one list.
|
||
|
||
---
|
||
|
||
### Appendix: guide/recent-projects.md
|
||
|
||
#### Recent projects
|
||
|
||
The **Open recent project** overlay lists the projects you opened before, so you can switch the current window to one of them. It opens with `Shift+Cmd+O` and floats over the top of the window.
|
||
|
||
[Guide index](index.md) · Related: [Start screen](start-screen.md), [Window layout](layout.md), [Title bar](title-bar.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| |
|
||
| +----------------------------------------------------------+ |
|
||
| | [] Open recent project 3 projects . [Cmd+Down] | (1) |
|
||
| | [Cmd+Up] [Return] | |
|
||
| +----------------------------------------------------------+ |
|
||
| | [] helder | (2) |
|
||
| | ~/code/helder | |
|
||
| | [] blog | |
|
||
| | ~/sites/blog | |
|
||
| | [] api | |
|
||
| | ~/code/api | |
|
||
| +----------------------------------------------------------+ |
|
||
| (dimmed workspace behind) (3) |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Header**: a folder icon, the title, the number of projects and the keys to use.
|
||
2. **Project rows**: a folder icon, the project name, and the full path below it.
|
||
3. **Backdrop**: the workspace, dimmed. Click it to close the overlay.
|
||
|
||
##### Features
|
||
|
||
###### Opening the overlay
|
||
- Press `Shift+Cmd+O`, or choose File > Open Recent Project....
|
||
- It only works when a project is open. On the [start screen](start-screen.md), the recent list is already on the screen.
|
||
- The list re-reads the recent projects each time it opens, so a project opened in another window shows up too.
|
||
|
||
###### What the list shows
|
||
- Your recent projects, newest first.
|
||
- The project in this window is left out.
|
||
- Projects whose folder no longer exists are left out.
|
||
- Up to 20 projects are kept.
|
||
- With no other projects, the list reads "No other recent projects".
|
||
- Hover a row to see its full path in a tooltip.
|
||
|
||
###### Choosing a project
|
||
- Click a row, or select it and press `Return`.
|
||
- The current window switches to that project. Helder first asks about any file with unsaved edits. If you cancel, you stay in the current project.
|
||
- The project's terminals restart in the new folder, and its saved layout and open file come back. See [Window layout](layout.md).
|
||
|
||
###### Moving the selection
|
||
- `Up` / `Down` or `Cmd+Up` / `Cmd+Down` move the selection. It stops at the ends.
|
||
- Hovering a row selects it. When you move with the keys, a still mouse does not steal the selection back.
|
||
|
||
###### Closing
|
||
- Press `Esc`, or click the dimmed backdrop.
|
||
|
||
###### Other ways to open a project
|
||
- **File > Open Folder...** (`Cmd+O`), or a click on the project name in the [title bar](title-bar.md): opens the macOS folder picker. The chosen folder replaces the project in this window.
|
||
- **File > Open Recent**: a submenu with the same recent projects, minus the current one. It reads "No Recent Projects" when empty.
|
||
- **File > New Window** (`Shift+Cmd+N`): opens a separate window on the [start screen](start-screen.md), so you can work on two projects side by side.
|
||
- With no Helder window in front, Open Folder and Open Recent open the project in a new window.
|
||
|
||
###### Where the list lives
|
||
The recent list is shared by all Helder windows on your Mac. Every project you open moves to the top of it.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Shift+Cmd+O` | Open the recent projects overlay |
|
||
| `Up` / `Down` | Move the selection |
|
||
| `Cmd+Up` / `Cmd+Down` | Move the selection |
|
||
| `Return` | Switch to the selected project |
|
||
| `Esc` | Close the overlay |
|
||
| `Cmd+O` | Open a folder with the folder picker |
|
||
| `Shift+Cmd+N` | Open a new window |
|
||
|
||
##### Related
|
||
|
||
- [Start screen](start-screen.md): the recent list in a window without a project.
|
||
- [Title bar](title-bar.md): click the project name to open another folder.
|
||
- [Window layout](layout.md): one project per window, and what is restored on switch.
|
||
- [Dialogs](dialogs.md): the save prompt for unsaved files before a switch.
|
||
|
||
---
|
||
|
||
### Appendix: guide/notifications.md
|
||
|
||
#### Notifications
|
||
|
||
Helder confirms what it just did with a toast: a small card that appears near the bottom centre of the window and goes away on its own. Toasts never ask for anything and never block your work.
|
||
|
||
[Guide index](index.md) · Related: [Window layout](layout.md), [Git](git.md), [Explorer](explorer.md), [Pass on to agent](pass-on-to-agent.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| |
|
||
| (workspace) |
|
||
| |
|
||
| +-------------------------------------------+ |
|
||
| |# [] Committed 2 files [Fix the login fo..]| (1) |
|
||
| +-------------------------------------------+ |
|
||
| |# [] Pushed 1 commit to origin/main | |
|
||
| +-------------------------------------------+ |
|
||
| ^ ^ ^ ^ |
|
||
| (2)(3) (4) (5) |
|
||
| |
|
||
+----------------------------------------------------------------------------+
|
||
| status bar |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Toast stack**: one card per message, newest at the bottom.
|
||
2. **Amber edge**: a thin amber rule on the left side of the card.
|
||
3. **Icon**: a small amber icon.
|
||
4. **Title**: what happened, in bright text.
|
||
5. **Detail**: the file, reference or message it is about, in a small amber chip.
|
||
|
||
##### Features
|
||
|
||
###### What a toast looks like
|
||
- A dark card with a thin border, a soft shadow and an amber rule on its left edge.
|
||
- The title says what happened, for example "Saved" or "Push failed".
|
||
- Most toasts carry a detail in an amber chip: a file path, a reference, a commit subject or a git message.
|
||
- A long detail is cut in the middle, so you see its start and its end.
|
||
- A card is never wider than 560 points.
|
||
|
||
###### Where it appears
|
||
- Centred at the bottom of the window, 44 points above the bottom edge, just over the status bar.
|
||
- Several toasts stack on top of each other.
|
||
- Toasts may sit on top of an open overlay, such as search or clean copy.
|
||
|
||
###### How it goes away
|
||
- Each toast disappears by itself after about 2.3 seconds.
|
||
- You cannot click a toast. Clicks go through it to whatever is underneath.
|
||
|
||
###### When toasts appear
|
||
|
||
Files and the editor:
|
||
|
||
| Title | Detail | When |
|
||
|---|---|---|
|
||
| Saved | file path | You saved a file with `Cmd+S` (auto-save does not toast) |
|
||
| Save failed | file path | A file could not be written |
|
||
| Created file / Created folder | new path | After New File or New Folder |
|
||
| Renamed file / Renamed folder | new path | After Rename |
|
||
| Deleted file / Deleted folder | path | After Delete |
|
||
| Create failed / Rename failed / Delete failed | path or name | The file action did not work |
|
||
| Copied reference | the reference | After Copy reference, for example `app/User.php:42` |
|
||
| Copied | file name | After Copy file name |
|
||
|
||
Git:
|
||
|
||
| Title | Detail | When |
|
||
|---|---|---|
|
||
| Committed 1 file / Committed N files | commit subject (first 34 characters) | A commit succeeded |
|
||
| Commit failed | git's first error line | The commit did not work; your message stays in the field |
|
||
| `Pushed N commits to origin/<branch>` | none | The push succeeded; without commits ahead it reads `Pushed to origin/<branch>` |
|
||
| Push failed | git's first error line | The push did not work |
|
||
| `Pulled N commits from origin/<branch>` | none | The pull brought in commits; `Pulled from origin/<branch>` when the count was not known. An up-to-date pull shows nothing |
|
||
| Pull failed | git's first error line | The pull did not work |
|
||
| `Switched to <branch>` | none | A branch switch from the Git view succeeded |
|
||
| — Commit or discard N files before you switch. | none | You clicked a branch while there are uncommitted changes |
|
||
|
||
Stage, unstage, discard and typed console commands show no toast. Their output, errors included, is in the Git view's [console](git.md#console).
|
||
|
||
The agent:
|
||
|
||
| Title | Detail | When |
|
||
|---|---|---|
|
||
| Passed to agent | the reference | Text was inserted into the Claude pane |
|
||
| Copied | character count | You copied the text of the [clean-copy](clean-copy.md) card |
|
||
|
||
###### Other short messages
|
||
Two other messages appear for a moment, but they are not toasts:
|
||
- **Too big.**: an amber word in the middle of the File column, for 1.6 seconds, when a file is too large to open, such as `composer.lock`. See [File view](file-view.md).
|
||
- **Branch and project card**: when you switch back to a Helder window, a card with the branch and the project name shows in the middle for half a second. See [Window layout](layout.md).
|
||
|
||
##### Related
|
||
|
||
- [Git](git.md): commit, pull, push and branch switches, which report through toasts.
|
||
- [Explorer](explorer.md) and [Right-click menu](right-click-menu.md): the file actions behind most file toasts.
|
||
- [Pass on to agent](pass-on-to-agent.md): the "Passed to agent" toast.
|
||
- [Dialogs](dialogs.md): prompts that do ask you something, unlike toasts.
|
||
|
||
---
|
||
|
||
### Appendix: guide/git.md
|
||
|
||
#### Git
|
||
|
||
The Git view is a full-screen page for everything git: it lists every changed file with an inline diff, stages and commits, pulls and pushes, switches branches, and shows each git command it runs in a console. Open it with `Cmd+G`.
|
||
|
||
[Guide index](index.md) · Related: [Git commit form](git-commit-form.md), [Right-click menu](right-click-menu.md#git-rows), [Dialogs](dialogs.md), [Notifications](notifications.md), [Status bar](status-bar.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| (1) [ git ] <> main 1 ahead of origin [Pull] [Push ^1] [Close CmdG] |
|
||
|----------------------------------------------------------------------------|
|
||
| (2) fix the login form_ |
|
||
| Jonathan <jonathan@example.com> Cmd+Enter commits [Commit 2 files|v] |
|
||
|----------------------------------------------------------------------------|
|
||
| (3)|v staged (2) [ ] [Unstage all]|
|
||
| |> [M] app/Http/UserController.php +4 -1 [Unstage] |
|
||
| |> [A] app/Models/Invoice.php +31 -0 [Unstage] |
|
||
| |
|
||
| (3) v changed (1) [Discard all] [Stage all]|
|
||
| (4) v [M] README.md +2 -1 [Discard] [Stage] |
|
||
| (5) 12 | old line || 12 | new line |
|
||
| 13 | same line || 13 | same line |
|
||
| ... 40 unchanged lines |
|
||
| v new . untracked (1) [Delete all] [Stage all]|
|
||
| v deleted (1) [Restore all] [Stage all]|
|
||
|----------------------------------------------------------------------------|
|
||
| (6) [ console ] git (x) | (7) [ branches ] clean . ... |
|
||
| $ git add -- README.md | local |
|
||
| $ git commit -m "fix the login form" | |<> main current |
|
||
| $ git _ | <> feature/a switch -> |
|
||
| | remote . origin |
|
||
| | () origin/feature/b checkout->|
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Top bar**: the branch, where it stands against origin, and the Pull, Push and Close buttons.
|
||
2. **Commit block**: the message, the author and the Commit button. See [Git commit form](git-commit-form.md).
|
||
3. **Section header**: the section name, its row count, and the bulk actions.
|
||
4. **File row**: status badge, path, line counts and the row actions.
|
||
5. **Inline diff**: the last commit on the left, the working tree on the right.
|
||
6. **Console**: every git command the view runs, with its output, and an input line for your own.
|
||
7. **Branches**: local branches and the branches on origin.
|
||
|
||
##### Features
|
||
|
||
###### Open and close the view
|
||
- `Cmd+G`, the **Git** toggle in the [Title bar](title-bar.md), or View > Show Git opens it. The toggle reads `Git N`, where N counts the changed files.
|
||
- The view covers the whole window: title bar, columns and status bar. The columns stay as they were under it. Terminals keep running.
|
||
- When it opens, the keyboard goes to the commit message.
|
||
- `Cmd+C` with no text selected, outside a terminal, also opens the view on the commit message.
|
||
- Close it with `Cmd+G`, `Esc`, or the **Close** button. The keyboard goes back to the column that had it.
|
||
- Dialogs, right-click menus, [Search](search.md), the full-screen [Diff](file-view-diff.md) and [notifications](notifications.md) show on top of the view. `Esc` closes those first, then the view.
|
||
- While the view is open, the column keys rest (arrows, `Cmd+Left` / `Cmd+Right`). `Cmd+1`, `Cmd+2` and `Cmd+3` still toggle the columns under it.
|
||
- The view is not remembered: a project always opens with it closed.
|
||
|
||
###### Top bar
|
||
- `[ git ]`, then the current branch in amber.
|
||
- Next to it, where the branch stands against its remote: `in sync with origin`, `1 ahead of origin`, `2 behind origin`, `1 ahead · 2 behind origin`, or `no upstream`.
|
||
- **Pull** shows `↓N` when there are commits to pull. **Push** shows `↑N` when there are commits to push.
|
||
- Opening the view runs `git fetch origin`, so the ahead and behind numbers are up to date. A repository without an `origin` skips this.
|
||
|
||
###### Sections
|
||
The changes sit in up to four sections, in this order. A section with no rows is left out.
|
||
|
||
| Section | Colour | What it holds | Row actions | Bulk actions |
|
||
|---|---|---|---|---|
|
||
| **staged** | amber | Everything staged for the next commit, whatever its status | Unstage | Unstage all |
|
||
| **changed** | light amber | Unstaged edits to tracked files; also renames and conflicts | Discard, Stage | Discard all, Stage all |
|
||
| **new · untracked** | teal | New files git does not track yet | Delete, Stage | Delete all, Stage all |
|
||
| **deleted** | lilac | Tracked files deleted from disk | Restore, Stage | Restore all, Stage all |
|
||
|
||
- Click a section header to fold or unfold it.
|
||
- One file can show up twice: once in staged and once in another section. That happens when you staged a file and then edited it again. Each row stands for its own half.
|
||
- A conflicted row (`U`) only offers **Stage**. Staging it marks the conflict as resolved.
|
||
|
||
###### File rows
|
||
Every row, left to right:
|
||
|
||
- A chevron: click anywhere on the row to show or hide its inline diff.
|
||
- A status badge: `A` new, `M` modified, `D` deleted, `R` renamed, `U` conflict. Hover it for the word.
|
||
- The path: the folder dim, the file name bright. A deleted file is struck through.
|
||
- The line counts: `+N` in teal and `−N` in light amber.
|
||
- The row actions, from the table above.
|
||
|
||
Staged rows carry an amber bar on their left edge.
|
||
|
||
###### Row actions
|
||
- **Stage** and **Unstage** run at once. They never ask.
|
||
- **Discard** throws away the unstaged changes of a file. The file goes back to its staged version, or to the last commit when nothing is staged.
|
||
- **Delete** removes a new file from disk.
|
||
- **Restore** brings a deleted file back.
|
||
- Discard and Delete ask first by default (`git.confirmDiscard`). See [Dialogs](dialogs.md#discard-changes). Restore never asks.
|
||
- An open file in the [File view](file-view.md) reloads after a Discard, Delete or Restore.
|
||
|
||
###### Inline diff
|
||
- The last commit (or the staged version) is on the left, the working tree on the right, lines side by side.
|
||
- Removed lines have an amber tint, added lines a teal tint. In a changed line pair, the part that differs is highlighted.
|
||
- Each change keeps 3 unchanged lines around it. Longer unchanged runs fold into `⋯ N unchanged lines`.
|
||
- A file over 1 MB shows `Too big.`. A file with no text changes shows `— No line changes.`.
|
||
- For the full-screen comparison, open the file and use the [Diff](file-view-diff.md).
|
||
|
||
###### Right-click a row
|
||
Right-click a file row for **Open in editor**, **Pass on reference** and **Copy reference**. See the [right-click menu](right-click-menu.md#git-rows). Open in editor and Pass on reference close the view first.
|
||
|
||
###### Pull and push
|
||
- **Pull** runs `git pull --no-rebase`. When your branch and origin both have new commits, git merges them.
|
||
- **Push** runs `git push`, or `Cmd+P` from anywhere. A branch with no upstream yet is pushed again with `git push -u origin <branch>`, so the next push needs nothing extra.
|
||
- While one runs, its button reads `Pulling…` or `Pushing…` and the console header says so. A second Pull or Push is ignored until it ends.
|
||
- Pull and push stop after 120 seconds.
|
||
- Helder never asks for a password. Git must already have access to the remote, for example through an SSH key or a credential helper.
|
||
- A [notification](notifications.md) says how it ended, for example `Pushed 2 commits to origin/main` or `Push failed` with git's error line.
|
||
|
||
###### Console
|
||
- Every action in the view logs the exact git command, such as `$ git add -- README.md`, and then git's output as it arrives.
|
||
- Errors read in amber, hints dim, staged and unstaged files from `status` in their colours, and a pushed branch in teal.
|
||
- Type your own command after `$ git` and press `Enter`. A leading `git` is allowed: `status` and `git status` do the same.
|
||
- `clear` empties the console. So does the eraser button in its header.
|
||
- `log` on its own shows the last 30 commits, one line each.
|
||
- `Up` brings back the commands you typed before, newest first.
|
||
- Commands run one at a time, in order. Typed commands also stop after 120 seconds.
|
||
- Git cannot ask you anything here: there is no editor and no pager. A command that needs an editor, such as `commit` without `-m`, stops with git's error.
|
||
- Click the console log without selecting text to put the cursor on the input line.
|
||
- The console keeps the last 400 lines.
|
||
|
||
###### Branches
|
||
- **local** lists your local branches. **remote · origin** lists the branches on origin.
|
||
- The current branch has an amber bar and reads `current`. A remote branch that has a local branch reads `tracked`.
|
||
- Click a branch to switch to it (`switch →`).
|
||
- Click a remote branch with no local branch to check it out (`checkout →`). Git creates a local branch that tracks it.
|
||
- Switching is locked while there are uncommitted changes. The header then reads `— N uncommitted files · switching locked`, the other branches are dimmed, and a click shows a notification that asks you to commit or discard first.
|
||
|
||
###### When the view is empty
|
||
- **Not a repository**: `— Not a git repository.`
|
||
- **Clean working tree**: `— No changes. The working tree is clean.`
|
||
|
||
###### Worktrees
|
||
A project folder that is a git worktree (or a submodule) works like a normal repository. Helder finds the real git folder and watches it for changes. There is no worktree list or worktree switcher.
|
||
|
||
###### How the list stays up to date
|
||
You do not need to refresh by hand. The list updates by itself:
|
||
|
||
- **On every change**: Helder watches the project folder and the git folder. Edits by you, by the agent, or by git in a terminal update the list after a short pause.
|
||
- **On a timer**: as a backstop, git is re-read every 10 seconds by default (`git.refreshInterval`).
|
||
- **When the view opens**: git is re-read, then origin is fetched.
|
||
- **After every action**: every git command from the view, typed ones included, re-reads git and the branches when it ends. Pull, a branch switch and typed commands also re-read the file tree and the open file.
|
||
- **By hand**: `Cmd+R` (View > Refresh) re-reads git, the file tree and the open file.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+G` | Open or close the Git view |
|
||
| `Esc` | Close the Git view (after any dialog, menu, search or Diff on top of it) |
|
||
| `Cmd+C` | Open the view on the commit message (no text selected, not in a terminal) |
|
||
| `Cmd+Enter` | Commit, while the view is open (not from the console input) |
|
||
| `Cmd+P` | Push the current branch |
|
||
| `Enter` | Run the command in the console input |
|
||
| `Up` | Recall the previous console command |
|
||
| `Cmd+R` | Re-read git, the file tree and the open file |
|
||
|
||
##### Settings
|
||
|
||
All settings live in `.helder/config.json`. See [Configuration](configuration.md).
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `git.confirmDiscard` | `true` | Ask before Discard and Delete |
|
||
| `git.refreshInterval` | `10000` | Milliseconds between automatic git re-reads; `0` turns the timer off |
|
||
| `git.defaultDiffMode` | `updated` | How a changed file opens; see [File view: Diff](file-view-diff.md) |
|
||
|
||
##### Related
|
||
|
||
- [Git commit form](git-commit-form.md): the message, author and Commit button at the top of the view.
|
||
- [Right-click menu](right-click-menu.md#git-rows): the menu on a file row.
|
||
- [Dialogs](dialogs.md): the confirm dialog for Discard and Delete.
|
||
- [File view: Diff](file-view-diff.md): the full-screen comparison of one file.
|
||
- [Explorer](explorer.md): shows the same status letters in the file tree.
|
||
- [Status bar](status-bar.md): branch, line totals and counts while the view is closed.
|
||
- [Notifications](notifications.md): the messages after a commit, pull, push or branch switch.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every shortcut in one list.
|
||
|
||
---
|
||
|
||
### Appendix: guide/git-commit-form.md
|
||
|
||
#### Git commit form
|
||
|
||
The commit form is the block at the top of the [Git](git.md) view, under its top bar. It holds the commit message, the author, and the Commit split button.
|
||
|
||
[Guide index](index.md) · Related: [Git](git.md), [Notifications](notifications.md), [Keyboard shortcuts](keyboard-shortcuts.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| (1) fix the login form_ |
|
||
|----------------------------------------------------------------------------|
|
||
| (2) Jonathan <jonathan@example.com> (3) Cmd+Enter commits |
|
||
| (4) [ Commit 2 files | v ] |
|
||
+----------------------------------------------------------------------------+
|
||
(5)
|
||
+------------------------+
|
||
| v Commit |
|
||
| ^ Commit and push |
|
||
+------------------------+
|
||
```
|
||
|
||
1. **Message field**: the commit message. The grey placeholder `Commit message` shows while it is empty.
|
||
2. **Author**: `user.name <user.email>` from your git config, read when the view opens. With no email set, only the name shows; with no name, nothing.
|
||
3. **Hint**: `⌘↵ commits`.
|
||
4. **Commit button**: `Commit N files`, or `Nothing staged`. The caret on its right opens the menu.
|
||
5. **Commit menu**: **Commit** and **Commit and push**.
|
||
|
||
##### Features
|
||
|
||
###### Write the message
|
||
- Opening the [Git](git.md) view puts the cursor in the field. `Cmd+C` with no text selected, outside a terminal, opens the view there too.
|
||
- The field gets an amber line under it while it has the cursor.
|
||
- The field grows with long text and scrolls after about seven lines.
|
||
- A commit message in Helder is always **one lowercase line**:
|
||
- Capitals become lowercase as you type or paste.
|
||
- A line break becomes a space. `Enter` does not start a new line, and it does not commit.
|
||
- This keeps dictated or pasted text as one short subject line.
|
||
- The draft stays in the field while the view is closed.
|
||
|
||
###### Commit
|
||
You can commit in three ways:
|
||
|
||
- Click **Commit N files**.
|
||
- Choose **Commit** from the caret menu.
|
||
- Press `Cmd+Enter` while the view is open. This works from the message field too, but not from the console input.
|
||
|
||
The button is amber when at least one file is staged and the message is not empty. Otherwise it is grey. A click always runs `git commit`, also when the button is grey, so git's own refusal shows in the [console](git.md#console).
|
||
|
||
###### Commit and push
|
||
- Choose **Commit and push** from the caret menu. It commits, and when the commit succeeds it pushes, the same as the **Push** button. See [Pull and push](git.md#pull-and-push).
|
||
|
||
###### After a commit
|
||
- The message field clears.
|
||
- The committed files leave the **staged** section. Unstaged edits stay where they were.
|
||
- A [notification](notifications.md) says `Committed N files`, with the start of your message below it (cut off after 34 characters).
|
||
- **Push** in the top bar shows `↑N`, because the branch is now ahead of its remote.
|
||
|
||
###### When a commit fails
|
||
- Your message stays in the field, so you can fix and retry.
|
||
- A notification says `Commit failed`, with git's first error line below it. The full output is in the console. Typical causes are nothing staged, an empty message, or a git hook that rejected the commit.
|
||
- When the message was empty, the cursor goes back to the field.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+C` | Open the Git view on the message field (no text selected, not in a terminal) |
|
||
| `Cmd+Enter` | Commit, while the Git view is open (not from the console input) |
|
||
| `Cmd+P` | Push the current branch |
|
||
|
||
##### Related
|
||
|
||
- [Git](git.md): the view that holds this form, and where you stage files.
|
||
- [Notifications](notifications.md): the messages after a commit or push.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every shortcut in one list.
|
||
|
||
---
|
||
|
||
### Appendix: guide/explorer.md
|
||
|
||
#### Explorer
|
||
|
||
The Explorer is the project's file tree. It is the second column from the left, between the [Git](git.md) column and the [File view](file-view.md).
|
||
|
||
[Guide index](index.md) · Related: [Right-click menu](right-click-menu.md), [Dialogs](dialogs.md), [Git](git.md), [File view](file-view.md), [Layout](layout.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+-------------------------------------+
|
||
| (1) EXPLORER console |
|
||
|-------------------------------------|
|
||
| (2)v [] app |
|
||
| v [] Http |
|
||
| (3) > [] Controllers |
|
||
| (4) [php] Kernel.php (5)M|
|
||
| > [] config |
|
||
| > [] tests |
|
||
| [md] README.md |
|
||
| [json] composer.json A |
|
||
| |
|
||
| (6) |
|
||
+-------------------------------------+
|
||
```
|
||
|
||
1. **Header**: the word `Explorer` on the left, the project name on the right.
|
||
2. **Open folder**: an amber `v` chevron and an open folder icon.
|
||
3. **Closed folder**: a grey `>` chevron and a closed folder icon.
|
||
4. **File**: a file-type badge and the file name, indented under its folder.
|
||
5. **Status letter**: the git status of a changed file.
|
||
6. **Empty space** under the rows: stands for the project folder itself. Right-click it for the project menu.
|
||
|
||
##### Features
|
||
|
||
###### Expand and collapse folders
|
||
|
||
- Click a folder to expand it. Click it again to collapse it.
|
||
- Each click also re-reads that folder from disk, so files the agent just added show up.
|
||
- A project opens with every folder collapsed.
|
||
- Opening a file from anywhere (the [Git](git.md) view, [Go to file](go-to-file.md), [Search](search.md)) expands its folders and highlights it in the tree.
|
||
- Folders come first, then files, each sorted by name. Case does not matter in the sort.
|
||
|
||
###### Icons
|
||
|
||
- Folders show a folder icon, open or closed, and a chevron.
|
||
- Files show a small file-type badge, for example `php`, `md` or `json`. The [Git](git.md) column and the [File view](file-view.md) bar use the same badges.
|
||
- An open folder shows its name in bright text.
|
||
|
||
###### Status letters
|
||
|
||
A file with a git change shows a letter on the right of its row:
|
||
|
||
| Letter | Meaning | Colour |
|
||
|---|---|---|
|
||
| `A` | Added (new or untracked) | teal |
|
||
| `M` | Modified | teal |
|
||
| `R` | Renamed | teal |
|
||
| `D` | Deleted | amber-deep |
|
||
|
||
The letter is the file's overall status. When a file has both a staged and an unstaged change, the unstaged one wins. Folders do not show a letter.
|
||
|
||
###### Selection
|
||
|
||
One row is highlighted. That is:
|
||
|
||
- the file open in the [File view](file-view.md), or
|
||
- the row under the keyboard cursor, while the Explorer is the active column, or
|
||
- the row whose [right-click menu](right-click-menu.md) is open.
|
||
|
||
Hovering a row moves the keyboard cursor to it. Hover a file to see its full project-relative path in a tooltip.
|
||
|
||
###### Open a file
|
||
|
||
- Click a file to open it in the [File view](file-view.md).
|
||
- When the open file has unsaved edits, Helder asks first: Save, Don't Save or Cancel. See [Dialogs](dialogs.md#unsaved-changes).
|
||
|
||
###### Keyboard navigation
|
||
|
||
- Click the Explorer, or move focus to it with `Cmd+Left` / `Cmd+Right`, to make it the active column.
|
||
- `Up` and `Down` move the cursor through the visible rows.
|
||
- `Enter` on a file opens it. `Enter` on a folder expands or collapses it.
|
||
- `Cmd+Right` opens the [right-click menu](right-click-menu.md#explorer-file) of the row under the cursor, beside the column.
|
||
|
||
###### What the tree leaves out
|
||
|
||
- **Hidden files**: names that start with a dot (`.env`, `.github`) are hidden. Press `Cmd+.` or click **Hidden** in the [Title bar](title-bar.md) to show them. The choice holds for the whole window.
|
||
- **Build and tool folders**: these never show: `node_modules`, `vendor`, `.git`, `out`, `dist`, `build`, `.cache`, `coverage`, `.helder`, `.next`, `.nuxt`, `.turbo`, `.idea`, `.vscode`, and `.DS_Store` files.
|
||
- **Your own excludes**: glob patterns in `files.exclude` hide matching paths.
|
||
- **Git-ignored files**: shown by default, so files like `.env` stay reachable. Set `files.followGitignore` to `true` to hide them.
|
||
- **Symbolic links** are not shown.
|
||
|
||
The same rules apply to [Search](search.md) and [Go to file](go-to-file.md).
|
||
|
||
###### Create, rename and delete
|
||
|
||
All file actions start from the [right-click menu](right-click-menu.md):
|
||
|
||
- **New file** and **New folder**: right-click a folder. **New file** in the project root: right-click the empty space under the rows.
|
||
- **Rename file** and **Rename folder**: right-click the entry.
|
||
- **Delete file** and **Delete folder**: right-click the entry. Delete always asks first, and it deletes for good. It does not use the Trash.
|
||
|
||
New file, New folder and Rename open a small [name prompt](dialogs.md#name-prompt). Delete opens a [confirm dialog](dialogs.md#delete-file-or-folder).
|
||
|
||
After the action:
|
||
|
||
- A new file opens in the [File view](file-view.md). Its folders expand.
|
||
- A new folder expands, ready for its first file.
|
||
- A renamed file stays open under its new name. Expanded folders stay expanded.
|
||
- A deleted file closes in the File view.
|
||
- A [notification](notifications.md) confirms each action, or says why it failed.
|
||
|
||
###### Stay up to date
|
||
|
||
The tree follows the disk. Helder watches the project folder and reloads the tree after a short pause when files change. `Cmd+R` reloads it by hand, together with git and the open file.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Up` / `Down` | Move the row cursor (Explorer active) |
|
||
| `Enter` | Open the file, or expand or collapse the folder |
|
||
| `Cmd+Right` | Open the right-click menu of the row under the cursor |
|
||
| `Cmd+Left` / `Cmd+Right` | Move focus to the column on the left or right |
|
||
| `Cmd+.` | Show or hide hidden files |
|
||
| `Cmd+R` | Reload the tree, git and the open file |
|
||
|
||
##### Settings
|
||
|
||
All settings live in `.helder/config.json`. See [Configuration](configuration.md).
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `files.exclude` | `[]` | Glob patterns to hide from the tree and the search |
|
||
| `files.followGitignore` | `false` | `true` hides files that git ignores |
|
||
|
||
##### Related
|
||
|
||
- [Right-click menu](right-click-menu.md): every action on a file, a folder and the empty space.
|
||
- [Dialogs](dialogs.md): the name prompt and the delete confirmation.
|
||
- [Git](git.md): the same status letters, with staging.
|
||
- [File view](file-view.md): where a clicked file opens.
|
||
- [Layout](layout.md): the Explorer toggle, Hidden and column widths.
|
||
- [Go to file](go-to-file.md): open a file by name without the tree.
|
||
|
||
---
|
||
|
||
### Appendix: guide/file-view.md
|
||
|
||
#### File view
|
||
|
||
The file view is the third column (Col C), between the [Explorer](explorer.md) and the [Claude Code](claude-code.md) column. It shows one file at a time: a bar on top, the file below it.
|
||
|
||
[Guide index](index.md) · Related: [Markdown](file-view-markdown.md), [Diff](file-view-diff.md), [Code symbols](code-symbols.md), [Pass on to Agent](pass-on-to-agent.md), [Status bar](status-bar.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+------------------------------------------------------------------+
|
||
| (1)[php] (2)app/Http/UserController.php (3)o (4)+12 -3 (5)[Diff] |
|
||
+------+-----------------------------------------------------------+
|
||
| (6)40| public function show(User $user) |
|
||
| 41| { |
|
||
| |42| $user->load('roles'); (7) changed line |
|
||
| |43| return view('users.show'); |
|
||
| =44| } (8) rule: lines removed here|
|
||
| 45| |
|
||
| | (9) the code: type here, select, right-click |
|
||
+------+-----------------------------------------------------------+
|
||
```
|
||
|
||
1. **Type badge**: a small coloured chip with the file extension.
|
||
2. **Path**: the file's path inside the project. A long path is cut at the start. Hover it to see it in full.
|
||
3. **Unsaved dot**: a small dot shows when the file has edits you have not saved.
|
||
4. **Change counts**: for a file with git changes, added lines in teal (`+12`) and removed lines in amber-deep (`-3`).
|
||
5. **View buttons**: **Preview** on Markdown files, **Diff** on changed files. The button of the current view is lit.
|
||
6. **Line numbers**: one number per line. Click a number to select that line.
|
||
7. **Changed line**: a line the change added or edited gets a teal tint, a teal left rule and a teal number.
|
||
8. **Removed-lines rule**: where lines were only removed, a thin amber-deep rule sits on the edge of the next line.
|
||
9. **Code**: the live, editable text of the file, with syntax colours.
|
||
|
||
##### Features
|
||
|
||
###### Open a file
|
||
- Click a file in the [Explorer](explorer.md), choose **Open in editor** on a row in the [Git](git.md) view, pick a result in [Search](search.md), or use [Go to file](go-to-file.md).
|
||
- The new file replaces the one that was open. Helder shows one file at a time.
|
||
- A file always opens fresh from disk.
|
||
- When you open a file at a line (from Search or the [symbol popup](code-symbols.md)), that line moves to the middle of the pane and flashes amber for about a second.
|
||
- `composer.lock` never opens. A short "Too big." message shows over the column instead.
|
||
|
||
###### The live view and changed lines
|
||
- A file without git changes opens as plain, editable code. It has no Diff button.
|
||
- A file with git changes opens in the same editable view, with its changed lines marked:
|
||
- Teal tint, teal left rule and teal line number: a line the file holds now that is new or edited.
|
||
- A thin amber-deep rule on the top edge of a line: lines were removed just above it. At the end of the file the rule sits under the last line.
|
||
- Removed lines never show inline. To see them, open the [Diff](file-view-diff.md).
|
||
- Right-click a marked line and choose **Show diff** to open the Diff centred on that line. A left click places the caret, as on any line.
|
||
- In a new file every line is teal, so its menu has no Show diff.
|
||
- The marks follow your edits once git sees the saved file.
|
||
|
||
###### Edit and save
|
||
- Type to edit. Undo and redo work as usual (`Cmd+Z`, `Cmd+Shift+Z`).
|
||
- `Cmd+S` saves the file. A "Saved" [notification](notifications.md) confirms it. If the write fails, you see "Save failed" and the file stays open with your edits.
|
||
- `Cmd+S` on a file without edits does nothing.
|
||
- After a save, git re-reads, so the [Git](git.md) view and the status bar update.
|
||
|
||
###### Auto-save
|
||
- Auto-save is off by default. Turn it on with `editor.autoSave` in the [configuration](configuration.md).
|
||
- With auto-save on, the file saves about 0.6 seconds after you stop typing. It shows no notification.
|
||
- Open edits are also written before the window closes or the project switches.
|
||
|
||
###### Indentation
|
||
- `Tab` inserts spaces, never a tab character. The number of spaces is `editor.tabSize` (default 4).
|
||
- With several lines selected, `Tab` indents every line one level.
|
||
- `Shift+Tab` outdents every touched line one level. It removes one tab, or up to `tabSize` spaces.
|
||
- The [status bar](status-bar.md) shows the setting, for example `Spaces: 4`.
|
||
|
||
###### Word wrap
|
||
- Long lines wrap onto the next row when word wrap is on. Otherwise you scroll sideways.
|
||
- `editor.wordWrap` sets it: `markdown` (default) wraps only Markdown files, `on` wraps every file, `off` wraps none.
|
||
- A wrapped line shows its number only on its first row.
|
||
|
||
###### Line numbers and selection
|
||
- Line numbers are always shown.
|
||
- Click a line number to select that whole line. `Shift`+click another number to extend the selection to it.
|
||
- `Cmd+A` selects the whole file. It also works when the keyboard is not in the code, as long as a file is open.
|
||
- The [status bar](status-bar.md) shows the caret position as line and column.
|
||
|
||
###### No guides or whitespace marks
|
||
- Helder draws no indent guides and no visible whitespace marks.
|
||
- The editable view does not tint the caret line. The caret itself is amber.
|
||
|
||
###### Unsaved changes when you switch or close
|
||
- Open another file (or the same file again) while the current file has unsaved edits, and a dialog asks: **Save**, **Don't Save** or **Cancel**.
|
||
- **Save** writes the file, then opens the new one.
|
||
- **Don't Save** drops the edits, then opens the new one.
|
||
- **Cancel** keeps the current file and its edits.
|
||
- With auto-save on, Helder saves silently and does not ask.
|
||
- Closing the window or switching project asks the same question for every file with unsaved edits.
|
||
|
||
###### Close a file
|
||
- `Cmd+W` closes the open file. With unsaved edits it asks Save, Don't Save or Cancel first.
|
||
- With no file open, `Cmd+W` closes the window.
|
||
|
||
###### Empty state
|
||
With no file open, the bar is empty and the pane shows "No file open" with three shortcuts:
|
||
|
||
| Shortcut | Action |
|
||
|---|---|
|
||
| `Cmd+O` | Open folder |
|
||
| `Cmd+Shift+O` | [Recent projects](recent-projects.md) |
|
||
| `Cmd+F` | [Search files & content](search.md) |
|
||
|
||
###### Files that are not plain text
|
||
- **Images** (png, jpg, gif, webp, svg, bmp, ico, avif and more) show as a picture, centred, on a checkerboard so transparent parts stay visible. They are read-only. An image that cannot be read shows "Can't preview this image".
|
||
- **Binary files** (pdf, zip, fonts, audio, video, databases and the like, or any file whose content turns out binary) show "This file cannot be displayed". There is no Preview or Diff button.
|
||
- **Deleted in the change**: a file git sees as deleted shows "No updated version" with the note "This file was deleted in the change." The Diff button still opens the old content.
|
||
- **Added in the change**: a new file shows all its lines in teal. In the Diff, the left side is empty.
|
||
- **Removed from disk while open**: the text stays on screen as unsaved edits, so nothing is lost. The unsaved dot shows. Save to write the file back, or close and choose Don't Save.
|
||
- **Too big**: `composer.lock` never opens. A changed file over 1 MB opens, but shows no line marks, and its Diff says "Too big."
|
||
|
||
###### Changes on disk
|
||
- Helder watches the project. When a file changes on disk (for example, the agent edits it), the open file updates by itself.
|
||
- If you have unsaved edits, Helder keeps your edits and does not overwrite them.
|
||
- `Cmd+R` re-reads git, the file tree and the open file. For the open file the disk wins: unsaved edits are dropped without a prompt.
|
||
|
||
###### Find
|
||
- The file view has no find bar of its own.
|
||
- `Cmd+F` opens project-wide [Search](search.md). With text selected, the first line of the selection fills the search field.
|
||
|
||
###### Zoom
|
||
- **View > Zoom In** (`Cmd++`), **Zoom Out** (`Cmd+-`) and **Actual Size** (`Cmd+0`) change the text size, about 10 percent per step.
|
||
- Zoom applies to the code, the Diff and the terminals. The Markdown preview keeps its size.
|
||
|
||
###### Right-click and pass on
|
||
- Right-click in the code for **Pass on reference** (or **Pass on selection** with text selected) and **Copy reference**.
|
||
- `Cmd+Right` with text selected opens the pass-on prompt for that selection.
|
||
- See [Pass on to Agent](pass-on-to-agent.md) and the [right-click menu](right-click-menu.md).
|
||
|
||
###### Class names in PHP
|
||
- Hold `Cmd` to underline the class names the project declares. `Cmd`+click one to open the [symbol popup](code-symbols.md).
|
||
|
||
###### Recent files
|
||
- `Cmd+Up` or `Cmd+Down` while you work in the file view opens the list of recently opened files. See [Go to file](go-to-file.md).
|
||
|
||
###### Syntax colours
|
||
These file types get syntax colours:
|
||
|
||
| Language | Extensions |
|
||
|---|---|
|
||
| PHP (including Blade, HTML with PHP parts) | `.php` |
|
||
| JavaScript | `.js`, `.mjs`, `.cjs`, `.jsx` |
|
||
| TypeScript | `.ts`, `.tsx` |
|
||
| Python | `.py` |
|
||
| HTML, XML and Vue | `.html`, `.xml`, `.vue` |
|
||
| CSS | `.css`, `.scss` |
|
||
| JSON | `.json` |
|
||
| Markdown | `.md` (code blocks get the colours of their language) |
|
||
| Shell | `.sh`, `.bash`, `.env` files |
|
||
| YAML | `.yml`, `.yaml` |
|
||
|
||
Every other text file shows plain text. The status bar shows the language name.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+S` | Save the open file |
|
||
| `Cmd+W` | Close the open file (or the window when none is open) |
|
||
| `Cmd+M` | Switch a Markdown file between code and Preview |
|
||
| `Cmd+A` | Select the whole file |
|
||
| `Tab` / `Shift+Tab` | Indent / outdent |
|
||
| `Cmd+Z` / `Cmd+Shift+Z` | Undo / redo |
|
||
| `Cmd+Right` | Pass on the selection to the agent (with text selected) |
|
||
| `Cmd`+click | Open the symbol popup for a PHP class name |
|
||
| `Cmd+F` | Search the project, seeded with the selection |
|
||
| `Cmd+Up` / `Cmd+Down` | Recent files |
|
||
| `Cmd+R` | Reload from disk (drops unsaved edits) |
|
||
| `Cmd++` / `Cmd+-` / `Cmd+0` | Zoom in / zoom out / actual size |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `editor.autoSave` | `false` | Save about 0.6 s after you stop typing, and never ask about unsaved edits |
|
||
| `editor.tabSize` | `4` | Spaces inserted by `Tab`, and the width of one indent level |
|
||
| `editor.wordWrap` | `markdown` | `markdown` wraps Markdown only, `on` wraps all files, `off` wraps none |
|
||
| `session.restoreOnLaunch` | `true` | Reopen the last open file when the project opens |
|
||
|
||
See [Configuration](configuration.md) for where these live.
|
||
|
||
##### Related
|
||
|
||
- [File view: Markdown](file-view-markdown.md): the rendered Preview for Markdown files.
|
||
- [File view: Diff](file-view-diff.md): the full-screen side-by-side comparison.
|
||
- [Code symbols](code-symbols.md): where a PHP class is declared and used.
|
||
- [Pass on to Agent](pass-on-to-agent.md): send a line or a selection to Claude.
|
||
- [Git](git.md): the changes that drive the line marks and the counts.
|
||
- [Status bar](status-bar.md): caret position, indentation and language.
|
||
- [Layout](layout.md): how the File column shows, hides and resizes.
|
||
|
||
---
|
||
|
||
### Appendix: guide/file-view-markdown.md
|
||
|
||
#### File view: Markdown
|
||
|
||
Markdown files (`.md`) open in the [file view](file-view.md) like any other file, with one extra: a rendered Preview. You switch between the source and the Preview with the **Preview** button in the bar or with `Cmd+M`.
|
||
|
||
[Guide index](index.md) · Related: [File view](file-view.md), [Diff](file-view-diff.md), [Pass on to Agent](pass-on-to-agent.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+--------------------------------------------------------------------+
|
||
| (1)[md] docs/setup.md (2)[Preview] (3)[Diff] |
|
||
+--------------------------------------------------------------------+
|
||
| (4) |
|
||
| Setup |
|
||
| ----------------------------------------------- |
|
||
| Install the app with Herd. Read the [guide] first. (5) link |
|
||
| |
|
||
| -- First item |
|
||
| -- Second item |
|
||
| |
|
||
| +----------------------------------------------+ |
|
||
| | composer install | (6) code block |
|
||
| +----------------------------------------------+ |
|
||
+--------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Bar**: the badge `md` and the path, as for every file.
|
||
2. **Preview button**: switches between the source and the rendered document. It is lit while the Preview shows.
|
||
3. **Diff button**: only on a changed file. See [Diff](file-view-diff.md).
|
||
4. **Rendered document**: the Markdown as formatted text, in a readable column of about 68 characters.
|
||
5. **Link**: click to follow it.
|
||
6. **Code block**: fenced code in a dark panel, with syntax colours.
|
||
|
||
##### Features
|
||
|
||
###### The source view
|
||
- A Markdown file opens in its source view: editable text with syntax colours.
|
||
- Headings, list markers, quote markers, rules, code spans and link targets get their own colours.
|
||
- A fenced code block (with three or more backticks or tildes) uses the colours of its language, for example ```` ```php ````.
|
||
- Word wrap is on for Markdown by default, so long paragraphs fold onto the next row. `editor.wordWrap` changes this.
|
||
- On a changed file, the source view shows the teal line marks like any [file view](file-view.md).
|
||
|
||
###### Switch to Preview
|
||
- Click **Preview** in the bar, or press `Cmd+M`. Press again to go back to the source.
|
||
- `Cmd+M` does nothing on a file that is not Markdown.
|
||
- The Preview shows the current text, unsaved edits included.
|
||
- The Preview is read-only. You can select and copy its text.
|
||
- Your undo history and unsaved edits stay intact while you are in the Preview.
|
||
|
||
###### What the Preview renders
|
||
|
||
| Markdown | Shown as |
|
||
|---|---|
|
||
| `#` to `######` headings | Bold headings; a level-3 heading gets a thin rule under it |
|
||
| Paragraphs | Body text; lines of one paragraph join into one |
|
||
| `**bold**`, `__bold__` | Bold |
|
||
| `*italic*`, `_italic_` | Italic |
|
||
| `~~text~~` | Strikethrough |
|
||
| `` `code` `` | Inline code |
|
||
| ```` ``` ```` fenced blocks | Code panel with syntax colours, scrolls sideways |
|
||
| `>` quotes | Amber rule on the left, quote text; quotes may nest |
|
||
| `-`, `*`, `+` lists | Items with an amber dash |
|
||
| `1.` or `1)` lists | Numbered items |
|
||
| GFM tables | A table with a header row; `:---:` and `---:` set centre and right alignment |
|
||
| `---`, `***`, `___` | A thin horizontal rule |
|
||
| `` | The image, from the project or from the web; the alt text while it loads or when it fails |
|
||
| `[text](url)` | A link |
|
||
|
||
Not rendered: nested lists, task-list checkboxes, raw HTML, and headings underlined with `===` or `---`. Fenced code in the Preview needs backticks; a `~~~` fence shows as plain text.
|
||
|
||
###### Links in the Preview
|
||
- A web link (`http`, `https`) opens in your browser.
|
||
- A `mailto:` link opens your mail app.
|
||
- A link to a file in the project opens that file in the file view.
|
||
- A link to an anchor (`#section`) is shown as text but does nothing.
|
||
- Links with other schemes, such as `javascript:`, are dropped for safety.
|
||
|
||
###### Right-click in the Preview
|
||
- Right-click anywhere in the Preview for **Pass on reference** and **Copy reference**. The reference points at line 1 of the file. See [Pass on to Agent](pass-on-to-agent.md).
|
||
|
||
###### Zoom
|
||
- The Preview keeps its own text size. `Cmd++` and `Cmd+-` zoom only the source view.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+M` | Switch between source and Preview |
|
||
| `Cmd+S` | Save (from the source view) |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `editor.wordWrap` | `markdown` | `markdown` wraps only Markdown files; `on` wraps every file; `off` wraps none |
|
||
|
||
##### Related
|
||
|
||
- [File view](file-view.md): editing, saving and the bar.
|
||
- [File view: Diff](file-view-diff.md): compare a changed Markdown file with its last commit.
|
||
- [Pass on to Agent](pass-on-to-agent.md): send a reference to the file to Claude.
|
||
- [Configuration](configuration.md): where `editor.wordWrap` lives.
|
||
|
||
---
|
||
|
||
### Appendix: guide/file-view-diff.md
|
||
|
||
#### File view: Diff
|
||
|
||
The Diff is a full-screen, side-by-side comparison of a changed file. It covers the whole window: the old version on the left, the current version on the right, lines aligned.
|
||
|
||
[Guide index](index.md) · Related: [File view](file-view.md), [Git](git.md), [Pass on to Agent](pass-on-to-agent.md), [Right-click menu](right-click-menu.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| (1)[php] app/User.php (2)Modified +3 -2 (3)HEAD -> staged (4)[Collapse Esc]|
|
||
+-------------------------------------+--------------------------------------+
|
||
| (5)ORIGINAL before | (6)ACTUAL after |
|
||
+-------------------------------------+--------------------------------------+
|
||
| 10 public function name() | 10 public function name() |
|
||
| |11 return $this->first; (7) | |11 return $this->full; (8) |
|
||
| |12 // old | (9) |
|
||
| 13 } | 12 } |
|
||
+-------------------------------------+--------------------------------------+
|
||
```
|
||
|
||
1. **File**: the type badge and the path.
|
||
2. **Status and counts**: `Added`, `Modified` or `Deleted`, then added lines in teal (`+3`) and removed lines in amber-deep (`-2`).
|
||
3. **Which half**: only when the file has both staged and unstaged changes. `HEAD -> staged` shows the staged part, `staged -> actual` shows the part not yet staged.
|
||
4. **Collapse**: closes the Diff. Same as `Esc`.
|
||
5. **Original**: the file as it was before (left).
|
||
6. **Actual**: the file as it is now (right).
|
||
7. **Removed or old line**: amber-deep tint, left rule and number.
|
||
8. **Added or new line**: teal tint, left rule and number.
|
||
9. **Filler**: an empty half where the other side has a line with no partner.
|
||
|
||
##### Features
|
||
|
||
###### Open the Diff
|
||
- Click **Diff** in the [file view](file-view.md) bar. The button shows only on a file with git changes.
|
||
- Right-click a marked (teal) line in the file view and choose **Show diff**. The Diff opens centred on that line.
|
||
- Show diff on a marked line always compares the last commit with the file on disk.
|
||
- The [Git](git.md) view has its own inline diff per file row. **Open in editor** on a row opens the file; click **Diff** there for the full-screen view.
|
||
|
||
###### Layout
|
||
- The Diff covers all columns. The window's shortcuts still work over it.
|
||
- Each side has its own line numbers, the numbers of that version of the file.
|
||
- Unchanged lines line up side by side. A run of removed lines pairs with the run of added lines next to it. Extra lines face an empty half.
|
||
- Both halves scroll together, up and down and sideways.
|
||
- Lines never wrap, so the rows stay aligned. Scroll sideways to read long lines.
|
||
- Syntax colours stay on, line by line.
|
||
- The text size follows View > Zoom (`Cmd++`, `Cmd+-`, `Cmd+0`).
|
||
|
||
###### Colours
|
||
- Teal is what the file holds now. Changed lines on the right get a teal tint, a teal left rule and a teal number.
|
||
- Amber-deep is what it held before. Changed lines on the left get an amber-deep tint, rule and number.
|
||
- There is no green and no red.
|
||
|
||
###### Special cases
|
||
- **Added file**: the left side is empty, the right side holds the whole file.
|
||
- **Deleted file**: the left side holds the old file, the right side is empty.
|
||
- **Too big**: a changed file over 1 MB shows "Too big." in place of the lines.
|
||
- **No changes**: if the file has no changes left, the Diff shows "No changes to compare."
|
||
- The Diff updates by itself when the file changes on disk or in git.
|
||
|
||
###### Select and copy
|
||
- Drag over lines on one side to select whole lines. The selection stays on the side where you started.
|
||
- `Cmd+C` copies the selected lines of that side, without line numbers.
|
||
- `Cmd+A` selects every line of the side that holds the selection, or of the Original side.
|
||
- A click clears the selection.
|
||
|
||
###### Right-click and pass on
|
||
- Right-click a line on either side for a small menu with **Pass on reference** and **Copy reference**.
|
||
- The reference is `path:line` with the line number of the side you clicked. An empty half refers to line 1.
|
||
- **Copy reference** puts the reference on the clipboard.
|
||
- **Pass on reference** opens the pass-on prompt inside the Diff. Type an optional note, press `Enter` to insert it into the [Claude Code](claude-code.md) pane. See [Pass on to Agent](pass-on-to-agent.md).
|
||
- Use `Up`, `Down` and `Enter` to pick a menu item with the keyboard.
|
||
|
||
###### Close the Diff
|
||
- Press `Esc` or click **Collapse**.
|
||
- `Esc` closes the innermost layer first: the menu, then the prompt, then the Diff.
|
||
- You return to the view you came from, with the keyboard back in the code.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Esc` | Close the menu, the prompt, or the Diff |
|
||
| `Cmd+C` | Copy the selected lines |
|
||
| `Cmd+A` | Select all lines of one side |
|
||
| `Up` / `Down` / `Enter` | Move through and choose in the right-click menu |
|
||
| `Cmd++` / `Cmd+-` / `Cmd+0` | Zoom in / zoom out / actual size |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `git.defaultDiffMode` | `updated` | Meant to open changed files straight in the Diff when set to `diff`. In this version a changed file always opens in the live file view. |
|
||
|
||
##### Related
|
||
|
||
- [File view](file-view.md): the live view with teal line marks, where **Show diff** opens the Diff.
|
||
- [Git](git.md): the Git view, with an inline diff per changed file.
|
||
- [Pass on to Agent](pass-on-to-agent.md): the reference format and the prompt.
|
||
- [Right-click menu](right-click-menu.md): the menus across Helder.
|
||
|
||
---
|
||
|
||
### Appendix: guide/code-symbols.md
|
||
|
||
#### Code symbols
|
||
|
||
Helder knows the PHP classes, interfaces, traits and enums your project declares. `Cmd`+click a class name in the [file view](file-view.md) to see where it is declared and every place that uses it, in a popup in the middle of the window.
|
||
|
||
[Guide index](index.md) · Related: [File view](file-view.md), [Search](search.md), [Explorer](explorer.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------+
|
||
| (1) App\Models\User (2) 14 references |
|
||
+----------------------------------------------------------------+
|
||
| (3) DEFINED IN |
|
||
| >[php] app/Models/User.php (4)[class] 12 |
|
||
| (5) EXTENDS [Authenticatable] |
|
||
| IMPLEMENTS [MustVerifyEmail] |
|
||
| USES [HasFactory] [Notifiable] |
|
||
| (6) USED IN |
|
||
| [php] app/Http/Controllers/UserController.php 3 |
|
||
| (7) 18 public function show(User $user) |
|
||
| 42 $user = User::findOrFail($id); |
|
||
| [php] app/Policies/UserPolicy.php 2 |
|
||
| 11 public function view(User $user): bool |
|
||
+----------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Name**: the class name. With exactly one declaration, the full name with its namespace.
|
||
2. **Reference count**: how many lines use the name.
|
||
3. **Defined in**: each declaration, with badge, path and line number.
|
||
4. **Kind**: `class`, `interface`, `trait` or `enum`.
|
||
5. **Relations**: what the declaration extends, implements and uses (traits). Each name is a chip.
|
||
6. **Used in**: the files that use the name, each with its number of hits.
|
||
7. **Hit**: the line number and the line itself.
|
||
|
||
##### Features
|
||
|
||
###### Find a clickable class name
|
||
- Hold `Cmd` while the keyboard is in the code. Every class name the project declares gets a thin amber underline.
|
||
- Move the pointer over an underlined name: the pointer turns into a hand.
|
||
- Names from `vendor/` count too, so framework classes are clickable.
|
||
- The underline shows in PHP files, including Blade templates.
|
||
|
||
###### Open the symbol popup
|
||
- `Cmd`+click an underlined class name.
|
||
- The popup opens at once and shows "Searching..." until the results are in.
|
||
- The popup sits in the middle of the window over a dimmed background.
|
||
|
||
###### Defined in
|
||
- Lists every declaration of the name, project files before `vendor/` files, up to 25.
|
||
- "No declaration in this project" means the name has no declaration Helder can find.
|
||
- Under a declaration, the **EXTENDS**, **IMPLEMENTS** and **USES** rows show related names.
|
||
- A related name the project declares lights amber when you hover it. Click it to load the popup for that name. Other names are grey and do nothing.
|
||
|
||
###### Used in
|
||
- Lists every line that uses the name, grouped by file. `vendor/` is left out.
|
||
- Import lines (`use App\Models\User;`) and the declaration line itself are left out.
|
||
- Up to 300 files are listed.
|
||
- Click a hit to open that file at that line. Click a file header to open the file at its first hit.
|
||
- The line you land on moves to the middle of the pane and flashes amber.
|
||
|
||
###### Move with the keyboard
|
||
- `Up` and `Down` move the highlight through the declarations first, then every hit.
|
||
- `Enter` opens the highlighted row.
|
||
- `Esc`, or a click outside the popup, closes it.
|
||
|
||
###### Keeping up to date
|
||
- When files change on disk, Helder rebuilds its list of class names. New classes become clickable without a restart.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd` (hold) | Underline the clickable class names |
|
||
| `Cmd`+click | Open the symbol popup for a class name |
|
||
| `Up` / `Down` | Move through declarations and hits |
|
||
| `Enter` | Open the highlighted declaration or hit |
|
||
| `Esc` | Close the popup |
|
||
|
||
##### Related
|
||
|
||
- [File view](file-view.md): where you `Cmd`+click, and where a result opens.
|
||
- [Search](search.md): free-text search across all files.
|
||
- [Explorer](explorer.md): the opened file is revealed in the tree.
|
||
|
||
---
|
||
|
||
### Appendix: guide/pass-on-to-agent.md
|
||
|
||
#### Pass on to Agent
|
||
|
||
Pass on to Agent sends a pointer to your code to the [Claude Code](claude-code.md) pane: a file path with a line or a line range, and optionally the selected code and a note. Copy reference puts the same pointer on the clipboard instead.
|
||
|
||
[Guide index](index.md) · Related: [File view](file-view.md), [Diff](file-view-diff.md), [Claude Code](claude-code.md), [Right-click menu](right-click-menu.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+--------------------------------------+
|
||
| * Pass on selection | (1)
|
||
| Copy reference | (2)
|
||
+--------------------------------------+
|
||
|
||
+----------------------------------------------+
|
||
| * Pass on to agent [esc] | (3)
|
||
| +------------------------------------------+ |
|
||
| | Add a note (optional)... | | (4)
|
||
| +------------------------------------------+ |
|
||
| Inserts [ check the eager load app/Http/ ] | (5)
|
||
| [ UserController.php:42-45 ] |
|
||
| [ ``` ] |
|
||
| [ $user->load('roles'); ] |
|
||
| [ ``` ] |
|
||
| (enter) insert into agent (esc) cancel | (6)
|
||
+----------------------------------------------+
|
||
```
|
||
|
||
1. **Pass on**: "Pass on selection" with text selected, else "Pass on reference". Opens the prompt.
|
||
2. **Copy reference**: copies the reference to the clipboard.
|
||
3. **Prompt title**: marked with the amber spark that marks every pass-on action.
|
||
4. **Note field**: an optional note. The keyboard starts here.
|
||
5. **Inserts**: a live preview of the exact text that goes to the agent.
|
||
6. **Hints**: `Enter` inserts, `Esc` cancels.
|
||
|
||
##### Features
|
||
|
||
###### The reference format
|
||
- A single line: `path:line`, for example `app/Http/UserController.php:42`.
|
||
- A range of lines: `path:start-end`, for example `app/Http/UserController.php:42-58`.
|
||
- The path is relative to the project folder.
|
||
- With text selected, the range covers every line the selection touches.
|
||
- With nothing selected, the reference is the line you right-clicked.
|
||
|
||
###### Right-click in the code
|
||
- Right-click anywhere in the [file view](file-view.md). The menu has exactly two items: a Pass on item and **Copy reference**.
|
||
- Without a selection: **Pass on reference** and **Copy reference**, for the clicked line.
|
||
- With a selection: **Pass on selection** (sends the reference and the selected code) and **Copy reference** (copies only the reference).
|
||
- In the Markdown [Preview](file-view-markdown.md) and on an image, the reference points at line 1 of the file.
|
||
- In the [Diff](file-view-diff.md), right-click a line on either side. The reference uses the line number of that side. The Diff passes on a reference, not code.
|
||
|
||
###### Copy reference
|
||
- Puts the reference on the clipboard.
|
||
- A "Copied reference" [notification](notifications.md) shows the reference.
|
||
|
||
###### The pass-on prompt
|
||
- Opens next to the click or the selection.
|
||
- Type a note, or leave the field empty.
|
||
- `Enter` inserts the text into the Claude Code pane. `Esc`, or a click outside the prompt, cancels without inserting.
|
||
- What is inserted:
|
||
- Reference only, no note: `app/User.php:42`
|
||
- Reference with a note: `check this => app/User.php:42`
|
||
- Selection: the note (if any) and the reference on one line, then the selected code in a fenced code block.
|
||
- A "Passed to agent" [notification](notifications.md) confirms the insert and shows the reference.
|
||
|
||
###### How the text lands in Claude Code
|
||
- The text goes into Claude's input as pasted text. It is never submitted.
|
||
- You can read it, edit it, and press `Enter` in the Claude pane yourself when you are ready.
|
||
- The keyboard stays where it was. Click the Claude pane, or move focus there, to send.
|
||
|
||
###### Stack several references
|
||
- Pass on as many references as you like before you send.
|
||
- When Claude's input already holds text, each new insert starts on a new line.
|
||
- Once you send (press `Enter` in Claude), the next insert starts a fresh message.
|
||
|
||
###### Pass on with the keyboard
|
||
- Select text in the file view and press `Cmd+Right`. The prompt opens for that selection, with the code included.
|
||
- Without a selection, `Cmd+Right` in the code keeps its normal meaning (end of line).
|
||
|
||
###### Other things you can pass on
|
||
- Files, folders and [Git](git.md) view rows have their own pass-on items in their [right-click menu](right-click-menu.md), such as **Pass on file name**.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+Right` | Open the pass-on prompt for the selected code |
|
||
| `Enter` | Insert into the agent (in the prompt) |
|
||
| `Esc` | Cancel the prompt or close the menu |
|
||
| `Up` / `Down` / `Enter` | Choose a menu item |
|
||
|
||
##### Related
|
||
|
||
- [Claude Code](claude-code.md): the pane that receives the text.
|
||
- [File view](file-view.md): select code and right-click.
|
||
- [File view: Diff](file-view-diff.md): pass on a line from the comparison.
|
||
- [Right-click menu](right-click-menu.md): all menus and their pass-on items.
|
||
- [Notifications](notifications.md): the confirmations after copy and pass on.
|
||
|
||
---
|
||
|
||
### Appendix: guide/claude-code.md
|
||
|
||
#### Claude Code
|
||
|
||
The Claude Code pane is the top half of the right-hand column. It is a live terminal that runs the Claude agent in your project folder.
|
||
|
||
[Guide index](index.md) · Related: [Command line](command-line.md), [Pass on to Agent](pass-on-to-agent.md), [Clean copy](clean-copy.md), [Layout](layout.md), [Right-click menu](right-click-menu.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+--------------------------------------------+
|
||
| (1) |
|
||
| Claude Code v2 |
|
||
| ...agent output... |
|
||
| |
|
||
| > explain src/app.php:12-14 (2) |
|
||
| ``` |
|
||
| function handle() { ... } |
|
||
| ```_ |
|
||
| |
|
||
+===== (3) drag to resize ===================+
|
||
| (4) Command line |
|
||
+--------------------------------------------+
|
||
```
|
||
|
||
1. **Agent terminal**: the whole pane is the terminal. There is no header bar above it.
|
||
2. **Composer**: Claude's input line. Passed references land here and wait for you.
|
||
3. **Splitter**: the bar between the two panes. Drag it to change their heights.
|
||
4. **Command line**: the shell pane below. See [Command line](command-line.md).
|
||
|
||
##### Features
|
||
|
||
###### Auto-launch
|
||
- When a project opens, Helder starts your login shell in the project folder and runs the agent command in it.
|
||
- The default command is `claude`. Set another with `ai.command`.
|
||
- The shell loads your profile and rc files first, so tools such as Homebrew and nvm are on the path.
|
||
- No prompt line and no echo of the command appear. You see the agent straight away.
|
||
- Turn `ai.autoLaunch` off and the pane opens a plain shell instead. You can then start the agent yourself.
|
||
- If the command is missing or fails, you see the error as normal terminal output in the pane.
|
||
- The pane takes the keyboard when it starts, so you can type to Claude at once.
|
||
|
||
###### Passed references arrive unsubmitted
|
||
- [Pass on to Agent](pass-on-to-agent.md) sends text into Claude's composer.
|
||
- The text arrives as a paste. It is never submitted. You press `Enter` when you are ready.
|
||
- Each new pass starts on a fresh line when the composer already holds text. So you can stack several references, then send them as one message.
|
||
- After a pass, the keyboard moves to the Claude pane and a short [notification](notifications.md) confirms it ("Passed to agent").
|
||
- Nothing is sent when the agent process is not running.
|
||
|
||
###### Text from Claude to copy
|
||
- Claude can hand you text to copy by writing it to `.clean-copy` in the project root. Helder then opens a card with that text and a **Copy** button. See [Clean copy](clean-copy.md).
|
||
- Both terminals run with `TERM_PROGRAM=Helder`, so Claude can tell it runs inside Helder.
|
||
|
||
###### Restart after the process exits
|
||
- When the agent exits (for example after `/exit`), the pane shows a grey line: `[process exited] · press any key to restart`.
|
||
- Press any key in the pane. Helder starts the agent again with the current settings.
|
||
- Closing the window ends the agent. Opening another project in the window starts a fresh agent there.
|
||
- Hiding the Claude column with its [title bar](title-bar.md) toggle does not stop the agent. It keeps running and keeps its output.
|
||
|
||
###### Copy and paste
|
||
- Select text with the mouse. The selection is copied to the clipboard straight away. No `Cmd+C` is needed.
|
||
- Right-click the pane for a small menu: **Copy** (only with a selection) and **Paste**. See [Right-click menu](right-click-menu.md).
|
||
- Paste through the menu behaves like a normal clipboard paste. Claude treats it as pasted text and does not submit it.
|
||
|
||
###### Focus
|
||
- Click anywhere in the pane to type in it. The first click works even when the window is not active.
|
||
- While the pane has the keyboard, keys such as arrows, `Enter`, `Cmd+A`, `Cmd+C`, `Cmd+Left` and `Cmd+Right` go to the terminal, not to Helder.
|
||
- `Option+Left` and `Option+Right` jump one word back or forward in the composer.
|
||
- The pointer is an I-beam over the text and an arrow over the scroll bar.
|
||
|
||
###### Zoom
|
||
- View > Zoom In (`Cmd++`), Zoom Out (`Cmd+-`) and Actual Size (`Cmd+0`) change the text size in both terminals and in the code.
|
||
- Each step is half a zoom level. The zoom is remembered across launches.
|
||
|
||
###### Colours and font
|
||
- The pane uses Helder's dark terminal theme: a slate background, light text and an amber cursor and selection.
|
||
- The default font is IBM Plex Mono. The cursor is a blinking bar.
|
||
- Bold text keeps its own colour. It does not switch to the bright variant unless you turn on `terminal.boldIsBright`.
|
||
- Both terminals share these settings. Changes apply to the running terminal; the agent keeps running.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Enter` | Send the composer to Claude |
|
||
| Any key, after exit | Restart the agent |
|
||
| `Option+Left` / `Option+Right` | Jump one word back / forward |
|
||
| `Cmd++` / `Cmd+-` / `Cmd+0` | Zoom terminal and code text in / out / reset |
|
||
| Mouse select | Copy the selection |
|
||
|
||
##### Settings
|
||
|
||
All settings live in `.helder/config.json`. See [Configuration](configuration.md).
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `ai.autoLaunch` | `true` | Run the agent command when the pane starts. Off gives a plain shell. |
|
||
| `ai.command` | `claude` | The command the pane runs. |
|
||
| `terminal.shell` | your `$SHELL` | The shell that runs the command. |
|
||
| `terminal.fontFamily` | IBM Plex Mono | Terminal font. |
|
||
| `terminal.fontSize` | built-in size | Terminal text size, before zoom. |
|
||
| `terminal.cursorStyle` | `bar` | `bar`, `block` or `underline`. |
|
||
| `terminal.cursorBlink` | `true` | Blinking cursor. |
|
||
| `terminal.boldIsBright` | `false` | Show bold text in the bright colour. |
|
||
| `terminal.scrollback` | `8000` | Lines kept for scrolling back. |
|
||
| `terminal.optionIsMeta` | `false` | Option acts as Meta (for a CLI's `Option+Enter`), but then Option no longer types accents. |
|
||
| `terminal.theme` | Helder dark | Background, foreground, cursor, selection and the 16 ANSI colours, as CSS colour strings. |
|
||
|
||
`terminal.lineHeight` and `terminal.letterSpacing` exist in the file but have no effect in the terminals.
|
||
|
||
##### Related
|
||
|
||
- [Command line](command-line.md): the shell pane below, with the same look and copy behaviour.
|
||
- [Pass on to Agent](pass-on-to-agent.md): send code references into Claude's composer.
|
||
- [Clean copy](clean-copy.md): copy text that Claude writes to `.clean-copy`.
|
||
- [Right-click menu](right-click-menu.md): Copy and Paste in the terminal.
|
||
- [Layout](layout.md): the splitter, the Claude toggle and column widths.
|
||
- [Configuration](configuration.md): where `ai` and `terminal` settings live.
|
||
|
||
---
|
||
|
||
### Appendix: guide/command-line.md
|
||
|
||
#### Command line
|
||
|
||
The command line is the bottom half of the right-hand column. It is a normal shell, opened in your project folder.
|
||
|
||
[Guide index](index.md) · Related: [Claude Code](claude-code.md), [Layout](layout.md), [Right-click menu](right-click-menu.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+--------------------------------------------+
|
||
| (1) Claude Code |
|
||
| |
|
||
+===== (2) drag to resize ===================+
|
||
| (3) |
|
||
| ~/code/myproject $ php artisan test |
|
||
| ... |
|
||
| ~/code/myproject $ _ |
|
||
| |
|
||
+--------------------------------------------+
|
||
```
|
||
|
||
1. **Claude Code**: the agent pane above. See [Claude Code](claude-code.md).
|
||
2. **Splitter**: the bar between the two panes. Drag it up or down.
|
||
3. **Shell terminal**: the whole pane is the terminal. There is no header bar; your shell prompt shows where you are.
|
||
|
||
##### Features
|
||
|
||
###### The shell
|
||
- Helder starts your shell as a login shell in the project folder.
|
||
- The shell loads your profile, so Homebrew, nvm and your aliases work, even when Helder was opened from the Finder.
|
||
- It is a plain terminal. Run any command, editor or tool you like.
|
||
- There is one shell pane per window. There are no tabs.
|
||
|
||
###### Choosing the shell
|
||
- By default Helder uses the shell in your `$SHELL`, else `/bin/zsh`.
|
||
- Set `terminal.shell` to another shell, for example `/bin/bash`. The same shell also hosts the [Claude Code](claude-code.md) pane.
|
||
|
||
###### Restart
|
||
- When the shell exits (for example after `exit`), the pane shows a grey line: `[process exited] · press any key to restart`.
|
||
- Press any key in the pane to start a fresh shell.
|
||
- Closing the window ends the shell. Opening another project in the window starts a fresh shell in the new folder.
|
||
- Hiding the Claude column hides this pane too. The shell keeps running and keeps its output.
|
||
|
||
###### Copy and paste
|
||
- Select text with the mouse. It is copied to the clipboard straight away.
|
||
- Right-click for **Copy** (only with a selection) and **Paste**. See [Right-click menu](right-click-menu.md).
|
||
|
||
###### Focus
|
||
- Click in the pane to type in it. The first click works even when the window is not active.
|
||
- While the pane has the keyboard, arrows, `Enter`, `Cmd+A`, `Cmd+C`, `Cmd+Left` and `Cmd+Right` go to the shell, not to Helder.
|
||
- `Option+Left` and `Option+Right` jump one word back or forward.
|
||
|
||
###### Splitter between Claude and the shell
|
||
- Drag the bar between the two panes to share the height.
|
||
- Claude starts with about half the column. Each pane keeps at least about a fifth of it.
|
||
- The position is remembered across launches, and is the same in every project.
|
||
|
||
###### Look
|
||
- Same font, colours, cursor and zoom as the [Claude Code](claude-code.md) pane. `Cmd++`, `Cmd+-` and `Cmd+0` zoom both terminals.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| Any key, after exit | Restart the shell |
|
||
| `Option+Left` / `Option+Right` | Jump one word back / forward |
|
||
| `Cmd++` / `Cmd+-` / `Cmd+0` | Zoom terminal and code text in / out / reset |
|
||
| Mouse select | Copy the selection |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `terminal.shell` | your `$SHELL` | The shell for both terminal panes. |
|
||
| `terminal.scrollback` | `8000` | Lines kept for scrolling back. |
|
||
| `terminal.optionIsMeta` | `false` | Option acts as Meta, but no longer types accents. |
|
||
|
||
The font, cursor and colour settings are shared with Claude Code. See [Claude Code](claude-code.md#settings) and [Configuration](configuration.md).
|
||
|
||
##### Related
|
||
|
||
- [Claude Code](claude-code.md): the agent pane above, with the same terminal behaviour.
|
||
- [Layout](layout.md): column widths, the Claude toggle and the splitters.
|
||
- [Right-click menu](right-click-menu.md): Copy and Paste in the terminal.
|
||
- [Configuration](configuration.md): the `terminal` settings.
|
||
|
||
---
|
||
|
||
### Appendix: guide/clean-copy.md
|
||
|
||
#### Clean copy
|
||
|
||
Clean copy lets Claude hand you text to copy: a command, a commit message, a draft. Claude writes it to a file, and Helder shows it in a card at the top of the window, ready to edit and copy. You never have to select text out of the terminal.
|
||
|
||
[Guide index](index.md) · Related: [Claude Code](claude-code.md), [Notifications](notifications.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------+
|
||
| (1) From Claude .clean-copy (2) [ Copy Cmd+Enter ] |
|
||
+----------------------------------------------------------------+
|
||
| (3) |
|
||
| feat: show the refund state on the order page |
|
||
| |
|
||
| The order page now shows when a refund is pending._ |
|
||
| |
|
||
+----------------------------------------------------------------+
|
||
| (4) copied as plain text . 74 characters |
|
||
+----------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Header**: the title and the file name, `.clean-copy`.
|
||
2. **Copy**: copies the text and closes the card.
|
||
3. **Text area**: the text Claude wrote, in a monospaced font. You can edit it before you copy.
|
||
4. **Footer**: how the text is copied, and how many characters it holds.
|
||
|
||
##### Features
|
||
|
||
###### The file
|
||
- The channel is one file: `.clean-copy` in the root of the project.
|
||
- Claude overwrites the whole file each time it has text for you. Helder only reads it; it never clears or deletes it.
|
||
- Both terminals get `TERM_PROGRAM=Helder` in their environment, so Claude can tell it runs inside Helder.
|
||
- Like any file, `.clean-copy` shows up in [Git](git.md) and the [Explorer](explorer.md) unless you ignore it.
|
||
|
||
###### When the card opens
|
||
- The card opens when the contents of `.clean-copy` change while the project is open.
|
||
- Helder waits a moment after the last write, so it reads the whole text, not half of it.
|
||
- The text that is in the file when you open the project never opens the card.
|
||
- An empty file, or one with only spaces and blank lines, does not open the card.
|
||
- Writing the same text again does not open the card a second time.
|
||
- The card opens in the window of that project, even when the window is in the background. Helder does not come to the front.
|
||
|
||
###### While something else is open
|
||
- When another card or dialog is open, such as [search](search.md) or a [dialog](dialogs.md), the text waits. The card opens once you close the other one.
|
||
- If Claude writes several times while you wait, only the newest text shows.
|
||
- When the clean-copy card is already open and new text arrives, the card shows the new text, unless you already edited the text. Then your edits stay and the new text is dropped.
|
||
|
||
###### Copying
|
||
- Click **Copy** or press `Cmd+Enter`.
|
||
- The text in the card, with your edits, goes to the clipboard as plain text.
|
||
- The card closes, and a [notification](notifications.md) says "Copied".
|
||
- `Esc`, or a click outside the card, closes it without copying.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+Enter` | Copy the text and close |
|
||
| `Esc` | Close without copying |
|
||
|
||
##### Related
|
||
|
||
- [Claude Code](claude-code.md): the agent that writes `.clean-copy`.
|
||
- [Notifications](notifications.md): the "Copied" confirmation.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every key in one list.
|
||
|
||
---
|
||
|
||
### Appendix: guide/search.md
|
||
|
||
#### Search
|
||
|
||
Search covers the whole window, edge to edge, like the [Git view](git.md). One query searches the open file, the contents of the project and the file names at the same time.
|
||
|
||
[Guide index](index.md) · Related: [Go to file](go-to-file.md), [File view](file-view.md), [Explorer](explorer.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| (1) Q handle_ (2) [php][md] (3) 3 here . 39 hits . 2 f |
|
||
+----------------------+---------------------------------+-------------------+
|
||
| (4) app.php 3 | (5) PROJECT 39 | (6) FILES 2 |
|
||
| 12 function handle | src/app.php 3 | Handler.php |
|
||
| 40 $this->handle( | 12 function handle() { | src/ |
|
||
| 88 handle($r); | 40 $this->handle($x); | handle.md * |
|
||
| | tests/AppTest.php 1 | docs/ |
|
||
| | 7 ->handle() | |
|
||
+----------------------+---------------------------------+-------------------+
|
||
| (7) Cmd+Left / Cmd+Right column Cmd+Up / Cmd+Down row Enter open esc |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Query field**: type here. The field has the keyboard as soon as Search opens.
|
||
2. **Type chips**: one chip per file type in the results. Click one to show only that type.
|
||
3. **Summary**: hits in this file, hits in the project, and matching file names.
|
||
4. **This file**: matches in the open file. Only shown when a file is open.
|
||
5. **Project**: content matches in the whole project, grouped per file.
|
||
6. **Files**: file names that match the query.
|
||
7. **Footer**: the keys, and an `esc` chip.
|
||
|
||
##### Features
|
||
|
||
###### Opening search
|
||
- Press `Cmd+F`, or click **Search** in the [title bar](title-bar.md).
|
||
- With text selected in the file view, the query starts with the first line of that selection.
|
||
- Search covers the whole window, title bar and status bar included, with no margin. Press `Esc` to close it.
|
||
|
||
###### Typing
|
||
- Results update as you type.
|
||
- **This file** and **Files** search from the first character.
|
||
- **Project** searches from two characters, after a very short pause. Each new key cancels the older search.
|
||
- Leading and trailing spaces are ignored.
|
||
- **This file** ignores case.
|
||
- **Project** ignores case, unless the query holds a capital letter. Then it matches case exactly.
|
||
- **Files** is fuzzy: the letters must appear in order, not next to each other. `hdlr` finds `Handler.php`. Matched letters are amber.
|
||
- File names that match on the name come first, before matches that only hit the folder path. Earlier and shorter matches rank higher.
|
||
|
||
###### The three columns
|
||
- The columns keep a fixed width: This file 30 percent, Project 45 percent, Files 25 percent. Without an open file: Project 65 percent, Files 35 percent.
|
||
- Moving the focus does not change a width. The focused column's title and count turn amber.
|
||
- Each project file shows its path and its number of hits. Up to 12 hit lines are shown per file; the count still tells the full number.
|
||
- Each hit line shows its line number and the line, with the match highlighted.
|
||
- In **Files**, the folder sits below the name. An amber dot marks a file with uncommitted git changes.
|
||
|
||
###### Type chips
|
||
- Chips appear when the results hold more than one file type. The most common type comes first.
|
||
- Click a chip to show only that type in Project and Files. Click it again to show every type.
|
||
- Hover a chip to see how many results it has.
|
||
|
||
###### Opening a result
|
||
- Press `Enter` or click a row. Search closes and the file opens in the [file view](file-view.md).
|
||
- A content hit opens the file at that line.
|
||
- Click a file header in Project to open the file at its first hit.
|
||
- A file name opens the file at the top.
|
||
- When the focused column is empty, `Enter` opens the first result of the other kind.
|
||
|
||
###### Mouse and keyboard
|
||
- Moving the pointer over a row selects it and focuses its column.
|
||
- When you move with the keyboard, a pointer that does not move does not steal the selection.
|
||
|
||
###### What is searched
|
||
- The whole project, including dotfiles such as `.env`.
|
||
- Hidden files and folders (those starting with a dot) only show when **Hidden** (`Cmd+.`) is on. See [Layout](layout.md).
|
||
- Some folders are always skipped: `node_modules`, `.git`, `vendor`, `dist`, `build`, `out`, `coverage`, `.cache`, `.next`, `.nuxt`, `.turbo`, `.idea`, `.vscode` and `.helder`.
|
||
- Add your own skips with `files.exclude`.
|
||
- Git-ignored files are searched too, unless you set `files.followGitignore` to `true`.
|
||
|
||
###### No results
|
||
Each column says why it is empty:
|
||
- "Type to search this file." / "No matches in this file."
|
||
- "Type at least two characters." / "No content matches."
|
||
- "Type to search file names." / "No file names match."
|
||
|
||
###### Limits
|
||
- Project: at most 400 files and 50 hits per file. Very long lines are cut.
|
||
- Files: the first 40 matches are listed. The count shows the full number.
|
||
- This file: at most 200 hits.
|
||
- Up to 12 type chips.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+F` | Open Search |
|
||
| `Cmd+Left` / `Cmd+Right` | Previous / next column |
|
||
| `Up` / `Down` | Previous / next row in the column |
|
||
| `Cmd+Up` / `Cmd+Down` | Previous / next row in the column |
|
||
| `Enter` | Open the selected result |
|
||
| `Esc` | Close Search |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `files.exclude` | `[]` | Extra globs to leave out of search and the Explorer. |
|
||
| `files.followGitignore` | `false` | `true` leaves git-ignored files out. |
|
||
|
||
See [Configuration](configuration.md).
|
||
|
||
##### Related
|
||
|
||
- [Go to file](go-to-file.md): jump back to a file you opened before.
|
||
- [File view](file-view.md): where a result opens.
|
||
- [Explorer](explorer.md): uses the same excludes.
|
||
- [Layout](layout.md): the Hidden toggle that shows dotfiles in search.
|
||
- [Title bar](title-bar.md): the Search button.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every key in one list.
|
||
|
||
---
|
||
|
||
### Appendix: guide/go-to-file.md
|
||
|
||
#### Go to file
|
||
|
||
Go to file is the **Recent files** list: a small card at the top of the window with the files you opened in this project, newest first. It opens from the file view with `Cmd+Up` or `Cmd+Down`.
|
||
|
||
[Guide index](index.md) · Related: [Search](search.md), [File view](file-view.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+------------------------------------------------------+
|
||
| (1) Recent files (2) 12 files . Cmd+Dn Cmd+Up Ent |
|
||
+------------------------------------------------------+
|
||
| (3) [php] app.php |
|
||
| src/ |
|
||
| (4)>[php] Handler.php * |
|
||
| src/Http/ |
|
||
| [md] README.md |
|
||
+------------------------------------------------------+
|
||
```
|
||
|
||
1. **Header**: the title of the card.
|
||
2. **Count and keys**: how many files the list holds, and the keys to use.
|
||
3. **Row**: a type badge, the file name, and its folder below it.
|
||
4. **Selected row**: highlighted. An amber dot marks a file with uncommitted git changes.
|
||
|
||
##### Features
|
||
|
||
###### What the list holds
|
||
- Every file you open goes to the top of the list. A file appears only once.
|
||
- The list keeps up to 100 files per project, and is remembered across launches.
|
||
- Renamed files follow their new name. Deleted files drop out.
|
||
- With no history yet, the card says "No files opened yet".
|
||
|
||
###### Opening the list
|
||
- Click in the [file view](file-view.md) so it has the focus, then press `Cmd+Down` or `Cmd+Up`.
|
||
- `Cmd+Down` starts on the previous file (the second row), so one `Cmd+Down` and `Enter` jumps back to it.
|
||
- `Cmd+Up` starts on the current file (the first row).
|
||
- The keys only open the list when there is at least one file in it.
|
||
|
||
###### Moving and opening
|
||
- `Up`/`Down` or `Cmd+Up`/`Cmd+Down` move the selection. It stops at the first and last row.
|
||
- Hover a row to select it. Click a row to open it.
|
||
- `Enter` opens the selected file and closes the card.
|
||
- `Esc`, or a click outside the card, closes it.
|
||
|
||
###### No typing
|
||
- This list has no search field and no fuzzy matching. To find a file by name, use the **Files** column of [Search](search.md) (`Cmd+F`).
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+Down` (in the file view) | Open the list on the previous file |
|
||
| `Cmd+Up` (in the file view) | Open the list on the current file |
|
||
| `Up` / `Down`, `Cmd+Up` / `Cmd+Down` | Move the selection |
|
||
| `Enter` | Open the selected file |
|
||
| `Esc` | Close |
|
||
|
||
##### Related
|
||
|
||
- [Search](search.md): fuzzy file-name search with `Cmd+F`.
|
||
- [File view](file-view.md): where the file opens.
|
||
- [Explorer](explorer.md): the opened file is selected in the tree.
|
||
- [Keyboard shortcuts](keyboard-shortcuts.md): every key in one list.
|
||
|
||
---
|
||
|
||
### Appendix: guide/right-click-menu.md
|
||
|
||
#### Right-click menu
|
||
|
||
Helder draws its own right-click menu, in the same dark style everywhere. This page lists every menu in the app: on Git view rows and the Commit button, in the Explorer, in the code, in the Diff, and in the two terminal panes.
|
||
|
||
[Guide index](index.md) · Related: [Git](git.md), [Explorer](explorer.md), [Dialogs](dialogs.md), [Pass on to Agent](pass-on-to-agent.md), [File view](file-view.md), [File view: Diff](file-view-diff.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| (1) app/Http/UserController.php |
|
||
|----------------------------------------|
|
||
| (2)|* Pass on reference |
|
||
| # Copy reference |
|
||
| * Pass on file name |
|
||
| # Copy file name |
|
||
|----------------------------------------| (3)
|
||
| / Rename file |
|
||
| [] Show in Finder |
|
||
| (4) x Delete file |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
1. **Header**: what you clicked: a path, or the project name ending in `/`. Folder, code, Diff, terminal and commit menus have no header.
|
||
2. **Highlighted item**: an amber rule on the left. The first item is highlighted when the menu opens.
|
||
3. **Separator**: a thin line between groups of items.
|
||
4. **Destructive item**: Delete reads in amber-deep, so it stands out.
|
||
|
||
Each item has a small icon. Add-type items (New file, New folder) have a teal icon. Copy file name and Show in Finder have an amber icon. Read aloud has a speaker icon. Plak has a note icon with a plus.
|
||
|
||
##### Features
|
||
|
||
###### Open, use and close a menu
|
||
|
||
- **Right-click** (or `Ctrl`+click) to open a menu at the pointer.
|
||
- On an [Explorer](explorer.md) row opened with the keyboard, the menu opens beside the column, level with the row, so it never covers the list.
|
||
- **With the keyboard**: in the Explorer, move the row cursor with `Up` / `Down`, then press `Cmd+Right`. The menu opens for the row under the cursor.
|
||
- Inside the menu:
|
||
- `Up` / `Down` (or `Cmd+Up` / `Cmd+Down`) move the highlight. It wraps around and skips separators.
|
||
- Hovering an item highlights it.
|
||
- `Enter` or a click runs the highlighted item.
|
||
- `Esc` closes the menu.
|
||
- A click outside closes the menu, and the click still reaches what you clicked.
|
||
- The row of an open menu stays highlighted until the menu closes.
|
||
- No item is ever greyed out. An item that does not apply is simply not in the menu.
|
||
|
||
###### What the shared items do
|
||
|
||
These items show up in several menus.
|
||
|
||
| Item | What it does | Asks first? |
|
||
|---|---|---|
|
||
| **Pass on reference** | Opens the [Pass on](pass-on-to-agent.md) prompt with the reference. On `Enter`, it lands in the [Claude Code](claude-code.md) input, not sent. | No |
|
||
| **Pass on selection** | The same, with the selected code added below the reference. | No |
|
||
| **Copy reference** | Copies the reference (a path, or `path:line`, or `path:start-end`) to the clipboard. A [notification](notifications.md) says `Copied reference`. | No |
|
||
| **Pass on file name** | Opens the Pass on prompt with only the file name, without folders. | No |
|
||
| **Copy file name** | Copies only the file name. A notification says `Copied`. | No |
|
||
| **Show in Finder** | Opens a Finder window with the item selected. | No |
|
||
| **Read aloud** | Markdown files only. Reads the file aloud with the system voice. Stop it with **Stop** in the [title bar](title-bar.md#read-aloud). | No |
|
||
|
||
###### Git rows
|
||
|
||
Right-click a file row in the [Git](git.md) view. The header is the file's path.
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| app/Http/UserController.php |
|
||
|----------------------------------------|
|
||
| [] Open in editor |
|
||
|----------------------------------------|
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **Open in editor** (bold): closes the Git view and opens the file in the [File view](file-view.md). A deleted file has nothing to open, so its menu holds only the two reference items.
|
||
- **Pass on reference**: closes the Git view, then opens the [Pass on](pass-on-to-agent.md) prompt with the file's path.
|
||
- **Copy reference**: copies the file's path.
|
||
|
||
Stage, unstage, discard, delete and restore are buttons on the row itself, not menu items. See [Row actions](git.md#row-actions).
|
||
|
||
###### Commit menu
|
||
|
||
Click the caret on the right of the **Commit** button in the [Git](git.md) view. The menu hangs under the caret and has no header.
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| v Commit |
|
||
| ^ Commit and push |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **Commit**: the same as the Commit button.
|
||
- **Commit and push** (bold): commits, then pushes when the commit succeeded. See [Git commit form](git-commit-form.md#commit-and-push).
|
||
|
||
###### Explorer: file
|
||
|
||
Right-click a file in the [Explorer](explorer.md). The header is the file's path.
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| app/Http/Kernel.php |
|
||
|----------------------------------------|
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
| * Pass on file name |
|
||
| # Copy file name |
|
||
|----------------------------------------|
|
||
| / Rename file |
|
||
| [] Show in Finder |
|
||
| x Delete file |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
A Markdown file (`.md`) in the Explorer gets one extra group after the copy items:
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| docs/setup.md |
|
||
|----------------------------------------|
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
| * Pass on file name |
|
||
| # Copy file name |
|
||
|----------------------------------------|
|
||
| )) Read aloud |
|
||
|----------------------------------------|
|
||
| / Rename file |
|
||
| ... |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **Read aloud**: reads the headings, paragraphs, list items, quotes and table cells aloud. Markup and link addresses are left out, and code blocks are skipped. The open file is read as it stands in the editor, unsaved edits included. A file with nothing to read shows `Nothing to read`. Reading another file stops the first one.
|
||
|
||
- **Rename file**: opens the [name prompt](dialogs.md#name-prompt) with the current name. Only the part before the extension is selected, so typing keeps the extension.
|
||
- **Delete file**: always asks first; see [Dialogs](dialogs.md#delete-file-or-folder). The file is deleted for good, not moved to the Trash.
|
||
|
||
###### Explorer: folder
|
||
|
||
Right-click a folder. This menu has no header.
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
|----------------------------------------|
|
||
| + New file |
|
||
| + New folder |
|
||
|----------------------------------------|
|
||
| / Rename folder |
|
||
| [] Show in Finder |
|
||
| x Delete folder |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **Pass on reference** and **Copy reference** use the folder path with a trailing `/`, for example `app/Http/`.
|
||
- **New file**: opens the [name prompt](dialogs.md#name-prompt) for a file inside this folder. The new file opens in the [File view](file-view.md).
|
||
- **New folder**: opens the name prompt for a folder inside this folder.
|
||
- **Rename folder**: opens the name prompt with the current name.
|
||
- **Delete folder**: always asks first. The folder and everything inside it are deleted for good.
|
||
|
||
A folder directly inside the top-level `ontwikkelingen/` folder gets one extra group at the top. The archive folder `ontwikkelingen/ontwikkeld/` and deeper folders do not.
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| T Bouwen |
|
||
|----------------------------------------|
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
| ... |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **Bouwen**: inserts `/bouwen <folder name>` into the [Claude Code](claude-code.md) input, not sent. For example `/bouwen 2026-10-02-001-stats`. A [notification](notifications.md) says `Passed to agent`.
|
||
|
||
###### Explorer: empty space
|
||
|
||
Right-click the empty space under the rows of the [Explorer](explorer.md). It stands for the project folder. The header is the project name with a trailing `/`.
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| console/ |
|
||
|----------------------------------------|
|
||
| + New file |
|
||
| [] Show in Finder |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **New file**: a new file in the project root. Type a path with slashes, such as `docs/notes.md`, to create it in a folder.
|
||
- **Show in Finder**: opens the project folder in Finder.
|
||
|
||
There is no New folder here. Type `name/file` in New file, or right-click an existing folder.
|
||
|
||
###### Code in the file view
|
||
|
||
Right-click in the code of the [File view](file-view.md). This menu has no header. The items use the reference:
|
||
|
||
- No selection: the path and the line you clicked, for example `src/app.php:42`.
|
||
- With a selection: the path and the first and last selected line, for example `src/app.php:42-58`.
|
||
|
||
Without a selection:
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
With a selection:
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| * Pass on selection |
|
||
| # Copy reference |
|
||
|----------------------------------------|
|
||
| )) Read aloud selection |
|
||
|----------------------------------------|
|
||
| >> Plak |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
On a marked (teal) line of a changed file:
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
|----------------------------------------|
|
||
| <> Show diff |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **Pass on selection** passes the reference and the selected code. See [Pass on to Agent](pass-on-to-agent.md).
|
||
- **Read aloud selection** reads the selected text aloud. In a Markdown file the markup is left out. Stop it with **Stop** in the [title bar](title-bar.md#read-aloud).
|
||
- **Plak** sends the selected text to [Plak](#plak). On a marked line it comes before Show diff.
|
||
- **Show diff** opens the full-screen [Diff](file-view-diff.md) of the file, centred on the line you right-clicked. Every marked line counts, a blank one and the space after the text included. A new file, where every line is marked, has no Show diff. A left click on a marked line only places the caret.
|
||
- The same menu shows on the rendered [Markdown preview](file-view-markdown.md) and on an image. There it refers to the file's first line, for example `README.md:1`, and has no Read aloud selection and no Plak. To hear a previewed file, right-click it in the Explorer and choose **Read aloud**.
|
||
- `Cmd+Right` with code selected opens the Pass on prompt straight away, without the menu.
|
||
|
||
###### Diff
|
||
|
||
Right-click a line in the full-screen [Diff](file-view-diff.md). The menu stays inside the Diff. It has no header and no Show diff.
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| * Pass on reference |
|
||
| # Copy reference |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- The line number comes from the side you clicked: the left pane gives the old line number, the right pane the new one.
|
||
- An empty half of a row (a line that exists on one side only) refers to line 1.
|
||
- `Up`, `Down`, `Enter` and `Esc` work as in every menu. `Esc` closes the menu first; a second `Esc` closes the Diff.
|
||
|
||
###### Terminal panes
|
||
|
||
Right-click in the [Claude Code](claude-code.md) pane or the [Command line](command-line.md) pane. This menu has no header.
|
||
|
||
With text selected in the pane:
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| # Copy |
|
||
| # Paste |
|
||
|----------------------------------------|
|
||
| )) Read aloud selection |
|
||
|----------------------------------------|
|
||
| >> Plak |
|
||
|----------------------------------------|
|
||
| ? Wait what? |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
Wait what? shows only in the Claude Code pane, not in the Command line pane.
|
||
|
||
Without a selection:
|
||
|
||
```text
|
||
+----------------------------------------+
|
||
| # Paste |
|
||
+----------------------------------------+
|
||
```
|
||
|
||
- **Copy** (only with a selection): copies the selected terminal text.
|
||
- **Paste**: types the clipboard text into that pane, as a normal paste would. With an empty clipboard nothing happens.
|
||
- **Read aloud selection** (only with a selection): reads the selected text with the system voice. Markdown markup is left out. With nothing left to read, a [notification](notifications.md) says `Nothing to read`. Stop it with **Stop** in the [title bar](title-bar.md#read-aloud).
|
||
- **Plak** (only with a selection): sends the selected text to [Plak](#plak).
|
||
- **Wait what?** (Claude Code pane, only with a selection): inserts ``/wait-what `selected text` `` into the [Claude Code](claude-code.md) input, not sent. Spaces and blank lines around the selection are trimmed. A [notification](notifications.md) says `Passed to agent`.
|
||
|
||
###### Plak
|
||
|
||
**Plak** sends the selected text to Plak, the scratchpad app for macOS. Plak must be installed.
|
||
|
||
- The text, with spaces and blank lines around it trimmed, goes to the end of the Plak page as a new block.
|
||
- Plak opens (it starts if it is not running), scrolls to the new block and takes the focus.
|
||
- A blank selection sends nothing. A [notification](notifications.md) says `Nothing to send`.
|
||
- A very long selection (more than about 100 KB) goes through the clipboard. Helder puts your own clipboard back one second later.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+Right` | Open the menu of the row under the cursor (Explorer) |
|
||
| `Up` / `Down` | Move the highlight; wraps around |
|
||
| `Cmd+Up` / `Cmd+Down` | Move the highlight, the same as `Up` / `Down` |
|
||
| `Enter` | Run the highlighted item |
|
||
| `Esc` | Close the menu |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `git.confirmDiscard` | `true` | Discard and Delete on a [Git](git.md) row ask first |
|
||
|
||
Delete file and Delete folder always ask; no setting turns that off.
|
||
|
||
##### Related
|
||
|
||
- [Dialogs](dialogs.md): the confirm dialog and the name prompt that menu items open.
|
||
- [Pass on to Agent](pass-on-to-agent.md): what happens after a Pass on item.
|
||
- [Git](git.md): the rows and the Commit button behind the git menus.
|
||
- [Explorer](explorer.md): the rows behind the file, folder and empty-space menus.
|
||
- [File view: Diff](file-view-diff.md): where Show diff leads.
|
||
- [Notifications](notifications.md): the confirmations after Copy and file actions.
|
||
|
||
---
|
||
|
||
### Appendix: guide/dialogs.md
|
||
|
||
#### Dialogs
|
||
|
||
Helder asks you something in three ways: a confirm dialog before a risky action, a small name prompt for new and renamed entries, and the macOS unsaved-changes alert. This page shows each one, what it says, and which keys answer it.
|
||
|
||
[Guide index](index.md) · Related: [Right-click menu](right-click-menu.md), [Git](git.md), [Explorer](explorer.md), [File view](file-view.md), [Notifications](notifications.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
|//////////////////////////// dimmed window /////////////////////////////////|
|
||
|////////// +------------------------------------------------+ ////////////|
|
||
|////////// | (1) Discard changes to app/Http/User.php? | ////////////|
|
||
|////////// | | ////////////|
|
||
|////////// | (2) This reverts to the last commit and | ////////////|
|
||
|////////// | cannot be undone. | ////////////|
|
||
|////////// | | ////////////|
|
||
|////////// | (3)[ Cancel esc ] (4)[ Discard enter ] | ////////////|
|
||
|////////// +------------------------------------------------+ ////////////|
|
||
|////////////////////////////////////////////////////////////////////////////|
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Title**: the question, often with the path it is about.
|
||
2. **Body**: what will happen. Not every confirm dialog has one.
|
||
3. **Cancel**: closes the dialog and does nothing. Its key is `Esc`.
|
||
4. **Confirm button**: amber-deep, named after the action (Discard or Delete). Its key is `Enter`.
|
||
|
||
##### Features
|
||
|
||
###### Confirm dialog
|
||
|
||
The confirm dialog sits on top of a dimmed window. Nothing else takes keys while it is open.
|
||
|
||
- `Enter` or a click on the confirm button runs the action.
|
||
- `Esc`, a click on **Cancel**, or a click on the dimmed area outside cancels. Nothing changes.
|
||
|
||
Helder shows a confirm dialog for these actions:
|
||
|
||
| Action | Title | Body | Button | When |
|
||
|---|---|---|---|---|
|
||
| Discard (Git view) | `Discard changes to <path>?` | `This reverts to the last commit and cannot be undone.` | Discard | When `git.confirmDiscard` is on (default) |
|
||
| Delete (Git view, new files) | `Delete <path>?` | `New files are removed from disk. This cannot be undone.` | Delete | When `git.confirmDiscard` is on (default) |
|
||
| Delete file | `Delete file?` | `<path> will be permanently deleted.` | Delete | Always |
|
||
| Delete folder | `Delete folder?` | `<path>/ and everything inside it will be permanently deleted.` | Delete | Always |
|
||
|
||
###### Discard changes
|
||
|
||
Comes from **Discard** or **Delete** in the [Git](git.md) view, on a row or as **Discard all** / **Delete all** on a section. With more than one file, the title names the count instead of a path, for example `Discard changes to 3 files?`. When the files include a new file, the body says `New files are removed from disk. This cannot be undone.`
|
||
|
||
On confirm, a changed file loses its unstaged changes: it goes back to its staged version, or to the last commit when nothing is staged. A new file is deleted from disk. An open copy in the [File view](file-view.md) reloads.
|
||
|
||
**Restore** on a deleted file never asks. Stage and unstage never ask either.
|
||
|
||
###### Delete file or folder
|
||
|
||
Comes from **Delete file** or **Delete folder** in the [Explorer](explorer.md). It always asks. On confirm:
|
||
|
||
- The file, or the folder with everything inside it, is deleted for good. It does not go to the Trash.
|
||
- An open file that was deleted closes in the File view.
|
||
- A notification says `Deleted file` or `Deleted folder`, or `Delete failed`.
|
||
|
||
###### Name prompt
|
||
|
||
The name prompt is a small panel for **New file**, **New folder**, **Rename file** and **Rename folder**. It opens where the right-click menu stood. The window is not dimmed.
|
||
|
||
```text
|
||
+------------------------------------------------+
|
||
| (1) [doc] New file (2)esc |
|
||
| +--------------------------------------------+ |
|
||
| | (3) file name... | |
|
||
| +--------------------------------------------+ |
|
||
| (4) creates [ app/Http/... ] |
|
||
| (5) enter create file esc cancel |
|
||
+------------------------------------------------+
|
||
```
|
||
|
||
1. **Title**: a file or folder icon in amber, and `New file`, `New folder`, `Rename file` or `Rename folder`.
|
||
2. **Esc chip**: a reminder that `Esc` closes the prompt.
|
||
3. **Name field**: has the keyboard as soon as the prompt opens. The hint reads `file name…` or `folder name…`.
|
||
4. **Preview**: the path that `Enter` will produce, in an amber chip. It reads `creates` for a new entry and `renames to` for a rename. It shows `…` while the name cannot be used.
|
||
5. **Footer**: the keys: `↵ create file`, `↵ create folder`, `↵ rename file` or `↵ rename folder`, and `esc cancel`.
|
||
|
||
How it works:
|
||
|
||
- Type a name. The preview follows each key.
|
||
- `Enter` creates or renames, then closes the prompt.
|
||
- `Esc`, or a click anywhere outside the panel, cancels.
|
||
- For a rename, the field starts with the current name. Only the part before the extension is selected, so typing a new name keeps `.php` or `.md`.
|
||
|
||
What happens after `Enter`:
|
||
|
||
- **New file**: the file is created empty and opens in the [File view](file-view.md). Its folders expand in the [Explorer](explorer.md).
|
||
- **New folder**: the folder is created and expands.
|
||
- **Rename**: the entry gets its new name. An open file stays open under the new name.
|
||
- A notification confirms: `Created file`, `Created folder`, `Renamed file` or `Renamed folder`, with the new path.
|
||
|
||
###### Names the prompt accepts
|
||
|
||
There are no error messages inside the prompt. Instead, `Enter` does nothing while the preview shows `…`. That happens when:
|
||
|
||
- The name is empty or only spaces.
|
||
- For a rename: the name has a `/`, is `.` or `..`, or is the same as the current name.
|
||
|
||
For **New file** and **New folder**, a name with slashes creates the folders on the way. `tests/Unit/MathTest.php` creates `tests/Unit/` when it does not exist yet. Leading and trailing slashes are dropped. Spaces around the name are trimmed.
|
||
|
||
A rename that only changes capitals (`readme.md` to `README.md`) works.
|
||
|
||
When a file or folder with that name already exists, nothing is overwritten. The prompt closes and a notification says `Create failed` or `Rename failed`, with the name.
|
||
|
||
###### Unsaved changes
|
||
|
||
When the open file has unsaved edits and you are about to lose them, Helder shows the standard macOS alert:
|
||
|
||
```text
|
||
+------------------------------------------------------+
|
||
| (!) Save changes to UserController.php? |
|
||
| |
|
||
| app/Http/UserController.php has unsaved edits. |
|
||
| They are lost if you close without saving. |
|
||
| |
|
||
| [ Save ] [ Don't Save ] [ Cancel ] |
|
||
+------------------------------------------------------+
|
||
```
|
||
|
||
It appears when you:
|
||
|
||
- open another file, or the same file again, from any place;
|
||
- close the file with `Cmd+W`;
|
||
- close the window or switch to another project. Each file with unsaved edits asks in turn.
|
||
|
||
The buttons:
|
||
|
||
- **Save** writes the file, then goes ahead. When the save fails, the file stays open and nothing else happens.
|
||
- **Don't Save** drops the edits and goes ahead.
|
||
- **Cancel** keeps the file, its edits and the selection in the [Explorer](explorer.md). Nothing happens.
|
||
|
||
`Enter` picks **Save**, `Esc` picks **Cancel**, as in every macOS alert.
|
||
|
||
With `editor.autoSave` on, opening another file saves the open one silently, without this alert.
|
||
|
||
##### Keyboard
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Enter` | Confirm dialog: run the action. Name prompt: create or rename. Unsaved alert: Save |
|
||
| `Esc` | Cancel any of the three |
|
||
|
||
##### Settings
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `git.confirmDiscard` | `true` | Ask before Discard and Delete in the Git view |
|
||
| `editor.autoSave` | `false` | Save the open file silently instead of asking, when you open another file |
|
||
|
||
##### Related
|
||
|
||
- [Right-click menu](right-click-menu.md): where most of these dialogs start.
|
||
- [Git](git.md): discard and delete.
|
||
- [Explorer](explorer.md): new, rename and delete.
|
||
- [File view](file-view.md): saving, and the unsaved-edits dot.
|
||
- [Notifications](notifications.md): the message after each action.
|
||
- [Configuration](configuration.md): where the settings live.
|
||
|
||
---
|
||
|
||
### Appendix: guide/keyboard-shortcuts.md
|
||
|
||
#### Keyboard shortcuts
|
||
|
||
Helder is built to run from the keyboard. Press `?` to see a short list of the main shortcuts in an overlay; this page lists every shortcut in the app, grouped by area.
|
||
|
||
[Guide index](index.md) · Related: [Window layout](layout.md), [Title bar](title-bar.md), [Configuration](configuration.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
+----------------------------------------------------------------------------+
|
||
| +----------------------------------------------+ |
|
||
| | (?) Keyboard shortcuts [esc] | (1) |
|
||
| +----------------------------------------------+ |
|
||
| | NAVIGATE (2) | |
|
||
| | [Cmd][F] Search contents and names (3) | |
|
||
| | [Cmd][Up Dn] Move through a list | |
|
||
| | ... | |
|
||
| | AGENT | |
|
||
| | [Cmd][->] Pass the selection to agent | |
|
||
| | ... | |
|
||
| | GIT | |
|
||
| | ... | |
|
||
| | FILE | |
|
||
| | ... | |
|
||
| +----------------------------------------------+ |
|
||
| (dimmed workspace behind) |
|
||
+----------------------------------------------------------------------------+
|
||
```
|
||
|
||
1. **Header**: a question-mark icon, the title and an `esc` chip.
|
||
2. **Group label**: NAVIGATE, AGENT, GIT and FILE.
|
||
3. **Row**: the keys as keycaps, then what they do.
|
||
|
||
##### Features
|
||
|
||
###### The shortcuts overlay
|
||
- 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:
|
||
- **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.
|
||
- **File**: save, Markdown preview, close, refresh, hidden files, select all, Fluid columns, zoom, and `Esc`.
|
||
- The full reference is below.
|
||
|
||
###### How Helder decides who gets a key
|
||
- 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.
|
||
|
||
##### Keyboard
|
||
|
||
###### Window and project
|
||
See [Window layout](layout.md), [Start screen](start-screen.md) and [Recent projects](recent-projects.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Shift+Cmd+N` | New window, on the start screen |
|
||
| `Cmd+O` | Open a folder in this window |
|
||
| `Shift+Cmd+O` | Open a recent project |
|
||
| `Cmd+W` | Close the open file, or the window when no file is open |
|
||
| `Shift+Cmd+W` | Close the window |
|
||
| `Cmd+Q` | Quit (asks about unsaved files first) |
|
||
| `Cmd+R` | Refresh git, the file tree and the open file from disk |
|
||
| `Ctrl+Cmd+F` | Enter or exit full screen |
|
||
| `?` | Keyboard shortcuts overlay (outside text fields and terminals) |
|
||
|
||
###### Layout and focus
|
||
See [Window layout](layout.md) and [Title bar](title-bar.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+1` | Show or hide the Explorer column |
|
||
| `Cmd+2` | Show or hide the File column |
|
||
| `Cmd+3` | Show or hide the Claude column |
|
||
| `Cmd+L` | Fluid column widths on or off |
|
||
| `Cmd+.` | Hidden files on or off |
|
||
| `Cmd+Left` / `Cmd+Right` | Focus the column to the left or right (outside text fields and terminals) |
|
||
| `Cmd++` | Zoom in (code, Diff and terminal text) |
|
||
| `Cmd+-` | Zoom out |
|
||
| `Cmd+0` | Actual size |
|
||
|
||
###### Start screen
|
||
See [Start screen](start-screen.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Up` / `Down`, `Cmd+Up` / `Cmd+Down` | Move the selection |
|
||
| `Return` | Open the selected row |
|
||
|
||
###### Git view
|
||
See [Git](git.md) and [Git commit form](git-commit-form.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+G` | Open or close the Git view |
|
||
| `Esc` | Close the Git view (when nothing is on top of it) |
|
||
| `Cmd+C` | Open the Git view on the commit message (with no text selected, outside a terminal) |
|
||
| `Cmd+Return` | Commit, while the Git view is open (not from the console input) |
|
||
| `Cmd+P` | Push the current branch (also with the view closed) |
|
||
| `Return` | Run the command in the console input |
|
||
| `Up` | Recall the previous console command |
|
||
|
||
###### Explorer
|
||
See [Explorer](explorer.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Up` / `Down` | Move the row cursor (when the column is active) |
|
||
| `Return` | Open the file, or open or close the folder |
|
||
| `Cmd+Right` | Open the selected row's menu |
|
||
|
||
###### File view
|
||
See [File view](file-view.md), [Markdown](file-view-markdown.md) and [Code symbols](code-symbols.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+S` | Save the file |
|
||
| `Cmd+W` | Close the file |
|
||
| `Cmd+M` | Markdown: switch between code and the rendered preview |
|
||
| `Cmd+A` | Select all in the file (also when the code view does not have the keyboard) |
|
||
| `Cmd+Up` / `Cmd+Down` | Open the recent files list (when the File column has focus) |
|
||
| `Tab` / `Shift+Tab` | Indent or outdent the line or selection |
|
||
| `Cmd+click` on a PHP class name | Show its declaration and references |
|
||
| Click a line number | Select that line |
|
||
| `Shift+click` a line number | Extend the selection to that line |
|
||
| Right-click a marked (changed) line, **Show diff** | Open the Diff at that line |
|
||
|
||
###### Recent files list
|
||
See [Go to file](go-to-file.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Up` / `Down`, `Cmd+Up` / `Cmd+Down` | Move the selection |
|
||
| `Return` | Open the selected file |
|
||
| `Esc` | Close the list |
|
||
|
||
###### Diff
|
||
See [Diff view](file-view-diff.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Esc` | Close the menu, then the pass-on prompt, then the Diff itself |
|
||
| `Cmd+A` | Select all lines on one side |
|
||
| `Cmd+C` | Copy the selected lines |
|
||
| `Up` / `Down`, `Return` | Move through and choose in the Diff's right-click menu |
|
||
|
||
###### Pass on to the agent
|
||
See [Pass on to agent](pass-on-to-agent.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+Right` | Pass the selected code to the agent (with a selection in the File column) |
|
||
| `Return` | Insert the reference into the agent |
|
||
| `Esc` | Cancel |
|
||
|
||
###### Search
|
||
See [Search](search.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+F` | Open search; selected text becomes the query |
|
||
| `Cmd+Left` / `Cmd+Right` | Move to the column on the left or right |
|
||
| `Up` / `Down`, `Cmd+Up` / `Cmd+Down` | Move through the results in a column |
|
||
| `Return` | Open the selected result |
|
||
| `Esc` | Close search |
|
||
|
||
###### Clean copy
|
||
See [Clean copy](clean-copy.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Cmd+Enter` | Copy the text and close the card |
|
||
| `Esc` | Close the card without copying |
|
||
|
||
###### Right-click menus and dialogs
|
||
See [Right-click menu](right-click-menu.md) and [Dialogs](dialogs.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Up` / `Down`, `Cmd+Up` / `Cmd+Down` | Move through a menu |
|
||
| `Return` | Choose the menu item, confirm a dialog, or accept a name |
|
||
| `Esc` | Close the menu or dialog |
|
||
| `Ctrl+click` | Same as a right-click on a Git view or Explorer row |
|
||
|
||
###### Terminals
|
||
See [Claude Code](claude-code.md) and [Command line](command-line.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Opt+Left` / `Opt+Right` | Jump back or forward one word (when `terminal.optionIsMeta` is off) |
|
||
| Select text | Copies it to the clipboard |
|
||
|
||
###### Recent projects
|
||
See [Recent projects](recent-projects.md).
|
||
|
||
| Keys | Action |
|
||
|---|---|
|
||
| `Up` / `Down`, `Cmd+Up` / `Cmd+Down` | Move the selection |
|
||
| `Return` | Switch to the selected project |
|
||
| `Esc` | Close the list |
|
||
|
||
##### Related
|
||
|
||
- [Window layout](layout.md): columns, focus and zoom.
|
||
- [Title bar](title-bar.md): the buttons that match many of these shortcuts.
|
||
- [Configuration](configuration.md): `terminal.optionIsMeta` changes what `Opt` does in a terminal.
|
||
|
||
---
|
||
|
||
### Appendix: guide/configuration.md
|
||
|
||
#### Configuration
|
||
|
||
Helder's settings belong to a project. They live in a `.helder` folder in the project root, as plain JSON files you edit in any editor, Helder included.
|
||
|
||
[Guide index](index.md) · Related: [Window layout](layout.md), [Keyboard shortcuts](keyboard-shortcuts.md), [Claude Code](claude-code.md), [Command line](command-line.md)
|
||
|
||
##### At a glance
|
||
|
||
```text
|
||
my-project/
|
||
+-- .helder/ (1)
|
||
| +-- config.json (2) your settings, only what you change
|
||
| +-- config.default.json (3) every setting with its default
|
||
| +-- .gitignore (4) keeps the folder out of git
|
||
| +-- recent.json (5) recently opened files
|
||
+-- .env (6) APP_NAME sets the project title
|
||
```
|
||
|
||
1. **`.helder` folder**: Helder creates it when you open the project.
|
||
2. **`config.json`**: your own settings. You create it. Put in only the keys you want to change.
|
||
3. **`config.default.json`**: the full list of settings and their defaults. Helder rewrites it each time the project opens.
|
||
4. **`.gitignore`**: ignores the whole `.helder` folder, because its content is local to your machine.
|
||
5. **`recent.json`**: the list behind the recent files navigator. See [Go to file](go-to-file.md).
|
||
6. **`.env`**: Helder reads only `APP_NAME` from it, for the project title.
|
||
|
||
##### Features
|
||
|
||
###### `config.json` and `config.default.json`
|
||
- **`config.default.json`** is documentation. Read it to see every setting. Helder rewrites it from its built-in defaults every time the project opens, so it always matches your Helder version. Edits to it are lost and never read.
|
||
- **`config.json`** is yours. Copy only the keys you want to change. Leave the rest out.
|
||
- Helder merges the two key by key. A key in `config.json` wins. A missing key uses the default.
|
||
- A key with a wrong type, or `null`, keeps its default. The rest of the file still works.
|
||
- A file that is not valid JSON is ignored as a whole, and every setting uses its default.
|
||
|
||
Example `config.json`:
|
||
|
||
```json
|
||
{
|
||
"editor": { "autoSave": true, "tabSize": 2 },
|
||
"git": { "defaultDiffMode": "diff" },
|
||
"files": { "exclude": ["vendor/**", "node_modules/**"] }
|
||
}
|
||
```
|
||
|
||
###### When changes take effect
|
||
- Helder watches `config.json`. Save it and the change applies right away to the editor, git prompts, the default diff mode and the terminal look (font, colours, cursor).
|
||
- `files.*` changes apply to the next search, and to the tree the next time it reloads. Press `Cmd+R` to reload it now.
|
||
- A few settings are read when the project opens: `ai.command`, `ai.autoLaunch`, `terminal.shell` and `git.refreshInterval`. Reopen the project, or open another one and come back, to apply them.
|
||
|
||
###### Project title
|
||
- The project title is the `APP_NAME` value from the project's `.env` file, when it has one. Quotes around the value are removed.
|
||
- Without `APP_NAME`, the title is the folder name.
|
||
- The title shows in the Dock, in `Cmd+Tab` and in the Dock's right-click menu. See [Window layout](layout.md).
|
||
|
||
###### Session restore
|
||
- With `session.restoreOnLaunch` on, a project reopens on the file you had open, in the same view (code or Markdown preview).
|
||
- A file that was in the full-screen Diff reopens on the live file.
|
||
- The column layout (which columns show, Fluid on or off, the locked widths) always comes back, whatever this setting says. See [Window layout](layout.md).
|
||
|
||
###### Things that are not settings
|
||
- There is no theme and no light mode. Helder is dark only.
|
||
- The code font and size are built in. Use zoom (`Cmd++`, `Cmd+-`, `Cmd+0`) to change the size of the code and terminal text.
|
||
- **Hidden** files (`Cmd+.`) and **Fluid** widths (`Cmd+L`) are toggles in the [title bar](title-bar.md), not settings.
|
||
|
||
##### Settings
|
||
|
||
###### ai: the Claude pane
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `ai.command` | `"claude"` | The command the Claude pane runs when the project opens |
|
||
| `ai.autoLaunch` | `true` | Run `ai.command` when the project opens. When off, the Claude pane starts as a plain shell |
|
||
|
||
###### editor: the File view
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `editor.autoSave` | `false` | Save edits on their own 0.6 seconds after the last keystroke, without a "Saved" toast. Opening another file saves silently instead of asking |
|
||
| `editor.tabSize` | `4` | Spaces per indent step for `Tab` and `Shift+Tab`. Helder indents with spaces |
|
||
| `editor.wordWrap` | `"markdown"` | Fold long lines: `"off"` never, `"on"` always, `"markdown"` only in Markdown files. The Diff never wraps |
|
||
|
||
###### git: the Git view
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `git.confirmDiscard` | `true` | Ask before Discard and Delete in the Git view. Restore never asks |
|
||
| `git.defaultDiffMode` | `"updated"` | How a changed file opens: `"updated"` on the live file, `"diff"` in the full-screen Diff |
|
||
| `git.refreshInterval` | `10000` | Milliseconds between automatic git status checks. `0` turns the check off. File watching still works |
|
||
|
||
`git.confirmStage` and `git.confirmUnstage` are gone: staging never asks. An older `config.json` that still has them loads fine; Helder ignores them.
|
||
|
||
###### files: the Explorer and search
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `files.exclude` | `[]` | Glob patterns to leave out of the Explorer and search, for example `"vendor/**"` |
|
||
| `files.followGitignore` | `false` | Also leave out files that git ignores. Off by default, so files like `.env` stay visible |
|
||
|
||
###### terminal: both terminal panes
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `terminal.shell` | `null` | The shell for both panes. `null` uses your login shell (`$SHELL`) |
|
||
| `terminal.fontFamily` | `null` | Terminal font. `null` uses the built-in IBM Plex Mono |
|
||
| `terminal.fontSize` | `null` | Terminal font size in points. `null` uses Helder's default size |
|
||
| `terminal.lineHeight` | `1.7` | Line height, as a multiple of the font size |
|
||
| `terminal.letterSpacing` | `0` | Extra space between letters |
|
||
| `terminal.cursorStyle` | `"bar"` | Cursor shape: `"bar"`, `"block"` or `"underline"` |
|
||
| `terminal.cursorBlink` | `true` | Blink the cursor |
|
||
| `terminal.boldIsBright` | `false` | Show bold text in the bright colour. Off keeps bold text in its own colour |
|
||
| `terminal.scrollback` | `8000` | Lines kept in the scroll history |
|
||
| `terminal.optionIsMeta` | `false` | Use `Opt` as the Meta key, for tools that need `Opt+Return`. When on, `Opt` no longer types accents and `Opt+Left/Right` no longer jump by word |
|
||
| `terminal.theme` | Helder dark | The terminal colours, see below |
|
||
|
||
###### terminal.theme: terminal colours
|
||
|
||
Every value is a CSS colour string, such as `"#E8913A"` or `"rgba(232,145,58,0.22)"`. Set only the ones you want to change.
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `background` | `#101720` | Pane background |
|
||
| `foreground` | `#E4E7E6` | Normal text |
|
||
| `cursor` | `#E8913A` | Cursor colour |
|
||
| `cursorAccent` | `#101720` | Text under a block cursor |
|
||
| `selectionBackground` | `rgba(232,145,58,0.22)` | Selection in the focused pane |
|
||
| `selectionInactiveBackground` | `rgba(232,145,58,0.12)` | Selection in a pane without focus |
|
||
| `black` / `brightBlack` | `#232C39` / `#6C7783` | ANSI black |
|
||
| `red` / `brightRed` | `#C4741F` / `#E8913A` | ANSI red |
|
||
| `green` / `brightGreen` | `#8FBFB4` / `#A6D2C7` | ANSI green |
|
||
| `yellow` / `brightYellow` | `#F0B476` / `#F5C79A` | ANSI yellow |
|
||
| `blue` / `brightBlue` | `#8FA9C4` / `#A9BFD6` | ANSI blue |
|
||
| `magenta` / `brightMagenta` | `#C3A6CE` / `#D6BFDF` | ANSI magenta |
|
||
| `cyan` / `brightCyan` | `#8FC4C4` / `#A9D6D6` | ANSI cyan |
|
||
| `white` / `brightWhite` | `#BAC0C0` / `#F4F5F4` | ANSI white |
|
||
|
||
###### session
|
||
|
||
| Setting | Default | Effect |
|
||
|---|---|---|
|
||
| `session.restoreOnLaunch` | `true` | Reopen the last open file and its view when the project opens |
|
||
|
||
##### Related
|
||
|
||
- [Window layout](layout.md): what Helder remembers outside these files.
|
||
- [Claude Code](claude-code.md): the pane `ai.*` controls.
|
||
- [Command line](command-line.md): the shell pane `terminal.*` controls.
|
||
- [Git](git.md): the prompts and refresh that `git.*` controls.
|
||
- [Explorer](explorer.md) and [Search](search.md): what `files.*` leaves out.
|
||
- [File view](file-view.md): what `editor.*` controls.
|
||
- [Diff view](file-view-diff.md): `git.defaultDiffMode`.
|
||
|
||
---
|
||
|
||
### Appendix: behaviour.md (original functional design; partly outdated, see conflicts in sections 1–8)
|
||
|
||
#### Helder Functional Design
|
||
|
||
This document describes how Helder behaves: every panel, interaction, and state, at the functional and UX level. It does not cover technical architecture. It is written to match the agreed user interface exactly.
|
||
|
||
Helder is a dark, AI-first macOS code editor for reviewing and navigating code written by an AI agent. It opens one project per window and has no light mode and no theme toggle.
|
||
|
||
---
|
||
|
||
##### 1. Window layout
|
||
|
||
The window has three horizontal regions stacked top to bottom:
|
||
|
||
1. A top bar.
|
||
2. The main body, split into three resizable columns.
|
||
3. A bottom status bar.
|
||
|
||
The three columns of the body, left to right, are:
|
||
|
||
1. **Explorer** (file tree)
|
||
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.
|
||
|
||
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.
|
||
|
||
The interface is dark only. Code is always syntax highlighted, in every panel and every view.
|
||
|
||
---
|
||
|
||
##### 2. Top bar
|
||
|
||
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.
|
||
- 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.
|
||
|
||
---
|
||
|
||
##### 3. Git view
|
||
|
||
A full-screen view over the whole window (top bar, columns and status bar) for staging, committing, pulling, pushing and switching branches. `Cmd+G`, the `Git N` toggle and View › Show Git open it. `Cmd+G`, `Esc` and its **Close** button close it. Dialogs, context menus, search, the Diff and toasts sit above it. The columns stay mounted under it, so terminals keep running and the editor keeps its state. Opening it puts the keyboard in the commit message; closing it hands the keyboard back to the column that had it. It is not persisted: a project always opens with it closed.
|
||
|
||
While it is open, the columns' row, focus and editor keys rest. `Cmd+Return` commits, except from the console input. The other `Cmd` shortcuts keep working. `Cmd+C` with no selection, outside a terminal, opens the view on the commit message. `Esc` closes the topmost layer: an overlay (context menu, dialog, search, Diff) first, then the Git view; with neither open it reaches the terminal.
|
||
|
||
From top to bottom:
|
||
|
||
###### Top bar
|
||
|
||
`[ git ]`, the current branch in amber, and its place against the upstream: `in sync with origin`, `N ahead of origin`, `N behind origin`, `N ahead · M behind origin`, or `no upstream`. Ahead and behind come from the status header. On the right: **Pull** (with `↓N` when behind), **Push** (with `↑N` when ahead) and **Close** (`⌘G`).
|
||
|
||
Opening the view reads the author and the branches, re-reads git and runs `git fetch origin`, but only when an origin exists, so ahead/behind are current.
|
||
|
||
- **Pull** runs `git pull --no-rebase`: diverged branches merge instead of failing on an unset `pull.rebase`.
|
||
- **Push** runs `git push`; when git reports there is no upstream, it retries with `git push -u origin <branch>`. `Cmd+P` pushes from anywhere.
|
||
- Both time out after 120 seconds. While one runs its button reads `Pulling…` / `Pushing…`, the console header says so, and a second pull or push is ignored. Git never prompts: no terminal prompt, no editor, no pager.
|
||
- The result is a toast: `Pushed N commits to origin/<branch>`, `Pulled N commits from origin/<branch>`, or `Push failed` / `Pull failed` with git's first error line.
|
||
|
||
###### Commit block
|
||
|
||
- The **commit message**: always one lowercase line. Capitals become lowercase and line breaks become spaces as the user types or pastes, so `Enter` never starts a second line. The field grows with wrapped text from 56 to 180 points. An amber underline shows focus.
|
||
- The **author**, `user.name <user.email>` from git config.
|
||
- A `⌘↵ commits` hint.
|
||
- A **Commit** split button: `Commit N files`, or `Nothing staged`. It is amber when something is staged and the message is not empty, grey otherwise. The caret opens **Commit** and **Commit and push**.
|
||
- A commit always runs `git commit -m`, also from the grey button, so git's own refusal shows in the console. On success the message clears and a toast says `Committed N files` with the subject; on failure the message stays, a toast says `Commit failed`, and an empty message takes the focus back. **Commit and push** pushes only after a successful commit.
|
||
|
||
###### Sections
|
||
|
||
Four colour-coded sections, each only when it has rows, in this order:
|
||
|
||
1. **staged**: every staged row, whatever its status. Row and bulk action: **Unstage** / **Unstage all**.
|
||
2. **changed**: unstaged edits to tracked files, including renames and conflicts. **Discard** and **Stage**.
|
||
3. **new · untracked**: **Delete** and **Stage**.
|
||
4. **deleted**: **Restore** and **Stage**.
|
||
|
||
- A header shows the name, a count badge and the bulk actions; a click folds the section.
|
||
- A row shows a chevron, a status badge (`A`, `M`, `D`, `R`, `U`), the path (folder dim, name bright, struck through when deleted), `+N` / `−N`, and its actions. A click expands an inline side-by-side diff of that row's half, last commit (or index) left and working tree right, with 3 lines of context around each change and longer unchanged runs folded into `⋯ N unchanged lines`. A file over the diff cap shows `Too big.`.
|
||
- A conflicted row offers only **Stage**: staging marks the resolution.
|
||
- **Discard** reverts unstaged changes (modified and deleted files from the index, new files removed). **Discard** and **Delete** ask first (`git.confirmDiscard`, default on); **Restore** never asks. Stage and unstage never ask.
|
||
- **Right-click** a row: **Open in editor** (left out for a deleted file), **Pass on reference**, **Copy reference**. Open in editor and Pass on reference close the view first.
|
||
|
||
###### Console
|
||
|
||
The bottom-left panel. Every action logs the exact git command (`$ git add -- path`) and streams its output line by line, coloured by kind: errors, hints, staged and unstaged lines of `status`, and the ref update of a push. Below the log, a `$ git` input runs typed commands, with or without a leading `git`. `clear` empties the log, a bare `log` runs `log --oneline --decorate -n 30`, and `Up` recalls earlier input. Commands, typed or from buttons, run one at a time. The log keeps the last 400 lines.
|
||
|
||
###### Branches
|
||
|
||
The bottom-right panel: **local** branches, then **remote · origin**. The current branch is marked; a remote branch with a local counterpart reads `tracked`. A click switches (`switch →`); a remote branch without a local one is checked out as a new tracking branch (`checkout →`). While there are uncommitted changes, switching is locked: the header says so, the other branches dim, and a click shows a toast instead of running git.
|
||
|
||
###### Empty states
|
||
|
||
- Not a repository: `— Not a git repository.`
|
||
- Clean working tree: `— No changes. The working tree is clean.`
|
||
|
||
---
|
||
|
||
##### 4. Explorer panel
|
||
|
||
The second column. A standard project file tree.
|
||
|
||
- An `EXPLORER` header.
|
||
- Folders expand and collapse. Files and folders use type icons.
|
||
- Files that have changes show their status letter (`A`, `M`, `D`) on the right of their row.
|
||
- **Left-click** a file opens it in the editor. The selected file is highlighted.
|
||
- The tree hides paths matched by `files.exclude` and, when `files.followGitignore` is on, paths ignored by git.
|
||
- **Right-click** a file offers **Copy reference**, which copies the file's project-relative path to the clipboard (the file-level form of the editor's Copy reference).
|
||
- A Markdown file (`.md`) also offers **Read aloud**, in its own group after the pass-on and copy items, in the Explorer. Helder reads the text with the system voice: headings, paragraphs, list items, quotes and table cells, with the markup and link URLs left out and code blocks skipped. The open file is read as it stands in the editor, unsaved edits included. A file with nothing to read shows `Nothing to read`. A new Read aloud replaces the one that is playing. A `$` is read as "dollar", except before a digit (`$5` stays "five dollars").
|
||
|
||
---
|
||
|
||
##### 5. 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.
|
||
|
||
###### Editor bar
|
||
|
||
A row above the code, holding for the open file, left to right:
|
||
|
||
- A type badge and the project-relative path.
|
||
- An unsaved indicator (a dot) when the file has unsaved edits. This matters because auto-save is off by default (`editor.autoSave`).
|
||
- For a file with changes relative to its committed state, the change counts: additions in teal (`+N`) and deletions in amber-deep (`−N`).
|
||
- On the right, a **Preview** button on Markdown files and a **Diff** button on changed files. The button of the active view is highlighted.
|
||
|
||
With no file open, the bar stays empty.
|
||
|
||
###### Views
|
||
|
||
All are presentations of the same file:
|
||
|
||
1. **The live file**: the current, editable version. On a changed file it marks the changed lines in place, with a teal tint, a 2px teal left rule, and a teal line number. There is no sign column, no `+` or `-` pair, and no removed line inline. A pure deletion has no current line to mark, so the neighbouring current line carries a 2px amber-deep rule on its top edge, or on its bottom edge at the end of the file. An unchanged file shows plain code.
|
||
2. **Preview**: Markdown files only. It shows the rendered document instead of the source. `Cmd+M` switches a Markdown file between code and the rendered preview.
|
||
3. **Diff**: changed files only. The editor expands to full screen, covering the other columns. The original file is on the left and the updated file is on the right, lines aligned. `Esc`, or a collapse control in the corner, returns to the live file.
|
||
|
||
A changed file opens on the live file, or on the Diff when `git.defaultDiffMode` is `diff`.
|
||
|
||
**On the live file, Show diff in the right-click menu of a marked line opens the Diff.** A left click on a marked line places the caret like on any line. The full-screen side-by-side view comes up on the pair of the whole file, HEAD against disk, and both panes scroll so that the right-clicked line sits in the middle of the window. A line near the start or the end of the file goes as near to the middle as the file permits. `Esc` returns to the live file. Hover does nothing, and there is no animation. A new file, where every line is marked, offers no Show diff.
|
||
|
||
Shared rules: teal is what the file holds now, amber-deep is what it held before. There is no green and no red anywhere. Syntax highlighting stays on in all modes. Line numbers follow `editor.lineNumbers` (default absolute).
|
||
|
||
###### 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).
|
||
- **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
|
||
|
||
Right-clicking inside the code area, with or without a selection, shows a context menu without a header line, with two items:
|
||
|
||
1. **Copy reference**: copies a reference to the clicked location to the clipboard. With no selection it is path plus single line, for example `src/Http/Controller/UserController.php:42`. With a selection it is path plus start and end line, for example `src/Http/Controller/UserController.php:42-58`. The path is project-relative.
|
||
2. **Pass on to Agent**: opens a small inline input popup anchored near the click or selection, with a single optional text field. On confirm (`Enter`), it composes one line, the typed text followed by the same reference, and inserts it into the agent pane's input. The insert does **not** submit. It lands as a new, unsubmitted line and the cursor sits on a fresh line, so the action can be repeated to stack several references before the user sends. `Esc` cancels with no insert. An empty field passes the bare reference.
|
||
|
||
With a selection, a separator and **Read aloud selection** follow Copy reference. It reads the selected text with the system voice; in a Markdown file the selection is read as prose, the markup left out. The rendered Markdown preview has no Read aloud selection; its selection is not Helder's (use Read aloud on the file).
|
||
|
||
With a selection, a separator and **Plak** follow Read aloud selection. It sends the selected text to Plak, the user's scratchpad app; see [Plak](#plak). The preview has no Plak.
|
||
|
||
On a marked line of the live file (any marked line, blank lines and the space after the text included), a separator and a last item follow: **Show diff**, which opens the Diff centred on that line. A new file, Preview and the Diff's own menu have no Show diff.
|
||
|
||
###### File-state behavior in the views
|
||
|
||
- **Added file**: only the current content exists. The live file marks every line as added, and Diff shows an empty left pane with the file on the right.
|
||
- **Deleted file**: only the committed content exists. The editor shows a short placeholder saying there is no updated version, and Diff shows the file on the left with an empty right pane.
|
||
- **Binary or unsupported file**: cannot be shown as editable text. The editor shows a short placeholder stating the file cannot be displayed, and the Preview and Diff buttons are not shown.
|
||
|
||
---
|
||
|
||
##### 6. Agent pane
|
||
|
||
The top pane of the fourth column.
|
||
|
||
- A `claude` header with an `agent session` label.
|
||
- It is a single terminal running the configured agent command. On launch it auto-runs that command when `ai.autoLaunch` is on (default), using `ai.command` (default `claude`).
|
||
- The pane shows the live agent session and has an input line at the bottom.
|
||
- It receives the **Pass on to Agent** inserts from the editor: text arrives in the input as content, never as a submitted command, so the user can stack several and send when ready.
|
||
- It is one terminal only. There are no additional agent sessions in this version.
|
||
- Both terminals run with `TERM_PROGRAM=Helder` in their environment, so the agent can tell it runs inside Helder.
|
||
|
||
###### Clean copy
|
||
|
||
The agent hands the user text to copy through one file, `.clean-copy` in the project root. The agent overwrites the file each time; Helder only reads it and never clears or deletes it.
|
||
|
||
- When the file's contents change while the project is open, Helder reads it after a short pause (writes are not atomic) and opens the **From Claude** popup, a card at the top of the window. The contents found when the project opens are the baseline and never open the popup. An empty or blank file, or the same text as last seen, opens nothing.
|
||
- The popup holds an editable text area. **Copy** (or `Cmd+Enter`) copies the text, with the user's edits, to the clipboard as plain text, closes the popup and shows the "Copied" toast. `Esc` or a click outside closes it without copying.
|
||
- With another overlay open, the newest text waits and opens once that overlay closes. New text while the popup is open replaces its text only when the user has not edited it.
|
||
- The popup opens in the project's own window even when that window is in the background; Helder does not take focus.
|
||
|
||
---
|
||
|
||
##### 7. Terminal pane
|
||
|
||
The bottom pane of the fourth column.
|
||
|
||
- A header showing the shell and working directory, for example `zsh` and the project path.
|
||
- It is a single shell terminal. It uses the operating system default shell, or the override in `terminal.shell` when set.
|
||
- It behaves as a normal terminal for that shell.
|
||
- It is one terminal only. There are no additional terminals in this version.
|
||
|
||
###### Right-click in a terminal
|
||
|
||
Right-clicking in the agent pane or the terminal pane shows a menu without a header line. With a selection it holds **Copy**, **Paste**, a separator, **Read aloud selection**, a separator and **Plak**; the agent pane adds a separator and **Wait what?**. Without a selection it holds only **Paste**.
|
||
|
||
**Read aloud selection** reads the selected text with the system voice, as prose with the Markdown markup left out. A selection with no prose left, such as one code block, is read as it is. Blank text reads nothing and shows the toast "Nothing to read".
|
||
|
||
###### Plak
|
||
|
||
**Plak** (code and terminal menus, only with a selection) sends the selected text, trimmed, to Plak, the user's macOS scratchpad app. The text lands at the end of the Plak page as a new block; Plak opens (it starts if needed), scrolls to the block and takes the focus. Blank text sends nothing and shows the toast "Nothing to send". Text up to about 100 KB goes in the URL; longer text goes through the clipboard, and Helder restores the user's clipboard one second later. The URL contract is in [plak.md](plak.md).
|
||
|
||
---
|
||
|
||
##### 8. Status bar
|
||
|
||
A bar across the bottom of the window. All items are **display only** for now; none are clickable.
|
||
|
||
- On the left: the current branch and the working-tree line totals, for example `feat/payments-balance +50 -38`.
|
||
- On the right: cursor position (`Ln, Col`), indentation (`Spaces: 4`), encoding (`UTF-8`), language (`PHP`), and the active view.
|
||
|
||
---
|
||
|
||
##### 9. Global interactions
|
||
|
||
###### Go to File (`Cmd+P`)
|
||
|
||
Opens a fuzzy file-open overlay. The user types part of a file name or path, the list narrows as they type, and selecting a result opens that file in the editor. `Esc` closes the overlay.
|
||
|
||
###### Search (`Cmd+F`)
|
||
|
||
Opens a modal search overlay that searches the open file, file contents and file names at once. Like the Git view, it covers the whole window edge to edge, title bar and status bar included: no margin, no dimmed background, no card. It sits above the Git view when opened from there; toasts sit above it.
|
||
|
||
Inside the overlay:
|
||
|
||
- A query field at the top, with the type chips and a summary.
|
||
- Result columns below, each with a fixed share of the width that never changes when the focus moves:
|
||
- **This file** (30 percent, only when a file is open): matches in the open file.
|
||
- **Project** (45 percent, 65 percent without This file): matches found inside files, grouped by file, each match shown as the matching line with the query highlighted in context.
|
||
- **Files** (25 percent, 35 percent without This file): files whose name or path matches the query.
|
||
- The focused column shows its focus only by its amber title and count.
|
||
- Selecting a content result opens the file and jumps to that line. Selecting a file-name result opens that file.
|
||
- When nothing matches, each column shows a brief no-results message.
|
||
- `Esc` closes the overlay; there is no area to click to close it. The respected excludes are the same as the Explorer (`files.exclude` and, when on, gitignore).
|
||
|
||
###### Mouse pointer
|
||
|
||
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.
|
||
- **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.
|
||
|
||
###### Pane resizing
|
||
|
||
Dragging any splitter resizes the adjacent panes. Positions persist across launches.
|
||
|
||
###### Pane toggles
|
||
|
||
Each column toggle in the title bar shows or hides its column; `Cmd+1`, `Cmd+2` and `Cmd+3` do the same for Explorer, File and Claude. Hiding only hides: the terminals and their processes, the editor buffer and scroll, and the Explorer's expanded folders survive any number of hide/show cycles. The editor absorbs the freed width; with the editor hidden the Agent and Terminal column fills the rest. With every column off the body shows the editor background. A hidden column cannot take focus, and hiding the focused column hands the keyboard back to the window. The three flags are saved per project. A saved layout from before the Git view still loads; its Git width and flag are ignored.
|
||
|
||
###### Session restore
|
||
|
||
When `session.restoreOnLaunch` is on (default), reopening a project restores the previously open file, its view, and the pane and splitter layout.
|
||
|
||
---
|
||
|
||
##### 10. Configuration
|
||
|
||
Settings are project-scoped and live in a `.helder` folder in the project root.
|
||
|
||
- **`.helder/config.json`**: the user's settings. It is sparse and holds only the values the user has overridden.
|
||
- **`.helder/config.default.json`**: the full set of defaults, with a default for every value. Helder regenerates this file on launch from its built-in defaults, so it always matches the installed version and serves as live documentation of every available setting. The app never reads user edits from this file.
|
||
- **Effective value** of any setting: the value from `config.json` if present, otherwise the value from `config.default.json`, merged key by key.
|
||
- There is no theme file. The code font and size are built in; `Cmd+0`, `Cmd++` and `Cmd+−` zoom the editor, Diff and terminal text.
|
||
|
||
Settings that affect behavior described above include indentation and editor display, file and search excludes, the default diff mode (`updated` or `diff`), the git discard confirmation, the terminal shell override, the agent auto-launch and command, and session restore.
|
||
|
||
---
|
||
|
||
##### 11. 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.
|
||
- **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.
|
||
|
||
---
|
||
|
||
##### Open assumptions to confirm
|
||
|
||
- In the Search overlay, content matches are on the left (70 percent) and file-name matches on the right (30 percent). Confirm this assignment, or swap the two sides.
|
||
- The editor bar shows an unsaved indicator because auto-save defaults to off. Confirm that behavior is wanted.
|
||
- The Explorer right-click offers a file-level Copy reference (path only), consistent with the editor's Copy reference. Confirm this is in scope.
|
||
|
||
---
|
||
|
||
### Appendix: plak.md (the plak:// URL contract)
|
||
|
||
#### Plak URL scheme
|
||
|
||
Plak is the user's scratchpad app for macOS. Other apps add text to it through two `plak://` URLs. This page is the contract that Helder relies on.
|
||
|
||
##### `plak://append?text=<text>`
|
||
|
||
Adds the text at the end of the Plak page, as a new block with its own created date.
|
||
|
||
- Percent-encode the text as a URL query value: space `%20`, newline `%0A`, `&` `%26`, `+` `%2B`, `#` `%23`.
|
||
- Never encode a space as `+`. Plak keeps a `+` literal, so the block would show `+` signs.
|
||
- Plak detects the content type as for a paste. PHP, JSON, XML and CSV become a code block or a table. All other text becomes plain text.
|
||
|
||
##### `plak://paste`
|
||
|
||
Adds the current contents of the macOS general pasteboard, text or images.
|
||
|
||
- Use it for images and for text over about 100 KB, where a long URL can fail to open.
|
||
- Put the content on the pasteboard first, then open the URL.
|
||
- Save the user's clipboard before, and restore it one second after.
|
||
|
||
##### What Plak does
|
||
|
||
- Plak starts if it is not running. It shows its window, scrolled to the new content, and takes the focus.
|
||
- An empty or missing `text` adds nothing, but Plak still shows.
|
||
- Every other `plak://` URL does nothing.
|
||
- There is no callback and no error result. The sender cannot know if the add worked.
|
||
|
||
##### Opening the URL
|
||
|
||
```sh
|
||
open "plak://append?text=Hello%20from%20my%20app"
|
||
```
|
||
|
||
```swift
|
||
var components = URLComponents()
|
||
components.scheme = "plak"
|
||
components.host = "append"
|
||
components.queryItems = [URLQueryItem(name: "text", value: text)]
|
||
// URLQueryItem leaves "+" as it is; encode it yourself.
|
||
components.percentEncodedQuery = components.percentEncodedQuery?
|
||
.replacingOccurrences(of: "+", with: "%2B")
|
||
if let url = components.url { NSWorkspace.shared.open(url) }
|
||
```
|
||
|
||
```applescript
|
||
open location "plak://append?text=Hello%20from%20my%20app"
|
||
```
|
||
|
||
```js
|
||
shell.openExternal("plak://append?text=" + encodeURIComponent(text))
|
||
```
|
||
|
||
```python
|
||
subprocess.run(["open", "plak://append?text=" + urllib.parse.quote(text, safe="")])
|
||
```
|
||
|
||
##### In Helder
|
||
|
||
- The **Plak** item in the right-click menu of the code and of both terminal panes uses this scheme. See [behaviour.md](behaviour.md#plak) and the [right-click guide](guide/right-click-menu.md#plak).
|
||
- URL building and the 100 KB choice: `Plak` in `Sources/HelderCore/Files/Plak.swift`. The limit counts UTF-8 bytes.
|
||
- Opening the URL and the clipboard save and restore: `SystemActing.sendToPlak` in `Sources/HelderUI/Shell/SystemActions.swift`.
|
||
|
||
Plak replaces Helder's old project note (`.notes.txt`, `Cmd+N`), which is gone.
|
||
|
||
---
|
||
|
||
### Appendix: design handoff v2 README (design source of the Git view)
|
||
|
||
#### Handoff: Helder App v2 — full-screen Git view
|
||
|
||
##### Overview
|
||
Helder is a desktop IDE shell for one developer working with Claude Code. It has a title bar, an Explorer (file tree), a File editor, a Claude transcript with prompt and terminal, a status bar, plus overlays for search and file diff.
|
||
|
||
**v2 replaces the old 264px Git sidebar with a full-screen Git view.** Press **⌘G** to toggle it. The view covers the whole window, the same way the file diff overlay does. In it the user can:
|
||
|
||
- see staged, changed, new (untracked) and deleted files, each in its own colour-coded section, with **Staged always on top**
|
||
- expand any file to see an inline side-by-side diff with collapsed context
|
||
- stage, unstage, discard, delete or restore files one at a time or in bulk
|
||
- write a commit message and commit, or commit and push
|
||
- pull and push, with ahead/behind counts
|
||
- read the real git commands and their output in a **console**, and type git commands there
|
||
- see local and remote **branches** and switch between them, but only when the working tree is clean
|
||
|
||
Everything outside the Git view works as it did in v1 (Explorer, File, Claude, terminal, search, diff, menus, modals). The only exceptions are the changed shortcuts listed below.
|
||
|
||
##### About the design files
|
||
The files in this bundle are **design references created in HTML**. They are prototypes that show the intended look and behaviour; they are not production code to copy. The task is to **recreate this design in Helder's real codebase**, using its existing framework, state management and git layer. If no environment exists yet, pick the best fit; for a desktop IDE shell that is likely Electron or Tauri, with React and a real git backend such as `simple-git`, `isomorphic-git` or shelling out to `git`.
|
||
|
||
The prototype fakes git: file contents live in memory, and console output is simulated. The real build must run real git commands and stream their real stdout and stderr into the console.
|
||
|
||
##### Fidelity
|
||
**High-fidelity.** Colours, type, spacing, states and copy are final. Recreate them pixel-precisely with the codebase's own components. The visual language is the Blijnder **Kade** design system in its dark (slate) application: IBM Plex Mono and IBM Plex Sans, flat fields, 2px radii, amber as the only accent, no shadows except on menus and modals.
|
||
|
||
---
|
||
|
||
##### Keyboard shortcuts (v2)
|
||
| Key | Action |
|
||
|---|---|
|
||
| ⌘G / Ctrl+G | Open or close the Git view |
|
||
| ⌘1 / ⌘2 / ⌘3 | Toggle Explorer / File / Claude (in v1 this was ⌘1–4, with Git on ⌘1) |
|
||
| ⌘F | Search the project |
|
||
| ⌘L | Fluid (soft wrap) |
|
||
| ⌘. | Show hidden files |
|
||
| ⌘N | Scratch note |
|
||
| ⌘↵ (in the commit message) | Commit |
|
||
| ↑ (in the console input) | Recall the last command |
|
||
| Esc | Closes the topmost layer, in this order: context menu → modal → search → file diff → Git view → interrupts Claude |
|
||
|
||
The title-bar panel toggle group now reads `Git N · Explorer · File · Claude`. **N** is the number of changed files, and the Git button's dot is amber while the view is open.
|
||
|
||
---
|
||
|
||
##### Screen: Git view (full screen)
|
||
|
||
A `position: fixed; inset: 0` layer, `z-index: 44`, background `#101720`, min-width 900px, laid out as a flex column. It sits above the app shell and below the file diff overlay (45), context menu (60/61), modal (70) and toast (80). This lets the confirm modals and the commit menu appear on top of it.
|
||
|
||
From top to bottom:
|
||
|
||
###### 1. Top bar — 44px
|
||
- Background `#18202B`, bottom border `1px #232C39`, padding `0 14px`, flex row, gap 14px, items centred.
|
||
- **`[ GIT ]`**: Plex Mono 700, 11px, letter-spacing .14em, uppercase, `#828D9A`.
|
||
- **Branch**: Lucide `git-branch` icon at 13px, then the branch name. Plex Mono 500, 12px, `#E8913A`, truncated with an ellipsis.
|
||
- **Sync label**: Plex Mono 400, 12px, `#828D9A`. Text is `2 behind origin`, `1 ahead · 2 behind origin`, or `in sync with origin`.
|
||
- A flex spacer, then three buttons, each 28px tall:
|
||
- Shared style: padding `0 11px`, border `1px #232C39`, radius 2px, transparent background, Plex Sans 500 12px `#BAC0C0`, icon 14px, gap 7px.
|
||
- Hover: text `#F4F5F4`, border `#3A424C`.
|
||
- **Pull**: icon `arrow-down-to-line`, label `Pull` (`Pulling…` while busy), then the count `↓2` in Plex Mono 600 11px `#E8913A`. The count is hidden when 0.
|
||
- **Push**: icon `arrow-up-from-line`, label `Push` (`Pushing…` while busy), then the count `↑1` in the same amber style.
|
||
- **Close**: icon `minimize-2`, label `Close`, then the key hint `⌘G` in amber mono 11px.
|
||
|
||
###### 2. Commit block
|
||
- Background `#18202B`, bottom border `1px #232C39`.
|
||
- **Message textarea**: full width, auto-grows (`field-sizing: content`) from 56px up to 180px.
|
||
- Background `#101720`, no border except a `1px #232C39` bottom border, which turns `#E8913A` on focus.
|
||
- Padding `14px 16px`, Plex Mono 400, 14px / 1.6, colour `#F4F5F4`, caret `#E8913A`.
|
||
- Placeholder: `Commit message`. The field gets focus when the Git view opens.
|
||
- **Footer row**: 52px tall, padding `0 14px 0 16px`, gap 16px.
|
||
- Author `Jonathan van Rij <jonathan@blijnder.nl>` in Plex Mono 12px `#828D9A`. In the real build, read this from `git config user.name` and `user.email`.
|
||
- Hint `⌘↵ commits` in Plex Mono 12px `#6C7783`.
|
||
- A spacer, then a **split button**, radius 2px, 32px tall:
|
||
- Main part: min-width 160px, padding `0 18px`, Plex Sans 600 13px.
|
||
- Label: `Commit N file(s)`, or `Nothing staged` when nothing is staged.
|
||
- Ready state (≥1 staged file **and** a non-empty message): background `#E8913A`, text `#101720`.
|
||
- Otherwise: background `#232C39`, text `#828D9A`. It stays clickable, so git's own error appears in the console.
|
||
- Caret part: 32×32px, `chevron-down` icon at 14px, separated from the main part by a `1px #101720` left border. It opens a context menu with `Commit` (icon `check`) and **`Commit and push`** (icon `arrow-up-from-line`, bold).
|
||
- Hover on either part: `filter: brightness(.92)`. (Real build: use amber-deep `#C4741F` instead, per Kade.)
|
||
|
||
###### 3. File sections (scrolling area, `flex: 1`, padding-bottom 24px)
|
||
Sections appear in this fixed order, and only when they contain files:
|
||
|
||
| Section | Contains | Colour | Tint (header background) | Bulk actions (left column · right column) | Row actions (left · right) |
|
||
|---|---|---|---|---|---|
|
||
| **STAGED** | every staged path, any status | `#E8913A` | `rgba(232,145,58,.08)` | — · Unstage all | — · Unstage |
|
||
| **CHANGED** | unstaged, modified | `#F0B476` | `rgba(240,180,118,.06)` | Discard all · Stage all | Discard · Stage |
|
||
| **NEW · UNTRACKED** | unstaged, added | `#8FBFB4` | `rgba(143,191,180,.06)` | Delete all · Stage all | Delete · Stage |
|
||
| **DELETED** | unstaged, deleted | `#C3A6CE` | `rgba(195,166,206,.06)` | Restore all · Stage all | Restore · Stage |
|
||
|
||
The section right after Staged gets `margin-top: 28px` and a `1px #232C39` top border, which visually separates staged from unstaged work.
|
||
|
||
If there are no changes at all, the area shows only: `— No changes. The working tree is clean.` (Plex Sans 13px / 1.6, `#828D9A`, padding `24px 16px`).
|
||
|
||
**Section header**: 46px tall, padding `0 14px 0 11px`, a `3px` left border in the section colour, the tint background, and a `1px #232C39` bottom border. Hover background is `#18202B`. Clicking it collapses or expands the section. From left to right:
|
||
- Chevron at 14px: `chevron-down` in `#E8913A` when open, `chevron-right` in `#6C7783` when closed.
|
||
- Label: Plex Mono 700, 11px, .14em, uppercase, in the section colour.
|
||
- Count badge: Plex Mono 600 11px, text `#101720` on the section colour, radius 2px, padding `3px 6px`.
|
||
- A spacer, then the **actions table**.
|
||
|
||
**Actions table** (identical in headers and rows, so the buttons line up as columns): a CSS grid `grid-template-columns: 100px 100px; gap: 6px`. When a section has only one action (Staged), the left cell is an empty spacer, so `Unstage` always sits in the right column.
|
||
- **Header buttons**: 100×28px, border `1px #3A424C`, radius 2px, transparent background, Plex Sans 500 12px. Hover: border `#6C7783`, background `#232C39`.
|
||
- **Row buttons**: 100×26px, border transparent, background transparent. Hover: border `#3A424C`, background `#232C39`, text `#F4F5F4`.
|
||
- **Text colour**: destructive actions (Discard, Delete, and their "all" versions) use `#F0B476`; all others use `#BAC0C0`.
|
||
- Buttons stop propagation, so clicking one never expands the row.
|
||
|
||
**File row**: 36px tall, padding `0 14px 0 11px`, gap 10px, row bottom border `1px #232C39`.
|
||
- A 3px left border: `#E8913A` for rows in Staged, transparent elsewhere.
|
||
- Background `#18202B` when expanded, transparent otherwise. Hover background is `#1F2834`.
|
||
- Click toggles the inline diff; right-click opens the context menu (below).
|
||
- From left to right:
|
||
1. Chevron at 13px: `chevron-down` in `#E8913A` when expanded, otherwise `chevron-right` in `#6C7783`.
|
||
2. **Status badge**: 18×18px, radius 2px, filled with the status colour (M `#F0B476`, A `#8FBFB4`, D `#C3A6CE`), letter in Plex Mono 700 11px `#101720`. Tooltip: Modified / New file / Deleted.
|
||
3. **Path**: flex 1, ellipsis, Plex Mono 400 13px. The directory part plus `/` is `#828D9A`; the file name is `#F4F5F4`. Deleted files have a `line-through` and the name in `#828D9A`.
|
||
4. **Stats**, placed just left of the actions table:
|
||
- `+N` in a 52px right-aligned cell, Plex Mono 500 12px `#8FBFB4`.
|
||
- `−N` in a 52px right-aligned cell, Plex Mono 500 12px `#F0B476`, padding-right 8px. Use a real minus sign `−`.
|
||
5. The actions table.
|
||
|
||
**Row context menu**:
|
||
- `Open in editor` (bold, icon `file-text`; not shown for deleted files): closes the Git view and opens the file.
|
||
- Separator.
|
||
- `Pass on reference` (icon `sparkle`): closes the Git view and inserts `@path` into the Claude prompt.
|
||
- `Copy reference` (icon `files`).
|
||
|
||
###### 4. Inline diff (inside an expanded row)
|
||
- A `1px #232C39` top border, padding `8px 0 12px`, Plex Mono 400 13px / 22px.
|
||
- Each line is a two-column grid, `minmax(0,1fr) minmax(0,1fr)`. Left is the last commit, right is the working tree. The left cell has a `1px #232C39` right border.
|
||
- **Each cell**:
|
||
- Line-number column: 52px wide, right-aligned, padding-right 12px, `user-select: none`.
|
||
- Code: `white-space: pre-wrap; word-break: break-word; tab-size: 4`, colour `#E4E7E6`.
|
||
- **Line types**:
|
||
|
||
| Type | Background | Line-number colour |
|
||
|---|---|---|
|
||
| Unchanged | transparent | `#3A424C` |
|
||
| Removed (left) | `rgba(232,145,58,.12)` | `#F0B476` |
|
||
| Added (right) | `rgba(143,191,180,.12)` | `#8FBFB4` |
|
||
| Empty filler (the side with no line) | `rgba(35,44,57,.35)` | — |
|
||
|
||
- **Intra-line highlight**: when a removed line is paired with an added line, compute their common prefix and suffix. Highlight the differing middle with a background of `rgba(232,145,58,.38)` on the left and `rgba(143,191,180,.36)` on the right. If they share no prefix or suffix, there is no highlight.
|
||
- **Hunking**: keep 3 lines of context around each change. Collapse any other run of unchanged lines into one separator row:
|
||
- 28px tall, `margin: 6px 0`, background `#18202B`, padding-left 64px.
|
||
- Text: `⋯ N unchanged lines` in Plex Mono 11px `#6C7783`.
|
||
- Added files show everything on the right; deleted files show everything on the left.
|
||
- The prototype uses an LCS line diff (`diffOps`). In production, use `git diff` hunks (`--unified=3`), or a proper diff library, and pair `-`/`+` runs line by line.
|
||
|
||
###### 5. Bottom strip — 230px, split 50/50
|
||
- Background `#18202B`, top border `1px #232C39`.
|
||
- `display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr)`. The left half has a `1px #232C39` right border.
|
||
|
||
**Left — Console**
|
||
- **Header**: 32px tall, padding `0 12px 0 16px`.
|
||
- `[ CONSOLE ] GIT` in Plex Mono 700 10px, .14em, uppercase, `#6C7783`.
|
||
- Busy label: `→ pushing to origin…` or `→ pulling from origin…` in 12px `#E8913A`.
|
||
- A spacer, then the clear button (icon `eraser` at 14px, `#828D9A`, hover `#F4F5F4`).
|
||
- **Log**: scrolls, auto-scrolls to the bottom on every new line, padding `0 16px 12px`, Plex Mono 12px / 1.6, `pre-wrap`, `tab-size: 4`, max 400 lines kept.
|
||
- Command lines: `$ git …` in `#F4F5F4`.
|
||
- Normal output: `#BAC0C0`.
|
||
- Errors and rejections: `#E8913A`.
|
||
- Hints: `#828D9A`.
|
||
- Staged paths in `status`: `#8FBFB4`; unstaged and untracked paths: `#F0B476`.
|
||
- **Input line**: prompt `$ git` in `#8FBFB4`, then an input with no border, Plex Mono 12px `#F4F5F4`. Placeholder: `status · add -A · commit -m "…" · push · pull · log`. Clicking anywhere in the console focuses it, unless the user is selecting text. Enter runs the command; ↑ recalls the last one; `clear` empties the log. A leading `git ` is optional.
|
||
|
||
**Every UI action logs the exact git command it ran.** The prototype supports these commands, and the real build should simply run git:
|
||
- `status`
|
||
- `add <path|.|-A>`
|
||
- `restore --staged <path|.>`
|
||
- `restore <path>`
|
||
- `clean -f <path>`
|
||
- `commit -m "…"`
|
||
- `push`
|
||
- `pull`
|
||
- `log`
|
||
- `diff [--staged]`
|
||
- `branch [-a]`
|
||
- `switch <name>` / `checkout <name>`
|
||
|
||
**Right — Branches**
|
||
- **Header**: 32px tall, padding `0 16px`.
|
||
- `[ BRANCHES ]` in the same style as the console header.
|
||
- Right side, 12px mono: `clean · click to switch` in `#828D9A`, or `— N uncommitted files · switching locked` in `#F0B476`.
|
||
- **List**: scrolls, with two groups. Group labels are Plex Mono 700 10px, .14em, uppercase, `#6C7783`, padding `8px 16px 4px`:
|
||
- **LOCAL**: local branches.
|
||
- **REMOTE · ORIGIN**: `origin/*` branches.
|
||
- **Branch row**: 28px tall, padding `0 16px 0 13px`, a 3px left border, gap 10px, hover background `#232C39`. From left to right:
|
||
- Icon at 13px: `git-branch` for local branches, `cloud` for remote ones.
|
||
- Name: Plex Mono 12px, ellipsis.
|
||
- Meta text: 11px `#6C7783`.
|
||
- Action text: 11px Plex Mono 600 `#E8913A`.
|
||
- **States**:
|
||
|
||
| State | Left border | Background | Name | Icon | Meta | Action | Cursor / opacity |
|
||
|---|---|---|---|---|---|---|---|
|
||
| Current | `#E8913A` | `rgba(232,145,58,.08)` | 600, `#F4F5F4` | `#E8913A` | `current` | — | default cursor |
|
||
| Other, tree clean | transparent | transparent | 400, `#BAC0C0` | `#6C7783` | `tracked` on remotes that already have a local branch | `switch →`, or `checkout →` for a remote with no local branch | pointer |
|
||
| Other, tree dirty | transparent | transparent | 400, `#BAC0C0` | `#6C7783` | — | — | 40% opacity, `not-allowed` cursor |
|
||
|
||
Tooltip on the dirty state: `Commit or discard your changes first`.
|
||
- **Switch rules**:
|
||
- "Dirty" means there is at least one changed file, staged or not.
|
||
- Clicking a branch while dirty only shows the toast `— Commit or discard N files before you switch.` Typing `git switch` while dirty logs git's real error: `error: Your local changes to N files would be overwritten by checkout.` / `Please commit your changes or stash them before you switch branches.` / `Aborting`.
|
||
- When clean, switching to a local branch runs `git switch <name>`.
|
||
- Switching to a remote branch with no local branch runs `git switch <name>`, which auto-creates a tracking branch. It logs `branch '<name>' set up to track 'origin/<name>'.` and `Switched to a new branch '<name>'`, then adds the branch to the local list.
|
||
- After a switch: the title bar, status bar and Git top bar show the new branch; ahead/behind are recalculated; expanded diffs are cleared; a toast reads `Switched to <name>`.
|
||
|
||
---
|
||
|
||
##### Interactions & behaviour
|
||
|
||
**Stage / unstage**
|
||
- Stage runs `git add <paths>`; when all unstaged paths are staged at once, it logs `git add -A`.
|
||
- Unstage runs `git restore --staged <paths>`, or `.` when everything is unstaged.
|
||
- Each file moves between sections immediately.
|
||
|
||
**Discard / delete / restore**
|
||
- Modified files: `git restore <paths>`. New files: `git clean -f <paths>`, which logs `Removing <path>` per file.
|
||
- Modified and new files open a confirm modal first:
|
||
- Title: `Discard changes to <path|N files>?`, or `Delete <path|N files>?` when every file is new.
|
||
- Body: `This reverts to the last commit and cannot be undone.`, or `New files are removed from disk. This cannot be undone.` when the batch includes new files.
|
||
- Confirm button: `Discard` or `Delete` (amber). Enter confirms, Esc cancels.
|
||
- Restoring deleted files is not destructive, so it runs at once without a modal.
|
||
|
||
**Commit**
|
||
- Validation runs through git and shows in the console:
|
||
- Nothing staged: `no changes added to commit (use "git add" and/or "git commit -a")`, or `nothing to commit, working tree clean`.
|
||
- Empty message: `Aborting commit due to empty commit message.`, and the message field gets focus.
|
||
- On success the console shows:
|
||
- `[<branch> <sha>] <first line>`
|
||
- ` N files changed, X insertions(+), Y deletions(-)`
|
||
- ` create mode 100644 <path>` / ` delete mode 100644 <path>` for added and deleted files
|
||
- After a commit: the message clears, the staged section disappears, ahead increases by 1, and the commit is added to `git log`.
|
||
- **Commit and push** pushes right after a successful commit.
|
||
|
||
**Push**
|
||
- Ahead 0: `Everything up-to-date`.
|
||
- Behind > 0: rejected (all in `#E8913A` except the hints):
|
||
- ` ! [rejected] <br> -> <br> (fetch first)`
|
||
- `error: failed to push some refs to '…'`
|
||
- Two hint lines in `#828D9A`: `hint: Updates were rejected because the remote contains work that you do not` / `hint: have locally. Pull first, then push again.`
|
||
- Otherwise the console shows the real progress output (`Enumerating…`, `Writing objects…`, `To …`) and ends with ` <old>..<new> <br> -> <br>` in `#8FBFB4`. Then ahead becomes 0 and a toast confirms.
|
||
- While busy the button reads `Pushing…` and further push/pull clicks are ignored.
|
||
|
||
**Pull**
|
||
- Behind 0: `Already up to date.`
|
||
- Otherwise: `From …`, then a fast-forward (`Updating a..b`, `Fast-forward`, and a diffstat), or `Merge made by the 'ort' strategy.` when ahead > 0, which creates a merge commit. Then behind becomes 0 and a toast reads `Pulled N commits from origin/<br>`.
|
||
- In the real build, refresh the file list after a pull.
|
||
|
||
**Other details**
|
||
- On open, the prototype seeds the console with `git fetch origin` output; this is what makes it show "2 behind". In the real build, run a background fetch when the view opens, or every few minutes, to keep the ahead/behind counts honest.
|
||
- Toasts appear at the bottom centre: background `#232C39`, border `1px #3A424C`, radius 2px, Plex Mono 13px, prefix `→ ` in amber, hidden after 2.4s.
|
||
- **Motion**: colour transitions only, 120–160ms on `cubic-bezier(0.22,1,0.36,1)`. Nothing slides or scales.
|
||
|
||
##### State (Git view)
|
||
```
|
||
gitOpen: boolean // ⌘G
|
||
gitSec: { [sectionKey]: boolean } // false = collapsed (default: open)
|
||
gitOpenFiles: string[] // expanded rows, key = `${section}:${path}`
|
||
commitMsg: string
|
||
staged: string[] // staged paths (real build: from `git status --porcelain=v2`)
|
||
files: { [path]: { orig, content } } // prototype only — replace with git status + git diff
|
||
BR: string // current branch
|
||
branches: string[]; remotes: string[] // `git branch`, `git branch -r`
|
||
ahead: number; behind: number // `git rev-list --left-right --count HEAD...@{u}`
|
||
commits: { sha, msg }[]
|
||
gBusy: null | 'push' | 'pull'
|
||
glog: { t: string, c: color }[] // console lines, cap 400
|
||
gInput: string; gHist: string[] // console input + history
|
||
```
|
||
**Derived values**:
|
||
- File status: M if `orig ≠ content`, A if `orig === null`, D if `content === null`.
|
||
- `unstaged` = changed minus staged. Sections come from status plus staged membership.
|
||
- `dirty` = changed.length > 0; it locks branch switching.
|
||
|
||
##### Design tokens used
|
||
- **Slate surfaces**:
|
||
- `#101720`: page, editor, diff, message field
|
||
- `#18202B`: bars, panels, expanded row, separators
|
||
- `#1F2834`: row hover
|
||
- `#232C39`: rules, hover fills, disabled button
|
||
- `#2B3544`: menu border
|
||
- `#3A424C`: strong rule, button border, unchanged line numbers
|
||
- **Text**:
|
||
- `#F4F5F4`: primary
|
||
- `#E4E7E6`: code
|
||
- `#BAC0C0`: secondary
|
||
- `#828D9A`: muted
|
||
- `#6C7783`: faint
|
||
- **Accent**: `#E8913A` (amber), `#C4741F` (amber-deep, hover), `#F0B476` (amber-soft).
|
||
- **Status**:
|
||
- Modified `#F0B476`, New `#8FBFB4` (teal), Deleted `#C3A6CE` (lilac), Staged `#E8913A`.
|
||
- Teal and lilac already exist in Helder's v1 vocabulary (diff colours and the php badge). They are app-level additions outside the core Kade palette.
|
||
- **Type**:
|
||
- IBM Plex Mono (400/500/600/700) and IBM Plex Sans (400/500/600).
|
||
- Sizes used: 10, 11, 12, 13, 14px.
|
||
- Label style: 700, letter-spacing .14em, uppercase, written lowercase in source and in brackets, e.g. `[ console ] git`.
|
||
- **Radius**: 2px for buttons, badges and inputs; 4px for menus; 8px for modals.
|
||
- **Shadows**: only for menus `0 4px 16px rgba(16,23,32,.45)` and modals `0 16px 48px rgba(16,23,32,.5)`.
|
||
- **Spacing**: 4px steps. Common values are 6, 8, 10, 12, 14 and 16px.
|
||
|
||
##### Assets
|
||
- **Icons**: Lucide 0.544.0 at stroke width 1.75, through the Kade `Icon` component. Used here:
|
||
- `git-branch`, `cloud`
|
||
- `arrow-down-to-line`, `arrow-up-from-line`
|
||
- `minimize-2`, `chevron-down`, `chevron-right`
|
||
- `eraser`, `check`, `file-text`, `sparkle`, `files`
|
||
- **Fonts**: IBM Plex Mono and IBM Plex Sans (Google Fonts, through the Kade `tokens/fonts.css`).
|
||
- There are no images.
|
||
|
||
##### Files
|
||
- `Helder App v2.dc.html`: the full prototype. Open it in a browser next to `support.js`; it loads the Kade tokens and bundle from `_ds/blijnder-e2fd6583-1c87-4e16-bc91-117f035adbbc/` in the source project.
|
||
- **Where to look in the file**:
|
||
|
||
| What | Where |
|
||
|---|---|
|
||
| Git view markup | the `<!-- git overlay -->` block |
|
||
| Git logic | methods prefixed `g…`: `gStage`, `gUnstage`, `gDiscard`, `gCommit`, `gPush`, `gPull`, `gSwitch`, `gStatus`, `gRun`, `gitRows` |
|
||
| Section, row and branch view models | `renderVals()`, from `const GC` to `brGroups` |
|
||
|
||
- `support.js`: the prototype runtime, needed only to open the HTML. Do not port it.
|
||
|
||
---
|
||
|
||
### Appendix: open to-do at handoff time
|
||
|
||
#### To do: editor pointer flicker and "Show diff"
|
||
|
||
Status on 2026-10-07: items 2 and 3 built and tested (not yet checked in the running app); item 1 open.
|
||
|
||
##### 1. Pointer flicker on a changed file
|
||
|
||
A file with a git change shows its changed lines with a tinted background.
|
||
|
||
- [x] Hover over the editor without a menu: steady pointer. Fixed: the line-number gutter is cut out of the I-beam rect (`visibleRectWithoutScrollers` in `Components/PointerPolicy.swift`).
|
||
- [ ] With the right-click menu open on a changed file, moving the mouse still flickers a bit between arrow and I-beam. Expected: a steady arrow over the menu and over every column behind it.
|
||
- Suspects: `CodeTextView`'s mouseMoved tracking area, NSTextView's own `mouseEntered` → `_mouseInside:` (already re-routed in `PointerBoundTextView`), the I-beam cursor rects of the `CodeScrollView` clip view, row-background redraws that reset cursor rects, and SwiftUI updates of the editor while the file changes on disk.
|
||
- Find the setter at runtime with a temporary `NSCursor.set` trace, fix it through `PointerPolicy`, then remove the trace.
|
||
|
||
##### 2. Show diff from the right-click menu, not from a click
|
||
|
||
- [x] A left click on a changed line places the caret like any line, and never opens the Diff. Remove `CodeEditorController.plainClick`, `actions.markedLineClicked`, the call in `CodeTextView.mouseDown` and the wiring in `EditorPane.swift` (`editor.openDiff(atLine:)`).
|
||
- [x] A right-click on a changed line shows the editor menu with a separator and **Show diff** below Pass on reference / Copy reference. It opens the Diff of that file at that line (`editor.openDiff(atLine:)`).
|
||
- Every marked line counts, including blank added lines and the area after the last glyph of a line.
|
||
- Same conditions as the old click: Actual mode, the file has a diff, not a newly added file (`EditorPresentation.opensDiffOnClick`, rename it).
|
||
- An unchanged line: menu unchanged. The menu in `DiffOverlayView` gets no Show diff.
|
||
- Plumbing: `ContextActions.entries(for: .editor…)`, `EditorStore.contextMenuRequest`, `WorkspaceModel+ContextActions.execute`, tint and symbol in `ContextMenuOverlay` (same as `.openDiff`).
|
||
|
||
##### 3. No header on the editor menu
|
||
|
||
- [x] The editor right-click menu loses its header line (for example `sample.php:12`), also in the Diff view. `ContextActions.header` returns "" for `.editor`. File, git-row and project-root menus keep theirs.
|
||
|
||
##### Done in this session (uncommitted)
|
||
|
||
- Bouwen item on `ontwikkelingen/<name>` folders.
|
||
- Arrow instead of the I-beam over the context menu where it covers the editor (`PointerBoundTextView.mouseEntered`).
|
||
- No header on folder menus.
|
||
|
||
##### Verify
|
||
|
||
- Tests and docs for each item, as in the earlier changes (`docs/guide/right-click-menu.md`, `docs/behaviour.md`).
|
||
- Check in the running app; drive the mouse only when Jonathan is away from the machine.
|