fix(frontend): preserve the app root path in share links

EC
20d ago
+142-1

Problem

Share links omit the app root path when Chainlit is served under a subpath. For example, /chat deployments generate /share/<id> instead of /chat/share/<id>.

Fix

Reuse getRouterBasename() in ShareDialog and remove the trailing slash before building the URL.

Scope

Package: @chainlit/app.

  • frontend/src/components/share/ShareDialog.tsx
  • frontend/tests/ShareDialog.spec.tsx

Tests

Added 7 cases covering root and nested paths, trailing slashes, displayed links, and clipboard copies for new and existing shares.

pnpm test (55 passed), pnpm lint, pnpm format-check, and pnpm type-check passed. Browser E2E tests were not run.

Fixes #3072.


Summary by cubic

Fixes share links dropping the app root path when Chainlit runs under a subpath, so /chat deployments now produce /chat/share/<id> instead of /share/<id>.

Reuses getRouterBasename() in ShareDialog and strips the trailing slash before building the share URL. Adds 7 unit test cases covering root and nested paths, trailing slashes, and clipboard copies for new and existing shares.