[Workbench] Session pickers default to the furthest-out session, not the next one #302
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
In the GM Workbench, the session dropdown (Session Prep, Beat Planner, Series Titles) defaults to the last occurrence of a recurring series — a month out — instead of the current/next session. Reported during real session prep: a prep sheet generated with the defaults is prepping for the wrong session.
Cause
GET /api/campaigns/{id}/sessionsreturns sessions newest-first bycreated_at:.order_by(Session.created_at.desc(), Session.id)Every consumer that picks "the first upcoming session" then gets the most recently created one. For a recurring series,
materialize_session_seriescreates occurrences in date order in one batch, so the last-created row is the furthest-out occurrence — which lands at index 0.Affected call sites:
autoSelectFirsttakesopts[0].id. Used bysession_prep(workbenchTools.jsx:691-703) andseries_titles.selectedIdfromactiveSessions[0].The dropdown option order is wrong too, not just the default — the list reads furthest-out first, so scrolling to the right session is unintuitive.
The rule already exists
AddToShelfgets this right and is already exported for reuse — AddToShelf.jsx:24-32:Note the resulting inconsistency inside a single Session Prep panel: the "Add to shelf" picker at the bottom defaults to the next session while the "Session" picker at the top defaults to the furthest-out one.
Proposed fix
sessionSelectoptions byconfirmed_timeascending (undated last) insessionOptions()so the dropdown reads next-first.autoSelectFirstand Beat Planner's seed use the shareddefaultSessionIdrule (preferin_progress, else earliest upcoming) rather than[0].created_at descis right for the session list views; this is a Workbench-side selection bug.Sorting client-side is enough given the page already fetches the session list; no API change needed.
Related
Cross-reference for the "Related" placeholder in the body — all four came out of the same session-prep run on 2026-08-11:
Suggested order: #303 → #302 → #305, since #305 is largely downstream of the other two. #304 is independent.
Picking this up as v4.3.0 phase 3 (#514), first on the Prep lane (#302 → #303 → #304 → #305 → #374 → #381). Client-side: the picker sorts by confirmed time, next first, and both the Session Prep picker and Beat Planner seed from the shared
defaultSessionIdruleAddToShelfalready exports. API ordering unchanged.Fixed in the phase 3 PR (auto-merging on green); ships with v4.3.0.
GET /api/campaigns/{id}/sessionsstill returns newest-created-first; that ordering is right for the history list and is unchanged. What changed is that the pickers stopped trusting it.webapp/frontend/src/utils/sessionOrder.js(soonestFirst) is now the single rule: dated sessions ascending, undated last.GeneratorPanel.sessionOptionssorts with it,autoSelectFirstmeans "whateverAddToShelf.defaultSessionIdwould pick" (in progress, else soonest), andAddToShelf's own rule is re-expressed on top of the shared sort so the two cannot drift.Three pickers fixed, not two: the Name Generator's session context had the identical bug, and leaving it on the old rule would have been exactly the drift this issue is about.
For the record: no existing test pinned the old behaviour. The
session_prepfixture's sessions carry noconfirmed_time, so a stable sort preserved their order and every assertion still passed. The new tests would have caught it: a weekly series in API order defaults to week 1 rather than week 3, and in-progress wins over soonest-upcoming.