review this PR: https://github.com/JanDeDobbeleer/oh-my-posh/pull/7369
- User
review this PR: https://github.com/JanDeDobbeleer/oh-my-posh/pull/7369
Assistant
review this PR: https://github.com/JanDeDobbeleer/oh-my-posh/pull/7369
Adds a .Interrupted template flag so a transient_prompt template can distinguish a Ctrl-C-interrupted command from one that ran and failed. Implemented via:
--interrupted CLI flag (print.go) → runtime.Flags.InterruptedInterrupted bool field on cache.SimpleTemplatetemplate/cache.go populates it from flags on both the primary-build and cache-restore pathsomp.zsh detects a nonzero return from recursive-edit (existing convention for "was interrupted") and forces a CLI-rendered (not pre-rendered) transient prompt with --interruptedThe design (bypass the pre-rendered fast path only on interrupt) is sound and the trade-off is explicitly commented.
1. Interrupted is missing from routedEnvDataKeys — inconsistent with the file's own stated invariant (src/template/cache.go)
loadCache sets tmpl.Interrupted = env.Flags().Interrupted the same way it sets tmpl.Code, _ = env.StatusCodes(). But Code (and PWD, ExecutionTime, PipeStatus) are protected in routedEnvDataKeys specifically because, per the existing comment:
"routedEnvDataKeys are env-section keys the CLI layer already routes into runtime.Flags before Init runs... They must never be applied a second time here, or a raw file value could clobber that resolved value."
Interrupted is exactly this kind of CLI-flag-resolved field but isn't in the list, so overlayEnvData (used by the --data replay feature) can unmarshal an "Interrupted" key from a data file and silently overwrite the flag-derived value after it was set. It should be added to routedEnvDataKeys for consistency with the pattern the same file already establishes.
2. Docs imply cross-shell support that isn't implemented (website/docs/configuration/transient.mdx)
The page's intro banner states transient prompt "works in nu, fish, zsh, powershell... bash... and cmd," and the new .Interrupted section is added without any shell caveat — but only omp.zsh was wired to pass --interrupted. Users on fish/powershell/nu/bash will see .Interrupted always false even after a genuine Ctrl-C, which reads as a bug rather than a documented limitation. Worth a "currently zsh-only" note, or filing a fast-follow to wire the other shells (the PR title/description suggest this may be intentional incremental scope, given it builds on the zsh-only #7360).
3. No test coverage despite the PR checklist claiming tests were added
The diff touches cli/print.go, runtime/environment.go, cache/template.go, template/cache.go, and omp.zsh but adds no test changes. The PR checklist has "Tests for the changes have been added" checked — worth confirming with the author whether that's an oversight, since the loadCache/restoreCache interaction (point 1) is exactly the kind of subtle regression a unit test would catch.
zle .send-break comment (# TODO (fix): this is not equal to sending a SIGINT...) is pre-existing, unrelated to this PR.((ret)) branch reuses the shell's existing "nonzero exit from recursive-edit == interrupted" convention, consistent with the later if ((ret)); then zle .send-break; fi — good reuse, no new assumption introduced.Interrupted alongside WSL, Root, etc.).Low risk to existing behavior — the change is additive (new field, new flag, new branch gated on ret), and the fast-path/perf trade-off is deliberate and well-commented. The main actionable item is #1 (data-overlay clobber), which is a real correctness gap matching a pattern the codebase already guards against elsewhere.
Not yet included in a published release.