Repository navigation
feat(prompt): SegmentId::Vcs native segment — wire the #292 git2 renderer into the segments engine (1.4.1) - #332
Merged
Conversation
…erer into the segments engine (closes #331) The oh-my-niu bundle's prompts/segments.toml declares [segments.git] id = vcs; the segments engine had no Vcs variant — a socket with no power. This lands the native segment for 1.4.1: - SegmentId::Vcs; from_name accepts vcs (the native id) and git (the bundle segment name), case/separator-insensitive as before. - Rendering goes through #292's in-process git2 renderer: git_prompt::branch_segment is now pub. branch / branch* / short-SHA detached, empty outside a repository. Zero child processes on the prompt path (niubash#145 red line; #604 measured PS1-embedded $(...) at ~100x native cost). Off-Windows the segment renders empty, matching the gitbash style's template fallback there. - Colour contract from the oh-my-niu themes: [git_clean] cyan, [git_dirty] yellow, keyed off the renderer's dirty star, applied regardless of preset (detached SHA renders clean-cyan, #292 style). - Perf: segment render p50 <= 10ms asserted (21-sample median, 10x headroom); measured warm p50 2.38ms / p90 2.47ms on the dev box, consistent with #292's 2.5ms. - Contract tests pin a verbatim mirror of the bundle's prompts/segments.toml: every declared id resolves natively and every shipped preset element resolves through the name->id map (the lean preset's git lands on SegmentId::Vcs).
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.
Closes #331. Milestone: 1.4.1 (owner ruling 2026-10-14; no GitHub milestone object exists on the repo, noted here per issue title).
What
The oh-my-niu bundle's
prompts/segments.tomldeclares[segments.git] id = "vcs"; the segments engine had noVcsvariant — a socket with no power. This lands the native segment:SegmentId::Vcs(crates/niubash-runtime/src/prompt_segments.rs:36);from_nameaccepts both"vcs"(the native id) and"git"(the bundle segment name), case/hyphen/underscore-insensitive like every other name (prompt_segments.rs:60-63).git_prompt::branch_segmentis nowpub(git_prompt.rs:110) and drives the segment (prompt_segments.rs:240-250). Owner-approved format:branch,branch*(dirty), short SHA (detached), empty outside a repository. Off-Windows the segment renders empty, matching the gitbash style's template fallback there.[git_clean]cyan,[git_dirty]yellow, keyed off the renderer's dirty*(vcs_colour,prompt_segments.rs:253-275); detached SHA renders clean-cyan, feat(prompt): built-in Git Bash compatible factory default on Windows #292 style. Applied regardless of preset: the compiled palettes carry no per-preset git colours (the built-in theme TOML stack retired with Interactive startup hangs on host-side async git-status thread; remove built-in git prompt + theme stack (owner decision) #145), so the segment carries its own contract colour, the same way preset colours are the existing mechanism for theme->segment wiring.Performance (scope 4)
vcs_segment_render_p50_within_10ms_budget: 21-sample median ≤ 10ms (10x headroom).git2::Repository::discover → head → statusesin-process. Nostd::process::Command/spawn anywhere inprompt_segments.rs/git_prompt.rs; WIP: Windows test-content layer — tool-identity stand-down for issue76_93 (root D-2) #604's PS1-embedded$(...)pattern is exactly what this segment bypasses.Tests (scope 3/5)
from_namematrix:vcs/git/VCS/Git/GIT/v-c-s/v_c_s→Vcs; near-misses (gitstatus,vc,gitbash) stayNone. Updates the Interactive startup hangs on host-side async git-status thread; remove built-in git prompt + theme stack (owner decision) #145-era assertion that"vcs"resolves toNone.branch*; detached → 7-char SHA.vcs_colourcontract unit test + end-to-end ANSI assertion (cyan\x1b[36mclean / yellow\x1b[33mdirty throughrender_left).OH_MY_NIU_SEGMENTS_TOMLpins a verbatim mirror of the bundle'sprompts/segments.toml; every declared id resolves natively and every shipped preset element resolves through the name→id map.oh_my_niu_git_segment_resolves_under_name_and_idwalks the shippedleanpreset's"git"element toSegmentId::Vcs(preset integration).Bundle side
Companion oh-my-niu PR: unixwin/oh-my-niu#11 (docs/CHANGELOG marking the socket live; all shipped presets already carry
git, all themes already declare[git_clean]/[git_dirty]— no format change needed, lean documented as the showcase preset).Validation
cargo fmt --check --all: clean.RUSTFLAGS=-D warnings cargo check -p niubash-runtime --all-targets: clean.RUSTFLAGS=-D warnings cargo check -p niubash-runtime --target x86_64-unknown-linux-gnu: clean (unix acceptance line).cargo test -p niubash-runtime --lib: 516 passed, 0 failed (includes the 8 git_prompt tests and 25 prompt_segments tests — 12 new/updated for Vcs).cargo clippy -D warningsis noisy from clippy 1.99 crate-wide drift (96 pre-existing hits, CI has no clippy gate); the only hit in touched files is pre-existing untouched code (prompt_segments.rsrender_right.map(|s| style_segment(s))).