fix: DevFlow broker daemon spawn args#175
Conversation
BrokerClient.EnsureBrokerRunningAsync was launching the daemon as \`maui broker start --foreground\` but the actual command path is \`maui devflow broker start --foreground\`. The daemon process exited immediately with "Unrecognized command or argument 'broker'", and any \`maui devflow ...\` invocation that auto-spawned the broker failed with "Broker unavailable". Insert \`devflow \` before \`broker\` in both spawn argument paths (in-place \`maui\` exe and \`dotnet <dll>\` framework-dependent path). Repro before the fix: maui devflow wait > [DevFlow Broker] Daemon process exited prematurely with code 1 > [DevFlow Broker] stderr: Unrecognized command or argument 'broker'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes DevFlow broker auto-spawn by correcting the CLI argv used when launching the broker daemon, ensuring maui devflow ... commands can start the broker successfully when it isn’t already running.
Changes:
- Add the missing
devflowsegment to broker daemon spawn arguments for both framework-dependent (dotnet <dll> ...) and self-contained executable paths. - Align the broker startup invocation with the documented/expected command shape:
maui devflow broker start --foreground.
Show a summary per file
| File | Description |
|---|---|
| src/Cli/Microsoft.Maui.Cli/DevFlow/Broker/BrokerClient.cs | Fixes broker daemon spawn args so auto-start uses devflow broker ... instead of broker .... |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
| } | ||
| fileName = exePath; | ||
| arguments = $"\"{dllPath}\" broker start --foreground"; | ||
| arguments = $"\"{dllPath}\" devflow broker start --foreground"; |
There was a problem hiding this comment.
The comment immediately above this branch still says the daemon is started with dotnet <entryDll> broker start --foreground, but the actual spawn args now include devflow broker .... Please update that comment to match the new argv so future changes don’t reintroduce this bug.
There was a problem hiding this comment.
Expert Code Review — fix: DevFlow broker daemon spawn args
Methodology: 3 independent reviewers with adversarial consensus.
✅ Verdict: Fix is correct
All 3 reviewers independently confirmed the two-line change correctly inserts the missing devflow subcommand in both broker daemon spawn paths (native-exe and dotnet <dll>). No other spawn paths exist in the codebase. Callers of EnsureBrokerRunningAsync / StartBrokerAsync are unaffected — they consume the returned port, not the argv.
Checks performed by reviewers:
- Full source file read of
BrokerClient.cs - Traced all callers (5 sites in
DevFlowCommands.csandMcpAgentSession.cs) - Searched codebase for other broker spawn arg construction — none found
- Verified
ProcessStartInfoflags, stderr capture, polling loop unchanged - No race conditions, security issues, or data loss risks
Findings
| # | Severity | File | Line | Consensus | Finding |
|---|---|---|---|---|---|
| 1 | 🟢 MINOR | src/Cli/Microsoft.Maui.Cli/DevFlow/Broker/BrokerClient.cs |
235 (outside diff) | 3/3 reviewers | Stale comment not updated. The inline comment still reads use dotnet <entryDll> broker start --foreground but should now read dotnet <entryDll> devflow broker start --foreground to match the corrected spawn args. No runtime impact, but could mislead future maintainers. |
Recommendation for Finding #1: Update the comment on line 235 to include the devflow prefix, matching the corrected arguments.
CI Status
| Check | Status |
|---|---|
build / build (macos-latest) |
🟡 In progress |
build / build (windows-latest) |
🟡 In progress |
license/cla |
✅ Passed |
Test coverage: No unit tests cover StartBrokerAsync (it spawns a real process). This is a pre-existing gap, not introduced by this PR.
Generated by Expert Code Review (auto) for issue #175 · ● 2.5M
Comment previously referred to the old 'broker start --foreground' argv that pre-dated the devflow subcommand split; it now reflects the actual 'devflow broker start --foreground' invocation. Addresses review feedback on #175. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment previously referred to the old 'broker start --foreground' argv that pre-dated the devflow subcommand split; it now reflects the actual 'devflow broker start --foreground' invocation. Addresses review feedback on #175. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7368cff to
d585b64
Compare
Repro
Root cause
BrokerClient.EnsureBrokerRunningAsyncspawned the daemon with the wrong argv. The command path ismaui devflow broker start --foreground, but the spawn args weremaui broker start --foreground(anddotnet <dll> broker start --foregroundon the framework-dependent path). The daemon exited immediately, and everymaui devflow ...that auto-spawned the broker failed.Fix
Insert
devflowbeforebrokerin both spawn argument paths insrc/Cli/Microsoft.Maui.Cli/DevFlow/Broker/BrokerClient.cs(lines 246, 251).Validation
After applying the fix and reinstalling
mauiglobally,maui devflow waitcorrectly auto-starts the broker on port 19223 and waits for an agent. Verified with a running BaristaNotes agent.