name: check-ui description: "Audit Python-to-JavaScript UI bindings for Gradio _js calls, global window exposure, and ui/globals.d.ts registration." argument-hint: "Optionally focus on a specific extension or module path"
Check Python-JavaScript UI Bindings
Audit SD.Next UI integration points where Python uses Gradio _js=... bindings to call JavaScript. Verify each JavaScript callback is exposed on the global window object and included in ui/globals.d.ts.
When To Use
- The user changes or reviews Python UI code under
modules/,scripts/, orextensions/with_js=callbacks. - A UI integration bug involves Python-triggered JavaScript functions.
- You need to validate UI contract consistency for Gradio-bound JS methods.
- User adds or updates extension with JavaScript code in
extensions/*/javascript.
Guidance
- Consult
.github/instructions/core.instructions.mdfor relevant core runtime guidance before proceeding.
Primary Files
ui/globals.d.tswiki/Dev-UI.mdmodules/**andscripts/**Python files that declare_js=valuesextensions/*/javascript/**TypeScript/JavaScript source files
Secondary Files To Inspect
ui/**/*.tsextensions-builtin/sdnext-modernui/src/**/*.tsextensions-builtin/sdnext-kanvas/src/**/*.tsextensions-builtin/sdnext-kanvas/javascript/kanvas.mjs
Audit Goals
For every Python _js usage, confirm:
- The referenced JS callback exists in code.
- The callback is assigned to
window.<name>or otherwise accessible as a global function. - The callback name is declared in
ui/globals.d.ts. - JavaScript-only methods called from Python are not implemented only as module-local exports.
For all extension JavaScript code under extensions/*/javascript, confirm:
- No missing JS callback registrations for Python-bound names.
- Global names are only used for Python bindings, not for code that should instead be imported.
ui/globals.d.tsremains the source of truth for Python-visible UI globals.
Procedure
1. Enumerate Python _js= Bindings
- Search
modules/,scripts/, andextensions/for_js=occurrences. - Capture the literal callback string values, including direct names and arrow-function expressions.
- For formatted strings, enumerate all possible callback names generated by the formatting pattern.
- Flag dynamic cases where the callback cannot be statically resolved.
This is the most complex part as _js can be assigned a direct string, a formatted string, or an inline function. Focus on extracting the intended callback name(s) for verification in the next steps.
Examples:
_js="send_to_kanvas"
_js=f"switch_to_{binding.tabname}"
_js=f'(x, y, i, j) => [x, y, ...selected_gallery_files("{tabname}")]'
_js='() => gallerySort("name")'
2. Enumerate any additional Extension JavaScript Sources
- Review
extensions/*/javascript,extensions-builtin/*/src, and the specific entry pointextensions-builtin/sdnext-kanvas/javascript/kanvas.mjsfor functions that attach towindow. - Confirm extension source files are the authoritative implementation, not generated build artifacts.
- Validate that any new JS entry points are registered by package build or extension initialization.
3. Verify JavaScript Exposure
- Search
ui/,extensions-builtin/sdnext-modernui/src/,extensions-builtin/sdnext-kanvas/src/, andextensions/*/javascript/for each callback name. - Confirm the callback is attached to
windowaswindow.<name> = ...or equivalent. - If the callback is an inline function string like
() => quickSaveStyle(), ensure the referenced helper exists and any helper used for Python integration is also globally available if needed.
4. Check TypeScript Declarations
- Open
ui/globals.d.tsand verify each Python-visible global callback name is declared. - Confirm the declaration shape is compatible with its usage if type annotations are present.
- If an extension exposes its own additional global helpers, verify the declaration file is updated accordingly.
5. Propose Fixes for Any Issues Found
- For missing global registrations, add
window.<name> = <function>in the appropriate JavaScript source file. - For missing
ui/globals.d.tsentries, add a declaration likedeclare global { function <name>(...args: any[]): any; }with appropriate types if possible.
6. Run UI Typecheck and Lint tests
- Run
pnpm eslintto ensure there are no linting errors. - Run
pnpm tscto ensure there are no type errors, which can catch missing or mismatched declarations. - Run
pnpm buildto ensure the extension builds correctly with the new or updated JavaScript code.
And fix any issues that arise from these checks.
Reporting Format
Report findings with:
- Python file and
_jsreference - JavaScript location and global registration status
ui/globals.d.tsdeclaration status- Severity: missing global, missing declaration, stale declaration, or dynamic/ambiguous binding
If no issues are found, state that the Python/JS UI binding audit is clear and mention whether any dynamic _js strings remain unresolved.
Output Expectations
When this skill is used, return:
- Total
_jsbindings inspected - Total missing or invalid global registrations
- Total missing or stale
ui/globals.d.tsentries - Summary of any ambiguous
_jscases that require manual review - A short summary of whether the UI binding contract is intact