fix: hide telegram qr code when self-hosting with no redis (#2535) master
* fix: make Telegram QR code optional for self-hosted instances without Redis - Backend: Gracefully handle Redis unavailability in createTelegramToken - Frontend: Show only manual chat ID entry when Redis is not available - With Redis: Full QR code + manual tabs - Without Redis: Manual entry only (no QR tab) * fix: convert null token to undefined for TypeScript compatibility * fix: only show QR tab when Redis is explicitly available Changed default from '?? true' to '=== true' to be more conservative. Now hides QR tab in all cases except when Redis is confirmed available. * fix: prevent QR tab flash on self-hosted instances - Add NEXT_PUBLIC_SELF_HOSTED env var to .env.docker.example - Hide QR tab during loading when NEXT_PUBLIC_SELF_HOSTED=true - Prevents flash of QR tab before Redis connection check completes * fix: use existing SELF_HOST naming convention - Replace NEXT_PUBLIC_SELF_HOSTED with NEXT_PUBLIC_SELF_HOST - Align with existing SELF_HOST variable for consistency - Add NEXT_PUBLIC_SELF_HOST to make flag available to client-side code * fix: always hide QR tab during loading to prevent flash - Remove build-time env var dependency (NEXT_PUBLIC_SELF_HOST) - Always show manual input while loading Redis check - QR tab only appears after confirming Redis is available - Works without rebuild for Docker deployments * feat: add biased loading behavior for Telegram QR tab - Backend: Add isSelfHosted flag from SELF_HOST env var - Frontend: Hide QR during loading on self-hosted (conservative) - Frontend: Show QR during loading on cloud (optimistic) - Works at runtime without rebuild * fix: revert to conservative loading to prevent QR flash on self-hosted Issue: tokenData is undefined during loading, so isSelfHosted check fails Solution: Always hide QR during loading, show only after Redis confirmed * feat: implement proper biased loading for Telegram QR - Add getServerConfig endpoint to return deployment type - Frontend fetches server config early and passes to component - Cloud: Shows QR during loading (optimistic) - Self-hosted: Hides QR during loading (conservative) - No more flash on self-hosted instances * fix: use correct trpc import pattern in form-telegram - Change from 'import { trpc }' to 'import { useTRPC }' - Use useTRPC() hook pattern matching other dashboard components - Fixes build error: Module not found '@/lib/trpc' * fix: use React Query pattern with queryOptions - Add useQuery import from @tanstack/react-query - Use queryOptions() instead of direct useQuery() call - Fixes TypeScript error: Property 'useQuery' does not exist * fix: use build-time NEXT_PUBLIC_SELF_HOST to eliminate flash - Replace async tRPC query with immediate process.env check - Add NEXT_PUBLIC_SELF_HOST to .env.docker.example - No loading delay means no flash on self-hosted instances * fix: add NEXT_PUBLIC_SELF_HOST to dashboard Dockerfile - Add to builder stage ENV so it's available during next build - Allows client-side code to immediately detect self-hosted environment * style: remove excessive empty lines in telegram-connection-flow * ci: apply automated fixes * fix: address dofigen and dead code violations 1. Add NEXT_PUBLIC_SELF_HOST to dofigen.yml source of truth - Ensures env var persists when Dockerfile is regenerated - Manually updated dofigen.lock (hash needs 'dofigen update' to regenerate) 2. Remove misleading NEXT_PUBLIC_SELF_HOST from .env.docker.example - NEXT_PUBLIC_* vars are baked at build time, not runtime - Added clarifying comment that it's fixed by Dockerfile 3. Remove unused API endpoints from notification.ts - Removed getServerConfig endpoint (never consumed by frontend) - Removed isSelfHosted field from createTelegramToken - Frontend uses NEXT_PUBLIC_SELF_HOST directly, no need for API call * style: remove extra blank line in .env.docker.example * refactor: use NEXT_PUBLIC_SELF_HOST directly in TelegramConnectionFlow - Remove isSelfHosted prop from FormTelegram component - Check NEXT_PUBLIC_SELF_HOST env var directly in TelegramConnectionFlow - Remove unnecessary prop passing between components - Enhance documentation for NEXT_PUBLIC_SELF_HOST in .env.docker.example * ci: apply automated fixes * fix: remove dead tokenData.isSelfHosted reference The createTelegramToken procedure no longer returns an isSelfHosted field (only token and redisAvailable), so the tokenData?.isSelfHosted check was dead code causing a TypeScript error. Simplified to rely solely on the build-time NEXT_PUBLIC_SELF_HOST env var. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>