Repository navigation
feat(shortcuts): WT-form desktop/Start-menu links on Win10 (niubash#211) - #290
Merged
Merged
Conversation
Win10 has no default-terminal setting, so direct-exe shortcuts are hosted
by conhost. When a wt.exe resolves AND the Niubash WT profile is
registered, generated shortcuts take the wt.exe -p Niubash form; without
WT the conhost baseline is kept unchanged.
- shortcut.rs: wt.exe resolution (WindowsApps alias -> PATH -> App Paths
registry HKCU/HKLM), pure plan construction, and .lnk write/read through
the shell-link COM object (vtables hand-declared: windows-sys 0.59 has
no interface types; SetPath is the interface's LAST method, verified
against shobjidl_core.h).
- niu --install-wt-shortcuts [--update-only] [--desktop|--start-menu]:
installer handoff passes {autodesktop}/{group} explicitly and only
rewrites links that already exist, so a declined desktop icon is never
grown; standalone runs create both in known folders.
- niubash.iss: desktopicon task (default on) plus a post-install rewrite
step gated on the wtprofile task; same link paths keep Inno's uninstall
log authoritative.
- windows_terminal.rs: expose NIU_PROFILE_NAME and the profile-registered
probe that gates the WT form.
Tests: resolution-order matrix, plan/conhost/WT-form parameter asserts,
multi-settings profile-registration matrix, and a COM round-trip that
writes .lnk files and reads them back through the same vtables. Real
installer smoke is a release-checklist item (PR body); the verb was
smoked against this machine's real WT Preview alias.
…ndtrip path asserts The CI cross-check lanes caught install_shortcuts calling the #[cfg(windows)] write_shortcut on unix targets (E0425); the verb entry in main.rs is already Windows-gated, so the lib function gets the same gate. The COM roundtrip asserts now compare canonicalized paths — the shell link resolves SetPath inputs to long form, so a target staged under an 8.3 short-name temp dir (CI RUNNER~1) read back runneradmin and tripped exact-match equality.
…dows The unix acceptance lanes caught leftover non-Windows orphans: the Context/Result imports and the top-level wide-string helpers serve only the Windows COM paths, so they carry the same cfg gate (the function-scoped registry helper keeps its own inner to_wide).
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.
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 #211
Completes the remaining implementable scope of #211 (the WT profile auto-registration half already landed on master via
windows_terminal.rs+ thewtprofileinstaller task). Owner direction from the issue thread: default to the WT form; conhost stays the fallback; other terminals stay out of scope.What changed
1.
wt.exeresolution, robust order (issue point 3) —crates/niubash-runtime/src/shortcut.rs::resolve_wt_exe%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe— stable and Preview share this alias and the OS hands it to whichever install won, so resolving the alias file itself sidesteps the preemption question entirely;PATH(scoop/choco/unpackaged installs);App Paths\wt.exeregistry default value, HKCU then HKLM (expand-string aware).2. Shortcut form branch —
ShortcutPlan::build/wt_form_eligiblewt.exe, arguments-p Niubash, working dir%USERPROFILE%, Niubash icon (bundled.ico, falling back to the niu.exe embedded icon — a.lnkcan't use the profile's PNG). Eligibility needs both a resolvedwt.exeand the registered profile (wt -pagainst an unknown profile errors out), via the newwindows_terminal::niubash_profile_registeredprobe.niu.exe, byte-for-byte the shape the installer always made — machines without WT (or with the profile task skipped) keep the status quo.3. New verb
niu --install-wt-shortcuts[\--quiet\] [\--update-only\] [\--desktop <dir>\] [\--start-menu <dir>\]The installer passes
{autodesktop}/{group}explicitly (no Known-Folder guessing on the Rust side);--update-onlyrewrites only links that already exist, so a declined desktop-icon task never grows a desktop icon. Standalone runs create both links in known folders. The links keep the exact installer paths (...\Niubash.lnk), so Inno's uninstall log stays authoritative after the in-place rewrite.4.
installer/niubash.iss— newdesktopicontask (default checked, per owner's WT-default direction); post-install step runs--install-wt-shortcuts --quiet --update-onlygated on the existingwtprofiletask, after the profile lands.Implementation note (COM)
windows-sys 0.59 carries COM free functions but no interface types, so
IShellLinkW/IPersistFilevtables are hand-declared in SDK order. Verified againstshobjidl_core.h:IShellLinkW::SetPathis the interface's LAST method (afterResolve) — the common interop listings that show it second are wrong, and that slot silently hitsGetIDList(returnsS_FALSE, sets nothing). The round-trip test pins the whole call set.Test matrix
resolve_prefers_windowsapps_alias_over_path_and_registryNoneresolve_falls_back_to_path_then_registry,resolve_returns_none_when_all_missingwt.exe -p Niubash+ home workdir + icoplan_uses_wt_form_when_wt_resolvedplan_keeps_conhost_form_without_wtprofile_registered_gate_matches_wt_form_eligibility,windows_terminal::profile_registration_detected_in_any_candidate.lnkparameters (target/args/icon/workdir) survive a real write+read via shell-link COMtests/wt_shortcut_roundtrip.rs(3 tests, exercised on this machine)install_shortcuts_updates_existing_and_skips_absent_linksVerification:
cargo fmt --check --allclean;cargo test -p niubash-runtime --lockedfully green (471 lib + 20 integration incl. the 3 new round-trip tests); root non-ConPTY integration green except two pre-existing, environment-reproducible failures on pristineorigin/masterin this environment (tests/repl_command.rs::command_mode_compound_commands_keep_home_paths_native—cd ~prints POSIX-stylePWD=/c/...withHOME=""under this shell profile — and the ConPTYissue182interactive test, which is out of this PR's non-ConPTY scope). Both reproduce byte-identically without this branch's changes; not regressions.Real smoke (this machine, not CI)
niu --install-wt-shortcutswas run against this machine's real WT Preview install (issue author's environment): both links written, and verified through the Windows shell COM independently —TargetPath = C:\Users\cmx\AppData\Local\Microsoft\WindowsApps\wt.exe,Arguments = -p Niubash,WorkingDirectory = C:\Users\cmx.Release checklist (real installer smoke — deferred per plan)
wt.exe -p Niubash; double-click opens the Niubash WT profile with Nerd Font rendering, CWD%USERPROFILE%(not System32).desktopicontask unchecked → no desktop link appears (update-only must not grow one).niu.execonhost form; launching works.