Skip to content

fix(cli): fall back to plain print when prompt_toolkit has no Win32 console#23011

Closed
KhanCold wants to merge 5 commits into
NousResearch:mainfrom
KhanCold:fix/cli-prompt-toolkit-win32-fallback
Closed

fix(cli): fall back to plain print when prompt_toolkit has no Win32 console#23011
KhanCold wants to merge 5 commits into
NousResearch:mainfrom
KhanCold:fix/cli-prompt-toolkit-win32-fallback

Conversation

@KhanCold

@KhanCold KhanCold commented May 10, 2026

Copy link
Copy Markdown

Closing as this duplicates existing work. Will focus on cleaner, focused PRs going forward.

KhanCold added 5 commits May 10, 2026 12:41
The LF-submit fix for thin PTYs (commit 5044e1c) regressed multiline
composition on macOS by binding c-j (LF) to submit unconditionally on
POSIX. Shift+Enter is delivered as c-j on many terminals, so it stopped
inserting newlines and submitted the message instead.

Upstream added install_shift_enter_alias() for CSI-u/modifyOtherKeys
terminals, but default macOS Terminal still sends bare LF for Shift+Enter.
This change complements upstream's approach.

Changes:
- _bind_prompt_submit_keys(): only bind 'enter'; remove unconditional
c-j binding so the caller can decide based on environment.
- In the CLI setup block, bind c-j to newline by default on POSIX local
terminals (not WSL/SSH/WT which are handled by _preserve_ctrl_enter_newline).
- When HERMES_CLI_SUBMIT_ON_LF=1 is set, bind c-j to submit instead,
opt-in for thin PTYs that deliver Enter as LF.

Adds regression tests covering:
- default POSIX: c-j inserts newline
- env HERMES_CLI_SUBMIT_ON_LF=1: c-j submits
- WSL/SSH/WT: c-j left untouched (has its own binding)

Fixes NousResearch#22908
NousResearch#22660)

Two methods in MemoryStore called .fetchone()["field"] without first
checking if fetchone() returned None, causing TypeError in race conditions.

- add_fact: after sqlite3.IntegrityError, the duplicate row may have been
deleted by a concurrent operation before the fallback SELECT executes.
  → Guard with explicit None check; raise RuntimeError for this
    impossible-but-observed state.

- update_fact: when category is not provided, a second SELECT fetches the
current category. If the row was deleted between the first SELECT and this
second one, fetchone() returns None.
  → Guard with explicit None check; return False (row no longer exists).

Fixes NousResearch#22660
…search#22569)

cron.jobs.load_jobs called data.get("jobs", []) immediately after
json.load(), assuming the root is always a dict. If jobs.json is
hand-edited or written by a legacy release in a non-dict shape
(bare list, null, scalar, string), the call crashes with AttributeError.

Changes:
- Guard both json.load() and json.loads(strict=False) paths with
  isinstance(data, dict) checks.
- If data is a bare list (legacy format), auto-migrate by calling
  save_jobs() and return the list.
- If data is any other non-dict shape, log an error and return []
  instead of crashing.

Fixes NousResearch#22569
…ch#22489)

The generic API-key health-check loop sends
to every provider, but Google AI Studio (generativelanguage.googleapis.com)
rejects Bearer tokens and requires  instead. This made
 falsely report Gemini as unreachable or invalid.

Changes:
- In , detect Gemini by checking whether the
  resolved base URL host matches .
- For Gemini endpoints, set  instead of .
- All other providers continue using  unchanged.

Fixes NousResearch#22489
…onsole (NousResearch#22482)

Kanban worker processes on Windows spawn with stdout/stderr redirected
to log files. In that setup there is no Win32 console buffer, so
prompt_toolkit's print_formatted_text path raises NoConsoleScreenBufferError.

Changes:
- Wrap _pt_print calls in cli.py and hermes_cli/banner.py with try/except
  that falls back to plain print() on any exception.
- This matches the existing pattern already used elsewhere in cli.py
  (the replay loop already has a bare except around the whole block).

Fixes NousResearch#22482
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #22482 (same fix for #22445). This PR also bundles unrelated defensive fixes (cron/jobs, holographic, doctor) not mentioned in the title or description.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels May 10, 2026
@KhanCold KhanCold closed this May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants