@@ -7,6 +7,7 @@ import { EXPERIMENT_IDS } from "@/common/constants/experiments";
77import { getPendingDraftSkillDiscoveryKey } from "@/common/constants/storage" ;
88import {
99 getAgentSkillsStore ,
10+ getDiscoveryKey ,
1011 useAgentSkills ,
1112 type AgentSkillsDiscovery ,
1213} from "@/browser/stores/AgentSkillsStore" ;
@@ -209,6 +210,7 @@ export function useComposerSuggestions(options: UseComposerSuggestionsOptions) {
209210 const mcpLoadedAt = useRef ( 0 ) ;
210211 const mcpWorkspace = useRef < string | null > ( null ) ;
211212 const mcpAbort = useRef < AbortController | null > ( null ) ;
213+ const freshSkillTokenKey = useRef ( "" ) ;
212214 const listId = useId ( ) ;
213215 const skillDiscovery : AgentSkillsDiscovery | null =
214216 variant === "workspace" && workspaceId
@@ -446,15 +448,18 @@ export function useComposerSuggestions(options: UseComposerSuggestionsOptions) {
446448 const updateCaret = ( nextInput : string , nextCursor : number ) => {
447449 setCaretState ( { input : nextInput , cursor : nextCursor } ) ;
448450 // Starting a `$` or `/` token asks again for a skill list that missed a
449- // source, e.g. an SSH host that was still connecting. Once per token.
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.
450454 const nextToken = detectActiveComposerToken ( nextInput , nextCursor ) ;
451- if (
452- skillDiscovery &&
453- ( nextToken ?. kind === "slash" || nextToken ? .kind === "inline" ) &&
454- ` ${ nextToken . kind } : ${ nextToken . startIndex } ` !== activeChannelKey
455- ) {
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 ) {
456460 getAgentSkillsStore ( ) . ensureFresh ( skillDiscovery ) ;
457461 }
462+ freshSkillTokenKey . current = nextSkillTokenKey ;
458463 } ;
459464
460465 const handleCursorActivity = ( ) => {
0 commit comments