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
- 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.
- Strict Intermediate Stability: Do not leave the code in a broken state between passes.
- No Beautification of Adjacent Code: Do NOT fix unrelated typos, formatting issues, or lint warnings in code you aren't actively migrating.
- No Monolithic Refactors: Do NOT batch Lit conversion and Widget Promotion in the same pass (except for small
< 150LOC leaf widgets). Keep CLs small and focused.
1. Migration Philosophy & Plan-Validate-Execute Pattern
- 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.
- 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.
- 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.
- Reusable vs. Single-Use Web Components Gate:
- Reusable UI primitives (
front_end/ui/components/**,front_end/ui/kit/**— shared buttons, menus, dialogs, links, badges, or trees reused across panels) must remain custom elements (HTMLElement). Do not migrate them toUI.WidgetorDEFAULT_VIEW. - Single-use custom elements (
extends HTMLElementorLitElementunderfront_end/panels/**/components/used solely for encapsulation in one feature or panel) should migrate toUI.Widget+DEFAULT_VIEW+@scope to (devtools-widget > *).
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Pre-flight Clarification: Before starting, verify if the task is
underspecified or ambiguous. If so, point this out and ask for
clarifications before proceeding.
- Step Sizing (
~35–200LOC Target,<= 350Ceiling) & 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.
- 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.
- 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.
- Strict CL Splitting Rules:
- Live Split Patterns (
<= 350Lines): When a migration exceeds 350 lines, split using one of three live-code patterns: (a) one live class or low-fanout shared helper per CL (leaf-to-root, wired to callers and tested immediately), (b) 2-passLocal Lit in performUpdate()->UI.Widget + DEFAULT_VIEW promotion(Pass 1 renders Lit templates live inperformUpdate(), removes imperative DOM, and tests behavior; Pass 2 promotes toDEFAULT_VIEWandcreateViewFunctionStubtests), or (c) vertical UI compartment slices (migrating one toolbar, settings pane, split pane, or formatter batch end-to-end per CL). - Separate Infrastructure & Shared-Helper CLs: Keep shared
ui/legacy,ui/kit, orUI.UIUtilschanges (e.g., converting a low-fanout helper likeUI.UIUtils.maybeCreateNewBadgeto returnLitTemplateacross its callers, or adding an HTML-native ID/attribute API to<devtools-menu>) in separate, preceding CLs rather than inlining helper internals or addingref(...)workarounds at call sites. Always verify withcog_api.py diffbefore uploading that no changes from later commits leaked into earlier infrastructure CLs. - CL Descriptions & Bug Trailers Across Stacks: Carry the target Buganizer issue ID across every CL in a split stack (
Bug: <id>on intermediate CLs,Fixed: <id>only on the final complete CL). Write descriptive<= 72-character subject lines stating what each CL changes functionally, without pass or step numbers (Pass 1:,(2/6)) in the subject line. - Standalone CSS
@scopeCLs: Migrating a Light DOM widget includes
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)
- Actions:
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:
- Option A (Logic First): Choose this if the component has a
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.
- Option B (Technology First): Choose this if the component has a
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
- Trigger Condition: User explicitly says "I accept the plan" or
equivalent.
- Subskill to Import/Delegate:
ui-eng-vision-test-scaffolder(Delegate to a subagent to encapsulate verbose test logs) - Actions:
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)
- Trigger Condition: Baseline tests green.
- Actions:
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).
- Remove the target file from the
@devtools/prefer-private-class-membersignore list ineslint.config.mjs(never combine a top-level inline/* eslint-disable @devtools/prefer-private-class-members */with aneslint.config.mjsignore entry, becauseeslint --fixstrips the inline disable while the rule is off ineslint.config.mjs). - Run
./dt lint <file>to apply the AST autofixer, then manually convert cross-instanceother.m()calls and rewritethis.#fn = this.#fn.bind(this)to arrow properties (#fn = (): void => { ... }). Preserve TypeScriptprivatewith// eslint-disable-next-line @devtools/prefer-private-class-membersonly forObject.createprototypes or legacy*TestRunner.js/blink/web_testshooks.
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)
- Trigger Condition: Baseline tests green (screenshot baselines established).
- Actions:
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
- Trigger Condition: Pass 0.5 staged (or baseline tests green if 0.5 skipped).
- Subskill to Import/Delegate:
ui-eng-vision-logic-consolidator(Delegate to a subagent to maintain focus) - Actions:
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)
- Trigger Condition: Previous pass staged.
- Subskill to Import/Delegate:
ui-eng-vision-local-lit-renderer(Delegate to a subagent for isolated template generation) - Actions:
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)
- Trigger Condition: Both local template rendering and logic consolidation
staged.
- Subskill to Import/Delegate:
ui-eng-vision-widget-promoter(Delegate to a subagent for final architectural cleanup) - Actions:
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)
- Dead-Code Removal: Remove dead helper methods, unused getters, and
obsolete container references in an initial standalone CL.
- 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.
- 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.
- 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>`)
- Sorting & Comparators: Move sorting functions from item elements to
presenter data nodes.
- Row Event Handlers: Move row event handlers (hover, context menu, drag,
rename triggers) to presenter methods.
- 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.
- State Tracking in Presenter: Track selection, expansion (
WeakSet), and
lazy population in the presenter via tree events rather than overriding
TreeElement.onpopulate() or onselect().
- Remove Custom Subclasses: Delete custom
TreeElementsubclasses 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>`)
- 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].
- 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.
<devtools-tree>Swap: ReplaceTreeOutlineInShadowwith
<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)
- 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.
- Universe Dependency Injection: When
Universedependencies 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).
- 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-apiESLint run does NOT prove a UI
Eng Vision migration is complete. The rule does not flag
extends UI.TreeOutline.TreeElementsubclasses,new MyTreeElementSubclass(...),
UI.InplaceEditor, unchainedcreateIcon()calls (for example, passed directly
to
this.setLeadingIcons([icon])), or unattached
new UI.{TabbedPane,TextPrompt,FilterBar}instances (when not
attached to
this.elementorthis.contentElement). Conversely, non-UI.Widget
helper classes that own
this.elementorthis.contentElementare flagged.
To inspect suppressed violations despite a file-level disable, run from the
devtools-frontendroot:
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:
- No Legacy Widgets: Zero references to
UI.TreeOutline,TreeElement
subclasses, UI.ListControl, UI.ListWidget, or UI.InplaceEditor.
- Standard MVP Constructor: Constructor accepts
element?: HTMLElementas
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.
- Widget Update Lifecycle: Renders exclusively via
override performUpdate(): void
and this.requestUpdate() (no custom #renderView() bypasses or synchronous
performUpdate() calls in presenter methods).
- 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.
- Declarative Primitives: Uses
<devtools-tree>,<devtools-list>,
persistent <devtools-prompt ?editing>, ?hidden=${...} exclusively
(without .hidden classes), and declarative autofocus for default focus.
- ES Private Fields & Config Cleanup: Uses ECMAScript
#privatefields 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>.