Skip to content

fix: DevFlow broker daemon spawn args#175

Merged
Redth merged 2 commits into
mainfrom
fix/broker-spawn-devflow-prefix
Apr 28, 2026
Merged

fix: DevFlow broker daemon spawn args#175
Redth merged 2 commits into
mainfrom
fix/broker-spawn-devflow-prefix

Conversation

@davidortinau
Copy link
Copy Markdown
Contributor

Repro

$ maui devflow wait
[DevFlow Broker] Daemon process exited prematurely with code 1
[DevFlow Broker] stderr: Unrecognized command or argument 'broker'.
[DevFlow Broker] stderr: Unrecognized command or argument 'start'.
[DevFlow Broker] stderr: Unrecognized command or argument '--foreground'.
Error: Broker unavailable

Root cause

BrokerClient.EnsureBrokerRunningAsync spawned the daemon with the wrong argv. The command path is maui devflow broker start --foreground, but the spawn args were maui broker start --foreground (and dotnet <dll> broker start --foreground on the framework-dependent path). The daemon exited immediately, and every maui devflow ... that auto-spawned the broker failed.

Fix

Insert devflow before broker in both spawn argument paths in src/Cli/Microsoft.Maui.Cli/DevFlow/Broker/BrokerClient.cs (lines 246, 251).

Validation

After applying the fix and reinstalling maui globally, maui devflow wait correctly auto-starts the broker on port 19223 and waits for an agent. Verified with a running BaristaNotes agent.

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>
Copilot AI review requested due to automatic review settings April 28, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 devflow segment 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";
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

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.cs and McpAgentSession.cs)
  • Searched codebase for other broker spawn arg construction — none found
  • Verified ProcessStartInfo flags, 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

davidortinau added a commit that referenced this pull request Apr 28, 2026
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>
@davidortinau davidortinau force-pushed the fix/broker-spawn-devflow-prefix branch from 7368cff to d585b64 Compare April 28, 2026 22:25
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.

3 participants