read text aloud
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user