read text aloud

This commit is contained in:
2026-10-23 09:40:20 +02:00
parent 281f5465a6
commit 92b90c0e13
20 changed files with 471 additions and 18 deletions
+5 -3
View File
@@ -12,15 +12,16 @@ Helder (executable) → HelderUI → HelderServices → HelderCore
| Target | May import | Rules |
|---|---|---|
| `HelderCore` | Foundation | Pure logic and value types, all `Sendable`. No AppKit, no SwiftUI, no disk, no processes. Swift 6 mode. |
| `HelderServices` | HelderCore, Foundation, CoreServices | Everything that touches disk or spawns `git`/`rg`, behind a protocol. Processes only through `ProcessRunning`. |
| `HelderServices` | HelderCore, Foundation, CoreServices, AVFoundation | Everything that touches disk or spawns `git`/`rg`, behind a protocol. Processes only through `ProcessRunning`. |
| `HelderUI` | Core, Services, SwiftUI, AppKit, SwiftTerm | `@Observable @MainActor` stores plus views. Never runs a process or touches project files directly, only through the service protocols (the SwiftTerm terminals are the one exception). |
| `Helder` | HelderUI | The `@main` app. Keep it tiny. |
## How a window works
- `WorkspaceModel` owns one window (`WorkspaceModel.swift`: state and `perform`; `+Commands`, `+ContextActions`, `+Lifecycle`, `+Refresh` hold the rest): the stores (`SourceControlStore`, `ExplorerStore`, `EditorStore`, `NoteStore`, `CleanCopyStore`, `TerminalStore`, `LayoutStore`, `OverlayStore`, `ToastStore`) and every action that spans more than one of them. A store never reaches into a sibling; `EditorStore` only reads the git state through a closure.
- `WorkspaceModel` owns one window (`WorkspaceModel.swift`: state and `perform`; `+Commands`, `+ContextActions`, `+Lifecycle`, `+Refresh` hold the rest): the stores (`SourceControlStore`, `ExplorerStore`, `EditorStore`, `NoteStore`, `CleanCopyStore`, `TerminalStore`, `LayoutStore`, `OverlayStore`, `ToastStore`, `ReadAloudStore`) and every action that spans more than one of them. A store never reaches into a sibling; `EditorStore` only reads the git state through a closure.
- **One entry point.** Views, the menu bar and the key router all call `WorkspaceModel.perform(Command)` (`Shell/Command.swift`). Context-menu items arrive as `.context(ContextAction)`; the model asks `SourceControlStore.confirmation(for:)` / `ExplorerStore.confirmation(for:)` first and shows the confirm overlay, and `.confirmPending` runs the action. The name prompt submits with `.submitName`, the pass-on prompt with `.passToAgent`, the note's ⌘P with `.passNote`.
- **Overlays never stack.** `OverlayStore.current` is one `Overlay` enum; only the model presents or dismisses it. `OverlayStore.onChange` lets the model run closing behaviour however an overlay went away (the note saves, the Diff gives back the mode it covered). `OverlayHost` draws the current overlay. `.launcher` is the ⇧⌘O "Open recent project" list; the bare window's launcher is part of the shell, not an overlay. The key router only sees `OverlayKind` (`none`, `note`, `diff(busy:)`, `other`): over the Diff the workspace keys keep working unless its own menu or prompt is open (`busy`). Toasts (`ToastStore`) may sit on top. The Diff draws its own right-click menu and pass-on prompt inside itself, so it stays open.
- **Read aloud.** `.readAloudFile` reads the open file's buffer (unsaved edits included) or the file from disk, turns it into prose with `MarkdownSpeech`, and hands it to `ReadAloudStore`; `.readAloudText` speaks the selection (selected Markdown as prose). `ReadAloudStore` lives as long as the window, like `ToastStore`; its `isReading` shows the title bar's Stop, which runs `.stopReading`. `closeProject()` stops the reading.
- **Stores report, the model shows.** Stores raise toasts through `notify`/`showToast` hooks the model wires to `ToastStore`; the model never toasts a second time for the same action.
- **Closing.** A window close, a project switch and ⌘Q all run `prepareToClose()` first: every unsaved file (at most the open one plus a vanished-file buffer) is asked about, and a cancel keeps everything open. Then `closeProject()` waits for running work, writes the note and session and ends the terminals.
- **Lifecycle.** `start()`: recents → config (applied to every store and the terminals) → git, tree, note and the `.clean-copy` baseline in parallel → `editor.restore` → watcher → git polling (`git.refreshInterval`) → the PHP class list 1.5 s later. Watcher events: `.cleanCopy` (`.clean-copy` in the root, 150 ms debounce, fired besides `.project`) makes `CleanCopyStore` re-read the file and opens the `.cleanCopy` overlay for new non-blank text (the text found at load is the baseline; another open overlay makes it wait, keeping only the newest); `.project` re-reads git, the tree, the open file and every unsaved buffer (the edits kept), invalidates the symbol index and reloads the class list 2 s after the last change; `.git` re-reads git; `.config` re-resolves and re-applies the config. ⌘R re-reads git and the tree and lets the disk win in the open file. A project switch or window close saves the note and the session, stops the watcher and polling, and ends both terminals.
@@ -40,7 +41,7 @@ Sources/HelderCore/
Files/ FileNode + FileTree, PathUtils, FileType (language, badge), limits + ignore rules, ContextActions (menus)
Git/ GitStatus/Change/GitSnapshot, Porcelain parsing, GitDerivation (rows, grouping, commit text)
Highlight/ SyntaxHighlighter and one grammar per language
Markdown/ block/inline tree and parser
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/LineSelection/OpenOptions
Symbols/ PHP symbol models and line parsers
@@ -51,6 +52,7 @@ Sources/HelderServices/
Process/ ProcessRunner, ExecutableLocator, ChildReaper, InstanceLauncher
Project/ ConfigService, NotesService, RecentStores, SessionStore, ProjectLocator
Search/ SearchServicing + RipgrepSearchService, ProjectScanner (rg, or a Swift walk)
Speech/ SpeechServicing + SpeechService (AVSpeechSynthesizer, the system voice), shared by the window
Symbols/ SymbolService
Sources/HelderUI/
State/ WorkspaceModel (+ extension files), WorkspaceServices/AppServices, one file per store
+5 -1
View File
@@ -35,6 +35,7 @@ The top bar contains, left to right:
- A breadcrumb showing the path to the active file, for example `console / src / Http / Controller / UserController.php`. The breadcrumb is **display only** for now. It is not clickable and does not navigate.
- Centred on the window, the **pane toggles**: Git · Explorer · File · Claude, one per column, all on by default (see Pane toggles in section 9). The breadcrumb truncates before it reaches them.
- On the right, the toolbar: **Search** (`Cmd+F`) and **Note** (`Cmd+N`) are actions; **Fluid** (`Cmd+L`) and **Hidden** (`Cmd+.`) are toggles. Then `?` for the keyboard shortcuts.
- While Helder reads aloud, a **Stop** toggle appears left of **Search**, in the same style and switched on. A click switches it off and stops the reading; the button then goes away. It also goes away when the reading reaches the end, and a project switch or window close stops the reading.
---
@@ -107,6 +108,7 @@ The second column. A standard project file tree.
- **Left-click** a file opens it in the editor. The selected file is highlighted.
- The tree hides paths matched by `files.exclude` and, when `files.followGitignore` is on, paths ignored by git.
- **Right-click** a file offers **Copy reference**, which copies the file's project-relative path to the clipboard (the file-level form of the editor's Copy reference).
- A Markdown file (`.md`) also offers **Read aloud**, in its own group after the pass-on and copy items, in the Explorer and on its git rows. Helder reads the text with the system voice: headings, paragraphs, list items, quotes and table cells, with the markup and link URLs left out and code blocks skipped. The open file is read as it stands in the editor, unsaved edits included. A file with nothing to read shows `Nothing to read`. A new Read aloud replaces the one that is playing. A `$` is read as "dollar", except before a digit (`$5` stays "five dollars").
---
@@ -152,7 +154,9 @@ Right-clicking inside the code area, with or without a selection, shows a contex
1. **Copy reference**: copies a reference to the clicked location to the clipboard. With no selection it is path plus single line, for example `src/Http/Controller/UserController.php:42`. With a selection it is path plus start and end line, for example `src/Http/Controller/UserController.php:42-58`. The path is project-relative.
2. **Pass on to Agent**: opens a small inline input popup anchored near the click or selection, with a single optional text field. On confirm (`Enter`), it composes one line, the typed text followed by the same reference, and inserts it into the agent pane's input. The insert does **not** submit. It lands as a new, unsubmitted line and the cursor sits on a fresh line, so the action can be repeated to stack several references before the user sends. `Esc` cancels with no insert. An empty field passes the bare reference.
On a marked line of the live file (any marked line, blank lines and the space after the text included), a separator and a third item follow: **Show diff**, which opens the Diff centred on that line. A new file, Preview and the Diff's own menu have no Show diff.
With a selection, a separator and **Read aloud selection** follow Copy reference. It reads the selected text with the system voice; in a Markdown file the selection is read as prose, the markup left out. The rendered Markdown preview has no Read aloud selection; its selection is not Helder's (use Read aloud on the file).
On a marked line of the live file (any marked line, blank lines and the space after the text included), a separator and a last item follow: **Show diff**, which opens the Diff centred on that line. A new file, Preview and the Diff's own menu have no Show diff.
### File-state behavior in the views
+31 -2
View File
@@ -26,7 +26,7 @@ Helder draws its own right-click menu, in the same dark style everywhere. This p
3. **Separator**: a thin line between groups of items.
4. **Destructive item**: Discard and Delete read in amber-deep, so they stand out.
Each item has a small icon. Add-type items (Stage, New file, New folder) have a teal icon. Copy file name, Unstage and Show in Finder have an amber icon.
Each item has a small icon. Add-type items (Stage, New file, New folder) have a teal icon. Copy file name, Unstage and Show in Finder have an amber icon. Read aloud has a speaker icon.
## Features
@@ -56,6 +56,7 @@ These items show up in several menus.
| **Pass on file name** | Opens the Pass on prompt with only the file name, without folders. | No |
| **Copy file name** | Copies only the file name. A notification says `Copied`. | No |
| **Show in Finder** | Opens a Finder window with the item selected. | No |
| **Read aloud** | Markdown files only. Reads the file aloud with the system voice. Stop it with **Stop** in the [title bar](title-bar.md#read-aloud). | No |
### Git rows
@@ -119,6 +120,26 @@ Right-click a file in the [Explorer](explorer.md). The header is the file's path
+----------------------------------------+
```
A Markdown file (`.md`), in the Explorer or on a git row, gets one extra group after the copy items:
```text
+----------------------------------------+
| docs/setup.md |
|----------------------------------------|
| * Pass on reference |
| # Copy reference |
| * Pass on file name |
| # Copy file name |
|----------------------------------------|
| )) Read aloud |
|----------------------------------------|
| / Rename file |
| ... |
+----------------------------------------+
```
- **Read aloud**: reads the headings, paragraphs, list items, quotes and table cells aloud. Markup and link addresses are left out, and code blocks are skipped. The open file is read as it stands in the editor, unsaved edits included. A file with nothing to read shows `Nothing to read`. Reading another file stops the first one.
- **Rename file**: opens the [name prompt](dialogs.md#name-prompt) with the current name. Only the part before the extension is selected, so typing keeps the extension.
- **Delete file**: always asks first; see [Dialogs](dialogs.md#delete-file-or-folder). The file is deleted for good, not moved to the Trash.
@@ -200,6 +221,8 @@ With a selection:
+----------------------------------------+
| * Pass on selection |
| # Copy reference |
|----------------------------------------|
| )) Read aloud selection |
+----------------------------------------+
```
@@ -215,8 +238,9 @@ On a marked (teal) line of a changed file:
```
- **Pass on selection** passes the reference and the selected code. See [Pass on to Agent](pass-on-to-agent.md).
- **Read aloud selection** reads the selected text aloud. In a Markdown file the markup is left out. Stop it with **Stop** in the [title bar](title-bar.md#read-aloud).
- **Show diff** opens the full-screen [Diff](file-view-diff.md) of the file, centred on the line you right-clicked. Every marked line counts, a blank one and the space after the text included. A new file, where every line is marked, has no Show diff. A left click on a marked line only places the caret.
- The same menu shows on the rendered [Markdown preview](file-view-markdown.md) and on an image. There it refers to the file's first line, for example `README.md:1`.
- The same menu shows on the rendered [Markdown preview](file-view-markdown.md) and on an image. There it refers to the file's first line, for example `README.md:1`, and has no Read aloud selection. To hear a previewed file, right-click it in the Explorer and choose **Read aloud**.
- `Cmd+Right` with code selected opens the Pass on prompt straight away, without the menu.
### Diff
@@ -244,9 +268,13 @@ With text selected in the pane:
+----------------------------------------+
| # Copy |
| # Paste |
|----------------------------------------|
| ? Wait what? |
+----------------------------------------+
```
Wait what? shows only in the Claude Code pane, not in the Command line pane.
Without a selection:
```text
@@ -257,6 +285,7 @@ Without a selection:
- **Copy** (only with a selection): copies the selected terminal text.
- **Paste**: types the clipboard text into that pane, as a normal paste would. With an empty clipboard nothing happens.
- **Wait what?** (Claude Code pane, only with a selection): inserts ``/wait-what `selected text` `` into the [Claude Code](claude-code.md) input, not sent. Spaces and blank lines around the selection are trimmed. A [notification](notifications.md) says `Passed to agent`.
## Keyboard
+13
View File
@@ -18,6 +18,12 @@ The title bar is the 44-point strip across the top of a project window. It tells
The bar is one row in the app. It is drawn on two rows here to fit the page.
While Helder reads aloud, a **Stop** button leads the toolbar:
```text
| [.Stop |Search |.Fluid |.Hidden |Note] [?] |
```
1. **Window buttons**: the macOS close, minimize and zoom buttons.
2. **Wordmark**: "Helder" with a blinking amber dot.
3. **Project name**: the project folder's name. Click it to open another folder.
@@ -64,6 +70,12 @@ The toolbar sits on the right. Each button shows its shortcut next to its label.
Fluid and Hidden carry a state dot like the pane toggles. Search and Note have no dot, because they are actions. Hover any button for a tooltip that explains its current state.
### Read aloud
- **Stop** shows only while Helder reads a file or a selection aloud. Start the reading from the [right-click menu](right-click-menu.md): **Read aloud** on a Markdown file, **Read aloud selection** in the code.
- It sits left of **Search**, in the same style, and its dot is on. The tooltip says "Read aloud: playing. Click to stop."
- Click it to switch it off: the reading stops and the button goes away.
- The button also goes away when the reading reaches the end. Switching projects or closing the window stops the reading.
### Moving the window
Drag an empty part of the title bar to move the window, as in any macOS app.
@@ -87,3 +99,4 @@ Drag an empty part of the title bar to move the window, as in any macOS app.
- [Keyboard shortcuts](keyboard-shortcuts.md): the overlay the `?` button opens.
- [Recent projects](recent-projects.md): opening another folder.
- [Status bar](status-bar.md): the matching bar at the bottom of the window.
- [Right-click menu](right-click-menu.md): where Read aloud starts.