Ui eng vision orchestrator

From ChromeDevTools/devtools-frontend · View interactive version

Ui eng vision orchestrator is an AI agent skill from the GitHub repository ChromeDevTools/devtools-frontend. High-level orchestrator for managing multi-pass migration of Chrome DevTools legacy components to the modern UI engineering vision (UI.Widget & Lit-html).

How to use this skill

Skill file

UI Engineering Vision Orchestrator: Meta-Skill Instructions

This meta-skill acts as the central coordinator for modernizing legacy Chrome

DevTools views into declarative UI.Widget components based on lit-html,

managing a multi-pass sequential CL pipeline to ensure each code modification is

small, testable, and highly reviewable.

Refer to ui_engineering.md for general

principles.


🛑 Critical Constraints & Forbidden Actions

  1. NEVER Break the Build: Code must compile and tests must pass at all steps. If you change a class API or method signature, you MUST update its usage in the same CL to maintain stability.
  2. Strict Intermediate Stability: Do not leave the code in a broken state between passes.
  3. No Beautification of Adjacent Code: Do NOT fix unrelated typos, formatting issues, or lint warnings in code you aren't actively migrating.
  4. No Monolithic Refactors: Do NOT batch Lit conversion and Widget Promotion in the same pass (except for small < 150 LOC leaf widgets). Keep CLs small and focused.

1. Migration Philosophy & Plan-Validate-Execute Pattern

  1. The Plan-Validate-Execute Principle: For each target file, the

orchestrator must first generate a structured migration_plan.md listing

the exact transformations, file targets, and subskills allocated for each

pass.

  1. User Acceptance Gate: The orchestrator must halt execution and present

the migration plan to the user. No code modification, subskill loading, or

CL staging can occur until the user explicitly accepts the plan.

  1. No Assumptions on Inheritance: Do not assume the class hierarchy in a

file matches older patterns or generic examples. Always perform a structure

analysis of the active file first and adapt the plan to the actual, current

code.

  1. Reusable vs. Single-Use Web Components Gate:
  1. Hybrid Files/Multiple Classes: Files may contain multiple classes in

different states of modernization (e.g., one partially migrated class and

one fully legacy class). If the file being migrated contains several

classes, the migration needs to be done separately for each class, starting

with the leaves and going up the dependency chain. Propose modifications

only for classes with actual violations.

  1. Coupling Analysis: Always check the integration files (e.g., sidebar

files, parent panel files) where the target class is instantiated to see if

there are any direct .element or .contentElement couplings. If found,

include the decoupling of these references in the plan.

  1. Neighboring Component Reference: Inspect neighboring modernized files of

the same archetype (e.g., DOMStorageItemsView.ts or

KeyValueStorageItemsView.ts for storage-like components) to find proven

patterns for toolbar and data-grid configurations.

  1. The Narrow Bridge Principle: Keep code modifications tightly scoped to a

single responsibility per CL. Do not combine technology migrations (e.g.,

converting imperative DOM to Lit-html) with base class refactoring in the

same diff.

  1. Strict Intermediate Stability: The code must compile and work correctly,

and all tests must pass after each step. You MUST update usages if you

change APIs.

  1. Establish Comprehensive Guardrails First: Ensure both logic tests

(verifying presenter interactions and state updates) and **screenshot

tests** (verifying layout/styling) exist before rewriting code. If coverage

is missing, scaffold it first.

  1. Pre-flight Clarification: Before starting, verify if the task is

underspecified or ambiguous. If so, point this out and ask for

clarifications before proceeding.

  1. Step Sizing (~35–200 LOC Target, <= 350 Ceiling) & 100% Live-Code Rule:

Aim for ~35–200 LOC in-place CLs (small < 150 LOC leaf widgets may

complete in one CL), and keep every CL at or under **350 changed lines

(insertions + deletions)**. Every CL must

execute 100% of its new view and presenter code in production, remove the

imperative code it replaces, and include unit tests covering that behavior in

the same CL. Never create a CL that adds an unused DEFAULT_VIEW or

*_VIEW export, defers unit tests to a follow-up test-only CL, or defers

imperative dead-code removal to a cleanup-only tail CL. The agent must stop

and report back after each step or substep to allow verification.

  1. Context Hygiene via Subagents: To keep the main conversation context

clean and focused on high-level orchestration, prefer delegating intense

execution tasks (like running tests, debugging compilations, or processing

independent classes in parallel) to specialized subagents.

  1. Cross-Repo Runtime Coupling Check (legacy_test_runner & blink/web_tests):

Before converting TypeScript private fields/methods to ES #private or

removing widget properties (e.g., .tabbedPane, .sidebarPaneStack,

.threadsSidebarPane, .searchInputElement), search both

front_end/legacy_test_runner/**/*.js and Chromium's

third_party/blink/web_tests/http/tests/devtools/**/*.js (which run on

dtf_linux_rel CQ via blink_web_tests and reflectively access private

members in untyped JS). Keep accessed members as TypeScript private with a

// Accessed in web_tests / legacy_test_runner comment, or migrate the

web_tests first in a dedicated CL.

  1. Strict CL Splitting Rules:

ensuring its stylesheet is wrapped in @scope to (devtools-widget > *)

(removing the file from the @devtools/no-unscoped-light-dom-styles

burndown list in eslint.config.mjs once scoped). Always land this

in a small, standalone CSS CL separate from logic, template, or

widget-promotion CLs for bisectability, with screenshot baselines

established beforehand.


2. Multi-Pass Execution Lifecycle

Plan Generation (Gated)

1. Verify if the task is underspecified or ambiguous. If so, ask for

clarifications first.

2. Scan the target file to determine size, complexity, legacy elements

(e.g., ReportView, ToolbarButton, DataGrid, TreeOutline), and

actual class inheritance. Deconstruct the file mentally (or in the plan)

into Business Logic (state, event handlers) and Rendering Logic

(DOM creation, CSS classes). Reference code elements by Name (not

line numbers) to ensure the plan remains valid as the codebase evolves.

Check if the class dependencies have been migrated to the ui eng vision

or not. If the file contains multiple classes, plan the migration

separately for each class, starting with the leaves and going up the

dependency chain.

3. Check the files depending on this file, to understand how the code in

this file is being used.

4. Dynamic Ordering Decision: Determine whether to run Logic

Consolidation first or Local lit-html rendering first:

complex, nested state model or highly coupled event-handlers.

Consolidating the state variables and defining the ViewInput

interface first provides a clean data contract, making the

subsequent template conversion highly deterministic.

relatively simple state flow but massive, deeply nested imperative

DOM construction. Converting the layout to declarative Lit templates

first (using temporary inline or local state) makes it much easier

to isolate and group the remaining state updates afterward.

5. Generate a migration_plan.md using the Structured Plan Template below.

6. Halt execution and print the formatted plan in Markdown to the chat.

Wait for user approval.

📝 Structured Plan Template

The plan you generate MUST follow this structure:

# Migration Plan: [FileName.ts]

## 📊 Current State
- **Hybrid File**: [Yes/No]
- **Classes Found**: [ClassA, ClassB]
- **Strategy Selection**: [Option A (Logic First) | Option B (Tech First)]

## 🛠️ Passes Checklist
- [ ] **Pass 0: Baseline & Safety Scaffolding**
  - Assigned to: `ui-eng-vision-test-scaffolder`
- [ ] **Pass 0.5: Privatize & Dead-Code Cleanup**
  - Mechanical prefactor: convert TypeScript `private` to ES `#private` and remove dead code
- [ ] **Pass 0.75: Light DOM CSS @scope Wrapping (Standalone CL)**
  - Ensure stylesheet is wrapped in `@scope to (devtools-widget > *)` and remove entry from the `@devtools/no-unscoped-light-dom-styles` burndown list in `eslint.config.mjs`
- [ ] **Pass 1: Logic Consolidation**
  - Assigned to: `ui-eng-vision-logic-consolidator`
- [ ] **Pass 2: Lit-HTML Rendering**
  - Assigned to: `ui-eng-vision-local-lit-renderer`
- [ ] **Pass 3: Widget Promotion**
  - Assigned to: `ui-eng-vision-widget-promoter`

Baseline & Safety Scaffolding

equivalent.

1. Verify existing test coverage. Propose and add missing logic tests

for interactions and screenshot tests for visual validation to avoid

regressions.

2. Pay extra attention not to skip this step.

Privatize & Dead-Code Cleanup (Pass 0.5)

1. Perform the Cross-Repo Runtime Coupling Check against legacy_test_runner and blink_web_tests first.

2. Convert internal TypeScript private fields/methods to ES #private (except those reflectively accessed by web tests).

3. Identify and remove unused dead code, redundant containers, or obsolete split widgets in a dedicated prefactor CL so mechanical renames don't clutter logic and view CLs.

4. Verify that all tests and lints pass and stage this prefactor CL before proceeding to logic consolidation.

Light DOM CSS @scope Wrapping (Pass 0.75 / Standalone CSS CL)

1. Wrap the Light DOM widget's stylesheet in @scope to (devtools-widget > *).

2. Remove the file from the @devtools/no-unscoped-light-dom-styles burndown list in eslint.config.mjs.

3. Verify zero visual regressions against screenshot goldens and land this in a small, standalone CL separate from logic, template, and widget-promotion CLs for bisectability.

Logic Consolidation

1. Extract manual elements, constructor DOM configurations, and imperative

updates into private update helper methods with structured

state-passing.

Local Lit-HTML Rendering (Technology Migration)

1. Migrate imperative elements to declarative templates (using component

mapping rules defined inside the subskill) and render them locally

within the existing view.

Widget Promotion (Architectural Bridge)

staged.

1. Promote view classes to modern UI.Widget classes, hook up

performUpdate() delegates, export the default view layout, and clean

up legacy wrappers.


3. Incremental Multi-CL Playbook for Complex Tree & List Widgets (`UI.TreeOutline` → `<devtools-tree>`)

For complex widgets with deeply nested item hierarchies, custom tree element

subclasses, or inline editing (such as NavigatorView or SearchResultsPane),

monolithic migrations introduce high review friction and regression risk.

Decompose the work into a 4-phase sequence of small, self-contained CLs

(~50–250 lines of diff each):

Phase 0: Safety Net, Cleanup & Latent Bug Fixes (Independent CLs)

  1. Dead-Code Removal: Remove dead helper methods, unused getters, and

obsolete container references in an initial standalone CL.

  1. Implementation-Decoupled Tests: Add structural and interaction unit

tests whose DOM assertions route through small local test helpers

(dumpTree(), findTreeItem(), activateRow(), openContextMenuOnRow())

rather than scattering direct tree-outline element queries across tests.

  1. Screenshot Baselines: Add assertScreenshot(...) golden tests covering

critical visual states (grouping modes, icons/badges, selection, dimmed

items) to establish baselines that catch visual regressions independently of

the underlying widget engine.

  1. Targeted Bug Fixes: If test scaffolding uncovers latent bugs in existing

logic, fix them in dedicated bugfix CLs before refactoring.

Phase 1: Decouple Custom Item Subclasses One Concern per CL (`Bug: <id>`)

  1. Sorting & Comparators: Move sorting functions from item elements to

presenter data nodes.

  1. Row Event Handlers: Move row event handlers (hover, context menu, drag,

rename triggers) to presenter methods.

  1. Icon & Action Templates: Convert imperative leading/trailing icons,

badges, and action buttons into module-level Lit template helpers, removing

view-layer refresh methods (updateTrailingIcons(), updateIcon()) from

presenter nodes once state moves to DEFAULT_VIEW.

  1. State Tracking in Presenter: Track selection, expansion (WeakSet), and

lazy population in the presenter via tree events rather than overriding

TreeElement.onpopulate() or onselect().

  1. Remove Custom Subclasses: Delete custom TreeElement subclasses one

class per CL, using plain UI.TreeOutline.TreeElement instances paired with

a WeakMap<TreeElement, Node> bridge and computing presenter node state

(title, tooltip, badges) independently of TreeElement creation.

Phase 2: Persistent `<devtools-prompt>` & `<devtools-tree>` Swap (`Bug: <id>`)

  1. Persistent <devtools-prompt ?editing>: Migrate inline renaming or

editing (UI.InplaceEditor) to a persistent <devtools-prompt ?editing> in

its own CL, updating E2E tests waiting on .being-edited to wait on

devtools-prompt[editing].

  1. Test-Helper Prep CL: If front_end/legacy_test_runner/** or

blink_web_tests walk internal tree elements, update test helpers to flush

innerView.performUpdate() and flushPendingUpdatesForTesting() after

expanding nodes.

  1. <devtools-tree> Swap: Replace TreeOutlineInShadow with

<devtools-tree autofocus> in DEFAULT_VIEW without widening

front_end/ui/legacy/Treeoutline.ts contracts. Host editable

<devtools-prompt ?editing> rows in a child UI.Widget (${widget(...)})

so <devtools-tree>'s light-DOM MutationObserver does not re-clone the

row and blur the active input. Use asynchronous this.requestUpdate() across

all presenter methods and remove

/* eslint-disable @devtools/no-imperative-dom-api */.

Phase 3: Pure Lifecycle, `INJECT` DI & Final Polish (`Fixed: <id>` on Final CL Only)

  1. Non-Destructive Lifecycle: Move model, workspace, and setting

subscriptions from constructor() into wasShown() / willHide(),

reconciling incremental changes that occurred while hidden rather than

calling reset() and wiping open folders or selection on every re-show.

  1. Universe Dependency Injection: When Universe dependencies are used,

add static override readonly INJECT and the standard MVP constructor

(element?: HTMLElement, [...]: WidgetDependencies, view: View = DEFAULT_VIEW)

(omit the WidgetDependencies parameter when INJECT is empty).

  1. Private Fields & Completeness: Convert remaining TypeScript private

members to #private (after verifying they are not reflectively accessed in

legacy_test_runner or blink/web_tests), and mark Fixed: <id> on this

final CL.


4. Definition of Done & `Bug:` vs `Fixed:` Completeness Gate

[!WARNING]

A clean @devtools/no-imperative-dom-api ESLint run does NOT prove a UI

Eng Vision migration is complete. The rule does not flag

extends UI.TreeOutline.TreeElement subclasses, new MyTreeElementSubclass(...),

UI.InplaceEditor, unchained createIcon() calls (for example, passed directly

to this.setLeadingIcons([icon])), or unattached

new UI.{TabbedPane,TextPrompt,FilterBar} instances (when not

attached to this.element or this.contentElement). Conversely, non-UI.Widget

helper classes that own this.element or this.contentElement are flagged.

To inspect suppressed violations despite a file-level disable, run from the

devtools-frontend root:

vpython3 third_party/node/node.py --output node_modules/eslint/bin/eslint.js --no-inline-config --rule '@devtools/no-imperative-dom-api: error' -f json <file>

Before closing a UI Eng Vision migration issue with Fixed: <id>, verify every

requirement below. If any item remains incomplete, use Bug: <id> and address

it in a follow-up CL:

  1. No Legacy Widgets: Zero references to UI.TreeOutline, TreeElement

subclasses, UI.ListControl, UI.ListWidget, or UI.InplaceEditor.

  1. Standard MVP Constructor: Constructor accepts element?: HTMLElement as

its first parameter, receives [...]: UI.Widget.WidgetDependencies<typeof MyWidget>

as parameter #2 only when static override readonly INJECT is non-empty,

and accepts an injectable view: View = DEFAULT_VIEW last.

  1. Widget Update Lifecycle: Renders exclusively via override performUpdate(): void

and this.requestUpdate() (no custom #renderView() bypasses or synchronous

performUpdate() calls in presenter methods).

  1. Non-Destructive Listener Lifecycle: External model and setting

listeners are attached in wasShown() and detached symmetrically in

willHide(), preserving populated UI state across hide/show cycles.

  1. Declarative Primitives: Uses <devtools-tree>, <devtools-list>,

persistent <devtools-prompt ?editing>, ?hidden=${...} exclusively

(without .hidden classes), and declarative autofocus for default focus.

  1. ES Private Fields & Config Cleanup: Uses ECMAScript #private fields and

methods for all internal members not on Object.create prototypes or

accessed by legacy_test_runner / blink/web_tests, removes the file from

the @devtools/prefer-private-class-members ignore list in

eslint.config.mjs, and passes ./dt lint <file>.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.