Make peer inactivity expiration duration configurable in the UI - #738
Make peer inactivity expiration duration configurable in the UI#738paul-hph wants to merge 2 commits into
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesPeer inactivity expiration
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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
src/modules/settings/AuthenticationTab.tsxOops! Something went wrong! :( ESLint: 9.39.3 TypeError: Converting circular structure to JSON 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/modules/settings/AuthenticationTab.tsx
- 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.
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 hardcodes600on every save of the Authentication page.This has two consequences for self-hosted admins:
peer_inactivity_expiration: 600was sent unconditionally).What this PR does
600. When the toggle is off, the stored account value is preserved instead of being overwritten.useExpirationStatedestructuring for the inactivity state (position 3 issetExpiresIn, but it was namedpeerInactivityExpireInterval).Verified:
next buildpasses, no new type errors, Prettier clean.Documentation
Select exactly one:
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
Screenshot
Toggle enabled with the new duration input (mirrors the Session Expiration row):