Repository navigation
Conversation
72f6667 to
e64598e
Compare
Alan52254
left a comment
There was a problem hiding this comment.
The server side is well factored: default_duration is the single source for both /api/session and /api/token, which is exactly what docs/interview-length.md asks for. My comments are about where an invalid or missing input silently changes the result, and about two test-scope issues. The one change I would make before merging is the defaultDuration fallback in web/app.js; the others are smaller. I did not repeat the open threads on web/interview.js:355.
e64598e to
0609ef1
Compare
0609ef1 to
ceaea79
Compare
ceaea79 to
46a811e
Compare
46a811e to
32f8528
Compare
32f8528 to
4d13dd5
Compare
254616c to
b1d70b9
Compare
b1d70b9 to
99b6a95
Compare
99b6a95 to
51964a9
Compare
51964a9 to
3176e85
Compare
jserv
left a comment
There was a problem hiding this comment.
Rebase the current branch onto the upstream default branch and resolve any conflicts. Run /codetrial-review in AI agents (use $codetrial-review in Codex) and resolve all identified issues. Rework the series into minimal, logically coherent commits, squash closely related commits, and ensure all commit messages follow the project’s rules.
|
Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open. Not addressed at the current head:
Checked at 3176e85. |
3176e85 to
462a74d
Compare
462a74d to
ffc61f6
Compare
The README and docs/interview-length.md call CODETRIAL_DURATION_MIN the length the lobby preselects, but only check-gemini, the setup probe and the recording cap check read it. The lobby always started on 45 for Medium and Hard, and a token request that named no length got the constant, so an operator who set 30 saw no change. /api/session now reports the default as defaultDurationMin, clamped into the range and to the recording ceiling by the same function that /api/token uses for a request that names no length. The lobby preselects it for Medium and Hard, and at most 30 for Easy. A value that is not one of the buttons selects the nearest one, and a length the candidate chose is left alone. With the variable unset, nothing changes. Closes sysprog21#582 Change-Id: I73ad723880f8df815252f4cb49cd3df5d992559e
ffc61f6 to
cf1ad2b
Compare
|
|
| void sessionPromise.then((session) => { | ||
| applyGrantedDuration(session?.defaultDurationMin); | ||
| renderRoundPlan(); | ||
| }); |
There was a problem hiding this comment.
There is a race condition here if /api/session resolves after /api/token has already granted the session's actual duration (for example, when /api/token clamps the duration down to a recording ceiling, while /api/session returns the unclamped defaultDurationMin).
Because sessionPromise.then(...) unconditionally calls applyGrantedDuration(session?.defaultDurationMin), a late /api/session response will overwrite the server-granted durationMin with defaultDurationMin and re-render the round plan with a mismatched length—violating the contract documented above applyGrantedDuration (lines 470–473).
Consider tracking whether a token-granted duration has already been applied (or guarding this callback so it only applies before connect() receives a granted duration):
| }); | |
| else | |
| void sessionPromise.then((session) => { | |
| if (!grantedDurationApplied) { | |
| applyGrantedDuration(session?.defaultDurationMin); | |
| } | |
| renderRoundPlan(); | |
| }); |
(with let grantedDurationApplied = false; set to true when connect() applies the /api/token response).
Local validation environment & test evidence:
- Environment:
MINGW64_NT-10.0-26200/ Nodev26.13.0 - Command:
node --test tests/browser/ - Result:
tests 350 | pass 350 | fail 0(existing suite passes, but no test currently covers out-of-order/api/sessionvs/api/tokensettlement when!namedDuration).
There was a problem hiding this comment.
This branch runs only when the URL names no length, so /api/token grants default_duration(CODETRIAL_DURATION_MIN, cap). /api/session reports defaultDurationMin from the same default_duration and cap (src/web/auth.rs), so a late answer applies the length already granted; it is not unclamped. Leaving it as is.
| function suggestedDuration(difficulties) { | ||
| return difficulties.has("Medium") || difficulties.has("Hard") ? 45 : 30; | ||
| const hard = difficulties.has("Medium") || difficulties.has("Hard"); | ||
| const wanted = hard ? defaultDuration : Math.min(30, defaultDuration); | ||
| const offered = durations.map((button) => Number(button.dataset.duration)); | ||
| return offered.reduce((best, value) => | ||
| Math.abs(value - wanted) < Math.abs(best - wanted) ? value : best, | ||
| ); | ||
| } |
There was a problem hiding this comment.
docs/interview-length.md (lines 18–19) specifies: "A default that is not one of the three buttons selects the nearest enabled one". Currently, suggestedDuration maps over all durations without filtering out button.disabled, relying solely on downstream underCeiling() in setDuration() to correct values above durationCeiling. If any button is disabled for reasons other than a ceiling (or if suggestedDuration is reused elsewhere), it returns a disabled duration.
Filtering to enabled buttons first aligns suggestedDuration directly with the documented contract:
| function suggestedDuration(difficulties) { | |
| return difficulties.has("Medium") || difficulties.has("Hard") ? 45 : 30; | |
| const hard = difficulties.has("Medium") || difficulties.has("Hard"); | |
| const wanted = hard ? defaultDuration : Math.min(30, defaultDuration); | |
| const offered = durations.map((button) => Number(button.dataset.duration)); | |
| return offered.reduce((best, value) => | |
| Math.abs(value - wanted) < Math.abs(best - wanted) ? value : best, | |
| ); | |
| } | |
| function suggestedDuration(difficulties) { | |
| const hard = difficulties.has("Medium") || difficulties.has("Hard"); | |
| const wanted = hard ? defaultDuration : Math.min(30, defaultDuration); | |
| const enabled = durations.filter((button) => !button.disabled); | |
| const pool = enabled.length > 0 ? enabled : durations; | |
| const offered = pool.map((button) => Number(button.dataset.duration)); | |
| return offered.reduce((best, value) => | |
| Math.abs(value - wanted) < Math.abs(best - wanted) ? value : best, | |
| ); | |
| } |
Local reproduction & test evidence:
- Environment:
MINGW64_NT-10.0-26200/ Nodev26.13.0 - Reproduction command:
node -e 'const durations = [{ dataset: { duration: "30" }, disabled: false }, { dataset: { duration: "45" }, disabled: true }, { dataset: { duration: "60" }, disabled: true }]; const wanted = 60; const offered = durations.map((b) => Number(b.dataset.duration)); const picked = offered.reduce((best, value) => Math.abs(value - wanted) < Math.abs(best - wanted) ? value : best); console.log({ enabledButtons: durations.filter(b => !b.disabled).map(b => b.dataset.duration), picked });' - Output:
{ enabledButtons: [ '30' ], picked: 60 } - Browser test suite (
node --test tests/browser/):350 passed, 0 failed.
There was a problem hiding this comment.
Only applyDurationCeiling disables a button, and setDuration passes the suggestion through underCeiling, which lands on the largest enabled length. Compared with the filtered version for every default and cap from 10 to 90 and both difficulty groups (6642 cases), the result is the same in all of them, so I am leaving it as is.
Problem and behavior
CODETRIAL_DURATION_MINis documented as the length the lobby preselects, but onlycheck-gemini, the setup probe and the recording cap check read it, so an operator who set 30 still saw 45 for Medium and Hard, and a token request that named no length got the constant 45.With this change
/api/sessionreports the default asdefaultDurationMin, the lobby preselects it once the session answers (Medium and Hard take it, Easy at most 30, snapped to the nearest enabled button), and Start sends the length on screen. A token request that names no length is granted the default, unsnapped.With the variable unset the lobby still starts on 45. Two direct-link cases change:
?duration=-5and?duration=30abcnow name no length and get the default instead of 10 and 30.Approach
default_durationinsrc/web/token.rsclamps the configured value into 10 to 90 and to the recording ceiling, and both/api/sessionand/api/tokencall it.configured_durationinsrc/config.rsreads the setting for the web server and the agent modes: text that is no whole number refuses startup, and a number outside 10 to 90 is clamped and named once on stderr.web/app.jsre-suggests the length when the session answers, except under a Start already on its way, so the length on screen is the one that ships.Validation
cargo test --locked,cargo clippy --locked --all-targetsandnode --test tests/browser/pass, apart from time-dependent livekit startup tests and browser timeouts outside this change, which fail now and then on this machine, one of them on a cleanupstream/maintoo. Each new rule has a test that fails when its line is reverted../scripts/test.shwas not rerun on this head. I did not check the lobby by hand in a browser.Interactive review
This is one commit over the 200-line threshold, so each pushed head went through the local interactive review.
Suggested reading order:
src/web/token.rs(default_duration,token_duration_min),src/config.rs(configured_duration),web/app.js(suggestedDuration,loadAccount, the Start handler), then the tests.Closes #582
Summary by cubic
CODETRIAL_DURATION_MINnow preselects the interview length in the lobby and becomes the default granted to a token request that names none; previously the lobby always started on 45 for Medium and Hard, and a nameless request got the constant 45./api/sessionreports the default asdefaultDurationMin; the lobby preselects it for Medium and Hard, caps Easy at 30, and snaps non-button values to the nearest enabled button.null,false,0and non-finite text name no length either.durationMinwhen the URL names none, cuts fractions to whole minutes, and waits for/api/sessionbefore drawing its round plan; a Start pressed before/api/sessionanswers leaves the length out unless the lobby already changed it.With the variable unset, behavior is unchanged.
Closes #582
Written for commit cf1ad2b. Summary will update on new commits.