Skip to content

feat(@clack/core,@clack/prompts): Multiline text input#240

Merged
dreyfus92 merged 16 commits into
bombshell-dev:mainfrom
MacFJA:multiline
Apr 1, 2026
Merged

feat(@clack/core,@clack/prompts): Multiline text input#240
dreyfus92 merged 16 commits into
bombshell-dev:mainfrom
MacFJA:multiline

Conversation

@MacFJA

@MacFJA MacFJA commented Feb 27, 2025

Copy link
Copy Markdown
Contributor

Add a new prompt: MultiLinePrompt and its rendering multiline

Changes

Added to @clack/core

  • Option to change the key that submit a prompt (default value is return to keep retro-compatibility)
  • A new event that send the raw char and key
  • A new util function (isSameKey) to test if two key are the same (with ctrl, meta, shift included in the check)
  • A new prompt MultiLinePrompt

Added to @clack/prompts

  • A new prompt function multiline

Difficulties and workaround

Issue: The return key is used to submit the prompt and is hardcoded, so impossible to insert new line
Solution: Make the submit key configurable (see: packages/core/src/prompts/prompt.ts:{22,53,210})

Issue: The default cursor management use vim mapping, so when pressing letter k, j, h or l to add those letter, the cursor also moves.
Solution: Re-implementing of the cursor management without vim mapping (see packages/core/src/prompts/multi-line.ts:29)

Issue: The event key lower the inputted char, so uppercased char are never displayed
Solution: Create a new event rawKey to send the untouched value (also used for the cursor management)


  • This PR (except if I miss something) don't create incompatibility with existing usage of the library (as it add new feature, and core changes have default value that behave as it was before)
  • This PR fix the issue [Feature Request] Multiline text #25

@changeset-bot

changeset-bot Bot commented Feb 27, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 61486ae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/prompts Minor
@clack/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Mar 18, 2025

Copy link
Copy Markdown

commit: 61486ae

@natemoo-re natemoo-re self-requested a review March 18, 2025 14:42

@natemoo-re natemoo-re left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow great stuff, thank you for contributing!

@deadcoder0904

Copy link
Copy Markdown

I'd love if this is merged. Its annoying to do multi-line with such a beautiful library. Only thing missing imo.

@43081j 43081j requested a review from dreyfus92 April 1, 2026 14:01

@dreyfus92 dreyfus92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good @43081j, can you push a changeset?

@dreyfus92

Copy link
Copy Markdown
Member

thank you @43081j 🎉

@dreyfus92 dreyfus92 merged commit 814ab9a into bombshell-dev:main Apr 1, 2026
7 checks passed
venables added a commit to venables/agent-panel that referenced this pull request Apr 9, 2026
Running `panel` with no arguments now opens a multi-line prompt that
sends the typed text to every configured agent, replacing the previous
help-text behavior. The TUI is styled like clack's text prompt and
lists the target agents above the input.

- Vendor a MultiLinePrompt built on @clack/core (until clack ships its
  own textarea in bombshell-dev/clack#240); extends the installed
  Prompt base class and uses an error-state workaround to veto the
  base class's submit-on-return since 1.2.0 lacks the _shouldSubmit
  hook.
- Intercept Shift+Enter at the raw stdin level via the kitty keyboard
  protocol (\x1b[>1u / \x1b[13;2u) so plain Enter submits and
  Shift+Enter inserts a newline. Alt+Enter works as a fallback in
  terminals that don't speak kitty keyboard.
- Bump @clack/prompts to 1.2.0 for the styleText-based colors and
  updated wrapTextWithPrefix signature.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants