Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Cerrado
#8,640 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
node.js, typescript
Área
cli

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
16.7k
Forks
808
Merge medio
11 h 33 min
PR fusionados (30 d)
855

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Effect-TS/effect

Todos los issues de Effect-TS/effect

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.