Skip to content

fix(cli): play animates in the desktop app's automata on Windows - #135

Merged
thethinkmachine merged 1 commit into
mainfrom
fix/cli-play-windows-app
Oct 3, 2026
Merged

thethinkmachine merged 1 commit into
mainfrom
fix/cli-play-windows-app

Conversation

@thethinkmachine

Copy link
Copy Markdown
Owner

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. Present in every release since play landed (v3.0.0–v3.1.1).

  • play takes its keys from keyboard(), 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.
  • A test pins those cases; the CLI skill notes how to reproduce it (the clips run under plain Node and cannot show it).

Checked with the repo's electron.exe as Node, from a .cmd under a pseudo-console, on both the source and the dist-cli/ bundle: before, every frame at once; after, 6 fps, space/arrows/q/Ctrl+C all work. npm test: 2791 pass.

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.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 05:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread cli/commands/play.mjs
open = () => new ReadStream(openSync('\\\\.\\CONIN$', 'r+'))
} = {}) {
if (stdin.isTTY) return { stream: stdin, close() {} };
if (platform !== 'win32' || !electron) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@thethinkmachine
thethinkmachine merged commit 391c93f into main Oct 3, 2026
18 checks passed
@thethinkmachine
thethinkmachine deleted the fix/cli-play-windows-app branch October 3, 2026 07:09
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.

2 participants