Repository navigation
fix(repl): reload persisted history across sessions - #372
Merged
Merged
Conversation
caomengxuan666
added a commit
that referenced
this pull request
Oct 18, 2026
…its (closes #373) Follow-up to #355 (findings 3 and 4; history persistence was #372). Sub-item 1, DSR fallback: interactive startup anchored the prompt with an ESC[6n cursor-position query and reedline 0.50 ABORTED read_line when it timed out — on a terminal that never answers (dumb terminals, script(1) recordings, some serial/tmux links) every startup paid a ~2.6 s stall, printed 'line editor error: The cursor position could not be read within a normal duration', and exited before painting any prompt. The editor bump to reedline 0.52 treats the query as advisory: the prompt paints without a reply and every later cycle stays interactive (crossterm's fixed 2 s query budget is the remaining per-cycle cost on the unix path; degrade-not-die). Windows/ConPTY cannot exercise the silent path at all — measured on this harness (Win10 19045): a silent session's transcript is exactly ESC[6n, conhost withholds the client before its first instruction until the terminal answers, a terminal-side contract below niu (Windows Terminal, pywinpty's agent and the shared test driver all answer). tests/issue373.rs pins both halves: the answering control leg everywhere, the silent regression leg on unix. Sub-item 2, file completion commit: with the engine's partial completions off, menu activation spliced NOTHING into the line — 'cat uniqfi<TAB>' kept 'cat uniqfi' with the completed word drawn only as the menu's highlighted entry, and Enter executed the uncompleted path (cat error). Every TAB now commits the GNU readline shape: the longest common prefix of the candidate set is spliced into the line, a lone candidate commits outright, the grid still shows for an ambiguous set. reedline 0.52 also offers an open menu first refusal at Enter (nushell's completion cell: first Enter accepts, second submits); a bash-like shell runs the line as typed, so the wrapper prefixes a typed Enter with a menu-dismissal Esc — gated to the TAB window (a TAB may leave the menu alive; a CONTROL chord ends the window, so the Ctrl+R search's accepting Enter stays the bare event its handler implements — an unconditional wrap made it a dead key, dropping whole Multiple batches in search mode). One Enter submits, bash's accept-line, grid up or not. quick_completions stays OFF deliberately: its lone-candidate path simulates Enter (accept AND execute). Sub-item 3, TTP: scripts/perf/ttp-bench.py measures spawn-to-first-prompt against GNU bash over the same ConPTY harness with NIU_TRACE_STARTUP attribution. Release binaries, N=5 medians, Win10 19045: master niu 3164.5 ms vs bash 3260.2 ms; fix niu 3139.8 ms vs bash 3289.3 ms — parity, no regression (the wall clock is this machine's ConPTY transport floor; niu's internal startup is ~70-140 ms). Regression evidence: runtime lib 542+ passed / 1 failed (test_get_builtin_commands, fails identically on the master baseline), interactive 65 passed / 5 failed (the byte-identical master-baseline failure set; one load flake per run), issue373 3/3 (DSR control + silent split, full Ctrl+R flow), completion_probe 29/29, repl_command 11/11. tab_completes_command_name and tab_completes_unique_file_path are un-ignored and green (the rubash#287 residuals are fixed by this change); tab_completion_empty_set_enter_still_submits pins the F5 shape.
caomengxuan666
added a commit
that referenced
this pull request
Oct 18, 2026
…its (closes #373) Follow-up to #355 (findings 3 and 4; history persistence was #372). Sub-item 1, DSR fallback: interactive startup anchored the prompt with an ESC[6n cursor-position query and reedline 0.50 ABORTED read_line when it timed out — on a terminal that never answers (dumb terminals, script(1) recordings, some serial/tmux links) every startup paid a ~2.6 s stall, printed 'line editor error: The cursor position could not be read within a normal duration', and exited before painting any prompt. The editor bump to reedline 0.52 treats the query as advisory: the prompt paints without a reply and every later cycle stays interactive (crossterm's fixed 2 s query budget is the remaining per-cycle cost on the unix path; degrade-not-die). Windows/ConPTY cannot exercise the silent path at all — measured on this harness (Win10 19045): a silent session's transcript is exactly ESC[6n, conhost withholds the client before its first instruction until the terminal answers, a terminal-side contract below niu (Windows Terminal, pywinpty's agent and the shared test driver all answer). tests/issue373.rs pins both halves: the answering control leg everywhere, the silent regression leg on unix. Sub-item 2, file completion commit: with the engine's partial completions off, menu activation spliced NOTHING into the line — 'cat uniqfi<TAB>' kept 'cat uniqfi' with the completed word drawn only as the menu's highlighted entry, and Enter executed the uncompleted path (cat error). Every TAB now commits the GNU readline shape: the longest common prefix of the candidate set is spliced into the line, a lone candidate commits outright, the grid still shows for an ambiguous set. reedline 0.52 also offers an open menu first refusal at Enter (nushell's completion cell: first Enter accepts, second submits); a bash-like shell runs the line as typed, so the wrapper prefixes a typed Enter with a menu-dismissal Esc — gated to the TAB window (a TAB may leave the menu alive; a CONTROL chord ends the window, so the Ctrl+R search's accepting Enter stays the bare event its handler implements — an unconditional wrap made it a dead key, dropping whole Multiple batches in search mode). One Enter submits, bash's accept-line, grid up or not. quick_completions stays OFF deliberately: its lone-candidate path simulates Enter (accept AND execute). Sub-item 3, TTP: scripts/perf/ttp-bench.py measures spawn-to-first-prompt against GNU bash over the same ConPTY harness with NIU_TRACE_STARTUP attribution. Release binaries, N=5 medians, Win10 19045: master niu 3164.5 ms vs bash 3260.2 ms; fix niu 3139.8 ms vs bash 3289.3 ms — parity, no regression (the wall clock is this machine's ConPTY transport floor; niu's internal startup is ~70-140 ms). Regression evidence: runtime lib 542+ passed / 1 failed (test_get_builtin_commands, fails identically on the master baseline), interactive 65 passed / 5 failed (the byte-identical master-baseline failure set; one load flake per run), issue373 3/3 (DSR control + silent split, full Ctrl+R flow), completion_probe 29/29, repl_command 11/11. tab_completes_command_name and tab_completes_unique_file_path are un-ignored and green (the rubash#287 residuals are fixed by this change); tab_completion_empty_set_enter_still_submits pins the F5 shape.
caomengxuan666
added a commit
that referenced
this pull request
Oct 18, 2026
…its (closes #373) Follow-up to #355 (findings 3 and 4; history persistence was #372). Sub-item 1, DSR fallback: interactive startup anchored the prompt with an ESC[6n cursor-position query and reedline 0.50 ABORTED read_line when it timed out — on a terminal that never answers (dumb terminals, script(1) recordings, some serial/tmux links) every startup paid a ~2.6 s stall, printed 'line editor error: The cursor position could not be read within a normal duration', and exited before painting any prompt. The editor bump to reedline 0.52 treats the query as advisory: the prompt paints without a reply and every later cycle stays interactive (crossterm's fixed 2 s query budget is the remaining per-cycle cost on the unix path; degrade-not-die). Windows/ConPTY cannot exercise the silent path at all — measured on this harness (Win10 19045): a silent session's transcript is exactly ESC[6n, conhost withholds the client before its first instruction until the terminal answers, a terminal-side contract below niu (Windows Terminal, pywinpty's agent and the shared test driver all answer). tests/issue373.rs pins both halves: the answering control leg everywhere, the silent regression leg on unix. Sub-item 2, file completion commit: with the engine's partial completions off, menu activation spliced NOTHING into the line — 'cat uniqfi<TAB>' kept 'cat uniqfi' with the completed word drawn only as the menu's highlighted entry, and Enter executed the uncompleted path (cat error). Every TAB now commits the GNU readline shape: the longest common prefix of the candidate set is spliced into the line, a lone candidate commits outright, the grid still shows for an ambiguous set. reedline 0.52 also offers an open menu first refusal at Enter (nushell's completion cell: first Enter accepts, second submits); a bash-like shell runs the line as typed, so the wrapper prefixes a typed Enter with a menu-dismissal Esc — gated to the TAB window (a TAB may leave the menu alive; a CONTROL chord ends the window, so the Ctrl+R search's accepting Enter stays the bare event its handler implements — an unconditional wrap made it a dead key, dropping whole Multiple batches in search mode). One Enter submits, bash's accept-line, grid up or not. quick_completions stays OFF deliberately: its lone-candidate path simulates Enter (accept AND execute). Sub-item 3, TTP: scripts/perf/ttp-bench.py measures spawn-to-first-prompt against GNU bash over the same ConPTY harness with NIU_TRACE_STARTUP attribution. Release binaries, N=5 medians, Win10 19045: master niu 3164.5 ms vs bash 3260.2 ms; fix niu 3139.8 ms vs bash 3289.3 ms — parity, no regression (the wall clock is this machine's ConPTY transport floor; niu's internal startup is ~70-140 ms). Regression evidence: runtime lib 542+ passed / 1 failed (test_get_builtin_commands, fails identically on the master baseline), interactive 65 passed / 5 failed (the byte-identical master-baseline failure set; one load flake per run), issue373 3/3 (DSR control + silent split, full Ctrl+R flow), completion_probe 29/29, repl_command 11/11. tab_completes_command_name and tab_completes_unique_file_path are un-ignored and green (the rubash#287 residuals are fixed by this change); tab_completion_empty_set_enter_still_submits pins the F5 shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
cargo fmt --check -p niubash
cargo test -p niubash-runtime history --lib --locked
cargo test --test interactive history_file_persists_across_sessions --locked -- --nocapture
Closes [interactive][UX] Interactive battery: cross-session history recall broken (file written at exit, never read back), first prompt 650ms vs bash 25ms, 2.6s stall + error when DSR unanswered, file Tab-completion preview never commits #355