Skip to content

Better support for workflows that involve multiple source directories#7738

Open
hatton wants to merge 9 commits intomasterfrom
BL-16014-MultipleDevExes
Open

Better support for workflows that involve multiple source directories#7738
hatton wants to merge 9 commits intomasterfrom
BL-16014-MultipleDevExes

Conversation

@hatton
Copy link
Member

@hatton hatton commented Mar 14, 2026

This change is Reviewable

hatton added 4 commits March 13, 2026 14:52
* an agent skill.md and scripts for starting, stopping, and connecting to Bloom.ex

* api/common/instanceInfo now gives information like the path to the exe file so that agents and tests can check that they are talking to the right bloom (vs. one in another worktree entirely)

Future:  allow multiple Blooms to be running.  e.g.
Add startup arguments for HTTP port and CDP port.
Bypass the single-instance token when given the ports.
Update the helper scripts to launch Bloom with explicit ports.
Make sure agents and tests kill the exact bloom they ran; they should be able to determine the pid.
Allows tests or agents to launch their own copies of bloom.exe on their own ports, lessoning the chance of stepping on other running versions running from different code directories.

Does not yet include any kind of principled random port choosing.
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Member Author

@hatton hatton left a comment

Choose a reason for hiding this comment

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

[GPT-5.4] Addressed the remaining feedback in ca63b5d and added line comments with the specifics.

@hatton hatton marked this pull request as ready for review March 14, 2026 22:00
Copilot AI review requested due to automatic review settings March 14, 2026 22:00
Copy link
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

This PR improves developer/automation workflows for running multiple Bloom instances (and/or multiple worktrees) by adding explicit startup port/label support, reserving a larger port block, and providing Node/Playwright tooling to launch and attach to the embedded WebView2 via CDP.

Changes:

  • Add startup parsing for --http-port, --cdp-port, --vite-port, and --label, and use these to support multi-instance startup flows.
  • Reserve a 3-port HTTP block (http, websocket, +1 extra reserved), expose common/instanceInfo, and improve Vite-dev port/origin handling.
  • Add automation scripts (watchBloomExe.mjs, go.mjs, bloom-automation helpers) and exe-backed Playwright smoke tests.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/BloomTests/ProgramTests.cs Adds unit tests for startup argument parsing and validation.
src/BloomExe/web/controllers/CommonApi.cs Adds common/instanceInfo endpoint for automation/runtime discovery.
src/BloomExe/web/ReactControl.cs Supports dynamic Vite dev ports and origin replacement; adds dev-server reachability checks.
src/BloomExe/web/BloomServer.cs Reserves a 3-port block; checks companion port availability; centralizes websocket port calculation.
src/BloomExe/Workspace/WorkspaceView.cs Replaces hard-coded websocket port math and supports Vite origin replacement in templates.
src/BloomExe/WebView2Browser.cs Makes remote debugging port configurable via --cdp-port (defaulting to 9222 only in DEBUG).
src/BloomExe/Shell.cs Updates window title to optionally show label and port summaries.
src/BloomExe/ProjectContext.cs Uses centralized websocket port accessor.
src/BloomExe/Edit/ToolboxView.cs Ensures Vite dev HTML templates use the correct origin when a non-default Vite port is chosen.
src/BloomExe/Edit/PageThumbnailList.cs Rewrites Vite dev origin in thumbnail list template when applicable.
src/BloomExe/Edit/EditingModel.cs Rewrites Vite dev origin in edit/page-list templates when applicable.
src/BloomExe/Book/Book.cs Stops hard-coding Vite origin; uses helper to build Vite dev URLs.
src/BloomBrowserUI/scripts/go.mjs New script to start Vite on a random/selected port, wait for readiness, then launch Bloom with matching --vite-port.
src/BloomBrowserUI/react_components/component-tester/playwright.bloom-exe.config.ts Adds a Playwright config for exe-backed UI tests.
src/BloomBrowserUI/react_components/component-tester/bloomExeCdp.ts Helpers to connect to Bloom’s embedded WebView2 over CDP and query workspace tab state.
src/BloomBrowserUI/react_components/TopBar/component-tests/bloom-exe-tabs.uitest.ts Adds exe-backed Playwright tests for tab switching and basic console/network observability.
src/BloomBrowserUI/react_components/TopBar/CollectionTopBarControls/component-tests/bloom-exe-collection-topbar.uitest.ts Adds an exe-backed Playwright smoke test for collection top bar controls.
src/BloomBrowserUI/package.json Adds exe and go scripts to launch watch/run and combined Vite+Exe flow.
scripts/watchBloomExe.mjs New repo-level launcher for dotnet watch run with explicit port leasing and readiness detection.
go.sh Convenience wrapper for running the combined go.mjs flow from repo root.
ReadMe.md Updates build/dev instructions to use ./go.sh; clarifies feedback env var guidance.
.github/skills/bloom-automation/webview2Targets.mjs Adds helper to list CDP targets (optionally selecting an instance via common/instanceInfo).
.github/skills/bloom-automation/switchWorkspaceTab.mjs Adds helper to attach via CDP and switch tabs by clicking the real top bar.
.github/skills/bloom-automation/killBloomProcess.mjs Adds helper to terminate Bloom/dotnet-watch processes with instance targeting.
.github/skills/bloom-automation/bloomProcessStatus.mjs Adds helper to report running Bloom/watch processes and endpoint reachability.
.github/skills/bloom-automation/bloomProcessCommon.mjs Shared automation utilities: port leasing, instance discovery, process classification, and endpoint helpers.
.github/skills/bloom-automation/SKILL.md Documents the new Bloom exe CDP automation workflow and helper commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import { fileURLToPath } from "node:url";

const standardBloomStartingHttpPort = 8089;
const standardBloomPortIncrement = 2;
errorMessage = $"Bloom requires a value after {optionName}.";
return true;
}

Comment on lines +845 to +849
&& StartupCdpPort.Value <= StartupHttpPort.Value + 2
)
{
errorMessage =
"Bloom's --cdp-port must not overlap the reserved HTTP block (http, http+1, http+2).";
Comment on lines +1489 to +1496
{
for (var i = 0; !success && i < kNumberOfPortsToTry; i++)
{
BloomServer.portForHttp = kStartingPort + (i * kNumberOfPortsWeNeed);
success =
AreReservedCompanionPortsAvailable(BloomServer.portForHttp)
&& AttemptToOpenPort();
}
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 new potential issues.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment on lines +29 to +37
private static int? kDefaultRemoteDebuggingPort =>
#if DEBUG
9222;
#else
null;
#endif

public static int? RemoteDebuggingPort =>
Program.StartupCdpPort ?? kDefaultRemoteDebuggingPort;

Choose a reason for hiding this comment

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

🚩 Remote debugging port now exposed in release builds when --cdp-port is passed

Previously, --remote-debugging-port=9222 was only added in DEBUG builds (src/BloomExe/WebView2Browser.cs:289-291 old code had #region DEBUG). Now RemoteDebuggingPort (src/BloomExe/WebView2Browser.cs:36-37) returns Program.StartupCdpPort ?? kDefaultRemoteDebuggingPort, where kDefaultRemoteDebuggingPort is 9222 in DEBUG and null in RELEASE. Passing --cdp-port on the command line would enable remote debugging in a release build. This is by design for automation, but worth noting that it opens a CDP port that could be accessed by other local processes.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Contributor

@nabalone nabalone left a comment

Choose a reason for hiding this comment

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

I didn't really review the .mjs scripts, thinking we would notice if there's something wrong with them. But let me know if I should


var remainingArgs = new List<string>();

for (var i = 0; i < args.Length; i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

[Worded by Devin]

Suggestion: consider simplifying this hand-rolled argument loop

This codebase already uses the CommandLineParser NuGet library (imported at , used at lines 214–264 with attribute-decorated classes like HydrateParameters in ). The 120-line hand-rolled loop here is inconsistent with that existing pattern.

Duplication: The three port option blocks (lines 746–812) are near-identical copy-paste that differ only in the option name and backing property. A dictionary-driven approach or a small shared helper could cut the loop body to ~20 lines:

var portOptions = new Dictionary<string, Action>
{
["--http-port"] = v => StartupHttpPort = SetOnce(StartupHttpPort, v, "--http-port"),
["--cdp-port"] = v => StartupCdpPort = SetOnce(StartupCdpPort, v, "--cdp-port"),
["--vite-port"] = v => StartupVitePort = SetOnce(StartupVitePort, v, "--vite-port"),
};

Bug — --label swallows flags: TryParseStartupStringArgument (line 876) unconditionally accepts the next token as the value, so --label --help silently treats --help as the label. The Node.js helpers in this same PR explicitly reject values starting with -- (e.g. requireOptionValue in bloomProcessCommon.mjs), but the C# side doesn't.

Magic number: The overlap check at line 845 hard-codes + 2 instead of referencing BloomServer.ReservedPortBlockLength, as also noted in the existing Copilot review thread.

Not blocking, but worth a cleanup pass — especially the --label flag-swallowing issue.

Copy link
Contributor

@nabalone nabalone Mar 23, 2026

Choose a reason for hiding this comment

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

If we want to keep Program.cs clean I thought this might be worth doing, and an AI could do it quickly. But feel free to ignore and merge

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