diff --git a/src/App.tsx b/src/App.tsx index f75a7a1..6d640d8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -226,6 +226,19 @@ export default function App() { // The come-back nudge moves to tomorrow on every launch and every new clear (or is used up). const clearedCount = Object.keys(progress.stars).length; useEffect(() => void refreshNudge(progressRef.current), [clearedCount, language]); + // Phones keep the app suspended for days, so coming back from the background counts as a launch: + // the nudge moves on (it must not arrive on a day they opened the game), and a new day re-renders + // so today's warm-up and daily show without a restart. + const [, setToday] = useState(dateKey); + useEffect(() => { + const back = () => { + if (document.visibilityState !== 'visible') return; + setToday(dateKey()); + void refreshNudge(progressRef.current); + }; + document.addEventListener('visibilitychange', back); + return () => document.removeEventListener('visibilitychange', back); + }, []); // Tapping the nudge opens the warm-up, when there is one today. useEffect( () => diff --git a/src/editor/firstFloors.test.ts b/src/editor/firstFloors.test.ts index 60d9d7d..4344065 100644 --- a/src/editor/firstFloors.test.ts +++ b/src/editor/firstFloors.test.ts @@ -4,6 +4,7 @@ import { parseReference } from '../sim/program'; import { introPalette, isIntroFloor, newCommands, nextStep, pathPreview } from './firstFloors'; import { PALETTE_ORDER } from './commands'; import type { LevelFile } from '../sim/types'; +import { warmupLevel } from '../daily/warmup'; const level = (id: string) => LEVELS.find((l) => l.id === id) as LevelFile; const commandsOf = (id: string) => LEVELS.find((l) => l.id === id)?.commands; @@ -22,6 +23,11 @@ describe('first floors', () => { expect(introPalette(level('t1-f06'), PALETTE_ORDER)).toEqual(PALETTE_ORDER); }); + it('gives the day-2 warm-up the same short palette (its players are on the intro floors)', () => { + expect(introPalette(warmupLevel('2026-11-25', 'turn'), PALETTE_ORDER)).toEqual(['forward', 'turn_left', 'turn_right']); + expect(introPalette(warmupLevel('2026-11-25', 'jumps'), PALETTE_ORDER)).toEqual(['forward', 'turn_left', 'turn_right', 'jump']); + }); + it('marks the commands each intro floor brings in as new', () => { expect([...newCommands('t1-f01', commandsOf)]).toEqual([]); expect([...newCommands('t1-f02', commandsOf)].sort()).toEqual(['turn_left', 'turn_right']); diff --git a/src/editor/firstFloors.ts b/src/editor/firstFloors.ts index 0b7e435..f8a4b56 100644 --- a/src/editor/firstFloors.ts +++ b/src/editor/firstFloors.ts @@ -12,6 +12,7 @@ import { Runner } from '../sim/interpreter'; import { shortestActionPath } from '../sim/solver'; import { applyAction, cloneWorld, createWorld, goalsMet } from '../sim/world'; import { makeBlock } from '../sim/program'; +import { isWarmupId } from '../daily/warmup'; /** Tower 1's opening floors, in order. */ export const INTRO_FLOORS = ['t1-f01', 't1-f02', 't1-f03', 't1-f04', 't1-f05']; @@ -23,9 +24,12 @@ export function isIntroFloor(id: string): boolean { return INTRO_FLOORS.includes(id); } -/** On the intro floors, drop the palette commands this floor doesn't have yet. */ +/** + * On the intro floors, drop the palette commands this floor doesn't have yet. The day-2 warm-up is + * for the same early players, so it gets the same short palette. + */ export function introPalette(level: Pick, palette: PaletteCommand[]): PaletteCommand[] { - if (!isIntroFloor(level.id)) return palette; + if (!isIntroFloor(level.id) && !isWarmupId(level.id)) return palette; return palette.filter((c) => (level.commands as string[]).includes(c)); } diff --git a/src/styles.css b/src/styles.css index 1587302..446d3ed 100644 --- a/src/styles.css +++ b/src/styles.css @@ -3050,6 +3050,10 @@ button.set-row { color: var(--ink); font: inherit; font-size: var(--fs-input); + /* a long choice ("Automatique (Français)") shrinks instead of pushing out of the row on narrow phones */ + min-width: 0; + max-width: 65%; + text-overflow: ellipsis; } .reminder-ask { margin: 10px 0 4px;