Repository navigation
async prompt updating - #18660
async prompt updating#18660
Conversation
1f3cfac to
18a4a5d
Compare
|
Hey, just a bot checking in! You edited files related to the configuration. |
Requires nushell/reedline#1136 Related PR (Builds ontop of): #18660 ## Description This is a follow-up to #18334 (non-blocking completions, merged) and #18671 (test-infra sync, merged). Those landed the async worker model (`CompletionResult` Fresh/Stale/Pending) but left... several issues unresolved. Sorry to all the folks who put up with that on the nightlies :( Overarching changes: - Across prompts we're using a LRU cache for storing and managing the caches. This is configurable, and default bounded to 100. For many completions nothing is loaded onto the LRU cache, only the intensive operations (git checkout, carapace stuff, etc.). Open to dramatically reducing this number, but it *sure* feels nice when it works. - Cache work is a lot more robust, we do narrowing and carry always an "env" for the completor environment, so we have a *rough* idea of when to complete for the sources that are mostly pure. - Added completionengine for the death of hardcoded dispatch with a routing enum. This allowed me to rewrite the completor trait around the context and fetched types, wiring a lot more logic directly through it. - Added completionsite and sitekind models for a catch-all way for resolving the facts of what is under the cursor, which kills maybe fifty sites of span math (what caused the super annoying completion duplication) - *commandline complete --type` now type-checks its argument (previously accepted any string and could silently no-op) and clamps the cursor to a valid boundary instead of indexing out of range. - complete paths is shared between file and directory completions, which eliminates a panic risk and more manual span constructions. - - **Flag/span plumbing.** `FlagRef` and `Flag::long_name` are adopted across `nu-parser`/`nu-engine`/`nu-cmd-lang` so flag identity survives through parsing and into completion and help-text rendering, which eliminated a lot of re-derive logic. ## User-facing changes (Release notes) - Added `$env.config.completions.cache_size` (default: `100`) to control that cap. - Completion results now persist across prompts instead of being discarded on every new prompt,. - Fixed a potential panic when narrowing file/directory completions on a path containing multi-byte (non-ASCII) characters. - `commandline complete --type` now validates its `--type` argument and no longer panics on an out-of-range cursor. - `use`, `overlay use`, `export use`, `source-env`, `hide-env`, `attr complete`, and `which` now go through the same completion dispatch as other builtins, fixing inconsistent/missing completions in a few of them ## Additional Notes - Can't promise that this eliminates all bugs, just most of them. The bigger thing it gives us is a more robust framework to fix bugs, going forward. Will be responsive to anything related to completions, and am okay with a longer review period before merge. The big things are covered now, however, with the added tests in this PR. - fixes #11211 --------- Co-authored-by: Darren Schroeder <[email protected]>
e5752c3 to
2242316
Compare
|
@fdncred This is now unblocked! |
|
@philocalyst not quite. ci is still angry. |
|
Fixed it up, one moment :) |
|
ay there :) |
|
I wonder if all the prompts should be included? Maybe some can't be? Here's the list. I think it's complete?
|
|
The other thing that concerns me about this PR is how it affects OSC133, if at all. I worked on that for a week or so to get right and I don't want to break it and have to figure out how to fix it. We need to keep the semantic prompt working nushell/reedline#1019. I'll try to test with ghostty when the CI is green. |
commented
Aug 3, 2026
|
Let me check, didn't know about that. |
commented
Aug 3, 2026
|
It does look like it's okay with semantic prompts, at least under my testing |
commented
Aug 3, 2026
|
And I'm adding dynmism to the VI indicators, it's not very diffuclt yay |
commented
Aug 3, 2026
|
Okay, so as of now, everything is configurable, including multiline |
715246e to
d98420b
Compare
|
It would be good to include an example using Also, You might have missed my comment here #18660 (comment) |
commented
Aug 3, 2026
|
Everything should be at least responded to |
commented
Aug 3, 2026
|
One thing I will add is that I saw some changes will add a visual mode. I don't know if more modes will come, but right now these changes are sort of out of sync with those modes being added. |
- emacs back to indicator - attached associated env vars
fbe1e02 to
64d1933
Compare
commented
Aug 4, 2026
|
Resolved :) |
commented
Aug 4, 2026
|
not quite |
6525f2e to
2d26954
Compare
commented
Aug 4, 2026
|
Well, it's mostly green but reverting shell_integration.rs after piepmatz just updated those tests probably isn't ideal. https://github.com/nushell/nushell/pull/18776/changes#diff-75255f62eeca5ecfd74c9e5e5a3b44d2abd71e6cc9b3905f5a3b79e10caeb89e |
commented
Aug 4, 2026
|
oh... |
commented
Aug 4, 2026
|
Yeah, I don't think it's reverted? I mean it's different because I changed the signature, but it all checks out to me, what exactly was reverted? |
commented
Aug 4, 2026
|
Did you look at this PR https://github.com/nushell/nushell/pull/18776/changes#diff-75255f62eeca5ecfd74c9e5e5a3b44d2abd71e6cc9b3905f5a3b79e10caeb89e, specifically shell_integration.rs? It looks like he removed create_test_engine() and you added it back amongst other things. |
2d26954 to
41ffcde
Compare
commented
Aug 4, 2026
|
Ahhh great, they actually caught a bug, too! initially assumed that was a fault of the rebase so accidentally removed some of your changes, my fault @cptpiepmatz :) |
commented
Aug 4, 2026
commented
Aug 4, 2026
|
Good! Yeah I didn't change the output mechanism, just how nu handles state and updates |
|
We need to take a look at performance next. This is the feeback we got. Any ideas @philocalyst ?
|
commented
Aug 5, 2026
|
Landing because we can work on performance separately. |
commented
Aug 5, 2026
Hm, didn't notice this, but I'm back on a fancy laptop; actually very interesting, if there are any performance cliffs you would still expect them to be small enough to be imperceptible (not that it's okay)... |
commented
Aug 5, 2026
|
Let's wait for a repro from Jan |

Description
I added support for async/streaming prompts. Background jobs now have the capabilitiy of pushing segments of the prompt to a live state in an in-place fashion. This will not disturb the line being edited.
The interactive prompt resided fully as owned state within the REPL loop. This prevented interaction with components who lived outside of that loop. I reworked this configuration to be built around a separate state mechanism --
PromptState-- which all prompt updates flow through in a thread-safe way. EngineState now owns it, encapsulated in an arc shared between jobs. Leaving NushellPrompt as a READ-ONLY view, rendering the current state of it on every redraw.Upon new prompt, PROMPT_COMMAND is re-evaled (rather than keeping the pushed/edited async state, which I'm open to alternative approaches on).
The actual prompt is interacted with through
commandline set-promptthat takes these parts (left/right/indicator) as flag arguments, and pushes them as overrides. This keeps PROMPT_COMMAND in place as the fallback/static mechanism, and effectively acts as the "ad-hoc" path. I purposefully didn't include things like vim or completion indicators, but those would be trivial to add.User-facing changes (Release notes)
Added
commandline set-promptfor async prompt updatescommandline set-promptcommand for ad-hoc updates to a rendered prompt.Examples:
Stand-in values, with background job spawn:
Additional notes
closes #18613