Skip to content

Make peer inactivity expiration duration configurable in the UI - #738

Open
paul-hph wants to merge 2 commits into
netbirdio:mainfrom
paul-hph:inactivity-expiration-configurable
Open

Make peer inactivity expiration duration configurable in the UI#738
paul-hph wants to merge 2 commits into
netbirdio:mainfrom
paul-hph:inactivity-expiration-configurable

Conversation

@paul-hph

@paul-hph paul-hph commented Jul 30, 2026

Copy link
Copy Markdown

Issue ticket number and link

No dedicated issue. Context: the inactivity expiration feature was added backend-side in netbirdio/netbird#2326 with peer_inactivity_expiration (seconds) fully supported by the accounts API — but the dashboard never exposed the duration and instead hardcodes 600 on every save of the Authentication page.

This has two consequences for self-hosted admins:

  • The inactivity duration can only be set via the API.
  • Worse: any value set via the API is silently reset to 10 minutes the next time an admin saves the Authentication settings page (peer_inactivity_expiration: 600 was sent unconditionally).

What this PR does

  • Adds an "Inactivity Expiration" input (minutes/hours/days) below the Require login after disconnect toggle, mirroring the existing Session Expiration input row.
  • On save, sends the configured duration instead of the hardcoded 600. When the toggle is off, the stored account value is preserved instead of being overwritten.
  • Updates the toggle help text ("for 10 minutes" → "for the configured period of time").
  • Fixes the useExpirationState destructuring for the inactivity state (position 3 is setExpiresIn, but it was named peerInactivityExpireInterval).

Verified: next build passes, no new type errors, Prettier clean.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

This exposes an existing, already-documented API setting (peer_inactivity_expiration) in the UI. Happy to follow up with a docs PR updating the screenshots/description on the periodic-authentication page if desired.

Docs PR URL (required if "docs added" is checked)

n/a

Summary by CodeRabbit

  • New Features
    • Added an expanded peer inactivity expiration section with a numeric duration input and an interval selector.
    • Updated the UI guidance and help text for configuring the inactivity period.
  • Bug Fixes
    • Improved validation for inactivity expiration settings before saving, preventing non-positive or invalid computed values.
    • Adjusted persistence to store the derived inactivity expiration only when the feature is enabled; otherwise it falls back to a safe default.

Screenshot

Toggle enabled with the new duration input (mirrors the Session Expiration row):

Inactivity Expiration field

The management API already supports peer_inactivity_expiration (seconds),
but the Authentication settings page hardcoded 600 on every save. This had
two consequences:

- The inactivity duration could only be set via the API.
- Any value set via the API was silently reset to 10 minutes the next time
  an admin saved the Authentication page.

This change adds an "Inactivity Expiration" input (minutes/hours/days) below
the "Require login after disconnect" toggle, mirroring the existing Session
Expiration input. When the toggle is disabled, the stored account value is
preserved instead of being overwritten.

Also completes the useExpirationState destructuring for the inactivity
state, which previously mislabeled the setExpiresIn setter as the interval
value.
@CLAassistant

CLAassistant commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f1185298-73da-408a-846f-6f91c6c32168

📥 Commits

Reviewing files that changed from the base of the PR and between e2b3a32 and 272683b.

📒 Files selected for processing (1)
  • src/modules/settings/AuthenticationTab.tsx

📝 Walkthrough

Walkthrough

AuthenticationTab now provides configurable peer inactivity expiration duration and interval controls, validates the derived value before saving, and persists the selected expiration in seconds when enabled.

Changes

Peer inactivity expiration

Layer / File(s) Summary
Expiration controls and state wiring
src/modules/settings/AuthenticationTab.tsx
Adds configurable duration and interval inputs, updates expiration state wiring, and disables interaction when required expiration settings are inactive.
Expiration persistence
src/modules/settings/AuthenticationTab.tsx
Validates derived expiration seconds, disables saving for invalid values, and persists the configured value when enabled with nullish fallback handling when disabled.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: mlsmaycon

Poem

A rabbit taps the settings pane,
“No more fixed ten-minute reign!”
Days or hours, minutes too,
Choose the span that works for you.
Saved in seconds, neat and bright—
Hop, hop, expiration right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making peer inactivity expiration configurable in the UI.
Description check ✅ Passed The description follows the template and covers the issue context, documentation decision, and optional E2E fields.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/modules/settings/AuthenticationTab.tsx

Oops! Something went wrong! :(

ESLint: 9.39.3

TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'configs' -> object with constructor 'Object'
| property 'flat' -> object with constructor 'Object'
| ...
| property 'plugins' -> object with constructor 'Object'
--- property 'react' closes the circle
Referenced from: /.eslintrc.json
at JSON.stringify ()
at /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2255:45
at Array.map ()
at ConfigValidator.formatErrors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2246:23)
at ConfigValidator.validateConfigSchema (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2277:84)
at ConfigArrayFactory._normalizeConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3123:19)
at ConfigArrayFactory._loadConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3088:21)
at ConfigArrayFactory._loadExtendedShareableConfig (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3393:21)
at ConfigArrayFactory._loadExtends (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3261:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3199:25)
(node:2) ESLintRCWarning: You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details. An eslintrc configuration file is used because you have the ESLINT_USE_FLAT_CONFIG environment variable set to false. If you want to use an eslint.config.js file, remove the environment variable. If you want to find the location of the eslintrc configuration file, use the --debug flag.
(Use node --trace-warnings ... to show where the warning was created)


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.

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/modules/settings/AuthenticationTab.tsx`:
- Around line 136-139: Validate the converted inactivity duration in the save
logic around convertToSeconds, requiring a finite positive number before issuing
the request and surfacing a field error otherwise. Keep the input editable in
the related input-rendering path; ensure empty or invalid values cannot be
persisted. Affected site src/modules/settings/AuthenticationTab.tsx lines
136-139 requires validation before the request;
src/modules/settings/AuthenticationTab.tsx lines 442-455 requires preserving
editability while reflecting the invalid state.
- Around line 154-156: Update the peer inactivity expiration fallback in the
settings payload and the initializer associated with
peerInactivityExpirationEnabled to use nullish coalescing instead of logical OR,
preserving persisted zero values while still defaulting when the stored value is
null or undefined.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a5b64929-863a-4593-9434-e5ef0b485351

📥 Commits

Reviewing files that changed from the base of the PR and between 1d408f2 and e2b3a32.

📒 Files selected for processing (1)
  • src/modules/settings/AuthenticationTab.tsx

Comment thread src/modules/settings/AuthenticationTab.tsx Outdated
Comment thread src/modules/settings/AuthenticationTab.tsx Outdated
- Block saving while the inactivity duration input is empty or non-positive
  (convertToSeconds yields NaN for a cleared input) by disabling the Save
  button and guarding the request payload.
- Use ?? instead of || so a stored peer_inactivity_expiration of 0 is
  preserved rather than silently replaced with 600.
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.

2 participants