Skip to content

fix(web): stabilize slash autocomplete in new sessions#246

Closed
jlovec wants to merge 2 commits into
tiann:mainfrom
jlovec:feat/project-slash-command
Closed

fix(web): stabilize slash autocomplete in new sessions#246
jlovec wants to merge 2 commits into
tiann:mainfrom
jlovec:feat/project-slash-command

Conversation

@jlovec
Copy link
Copy Markdown
Contributor

@jlovec jlovec commented Mar 5, 2026

Summary

  • Fix slash autocomplete race in newly opened sessions where initial remote command fetch may fail
  • Add slash-context compensation trigger so recovery does not rely on leaving/re-entering slash mode
  • Keep in-flight dedupe and cooldown protections to avoid refetch storms
  • Scope slash command cache key by sessionId + agentType
  • Add tests for merge filtering and cooldown boundary behavior in useSlashCommands

Test plan

  • bun run --cwd web test
  • bun run --cwd web typecheck
  • Manual: verify first / in a newly opened session can recover after initial fetch failure
  • Manual: verify slash suggestions remain stable across session/flavor switches

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.
@jlovec jlovec force-pushed the feat/project-slash-command branch from 3b520e4 to 63f0d64 Compare March 5, 2026 12:12
cooldownMs: number = SLASH_ENTRY_COOLDOWN_MS
): boolean {
if (!state.hasFetchedSuccessfully || state.lastFetchError !== null) {
return true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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
}

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Findings

  • [MAJOR] Refetch loop on slash entry after failures can hammer RPC when backend is down (web/src/components/AssistantChat/HappyComposer.tsx:157, web/src/hooks/queries/useSlashCommands.ts:120)

Testing

  • Not run (automation)

@jlovec
Copy link
Copy Markdown
Contributor Author

jlovec commented Mar 6, 2026

按功能拆分后已由新 PR 承接:#255(Web 斜杠自动补全)与 #254(spawn 稳定性修复)。为保持审查范围清晰,此 PR 关闭。

@jlovec jlovec closed this Mar 6, 2026
@jlovec jlovec deleted the feat/project-slash-command branch March 8, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant