fix(dashboard): skill-menu highlight survives identity-only skills revalidation
Root cause of the recurring ChatView skill-menu CI flakes (and a real UX bug): the highlight-reset effect keyed on filteredSkills array identity, but useDiscoveredSkillsCache (SWR) re-delivers content-identical lists with fresh identities — cache reads re-parse JSON and revalidation notifies a new array. A revalidation landing between a user's (or the test's) arrow-key press and the next frame wiped the highlight back to 0. Key the reset on the joined skill-id list instead, so only a semantic list change resets the keyboard position. Regression test proves the invariant: deferred revalidation with identical content lands mid- navigation and the highlight persists (fails on the old identity-keyed reset in all three vitest projects). This test family needed three prior stabilization passes (FN-5864, FN-5745, FN-5725) — this addresses the underlying race rather than the assertions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1239,9 +1239,18 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
|
||||
return byName;
|
||||
}, [mentionAgents]);
|
||||
|
||||
// Key the reset on skill ids, not array identity: useDiscoveredSkillsCache
|
||||
// (SWR) re-delivers content-identical lists with fresh identities (cache
|
||||
// reads re-parse; revalidation notifies a new array). Resetting on identity
|
||||
// alone wipes the user's keyboard highlight mid-navigation when a
|
||||
// revalidation lands — only a *semantic* list change should reset it.
|
||||
const filteredSkillsKey = useMemo(
|
||||
() => filteredSkills.map((skill) => skill.id).join(" | ||||