Skip to content

P3 sweep: self-update highlight (niu#260) + android cross-check gates (niu#207 step 1) + rc-0 history flush restore - #281

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/p3-sweep
Oct 12, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix/p3-sweep

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

逐条处置(5 个开放 issue)

Issue 处置 落点
#260 self-update 是红色的 fixed 1059080
#207 平台 roadmap step 1 fixed(android 双 target 进 cross-check),其余 analysis 3ea224e
#211 Win10 桌面快捷方式 conhost analysis-needed(一半已落地,剩快捷方式形态需 owner 拍板) issue 评论
#186 全屏插件管理器 TUI analysis-needed(M1-M4 立项级,建议 M1 单独开分支) issue 评论
#104 Winget fixed-external(winget-pkgs#444854 已 MERGED,建议 owner 确认可见后关闭) issue 评论

另含一个前置修复(不在 issue 列表内,但是 master 当前 CI 红的根因):c1eac99。

#260(fixed, 1059080)

self-update / update-niubash 是 REPL 先行拦截词(repl::self_update_command_args),永远不在 PATH 上解析,高亮器把它们涂成 UnknownToken(红)——即截图现象;logout 同类。新增 repl::is_repl_reserved_command(exit/logout/self-update/update-niubash,大小写敏感对齐 REPL 精确匹配),高亮器在命令位把这些词按 Builtin(青)上色;参数位不受影响。测试:复现测试(改前 fg(Red)→改后 fg(Cyan))、参数位 Default、谓词单测。

#207 step 1(3ea224e)

rubash#456(bionic 适配)合入后,niubash 侧 workspace 在两个 android target 上 cargo check --workspace --locked 本机全绿,进入 cross-target-check 矩阵(同 #210 musl/ohos 形态)。途中清掉两个阻塞:

  • arboard 无 android 后端:reedline 的 system_clipboard(拉进 arboard)按目标平台门控——Windows/macOS/Linux 不变(arboard 仍在宿主图里),android 丢 Ctrl+V 系统剪贴板(stub 保形,bracketed paste 不受影响)。
  • build.rs 用 host 谓词 #[cfg(windows)] 门控 rc.exe:Windows 宿主交叉 check android target 时会去跑 SDK 的 arm64 rc.exe(arm64 二进制,x64 上 os error 216)。改用 CARGO_CFG_TARGET_OS——.res 本来只进 PE。

Android 仍只是 compile-verified:没有原生 smoke gate 之前不发产物(docs/release.md 红线不松)。矩阵尚缺的承诺/best-effort/不做清单与 iOS non-goal 文档化,等 owner 在 #207 拍板后另行成文。

前置修复:rc-0 一次性会话恢复 Drop(c1eac99)

master 当前 CI 红(host_contract::history_and_fc_use_the_host_history_provider,130598a 起):#272 把所有一次性出口都汇入 finish_and_exit(std::process::exit,跳过 Drop),而 RubashHistoryProvider::drop 是 history -c 落盘的唯一载体(#265)。484dad3 的原版在 rc 0 时是正常返回的。finish_one_shot 改回「非零才 exit,rc 0 正常返回」,原先依赖其恒发散的臂显式 return Ok(()) 防止坠入后续分支。手测:-c 序列结束后 history 文件为空、exit 5 rc 不变、cwd-state 记录保留。

测试证据

  • cargo test -p niubash-runtime --lib:458 passed, 0 failed(含新增 4 个测试)。
  • 根包集成(非 ConPTY)全绿:smoke、smoke_1_3_0(a1-e1 非 PTY 项)、startup_files、repl_command、host_contract(43 passed,含修复目标)、cwd_state、plugin_*、issue1xx、compat 等。
  • android 双 target 本机:cargo check --workspace --locked --target aarch64-linux-android 与 --target armv7-linux-androideabi 全绿。
  • 已知与本 PR 无关的环境红:issue182_bashit_history_interlock、smoke_1_3_0 d2/d3(三个 ConPTY journey)在 base c3df161 上同样确定性失败(已逐 commit 复核:base/1059080/3ea224e/HEAD 全失败,10s PTY 屏幕匹配超时,非历史文件断言),疑似本机 ConPTY 渲染/驱动匹配问题,建议单独排查。
  • cargo fmt --check 干净。

不关闭任何 issue

#211/#186/#207 的处置建议详见各 issue 评论,等 owner 拍板;#104/#260 的关闭建议也在评论里。

…ash, logout) as builtins (niu#260)

self-update / update-niubash are intercepted by the REPL before engine
command resolution, so they never resolve on PATH and the highlighter
painted them as unknown tokens (red) even though they run fine (issue
screenshot: red 'self-update' at the prompt). Same class of problem for
'logout', which is also a REPL-exact-match word.

Add repl::is_repl_reserved_command as the shared predicate over REPL-
reserved first words (exit, logout, self-update, update-niubash) and
consult it from the highlighter's command-position classification, so
these words get builtin styling instead of UnknownToken. Case-sensitive
by design, matching the REPL's exact-match intercepts; argument
positions are unaffected.

Tests: highlighter repaints the three words as Builtin, argument
position stays Default, predicate unit test covers exact-match
semantics.
…checks (niu#207 step 1)

rubash#456 landed the bionic cfg fixes, so both android targets now
check clean through rubash; this exposes them on the niubash side of
the workspace check, same shape as the musl/ohos legs (#210/#221).
Both targets verified green locally: cargo check --workspace --locked
--target aarch64-linux-android and --target armv7-linux-androideabi.

Two blockers surfaced and are fixed here:

- arboard 3.6.1 (via reedline's system_clipboard feature) has no
  android backend and fails to compile for android targets. Gate the
  feature to non-android targets in Cargo.toml: Windows/macOS/Linux
  builds keep the system clipboard (arboard stays in their graphs),
  android loses Ctrl+V system paste behind a stub
  add_system_clipboard_keybindings, bracketed paste unaffected.

- build.rs gated the icon .res embedding on #[cfg(windows)] - a HOST
  predicate. Cross-checking an android target from a Windows dev box
  made it run the SDK's arm64 rc.exe, an arm64 binary that cannot
  launch on x64 (os error 216). Gate on CARGO_CFG_TARGET_OS instead;
  the resource only links into PE binaries anyway. Ubuntu-hosted CI
  legs are unaffected either way.

Part of niubash#207 (platform roadmap) step 1/2: make the compile
surface visible and honest. Android remains compile-verified only -
no release artifacts until a native smoke gate exists per
docs/release.md red line.
…n-end write runs

Pre-existing master red (host_contract::history_and_fc_use_the_host_history_provider,
failing on CI since 130598a): a one-shot 'niu -c history -c' left the
history file holding the pre-clear list instead of truncating it.

Root cause: 130598a routed every one-shot exit through
finish_one_shot -> piped_stdout::finish_and_exit -> std::process::exit,
which skips Rust destructors. RubashHistoryProvider::drop is the only
thing that carries a GNU 'history -c' to the file at session end
(niubash#265), so rc-0 -c sessions stopped flushing. 484dad3 (the
original fast path) returned Ok(()) on rc 0 and only diverged on
nonzero codes - the Drop ran and the test passed.

finish_one_shot now calls piped_stdout::finish() and exits only on
nonzero codes; rc 0 returns to the caller. Arms that previously relied
on the always-diverging call tail now 'return Ok(())' explicitly so
they cannot fall through into the script/REPL arms.

Verified: the manual -c sequence (history; fc 2 / -s / -d 2 / -c) ends
with an empty history file; 'exit 5' still propagates rc 5; host_contract
and cwd_state suites green; cwd-state recording (the #272 feature)
still runs before both exit forms.
…is runtime-gated on the target OS

3ea224e (#207 step 1) moved the call site from host #[cfg(windows)] to a
CARGO_CFG_TARGET_OS runtime check so a Windows host cross-checking an
android target no longer runs the SDK's arm64 rc.exe (os error 216), but
left the definition behind #[cfg(windows)]. On a linux/macOS host the
call site now compiles while the definition is cfg'd out: E0425 on every
non-Windows host (ubuntu/macos/android/ohos/armv7 cross-checks).

Drop the cfg from the definition - it is std-only and dead unless the
target is Windows.
@caomengxuan666
caomengxuan666 merged commit fe4dd52 into master Oct 12, 2026
8 of 9 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 12, 2026
…on-end writes

Public API retention after the #281 ruling: the rc-0 one-shot exits return
from main normally, so the provider's Drop flush carries the session-end
history write on every standard path and the funnel never calls this —
the method exists for embedding hosts that terminate through
std::process::exit on paths the funnel does not own (a hard exit skips
Drop, so the write must be made explicitly). Best-effort like every
history-file write: never fails, never reaches stderr.
@caomengxuan666
caomengxuan666 deleted the fix/p3-sweep branch October 13, 2026 02:06
caomengxuan666 added a commit that referenced this pull request Oct 13, 2026
… integrate through the rc data layer (#278)

* refactor(completion): retire the in-core carapace provider; providers integrate through the rc data layer

Architecture correction before 1.4.0 (owner ruling 2026-10-12): no shell
hardcodes a third-party completion provider into its source. #243 compiled
CarapaceCompletionPlugin (NIU_CARAPACE discovery, Go-binary output parsing,
300 ms timeout, 5-min TTL session cache, winuxcmd-TOML yield logic) into the
completion core; the provider belongs in the rc DATA layer, integrating
through the protocol the shell already speaks.

Removed: crates/niubash-runtime/src/completion/carapace.rs and every hook
(mod declaration, CarapaceCoverage plumbing in completer.rs, the live
registration test). NIU_CARAPACE never shipped in a tag, so zero
compatibility debt.

The protocol layer is unchanged — the three native surfaces still stand:
`complete` compspecs (rubash engine), NIU_COMPDEFS compdef functions, and
winuxcmd applet TOMLs / completion definition files.

Put back at the data layer, per the standard bash-completion practice:

- niu setup grows an opt-in question (default OFF) that appends the standard
  guarded carapace-bin rc snippet — the same block a bash user writes by
  hand, with the install requirement commented; niu ships and installs no
  provider.
- New docs page "External Completion Providers" (SUMMARY-linked): the
  protocol surfaces, priority rules, carapace-bin as one example, and an
  honest status note — complete -F/-C hook functions resolve in-script
  (compgen -F) but their interactive Tab resolution remains a rubash engine
  follow-up; function providers speak the compdef protocol today.
- Binary-level tests pin the rc route: `complete -W` wordlists and compdef
  hooks sourced from ~/.niubashrc serve Tab candidates through the real
  startup sequence, and a standard .bash completion script serves flag
  candidates through the bash-import channel. The --completion-probe now
  mirrors the REPL startup (loads compdefs, installs the completion bridge),
  which is what makes those probes faithful.
- CHANGELOG 1.4.0 records #243 as the architecture correction it was.

cargo test --no-fail-fast failure set is identical to the origin/master
baseline run on the same machine (environment-bound interactive/ConPTY
failures only); cargo fmt --check clean.

* feat(history): expose Shell::flush_session_history for explicit session-end writes

Public API retention after the #281 ruling: the rc-0 one-shot exits return
from main normally, so the provider's Drop flush carries the session-end
history write on every standard path and the funnel never calls this —
the method exists for embedding hosts that terminate through
std::process::exit on paths the funnel does not own (a hard exit skips
Drop, so the write must be made explicitly). Best-effort like every
history-file write: never fails, never reaches stderr.
caomengxuan666 added a commit that referenced this pull request Oct 13, 2026
…1.4.0 section (#326)

- The [Unreleased] entries (#284/#287, #293-#304, #313) move into
  [1.4.0]; [Unreleased] is empty again.
- Newly recorded (today's wave): Git Bash compatible factory default
  prompt (#292, headline), WT-form shortcuts (#290/#211), the paste
  burst trailing-Enter fix (#308/#291), self-update SHA256 + release
  pinning (#311/#312), managed-block convergence (#324), completion
  tables/NIU_COMPDEFS/NIU_ENV probe (#305-#307), -s on-demand stdin
  (rubash#586 host half), bash/rbash invocation faces (#321/#322).
- Older gaps recorded: closed-stdout pipe contract (#245/#286), history
  session-end write-back (#265), sh POSIX contract (#262), PWD persona
  alignment (#283), one-shot fast path (#270), --cwd-state (#272),
  --encoded-command (#271), REPL-command highlighting (#281), docs
  passes (#255/#225/#226/#227), MSRV (#267), easter-egg prune (#264).

CHANGELOG-only change; no version claims.
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