unsloth/studio/frontend
Daniel Han 43beeae39d
studio/frontend: friendlier 404 fallback for unknown routes (#5664)
* studio/frontend: friendlier 404 fallback for unknown routes

TanStack Router defaults to a bare "Not Found" string when no
route matches. With Studio's root layout that string sits alone
in the main content area while the sidebar still renders, which
looks broken when the user hits a typo'd path, a stale share
link, or a chat URL with an extra path segment.

Provide a small DefaultNotFound component to createRouter:
sloth mascot, "Page not found" heading, the offending pathname,
and a Back to chat button. Studio chrome continues to render
around it, so the user gets the same sidebar nav for free.

Resolves #5663.

* studio/frontend: 404 fallback uses useRouterState + URL-encoded sloth path

Address review feedback on #5664:
- Read pathname via useRouterState({ select: s => s.location.pathname })
  instead of window.location.pathname. Matches the pattern already used
  in __root.tsx, drops the window-typeof guard, and stays consistent with
  the router store on subsequent client navigations.
- URL-encode the sloth mascot src so the space-containing path resolves
  cleanly without relying on the browser to encode it.
- Add break-all on the pathname paragraph so long offending URLs wrap
  instead of pushing the card wider than the viewport.

---------

Co-authored-by: danielhanchen <michaelhan2050@gmail.com>
2026-05-22 04:30:32 -07:00
..
public Polish/cloud to providers (#5450) 2026-05-15 19:29:21 +04:00
src studio/frontend: friendlier 404 fallback for unknown routes (#5664) 2026-05-22 04:30:32 -07:00
.gitignore perf(studio): upgrade to Vite 8 + auto-install bun for faster frontend builds (#4522) 2026-03-25 04:27:41 -07:00
.gitkeep add studio root folder 2026-02-02 09:14:35 +00:00
.npmrc security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
biome.json feat: add seed dataset support with configuration, preview, and builder utilities 2026-02-14 18:44:38 +01:00
components.json add studio root folder 2026-02-02 09:14:35 +00:00
data-designer.openapi (1).yaml save and import, and fixes 2026-02-04 14:32:49 +01:00
eslint.config.js Final cleanup 2026-03-12 18:28:04 +00:00
index.html Final cleanup 2026-03-12 18:28:04 +00:00
package-lock.json Add OpenDocument chat attachments (#5510) 2026-05-18 03:41:24 -07:00
package.json Add OpenDocument chat attachments (#5510) 2026-05-18 03:41:24 -07:00
tsconfig.app.json Relax frontend unused local check (#4388) 2026-03-17 16:04:11 -07:00
tsconfig.json cleanup 2026-02-04 13:28:39 +01:00
tsconfig.node.json cleanup 2026-02-04 13:28:39 +01:00
vite.config.ts Fix Install commands for Windows + 1 line installs (#4447) 2026-03-19 02:09:09 -07:00