From f3ad1fc301f5c897182b05cee66f7b8e439328b6 Mon Sep 17 00:00:00 2001 From: lempkey Date: Mon, 6 Apr 2026 16:19:41 +0100 Subject: [PATCH] fix: use prefix-aware Link for export/import on Company Settings page The Export and Import buttons in CompanySettings used plain anchors which bypass the router's company-prefix wrapper. The links resolved to /company/export and /company/import instead of /:prefix/company/export, showing a 'Company not found' error. Replace both elements with from @/lib/router, which calls applyCompanyPrefix under the hood and correctly resolves to /:prefix/company/{export,import} regardless of which company is active. Fixes: #2910 --- ui/src/lib/company-routes.test.ts | 25 +++++++++++++++++++++++++ ui/src/pages/CompanySettings.tsx | 9 +++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ui/src/lib/company-routes.test.ts b/ui/src/lib/company-routes.test.ts index d6dc2668..ced25744 100644 --- a/ui/src/lib/company-routes.test.ts +++ b/ui/src/lib/company-routes.test.ts @@ -20,4 +20,29 @@ describe("company routes", () => { "/execution-workspaces/workspace-123", ); }); + + /** + * Regression tests for https://github.com/paperclipai/paperclip/issues/2910 + * + * The Export and Import links on the Company Settings page used plain + * `` anchors which bypass the router's Link + * wrapper. Without the wrapper, the company prefix is never applied and + * the links resolve to `/company/export` instead of `/:prefix/company/export`, + * producing a "Company not found" error. + * + * The fix replaces the `` elements with the prefix-aware `` from + * `@/lib/router`. These tests assert that the underlying `applyCompanyPrefix` + * utility (used by that Link) correctly rewrites the export/import paths. + */ + it("applies company prefix to /company/export", () => { + expect(applyCompanyPrefix("/company/export", "PAP")).toBe("/PAP/company/export"); + }); + + it("applies company prefix to /company/import", () => { + expect(applyCompanyPrefix("/company/import", "PAP")).toBe("/PAP/company/import"); + }); + + it("does not double-apply the prefix if already present", () => { + expect(applyCompanyPrefix("/PAP/company/export", "PAP")).toBe("/PAP/company/export"); + }); }); diff --git a/ui/src/pages/CompanySettings.tsx b/ui/src/pages/CompanySettings.tsx index e0db3706..30b39627 100644 --- a/ui/src/pages/CompanySettings.tsx +++ b/ui/src/pages/CompanySettings.tsx @@ -1,4 +1,5 @@ import { ChangeEvent, useEffect, useState } from "react"; +import { Link } from "@/lib/router"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION } from "@paperclipai/shared"; import { useCompany } from "../context/CompanyContext"; @@ -548,16 +549,16 @@ export function CompanySettings() {