Skip to content

feat(inspector): add 1-click template override and open in IDE - #303

Open
dermatz wants to merge 2 commits into
mainfrom
feature/inspector-ide-override
Open

dermatz wants to merge 2 commits into
mainfrom
feature/inspector-ide-override

Conversation

@dermatz

@dermatz dermatz commented Nov 30, 2026

Copy link
Copy Markdown
Member

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.

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>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants