Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ab90267
Voting sidebar menu
Le-frances13 Aug 24, 2026
1bda07b
feat: Many UI Improvements
Le-frances13 Aug 24, 2026
9fd4c09
feat: motion dialog closes afther sending motion
Le-frances13 Aug 24, 2026
9439c61
feat: voting results
Le-frances13 Aug 24, 2026
9158e00
fix: veto check stops crashing frontend
Le-frances13 Aug 24, 2026
6fd1258
Merge branch 'main' into frontend/UI
Extroias Aug 26, 2026
5015af3
fix: minor fixes
Extroias Aug 26, 2026
c743f91
feat: many UI fixes
Le-frances13 Aug 29, 2026
ca51636
Fix: motions button locked in unmoderated debate
Le-frances13 Aug 29, 2026
779508b
fix: improve apply passed motion and allowed motions list
Extroias Aug 29, 2026
7d17683
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Extroias Aug 29, 2026
09154d6
fix: changed error
Extroias Aug 29, 2026
c8868e2
feat: quorum sidebar menu
Le-frances13 Aug 29, 2026
f4a0973
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Le-frances13 Aug 29, 2026
8d4016b
fix: voting menu sidebar text centering
Le-frances13 Aug 29, 2026
540f250
fix: time cece button disables if there is no time to cede
Le-frances13 Aug 29, 2026
34a5a75
feat: timer disapears on unmoderated debate
Le-frances13 Aug 29, 2026
e22d9f2
feat: delegation map halos effects when voting
Le-frances13 Aug 30, 2026
8ee9364
fix: removal of not ready yet features
Le-frances13 Aug 30, 2026
93a7db9
feat: roll call answer implementaiton
Le-frances13 Aug 30, 2026
4a4e1ef
fix: removed contaxt menu for delegate view
Le-frances13 Aug 30, 2026
317888b
feat: Log Motion on frontend
Extroias Aug 30, 2026
06e37c8
fix: voting result popup now works
Extroias Aug 30, 2026
7737e61
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Extroias Aug 30, 2026
25397d9
fix: minor fix on close session
Extroias Aug 31, 2026
8c9008b
feat: QOL session dialog closes as button is pressed
Le-frances13 Aug 31, 2026
56f05ff
feat: QOL close roll call from sidebar
Le-frances13 Aug 31, 2026
3ff6a0e
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Le-frances13 Aug 31, 2026
3fc1f1e
feat? new logo
Le-frances13 Aug 31, 2026
6187050
fix: popup issues
Extroias Aug 31, 2026
e4f31a2
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Extroias Aug 31, 2026
e3781a9
feat: added actual links to footer
Le-frances13 Aug 31, 2026
be17e54
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Le-frances13 Aug 31, 2026
f7c763e
feat: new logo types
Le-frances13 Aug 31, 2026
0262b5c
fix: cede time timerisrunning check
Le-frances13 Aug 31, 2026
cf91e64
feat: Cede Time event now working
Extroias Aug 31, 2026
a7580aa
fix: commented unused delegation acntions
Le-frances13 Aug 31, 2026
233eab6
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Le-frances13 Aug 31, 2026
e143e19
fix: end speech button disables when timer is running
Le-frances13 Aug 31, 2026
a687e5a
feat: visual clue for cede time
Le-frances13 Aug 31, 2026
1cef500
feat: cancel cede time
Le-frances13 Aug 31, 2026
e6c2c68
feat: End Speech event and functionality
Extroias Aug 31, 2026
a140771
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Extroias Aug 31, 2026
7a78049
fix: cancel cede time works
Le-frances13 Aug 31, 2026
65d411c
Merge branch 'frontend/UI' of https://github.com/uspcodelab/webmun in…
Le-frances13 Aug 31, 2026
88980e0
feat: end speech turns off cede time
Le-frances13 Aug 31, 2026
6ea12c0
Merge branch 'main' into frontend/UI
r0liveir Aug 31, 2026
f3202a9
chore: update eslint rules to disable unused vars check, and format s…
r0liveir Aug 31, 2026
8af818a
Fix session engine event outcomes
r0liveir Aug 31, 2026
2dd03be
chore: remove unused imports
r0liveir Aug 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 148 additions & 72 deletions backend/app/session/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,37 @@
Motions.POSTPONE_SESSION,
Motions.TOUR_DE_TABLE,
Motions.END_DEBATE,
Motions.VOTE_AMENDMENT,
Motions.VOTE_BY_ROLL_CALL,
Motions.CLOSE_SPEAKERS_LIST,
Motions.SPLIT_PROPOSAL,
Motions.INTRODUCE_RESOLUTION_PROPOSAL,
Motions.INTRODUCE_AMENDMENT_PROPOSAL,
Motions.CHANGE_TOPIC,
Motions.QUORUM,
Motions.CUSTOM_MOTION,
},
States.CLOSED_GSL: {
Motions.REOPEN_SPEAKERS_LIST,
Motions.CHANGE_DEBATE_TYPE,
Motions.POSTPONE_SESSION,
Motions.TOUR_DE_TABLE,
Motions.END_DEBATE,
Motions.VOTE_AMENDMENT,
Motions.VOTE_BY_ROLL_CALL,
Motions.REOPEN_SPEAKERS_LIST,
Motions.INTRODUCE_RESOLUTION_PROPOSAL,
Motions.INTRODUCE_AMENDMENT_PROPOSAL,
Motions.CHANGE_TOPIC,
Motions.QUORUM,
Motions.CUSTOM_MOTION,
},
States.VOTING_PREPARATION: {
Motions.VOTE_BY_ROLL_CALL,
Motions.SPLIT_PROPOSAL,
Motions.INTRODUCE_AMENDMENT_PROPOSAL,
Motions.VOTE_AMENDMENT,
Motions.CUSTOM_MOTION,
},
States.MODERATED_CAUCUS: {
Motions.CHANGE_DEBATE_TYPE,
Motions.POSTPONE_SESSION,
Motions.TOUR_DE_TABLE,
Motions.END_DEBATE,
Motions.INTRODUCE_RESOLUTION_PROPOSAL,
Motions.CHANGE_TOPIC,
Motions.QUORUM,
Motions.CUSTOM_MOTION,
},
Expand Down Expand Up @@ -110,14 +113,19 @@
"""Should validate motion payload before submitting"""

# can also raise error if there are missing fields
if (
payload.type == Motions.CHANGE_DEBATE_TYPE
and payload.debate_type == DebateTypes.MODERATED_DEBATE
and payload.per_speaker_seconds is None
if payload.type == Motions.CHANGE_DEBATE_TYPE and (
(
payload.debate_type == DebateTypes.UNMODERATED_DEBATE
and payload.total_duration_minutes is None
)
or (
payload.debate_type == DebateTypes.MODERATED_DEBATE
and payload.per_speaker_seconds is None
)
):
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_MESSAGE,
message="Cannot submit motion without speaking time",
message="Cannot submit debate motion without the required duration",
)


Expand Down Expand Up @@ -278,7 +286,11 @@
)

if (
current_state in {States.MODERATED_CAUCUS, States.UNMODERATED_CAUCUS}
current_state
in {
States.MODERATED_CAUCUS,
States.UNMODERATED_CAUCUS,
}
and not state.can_set_motion
):
raise EventRejectedError(
Expand Down Expand Up @@ -422,10 +434,10 @@
) -> DispatchOutcome:
require_chair(actor)

if state.current_state not in (States.SETUP, States.ROLL_CALL, States.FINISHED):
if state.current_state != States.ROLL_CALL:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Session may only be closed from setup, roll_call or finished",
message="Session may only be closed during roll call",
)

state.current_state = States.FINISHED
Expand Down Expand Up @@ -551,50 +563,56 @@
state.timer_is_running = False
state.timer_expiration = None

# 1st block: change of debate motions
if motion.type == Motions.CHANGE_DEBATE_TYPE and motion.debate_type is not None:
state.caucus_list = []
state.current_speaker = None
duration_seconds = (
(motion.total_duration_minutes * 60)
if motion.total_duration_minutes is not None
else 600
) # defaults to 10 minutes as fallback

match motion.debate_type:
case DebateTypes.MODERATED_DEBATE:
next_state = States.MODERATED_CAUCUS
state.debate = DebateContext(
debate_type=DebateTypes.MODERATED_DEBATE,
return_state=return_state,
total_duration_seconds=duration_seconds,
per_speaker_seconds=motion.per_speaker_seconds,
expires_at=datetime.now(UTC) + timedelta(seconds=duration_seconds),
)
reset_timer(
state,
motion.per_speaker_seconds
if motion.per_speaker_seconds is not None
else 60,
)

case DebateTypes.UNMODERATED_DEBATE:
next_state = States.UNMODERATED_CAUCUS
state.debate = DebateContext(
debate_type=DebateTypes.UNMODERATED_DEBATE,
return_state=return_state,
total_duration_seconds=duration_seconds,
per_speaker_seconds=None,
expires_at=datetime.now(UTC) + timedelta(seconds=duration_seconds),
)
reset_timer(state) # should not display per_speaker timer

case DebateTypes.SPEAKERS_LIST:
next_state = States.OPEN_GSL
state.debate = None
reset_timer(state, state.gsl_default_time_seconds)

match motion.type:
case Motions.CHANGE_DEBATE_TYPE:
if motion.debate_type is None:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_MESSAGE,
message="No Debate Type Provided",
)
state.current_speaker = None
duration_seconds = (
(motion.total_duration_minutes * 60)
if motion.total_duration_minutes is not None
else 600
) # defaults to 10 minutes as fallback

match motion.debate_type:
case DebateTypes.MODERATED_DEBATE:
next_state = States.MODERATED_CAUCUS
state.debate = DebateContext(
debate_type=DebateTypes.MODERATED_DEBATE,
return_state=return_state,
total_duration_seconds=duration_seconds,
per_speaker_seconds=motion.per_speaker_seconds
if motion.per_speaker_seconds is not None
else state.gsl_default_time_seconds,
expires_at=datetime.now(UTC)
+ timedelta(seconds=duration_seconds),
)
reset_timer(
state,
motion.per_speaker_seconds
if motion.per_speaker_seconds is not None
else state.gsl_default_time_seconds,
)

case DebateTypes.UNMODERATED_DEBATE:
next_state = States.UNMODERATED_CAUCUS
state.debate = DebateContext(
debate_type=DebateTypes.UNMODERATED_DEBATE,
return_state=return_state,
total_duration_seconds=duration_seconds,
per_speaker_seconds=None,
expires_at=datetime.now(UTC)
+ timedelta(seconds=duration_seconds),
)
reset_timer(state) # should not display per_speaker timer

case DebateTypes.SPEAKERS_LIST:
next_state = States.OPEN_GSL
state.debate = None
reset_timer(state, state.gsl_default_time_seconds)
case Motions.POSTPONE_SESSION:
pass
case Motions.REOPEN_SESSION:
Expand Down Expand Up @@ -681,16 +699,11 @@

present = count_present_delegations(state)
passed = tally_votes(state.voting, present)

# TODO: Change this

Check warning on line 703 in backend/app/session/engine.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=uspcodelab_webmun&issues=AaBYM4Mg2CM7aI0_drZD&open=AaBYM4Mg2CM7aI0_drZD&pullRequest=107
effect = SessionEffect(
type=enums.SessionEffectType.VOTE_CLOSED,
data={
"present": present,
"favour": sum(
vote == enums.VotingChoice.FAVOUR
for vote in state.voting.voting_registry.values()
),
"passed": passed,
},
data={**state.voting.model_dump(mode="json"), "passed": passed},
)

if passed:
Expand Down Expand Up @@ -905,7 +918,7 @@
if representation_id not in state.delegations:
raise EventRejectedError(
code=enums.EventErrorCode.NOT_FOUND,
message="Representation not found",

Check failure on line 921 in backend/app/session/engine.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Representation not found" 3 times.

See more on https://sonarcloud.io/project/issues?id=uspcodelab_webmun&issues=AaBYM4Mg2CM7aI0_drZC&open=AaBYM4Mg2CM7aI0_drZC&pullRequest=107
)

if representation_id not in state.gsl_queue:
Expand Down Expand Up @@ -960,6 +973,72 @@
return DispatchOutcome(state=state)


def handle_cede_time(
state: SessionLiveState, event: schemas.CedeTimeEvent, actor: SessionActor
) -> DispatchOutcome:

representation_id = event.payload.representation_id
if representation_id not in state.delegations:
raise EventRejectedError(
code=enums.EventErrorCode.NOT_FOUND,
message="Representation not found",
)

if state.current_state not in [
States.MODERATED_CAUCUS,
States.OPEN_GSL,
States.CLOSED_GSL,
]:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Can only cede time during moderated debate or debate by list",
)

if state.timer_is_running:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Cannot cede time while timer is running",
)

if not state.current_speaker:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Cannot cede time if there's no speaker",
)

if state.timer_remaining_seconds <= 0:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Cannot cede time if there's no time",
)

state.current_speaker = representation_id

return DispatchOutcome(state=state)


def handle_end_speech(
state: SessionLiveState, event: schemas.EndSpeechEvent, actor: SessionActor
) -> DispatchOutcome:

if state.current_speaker is None:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Cannot end speech without speaker",
)

if state.timer_is_running:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Cannot end speech while timer is running",
)

state.current_speaker = None
reset_timer(state)

return DispatchOutcome(state=state)


def handle_mark_roll_call(
state: SessionLiveState, event: schemas.MarkRollCallEvent, actor: SessionActor
) -> DispatchOutcome:
Expand All @@ -980,11 +1059,6 @@
state: SessionLiveState, event: schemas.MarkRollCallBulkEvent, actor: SessionActor
) -> DispatchOutcome:
require_chair(actor)
if state.current_state != States.ROLL_CALL or state.roll_call is None:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
message="Cannot mark roll call right now",
)

for delegation_id in event.payload.Rollcalls.keys():
if delegation_id not in state.delegations:
Expand Down Expand Up @@ -1056,6 +1130,8 @@
ChairEvents.NEXT_SPEAKER: handle_next_speaker,
ChairEvents.ADD_GSL_SPEAKER: handle_add_gsl_speaker,
ChairEvents.GRANT_FLOOR: handle_grant_floor,
ChairEvents.CEDE_TIME: handle_cede_time,
ChairEvents.END_SPEECH: handle_end_speech,
ChairEvents.MARK_ROLLCALL: handle_mark_roll_call,
ChairEvents.MARK_ROLLCALL_BULK: handle_mark_roll_call_bulk,
ChairEvents.CLOSE_ROLLCALL: handle_close_roll_call,
Expand Down
4 changes: 4 additions & 0 deletions backend/app/session/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ class ChairEvents(StrEnum):
MARK_AGENDA_ITEM = "MarkAgendaItemEvent"
DELETE_AGENDA_ITEM = "DeleteAgendaItemEvent"
SET_AGENDA = "SetAgenda"

NEXT_SPEAKER = "NextSpeakerEvent"
ADD_GSL_SPEAKER = "AddGslSpeakerEvent"
GRANT_FLOOR = "GrantFloorEvent"
CEDE_TIME = "CedeTimeEvent"
END_SPEECH = "EndSpeechEvent"

MARK_ROLLCALL = "MarkRollCallEvent"
MARK_ROLLCALL_BULK = "MarkRollCallBulkEvent"
CLOSE_ROLLCALL = "CloseRollCallEvent"
Expand Down
6 changes: 5 additions & 1 deletion backend/app/session/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ class SessionLiveState(BaseModel):
has_veto_power: bool = False


# Add more effect payload shapes as they are introduced.
EffectPayloads = dict[str, Any]


class SessionEffect(BaseModel):
type: enums.SessionEffectType
data: dict[str, Any] = {}
data: EffectPayloads = {}


class DispatchOutcome(BaseModel):
Expand Down
16 changes: 16 additions & 0 deletions backend/app/session/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ class GrantFloorPayload(BaseModel):
seconds: int | None = Field(default=None, ge=1)


class CedeTimePayload(BaseModel):
representation_id: int


class ChairSetAgendaPayload(BaseModel):
agenda: list[str]

Expand Down Expand Up @@ -201,6 +205,16 @@ class GrantFloorEvent(BaseModel):
payload: GrantFloorPayload


class CedeTimeEvent(BaseModel):
type: Literal[enums.ChairEvents.CEDE_TIME]
payload: CedeTimePayload


class EndSpeechEvent(BaseModel):
type: Literal[enums.ChairEvents.END_SPEECH]
payload: EmptyPayload


class SetAgendaEvent(BaseModel):
type: Literal[enums.ChairEvents.SET_AGENDA]
payload: ChairSetAgendaPayload
Expand Down Expand Up @@ -277,6 +291,8 @@ class DeleteAgendaItemEvent(BaseModel):
| NextSpeakerEvent
| AddGslSpeakerEvent
| GrantFloorEvent
| CedeTimeEvent
| EndSpeechEvent
| SetAgendaEvent
| SetAgendaItemEvent
| MarkAgendaItemEvent
Expand Down
Loading
Loading