fix(web): clear removed skill mention picker state (#6920)

Co-authored-by: T-sanjay-ram <sanjayramctr07@gmail.com>
This commit is contained in:
T Sanjay Ram
2026-08-18 06:48:37 +00:00
committed by GitHub
co-authored by T-sanjay-ram
parent 38c1d11a6f
commit 322ed407fa
2 changed files with 26 additions and 7 deletions
+6 -6
View File
@@ -3118,7 +3118,7 @@ export const ChatComposer = forwardRef<ChatComposerHandle, Props>(
setMentionIndex(0);
}}
activeIndex={mentionIndex}
currentSkillId={currentSkillId}
stagedSkillIds={new Set(stagedSkills.map((skill) => skill.id))}
onPickFile={insertMention}
onPickWorkspaceContext={insertWorkspaceMention}
onPickPlugin={(record) => void insertPluginMention(record)}
@@ -5674,7 +5674,7 @@ function MentionPopover({
tab,
onTabChange,
activeIndex,
currentSkillId,
stagedSkillIds,
onPickFile,
onPickWorkspaceContext,
onPickPlugin,
@@ -5692,7 +5692,7 @@ function MentionPopover({
tab: MentionTab;
onTabChange: (tab: MentionTab) => void;
activeIndex: number;
currentSkillId: string | null;
stagedSkillIds: Set<string>;
onPickFile: (path: string) => void;
onPickWorkspaceContext: (item: WorkspaceContextItem) => void;
onPickPlugin: (record: InstalledPluginRecord) => void;
@@ -5862,7 +5862,7 @@ function MentionPopover({
const flat = optionIndex;
optionIndex += 1;
const rowActive = flat === activeIndex;
const isCurrent = skill.id === currentSkillId;
const isStaged = stagedSkillIds.has(skill.id);
return (
<button
key={`skill-${skill.id}`}
@@ -5875,14 +5875,14 @@ function MentionPopover({
onClick={() => onPickSkill(skill)}
title={localizeSkillDescription(locale, skill)}
>
<Icon name={isCurrent ? 'check' : 'file'} size={12} />
<Icon name={isStaged ? 'check' : 'file'} size={12} />
<span className="mention-item-body">
<strong>{localizeSkillName(locale, skill)}</strong>
<span className="mention-meta mention-meta--desc">
{localizeSkillDescription(locale, skill) || skill.id}
</span>
</span>
<span className="mention-meta mention-item-kind">{isCurrent ? t('chat.mentionActiveSkill') : skill.mode}</span>
<span className="mention-meta mention-item-kind">{isStaged ? t('chat.mentionActiveSkill') : skill.mode}</span>
</button>
);
})}
@@ -18,7 +18,7 @@ import { ChatComposer, type ChatComposerHandle } from '../../src/components/Chat
import { I18nProvider } from '../../src/i18n';
import type { Locale } from '../../src/i18n/types';
import type { AppliedPluginSnapshot, ProjectMetadata } from '@open-design/contracts';
import { composerText, pressEnter, typeAndSettle } from '../helpers/lexical-composer';
import { composerText, pressEnter, typeAndSettle, typeInComposer } from '../helpers/lexical-composer';
const COMMUNITY_PLUGIN = {
id: 'community-deck',
@@ -1048,6 +1048,25 @@ describe('ChatComposer context pickers', () => {
expect(screen.queryByTestId('staged-contexts')).toBeNull();
});
it('does not keep a removed @ skill marked active when the mention picker reopens', async () => {
renderComposer({ currentSkillId: 'deck-builder' });
await flushMounts();
await typeAndSettle('@deck');
await waitFor(() => expect(screen.getByText('Deck Builder')).toBeTruthy());
fireEvent.click(screen.getByText('Deck Builder'));
await waitFor(() => expect(composerText()).toBe('@Deck Builder '));
typeInComposer('');
await waitFor(() => expect(screen.queryByTestId('staged-contexts')).toBeNull());
await typeAndSettle('@deck');
const picker = await screen.findByTestId('mention-popover');
const skill = within(picker).getByRole('option', { name: /Deck Builder/ });
expect(skill.textContent).not.toContain('Active');
});
it('shows all matching skills and ranks exact prefix matches first', async () => {
skills = [
makeSkill({