Skip to content

Fixed model discovery failing when CR is absorbed as newline in prompt - #103

Merged
oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/model-discovery-cr-newline
May 1, 2026
Merged

oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/model-discovery-cr-newline

Conversation

@oleg68

@oleg68 oleg68 commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Under load, /model + CR is sometimes treated as a newline in the multiline prompt input instead of submitting the command. The screen shows ❯ /model → blank line → separator, and the polling loop times out with no model list.
  • Added isModelCommandPendingWithBlankLine() that detects this exact screen pattern (cursor line with /model, followed by blank line, then separator line).
  • Added retry inside the discovery polling loop: sends PTY_BACKSPACE + 200 ms delay + \r to resubmit the command (max 12 retries, leaving the last 4 polls to read the menu).
  • Added PTY_BACKSPACE = {0x7f} constant alongside existing PTY_ESC.
  • Added 3 unit tests with the real-world fixture from the bug report.

Test plan

  • Open Claude session on a busy machine — model combo should populate reliably
  • Check messages.log for [discoverModels] /model pending with blank line to confirm retry fires on affected runs
  • Verify no false-positive retries when /model appears in Claude's output history (covered by unit test)
  • mvn test passes (33 tests including 3 new)

🤖 Generated with Claude Code

Under load the /model command sometimes gets CR treated as a multiline
newline instead of submission. The screen then shows ❯ /model → blank
line → separator. Added isModelCommandPendingWithBlankLine() detector
and retry logic: send PTY_BACKSPACE + CR to resubmit the command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@oleg68
oleg68 merged commit b12f4d3 into nbplugins:main May 1, 2026
3 checks passed
@oleg68
oleg68 deleted the bugfix/model-discovery-cr-newline branch May 1, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant