Wasm terminal color always detected as unsupported
tqwewe opened this issue · 3 comments
Lines 16 to 19 in 02fa5c0
In the wasm terminal module, it sets is_a_color_terminal
to always return false. But this should use detection similar to native terminals.
In my case, I'm trying to implement console
with a wasm runner called lunatic
, though coloring doesn't work unless I force it to be enabled, since the compiled module is a wasm module ran by lunatic.
I would need to look into what WASI wants to do there. There is some discussion about how this is supposed to work over there: WebAssembly/WASI#162
It looks like even if console
were to report a color terminal, wasmtime
would filter out ANSI codes. I'm unfamiliar with lunatic
, not sure how that works. If you have a reference about how lunatic
supports ANSI codes I would be interested.
Lunatic uses wasmtime under the hood for running the wasm, and just manages multiple "processes". But the main support would be a matter of wasmtime really.
If I force it to be enabled, it prints the colors just fine. I guess wasi just lacks a spec/support for ansi stuff, and sadly that github issue isn't very active.
I guess my best case going forward could be to just copying these lines
Lines 26 to 33 in 02fa5c0
That is interesting. Because this commit here indicates that ANSI sequences should be filtered by wasmtime: bytecodealliance/wasmtime#684 — it's also documented here as explicitly filtered: https://github.com/bytecodealliance/wasmtime/blob/e4dc9c79443259e40f3e93b9c7815b0645ebd5c4/docs/security.md?plain=1#L98
I would love to get some guidance on what to do with ANSI codes before committing to something. Right now you can already manually force colors on globally by calling console::set_colors_enabled
overriding what happens normally.