Repository navigation
fix(repl): a DSR-silent terminal keeps its shell; TAB completion commits (closes #373) - #418
Conversation
cff47e3 to
3f7f0ad
Compare
|
CR round pushed (3f7f0ad, rebased onto b3c9c52 — #419/#401 merged mid-flight; interactive.rs conflict resolved by taking master's file and re-applying only this PR's deltas). F1 (Ctrl+R dead key) — fixed. Root cause confirmed as reviewed: F1 regression coverage. Two layers: (1) unit — F2 — superseded by the F1 fix: paste flows no longer carry the Esc at all, so their assertions pin the bare shape ( F3 — documented in the F4 — documented in F5 — Upstream: agreed and noted here for the record — reedline 0.52's history-search handler drops whole Re-verification on b3c9c52 ( |
…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.
3f7f0ad to
bcd5769
Compare
|
Resume after a rate-limit kill: rebased onto current master (717327a — #421 landed; only CHANGELOG.md overlapped, resolved; also corrected a stale Re-verification on 717327a ( |
CR round 2 verdict: APPROVE (post-F1-fix, rebase onto 717327a)Re-reviewed bcd5769 independently (fresh worktree, all suites re-run locally on Win10 19045). Self-approval is blocked by GitHub (same account), so the verdict lands as a comment. F1 (Ctrl+R dead key) — fixed and verified at two layers.
Regression discipline re-verified.
Non-blocking notes (no action required):
Ready to merge. |
Follow-up to #355 (findings 3 and 4; history persistence was closed by #372). Closes #373.
Per-sub-item status
ESC[6n)crossterm29paste-detector pin stays valid). 0.50's painter abortedread_lineon the query timeout (crossterm unix path: fixed 2 s poll) → error + dead session. 0.52'sanchor_promptdegrades: newline + stale row, prompt paints, later cycles stay interactive. Repro (execution-level): a DSR-silent PTY on master printed the banner never and the error at ~2.6 s (the #355 Termux measurement, re-verified through the new harness on the unix code path); after the fix the prompt paints and theechoround trip completes with no error text.partial_completionswere OFF, so menu activation spliced nothing:cat uniqfi<TAB>keptcat uniqfi, the completed word was only the menu's highlighted entry, and Enter executed the unexpanded path. Now every TAB splices the GNU readline shape (lone candidate commits outright; ambiguous set commits its common prefix and still lists). reedline 0.52 additionally offers an open menu first refusal at Enter (nushell semantics: first Enter accepts, second submits); a bash-like shell runs the line as typed, so the paste wrapper prefixes a typed Enter with a menu-dismissalEsc— one Enter submits, grid up or not.quick_completionsstays OFF deliberately (its lone-candidate path simulates Enter = accept AND execute — not bash).scripts/perf/ttp-bench.py(sandboxed HOME, ConPTY, DSR answered, N=5 medians,NIU_TRACE_STARTUPattribution). Release binaries, Win10 19045: master niu 3164.5 ms / bash 3260.2 ms → fix niu 3139.8 ms / bash 3289.3 ms — parity, no regression. Attribution: niu's internal startup is ~70–140 ms; the wall clock is this machine's ConPTY transport floor (same for bash), consistent withscripts/perf/budgets.toml.Acceptance criteria
tests/issue373_dsr.rs— an answers-nothing terminal driver over portable-pty. Control leg (answersESC[6n/ESC[c) green everywhere (banner 215–282 ms, prompt +43–53 ms, cycle ~32 ms). Silent leg: hard assertions (banner + prompt +echoround trip + no line-editor error, bounded budgets) on unix; on Windows/ConPTY the silent condition cannot reach niu — measured transcript of a silent session is exactly<ESC>[6n: conhost withholds the client before its first instruction until the terminal answers (session-attach contract, terminal-side; Windows Terminal / pywinpty / the shared driver all answer). The Windows half of the contract is pinned by the control leg; the silent leg prints a rationale skip there.tests/interactivematrix green apart from a pre-existing failure set (below).issue373_dsr(fallback) +tab_completes_unique_file_path/tab_completes_command_nameun-ignored and green (the rubash#287 "wiring gap" residuals are fixed by this change; the unique-file test asserts the execution-level chain: one Enter after TAB runs the completed path —uniq-file-bodyprints, noNo such file).Scope notes
GnuMenumigrates to the now-mandatoryMenu::settings(name/marker builders write straight intoMenuSettings; thename()/indicator()overrides are gone — defaults read settings) andVi::newtakes the upstream-default visual keybindings (niubash never bound visual keys).Multiple([Esc, Enter])/[flush, Esc, Enter]); the [P1][regression #252] Windows 粘贴块启发式吞掉每个提示符后的第一次 Enter —— ConPTY 驱动/脚本/快速打字全部丢提交 #284/[P2] Enter pressed within the paste burst window is swallowed as chunk data — needs a second Enter #308/[P1][blocks 1.4.1] interactive paste still swallows line starts in WT on the current build — full script reproduction (owner live session 2026-10-14) #341 contracts they encode (typed submit passes through, flush+submit in one batch, no bare CR parked in the pushback) are unchanged and still asserted.ListMenu::can_partially_completeisfalse; Ctrl-R ridesSearchHistory, not the menu event).Verification (this host, Win10 19045,
--test-threads=1)cargo test -p niubash-runtime --lib: 542 passed / 1 failed —test_get_builtin_commands, fails identically on the origin/master baseline run (pre-existing, environment-dependent builtin set).cargo test --test interactive: 65 passed / 5 failed —continuation_single_quote,continuation_subshell_paren,ctrl_c_interrupts_external_command,ctrl_d_after_background_job,gitbash_factory_prompt; byte-identical failure set on the origin/master baseline run (pre-existing on master, unrelated surfaces;multiline_crlf_pasteflapped in one run on both trees).issue373_dsr2/2 ·completion_probe29/29 ·repl_command11/11.