@@ -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 */
113125export function getAllowedSessionOptions (
114126 orgCapSeconds : number | null ,
0 commit comments