Skip to content

refactor(admin): web-search#9761

Open
raunakab wants to merge 5 commits intorefactor/select-card-migrationfrom
feat/web-search-select-card
Open

refactor(admin): web-search#9761
raunakab wants to merge 5 commits intorefactor/select-card-migrationfrom
feat/web-search-select-card

Conversation

@raunakab
Copy link
Copy Markdown
Contributor

@raunakab raunakab commented Mar 30, 2026

Description

Refactor the /admin/configuration/web-search page to use the new Opal SelectCard and CardHeaderLayout primitives (from #9760) instead of the legacy Select component from refresh-components/cards.

  • Adds a local ProviderCard component that maps provider status to Interactive.Stateful states (disconnected→empty, connected→filled, selected→selected)
  • Uses Hoverable for reveal-on-hover actions (Set as Default, Disconnect)
  • Uses CardHeaderLayout for the card content structure with rightChildren and bottomRightChildren slots

Screenshots + Videos

Screen.Recording.2026-03-30.at.12.07.32.PM.mov

Additional Options

  • [Optional] Please cherry-pick this PR to the latest release version.
  • [Optional] Override Linear Check

Summary by cubic

Refactored the /admin/configuration/web-search page to use @opal/components SelectCard and @opal/layouts CardHeaderLayout for a consistent, stateful card UI. Moved the page into refresh-pages with shared service/types, e2e helpers, and absolute imports.

  • Refactors

    • Replaced refresh-components/cards Select with @opal/components SelectCard and @opal/layouts CardHeaderLayout.
    • Added local ProviderCard that maps provider status to SelectCard states and wires connect/select/deselect/edit/disconnect.
    • Used @opal/core Hoverable to reveal "Disconnect" on hover; "Set as Default" is always visible; show "Current Default" when selected.
    • Extracted into web/src/refresh-pages/admin/WebSearchPage/ (index.tsx), moved API calls to svc.ts and shared types to interfaces.ts; deduped e2e helpers/fake data in web/tests/e2e/admin/web-search/svc.ts; converted relative imports to absolute.
  • Bug Fixes

    • Removed unused Interactive import and correctly wired onDeselect in ProviderCard.
    • Removed Hoverable wrapper from "Set as Default" button.

Written for commit f410ab9. Summary will update on new commits.

@raunakab raunakab requested a review from a team as a code owner March 30, 2026 18:48
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 30, 2026

Greptile Summary

This PR refactors the /admin/configuration/web-search page from the legacy ProviderCard/Select components into Opal's SelectCard + CardHeaderLayout primitives, relocating the implementation into refresh-pages/admin/WebSearchPage/. The logic is sound and the split into svc.ts, interfaces.ts, and co-located utilities is a clean architectural improvement.

  • The new ProviderCard component correctly maps disconnected → empty, connected → filled, selected → selected states and properly wires all connect/select/deselect/edit/disconnect callbacks.
  • Service functions in svc.ts are well-structured, with consistent error parsing and correct endpoint selection.
  • Disconnect flow (activate replacement then delete) is correctly sequenced.
  • The openProviderModal e2e helper uses a regex /^Edit / with a trailing space that will silently fail to match icon-only Edit buttons whose accessible name is "Edit" (no trailing space). Tests using the Edit fallback path will time out rather than clicking.
  • Debug console.log statements were left in web_search_providers.spec.ts and web_content_providers.spec.ts and should be removed.

Confidence Score: 4/5

  • Safe to merge after fixing the Edit button regex in the e2e helper and removing debug console.log statements.
  • The production code is clean and correct — both the UI refactor and service layer look solid. The one concrete defect is in the test helper: the /^Edit / regex (trailing space) will silently fail to locate the Edit button whenever that code path is exercised, causing tests to time out. The debug console.log lines are noise. Neither issue touches production behaviour, but the regex bug makes the test suite unreliable.
  • web/tests/e2e/admin/web-search/svc.ts (regex bug), web/tests/e2e/admin/web-search/web_search_providers.spec.ts and web_content_providers.spec.ts (debug logs)

Important Files Changed

Filename Overview
web/src/refresh-pages/admin/WebSearchPage/index.tsx Main page component refactored to use SelectCard/CardHeaderLayout; new ProviderCard local component correctly maps provider status to SelectCard states; onDeselect and service layer calls are properly wired.
web/tests/e2e/admin/web-search/svc.ts New shared e2e helpers and fake data; openProviderModal regex /^Edit / has a trailing space that will fail to match icon-only Edit buttons with accessible name "Edit".
web/tests/e2e/admin/web-search/disconnect-provider.spec.ts New e2e specs covering all disconnect scenarios (non-active, active with/without replacements, built-in provider); comprehensive coverage.
web/tests/e2e/admin/web-search/web_search_providers.spec.ts Updated e2e specs for search providers; contains debug console.log statements that should be removed before merge.
web/tests/e2e/admin/web-search/web_content_providers.spec.ts Updated e2e specs for content providers; also contains debug console.log statements that should be removed before merge.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[WebSearchPage] --> B[combinedSearchProviders]
    A --> C[combinedContentProviders]

    B --> D[ProviderCard\nsearch]
    C --> E[ProviderCard\ncontent]

    D --> F{status}
    E --> F

    F -->|disconnected| G[SelectCard: empty\nConnect button visible]
    F -->|connected| H[SelectCard: filled\nSet as Default button visible]
    F -->|selected| I[SelectCard: selected\nCurrent Default/Crawler badge]

    G -->|onClick / Connect click| J[openSearchModal / openContentModal]
    H -->|Set as Default click| K[handleActivate*Provider]
    I -->|onClick on card| L[handleDeactivate*Provider]

    D -->|Disconnect click\non hover| M[setDisconnectTarget]
    E -->|Disconnect click\non hover| M
    M --> N[WebSearchDisconnectModal]
    N -->|confirm| O[disconnectProvider in svc.ts\nactivate replacement → DELETE]

    J --> P[WebProviderSetupModal]
    P -->|Connect| Q[connectProviderFlow\ntest → upsert]
    Q --> R[mutate SWR cache]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: web/tests/e2e/admin/web-search/web_search_providers.spec.ts
Line: 18

Comment:
**Debug `console.log` statements should be removed**

These `console.log` calls (`"[web-search-test] Page loaded successfully"`, `"[web-search-test] Clicked Connect, waiting for validation..."`, etc.) are debugging statements added during development and should be removed before merging. The same pattern appears in `web/tests/e2e/admin/web-search/web_content_providers.spec.ts` (lines 16, 56, 62, and 68 in that file).

**Rule Used:** Remove temporary debugging code before merging to ... ([source](https://app.greptile.com/review/custom-context?memory=b39fa59b-2568-4dd3-9576-83b46251a7b8))

**Learnt From**
[onyx-dot-app/onyx#4792](https://github.com/onyx-dot-app/onyx/pull/4792)

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: web/tests/e2e/admin/web-search/svc.ts
Line: 69-71

Comment:
**Regex pattern with trailing space may silently fail**

The regex `/^Edit /` requires the button's accessible name to start with `"Edit "` (with a trailing space). However, the Edit button in `ProviderCard` is an icon-only button rendered with `icon={SvgSettings}` and `tooltip="Edit"` — its accessible name will be `"Edit"` (no trailing space). The regex therefore never matches, causing this fallback path to silently do nothing instead of clicking the Edit button.

```suggestion
  const editButton = card.getByRole("button", { name: /^Edit/i });
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (7): Last reviewed commit: "style: convert all relative imports to a..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Preview Deployment

Status Preview Commit Updated
https://onyx-preview-3b4ezb8n7-danswer.vercel.app f410ab9 2026-03-30 20:55:39 UTC

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Confidence score: 3/5

  • There is a concrete regression risk in web/src/app/admin/configuration/web-search/page.tsx: onDeselect is passed to ProviderCard but never used, so users may be unable to deselect a previously selected provider.
  • Because this is a user-facing behavior break (severity 6/10, high confidence 8/10), the change carries some merge risk until deselection is wired back in (or an explicit deselect control is added).
  • Pay close attention to web/src/app/admin/configuration/web-search/page.tsx - restore deselection behavior by connecting selected-state interactions to onDeselect.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="web/src/app/admin/configuration/web-search/page.tsx">

<violation number="1" location="web/src/app/admin/configuration/web-search/page.tsx:280">
P2: `onDeselect` is passed into `ProviderCard` but never used, so selected providers can no longer be deselected. Wire the selected state to call `onDeselect` (or add an explicit control) to preserve the existing behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@raunakab raunakab force-pushed the feat/web-search-select-card branch 2 times, most recently from 2bdaf56 to 5736e33 Compare March 30, 2026 19:29
Base automatically changed from feat/opal-select-card-primitives to main March 30, 2026 20:02
@raunakab raunakab force-pushed the feat/web-search-select-card branch from 5736e33 to 40e37cf Compare March 30, 2026 20:04
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="web/src/refresh-pages/admin/WebSearchPage/index.tsx">

<violation number="1" location="web/src/refresh-pages/admin/WebSearchPage/index.tsx:298">
P2: `Set as Default` is no longer wrapped in `Hoverable.Item`, so it is always visible instead of reveal-on-hover like the other card actions.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@raunakab raunakab changed the title refactor(admin): migrate web-search page to SelectCard refactor(admin): web-search Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🖼️ Visual Regression Report

Project Changed Added Removed Unchanged Report
admin 14 0 6 144 View Report
exclusive 0 0 0 8 ✅ No changes

…yout

Replace the legacy Select component from refresh-components/cards with
the new Opal SelectCard and CardHeaderLayout primitives. Adds a local
ProviderCard component that maps provider status to Interactive.Stateful
states (disconnected→empty, connected→filled, selected→selected) and
uses Hoverable for reveal-on-hover actions.
…pers

Move page content from app/admin/configuration/web-search/ into
refresh-pages/admin/WebSearchPage/ following the UsersPage pattern.
Extract API calls into svc.ts and shared types into interfaces.ts.
Deduplicate e2e test helpers (findProviderCard, openProviderModal,
mockWebSearchApis, fake data) into tests/e2e/admin/web-search/svc.ts.
@raunakab raunakab changed the base branch from main to refactor/select-card-migration March 30, 2026 20:52
@raunakab raunakab force-pushed the feat/web-search-select-card branch from 566f61b to f410ab9 Compare March 30, 2026 20:52
Comment on lines +69 to +71
const editButton = card.getByRole("button", { name: /^Edit / });
await editButton.waitFor({ state: "visible", timeout: 5000 });
await editButton.click();
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.

P1 Regex pattern with trailing space may silently fail

The regex /^Edit / requires the button's accessible name to start with "Edit " (with a trailing space). However, the Edit button in ProviderCard is an icon-only button rendered with icon={SvgSettings} and tooltip="Edit" — its accessible name will be "Edit" (no trailing space). The regex therefore never matches, causing this fallback path to silently do nothing instead of clicking the Edit button.

Suggested change
const editButton = card.getByRole("button", { name: /^Edit / });
await editButton.waitFor({ state: "visible", timeout: 5000 });
await editButton.click();
const editButton = card.getByRole("button", { name: /^Edit/i });
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/tests/e2e/admin/web-search/svc.ts
Line: 69-71

Comment:
**Regex pattern with trailing space may silently fail**

The regex `/^Edit /` requires the button's accessible name to start with `"Edit "` (with a trailing space). However, the Edit button in `ProviderCard` is an icon-only button rendered with `icon={SvgSettings}` and `tooltip="Edit"` — its accessible name will be `"Edit"` (no trailing space). The regex therefore never matches, causing this fallback path to silently do nothing instead of clicking the Edit button.

```suggestion
  const editButton = card.getByRole("button", { name: /^Edit/i });
```

How can I resolve this? If you propose a fix, please make it concise.

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.

1 participant