diff --git a/backend/app/routers/logs.py b/backend/app/routers/logs.py index df596ff..9c1dac8 100644 --- a/backend/app/routers/logs.py +++ b/backend/app/routers/logs.py @@ -31,7 +31,10 @@ async def get_timeline( .where(Child.user_id == current_user.id) .options( selectinload(TimerEvent.block).selectinload(ScheduleBlock.subject), - selectinload(TimerEvent.session).selectinload(DailySession.child), + selectinload(TimerEvent.session).options( + selectinload(DailySession.child), + selectinload(DailySession.template), + ), ) .order_by(TimerEvent.occurred_at.desc()) ) @@ -49,6 +52,10 @@ async def get_timeline( def _to_timeline_out(e: TimerEvent) -> TimelineEventOut: blk = e.block sub = blk.subject if blk else None + if e.event_type == "session_start": + block_label = e.session.template.name if e.session.template else None + else: + block_label = (blk.label or sub.name) if blk and sub else (blk.label if blk else None) return TimelineEventOut( id=e.id, event_type=e.event_type, @@ -56,7 +63,7 @@ def _to_timeline_out(e: TimerEvent) -> TimelineEventOut: session_date=e.session.session_date, child_id=e.session.child_id, child_name=e.session.child.name, - block_label=(blk.label or sub.name) if blk and sub else (blk.label if blk else None), + block_label=block_label, subject_name=sub.name if sub else None, subject_icon=sub.icon if sub else None, subject_color=sub.color if sub else None, @@ -71,7 +78,10 @@ async def _get_timer_event(event_id: int, current_user: User, db: AsyncSession) .where(TimerEvent.id == event_id, Child.user_id == current_user.id) .options( selectinload(TimerEvent.block).selectinload(ScheduleBlock.subject), - selectinload(TimerEvent.session).selectinload(DailySession.child), + selectinload(TimerEvent.session).options( + selectinload(DailySession.child), + selectinload(DailySession.template), + ), ) ) event = result.scalar_one_or_none() diff --git a/backend/app/routers/sessions.py b/backend/app/routers/sessions.py index 946ebb3..a093829 100644 --- a/backend/app/routers/sessions.py +++ b/backend/app/routers/sessions.py @@ -126,6 +126,11 @@ async def start_session( db.add(session) await db.commit() await db.refresh(session) + + # Record session start as a timer event so it appears in the activity log + db.add(TimerEvent(session_id=session.id, block_id=None, event_type="session_start")) + await db.commit() + await _broadcast_session(db, session) return session diff --git a/frontend/src/views/LogView.vue b/frontend/src/views/LogView.vue index fbc4fe4..4b66a5d 100644 --- a/frontend/src/views/LogView.vue +++ b/frontend/src/views/LogView.vue @@ -101,7 +101,7 @@
- +
@@ -183,11 +183,12 @@ function fmtTime(isoStr) { } const EVENT_META = { - start: { icon: '▶', label: 'Started' }, - pause: { icon: '⏸', label: 'Paused' }, - resume: { icon: '↺', label: 'Resumed' }, - complete: { icon: '✓', label: 'Completed' }, - skip: { icon: '⟶', label: 'Skipped' }, + session_start: { icon: '🏫', label: 'Day started' }, + start: { icon: '▶', label: 'Started' }, + pause: { icon: '⏸', label: 'Paused' }, + resume: { icon: '↺', label: 'Resumed' }, + complete: { icon: '✓', label: 'Completed' }, + skip: { icon: '⟶', label: 'Skipped' }, } function eventIcon(entry) {