Agent Skills › ChromeDevTools/devtools-frontend › ui-eng-vision-widget-promoter

ui-eng-vision-widget-promoter

GitHub

将遗留视图升级为现代UI.Widget类,重构继承关系,集成Lit模板渲染与依赖注入,清理旧版包装器。

.agents/skills/ui-eng-vision-widget-promoter/SKILL.md ChromeDevTools/devtools-frontend

Trigger Scenarios

需要迁移遗留SimpleView到UI.Widget 重构组件以使用performUpdate渲染 升级视图委托和依赖注入

Install

npx skills add ChromeDevTools/devtools-frontend --skill ui-eng-vision-widget-promoter -g -y
More Options

Non-standard path

npx skills add https://github.com/ChromeDevTools/devtools-frontend/tree/main/.agents/skills/ui-eng-vision-widget-promoter -g -y

Use without installing

npx skills use ChromeDevTools/devtools-frontend@ui-eng-vision-widget-promoter

指定 Agent (Claude Code)

npx skills add ChromeDevTools/devtools-frontend --skill ui-eng-vision-widget-promoter -a claude-code -g -y

安装 repo 全部 skill

npx skills add ChromeDevTools/devtools-frontend --all -g -y

预览 repo 内 skill

npx skills add ChromeDevTools/devtools-frontend --list

SKILL.md

Frontmatter
{
    "name": "ui-eng-vision-widget-promoter",
    "description": "Promotes legacy views to modern UI.Widget classes, hooks up performUpdate() rendering, and exports default views.",
    "allowed-tools": "code_search open_urls"
}

Subskill: Widget Promoter (Pass 3)

This subskill completes the architectural transition, upgrading the component from legacy base classes (like SimpleView or custom wrapper layouts) into clean UI.Widget classes that use native update rendering delegates.


1. Widget Promotion Guidelines

  1. Change Class Inheritance:

    • Rewrite class declarations to extend UI.Widget (or specialized sub-layouts like UI.Widget.VBox).
    • Clean up and remove older constructors that perform custom container initializations or access .element directly for manual append operations.
    • Note that VBox and HBox inherit directly from Widget. They fully support view injection (view = DEFAULT_VIEW), performUpdate(), and requestUpdate() without modification.
  2. Upgrade View Delegates & Inject View:

    • Migrate the local Lit template strings into a formally exported default view layout (using named imports import {html, render} from '../../ui/lit/lit.js';):

      export const DEFAULT_VIEW: View = (input, output, target) => {
        render(html`...`, target);
      };
      
    • Make the view injectable in the constructor for testability (as per docs/ui_engineering.md), and use static INJECT if requesting dependencies from Universe:

      class MyWidget extends UI.Widget.VBox {
        static override readonly INJECT = [SDK.TargetManager.TargetManager] as const;
      
        #targetManager: SDK.TargetManager.TargetManager;
        #view: View;
        constructor(
          element?: HTMLElement,
          [targetManager]: UI.Widget.WidgetDependencies<typeof MyWidget> = [],
          view: View = DEFAULT_VIEW,
        ) {
          super(element);
          this.#targetManager = targetManager;
          this.#view = view;
        }
      
    • Implement the standard modern performUpdate() override on the widget:

      override performUpdate(): void {
        this.#view(this.viewInput, this.viewOutput, this.contentElement);
      }
      
  3. Clean Up Legacy Wrappers:

    • Remove any LegacyWrapper bindings or custom wrappable custom elements.

    • Replace old panel instantiations with standard <devtools-widget> declarative entries (using const {widget} = UI.Widget;):

      html`<devtools-widget ${widget(MyWidgetClass, {params})}></devtools-widget>`
      
    • Inspect instantiator files (e.g., ApplicationPanelSidebar.ts) and decouple any direct accesses to .element.


2. Safety & Verification Rules

  • CRITICAL: Never update screenshot goldens without explicit consent of the user. Most likely the failure points to an issue in the implementation or (less likely) the test itself. Look at the screenshot diffs to debug.
  • Minimal Code Movement & Helper Topology: When migrating, try to move code around as little as possible, in particular around the lit rendering helpers. Preserve existing standalone/module-level DOM helper functions (e.g., linkifyIcon, maybeCreateLinkToElementsPanel) and async class update helpers in their original locations, having DOM helpers return LitTemplate (or Promise<LitTemplate|null>) rather than deleting and inlining them into performUpdate() or DEFAULT_VIEW. This minimizes the git diff and improves reviewability.

🔍 Mental Audit (Internal Self-Correction)

Before reporting back or committing, re-read the instructions and verify:

  1. ❓ Decoupling: Did I remove all direct .element or .contentElement couplings from instantiator files?
  2. ❓ Inheritance: Does the class now cleanly inherit from UI.Widget or its variants?
  3. ❓ Injectability: Is the view injectable in the constructor?
  4. ❓ Build: Does the code compile and do tests pass?

Version History

  • 6527f72 Current 2026-10-20 02:27

    明确保留独立DOM辅助函数和类更新辅助方法的原始拓扑结构,就地转换为返回LitTemplate而非内联。

  • 678d19c 2026-08-20 15:21

Same Skill Collection

.agents/skills/code-review/SKILL.md
.agents/skills/devtools-ci/SKILL.md
.agents/skills/devtools-imports/SKILL.md
.agents/skills/devtools-model-management/SKILL.md
.agents/skills/devtools-setting-migration/SKILL.md
.agents/skills/devtools-source-maps/SKILL.md
.agents/skills/devtools-testing-guidance/SKILL.md
.agents/skills/devtools-unicode-escaping/SKILL.md
.agents/skills/devtools-ux-writing-refactor/SKILL.md
.agents/skills/devtools-verification/SKILL.md
.agents/skills/evaluate-ai-css-completion/SKILL.md
.agents/skills/fix-tests/SKILL.md
.agents/skills/fixing-skipped-tests/SKILL.md
.agents/skills/foundation-test-migration/SKILL.md
.agents/skills/gerrit-cli/SKILL.md
.agents/skills/merging-devtools-module/SKILL.md
.agents/skills/migrate-chromium-test/SKILL.md
.agents/skills/review-models-core/SKILL.md
.agents/skills/review-tests/SKILL.md
.agents/skills/review-ui-widgets/SKILL.md
.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md
.agents/skills/ui-eng-vision-logic-consolidator/SKILL.md
.agents/skills/ui-eng-vision-orchestrator/SKILL.md
.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md
.agents/skills/ui-widgets/SKILL.md
.agents/skills/version-control/SKILL.md
.agents/skills/repro-flaky-tests/SKILL.md

Metadata

Files
0
Version
6527f72
Hash
a146a129
Indexed
2026-08-20 15:21

홈 - 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-22 00:12
浙ICP备14020137号-1