Skip to content

refactor(onboard): extract web search support helper - #3302

Merged
cv merged 66 commits into
mainfrom
refactor/onboard-web-search-support
May 13, 2026
Merged

refactor(onboard): extract web search support helper#3302
cv merged 66 commits into
mainfrom
refactor/onboard-web-search-support

Conversation

@cv

@cv cv commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Extract the web-search support detection helper out of the large onboarding module. This keeps the onboarding cleanup stack moving with a small behavior-preserving split and direct coverage for Dockerfile support detection.

Changes

  • Add src/lib/onboard/web-search-support.ts for determining whether an agent image supports the NEMOCLAW_WEB_SEARCH_ENABLED Dockerfile ARG.
  • Update src/lib/onboard.ts to import the support helper while preserving existing agentSupportsWebSearch exports and call sites.
  • Add unit tests covering Hermes suppression, override Dockerfiles, agent Dockerfile fallback, root Dockerfile fallback, and unsupported Dockerfiles.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • Refactor

    • Web-search support detection reorganized into a dedicated module for improved maintainability and clearer behavior.
  • Tests

    • Added comprehensive test suite covering web-search availability across agents and Dockerfile configurations.

Review Change Stack

@cv cv self-assigned this May 9, 2026
@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

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: f0d7b20b-d503-49a6-ae17-babeffcabb8b

📥 Commits

Reviewing files that changed from the base of the PR and between 0154408 and 2b7b3e9.

📒 Files selected for processing (1)
  • src/lib/onboard/web-search-support.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/onboard/web-search-support.test.ts

📝 Walkthrough

Walkthrough

Extracts web-search detection into src/lib/onboard/web-search-support.ts (new WebSearchAgent type and agentSupportsWebSearch()), adds Vitest coverage, and updates src/lib/onboard.ts to import and call the helper (passing ROOT) in configure and resume flows.

Changes

Web Search Support Extraction

Layer / File(s) Summary
Web-search support utility
src/lib/onboard/web-search-support.ts
New module exports WebSearchAgent type and agentSupportsWebSearch(agent, dockerfilePathOverride, rootDir) function that detects web-search capability by checking candidate Dockerfile paths (override, agent-specific, root) for ARG NEMOCLAW_WEB_SEARCH_ENABLED=, explicitly returning false for hermes agent and handling missing files gracefully.
Web-search support tests
src/lib/onboard/web-search-support.test.ts
Vitest suite with temporary directory helpers and five test cases validating hermes exclusion, override path precedence, fallback ordering between agent and root Dockerfiles, false return when no candidate declares the web-search ARG, and true return when root Dockerfile declares the ARG despite missing agent Dockerfile.
Integration into onboarding
src/lib/onboard.ts
Imports agentSupportsWebSearch from the new utility module and updates configureWebSearch() and resume/recreate paths to call the helper with ROOT argument, replacing previous inline detection logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • ericksoa
  • jyaunches
  • prekshivyas

Poem

🐰 I hopped through Dockerfile trails today,
sniffed for ARGs along the way,
Hermes sleeps; others get a peek,
helper born and tests to speak,
onboarding sings—search is on display! 🔍

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 The title 'refactor(onboard): extract web search support helper' clearly and concisely summarizes the main change—extracting web-search support detection logic into a dedicated helper module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/onboard-web-search-support

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

@cv
cv marked this pull request as draft May 9, 2026 01:23
@copy-pr-bot

copy-pr-bot Bot commented May 9, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@copy-pr-bot

copy-pr-bot Bot commented May 9, 2026

Copy link
Copy Markdown

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.

@cv cv added v0.0.40 and removed v0.0.39 labels May 12, 2026

@cjagwani cjagwani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm — clean 1:1 extraction, behavior preserved at both call sites in onboard.ts (both pass ROOT explicitly).

one nit not worth blocking on: rootDir = process.cwd() default is a small semantic drift from the old code which closed over ROOT (resolved via __dirname). prod is fine since callers pass ROOT, but test/onboard.test.ts:2150-2152 now relies on cwd === repo root. consider importing ROOT from state/paths.ts as the default, or dropping the default entirely so callers must be explicit. either way, follow-up not blocker.

new unit tests cover hermes / override / fallback / no-arg — meaningful, and the existing integration tests in test/onboard.test.ts still exercise the re-exported symbol via onboard.ts. approving.

@cv
cv changed the base branch from refactor/onboard-dockerfile-patch to main May 13, 2026 02:42
cv added 4 commits May 12, 2026 19:43
## Summary
Extract the Brave web-search configuration flow out of the large
onboarding module. This continues the onboarding cleanup stack by moving
validation, prompting, credential persistence, and configuration
selection into a focused helper module with direct coverage.

## Changes
- Add `src/lib/onboard/web-search-config.ts` for Brave Search
validation, recovery prompting, credential setup, and web-search config
selection.
- Update `src/lib/onboard.ts` to use the extracted helper factory while
preserving existing exports and call sites.
- Add unit tests covering Brave validation curl arguments,
unsupported-agent skip behavior, existing config reuse, non-interactive
env setup, interactive credential prompting, and skip recovery.

## Type of Change
- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Verification
- [x] `npx prek run --all-files` passes
- [x] `npm test` passes
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] Docs updated for user-facing behavior changes
- [ ] `make docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv marked this pull request as ready for review May 13, 2026 02:45
@cjagwani
cjagwani self-requested a review May 13, 2026 02:47
@github-actions

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: None
Optional E2E: brave-search-e2e, cloud-onboard-e2e, onboard-resume-e2e, hermes-e2e

Dispatch hint: brave-search-e2e,cloud-onboard-e2e,onboard-resume-e2e,hermes-e2e

Workflow run

Full advisor summary

Pi Semantic E2E Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • None. This PR is a behavior-preserving extraction of agentSupportsWebSearch into its own module with an explicit rootDir parameter; both former call sites pass ROOT and the function body (candidate ordering, Hermes short-circuit, ARG regex) is unchanged. The added vitest spec covers every branch (hermes skip, override precedence, agent→root fallback, no-ARG → false), so existing E2E coverage is not merge-blocking. Optional E2E jobs above are listed for confidence if a maintainer wants a live-system check of the Brave gate.

Optional E2E

  • brave-search-e2e: Most direct E2E exercise of the codepath gated by agentSupportsWebSearch: non-interactive onboard auto-enables Brave Web Search, applies the brave network preset, and runs real Brave queries via the openclaw agent and curl. Confirms the extracted function still returns true for the OpenClaw root Dockerfile path. Gated on BRAVE_API_KEY secret and lives in nightly-e2e, so optional for a refactor with full unit coverage.
  • cloud-onboard-e2e: Exercises the public installer + non-interactive onboard wizard end-to-end on the OpenClaw root Dockerfile, traversing the same configureWebSearch and post-inference webSearchSupported call sites that were rewired to take ROOT explicitly. Catches any accidental ROOT/path resolution regression in the extracted module.
  • onboard-resume-e2e: Hits the second call site of agentSupportsWebSearch, which decides whether stored webSearchConfig is cleared as 'stale' on resume. A regression in path resolution could spuriously clear config and force sandbox recreation on resume.
  • hermes-e2e: Validates the hermes short-circuit branch (agentSupportsWebSearch returns false for Hermes regardless of Dockerfile contents). Confirms Hermes onboarding still skips the Brave prompt and reaches a healthy sandbox.

New E2E recommendations

  • None.

Dispatch hint

  • Workflow: nightly-e2e.yaml
  • jobs input: brave-search-e2e,cloud-onboard-e2e,onboard-resume-e2e,hermes-e2e

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/onboard/web-search-support.test.ts`:
- Line 58: Replace the hardcoded absolute path "/missing" in the test call to
agentSupportsWebSearch with a repo-local guaranteed-nonexistent path derived
from the existing root test fixture (e.g., use path.join(root, "nonexistent") or
path.resolve(root, "does-not-exist")) so the test uses a repo-local missing path
that is platform-independent; update the expect invocation that currently calls
agentSupportsWebSearch({ name: "openclaw", dockerfilePath: "/missing" }, null,
root) to use the constructed path instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e2fe2a1b-6547-4056-9ea1-2cafb0cf3ce3

📥 Commits

Reviewing files that changed from the base of the PR and between 6f4e276 and 0154408.

📒 Files selected for processing (3)
  • src/lib/onboard.ts
  • src/lib/onboard/web-search-support.test.ts
  • src/lib/onboard/web-search-support.ts

Comment thread src/lib/onboard/web-search-support.test.ts Outdated
@cv
cv enabled auto-merge (squash) May 13, 2026 02:53

@cjagwani cjagwani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

approved

@cv
cv merged commit f83d313 into main May 13, 2026
19 of 20 checks passed
@cv
cv deleted the refactor/onboard-web-search-support branch May 27, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants