Skip to content

feat(tour): post-login product tour foundation + M0/M0.5/M1#244

Open
artlut-eng wants to merge 1 commit into
mainfrom
feat/tour-m0-m05
Open

feat(tour): post-login product tour foundation + M0/M0.5/M1#244
artlut-eng wants to merge 1 commit into
mainfrom
feat/tour-m0-m05

Conversation

@artlut-eng

Copy link
Copy Markdown
Collaborator

Resumo

Primeiro checkpoint estável do tour pós-login (tour-pos-login.md). Entrega a fundação modular + os três primeiros módulos (M0 Boas-vindas, M0.5 Escolher 3 tarefas, M1 Tour interativo de Tasks). M2–M6 e Wrap-up virão em PRs separadas.

Foundation

  • Store (lib/tour/store.ts) — Zustand + AsyncStorage por character_id (rpgtasks.tour.v1.{id}). Persiste modules (status por módulo), mantém stepIndices em memória pra módulos multi-tela compartilharem progresso. resetAll() pro botão de Settings.
  • Event bus (lib/tour/eventBus.ts) — Contador por evento. Cada <TourModule> guarda baseline no mount do step e só avança em emissões NOVAS.
  • Active step broadcastuseActiveTourStepStore propaga {module, position} pra Home reservar scroll bump abaixo do tooltip.

Componentes

  • TourStep — Tooltip não-bloqueante (pointerEvents: 'box-none'), sem dim band, card com sombra forte. Bottom padding via useBottomNavClearance.
  • FullScreenStep — Painel cheio Perceva-branded pra M0 e Wrap-up futuro.
  • TourModule — Runner genérico: filtro por screen, avanço por Próximo / evento / timer, callbacks onExitScreen (pra fechar detalhes ao avançar) e onComplete.

Módulos

  • M0 — Boas-vindas (app/tour/m0.tsx) — Full-screen Perceva. Skip semeia 3 templates default só se o user tem <3 tarefas.
  • M0.5 — Escolher 3 tarefas (app/tour/m0-5.tsx) — Grid de 12 cards curados (1 por sub-atributo). Cards já adotados ficam dimmed com badge. Skip respeita o mesmo guard de M0.
  • M1 — Tour de Tasks — 5 steps gesto-driven (TASK_TAPPED → TASK_LONG_PRESSED → TASK_COMPLETED → DRAWER_EXPANDED). Step 2 vive no task-form; X / Próximo fecham detail via onExitScreen. useFocusEffect em task-form garante avanço mesmo quando o user fecha por hardware back.

Wiring

  • AuthGate redireciona pra /tour/m0 quando m0Status === 'pending' e onboarding já visto.
  • Home emite TASK_TAPPED / LONG_PRESSED / COMPLETED / DRAWER_EXPANDED e calcula tourBottomBump baseado no position do step ativo.
  • CompletedBucket ganhou prop onToggle?(open) pra emitir DRAWER_EXPANDED.
  • Profile — "Refazer onboarding" agora reseta useOnboardingStore + useTourStore (catch-all temporário; per-module replay vem depois).

i18n

  • Novas chaves tour.common.*, tour.m0.*, tour.m0_5.*, tour.m1.step{1..5}.* em pt-BR e en-US.

Bugfixes que entraram junto

  • Web: useNotificationsSetup agora guarda Platform.OS !== 'web' — expo-notifications não tem shim web e crashava o bundle no Metro local.
  • Migration circle_message: record 'v_template' has no field 'sub_id' — Já mergeado na main via feat(learning): summary — Deep Work (Cal Newport) #242, mas o arquivo está aqui também (resolvido pelo rebase pra ficar igual main).

Test plan

  • Login fresh → cai direto em /tour/m0
  • M0 Skip com 0 tasks → seeda 3 defaults; com 3+ tasks → não duplica
  • M0.5 adotando 3 tasks únicas avança normal
  • M0.5 Skip com 3+ tasks adotadas → não semeia nada
  • M1 segue gesto a gesto, step 2 na detail, X fecha + avança
  • Settings "Refazer onboarding" → volta a M0 limpo
  • Web (Metro): login funciona sem crash de notifications

Follow-ups

  • M2 (criar task), M3 (quests), M4 (rewards), M5 (Me), M6 (Learn), Wrap-up
  • Per-module replay list em Settings (substituir o catch-all atual)

First slice of the post-login tour spec from
design_handoff_tour_pos_login. Ships the foundation (state, components,
i18n) plus the first three modules end-to-end:

Foundation (`app/lib/tour/`)
- `constants.ts`  module ids in order, 12 curated initial templates,
                  3 silent-seed fallbacks, sub map for the picker.
- `store.ts`      zustand + AsyncStorage, keyed per character_id so
                  per-user state doesn't bleed between accounts.
                  Holds per-module status + in-memory stepIndex
                  shared across multiple `<TourModule>` mounts.
                  Also `useActiveTourStep()` for layout consumers
                  that need to reserve space behind the tooltip.
- `eventBus.ts`   counter-based emit/listen bus. Steps with
                  `awaitEvent` advance on emission; baseline-at-mount
                  pattern means only NEW emits count.
- `m1Steps.ts`    config for M1.

Components (`app/components/tour/`)
- `FullScreenStep`  reusable Perceva-branded hero panel (used by M0).
- `TourStep`        non-blocking tooltip overlay — `pointerEvents:
                    'box-none'`, no dim, only the card catches touches.
                    Floats above the BottomNavBar via `useBottomNavClearance`.
- `TourModule`      generic runner: respects per-screen filtering via
                    `screen` prop, drives advance via Next / awaitEvent
                    / autoAdvanceMs, calls optional `onExitScreen`
                    after navigation away.

Modules
- M0   `/tour/m0` — welcome card with name + Começar/Pular.
- M0.5 `/tour/m0-5` — grid of 12 selectable cards; "Continuar"
       enables at exactly 3. Skipping silently seeds 3 defaults
       (dexterity/stretch, learn/read, circle/message) — but only
       when the user has fewer than 3 tasks already, and never
       duplicates templates they already own.
- M1   5 interactive spotlights on Home + task-form:
         1. tap a task     (awaitEvent task:tapped)
         2. detail screen   (Next-to-advance, lives on /task-form)
         3. long-press      (awaitEvent task:long-pressed)
         4. mark as done    (awaitEvent task:completed)
         5. expand drawer   (awaitEvent drawer:expanded)
       Closing /task-form via the screen's own X / save / back
       auto-advances to step 3 via `useFocusEffect` so the user is
       never stranded.

Wiring
- AuthGate (in `_layout.tsx`) routes new authenticated users to
  /tour/m0 when M0 status is `pending` and onboarding slides are done.
- Settings "Refazer onboarding" now also resets every tour module
  (temporary catch-all until per-module replay lands).
- Home (`(tabs)/index.tsx`) emits task:tapped / task:long-pressed /
  task:completed / drawer:expanded; bumps scroll paddingBottom by
  160px while a bottom tooltip is visible so the relevant content
  settles just above the card.
- task-form emits step 2 + auto-advances on blur.
- CompletedBucket gains an optional `onToggle(open)` callback.
- useNotificationsSetup early-returns on web (notifications module
  has no web shim — was crashing the login flow there).

DB
- `supabase/migrations/20260602000002_start_task_from_template_fix.sql`
  fixes a latent bug in the May-24 RPC that still referenced legacy
  `task_template.sub_id` + difficulty/metric columns (dropped in the
  multi-sub migration). Was undetected until M0.5 became the first
  caller exercising the adoption path. Already applied to cloud.

i18n
- `tour.common.*` + `tour.m0.*` + `tour.m0_5.*` + `tour.m1.step{1..6}.*`
  in PT and EN.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant