Skip to content

feat(dashboard): select optional Xray API services in both core editors#662

Open
Multi-Engineer-dev wants to merge 8 commits into
PasarGuard:devfrom
multi-engineer:feat/dashboard-xray-api-services
Open

feat(dashboard): select optional Xray API services in both core editors#662
Multi-Engineer-dev wants to merge 8 commits into
PasarGuard:devfrom
multi-engineer:feat/dashboard-xray-api-services

Conversation

@Multi-Engineer-dev

Copy link
Copy Markdown

What

Adds first-class support for selecting optional Xray gRPC API services from
the dashboard, in both core-config editors, plus the supporting validation,
persistence, and localization.

Why

Xray exposes optional API services (e.g. RoutingService, ObservatoryService)
beyond the always-on HandlerService / LoggerService / StatsService.
Operators previously had to hand-edit raw JSON to enable them. This adds a
guided, validated control and ensures the selection round-trips correctly
through the structured editor.

What's included

  • Allowlist + helpers (lib/xray-api-services.ts): canonical required and
    optional service lists mirrored from xray-core, with pure helpers to read and
    toggle the selected optional services. Unit tests pin the allowlist so it
    can't drift silently.
  • Legacy core config modal: an "API Services" control to toggle optional
    services, with blocking validation that rejects unknown names and de-dupes
    them, plus accessible label/checkbox associations.
  • Structured core editor: a new "API" section mirroring the same control for
    the default route-based editor.
  • Localization: the structured editor's API section header and card
    (title + hint) are translated across all four locales (en/fa/ru/zh); the
    "API" acronym is kept as-is.
  • Fixes:
    • Toggling a service off now reliably enables Save. The structured editor's
      adapter re-emits api from raw.source, so toggles now update raw.source
      and raw.topLevel in lockstep (setRawOptionalService) — otherwise removing
      the last optional service produced no diff and left Save disabled.
    • The API section header renders proper labels even when a stale PWA-cached
      locale is served, via defaultValue fallbacks on PageHeader.

Tests

  • Unit tests for the allowlist helpers, including regressions for the
    toggle-persistence fix.
  • All four locale files validated (parse + key resolution).
  • esbuild integration check against a real core config, lints, and a
    production build all pass.

Related

Dashboard half of the Xray API services feature. The backend that merges these
user-selected services with the node's required services (instead of
overwriting them) lives in Node PR 60.

Adds an "API" section to the route-based core editor (Nodes > Cores),
mirroring the legacy core-config modal's control. Reuses the existing
xray-api-services helpers; optional services are stored on the profile's
preserved top-level `api` block and persisted through the xray adapter.
…ction

Unchecking the last optional api service emptied raw.topLevel.api, so the
adapter override disappeared and the kit re-emitted the original api from
raw.source, leaving the persisted config unchanged (Save never enabled and
the removal would not stick). setRawOptionalService now edits raw.source and
raw.topLevel in lockstep so toggles round-trip cleanly.

The API section header rendered the raw i18n key whenever a stale
(service-worker cached) locale bundle lacked the new keys. PageHeader now
accepts title/description defaults, matching the codebase's defaultValue
pattern, so the header reads correctly regardless of cache state.
The structured core editor's API section was only partly localized:
- coreEditor.section.api / sectionDesc.api existed in en.json only, so
  fa/ru/zh fell back to English for the section header.
- coreEditor.api.title / api.hint (the section card title and hint) were
  inline English defaultValues, absent from every locale file.

Add the section header keys to fa/ru/zh and the card title + hint to all
four locales (the "API" acronym is kept; descriptive text translated).
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6755e60-82f9-4820-87fa-24a860cccc1d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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