Repository navigation
feat(app): add a command editor to the Commands tab - #163
Conversation
A Command editor pane beside the command buttons, or under them where the tab is narrow: write a few lines and send them, or the selection, line by line through sendLine to the window's send target, with Cmd/Ctrl+Enter. Options for Enter after each line and clearing after sending; Save as command opens the quick command editor filled in. The text is kept in commandeditor.txt in the config folder. Closes #160 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015nMqJHsqtndDSqJDPp1qYv
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0d3e24a65
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| a.sendToTargets(s, send, func() { | ||
| if a.settings.CommandEditorClear && buf.Version() == version { | ||
| if len(sent) == 0 { | ||
| buf.Set("") |
There was a problem hiding this comment.
Clear the editor only after sending to at least one session
With “Clear after sending” enabled, if all target sessions disconnect while the first-send confirmation is open, confirming still clears the draft even though nothing was sent. In sendtarget.go, sendToTargets skips disconnected sessions but invokes its completion callback unconditionally, and the confirmation dialog leaves Send enabled. Track whether the send callback actually ran and require that before removing the text, so unsent commands remain available to retry.
Useful? React with 👍 / 👎.
A selection in the command editor now sends, saves as a command and, with Clear after sending, removes every line it touches, whole, so a sloppy drag never sends half a command. A selection ending at the start of a line leaves that line out. Beside the editor the Commands toolbar's search was too narrow for its placeholder, so it now says just "Search" (搜索) while the editor shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015nMqJHsqtndDSqJDPp1qYv
Summary
Adds FinalShell's command editor to the Commands tab: a pane for writing a few lines and sending them without saving them as a quick command first.
commandEditorShown,commandEditorWidth,commandEditorPercent), local only.ui/editor, the same editor as the remote file editor, notui.TextArea. It gives line numbers, as the mockup shows, and selections. Its rope also lays out only the lines in view, so a large text stays responsive. The text is split into lines only when it is sent. Highlighting, auto-closing brackets, folding and whitespace markers are off. Enter inserts a new line, Tab indents, and Esc gives the keyboard back to the terminal, as the command bar does. In a panel row, Esc does nothing.sendQuick:config.QuickCommandLines, then each line throughsendLine. Lines with control characters are sent as they are, as quick commands send them.quickTarget, which now takes an anchor ("quick" or "editor") so each control gets its own Choose sessions popover. It is the samea.sendTostate, and the send goes throughsendToTargets, so it has the same warning color and the same first-send question. While the editor shows, the toolbar hides its own Send to, because the editor's control sets the same target.quickSearchShort), because "Search commands" was clipped beside the editor at default widths. Its accessible name stays "Search commands".commandEditorNoEnterandcommandEditorClear, local only. Clear removes only what was sent: the selected lines, whole, with their newlines, or everything. It is skipped if the text changed while the question was open, and Cmd+Z brings the text back. After a send the editor keeps the keyboard. With Enter off, the terminal takes the keyboard instead so you can press Enter there.commandeditor.txtin the config folder. It is not synced and is the same for every session. It is written with the atomic write helper one second after typing stops, and again inCloseAll. If the file cannot be read, the pane shows a banner and nothing is written over the file.withRightColumnintoendSplitin splits.go, which both callers use.Design decisions to check: the toolbar's Send to is hidden while the editor shows (the mockup shows both, but at its width they don't fit beside the editor). The editor is hidden by default. The Send button shows its shortcut as small text instead of an icon.
Closes #160
Testing
go fmt ./...(no changes),go build ./...,go vet ./...,GOOS=windows go vet .,GOOS=darwin go vet .,go tool mygo vetandgo test -race ./...all pass on main with fix(sshx): keep idle connections alive with SSH keepalives #162.internal/app/cmdeditor_test.go:App.TestCmdEditorWholeLines,TestCmdSelectedLines): a partial selection across two lines sends both lines whole, a backwards selection inside a line sends that line, a selection ending at column 0 leaves that line out, Save as command takes the same lines, and Clear after sending removes the whole lines and undoes. A table covers single and multiple selections, a selection of just a newline, the last line and the whole text.TestCmdEditorSearchPlaceholder), in English and Simplified Chinese: the long one without the editor, the short one beside it, and its measured width fits the field.Appreads the file) and being saved onCloseAll. An unreadable file is not overwritten.SHOT_DIR=… go test ./internal/app -run TestCmdEditorShots, checked against the mockup:cmdeditor-selection(open with a selection) andcmdeditor-partial(a partial-line selection)cmdeditor-options(the Options menu)cmdeditor-target-allandcmdeditor-confirm(target All and its question)cmdeditor-right-columnandcmdeditor-right-column-hidden(the Commands tab in the right column)cmdeditor-hiddengo run ./tools/screenshotsregenerateddocs/screenshots/quick-commands-{en,zh-CN}.png. The other scenes came out unchanged.features.mdhas a new "Command editor" subsection and a note under Layout.configuration.mdhas the file, the keys and the local settings list.development.mdhas the file layout. All in both languages, with the same headings.TestSSHagainst a real server.Generated by Claude Code