Skip to content

[codex] warn before relay toggle restarts host service - #3845

Merged
Kitenite merged 3 commits into
mainfrom
relay-toggle-warning
Apr 28, 2026
Merged

Kitenite merged 3 commits into
mainfrom
relay-toggle-warning

Conversation

@Kitenite

@Kitenite Kitenite commented Apr 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Warn before changing the relay exposure setting in either direction, because the setting mutation restarts active host-service instances and stops running terminals.

Changes

  • Route both enable and disable switch actions through the relay confirmation dialog.
  • Pass the intended target state into the dialog so the copy and action label match the direction.
  • Use destructive confirmation actions for both directions, labeled Enable and restart or Disable and restart.
  • Keep the stronger typed confirmation for enabling relay access.

Impact

Users now see that changing Relay access restarts the host service, stops running terminals, and interrupts file watches or other host-backed work before the setting is applied.

Validation

  • bunx @biomejs/biome@2.4.2 check --write --unsafe apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/SecuritySettings.tsx apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/components/ExposeViaRelayConfirmDialog/ExposeViaRelayConfirmDialog.tsx
  • bun run --cwd apps/desktop typecheck

Summary by cubic

Show a confirmation before enabling or disabling Superset Relay access, warning that the change restarts the host service, kills running terminals, and interrupts file watches and other host-backed work. Enabling still requires typing "I understand"; disabling only needs a simple confirm.

  • New Features
    • Route both enable and disable through a single confirm dialog that knows the target state.
    • Action labels now read "Enable and restart" or "Disable and restart"; dialog copy trimmed to focus on the access change and restart.

Written for commit 635f1bc. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

Bug Fixes

  • Confirmation dialog now appears for both enabling and disabling relay access to ensure deliberate changes.
  • Enabling requires typing the confirmation phrase; disabling is simplified (no typed confirmation).
  • Dialog titles, descriptions, and confirm button labels/appearance update to reflect whether you are enabling or disabling.

@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR routes both the enable and disable relay-toggle actions through the ExposeViaRelayConfirmDialog, ensuring users always see the host-service restart warning before the setting changes. The dialog content, typed-confirmation requirement, button variant, and button label are now conditional on targetEnabled, keeping the stronger "I understand" gate only for the riskier enable path.

Confidence Score: 5/5

Safe to merge — logic is correct, state is properly reset between dialog openings, and the security gate for enabling is preserved.

Both changed files are small, focused, and follow existing patterns. The typed state is correctly reset on close, the optimistic-update rollback is unaffected, and the only remaining note is a trivial redundant variable. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/SecuritySettings.tsx Routes both enable and disable toggle actions through the confirmation dialog by adding confirmTargetEnabled state; captures value in closure for runToggle
apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/components/ExposeViaRelayConfirmDialog/ExposeViaRelayConfirmDialog.tsx Adds targetEnabled prop to branch dialog title, body, typed-confirmation requirement, button variant, and button label between enable and disable flows

Sequence Diagram

sequenceDiagram
    participant U as User
    participant SW as Switch
    participant SS as SecuritySettings
    participant D as ExposeViaRelayConfirmDialog
    participant API as tRPC Mutation

    U->>SW: Toggle (on or off)
    SW->>SS: handleChange(next)
    SS->>SS: setConfirmTargetEnabled(next)
    SS->>SS: setConfirmOpen(true)
    SS->>D: open=true, targetEnabled=next

    alt targetEnabled = true (Enable)
        D-->>U: Show security risk warning + "I understand" input
        U->>D: Types "I understand"
        U->>D: Click "Enable"
        D->>SS: onConfirm()
        SS->>SS: setConfirmOpen(false)
        SS->>API: runToggle(true)
    else targetEnabled = false (Disable)
        D-->>U: Show restart/disconnect warning (no input required)
        U->>D: Click "Disable"
        D->>SS: onConfirm()
        SS->>SS: setConfirmOpen(false)
        SS->>API: runToggle(false)
    end

    API-->>SS: toast.promise (loading -> success/error)
    API-->>SS: optimistic update + invalidate
Loading

Reviews (1): Last reviewed commit: "warn before relay toggle restarts host s..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Both enabling and disabling the "Expose via Relay" setting now open a confirmation dialog; the intended target state is stored in component state and passed to the dialog so confirmation executes the correct enable or disable action.

Changes

Cohort / File(s) Summary
Security settings toggle
apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/SecuritySettings.tsx
Toggle handler now always sets confirmTargetEnabled and opens the confirmation dialog instead of immediately performing the toggle; confirmation result drives runToggle(targetEnabled).
Relay confirmation dialog
apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/components/ExposeViaRelayConfirmDialog/ExposeViaRelayConfirmDialog.tsx
Added targetEnabled: boolean prop. Dialog adjusts title, description, confirm button label/variant, and requires typed CONFIRM_PHRASE only when enabling; disabling can confirm without typed input.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SecuritySettings
  participant ConfirmDialog
  participant ToggleService

  User->>SecuritySettings: click relay toggle
  SecuritySettings->>SecuritySettings: set confirmTargetEnabled, open ConfirmDialog
  SecuritySettings->>ConfirmDialog: show(targetEnabled)
  alt targetEnabled == true
    User->>ConfirmDialog: type CONFIRM_PHRASE and click confirm
  else targetEnabled == false
    User->>ConfirmDialog: click confirm
  end
  ConfirmDialog->>SecuritySettings: onConfirm(targetEnabled)
  SecuritySettings->>ToggleService: runToggle(targetEnabled)
  ToggleService-->>SecuritySettings: success/failure
  SecuritySettings-->>User: update UI / show result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I paused my hop, then asked with care,
Which way to flip the relay there.
A phrase to grant the open door,
A click to close — I check once more.
Safe hops, safe relays, everywhere.

🚥 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
Title check ✅ Passed The title clearly describes the main change: adding a warning/confirmation before relay toggle that restarts the host service.
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.
Description check ✅ Passed The pull request description comprehensively covers all required sections: clear summary, detailed changes, impact statement, and validation steps performed.

✏️ 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 relay-toggle-warning

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 and usage tips.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/components/ExposeViaRelayConfirmDialog/ExposeViaRelayConfirmDialog.tsx (1)

33-37: ⚠️ Potential issue | 🟡 Minor

Reset typed confirmation when mode flips while open.

On Line 37, canConfirm can stay true if targetEnabled changes in-place while the dialog remains open and typed still matches. Consider clearing typed on targetEnabled transitions as well, not only on close.

Suggested patch
-useEffect(() => {
-	if (!open) setTyped("");
-}, [open]);
+useEffect(() => {
+	if (!open) {
+		setTyped("");
+		return;
+	}
+	if (targetEnabled) {
+		setTyped("");
+	}
+}, [open, targetEnabled]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/components/ExposeViaRelayConfirmDialog/ExposeViaRelayConfirmDialog.tsx`
around lines 33 - 37, The dialog leaves typed matching CONFIRM_PHRASE when
targetEnabled flips while open, so add logic to reset typed on targetEnabled
transitions (not just on open): in ExposeViaRelayConfirmDialog add a useEffect
that watches [targetEnabled, open] (or include targetEnabled in the existing
useEffect dependency) and calls setTyped("") whenever open is true and
targetEnabled changes, ensuring canConfirm (which uses targetEnabled and typed)
is recalculated correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/components/ExposeViaRelayConfirmDialog/ExposeViaRelayConfirmDialog.tsx`:
- Around line 33-37: The dialog leaves typed matching CONFIRM_PHRASE when
targetEnabled flips while open, so add logic to reset typed on targetEnabled
transitions (not just on open): in ExposeViaRelayConfirmDialog add a useEffect
that watches [targetEnabled, open] (or include targetEnabled in the existing
useEffect dependency) and calls setTyped("") whenever open is true and
targetEnabled changes, ensuring canConfirm (which uses targetEnabled and typed)
is recalculated correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c53c8fcf-985a-40f6-bea5-a6fadfec9b89

📥 Commits

Reviewing files that changed from the base of the PR and between a614c72 and 635f1bc.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/routes/_authenticated/settings/security/components/SecuritySettings/components/ExposeViaRelayConfirmDialog/ExposeViaRelayConfirmDialog.tsx

@Kitenite
Kitenite merged commit 3419644 into main Apr 28, 2026
7 checks passed
@Kitenite
Kitenite deleted the relay-toggle-warning branch April 28, 2026 22:26
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch

Thank you for your contribution! 🎉

MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request May 21, 2026
* warn before relay toggle restarts host service

* trim relay toggle dialog copy

* clarify relay toggle kills terminals
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