Add manual block start and fix timer display labels

Blocks are now selected without auto-starting the timer. Clicking a block
makes it current (highlighted) but leaves it in a ready state. A "Start"
button (indigo) triggers timing for a fresh block; "Resume" appears for
previously-worked blocks; "Pause" remains while running.

Also fixes the sidebar duration label to show "Done!" when elapsed ≥ total
and "< 1 min" for sub-minute remaining time instead of "0 min".

Backend adds a "select" event type that records an implicit pause for the
previous block, updates current_block_id, and broadcasts is_paused=true
with prev_block_elapsed_seconds so the TV sidebar stays accurate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-03 00:09:27 -08:00
parent ca858c2050
commit cc599603cf
4 changed files with 102 additions and 26 deletions

View File

@@ -47,9 +47,14 @@
v-if="scheduleStore.session.current_block_id && !scheduleStore.isPaused"
@click="sendAction('pause')"
>Pause</button>
<button
class="btn-sm btn-start"
v-if="scheduleStore.isPaused && scheduleStore.blockElapsedOffset === 0 && scheduleStore.session.current_block_id"
@click="scheduleStore.startCurrentBlock(scheduleStore.session.id)"
>Start</button>
<button
class="btn-sm"
v-if="scheduleStore.isPaused"
v-if="scheduleStore.isPaused && scheduleStore.blockElapsedOffset > 0"
@click="sendAction('resume')"
>Resume</button>
<button class="btn-sm btn-danger" @click="sendAction('complete')">End Day</button>
@@ -227,20 +232,9 @@ function blockElapsed(block) {
function selectBlock(block) {
if (!scheduleStore.session) return
const currentId = scheduleStore.session.current_block_id
// Clicking the current block while paused → resume it
if (block.id === currentId && scheduleStore.isPaused) {
scheduleStore.sendTimerAction(scheduleStore.session.id, 'resume')
return
}
// Clicking the current block while running → do nothing
if (block.id === currentId) return
// Switch to the new block in one atomic step (no separate pause request)
scheduleStore.switchBlock(scheduleStore.session.id, block.id)
// Clicking the current block does nothing — use Start/Pause/Resume buttons
if (block.id === scheduleStore.session.current_block_id) return
scheduleStore.selectBlock(scheduleStore.session.id, block.id)
}
onMounted(async () => {
@@ -327,6 +321,8 @@ h1 { font-size: 1.75rem; font-weight: 700; }
.btn-sm:hover { background: #334155; }
.btn-sm.btn-danger { border-color: #7f1d1d; color: #fca5a5; }
.btn-sm.btn-danger:hover { background: #7f1d1d; }
.btn-sm.btn-start { border-color: #4f46e5; color: #818cf8; }
.btn-sm.btn-start:hover { background: #4f46e5; color: #fff; }
.no-session { text-align: center; padding: 1.5rem 0; color: #64748b; }
.no-session p { margin-bottom: 1rem; }