linnet/compose.yml
pyr0ball 1bc47b8e0f fix: mobile tab timeout — idle session reaper + wake lock + visibility reconnect
Backend:
- Session.last_subscriber_left_at: monotonic timestamp set when last SSE subscriber
  leaves, cleared when a new one arrives
- Session.subscriber_count(): replaces len(_subscribers) access from outside the model
- session_store._reaper_loop(): kills sessions with no subscribers for >SESSION_IDLE_TTL_S
  (default 90s); runs every TTL/2 seconds via asyncio.create_task at startup
- session_store._reaper_loop_once(): single-cycle variant for deterministic tests
- app/main.py lifespan: starts reaper on startup, cancels it cleanly on shutdown
- config.py: SESSION_IDLE_TTL_S setting (90s default, overridable per-env)

Frontend:
- useWakeLock.ts: Screen Wake Lock API wrapper; acquires on connect, releases on
  disconnect; degrades silently when unsupported (battery saver, iOS Safari)
- useToneStream.ts: visibilitychange handler — on hidden: closes EventSource without
  ending backend session (grace window stays open); on visible: GET /session/{id}
  liveness check, reconnects SSE + re-acquires wake lock if alive, sets expired=true
  and calls store.reset() if reaped
- ComposeBar.vue: surfaces expired state with calm 'Session timed out' notice
  (not an error — expected behaviour on long screen-off)

Tests:
- test_reaper.py: 7 tests covering subscriber idle tracking, reaper eligibility
  (kills idle, spares active subscriber, spares within-TTL)
2026-04-11 09:42:42 -07:00

31 lines
752 B
YAML

services:
linnet-api:
build:
context: .
dockerfile: Dockerfile
args:
GIT_TOKEN: ${GIT_TOKEN:-}
ports:
- "${LINNET_PORT:-8522}:8522"
env_file:
- .env
environment:
CF_VOICE_MOCK: "${CF_VOICE_MOCK:-1}"
volumes:
# Live-reload app code without rebuilding the image in dev
- ./app:/app/app:ro
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped
linnet-frontend:
image: node:20-slim
working_dir: /app
volumes:
- ./frontend:/app
ports:
- "${LINNET_FRONTEND_PORT:-8521}:8521"
command: sh -c "npm install && npm run dev -- --host 0.0.0.0"
environment:
NODE_ENV: development
restart: unless-stopped