Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

DRAFT: Prompt: Esc is ignored — only Ctrl-C/Ctrl-D cancel a prompt

クローズ
#8,640 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
node.js, typescript
領域
cli

調査の方向性

Start with packages/effect/src/cli/Prompt.ts:3615-3642 and inspect handleSelectProcess alongside the other prompt process handlers. Read packages/platform/node-shared/src/NodeTerminal.ts:176-178 and verify the existing escape key behavior with the provided pseudo-terminal reproduction. Done should establish the intended Esc behavior and reflect it consistently in the relevant prompt handling or documentation, with coverage where the repository provides an appropriate test location.

索引モデルが issue の本文から書いたものです。

説明

We use Prompt in interactive CLIs and noticed that Esc does nothing in a prompt. We aren't sure whether that's intended.

What we observed

Pressing Esc in a Prompt.Select beeps (\x07), and the prompt keeps waiting. Enter then submits the highlighted choice. The only ways to back out of a prompt are Ctrl-C and Ctrl-D, which surface as Terminal.QuitError. Some other terminal prompt libraries treat Esc as cancel, so users try it and nothing happens.

Environment: [email protected] (tag [email protected], ad61db8) and @effect/[email protected], on Node 26.10.0 and macOS. From reading the source, the same lines are unchanged on main at 8b0eac6 (packages/effect/src/cli/Prompt.ts:3615-3642).

Reproduction
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"
import * as NodeServices from "@effect/platform-node/NodeServices"
import { Console, Effect } from "effect"
import { Prompt } from "effect/cli"

const pick = Prompt.Select({
  message: "Pick one",
  choices: [{ title: "a", value: "a" }, { title: "b", value: "b" }]
})

Prompt.run(pick).pipe(
  Effect.flatMap((value) => Console.log(`\nselected: ${value}`)),
  Effect.catchTag("QuitError", () => Console.log("\nQuitError")),
  Effect.provide(NodeServices.layer),
  NodeRuntime.runMain
)

We ran node repro.ts under a pseudo-terminal, sent keystrokes to it, and captured the raw output live (escape bytes shown escaped).

Esc, then Enter half a second later. The \x07 after the first frame is the beep for Esc; the prompt then submits a:

\x1b[?25l\x1b[96m?\x1b[0m \x1b[1mPick one\x1b[0m \x1b[90m›\x1b[0m \r\n\x1b[96m❯\x1b[0m \x1b[4m\x1b[96ma\x1b[0m \r\n  b \x07\x1b[2K\x1b[1G\x1b[2K\x1b[G\x1b[32m✔\x1b[0m \x1b[1mPick one\x1b[0m \x1b[90m…\x1b[0m  \x1b[37ma\x1b[0m\r\n\x1b[?25h\r\nselected: a\r\n

The control, Ctrl-C:

\x1b[?25l\x1b[96m?\x1b[0m \x1b[1mPick one\x1b[0m \x1b[90m›\x1b[0m \r\n\x1b[96m❯\x1b[0m \x1b[4m\x1b[96ma\x1b[0m \r\n  b \x07\x1b[?25h\r\nQuitError\r\n

The key does reach the prompt. Reading one event from Terminal.readInput under the same pseudo-terminal and pressing Esc prints key.name="escape".

Where it happens
  • Prompt.ts:3615-3642: handleSelectProcess has no "escape" case, so the key falls to default, which returns Action.Beep(). The other built-in prompts' process handlers have no "escape" case either; grep -n escape packages/effect/src/cli/Prompt.ts finds nothing.
  • NodeTerminal.ts:176-178: the default shouldQuit ends input on Ctrl-C or Ctrl-D only.
Is this intended?

If Esc is left unbound on purpose, for example to leave it free for a future use, a line in the Prompt docs would help users. If not, one possible direction is to treat "escape" like Ctrl-C and fail with QuitError. Existing handling of cancellation, such as Flag.withFallbackPrompt re-failing with the original missing-option error, would then apply to it unchanged. Another is a Prompt option that opts into this behaviour. readline's escapeCodeTimeout: 50 in NodeTerminal already separates a lone Esc from the start of an arrow-key sequence, as the key.name check above shows.

主要言語
TypeScript
スター
16.7k
フォーク
808
平均マージ
10時間 17分
マージ済み PR(30日)
850

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Effect-TS/effect のほかの issue

Effect-TS/effect の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。