Repository navigation
fix(cli): play animates in the desktop app's automata on Windows - #135
Conversation
The installed `automata` is the app's executable run as Node, and on Windows that is a GUI program: Electron reattaches stdout and stderr to the console but not stdin. play saw a stdin that was no terminal, took it for a pipe, and printed every frame instead of playing them. Its keys now come from keyboard(), which opens the console's input by name (\.\CONIN$) in exactly that case — Electron on win32 with no terminal on stdin. Anywhere else a non-terminal stdin is a real pipe and still gets frames; if no console can be opened, it falls back to frames rather than failing. The console stream is closed on quit, or the process would never exit. The clips never caught it: they run this checkout under plain Node.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 922113e0cf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| open = () => new ReadStream(openSync('\\\\.\\CONIN$', 'r+')) | ||
| } = {}) { | ||
| if (stdin.isTTY) return { stream: stdin, close() {} }; | ||
| if (platform !== 'win32' || !electron) return null; |
There was a problem hiding this comment.
Preserve frame mode for redirected stdin
When the Windows desktop CLI is invoked from a console with stdin genuinely redirected (for example, automata play ... < input.txt), stdin.isTTY is false but process.versions.electron is set, so this condition opens CONIN$ and enters the interactive loop instead of emitting all frames. That changes the documented piped/redirected behavior and can leave scripts waiting for a q keystroke; only use the console fallback when stdin is actually unattached rather than treating every non-TTY Electron stdin as that case.
Useful? React with 👍 / 👎.
The installed
automatais the app's executable run as Node, and on Windows that is a GUI program: Electron reattaches stdout and stderr to the console but not stdin.playsaw a stdin that was no terminal, took it for a pipe, and printed every frame instead of playing them. Present in every release sinceplaylanded (v3.0.0–v3.1.1).playtakes its keys fromkeyboard(), which opens\.\CONIN$in exactly that case — Electron on win32 with no terminal on stdin. Anywhere else a non-terminal stdin is a real pipe and still gets frames; with no console to open it falls back to frames rather than failing. The console stream is closed on quit, or the process would never exit.Checked with the repo's
electron.exeas Node, from a.cmdunder a pseudo-console, on both the source and thedist-cli/bundle: before, every frame at once; after, 6 fps, space/arrows/q/Ctrl+C all work.npm test: 2791 pass.