release: merge dev into main#21
Merged
Merged
Conversation
Replaces the hand-rolled "5+1+5+1+5" Tec21 calendar with the real periods extracted from the student's official MiTec horario PDF. Periods, materias, CRNs, schedules, and Semana Tec flags now come from the source of truth instead of being computed from a single start date. Backend - lib/pdf/horario-parser.ts: sends the PDF directly to Gemini multimodal (gemini-2.5-flash) with a structured response schema. Returns alumno, matricula, periodo, and an array of materias with their `periodos` (each with inicio/fin/dias/hora_inicio/hora_fin/ubicacion/es_semana_tec). - POST /api/profile/horario: multipart upload, parses, replaces materias_inscritas with PDF-derived rows and updates profiles with periodo_nombre/periodo_inicio/periodo_fin. - lib/tec21/calendar.ts refactor: getPeriodoActivo() reads materias_inscritas.periodos to detect Semana Tec (any active period flagged) or compute the current block boundaries (intersection of active non-tec periods). Returns a human label and dias_restantes_bloque for prompt context. - lib/gemini/prompts.ts: prompt now uses periodo_activo (real data) instead of computed semana_actual; new rules around Semana Tec; stronger Canvas prioritization; few-shot updated to a Semana Tec scenario. - /api/insights/generate: filters materias to those active in the current period, marks Semana Tec materias, keeps Canvas-inferred materias. Frontend - OnboardingFlow rewritten: paso 3 ahora es "sube tu PDF de MiTec" en lugar de selección manual de materias. Auto-fills nombre/matricula del PDF. - Old SelectedMateria/TOGGLE_MATERIA logic removed — PDF is source of truth. Schema - profiles.semestre_inicio dropped; replaced by periodo_nombre/periodo_inicio/periodo_fin. - materias_inscritas: + crn text, + periodos jsonb. Migration: ALTER TABLE profiles DROP COLUMN IF EXISTS semestre_inicio; ALTER TABLE profiles ADD COLUMN IF NOT EXISTS periodo_nombre text; ALTER TABLE profiles ADD COLUMN IF NOT EXISTS periodo_inicio date; ALTER TABLE profiles ADD COLUMN IF NOT EXISTS periodo_fin date; ALTER TABLE materias_inscritas ADD COLUMN IF NOT EXISTS crn text; ALTER TABLE materias_inscritas ADD COLUMN IF NOT EXISTS periodos jsonb default '[]'::jsonb; Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat: PDF horario upload — real Tec21 calendar from MiTec
…#20) * fix: dashboard always shows current week + surface Google Calendar errors Two bugs reported on demo: 1. Dashboard header showed stale week (e.g. "27 de abril al 3 de mayo" while today is May 9). Cause: dashboard anchored the week to insight.semana_iso, so a cached insight from a previous ISO week dragged the UI back. Fix: always anchor to today; if the cached insight is from a different ISO week, treat as no-insight and render EmptyInsightCard so the user regenerates. 2. /api/calendar/create returned a generic "No se pudo crear ningún evento" that hid the real Google API error. Cause: createEvents only logged errors to the server. Fix: return per-event errors with status + message in the response. Also adds timeZone: "America/Monterrey" to start/end (Google rejects ambiguous datetimes without offset). When the first error is 401/403 the response includes a "cierra sesión y vuelve a entrar" hint so the user can refresh the OAuth token if scope is the issue. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: better error messages when Google Calendar API is disabled - Bump error message truncation from 200 to 500 chars so the full Cloud Console URL Google returns isn't cut off mid-word. - New hint logic: if the response mentions "has not been used" or "disabled" we tell the user to enable the API instead of pointing them to re-login. The previous re-login hint only made sense for actual auth failures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(dashboard): auto-sync Google Calendar + Canvas iCal on every load The dashboard reads `eventos` from the DB but nothing was populating that table on its own — the user had to manually POST to /api/calendar/sync or /api/canvas/sync to see anything. Now we sync both right before rendering so a fresh login or page reload shows real events without any extra step. - lib/google/calendar.ts: extract syncGoogleCalendarToDb(supabase, userId) reusable from server components, so the dashboard and the existing route share one implementation. - lib/ical/parser.ts: same — syncCanvasIcalToDb(supabase, userId, icalUrl) reads profile.canvas_ical_url and upserts entregas. - dashboard/page.tsx: autoSyncExternalCalendars() runs both syncs in parallel via Promise.allSettled before loadCurrentInsight + loadWeekEventos, swallowing per-source errors so a stale cache is preferred over a broken dashboard. Skipped in demo mode (?demo=1). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(dashboard): auto-generate weekly insight on empty state When the dashboard lands on EmptyInsightCard the user had to click "Generar mi semana" to get any blocks. Now the card auto-fires the generation on first mount (using useRef guard so React strict-mode double-render doesn't double-trigger). Loading title + spinner reflect the in-flight call. If generation errors, surface the server's error message inline and switch the button to "Reintentar" without auto-retrying. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification