Skip to content

Conversation

@dkaser
Copy link
Collaborator

@dkaser dkaser commented Nov 5, 2025

Summary by CodeRabbit

  • New Features
    • Added auto-update configuration option to the Tailscale plugin interface, enabling users to toggle automatic updates on or off. The setting is persisted and managed through the plugin's configuration system.

@coderabbitai
Copy link

coderabbitai bot commented Nov 5, 2025

Walkthrough

This pull request adds support for Tailscale's auto-update feature across the plugin stack. Changes include a new frontend UI function to toggle auto-update, server-side action handler in Config.php, localization entry, data model extensions to track the auto-update state, and a LocalAPI method to communicate the preference to Tailscale via PATCH request.

Changes

Cohort / File(s) Summary
Frontend UI Layer
src/usr/local/emhttp/plugins/tailscale/include/Pages/Tailscale.php, src/usr/local/emhttp/plugins/tailscale/locales/en_US.json
Added async function setAutoUpdate(enable) that displays a spinner, disables controls, posts to Config.php with action set-auto-update, and refreshes UI. Added localization entry "auto_update": "Auto Update" for display.
Configuration & Action Handling
src/usr/local/emhttp/plugins/tailscale/include/data/Config.php
Added UI button for auto-update toggling and new action handler set-auto-update that validates the enable parameter, logs the change, and invokes LocalAPI->setAutoUpdate($enable).
Data Model
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/ConnectionInfo.php, src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Info.php
Added public property AutoUpdate to ConnectionInfo. Added public method autoUpdateEnabled(): bool and updated getConnectionInfo() to include AutoUpdate value derived from prefs.AutoUpdate->Apply.
API Integration
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/LocalAPI.php
Added public method setAutoUpdate(bool $enabled): void that constructs a PATCH request body with AutoUpdate fields and sends it to v0/prefs endpoint.

Sequence Diagram

sequenceDiagram
    participant User
    participant Frontend as Frontend<br/>(Tailscale.php)
    participant Backend as Backend<br/>(Config.php)
    participant API as LocalAPI
    participant TS as Tailscale<br/>API

    User->>Frontend: Click auto-update toggle
    Frontend->>Frontend: Show spinner, disable controls
    Frontend->>Backend: POST action=set-auto-update
    Backend->>API: setAutoUpdate($enable)
    API->>TS: PATCH /v0/prefs<br/>(AutoUpdate: {Apply, Set})
    TS-->>API: Success
    API-->>Backend: Return
    Backend->>Frontend: Response
    Frontend->>Frontend: Call showTailscaleConfig()
    Frontend->>Frontend: Refresh UI
    Frontend-->>User: Display updated state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

  • LocalAPI.php: Verify the PATCH request body structure matches Tailscale's expected format for AutoUpdate preferences and that Apply/Set flags are correctly set
  • Info.php: Confirm autoUpdateEnabled() safely handles null/missing values in prefs.AutoUpdate->Apply chain
  • Config.php: Ensure the set-auto-update action handler properly validates the enable parameter before passing to LocalAPI
  • Cross-layer consistency: Verify that the AutoUpdate state flows correctly from API response through data model to frontend display

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add configuration option for auto update' accurately and concisely describes the main change: introducing a new auto-update configuration feature across the Tailscale plugin.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/auto-update

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1d5a55 and 71e119e.

📒 Files selected for processing (6)
  • src/usr/local/emhttp/plugins/tailscale/include/Pages/Tailscale.php (1 hunks)
  • src/usr/local/emhttp/plugins/tailscale/include/data/Config.php (3 hunks)
  • src/usr/local/emhttp/plugins/tailscale/locales/en_US.json (1 hunks)
  • src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/ConnectionInfo.php (1 hunks)
  • src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Info.php (2 hunks)
  • src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/LocalAPI.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/usr/local/emhttp/plugins/tailscale/include/data/Config.php (2)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Info.php (2)
  • autoUpdateEnabled (503-506)
  • tr (66-69)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/LocalAPI.php (1)
  • setAutoUpdate (144-151)
🔇 Additional comments (9)
src/usr/local/emhttp/plugins/tailscale/locales/en_US.json (1)

92-92: LGTM!

The localization entry follows the existing pattern and is correctly placed within the info section.

src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/ConnectionInfo.php (1)

35-35: LGTM!

The property addition follows the existing pattern for ConnectionInfo fields. Consistent type declaration and initialization.

src/usr/local/emhttp/plugins/tailscale/include/Pages/Tailscale.php (1)

84-89: LGTM!

The function follows the established pattern used by setFeature and setAdvertiseExitNode. Consistent implementation with proper async handling and UI state management.

src/usr/local/emhttp/plugins/tailscale/include/data/Config.php (3)

73-75: LGTM!

The button creation follows the established pattern. Unlike DNS and Routes, this doesn't check a configuration flag (like AllowDNS). This matches the pattern for SSH, suggesting auto-update is always user-controllable, which seems appropriate.


110-110: LGTM!

The configuration row is properly structured and follows the existing pattern. Positioning auto-update first in the table is a reasonable choice for this system-level setting.


312-321: LGTM!

The action handler follows the established pattern with proper parameter validation and logging. Error handling is consistent with other action cases, relying on the outer try-catch block.

src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Info.php (2)

503-506: LGTM!

The method follows the established pattern for preference checks with appropriate null-safe default handling.


119-119: LGTM!

The ConnectionInfo field population follows the exact pattern used for other boolean preferences with proper translation to user-facing strings.

src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/LocalAPI.php (1)

144-151: LGTM!

The implementation correctly handles the nested AutoUpdate preference structure. Setting both Apply and Check to the same value is appropriate for the simple enable/disable toggle in the UI. The structure aligns with how Info.php reads the preference at line 505.


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.

@github-actions github-actions bot added the feat label Nov 5, 2025
@dkaser dkaser merged commit 50ae227 into trunk Nov 5, 2025
6 checks passed
@dkaser dkaser deleted the feat/auto-update branch November 5, 2025 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants