# 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; and Read aloud (system voice) of Markdown and selections. 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`, `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) 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) 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, 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 ` after install; refusal message: `refusing to replace (bundle id ''); pass --force to overwrite it`. - Unknown option → `unknown option: ` 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 | `/.helder/config.json` (user, sparse) and `/.helder/config.default.json` (regenerated on launch) | | Per-project recent files | `/.helder/recent.json` (JSON array of project-relative paths, newest first) | 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. 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, Read aloud, 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 | | 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 ` -i -c ""` 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 and Read aloud selection. - 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 (`design/`) 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 `/Helder_HelderUI.bundle/Fonts` then `/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 ". - **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: `` 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 (`design/README.md`, prototype HTML) The handoff describes the design language as a dark (slate) design system: 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 the core palette. - **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", ]` 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: ` 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 : `. - 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. | | `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:` (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:` | 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 | | `/.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: `