@@ -263,6 +263,101 @@ describe("SkillsSettings", () => {
263263 expect ( warning ) . toHaveTextContent ( "found character that cannot start any token" )
264264 } )
265265
266+ it ( "shows diagnostics that arrive after the settings view is already mounted" , ( ) => {
267+ const view = renderSkillsSettings ( mockSkills , undefined , [ ] )
268+
269+ expect ( screen . queryByRole ( "alert" ) ) . not . toBeInTheDocument ( )
270+
271+ // The extension pushes a fresh diagnostics list through the extension state while the view stays
272+ // mounted. The memoized list has to follow that value, or the warning freezes at first render.
273+ mockExtensionState = {
274+ ...mockExtensionState ,
275+ skillDiagnostics : [
276+ {
277+ path : "/workspace/.roo/skills/late/SKILL.md" ,
278+ source : "project" ,
279+ message : "bad indentation of a mapping entry" ,
280+ line : 4 ,
281+ column : 9 ,
282+ } ,
283+ ] ,
284+ }
285+ view . rerender ( < SkillsSettings /> )
286+
287+ const warning = screen . getByRole ( "alert" )
288+ expect ( warning . querySelector ( "span" ) ?. textContent ) . toBe ( "/workspace/.roo/skills/late/SKILL.md:4:9" )
289+ expect ( warning ) . toHaveTextContent ( "bad indentation of a mapping entry" )
290+ } )
291+
292+ it ( "keeps each diagnostic row in its own element when the diagnostics list is reordered" , ( ) => {
293+ const view = renderSkillsSettings ( mockSkills , undefined , [
294+ {
295+ path : "/workspace/.roo/skills/broken-2/SKILL.md" ,
296+ source : "project" ,
297+ message : "unexpected end of the stream" ,
298+ } ,
299+ {
300+ path : "/workspace/.roo/skills/broken-3/SKILL.md" ,
301+ source : "project" ,
302+ message : "bad indentation of a mapping entry" ,
303+ line : 7 ,
304+ } ,
305+ {
306+ path : "/workspace/.roo/skills/broken-4/SKILL.md" ,
307+ source : "project" ,
308+ message : "found character that cannot start any token" ,
309+ line : 12 ,
310+ column : 3 ,
311+ } ,
312+ ] )
313+
314+ const created = Array . from ( screen . getByRole ( "alert" ) . querySelectorAll ( "li" ) )
315+ // Every row is keyed by the diagnostic it reports, so a reordered list must reuse the element the
316+ // row was created in. Position-matched rows move row-local state and selection away from the
317+ // diagnostic the reader is looking at.
318+ created . forEach ( ( row , index ) => {
319+ row . dataset . initialPosition = String ( index )
320+ } )
321+ expect ( created . map ( ( row ) => row . querySelector ( "span" ) ?. textContent ) ) . toEqual ( [
322+ "/workspace/.roo/skills/broken-2/SKILL.md" ,
323+ "/workspace/.roo/skills/broken-3/SKILL.md:7" ,
324+ "/workspace/.roo/skills/broken-4/SKILL.md:12:3" ,
325+ ] )
326+
327+ mockExtensionState = {
328+ ...mockExtensionState ,
329+ skillDiagnostics : [
330+ {
331+ path : "/workspace/.roo/skills/broken-4/SKILL.md" ,
332+ source : "project" ,
333+ message : "found character that cannot start any token" ,
334+ line : 12 ,
335+ column : 3 ,
336+ } ,
337+ {
338+ path : "/workspace/.roo/skills/broken-3/SKILL.md" ,
339+ source : "project" ,
340+ message : "bad indentation of a mapping entry" ,
341+ line : 7 ,
342+ } ,
343+ {
344+ path : "/workspace/.roo/skills/broken-2/SKILL.md" ,
345+ source : "project" ,
346+ message : "unexpected end of the stream" ,
347+ } ,
348+ ] ,
349+ }
350+ view . rerender ( < SkillsSettings /> )
351+
352+ const reordered = Array . from ( screen . getByRole ( "alert" ) . querySelectorAll ( "li" ) )
353+ expect ( reordered . map ( ( row ) => row . querySelector ( "span" ) ?. textContent ) ) . toEqual ( [
354+ "/workspace/.roo/skills/broken-4/SKILL.md:12:3" ,
355+ "/workspace/.roo/skills/broken-3/SKILL.md:7" ,
356+ "/workspace/.roo/skills/broken-2/SKILL.md" ,
357+ ] )
358+ expect ( reordered . map ( ( row ) => row . dataset . initialPosition ) ) . toEqual ( [ "2" , "1" , "0" ] )
359+ } )
360+
266361 it ( "displays project skills section when in a workspace" , ( ) => {
267362 renderSkillsSettings ( )
268363
0 commit comments