feat: add prompt composer to terminal context menu#133
Closed
mpmisha wants to merge 3 commits into
Closed
Conversation
Adds a notepad-style scratchpad to each terminal pane, accessible from the
pane right-click menu (📝 Prompt composer). Lets users compose long,
multi-line prompts in a real text editor before sending them - avoids the
fiddliness of editing multi-line input directly in the terminal and stops
stray Enter keys from submitting half-written messages.
The modal has three footer buttons:
- Copy: writes the draft to the clipboard.
- Submit: bracketed-pastes the draft into the focused terminal. We do not
also send Enter - the user reviews in the terminal and presses
Enter themselves. Intentional: avoids accidental submission and
Ink-based AI CLIs handle programmatic \r post-paste inconsistently.
- Close: dismiss (also bound to Esc and backdrop click).
Drafts are per-terminal and persist for the session; they're dropped when
the owning pane closes (and the composer auto-dismisses if its target pane
goes away).
Reuses the existing prepareClipboardPaste helper for bracketed-paste
wrapping + CRLF→LF normalization (so Windows-CRLF drafts work cleanly).
Pure draft-map helpers (updateComposerDrafts, dropComposerDraft) extracted
to src/renderer/utils/prompt-composer.ts and covered by 14 focused tests in
tests/e2e/task-180-prompt-composer.spec.ts. All tests pass; tsc error count
unchanged vs main; renderer vite build succeeds.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…atcher
- Bind Ctrl+Alt+P (⌘⌥P on Mac) to open the prompt composer for the
focused pane. Ctrl+Shift+P was already taken by the command palette.
- Surface the shortcut in the pane context menu hint, the Command
Palette ('Open Prompt Composer'), and the Shortcuts Help overlay.
- Fix matchesCombo() to also compare against event.code on Mac for
letter/digit keys. Without this, Option+P reports event.key='π'
(Option+R → '®', etc.) and every Cmd+Option+<letter> shortcut
silently no-ops on Mac. Side benefit: the pre-existing Ctrl+Alt+R
(refresh pane) and Ctrl+Alt+N (new terminal in place) bindings now
also work on Mac.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Added a keyboard shortcut on a follow-up commit (
|
The prompt composer is mainly useful for drafting chat prompts for AI
CLIs; on a plain shell pane it would be a surprising surface. Hide it
in all three entry points when the focused/target pane has no
aiSessionId:
- Pane context menu item: wrapped in {aiSessionId && (...)}, same as
'Show prompts' and 'Session summary'.
- Ctrl+Alt+P shortcut: no-ops when the focused pane isn't AI.
- Command Palette 'Open Prompt Composer' entry: conditionally included
based on the focused pane's aiSessionId; useMemo dep added so the
list rebuilds on focus changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
|
Thanks @mpmisha - great idea and cleanly implemented. Merged! 🎉 I built on it a bit with a few enhancements, and it'll ship in the next release. Thanks again! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a notepad-style Prompt Composer to each terminal pane, accessible from the pane right-click context menu (📝 Prompt composer). Closes TASK-180.
Why
Composing long, multi-line prompts directly in the terminal is awkward — newlines and paste are fiddly, and a stray Enter submits a half-written message. The composer is a plain modal
<textarea>so users can write and edit freely, then copy or paste the whole thing into the terminal as a single block.How it works
Three buttons in the footer:
writePty. We do not also send Enter — the user reviews in the terminal and presses Enter themselves. Intentional:\rafter bracketed paste inconsistentlyDrafts persist per-terminal for the current session, so closing and reopening the dialog doesn't lose work. Drafts are dropped when the owning pane is closed, and the composer auto-dismisses if its target pane goes away.
Submit reuses the existing
prepareClipboardPastehelper for bracketed-paste wrapping + CRLF→LF normalization (so Windows-CRLF drafts work cleanly).Files
Added
src/renderer/components/PromptComposer.tsx— the modalsrc/renderer/utils/prompt-composer.ts— pure draft-map helpers (DRY + testable)tests/e2e/task-180-prompt-composer.spec.ts— 14 pure-function testsbacklog/tasks/task-180 - …md— Backlog taskModified
src/renderer/state/terminal-store.ts— new state (promptComposerRequest,composerDrafts), open/close/setDraft actions,closeTerminalcleanupsrc/renderer/components/TerminalPanel.tsx— context menu item between "Show prompts" and "Session summary"src/renderer/App.tsx— mounts<PromptComposer />src/renderer/styles/global.css—.prompt-composer-*styles, matches the SessionSummary card familyOut of scope
Validation
npx tsc --noEmit: no new errors introduced (same 32 pre-existing errors on this branch vs.main; remaining errors are all in unrelated code paths).npx vite build --config vite.renderer.config.ts: succeeds.npx playwright test tests/e2e/task-180-prompt-composer.spec.ts: 14/14 pass.paste-wrap,smart-unwrap-on-copy) still pass.npm start: right-click pane → composer opens → Copy & Submit both work → Esc/backdrop close → draft persists across reopen → draft cleared on pane close.