Repository navigation
Conversation
Allow opening templates directly in PhpStorm, VS Code, Cursor, Zed, Sublime Text, or a custom editor URL from the frontend Inspector with browser-saved host path mapping for Docker/DDEV setups. Add an HMAC-protected developer endpoint and theme selector to create template overrides in editable frontend themes and clean affected caches in one click. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Template overrides can copy the wrong source and redirect later IDE actions to an unrendered file, while synthetic IDE-link clicks can cancel navigation or close the Inspector.
3 open issues
What changed in this PR
Extends the Magento frontend Inspector with direct editor access and browser-triggered template overrides, reusing the existing template parsing and copying services.
Changes:
- Adds editor selection and browser-saved host path mapping for Docker/DDEV setups.
- Adds a developer-restricted override endpoint, target-theme selector, and automatic cache cleaning.
- Adds backend unit tests and documents the new Inspector actions.
| File | Description |
|---|---|
tests/Unit/Service/TemplateOverride/BrowserTemplateOverriderTest.php |
Tests override validation, copying, fallback resolution, and cache cleaning. |
tests/Unit/Service/Inspector/OverrideTokenManagerTest.php |
Tests token generation and validation. |
tests/Unit/Controller/Inspector/OverrideTest.php |
Tests endpoint access checks, payloads, and responses. |
tests/Unit/Block/InspectorTest.php |
Tests endpoint metadata and theme selection data. |
src/view/frontend/web/js/inspector/tabs.js |
Adds template actions to structure sections. |
src/view/frontend/web/js/inspector/picker.js |
Resets IDE settings state when closing or unpinning. |
src/view/frontend/web/js/inspector/ide.js |
Implements editor links, path mapping, and override controls. |
src/view/frontend/web/js/inspector/draggable.js |
Excludes new interactive controls from dragging. |
src/view/frontend/web/js/inspector.js |
Registers and initialises IDE integration. |
src/view/frontend/web/css/inspector.css |
Styles template actions and IDE settings. |
src/view/frontend/templates/inspector.phtml |
Exposes endpoint, token, path, and theme metadata. |
src/Service/TemplateOverride/BrowserTemplateOverrider.php |
Creates theme overrides and cleans affected caches. |
src/Service/Inspector/OverrideTokenManager.php |
Generates and validates override request tokens. |
src/Model/TemplateOverrideResult.php |
Carries override results and file paths. |
src/etc/frontend/routes.xml |
Registers the frontend endpoint route. |
src/Controller/Inspector/Override.php |
Handles protected override requests and JSON responses. |
src/Block/Inspector.php |
Supplies IDE and theme metadata to the Inspector. |
README.md |
Documents Open in IDE and Override & Open. |
Review effort: Balanced
| )); | ||
| } | ||
|
|
||
| $sourceFile = $this->fallbackResolver->findFirstExistingFile($fallbackDirs, $templatePath); |
| link.rel = "noopener noreferrer"; | ||
| link.style.display = "none"; | ||
| document.body.appendChild(link); | ||
| link.click(); |
| return; | ||
| } | ||
|
|
||
| this.applyOverridePathToElement(element, payload.targetPath); |
Split template section and IDE settings DOM builders into focused helper methods, drop unused initial assignment in tabs.js, and replace redundant ini_get string casts flagged by Mago 1.62. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Path-encoding and mapping bugs break IDE links, override responses can assign incorrect template metadata to blocks, and the IDE selector lacks an accessible name.
8 open issues
Escape URL fragments in IDE file paths · New Preserve absolute paths for external templates · New Ignore stale override responses for inactive elements · New Keep unrelated override paths out of rendered-template metadata · New Associate the IDE selector with an accessible label · New Preserve rendered template metadata when creating an unrelated override Stop synthetic IDE link clicks from reaching the picker handler Resolve override source from the inspected theme, not the target theme
Review effort: Balanced
Comment on lines
+19
to
+29
| `vscode://file/${encodeURI(file.replace(/^\/+/, ""))}:${line}`, | ||
| }, | ||
| cursor: { | ||
| label: "Cursor", | ||
| buildUrl: (file, line) => | ||
| `cursor://file/${encodeURI(file.replace(/^\/+/, ""))}:${line}`, | ||
| }, | ||
| zed: { | ||
| label: "Zed", | ||
| buildUrl: (file, line) => | ||
| `zed://file/${encodeURI(file.replace(/^\/+/, ""))}:${line}`, |
Comment on lines
+204
to
+207
| resolveHostFilePath(relativePath) { | ||
| const cleanRel = (relativePath || "") | ||
| .replace(/\\/g, "/") | ||
| .replace(/^\/+/, ""); |
Comment on lines
+289
to
+300
| try { | ||
| const payload = await this.sendOverrideRequest(data.template); | ||
| this.handleOverrideResponse(payload, element); | ||
| } catch (error) { | ||
| this.ideStatusMessage = { | ||
| type: "error", | ||
| text: error?.message || "Network error while creating override.", | ||
| }; | ||
| } finally { | ||
| this.isOverridingTemplate = false; | ||
| this.refreshCurrentBadge(element); | ||
| } |
| * Update local DOM metadata and open the overridden template in IDE | ||
| */ | ||
| handleOverrideResponse(payload, element) { | ||
| this.applyOverridePathToElement(element, payload.targetPath); |
| editorLabel.textContent = "Editor / IDE"; | ||
|
|
||
| const editorSelect = document.createElement("select"); | ||
| editorSelect.className = "mageforge-ide-select"; |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Allow opening templates directly in PhpStorm, VS Code, Cursor, Zed, Sublime Text, or a custom editor URL from the frontend Inspector with browser-saved host path mapping for Docker/DDEV setups. Add an HMAC-protected developer endpoint and theme selector to create template overrides in editable frontend themes and clean affected caches in one click.