Skip to content

feat: add interactive menu for managing MageForge Inspector actions - #240

Merged
dermatz merged 4 commits into
mainfrom
fix/inspector-command-menu
Aug 11, 2026
Merged

feat: add interactive menu for managing MageForge Inspector actions#240
dermatz merged 4 commits into
mainfrom
fix/inspector-command-menu

Conversation

@dermatz

@dermatz dermatz commented Aug 10, 2026

Copy link
Copy Markdown
Member

This pull request enhances the InspectorCommand to support an interactive mode for selecting actions, improving user experience when no action argument is provided. The command now presents a menu for enabling, disabling, or checking the status of the MageForge Inspector, with a fallback to status in non-interactive environments. The most important changes are:

Interactive Command Enhancements:

  • Made the action argument optional in the InspectorCommand so that if omitted, the user is presented with an interactive menu to choose an action. The help text was updated to reflect this new behavior.
  • Added a new promptAction method using Laravel\Prompts\SelectPrompt to display an interactive menu for selecting "enable", "disable", or "status". The menu shows the current inspector status and provides keyboard navigation hints.
  • Updated the command execution logic to invoke the interactive menu when no action is provided and to gracefully handle non-interactive terminals by defaulting to showing the status.
  • Imported the Laravel\Prompts\SelectPrompt class to support the new interactive prompt functionality.

Copilot AI lite review requested due to automatic review settings August 10, 2026 13:36

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.

Pull request overview

This PR enhances the mageforge:theme:inspector CLI command to support an interactive mode when no action argument is provided, improving usability for developers running the command in a real terminal.

Changes:

  • Made the action argument optional and updated help text to describe interactive behaviour.
  • Added an interactive action selector using Laravel\Prompts\SelectPrompt, with fallback to showing status in non-interactive environments.
  • Updated execution flow to prompt for “enable/disable/status” when appropriate.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Console/Command/Dev/InspectorCommand.php Outdated
Comment thread src/Console/Command/Dev/InspectorCommand.php
Copilot AI review requested due to automatic review settings August 10, 2026 14:51

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/Console/Command/Dev/InspectorCommand.php:154

  • promptAction() uses Laravel Prompts but doesn’t set/reset the prompt environment (used elsewhere for Docker/DDEV compatibility) and only restores TTY on the success path. If the prompt throws, the terminal may be left in a bad state and env vars won’t be restored.
        try {
            $selection = $prompt->prompt();
            \Laravel\Prompts\Prompt::terminal()->restoreTty();
            return is_string($selection) ? $selection : null;
        } catch (\Exception $e) {

src/Console/Command/Dev/InspectorCommand.php:103

  • The new “no action provided” behaviour (interactive prompt when possible; status fallback when non-interactive) isn’t covered by unit tests. There are existing unit tests for this command, so this new branch should be exercised to prevent regressions.
        // No action given: show interactive menu, fall back to status in non-interactive mode
        if ($action === '') {
            if (!$this->isInteractiveTerminal($output)) {
                return $this->showStatus();
            }

            $selectedAction = $this->promptAction();
            if ($selectedAction === null) {
                return Cli::RETURN_FAILURE;
            }
            $action = $selectedAction;
        }

src/Console/Command/Dev/InspectorCommand.php:62

  • Help text says the interactive menu is to “enable or disable” the inspector, but the menu also includes a “status” option; the help should reflect all available actions.
                  <info>php %command.full_name%</info>
                  Show an interactive menu to enable or disable the inspector

Copilot AI review requested due to automatic review settings August 10, 2026 15:02

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/Console/Command/Dev/InspectorCommand.php:101

  • When the interactive menu returns null (e.g. user cancels), the command exits with failure but prints no message. Adding a short warning/error improves UX and makes failures clearer in logs.
            if ($selectedAction === null) {
                return Cli::RETURN_FAILURE;
            }

src/Console/Command/Dev/InspectorCommand.php:94

  • The interactive menu is only gated by isInteractiveTerminal($output). This ignores Symfony's --no-interaction flag (InputInterface::isInteractive() becomes false), which can cause the command to block on a prompt in scripted/non-interactive runs even when the terminal is a real TTY.
            if (!$this->isInteractiveTerminal($output)) {

Copilot AI review requested due to automatic review settings August 11, 2026 05:53

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/Console/Command/Dev/InspectorCommand.php:152

  • setPromptEnvironment() is called after the SelectPrompt is constructed. In other commands (and AbstractCommand), the prompt environment is set before building the prompt so terminal dimensions/TERM are in place for prompt setup and rendering. Consider moving the environment setup above the new SelectPrompt(...) construction to avoid subtle rendering issues in Docker/DDEV terminals.
        // Set environment variables for Laravel Prompts (Docker/DDEV compatibility)
        $this->setPromptEnvironment();

src/Console/Command/Dev/InspectorCommand.php:162

  • In the finally block, if Prompt::terminal()->restoreTty() throws, resetPromptEnvironment() won’t run and the process environment can be left mutated (COLUMNS/LINES/TERM). Wrap the TTY restore in its own try/catch so prompt env reset always happens.
        } finally {
            \Laravel\Prompts\Prompt::terminal()->restoreTty();
            $this->resetPromptEnvironment();
        }

@dermatz
dermatz enabled auto-merge (squash) August 11, 2026 06:07
@dermatz
dermatz disabled auto-merge August 11, 2026 06:07
@dermatz
dermatz merged commit 412c63f into main Aug 11, 2026
21 checks passed
@dermatz
dermatz deleted the fix/inspector-command-menu branch August 11, 2026 06:07
@github-actions github-actions Bot mentioned this pull request Aug 11, 2026
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