Skip to content

Commit 994592b

Browse files
committed
🤖 fix: a restored skill token still asks for fresh skills when typed in
1 parent de69088 commit 994592b

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { EXPERIMENT_IDS } from "@/common/constants/experiments";
77
import { getPendingDraftSkillDiscoveryKey } from "@/common/constants/storage";
88
import {
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 = () => {

‎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-
function getDiscoveryKey(discovery: AgentSkillsDiscovery): string {
26+
export 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)