Skip to content

fix(cli): allow Explorer launches to open the web UI - #166

Open
zhengzeyi wants to merge 1 commit into
banbox:mainfrom
zhengzeyi:fix/allow-explorer-web-launch
Open

fix(cli): allow Explorer launches to open the web UI#166
zhengzeyi wants to merge 1 commit into
banbox:mainfrom
zhengzeyi:fix/allow-explorer-web-launch

Conversation

@zhengzeyi

Copy link
Copy Markdown
Contributor

Summary

  • Disable Cobra's Windows Explorer mousetrap prompt in entry.RunCmd.
  • Preserve Banbot's existing no-argument Web UI launch path when bot.exe is opened from Explorer.

Testing

  • Not run (source-only compatibility change; no binary build requested).

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix Windows Explorer launch by disabling Cobra mousetrap prompt

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Disable Cobra’s Windows Explorer mousetrap prompt during CLI startup.
• Preserve no-argument behavior so opening bot.exe launches the Web UI.
Diagram

graph TD
  A([Windows Explorer]) --> B["entry/main.go"] --> C["entry.RunCmd"] --> D["cobra.MousetrapHelpText = \"\""] --> E["Execute(os.Args[1:])"]

  subgraph Legend
    direction LR
    _ui([User action]) ~~~ _code["Go code"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Disable mousetrap only on Windows builds
  • ➕ Avoids changing global Cobra behavior on non-Windows platforms
  • ➕ Makes intent explicit (Windows-only workaround)
  • ➖ Requires build tags or runtime OS branching
  • ➖ Adds complexity for minimal practical benefit (Cobra only uses it on Windows)
2. Handle Explorer/no-arg launch before Cobra Execute
  • ➕ Bypasses Cobra entirely for the web UI path, avoiding related prompts
  • ➕ Keeps Cobra defaults unchanged for normal CLI invocations
  • ➖ Splits startup logic and can drift from Cobra’s argument semantics
  • ➖ More invasive change than needed for the prompt suppression

Recommendation: Current approach is appropriate: setting cobra.MousetrapHelpText to an empty string is the smallest, targeted change that prevents the Explorer prompt while keeping existing no-arg behavior intact. If reviewers are concerned about global side effects, consider gating the assignment to Windows only, but that likely isn’t necessary in practice.

Files changed (1) +1 / -0

Bug fix (1) +1 / -0
main.goDisable Cobra Windows mousetrap help text before Execute() +1/-0

Disable Cobra Windows mousetrap help text before Execute()

• Sets cobra.MousetrapHelpText to an empty string during CLI initialization. This prevents Cobra’s Windows Explorer “mousetrap” prompt from interfering with no-argument launches that should open the Web UI.

entry/main.go

@sonarqubecloud

Copy link
Copy Markdown

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant