Open DaniGuardiola opened 9 months ago
This bug was fixed by https://github.com/oven-sh/bun/pull/7650 👍
Is this working? I was trying to run the use-input example from the ink repo and I couldn't make it to work with 1.0.23
@luiz290788 in my case, I used (my own CLI) to test it: bunx classy-ink
It didn't work when I filed this issue, but now it does, at least for me. Feel free to try it yourself and let me know if inputs work for you.
It is not working with the example in the repo. I will open another issue. I believe the problem is related to useApp
.
Not working
Can confirm, this doesn't seem to be working:
import React from "react";
import { render, Text, useApp, useInput } from "ink";
function Minimal() {
const { exit } = useApp();
useInput((input) => {
if (input === "q") {
exit();
}
});
return React.createElement(Text, { color: "dim" }, ["This is a test; ctrl+c or q to exit"]);
}
render(React.createElement(Minimal));
process.on("exit", () => {
const terminal = process.stderr.isTTY
? process.stderr
: process.stdout.isTTY
? process.stdout
: undefined;
terminal?.write("\u001B[?25h");
});
Works fine in Node, never accepts input in Bun (pkill -f bun
in another terminal to kill it)
Re-opening since other people seem to still be running into this bug.
Bun doesn't call
process.stdin.resume()
And that is why app automatically exits and useIntput is not working.
@DaniGuardiola @baublet please, confirm that this works for you:
import React from "react";
import { render, Text, useApp, useInput } from "ink";
//you need this
process.stdin.resume()
function Minimal() {
const { exit } = useApp();
useInput((input) => {
if (input === "q") {
exit();
}
});
return React.createElement(Text, { color: "dim" }, ["This is a test; ctrl+c or q to exit"]);
}
render(React.createElement(Minimal));
process.on("exit", () => {
const terminal = process.stderr.isTTY
? process.stderr
: process.stdout.isTTY
? process.stdout
: undefined;
terminal?.write("\u001B[?25h");
});
@slavaGanzin thanks, I just tried this with Bun v1.1.14
, and while the program waits for input, pressing q
doesn't quit, as it does on node with ts-node.
The ctrl + c functionality works, just not the q
😃
Bun doesn't call
process.stdin.resume()
And that is why app automatically exits and useIntput is not working.@DaniGuardiola @baublet please, confirm that this works for you:
import React from "react"; import { render, Text, useApp, useInput } from "ink"; //you need this process.stdin.resume() function Minimal() { const { exit } = useApp(); useInput((input) => { if (input === "q") { exit(); } }); return React.createElement(Text, { color: "dim" }, ["This is a test; ctrl+c or q to exit"]); } render(React.createElement(Minimal)); process.on("exit", () => { const terminal = process.stderr.isTTY ? process.stderr : process.stdout.isTTY ? process.stdout : undefined; terminal?.write("\u001B[?25h"); });
idk if its related to this issue but looks like https://github.com/vadimdemedes/ink-text-input doesnt work aswell: it just exists the process. Bun 1.1.20, platform: windows.
Looks like works only with process.stdin.resume()
and you have to press ctrl-c
two times to exit
What version of Bun is running?
1.0.7+b0393fba6200d8573f3433fb0af258a0e33ac157
What platform is your computer?
Microsoft Windows NT 10.0.22621.0 x64 (WSL: Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64)
What steps can reproduce the bug?
Create a simple Ink program that uses
useInput
. Run with bun.What is the expected behavior?
Program responds to input.
What do you see instead?
Program does not respond to input.
Additional information
No response