Skip to content

Commit b768149

Browse files
committed
code comment update
1 parent 9faf77f commit b768149

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

apps/webapp/app/services/sessionDuration.server.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,22 @@ export async function getEffectiveSessionDuration(
105105
}
106106

107107
/**
108-
* Returns the dropdown options the user is allowed to pick. If an org cap
109-
* exists, options strictly greater than the cap are removed. The user's
110-
* currently-saved value is always included even if it now exceeds the cap, so
111-
* the form remains valid until they pick a smaller value.
108+
* Returns the dropdown options the user is allowed to pick. Options strictly
109+
* greater than the org cap are removed.
110+
*
111+
* `currentValueSeconds` should be the *effective* (clamped) duration — i.e.
112+
* `EffectiveSessionDuration.durationSeconds`, which is guaranteed to be ≤
113+
* `orgCapSeconds`. Passing the clamped value makes the dropdown's selected
114+
* option reflect what's actually in effect rather than the user's stored
115+
* preference, which is the right UX when a stricter org cap supersedes a
116+
* larger user setting (the raw user preference stays in the DB and is
117+
* restored automatically if the cap is later removed).
118+
*
119+
* The tag-along branch below — appending `currentValueSeconds` to the option
120+
* list when it isn't already present — is now defensive only. It exists so
121+
* that any caller passing an out-of-range value (e.g. tests, or future
122+
* callers wanting to surface the raw user preference) still gets a renderable
123+
* form, rather than a dropdown whose `defaultValue` matches no option.
112124
*/
113125
export function getAllowedSessionOptions(
114126
orgCapSeconds: number | null,

0 commit comments

Comments
 (0)