Skip to content

fix(cli): recognize BuildKit sandbox build progress (Fixes #2311)#2404

Open
deepujain wants to merge 1 commit intoNVIDIA:mainfrom
deepujain:fix/2311-buildkit-progress
Open

fix(cli): recognize BuildKit sandbox build progress (Fixes #2311)#2404
deepujain wants to merge 1 commit intoNVIDIA:mainfrom
deepujain:fix/2311-buildkit-progress

Conversation

@deepujain
Copy link
Copy Markdown
Contributor

@deepujain deepujain commented Apr 24, 2026

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

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 verifying BuildKit-formatted progress lines are captured, surfaced in output, and reported to the log callback.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Apr 24, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dfa73f1e-6575-4789-a1aa-d0a729060dc9

📥 Commits

Reviewing files that changed from the base of the PR and between 065412c and d17b8f1.

📒 Files selected for processing (2)
  • src/lib/sandbox-create-stream.test.ts
  • src/lib/sandbox-create-stream.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/sandbox-create-stream.test.ts
  • src/lib/sandbox-create-stream.ts

📝 Walkthrough

Walkthrough

Adds BuildKit progress recognition to the sandbox build stream: centralizes regex patterns for build/upload phases, introduces an exported BUILD_PROGRESS_PATTERNS constant, refactors visible-progress filtering, and adds a vitest that emits BuildKit-formatted progress lines and asserts correct collection, phase detection, and callback invocation.

Changes

Cohort / File(s) Summary
Build / progress parsing
src/lib/sandbox-create-stream.ts
Centralizes and extends progress-detection regexes: introduces exported BUILD_PROGRESS_PATTERNS: readonly RegExp[], replaces legacy-only checks with shared BUILD_PROGRESS_PATTERNS / UPLOAD_PROGRESS_PATTERNS, and refactors shouldShowLine to use aggregated VISIBLE_PROGRESS_PATTERNS so BuildKit (#n [...], `#n (DONE
Test: BuildKit progress handling
src/lib/sandbox-create-stream.test.ts
Adds a vitest case that emits BuildKit-style stdout lines (e.g., #1 ...) and exits 0; asserts streamSandboxCreate resolves with status: 0, that sawProgress is true, the emitted #1 ... line appears in collected output, and the logLine callback is called with each exact progress line.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through logs both old and new,
Counting hashes, one, two, three — woohoo!
BuildKit whispers in rhythmic lines,
I nibbled patterns, marked the signs.
Hooray — progress seen, the stream says "true"! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly summarizes the main change: adding BuildKit progress recognition to the sandbox build stream parser, directly addressing the linked issue #2311.
Linked Issues check ✅ Passed Changes fully implement the NemoClaw portion of issue #2311: recognize BuildKit output patterns (step lines and completion markers) and track build phase while preserving legacy builder support.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objectives: test additions verify BuildKit progress output, and parser updates add BuildKit pattern recognition while maintaining legacy-builder compatibility.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 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 flushLine and shouldShowLine. 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

📥 Commits

Reviewing files that changed from the base of the PR and between dc02013 and 065412c.

📒 Files selected for processing (2)
  • src/lib/sandbox-create-stream.test.ts
  • src/lib/sandbox-create-stream.ts

Fixes NVIDIA#2311

Signed-off-by: Deepak Jain <deepujain@gmail.com>
@deepujain deepujain force-pushed the fix/2311-buildkit-progress branch from 065412c to d17b8f1 Compare April 24, 2026 02:18
@deepujain
Copy link
Copy Markdown
Contributor Author

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.

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.

OpenShell uses legacy Docker builder instead of BuildKit

1 participant