Skip to content

ui: navigate through typed routes, and let the dev proxy reach llama-server - #125

Draft
allozaur wants to merge 2 commits into
masterfrom
allozaur/refactor/ui-typed-routes-and-dev-proxy
Draft

allozaur wants to merge 2 commits into
masterfrom
allozaur/refactor/ui-typed-routes-and-dev-proxy

Conversation

@allozaur

Copy link
Copy Markdown
Owner

Overview

Llama Chat navigates through SvelteKit's typed routes, and its dev server reaches llama-server without a 403. Nothing changes for the user of a build; the URLs are the same #/… ones.

Additional information

The new bottom of the fork stack. These two commits sat at the bottom of the Llama Harness branch (#55) without being part of it, and every layer above builds on them. The harness itself is upstream now (ggml-org#32927), so #55 is closed and the two commits get a PR of their own.

What changed
  • Typed routes. ROUTES holds route ids, as page.route.id reports them, in place of hash strings and the separate *_ROUTE_ID constants. Every link and goto() goes through resolve() from $app/paths, which checks the route exists and returns its URL (#/models with the hash router). RouterService resolves the routes that take params. Checks for the current page compare page.route.id instead of the hash, and svelte/no-navigation-without-resolve is on again.
  • Dev proxy. llama-server refuses browser requests whose Origin is not its own host unless --cors-origins allows it, and the Vite proxy forwarded the page's origin, so loading a model, saving tools and /v1 calls failed with 403 under vite dev. The proxy now calls the server with its own Host and no Origin, WebSocket upgrades included. Sec-Fetch-Site still passes through, so requests from other sites stay refused.
Testing
  • ui/apps/chat: npm run check (0 errors), npm run lint and the unit tests pass on this branch, rebased onto master at 9578bd3.

Requirements

llama-server refuses browser requests whose Origin does not match its own
host unless --cors-origins allows it, and the Vite proxy forwarded the
page's Origin (localhost:5173, or a LAN or Tailscale address). Loading a
model, saving tools and /v1 calls failed with 403 under `vite dev`.

The proxy now calls the server with its own Host and no Origin, WebSocket
upgrades included. Sec-Fetch-Site still passes through, so requests from
other sites stay refused.

Assisted-by: Claude (Opus 5.5 Medium)
ROUTES holds the app's route ids, as page.route.id reports them, in
place of hash strings and the separate *_ROUTE_ID constants. Every link
and goto() goes through resolve() from $app/paths, which checks the
route exists and returns its URL (#/models with the hash router).
RouterService resolves the routes that take params: a chat, a project,
a project's chat or new chat, and an extension's page. Tab links,
sidebar items and extension navigation items carry the resolved URL's
type, and checks for the current page compare page.route.id instead of
the hash.

svelte/no-navigation-without-resolve is on again, with type information
for the app's modules so a URL typed as ResolvedPathname passes. Links
that leave the app say so with rel="external"; the deep-link cleanups,
which change the current page's own query, are marked as such.

Assisted-by: Claude (Opus 5.5 Medium)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant