Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

nes: fix: use speculativeRequestDelay for cached speculative results#4985

Merged
ulugbekna merged 2 commits into
mainfrom
ulugbekna/cooing-tiger
Apr 5, 2026
Merged

nes: fix: use speculativeRequestDelay for cached speculative results#4985
ulugbekna merged 2 commits into
mainfrom
ulugbekna/cooing-tiger

Conversation

@ulugbekna

Copy link
Copy Markdown
Contributor

When a speculative request completes and caches its result before the user accepts, the subsequent getNextEdit() takes the cache path. In this path, isFromSpeculativeRequest was not being set from the cached edit's source, causing computeMinimumResponseDelay to apply the normal cacheDelay instead of the speculative-specific speculativeRequestDelay.

Set isFromSpeculativeRequest from cachedEdit.source.isSpeculative in the cache path so that cached speculative results use the correct (typically 0ms) delay.

When a speculative request completes and its result is cached before the
user accepts, the subsequent getNextEdit() takes the cache path where
isFromSpeculativeRequest stays false. This causes computeMinimumResponseDelay
to use the normal cacheDelay instead of the speculative-specific
speculativeRequestDelay (typically 0ms).

The test sets cacheDelay=5000ms and speculativeRequestDelay=0ms, then
verifies that a cached speculative result returns fast. Currently it
times out at 5000ms, confirming the bug.
When a speculative request completes and caches its result before the
user accepts, the subsequent getNextEdit() takes the cache path. In
this path, isFromSpeculativeRequest was not being set from the cached
edit's source, causing computeMinimumResponseDelay to apply the normal
cacheDelay instead of the speculative-specific speculativeRequestDelay.

Set isFromSpeculativeRequest from cachedEdit.source.isSpeculative in
the cache path so that cached speculative results use the correct
(typically 0ms) delay.
@ulugbekna ulugbekna enabled auto-merge April 5, 2026 19:08
@ulugbekna ulugbekna self-assigned this Apr 5, 2026
Copilot AI review requested due to automatic review settings April 5, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes NES minimum-response-delay selection for cached results that originally came from speculative requests, so cached speculative suggestions use InlineEditsSpeculativeRequestDelay (typically 0ms) instead of the normal InlineEditsCacheDelay.

Changes:

  • Set isFromSpeculativeRequest from cachedEdit.source.isSpeculative in the cached-edit path so computeMinimumResponseDelay() selects the correct delay bucket.
  • Add a regression test ensuring cached speculative results honor speculativeRequestDelay even when enforceCacheDelay=true.
Show a summary per file
File Description
src/extension/inlineEdits/node/nextEditProvider.ts Propagates speculative-origin metadata when serving from cache so delay computation uses the speculative-specific delay.
src/extension/inlineEdits/test/node/nextEditProviderSpeculative.spec.ts Adds coverage for the “speculative completed → cached → served from cache” path to prevent regressions.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@ulugbekna ulugbekna added this pull request to the merge queue Apr 5, 2026
Merged via the queue into main with commit b6d44c3 Apr 5, 2026
23 checks passed
@ulugbekna ulugbekna deleted the ulugbekna/cooing-tiger branch April 5, 2026 19:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants