adds Clean Copy Support

This commit is contained in:
2026-10-12 09:43:57 +02:00
parent 188e078055
commit 281f5465a6
28 changed files with 579 additions and 120 deletions
+4 -4
View File
@@ -18,12 +18,12 @@ Helder (executable) → HelderUI → HelderServices → HelderCore
## How a window works
- `WorkspaceModel` owns one window (`WorkspaceModel.swift`: state and `perform`; `+Commands`, `+ContextActions`, `+Lifecycle`, `+Refresh` hold the rest): the stores (`SourceControlStore`, `ExplorerStore`, `EditorStore`, `NoteStore`, `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`) 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.
- **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 and note in parallel → `editor.restore` → watcher → git polling (`git.refreshInterval`) → the PHP class list 1.5 s later. Watcher events: `.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.
- **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.
- **Terminals.** `TerminalStore` owns both panes' handles. Ending a pane goes through the store (`terminateAll`, `restart`, or `release` when a pane's window closes), which signals the child and lets `ChildReaper` collect it, so no zombie or orphan is left. A pane whose child exited restarts on the next key press. Right-click raises `contextMenuRequested`; the model shows the app's own menu (`.terminal` target: Copy with a selection, Paste). Font size follows `layout.textScale` (⌘0/⌘+/⌘−) live.
- **Git and files.** Git gets paths as literal pathspecs (`GIT_LITERAL_PATHSPECS=1`, so `pages/[id].vue` is one file). A changed file over `FileLimits.maxDiffFileBytes` (1 MB) keeps its row but loads no text: `GitFileChange.isTooBig` → `Diff.isTooBig`, and the Diff shows "Too big.". Saves are atomic (temp file, then rename, keeping permissions). Writes, creates, renames and deletes are refused when the entry's folder resolves (symlinks included) outside the project (`containedURL`). The watcher drops `IgnoreRules.walkIgnoredNames`, framework caches (`storage/framework/`, `bootstrap/cache/`, `.phpunit*`) and `files.exclude`.
- **Processes.** Every new window (⇧⌘N, the Dock's New Window, Open Folder or Open Recent with no key window) is a new Helder process via `SystemActing.openNewInstance`: `NSWorkspace` with `createsNewApplicationInstance` in the bundle, `InstanceLauncher` (Foundation `Process`) under `swift run`. The folder travels as `-HelderProject <path>`, which `ProjectLocator.initialRoot` reads as its directory argument; a bare path could reach AppKit as a file to open. Switching projects (⌘O, Open Recent in a window) stays in the process. `AppName` renames the process to the project's title (the launcher is "Helder"), so Mission Control, the Dock and ⌘Tab tell projects apart. Windows are not restorable and `NSQuitAlwaysKeepsWindows` is off, so a launch opens exactly one window.
@@ -34,7 +34,7 @@ Helder (executable) → HelderUI → HelderServices → HelderCore
```
Sources/HelderCore/
Agent/ AgentReference, BracketedPaste, TerminalLaunch
Agent/ AgentReference, BracketedPaste, TerminalLaunch (`TERM_PROGRAM=Helder`), CleanCopy (file name, new-text rule)
Config/ HelderConfig (tolerant decoding), config resolution, .env title
Diff/ Diff models, LineDiff, DiffViews, ViewMode
Files/ FileNode + FileTree, PathUtils, FileType (language, badge), limits + ignore rules, ContextActions (menus)
@@ -63,7 +63,7 @@ Sources/HelderUI/
Explorer/ the file tree column and the row glyphs
Editor/ the bar above the code, code/markdown/image panes, Diff overlay, pass-on panel, symbol popup
Terminal/ agent + shell panes over SwiftTerm
Overlays/ OverlayHost, search, note, shortcuts, recent files, context menu, name prompt, confirm, OverlayKeys
Overlays/ OverlayHost, search, note and clean copy (sharing OverlayTextEditor), shortcuts, recent files, context menu, name prompt, confirm, OverlayKeys
Theme/ Palette, Typography, Metrics, FontRegistry
Resources/Fonts/ IBM Plex Mono 400–700, Plex Sans 400/500/600/700/400i (WOFF2, OFL)
Tests/<Target>Tests/<same folders>/
+10
View File
@@ -171,6 +171,16 @@ The top pane of the fourth column.
- The pane shows the live agent session and has an input line at the bottom.
- It receives the **Pass on to Agent** inserts from the editor: text arrives in the input as content, never as a submitted command, so the user can stack several and send when ready.
- It is one terminal only. There are no additional agent sessions in this version.
- Both terminals run with `TERM_PROGRAM=Helder` in their environment, so the agent can tell it runs inside Helder.
### Clean copy
The agent hands the user text to copy through one file, `.clean-copy` in the project root. The agent overwrites the file each time; Helder only reads it and never clears or deletes it.
- When the file's contents change while the project is open, Helder reads it after a short pause (writes are not atomic) and opens the **From Claude** popup, a card like the note. The contents found when the project opens are the baseline and never open the popup. An empty or blank file, or the same text as last seen, opens nothing.
- The popup holds an editable text area. **Copy** (or `Cmd+Enter`) copies the text, with the user's edits, to the clipboard as plain text, closes the popup and shows the "Copied" toast. `Esc` or a click outside closes it without copying.
- With another overlay open, the newest text waits and opens once that overlay closes. New text while the popup is open replaces its text only when the user has not edited it.
- The popup opens in the project's own window even when that window is in the background; Helder does not take focus.
---
+6 -1
View File
@@ -2,7 +2,7 @@
The Claude Code pane is the top half of the right-hand column. It is a live terminal that runs the Claude agent in your project folder.
[Guide index](index.md) · Related: [Command line](command-line.md), [Pass on to Agent](pass-on-to-agent.md), [Layout](layout.md), [Right-click menu](right-click-menu.md)
[Guide index](index.md) · Related: [Command line](command-line.md), [Pass on to Agent](pass-on-to-agent.md), [Clean copy](clean-copy.md), [Layout](layout.md), [Right-click menu](right-click-menu.md)
## At a glance
@@ -45,6 +45,10 @@ The Claude Code pane is the top half of the right-hand column. It is a live term
- After a pass, the keyboard moves to the Claude pane and a short [notification](notifications.md) confirms it ("Passed to agent").
- Nothing is sent when the agent process is not running.
### Text from Claude to copy
- Claude can hand you text to copy by writing it to `.clean-copy` in the project root. Helder then opens a card with that text and a **Copy** button. See [Clean copy](clean-copy.md).
- Both terminals run with `TERM_PROGRAM=Helder`, so Claude can tell it runs inside Helder.
### Restart after the process exits
- When the agent exits (for example after `/exit`), the pane shows a grey line: `[process exited] · press any key to restart`.
- Press any key in the pane. Helder starts the agent again with the current settings.
@@ -107,6 +111,7 @@ All settings live in `.helder/config.json`. See [Configuration](configuration.md
- [Command line](command-line.md): the shell pane below, with the same look and copy behaviour.
- [Pass on to Agent](pass-on-to-agent.md): send code references into Claude's composer.
- [Notes](notes.md): send the project note to Claude with `Cmd+P`.
- [Clean copy](clean-copy.md): copy text that Claude writes to `.clean-copy`.
- [Right-click menu](right-click-menu.md): Copy and Paste in the terminal.
- [Layout](layout.md): the splitter, the Claude toggle and column widths.
- [Configuration](configuration.md): where `ai` and `terminal` settings live.
+67
View File
@@ -0,0 +1,67 @@
# Clean copy
Clean copy lets Claude hand you text to copy: a command, a commit message, a draft. Claude writes it to a file, and Helder shows it in a card at the top of the window, ready to edit and copy. You never have to select text out of the terminal.
[Guide index](index.md) · Related: [Claude Code](claude-code.md), [Notes](notes.md), [Notifications](notifications.md)
## At a glance
```text
+----------------------------------------------------------------+
| (1) From Claude .clean-copy (2) [ Copy Cmd+Enter ] |
+----------------------------------------------------------------+
| (3) |
| feat: show the refund state on the order page |
| |
| The order page now shows when a refund is pending._ |
| |
+----------------------------------------------------------------+
| (4) copied as plain text . 74 characters |
+----------------------------------------------------------------+
```
1. **Header**: the title and the file name, `.clean-copy`.
2. **Copy**: copies the text and closes the card.
3. **Text area**: the text Claude wrote, in a monospaced font. You can edit it before you copy.
4. **Footer**: how the text is copied, and how many characters it holds.
## Features
### The file
- The channel is one file: `.clean-copy` in the root of the project.
- Claude overwrites the whole file each time it has text for you. Helder only reads it; it never clears or deletes it.
- Both terminals get `TERM_PROGRAM=Helder` in their environment, so Claude can tell it runs inside Helder.
- Like any file, `.clean-copy` shows up in [Git](git.md) and the [Explorer](explorer.md) unless you ignore it.
### When the card opens
- The card opens when the contents of `.clean-copy` change while the project is open.
- Helder waits a moment after the last write, so it reads the whole text, not half of it.
- The text that is in the file when you open the project never opens the card.
- An empty file, or one with only spaces and blank lines, does not open the card.
- Writing the same text again does not open the card a second time.
- The card opens in the window of that project, even when the window is in the background. Helder does not come to the front.
### While something else is open
- When another card or dialog is open, such as the [note](notes.md) or [search](search.md), the text waits. The card opens once you close the other one.
- If Claude writes several times while you wait, only the newest text shows.
- When the clean-copy card is already open and new text arrives, the card shows the new text, unless you already edited the text. Then your edits stay and the new text is dropped.
### Copying
- Click **Copy** or press `Cmd+Enter`.
- The text in the card, with your edits, goes to the clipboard as plain text.
- The card closes, and a [notification](notifications.md) says "Copied".
- `Esc`, or a click outside the card, closes it without copying.
## Keyboard
| Keys | Action |
|---|---|
| `Cmd+Enter` | Copy the text and close |
| `Esc` | Close without copying |
## Related
- [Claude Code](claude-code.md): the agent that writes `.clean-copy`.
- [Notes](notes.md): the card the clean-copy card looks like.
- [Notifications](notifications.md): the "Copied" confirmation.
- [Keyboard shortcuts](keyboard-shortcuts.md): every key in one list.
+1
View File
@@ -59,6 +59,7 @@ This guide explains Helder from the user's side: what each part of the window sh
- [Claude Code](claude-code.md): the agent pane.
- [Command line](command-line.md): the shell pane.
- [Clean copy](clean-copy.md): text Claude hands you to copy, through `.clean-copy`.
### Finding things
+8
View File
@@ -173,6 +173,14 @@ See [Notes](notes.md).
| `Cmd+P` | Pass the whole note to the agent (while the note is open) |
| `Esc` | Close the note (it saves) |
### Clean copy
See [Clean copy](clean-copy.md).
| Keys | Action |
|---|---|
| `Cmd+Enter` | Copy the text and close the card |
| `Esc` | Close the card without copying |
### Right-click menus and dialogs
See [Right-click menu](right-click-menu.md) and [Dialogs](dialogs.md).
+1
View File
@@ -83,6 +83,7 @@ The agent and the note:
| Passed to agent | the reference | Text was inserted into the Claude pane |
| Note passed to agent | `.notes.txt` | You passed the whole note with `Cmd+P` |
| Save failed | `.notes.txt` | The project note could not be saved |
| Copied | character count | You copied the text of the [clean-copy](clean-copy.md) card |
### Other short messages
Two other messages appear for a moment, but they are not toasts: