Skip to content

Phase 1.x: boxen guard for repl.printKeyCodes() (/R K corrupts framebuffer) #794

Description

@jsavin

Problem

repl.printKeyCodes() (frontier-cli/repl.c:3544) calls linenoisePrintKeyCodes(), which takes exclusive control of stdin in raw mode and only returns once the user presses Esc three times. In the boxen REPL it would corrupt the framebuffer (raw byte echo onto the boxen-composited terminal) AND collide with boxen's own stdin reads.

The existing guard at repl.c:3545-3548 checks g_repl_active && isatty(STDIN_FILENO) — both true under --debug-tui, so it does NOT prevent the call from running there.

Fix

Add a boxen_ui_is_active() short-circuit:

static boolean replverbhost_print_key_codes(void) {
    if (boxen_ui_is_active()) {
        repl_append_scrollback(
            "/R K (Key codes) is not available in boxen mode -- "
            "exit --debug-tui and run from the linenoise REPL.");
        return false;
    }
    if (!g_repl_active) return false;
    if (!isatty(STDIN_FILENO)) return false;
    linenoisePrintKeyCodes();
    return true;
}

The message lands in the scrollback ring via the normal stdout-capture path.

Context

Acceptance

  • /R K in --debug-tui shows the "not available in boxen mode" message in scrollback without corrupting the framebuffer
  • /R K in linenoise mode still works as today (regression check)
  • Test in tools/tui-tests/tests/test_06_ui_bridge.py asserts the message appears and the REPL stays alive

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions