Skip to content

feat(channels): remove a configured sidecar channel from the dashboard#6202

Merged
houko merged 13 commits into
mainfrom
feat/6186-channel-remove
Jun 19, 2026
Merged

feat(channels): remove a configured sidecar channel from the dashboard#6202
houko merged 13 commits into
mainfrom
feat/6186-channel-remove

Conversation

@houko

@houko houko commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #6186. Channels could only be added from the dashboard — the only mutating endpoint was POST /api/channels/sidecar/{name}/configure, with no inverse, so removing a channel meant hand-editing ~/.librefang/config.toml.

Changes

Backend (librefang-api)

  • routes/sidecar_toml.rs — new remove_sidecar_block(path, name): removes the [[sidecar_channels]] block by name via toml_edit (preserving every other section's formatting), drops the sidecar_channels array key entirely when the last block goes, and writes atomically (same tempfile+rename scheme as upsert_sidecar_block). Returns whether a block was removed.
  • routes/channels.rs — new DELETE /api/channels/sidecar/{name} handler: rewrites config.toml under the same config_write_lock that gates configure and POST /api/config/set, 404s when no matching block exists, then reload_config() + (on ReloadChannels) reload_channels_from_disk so the removed sidecar child process is stopped, not just dropped from disk. Registered in router() and openapi.rs.

Frontend (dashboard)

  • api.ts / lib/http/client.tsremoveSidecarConfig(name) calling the DELETE endpoint.
  • lib/mutations/channels.tsuseRemoveSidecarConfig with colocated channelKeys.all invalidation.
  • pages/ChannelsPage.tsx — a confirm-guarded Trash button on each configured channel card.
  • i18n keys added to en / zh / uk.

Scope decision

A removed channel's per-channel secret keys are deliberately left untouched: there is no remove_secret primitive today, and purging secrets is a separable destructive action. The confirm dialog states this. Wiring a secret-purge is a follow-up if wanted.

Verification

cargo check --workspace --lib                                  # ✓
cargo clippy -p librefang-api --lib -- -D warnings             # ✓
cargo test -p librefang-api --test sidecar_toml_test \
  --test channel_remove_test \
  --test dead_route_audit_test --test openapi_path_coverage_test   # all pass
cargo fmt --check                                              # clean
  • sidecar_toml_test: remove_drops_named_block_and_keeps_others, remove_absent_name_is_noop_returning_false, remove_last_block_drops_the_array_key.
  • channel_remove_test (TestServer): delete_removes_configured_sidecar_then_404s_on_repeat, delete_unknown_sidecar_404s.
  • dead_route_audit + openapi_path_coverage confirm the new route is wired and documented.
pnpm typecheck          # clean
pnpm exec vitest run src/pages/ChannelsPage.test.tsx   # 19 passed (incl. new remove-flow test)
pnpm build              # ✓

Channels could only be added — removing one meant hand-editing config.toml, since the only mutating endpoint was POST /api/channels/sidecar/{name}/configure with no inverse.
Add remove_sidecar_block to rewrite config.toml with toml_edit (dropping the array key when the last block goes), plus a DELETE /api/channels/sidecar/{name} handler that runs it under the same config_write_lock that gates configure, then hot-reloads so the removed sidecar child is stopped rather than left running until restart.
The dashboard configured-channel cards gain a confirm-guarded Trash button wired to a dedicated useRemoveSidecarConfig mutation that invalidates channelKeys.all.
The channel's per-channel secret keys are deliberately left untouched, since purging them is a separable destructive action with no remove primitive yet.

Tests: remove_sidecar_block unit tests (named removal, absent no-op, last-block array drop), DELETE integration tests (removes then 404s on repeat, unknown 404), and a dashboard remove-flow test; the openapi and dead-route reflection guards cover the new route.

Closes #6186
@github-actions github-actions Bot added size/L 250-999 lines changed area/docs Documentation and guides and removed size/L 250-999 lines changed labels Jun 18, 2026
@github-actions github-actions Bot added size/L 250-999 lines changed area/sdk JavaScript and Python SDKs labels Jun 18, 2026
claude and others added 2 commits June 18, 2026 05:39
…e response

The sidecar-delete handler's bridge-restart failure path interpolated
the raw error chain into the client response body. Keep the actionable
partial-failure signal (the channel WAS removed from config.toml) as a
static message and leave the full error to the existing server-side
tracing::error! log.
@github-actions github-actions Bot added the has-conflicts PR has merge conflicts that need resolution label Jun 18, 2026
@houko
houko enabled auto-merge (squash) June 18, 2026 15:39
# Conflicts:
#	.secrets.baseline
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 19, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review and removed has-conflicts PR has merge conflicts that need resolution labels Jun 19, 2026
@github-actions github-actions Bot added has-conflicts PR has merge conflicts that need resolution and removed ready-for-review PR is ready for maintainer review labels Jun 19, 2026
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review has-conflicts PR has merge conflicts that need resolution and removed has-conflicts PR has merge conflicts that need resolution ready-for-review PR is ready for maintainer review labels Jun 19, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying librefang-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8c982d8
Status: ✅  Deploy successful!
Preview URL: https://23f23603.librefang-docs.pages.dev
Branch Preview URL: https://feat-6186-channel-remove.librefang-docs.pages.dev

View logs

@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review has-conflicts PR has merge conflicts that need resolution and removed has-conflicts PR has merge conflicts that need resolution labels Jun 19, 2026
@github-actions github-actions Bot removed the ready-for-review PR is ready for maintainer review label Jun 19, 2026
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review has-conflicts PR has merge conflicts that need resolution and removed has-conflicts PR has merge conflicts that need resolution ready-for-review PR is ready for maintainer review labels Jun 19, 2026
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review has-conflicts PR has merge conflicts that need resolution and removed has-conflicts PR has merge conflicts that need resolution ready-for-review PR is ready for maintainer review labels Jun 19, 2026
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review and removed has-conflicts PR has merge conflicts that need resolution labels Jun 19, 2026
@houko
houko merged commit 6255100 into main Jun 19, 2026
33 checks passed
@houko
houko deleted the feat/6186-channel-remove branch June 19, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation and guides area/sdk JavaScript and Python SDKs ready-for-review PR is ready for maintainer review size/L 250-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

通道增加移除功能

2 participants