Skip to content

Commit ab647ee

Browse files
committed
🤖 fix: ask for fresh skills on every caret update inside a skill token
1 parent 9a9d271 commit ab647ee

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

‎src/browser/features/ChatInput/useComposerSuggestions.ts‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { EXPERIMENT_IDS } from "@/common/constants/experiments";
77
import { getPendingDraftSkillDiscoveryKey } from "@/common/constants/storage";
88
import {
99
getAgentSkillsStore,
10-
getDiscoveryKey,
1110
useAgentSkills,
1211
type AgentSkillsDiscovery,
1312
} from "@/browser/stores/AgentSkillsStore";
@@ -210,7 +209,6 @@ export function useComposerSuggestions(options: UseComposerSuggestionsOptions) {
210209
const mcpLoadedAt = useRef(0);
211210
const mcpWorkspace = useRef<string | null>(null);
212211
const mcpAbort = useRef<AbortController | null>(null);
213-
const freshSkillTokenKey = useRef("");
214212
const listId = useId();
215213
const skillDiscovery: AgentSkillsDiscovery | null =
216214
variant === "workspace" && workspaceId
@@ -447,19 +445,15 @@ export function useComposerSuggestions(options: UseComposerSuggestionsOptions) {
447445

448446
const updateCaret = (nextInput: string, nextCursor: number) => {
449447
setCaretState({ input: nextInput, cursor: nextCursor });
450-
// Starting a `$` or `/` token asks again for a skill list that missed a
451-
// source, e.g. an SSH host that was still connecting. Once per token,
452-
// tracked here rather than from the rendered token, so a token that a
453-
// draft restore put in place still asks when the user types in it.
448+
// While the caret is in a `$` or `/` token, ask again for a skill list that
449+
// missed a source, e.g. an SSH host that was still connecting. This keeps
450+
// no per-token memory, so draft restores, sends and clears cannot leave it
451+
// stale. The store makes this a no-op for a complete list and keeps at most
452+
// one request per list in flight.
454453
const nextToken = detectActiveComposerToken(nextInput, nextCursor);
455-
const nextSkillTokenKey =
456-
skillDiscovery && (nextToken?.kind === "slash" || nextToken?.kind === "inline")
457-
? `${getDiscoveryKey(skillDiscovery)}|${nextToken.kind}:${nextToken.startIndex}`
458-
: "";
459-
if (skillDiscovery && nextSkillTokenKey && nextSkillTokenKey !== freshSkillTokenKey.current) {
454+
if (skillDiscovery && (nextToken?.kind === "slash" || nextToken?.kind === "inline")) {
460455
getAgentSkillsStore().ensureFresh(skillDiscovery);
461456
}
462-
freshSkillTokenKey.current = nextSkillTokenKey;
463457
};
464458

465459
const handleCursorActivity = () => {

‎src/browser/stores/AgentSkillsStore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface Entry {
2323
stale: boolean;
2424
}
2525

26-
export function getDiscoveryKey(discovery: AgentSkillsDiscovery): string {
26+
function getDiscoveryKey(discovery: AgentSkillsDiscovery): string {
2727
return "projectPath" in discovery
2828
? `project:${discovery.projectPath}`
2929
: `ws:${discovery.workspaceId}:${String(discovery.disableWorkspaceAgents)}`;

0 commit comments

Comments
 (0)