DRAFT: Prompt: Esc is ignored — only Ctrl-C/Ctrl-D cancel a prompt
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:handleSelectProcesshas no"escape"case, so the key falls todefault, which returnsAction.Beep(). The other built-in prompts'processhandlers have no"escape"case either;grep -n escape packages/effect/src/cli/Prompt.tsfinds nothing.NodeTerminal.ts:176-178: the defaultshouldQuitends 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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Effect-TS/effect
-
`fromJsonSchemaDocument`: import open `patternProperties`Posiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10048 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
`fromJsonSchemaDocument`: intersect an object with `anyOf` branches that re-declare an enum propertyAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
Los mantenedores suelen responder en 1 día
-
`fromJsonSchemaDocument`: import `dependentRequired` (draft-07 `dependencies`)Posiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10046 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
`fromJsonSchemaDocument`: import `if` / `then` / `else`Posiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10045 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
`fromJsonSchemaDocument`: import the `not` keywordPosiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10044 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
e2e-failure ready-to-code
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
redhat-developer/rhdh-plugin-export-overlays#4616 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
ai-handle
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nextlevelbuilder/dewee-web-v2#73 ·
Los mantenedores suelen responder en 1 día
-
backend bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
PoCInnovation/Distribox#255 ·
Los mantenedores suelen responder en 1 día