Skip to content

Prevent hard UI crashes on render errors (Ink raw text in Box) and add graceful fallback #18028

@LyalinDotCom

Description

@LyalinDotCom

What happened?

If a render error occurs in the Ink UI (e.g., a raw string returned inside a ), the CLI can crash so hard that the terminal becomes unresponsive and even Ctrl+C no longer works. The process appears stuck in a broken render loop.

Example error seen in the terminal:

ERROR Text string " " must be rendered inside component

node_modules/ink/build/reconciler.js:156:19

153: },
154: createTextInstance(text, _root, hostContext) {
155: if (!hostContext.isInsideText) {
156: throw new Error(Text string "${text}" must be rendered inside <Text> component);
157: }
158: return createTextNode(text);
159: },
...

Example user flow that triggered this recently:

  • Pressing ? to open the shortcuts UI, which renders a panel with inline spacing.

What did you expect to happen?

  • Render errors should never hard‑crash the CLI.
  • The UI should fall back to a safe minimal screen that still allows Ctrl+C to exit.
  • Errors should be logged so they can be debugged later.
  • (Optional) Provide a lightweight “failsafe” input handler outside Ink so Ctrl+C always works even
    if the UI crashes.

Analysis / Recommendations

  1. Add a top‑level error boundary around the Ink app:
    • Catches render exceptions.
    • Shows a minimal safe fallback.
    • Logs the error (and stack) to a debug log or crash file.
    • Keeps stdin listeners alive so Ctrl+C still works.
  2. Add a failsafe SIGINT handler outside the React tree:
    • If the UI crashes, Ctrl+C still terminates the process cleanly.
  3. Enforce safe rendering practices:
    • Lint/test rules to prevent raw strings inside .
    • Small helper components for layout spacing that always render .
  4. Add a smoke test for rendering:
    • Render key UI surfaces and assert no render exceptions.

Client information

Client Information

Run gemini to enter the interactive CLI, then run the /about command.

> /about
# paste output here

Login information

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreIssues related to User Interface, OS Support, Core Functionalitystatus/needs-info

    Type

    No fields configured for Bug.

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions