Skip to content

Routing guards & shared landing layout#174

Open
medazizktata25 wants to merge 5 commits intoGuepard-Corp:mainfrom
medazizktata25:feat/org-project-routing-guards
Open

Routing guards & shared landing layout#174
medazizktata25 wants to merge 5 commits intoGuepard-Corp:mainfrom
medazizktata25:feat/org-project-routing-guards

Conversation

@medazizktata25
Copy link
Contributor

PR Title

✨ Routing guards & shared landing layout

What

  • Hard guard org/project/datasource/chat routes: no “soft not found” UIs; invalid or missing slugs now properly 404 via loaders / components.
  • Unify error/404 behavior: root ErrorBoundary renders inside the normal app shell (head, theme, providers) and shows the shared NotFoundPage or i18n generic error.
  • Smarter home redirect: / only auto-redirects to the last project when it was used within the last hour, otherwise shows the landing.
  • Modular landing/welcome UI: factor out shared hero + typing animation + section dividers + feature cards used by root landing and project welcome.
  • Cleanups / correctness: notebook unsaved-state effect deps, agent UI props vs QweryPromptInputProps, import + lint fixes.

How

Commits on this branch:

  1. 0ee206fb – Implement error handling and loading states across various routes; introduce ProjectGuard for project context validation

    • Routing / guards

      • Add ProjectGuard in project-context:
        • Uses useProject(); while loading shows a minimal loading UI.
        • If project/org is missing, throws new Response('Not Found', { status: 404 }).
        • When storing last project slug, also stores qwery:last-project-used-at for “recentness” logic.
      • Wrap project layouts:
        • Both SidebarLayout and SimpleModeSidebarLayout wrap content in <ProjectProvider><ProjectGuard>…</ProjectGuard></ProjectProvider>.
      • Loaders now hard-404:
        • organization/index.tsx, project/index.tsx, datasource/{tables,table,schema}.tsx:
          • Validate slugs.
          • Catch DomainException from services and rethrow 404.
        • project/conversation/conversation.tsx:
          • 404s if slug is missing or the loaded conversation is missing.
        • Organization/datasource UIs throw 404 instead of rendering inline “not found” states.
    • Error shell

      • Root ErrorBoundary in apps/web/app/root.tsx:
        • Uses the same layout shell as <App /> (meta, links, providers, theme, language, csrf).
        • 404s render the shared NotFoundPage.
        • Non-404s render i18n’d common:errorPageHeading + common:genericErrorSubHeading.
  2. a119dcf2 – Refactor landing page components and introduce new feature cards for enhanced user experience; implement brand typing animation and section dividers for better visual structure (shared between root route content and dashboard page inside project)

    • Shared landing components (new)

      • apps/web/components/landing/:
        • use-brand-typing-animation.ts: encapsulates the “Query → Qwery” typing + delete + retype cycle, exposes brandText and showCursor.
        • landing-hero.tsx: logo + brand typing + title + subtitle.
        • landing-section-divider.tsx: reusable labeled divider row.
        • landing-feature-card.tsx: standard feature card UI.
        • index.ts: barrel export.
    • Root landing (apps/web/app/routes/index.tsx)

      • Remove ad-hoc hero/typing effect and section dividers.
      • Use:
        • <LandingHero title={...} subtitle={...} /> with greeting vs generic title.
        • <LandingSectionDivider label="What you can do" /> and "Get started now".
        • <LandingFeatureCard> for the feature grid.
      • Keep “last project used within 1h” redirect logic:
        • Reads qwery:last-project-slug and qwery:last-project-used-at from localStorage.
        • Redirects to /prj/:slug only if timestamp is recent.
      • Lint-safe JSX: escape "Let’s go" as Let&apos;s go.
    • Project welcome (apps/web/app/routes/project/_components/welcome.tsx)

      • Remove local brand typing useEffect + brandText / showCursor state.
      • Use shared components:
        • <LandingHero title={t('heroTitle')} subtitle={t('heroSubtitle')} />.
        • <LandingSectionDivider label={t('quickActions')} /> and label for sample data.
      • Keep the rest as-is: main PromptInput, suggestion buttons, quick actions, playground section.
  3. ffe87626 – Fix: clean up imports in organization route and project layout; add translation function to notebook effect dependencies for improved functionality (checks fix)

    • Lint / typecheck fixes
      • organization/index.tsx: remove unused Trans import.
      • project/layout.tsx: stop importing unused AgentTabs (keep AgentStatusProvider).
      • project/notebook.tsx:
        • Add t to handleDeleteNotebook useCallback deps to satisfy react-hooks/exhaustive-deps.
      • index.tsx:
        • Escape "Let's" properly; keep Tailwind arbitrary class warnings as-is (non-fatal suggestions).

Review Guide

  1. Routing / guards / 404 behavior

    • apps/web/lib/context/project-context.tsxProjectGuard, localStorage timestamp.
    • apps/web/app/routes/organization/index.tsx, project/index.tsx, datasource/{tables,table,schema}.tsx, project/conversation/conversation.tsx – loader and component 404 paths.
  2. Error shell and root

    • apps/web/app/root.tsxErrorBoundary and use of app shell + i18n messages.
  3. Landing & welcome modularization

    • apps/web/components/landing/* – new shared components and hook.
    • apps/web/app/routes/index.tsx – landing refactor + recent-project redirect.
    • apps/web/app/routes/project/_components/welcome.tsx – refactored to use shared landing modules.
  4. Misc correctness / typecheck

    • apps/web/app/routes/project/notebook.tsxuseCallback deps and unsaved state registration.
    • packages/ui/src/qwery/agent-ui.tsx – prop alignment with QweryPromptInputProps.

Testing

  • Manual
    • Navigate to / with and without qwery:last-project-* in localStorage, and with timestamps older/newer than 1h.
    • Hit org/project/datasource/chat routes with valid, missing, and invalid slugs; confirm:
      • Valid → renders as before.
      • Invalid/missing → shared 404 page, not inline “not found” fragments.
    • Trigger runtime errors to see generic error page wrapped in full app shell.
    • Verify project welcome page and root landing share the same hero / divider look and feel.
  • Automated
    • pnpm lint for apps/web and packages/ui (fixed previous errors).
    • pnpm typecheck now passes for @qwery/ui and apps/web (no QweryPromptInputProps mismatch).

Documentation / User Impact

  • User impact

    • More predictable navigation:
      • You never land on a “dashboard”/project page if the org/project doesn’t exist; you get a consistent 404.
      • Root / behavior is sane: only “sticky” redirect if you actually used that project recently.
    • Better UX:
      • Consistent landing/welcome visuals, shared hero and sections.
      • Error & 404 pages are styled and localized like the rest of the app.
    • No known breaking API changes; routing behavior around invalid slugs is now strictly 404 instead of ad-hoc UI.
  • Docs

    • No formal docs updated; behavior is aligned with existing error-handling conventions. If you want, I can add a short note under routing/error-handling to call out ProjectGuard + loader-based 404s.

…troduce ProjectGuard for project context validation
…enhanced user experience; implement brand typing animation and section dividers for better visual structure (shared between root route content and dashboard page inside project)
…ranslation function to notebook effect dependencies for improved functionality (checks fix)
…n, and project loaders; implement conversation page slug validation
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