fix(web): stabilize slash autocomplete in new sessions#246
Closed
jlovec wants to merge 2 commits into
Closed
Conversation
Ensure slash command suggestions refresh when entering slash context in newly opened sessions. Add per-session+agent command caching safeguards, deduped merge logic, and regression tests to prevent stale or missing autocomplete results.
3b520e4 to
63f0d64
Compare
| cooldownMs: number = SLASH_ENTRY_COOLDOWN_MS | ||
| ): boolean { | ||
| if (!state.hasFetchedSuccessfully || state.lastFetchError !== null) { | ||
| return true |
There was a problem hiding this comment.
[MAJOR] Refetch loop on slash entry after failures
Why this is a problem: HappyComposer triggers onSlashEntry when a fetch settles while still in slash context, and shouldAttemptSlashEntryRefetch returns true whenever an error exists. A failed refetch therefore immediately re-triggers another refetch with no cooldown, which can hammer RPC and keep the UI in a fetch loop when the backend is down.
Suggested fix:
export function shouldAttemptSlashEntryRefetch(
state: SlashFetchState,
now: number,
cooldownMs: number = SLASH_ENTRY_COOLDOWN_MS
): boolean {
if (state.lastFetchError !== null) {
return now - state.lastEntryRefetchAt >= cooldownMs
}
if (!state.hasFetchedSuccessfully) {
return true
}
return now - state.lastEntryRefetchAt >= cooldownMs
}
Contributor
Author
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.
Summary
Test plan
/in a newly opened session can recover after initial fetch failure