fix(cli): recognize BuildKit sandbox build progress (Fixes #2311)#2404
Conversation
📝 WalkthroughWalkthroughCentralizes regex-based detection for build/upload progress in the sandbox stream, exports Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/sandbox-create-stream.ts (1)
125-130: Consider centralizing progress regexes to avoid parser drift.The same patterns are duplicated between
flushLineandshouldShowLine. A shared matcher keeps future edits safer.♻️ Suggested refactor
+const BUILD_PROGRESS_PATTERNS: RegExp[] = [ + /^ {2}Building image /, + /^ {2}Step \d+\/\d+ : /, + /^#\d+ \[/, + /^#\d+ (DONE|CACHED)\b/, +]; + +const UPLOAD_PROGRESS_PATTERNS: RegExp[] = [ + /^ {2}Pushing image /, + /^\s*\[progress\]/, + /^ {2}Image .*available in the gateway/, +]; + +const VISIBLE_PROGRESS_PATTERNS: RegExp[] = [ + ...BUILD_PROGRESS_PATTERNS, + /^ {2}Context: /, + /^ {2}Gateway: /, + /^Successfully built /, + /^Successfully tagged /, + /^ {2}Built image /, + ...UPLOAD_PROGRESS_PATTERNS, + /^Created sandbox: /, + /^✓ /, +]; + +function matchesAny(line: string, patterns: readonly RegExp[]) { + return patterns.some((re) => re.test(line)); +} ... - if ( - /^ {2}Building image /.test(line) || - /^ {2}Step \d+\/\d+ : /.test(line) || - /^#\d+ \[/.test(line) || - /^#\d+ (DONE|CACHED)\b/.test(line) - ) { + if (matchesAny(line, BUILD_PROGRESS_PATTERNS)) { setPhase("build"); - } else if ( - /^ {2}Pushing image /.test(line) || - /^\s*\[progress\]/.test(line) || - /^ {2}Image .*available in the gateway/.test(line) - ) { + } else if (matchesAny(line, UPLOAD_PROGRESS_PATTERNS)) { setPhase("upload"); ... - return ( - /^ {2}Building image /.test(line) || - /^ {2}Step \d+\/\d+ : /.test(line) || - /^#\d+ \[/.test(line) || - /^#\d+ (DONE|CACHED)\b/.test(line) || - ... - /^✓ /.test(line) - ); + return matchesAny(line, VISIBLE_PROGRESS_PATTERNS);Also applies to: 147-164
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/sandbox-create-stream.ts` around lines 125 - 130, The duplicated Docker progress regexes used in flushLine and shouldShowLine should be centralized into a single exported constant (e.g., PROGRESS_REGEXES or progressMatchers) and reused by both functions; update flushLine and shouldShowLine to iterate over that shared array of RegExp objects (or test each with .some) instead of repeating the same literal patterns so future changes only need to be made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/sandbox-create-stream.ts`:
- Around line 125-130: The duplicated Docker progress regexes used in flushLine
and shouldShowLine should be centralized into a single exported constant (e.g.,
PROGRESS_REGEXES or progressMatchers) and reused by both functions; update
flushLine and shouldShowLine to iterate over that shared array of RegExp objects
(or test each with .some) instead of repeating the same literal patterns so
future changes only need to be made in one place.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 70d3bb59-a42a-43bd-94f1-73854b7510d9
📒 Files selected for processing (2)
src/lib/sandbox-create-stream.test.tssrc/lib/sandbox-create-stream.ts
065412c to
d17b8f1
Compare
|
Centralized the BuildKit and legacy progress matchers so phase detection and visible-output filtering share the same patterns. Reran npm run build:cli, npm run typecheck:cli, and npm test -- src/lib/sandbox-create-stream.test.ts. |
|
✨ Thanks for submitting this pull request that proposes a way to fix a bug that causes NemoClaw's sandbox create stream to not recognize BuildKit sandbox build progress. This identifies a bug and proposes a change to recognize BuildKit progress markers. The addition of a focused test to verify the lines are logged and collected in output will help ensure the issue does not recur. Related open issues: |
Fixes NVIDIA#2311 Signed-off-by: Deepak Jain <deepujain@gmail.com>
d17b8f1 to
c468381
Compare
|
Rebased on latest main, no code changes needed beyond replay. npm test -- src/lib/sandbox-create-stream.test.ts passes. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/sandbox-create-stream.test.ts (1)
76-76: Remove theas nevercast fromspawnImpl.Line 76 uses
child as never, while all other tests in this file (lines 35, 48, 103, 130, 148, 170, 191) usespawnImpl: () => childdirectly. SinceFakeChildimplementsStreamableChildProcess, the cast is unnecessary and suppresses type safety without benefit. Removing it ensures consistency across the test suite.Proposed change
- spawnImpl: () => child as never, + spawnImpl: () => child,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/sandbox-create-stream.test.ts` at line 76, Remove the unnecessary type cast on the spawnImpl return value: update the test's spawnImpl: () => child as never to simply spawnImpl: () => child because FakeChild already implements StreamableChildProcess; this restores type safety and matches other tests (see spawnImpl usage and the FakeChild/StreamableChildProcess types).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/sandbox-create-stream.test.ts`:
- Line 76: Remove the unnecessary type cast on the spawnImpl return value:
update the test's spawnImpl: () => child as never to simply spawnImpl: () =>
child because FakeChild already implements StreamableChildProcess; this restores
type safety and matches other tests (see spawnImpl usage and the
FakeChild/StreamableChildProcess types).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 8f44a91a-bdac-49fc-8a88-0f7ed5bcfd73
📒 Files selected for processing (2)
src/lib/sandbox-create-stream.test.tssrc/lib/sandbox-create-stream.ts
) ## Summary NemoClaw's sandbox create stream only recognized the legacy Docker builder format, so BuildKit output would not be treated as active build progress once OpenShell emits it. This adds BuildKit progress markers to the same parser path as the existing legacy builder output. It keeps the current legacy behavior and makes `#1 [internal] ...`, `#2 CACHED`, and `#3 DONE ...` visible as build progress. ## Changes - `src/lib/sandbox-create-stream.ts`: recognize BuildKit step and completion lines while tracking the build phase. - `src/lib/sandbox-create-stream.test.ts`: cover BuildKit progress output and verify it is streamed to the user. ## Testing - `npm run build:cli` passed - `npm run typecheck:cli` passed - `npm test -- src/lib/sandbox-create-stream.test.ts` passed - `npm test` was also attempted. The full suite is not green on current main in this environment; failures are in existing installer/onboard/legacy-guard tests outside this change. ## Evidence it works The new focused test feeds BuildKit-style output into `streamSandboxCreate` and verifies that the lines are logged, collected in output, and mark sandbox creation as having seen progress. Fixes #2311 Signed-off-by: Deepak Jain <deepujain@gmail.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved detection and display of BuildKit and upload progress so progress markers and completion states are recognized reliably. * **Refactor** * Centralized progress-detection logic for more consistent handling of build and upload output. * **Tests** * Added a test ensuring BuildKit-formatted progress lines are captured, included in output, and reported to the log callback. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Deepak Jain <deepujain@gmail.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com>
… (NVIDIA#2404) ## Summary NemoClaw's sandbox create stream only recognized the legacy Docker builder format, so BuildKit output would not be treated as active build progress once OpenShell emits it. This adds BuildKit progress markers to the same parser path as the existing legacy builder output. It keeps the current legacy behavior and makes `NVIDIA#1 [internal] ...`, `NVIDIA#2 CACHED`, and `NVIDIA#3 DONE ...` visible as build progress. ## Changes - `src/lib/sandbox-create-stream.ts`: recognize BuildKit step and completion lines while tracking the build phase. - `src/lib/sandbox-create-stream.test.ts`: cover BuildKit progress output and verify it is streamed to the user. ## Testing - `npm run build:cli` passed - `npm run typecheck:cli` passed - `npm test -- src/lib/sandbox-create-stream.test.ts` passed - `npm test` was also attempted. The full suite is not green on current main in this environment; failures are in existing installer/onboard/legacy-guard tests outside this change. ## Evidence it works The new focused test feeds BuildKit-style output into `streamSandboxCreate` and verifies that the lines are logged, collected in output, and mark sandbox creation as having seen progress. Fixes NVIDIA#2311 Signed-off-by: Deepak Jain <deepujain@gmail.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved detection and display of BuildKit and upload progress so progress markers and completion states are recognized reliably. * **Refactor** * Centralized progress-detection logic for more consistent handling of build and upload output. * **Tests** * Added a test ensuring BuildKit-formatted progress lines are captured, included in output, and reported to the log callback. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Deepak Jain <deepujain@gmail.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com>
Summary
NemoClaw's sandbox create stream only recognized the legacy Docker builder format, so BuildKit output would not be treated as active build progress once OpenShell emits it.
This adds BuildKit progress markers to the same parser path as the existing legacy builder output. It keeps the current legacy behavior and makes
#1 [internal] ...,#2 CACHED, and#3 DONE ...visible as build progress.Changes
src/lib/sandbox-create-stream.ts: recognize BuildKit step and completion lines while tracking the build phase.src/lib/sandbox-create-stream.test.ts: cover BuildKit progress output and verify it is streamed to the user.Testing
npm run build:clipassednpm run typecheck:clipassednpm test -- src/lib/sandbox-create-stream.test.tspassednpm testwas also attempted. The full suite is not green on current main in this environment; failures are in existing installer/onboard/legacy-guard tests outside this change.Evidence it works
The new focused test feeds BuildKit-style output into
streamSandboxCreateand verifies that the lines are logged, collected in output, and mark sandbox creation as having seen progress.Fixes #2311
Signed-off-by: Deepak Jain deepujain@gmail.com
Summary by CodeRabbit
Bug Fixes
Refactor
Tests