[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BTF2Z1G4BT3V7C27J5PQKP":3,"skill-same:01M7BTF2Z1G4BT3V7C27J5PQKP":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BTF2Z1G4BT3V7C27J5PQKP","component-fixtures",null,"Use when creating or updating component fixtures for screenshot testing, or when designing UI components to be fixture-friendly. Covers fixture file structure, theming, service setup, CSS scoping, async rendering, and common pitfalls.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fcomponent-fixtures\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: component-fixtures\ndescription: Use when creating or updating component fixtures for screenshot testing, or when designing UI components to be fixture-friendly. Covers fixture file structure, theming, service setup, CSS scoping, async rendering, and common pitfalls.\n---\n\n# Component Fixtures\n\nComponent fixtures render isolated UI components for visual screenshot testing via the component explorer. Fixtures live in `src\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F` and are auto-discovered by the Vite dev server using the glob `src\u002F**\u002F*.fixture.ts`.\n\nUse tools `mcp_component-exp_`* to list and screenshot fixtures. If you cannot see these tools, inform the user to them on.\n\n## Running Fixtures Locally\n\n1. Start the component explorer server: run the **Component Explorer Server** task\n2. Use the `mcp_component-exp_list_fixtures` tool to see all available fixtures and their URLs\n3. Use the `mcp_component-exp_screenshot` tool to capture screenshots programmatically\n\n## File Structure\n\nEach fixture file exports a default `defineThemedFixtureGroup(...)`. The file must end with `.fixture.ts`.\n\n```\nsrc\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F\n  fixtureUtils.ts              # Shared helpers (DO NOT import @vscode\u002Fcomponent-explorer elsewhere)\n  myComponent.fixture.ts       # Your fixture file\n```\n\n## Basic Pattern\n\n```typescript\nimport { ComponentFixtureContext, createEditorServices, defineComponentFixture, defineThemedFixtureGroup } from '.\u002FfixtureUtils.js';\n\nexport default defineThemedFixtureGroup({ path: 'myFeature\u002F' }, {\n    Default: defineComponentFixture({ render: renderMyComponent }),\n    AnotherVariant: defineComponentFixture({ render: renderMyComponent }),\n});\n\nfunction renderMyComponent({ container, disposableStore, theme }: ComponentFixtureContext): void {\n    container.style.width = '400px';\n\n    const instantiationService = createEditorServices(disposableStore, {\n        colorTheme: theme,\n        additionalServices: (reg) => {\n            \u002F\u002F Register additional services the component needs\n            reg.define(IMyService, MyServiceImpl);\n            reg.defineInstance(IMockService, mockInstance);\n        },\n    });\n\n    const widget = disposableStore.add(\n        instantiationService.createInstance(MyWidget, \u002F* constructor args *\u002F)\n    );\n    container.appendChild(widget.domNode);\n}\n```\n\nKey points:\n- **`defineThemedFixtureGroup`** automatically creates Dark and Light variants for each fixture\n- **`defineComponentFixture`** wraps your render function with theme setup and shadow DOM isolation\n- **`createEditorServices`** provides a `TestInstantiationService` with base editor services pre-registered\n- Always register created widgets with `disposableStore.add(...)` to prevent leaks\n- Pass `colorTheme: theme` to `createEditorServices` so theme colors render correctly\n\n## Utilities from fixtureUtils.ts\n\n| Export | Purpose |\n|---|---|\n| `defineComponentFixture` | Creates Dark\u002FLight themed fixture variants from a render function |\n| `defineThemedFixtureGroup` | Groups multiple themed fixtures into a named fixture group |\n| `createEditorServices` | Creates `TestInstantiationService` with all base editor services |\n| `registerWorkbenchServices` | Registers additional workbench services (context menu, label, etc.) |\n| `createTextModel` | Creates a text model via `ModelService` for editor fixtures |\n| `setupTheme` | Applies theme CSS to a container (called automatically by `defineComponentFixture`) |\n| `darkTheme` \u002F `lightTheme` | Pre-loaded `ColorThemeData` instances |\n\n**Important:** Only `fixtureUtils.ts` may import from `@vscode\u002Fcomponent-explorer`. All fixture files must go through the helpers in `fixtureUtils.ts`.\n\n## CSS Scoping\n\nFixtures render inside shadow DOM. The component-explorer automatically adopts the global VS Code stylesheets and theme CSS.\n\n### Matching production CSS selectors\n\nMany VS Code components have CSS rules scoped to deep ancestor selectors (e.g., `.interactive-session .interactive-input-part > .widget-container .my-element`). In fixtures, you must recreate the required ancestor DOM structure for these selectors to match:\n\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    container.classList.add('interactive-session');\n\n    \u002F\u002F Recreate ancestor structure that CSS selectors expect\n    const inputPart = dom.$('.interactive-input-part');\n    const widgetContainer = dom.$('.widget-container');\n    inputPart.appendChild(widgetContainer);\n    container.appendChild(inputPart);\n\n    widgetContainer.appendChild(myWidget.domNode);\n}\n```\n\n**Design recommendation for new components:** Avoid deeply nested CSS selectors that require specific ancestor elements. Use self-contained class names (e.g., `.my-widget .my-element` rather than `.parent-view .parent-part > .wrapper .my-element`). This makes components easier to fixture and reuse.\n\n## Services\n\n### Using createEditorServices\n\n`createEditorServices` pre-registers these services: `IAccessibilityService`, `IKeybindingService`, `IClipboardService`, `IOpenerService`, `INotificationService`, `IDialogService`, `IUndoRedoService`, `ILanguageService`, `IConfigurationService`, `IStorageService`, `IThemeService`, `IModelService`, `ICodeEditorService`, `IContextKeyService`, `ICommandService`, `ITelemetryService`, `IHoverService`, `IUserInteractionService`, and more.\n\n### Additional services\n\nRegister extra services via `additionalServices`:\n\n```typescript\ncreateEditorServices(disposableStore, {\n    additionalServices: (reg) => {\n        \u002F\u002F Class-based (instantiated by DI):\n        reg.define(IMyService, MyServiceImpl);\n        \u002F\u002F Instance-based (pre-constructed):\n        reg.defineInstance(IMyService, myMockInstance);\n    },\n});\n```\n\n### Mocking services\n\nUse the `mock\u003CT>()` helper from `base\u002Ftest\u002Fcommon\u002Fmock.js` to create mock service instances:\n\n```typescript\nimport { mock } from '..\u002F..\u002F..\u002F..\u002Fbase\u002Ftest\u002Fcommon\u002Fmock.js';\n\nconst myService = new class extends mock\u003CIMyService>() {\n    override someMethod(): string { return 'test'; }\n    override onSomeEvent = Event.None;\n};\nreg.defineInstance(IMyService, myService);\n```\n\nFor mock view models or data objects:\n```typescript\nconst element = new class extends mock\u003CIChatRequestViewModel>() { }();\n```\n\n## Async Rendering\n\nThe component explorer waits **2 animation frames** after the synchronous render function returns. For most components, this is sufficient.\n\nIf your render function returns a `Promise`, the component explorer waits for the promise to resolve.\n\n### Pitfall: DOM reparenting causes flickering\n\nAvoid moving rendered widgets between DOM parents after initial render. This causes:\n- Layout recalculation (the widget jumps as `position: absolute` coordinates become invalid)\n- Focus loss (blur events can trigger hide logic in widgets like QuickInput)\n- Screenshot instability (the component explorer may capture an intermediate layout state)\n\n**Bad pattern — reparenting a widget after async wait:**\n```typescript\nasync function render({ container }: ComponentFixtureContext): Promise\u003Cvoid> {\n    const host = document.createElement('div');\n    container.appendChild(host);\n    \u002F\u002F ... create widget inside host ...\n    await waitForWidget();\n    container.appendChild(widget);  \u002F\u002F BAD: reparenting causes flicker\n    host.remove();\n}\n```\n\n**Better pattern — render in-place with the correct DOM structure from the start:**\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    \u002F\u002F Set up the correct DOM structure first, then create the widget inside it\n    const widget = createWidget(container);\n    container.appendChild(widget.domNode);\n}\n```\n\nIf the component absolutely requires async setup (e.g., QuickInput which renders internally), minimize DOM manipulation after the widget appears by structuring the host container to match the final layout from the beginning.\n\n## Adapting Existing Components for Fixtures\n\nExisting components often need small changes to become fixturable. When writing a fixture reveals friction, fix the component — don't work around it in the fixture. Common adaptations:\n\n### Decouple CSS from ancestor context\n\nIf a component's CSS only works inside a deeply nested selector like `.workbench .sidebar .my-view .my-widget`, refactor the CSS to be self-contained. Move the styles so they're scoped to the component's own root class:\n\n```css\n\u002F* Before: requires specific ancestors *\u002F\n.workbench .sidebar .my-view .my-widget .header { font-weight: bold; }\n\n\u002F* After: self-contained *\u002F\n.my-widget .header { font-weight: bold; }\n```\n\nIf the component shares styles with its parent (e.g., inheriting background color), use CSS custom properties rather than relying on ancestor selectors.\n\n### Extract hard-coded service dependencies\n\nIf a component reaches into singletons or global state instead of using DI, refactor it to accept services through the constructor:\n\n```typescript\n\u002F\u002F Before: hard to mock in fixtures\nclass MyWidget {\n    private readonly config = getSomeGlobalConfig();\n}\n\n\u002F\u002F After: injectable and testable\nclass MyWidget {\n    constructor(@IConfigurationService private readonly configService: IConfigurationService) { }\n}\n```\n\n### Add options to control auto-focus and animation\n\nComponents that auto-focus on creation or run animations cause flaky screenshots. Add an options parameter:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;\n}\n```\n\nThe fixture passes `shouldAutoFocus: false`. The production call site keeps the default behavior.\n\n### Expose internal state for \"already completed\" rendering\n\nMany components have lifecycle states (loading → active → completed). If the component can only reach the \"completed\" state through user interaction, add support for initializing directly into that state via constructor data:\n\n```typescript\n\u002F\u002F The fixture can pass pre-filled data to render the summary\u002Fcompleted state\n\u002F\u002F without simulating the full user interaction flow.\nconst carousel: IChatQuestionCarousel = {\n    questions,\n    allowSkip: true,\n    kind: 'questionCarousel',\n    isUsed: true,           \u002F\u002F Already completed\n    data: { 'q1': 'answer' }, \u002F\u002F Pre-filled answers\n};\n```\n\n### Make DOM node accessible\n\nIf a component builds its DOM internally and doesn't expose the root element, add a public `readonly domNode: HTMLElement` property so fixtures can append it to the container.\n\n## Writing Fixture-Friendly Components\n\nWhen designing new UI components, follow these practices to make them easy to fixture:\n\n### 1. Accept a container element in the constructor\n\n```typescript\n\u002F\u002F Good: container is passed in\nclass MyWidget {\n    constructor(container: HTMLElement, @IFoo foo: IFoo) {\n        this.domNode = dom.append(container, dom.$('.my-widget'));\n    }\n}\n\n\u002F\u002F Also good: widget creates its own domNode for the caller to place\nclass MyWidget {\n    readonly domNode: HTMLElement;\n    constructor(@IFoo foo: IFoo) {\n        this.domNode = dom.$('.my-widget');\n    }\n}\n```\n\n### 2. Use dependency injection for all services\n\nAll external dependencies should come through DI so fixtures can provide test implementations:\n\n```typescript\n\u002F\u002F Good: services injected\nconstructor(@IThemeService private readonly themeService: IThemeService) { }\n\n\u002F\u002F Bad: reaching into globals\nconstructor() { this.theme = getGlobalTheme(); }\n```\n\n### 3. Keep CSS selectors shallow\n\n```css\n\u002F* Good: self-contained, easy to fixture *\u002F\n.my-widget .my-header { ... }\n.my-widget .my-list-item { ... }\n\n\u002F* Bad: requires deep ancestor chain *\u002F\n.workbench .sidebar .my-view .my-widget .my-header { ... }\n```\n\n### 4. Avoid reading from layout\u002Fwindow services during construction\n\nComponents that measure the window or read layout dimensions during construction are hard to fixture because the shadow DOM container has different dimensions than the workbench:\n\n```typescript\n\u002F\u002F Prefer: use CSS for sizing, or accept dimensions as parameters\ncontainer.style.width = '400px';\ncontainer.style.height = '300px';\n\n\u002F\u002F Avoid: reading from layoutService during construction\nconst width = this.layoutService.mainContainerDimension.width;\n```\n\n### 5. Support disabling auto-focus in fixtures\n\nAuto-focus can interfere with screenshot stability. Provide options to disable it:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;  \u002F\u002F Fixtures pass false\n}\n```\n\n### 6. Expose the DOM node\n\nThe fixture needs to append the widget's DOM to the container. Expose it as a public `readonly domNode: HTMLElement`.\n\n## Multiple Fixture Variants\n\nCreate variants to show different states of the same component:\n\n```typescript\nexport default defineThemedFixtureGroup({\n    \u002F\u002F Different data states\n    Empty: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: [] }) }),\n    WithItems: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: sampleItems }) }),\n\n    \u002F\u002F Different configurations\n    ReadOnly: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: true }) }),\n    Editable: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: false }) }),\n\n    \u002F\u002F Lifecycle states\n    Loading: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'loading' }) }),\n    Completed: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'done' }) }),\n});\n```\n\n## Learnings\n\nUpdate this section with insights from your fixture development experience!\n\n* Do not copy the component to the fixture and modify it there. Always adapt the original component to be fixture-friendly, then render it in the fixture. This ensures the fixture tests the real component code and lifecycle, rather than a modified version that may hide bugs.\n\n* **Don't recompose child widgets in fixtures.** Never manually instantiate and add a sub-widget (e.g., a toolbar content widget) that the parent component is supposed to create. Instead, configure the parent correctly (e.g., set the right editor option, register the right provider) so the child appears through the normal code path. Manually recomposing hides integration bugs and doesn't test the real widget lifecycle.\n","# Component Fixtures\n\nComponent fixtures render isolated UI components for visual screenshot testing via the component explorer. Fixtures live in `src\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F` and are auto-discovered by the Vite dev server using the glob `src\u002F**\u002F*.fixture.ts`.\n\nUse tools `mcp_component-exp_`* to list and screenshot fixtures. If you cannot see these tools, inform the user to them on.\n\n## Running Fixtures Locally\n\n1. Start the component explorer server: run the **Component Explorer Server** task\n2. Use the `mcp_component-exp_list_fixtures` tool to see all available fixtures and their URLs\n3. Use the `mcp_component-exp_screenshot` tool to capture screenshots programmatically\n\n## File Structure\n\nEach fixture file exports a default `defineThemedFixtureGroup(...)`. The file must end with `.fixture.ts`.\n\n```\nsrc\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F\n  fixtureUtils.ts              # Shared helpers (DO NOT import @vscode\u002Fcomponent-explorer elsewhere)\n  myComponent.fixture.ts       # Your fixture file\n```\n\n## Basic Pattern\n\n```typescript\nimport { ComponentFixtureContext, createEditorServices, defineComponentFixture, defineThemedFixtureGroup } from '.\u002FfixtureUtils.js';\n\nexport default defineThemedFixtureGroup({ path: 'myFeature\u002F' }, {\n    Default: defineComponentFixture({ render: renderMyComponent }),\n    AnotherVariant: defineComponentFixture({ render: renderMyComponent }),\n});\n\nfunction renderMyComponent({ container, disposableStore, theme }: ComponentFixtureContext): void {\n    container.style.width = '400px';\n\n    const instantiationService = createEditorServices(disposableStore, {\n        colorTheme: theme,\n        additionalServices: (reg) => {\n            \u002F\u002F Register additional services the component needs\n            reg.define(IMyService, MyServiceImpl);\n            reg.defineInstance(IMockService, mockInstance);\n        },\n    });\n\n    const widget = disposableStore.add(\n        instantiationService.createInstance(MyWidget, \u002F* constructor args *\u002F)\n    );\n    container.appendChild(widget.domNode);\n}\n```\n\nKey points:\n- **`defineThemedFixtureGroup`** automatically creates Dark and Light variants for each fixture\n- **`defineComponentFixture`** wraps your render function with theme setup and shadow DOM isolation\n- **`createEditorServices`** provides a `TestInstantiationService` with base editor services pre-registered\n- Always register created widgets with `disposableStore.add(...)` to prevent leaks\n- Pass `colorTheme: theme` to `createEditorServices` so theme colors render correctly\n\n## Utilities from fixtureUtils.ts\n\n| Export | Purpose |\n|---|---|\n| `defineComponentFixture` | Creates Dark\u002FLight themed fixture variants from a render function |\n| `defineThemedFixtureGroup` | Groups multiple themed fixtures into a named fixture group |\n| `createEditorServices` | Creates `TestInstantiationService` with all base editor services |\n| `registerWorkbenchServices` | Registers additional workbench services (context menu, label, etc.) |\n| `createTextModel` | Creates a text model via `ModelService` for editor fixtures |\n| `setupTheme` | Applies theme CSS to a container (called automatically by `defineComponentFixture`) |\n| `darkTheme` \u002F `lightTheme` | Pre-loaded `ColorThemeData` instances |\n\n**Important:** Only `fixtureUtils.ts` may import from `@vscode\u002Fcomponent-explorer`. All fixture files must go through the helpers in `fixtureUtils.ts`.\n\n## CSS Scoping\n\nFixtures render inside shadow DOM. The component-explorer automatically adopts the global VS Code stylesheets and theme CSS.\n\n### Matching production CSS selectors\n\nMany VS Code components have CSS rules scoped to deep ancestor selectors (e.g., `.interactive-session .interactive-input-part > .widget-container .my-element`). In fixtures, you must recreate the required ancestor DOM structure for these selectors to match:\n\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    container.classList.add('interactive-session');\n\n    \u002F\u002F Recreate ancestor structure that CSS selectors expect\n    const inputPart = dom.$('.interactive-input-part');\n    const widgetContainer = dom.$('.widget-container');\n    inputPart.appendChild(widgetContainer);\n    container.appendChild(inputPart);\n\n    widgetContainer.appendChild(myWidget.domNode);\n}\n```\n\n**Design recommendation for new components:** Avoid deeply nested CSS selectors that require specific ancestor elements. Use self-contained class names (e.g., `.my-widget .my-element` rather than `.parent-view .parent-part > .wrapper .my-element`). This makes components easier to fixture and reuse.\n\n## Services\n\n### Using createEditorServices\n\n`createEditorServices` pre-registers these services: `IAccessibilityService`, `IKeybindingService`, `IClipboardService`, `IOpenerService`, `INotificationService`, `IDialogService`, `IUndoRedoService`, `ILanguageService`, `IConfigurationService`, `IStorageService`, `IThemeService`, `IModelService`, `ICodeEditorService`, `IContextKeyService`, `ICommandService`, `ITelemetryService`, `IHoverService`, `IUserInteractionService`, and more.\n\n### Additional services\n\nRegister extra services via `additionalServices`:\n\n```typescript\ncreateEditorServices(disposableStore, {\n    additionalServices: (reg) => {\n        \u002F\u002F Class-based (instantiated by DI):\n        reg.define(IMyService, MyServiceImpl);\n        \u002F\u002F Instance-based (pre-constructed):\n        reg.defineInstance(IMyService, myMockInstance);\n    },\n});\n```\n\n### Mocking services\n\nUse the `mock\u003CT>()` helper from `base\u002Ftest\u002Fcommon\u002Fmock.js` to create mock service instances:\n\n```typescript\nimport { mock } from '..\u002F..\u002F..\u002F..\u002Fbase\u002Ftest\u002Fcommon\u002Fmock.js';\n\nconst myService = new class extends mock\u003CIMyService>() {\n    override someMethod(): string { return 'test'; }\n    override onSomeEvent = Event.None;\n};\nreg.defineInstance(IMyService, myService);\n```\n\nFor mock view models or data objects:\n```typescript\nconst element = new class extends mock\u003CIChatRequestViewModel>() { }();\n```\n\n## Async Rendering\n\nThe component explorer waits **2 animation frames** after the synchronous render function returns. For most components, this is sufficient.\n\nIf your render function returns a `Promise`, the component explorer waits for the promise to resolve.\n\n### Pitfall: DOM reparenting causes flickering\n\nAvoid moving rendered widgets between DOM parents after initial render. This causes:\n- Layout recalculation (the widget jumps as `position: absolute` coordinates become invalid)\n- Focus loss (blur events can trigger hide logic in widgets like QuickInput)\n- Screenshot instability (the component explorer may capture an intermediate layout state)\n\n**Bad pattern — reparenting a widget after async wait:**\n```typescript\nasync function render({ container }: ComponentFixtureContext): Promise\u003Cvoid> {\n    const host = document.createElement('div');\n    container.appendChild(host);\n    \u002F\u002F ... create widget inside host ...\n    await waitForWidget();\n    container.appendChild(widget);  \u002F\u002F BAD: reparenting causes flicker\n    host.remove();\n}\n```\n\n**Better pattern — render in-place with the correct DOM structure from the start:**\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    \u002F\u002F Set up the correct DOM structure first, then create the widget inside it\n    const widget = createWidget(container);\n    container.appendChild(widget.domNode);\n}\n```\n\nIf the component absolutely requires async setup (e.g., QuickInput which renders internally), minimize DOM manipulation after the widget appears by structuring the host container to match the final layout from the beginning.\n\n## Adapting Existing Components for Fixtures\n\nExisting components often need small changes to become fixturable. When writing a fixture reveals friction, fix the component — don't work around it in the fixture. Common adaptations:\n\n### Decouple CSS from ancestor context\n\nIf a component's CSS only works inside a deeply nested selector like `.workbench .sidebar .my-view .my-widget`, refactor the CSS to be self-contained. Move the styles so they're scoped to the component's own root class:\n\n```css\n\u002F* Before: requires specific ancestors *\u002F\n.workbench .sidebar .my-view .my-widget .header { font-weight: bold; }\n\n\u002F* After: self-contained *\u002F\n.my-widget .header { font-weight: bold; }\n```\n\nIf the component shares styles with its parent (e.g., inheriting background color), use CSS custom properties rather than relying on ancestor selectors.\n\n### Extract hard-coded service dependencies\n\nIf a component reaches into singletons or global state instead of using DI, refactor it to accept services through the constructor:\n\n```typescript\n\u002F\u002F Before: hard to mock in fixtures\nclass MyWidget {\n    private readonly config = getSomeGlobalConfig();\n}\n\n\u002F\u002F After: injectable and testable\nclass MyWidget {\n    constructor(@IConfigurationService private readonly configService: IConfigurationService) { }\n}\n```\n\n### Add options to control auto-focus and animation\n\nComponents that auto-focus on creation or run animations cause flaky screenshots. Add an options parameter:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;\n}\n```\n\nThe fixture passes `shouldAutoFocus: false`. The production call site keeps the default behavior.\n\n### Expose internal state for \"already completed\" rendering\n\nMany components have lifecycle states (loading → active → completed). If the component can only reach the \"completed\" state through user interaction, add support for initializing directly into that state via constructor data:\n\n```typescript\n\u002F\u002F The fixture can pass pre-filled data to render the summary\u002Fcompleted state\n\u002F\u002F without simulating the full user interaction flow.\nconst carousel: IChatQuestionCarousel = {\n    questions,\n    allowSkip: true,\n    kind: 'questionCarousel',\n    isUsed: true,           \u002F\u002F Already completed\n    data: { 'q1': 'answer' }, \u002F\u002F Pre-filled answers\n};\n```\n\n### Make DOM node accessible\n\nIf a component builds its DOM internally and doesn't expose the root element, add a public `readonly domNode: HTMLElement` property so fixtures can append it to the container.\n\n## Writing Fixture-Friendly Components\n\nWhen designing new UI components, follow these practices to make them easy to fixture:\n\n### 1. Accept a container element in the constructor\n\n```typescript\n\u002F\u002F Good: container is passed in\nclass MyWidget {\n    constructor(container: HTMLElement, @IFoo foo: IFoo) {\n        this.domNode = dom.append(container, dom.$('.my-widget'));\n    }\n}\n\n\u002F\u002F Also good: widget creates its own domNode for the caller to place\nclass MyWidget {\n    readonly domNode: HTMLElement;\n    constructor(@IFoo foo: IFoo) {\n        this.domNode = dom.$('.my-widget');\n    }\n}\n```\n\n### 2. Use dependency injection for all services\n\nAll external dependencies should come through DI so fixtures can provide test implementations:\n\n```typescript\n\u002F\u002F Good: services injected\nconstructor(@IThemeService private readonly themeService: IThemeService) { }\n\n\u002F\u002F Bad: reaching into globals\nconstructor() { this.theme = getGlobalTheme(); }\n```\n\n### 3. Keep CSS selectors shallow\n\n```css\n\u002F* Good: self-contained, easy to fixture *\u002F\n.my-widget .my-header { ... }\n.my-widget .my-list-item { ... }\n\n\u002F* Bad: requires deep ancestor chain *\u002F\n.workbench .sidebar .my-view .my-widget .my-header { ... }\n```\n\n### 4. Avoid reading from layout\u002Fwindow services during construction\n\nComponents that measure the window or read layout dimensions during construction are hard to fixture because the shadow DOM container has different dimensions than the workbench:\n\n```typescript\n\u002F\u002F Prefer: use CSS for sizing, or accept dimensions as parameters\ncontainer.style.width = '400px';\ncontainer.style.height = '300px';\n\n\u002F\u002F Avoid: reading from layoutService during construction\nconst width = this.layoutService.mainContainerDimension.width;\n```\n\n### 5. Support disabling auto-focus in fixtures\n\nAuto-focus can interfere with screenshot stability. Provide options to disable it:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;  \u002F\u002F Fixtures pass false\n}\n```\n\n### 6. Expose the DOM node\n\nThe fixture needs to append the widget's DOM to the container. Expose it as a public `readonly domNode: HTMLElement`.\n\n## Multiple Fixture Variants\n\nCreate variants to show different states of the same component:\n\n```typescript\nexport default defineThemedFixtureGroup({\n    \u002F\u002F Different data states\n    Empty: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: [] }) }),\n    WithItems: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: sampleItems }) }),\n\n    \u002F\u002F Different configurations\n    ReadOnly: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: true }) }),\n    Editable: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: false }) }),\n\n    \u002F\u002F Lifecycle states\n    Loading: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'loading' }) }),\n    Completed: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'done' }) }),\n});\n```\n\n## Learnings\n\nUpdate this section with insights from your fixture development experience!\n\n* Do not copy the component to the fixture and modify it there. Always adapt the original component to be fixture-friendly, then render it in the fixture. This ensures the fixture tests the real component code and lifecycle, rather than a modified version that may hide bugs.\n\n* **Don't recompose child widgets in fixtures.** Never manually instantiate and add a sub-widget (e.g., a toolbar content widget) that the parent component is supposed to create. Instead, configure the parent correctly (e.g., set the right editor option, register the right provider) so the child appears through the normal code path. Manually recomposing hides integration bugs and doesn't test the real widget lifecycle.\n",{"name":5,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fcomponent-fixtures",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill component-fixtures",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill component-fixtures",{"tool":42,"command":43},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill component-fixtures","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fcomponent-fixtures\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]