You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Full diagnosis in #38 (comments). Summary: in a GUI-subsystem (WinExe) host that attaches to the parent console, dispatching a Viewer command without --cat launches the interactive Terminal.Gui session on a console the shell never stopped owning; shells do not wait for GUI-subsystem exes, so the TUI and the shell fight over the same input queue while the TUI paints frames over the prompt.
Ask
CliHostOptions.NonInteractive (or ForceCat): when set, viewer commands always render via RenderCatAsync and input commands without --initial fail with a clear message instead of launching a TUI. Hybrid hosts set it once instead of rewriting args.
Docs: a "Hosting from a GUI app" section covering the three requirements discovered while wiring TG.Cli into a WinForms app (tig/mcec#252): AttachConsole + enable VT via CONOUT$ (Docs: hosting CliHost from a GUI-subsystem (WinExe) app leaks literal ANSI; AttachConsole alone is not enough #38), force non-interactive viewers (this issue), and the inherent caveat that the shell prompt returns before the output (GUI exes are not waited on; the classic cure is a console-subsystem .com shim, worth mentioning).
Our working host-side workaround, for reference:
// Viewer commands default to an interactive TG session; force headless rendering.if(args.Length>0&&viewerAliases.Contains(args[0],StringComparer.OrdinalIgnoreCase)&&!args.Contains("--cat",StringComparer.OrdinalIgnoreCase)){args=[.. args,"--cat"];}
Context
Full diagnosis in #38 (comments). Summary: in a GUI-subsystem (WinExe) host that attaches to the parent console, dispatching a Viewer command without
--catlaunches the interactive Terminal.Gui session on a console the shell never stopped owning; shells do not wait for GUI-subsystem exes, so the TUI and the shell fight over the same input queue while the TUI paints frames over the prompt.Ask
CliHostOptions.NonInteractive(orForceCat): when set, viewer commands always render viaRenderCatAsyncand input commands without--initialfail with a clear message instead of launching a TUI. Hybrid hosts set it once instead of rewriting args.AttachConsole+ enable VT viaCONOUT$(Docs: hosting CliHost from a GUI-subsystem (WinExe) app leaks literal ANSI; AttachConsole alone is not enough #38), force non-interactive viewers (this issue), and the inherent caveat that the shell prompt returns before the output (GUI exes are not waited on; the classic cure is a console-subsystem.comshim, worth mentioning).Our working host-side workaround, for reference: