Skip to content

The open-source app everyone uses to manage agents at work

fix(ui): restore prefix-aware company export/import links (#6648)

Jakub Mikiciukf44a002b8d3e
diff --git a/ui/src/lib/company-routes.test.ts b/ui/src/lib/company-routes.test.ts
index 0c0b1be277..cce73805ea 100644
--- a/ui/src/lib/company-routes.test.ts
+++ b/ui/src/lib/company-routes.test.ts
@@ -36,6 +36,25 @@ describe("company routes", () => {
expect(toCompanyRelativePath("/PAP/search?q=foo")).toBe("/search?q=foo");
});
+ it("rewrites company package paths with the active prefix", () => {
+ expect(applyCompanyPrefix("/company/export", "NEU")).toBe("/NEU/company/export");
+ expect(applyCompanyPrefix("/company/import", "NEU")).toBe("/NEU/company/import");
+ expect(applyCompanyPrefix("/company/settings/cloud-upstream", "NEU")).toBe(
+ "/NEU/company/settings/cloud-upstream",
+ );
+ expect(applyCompanyPrefix("/org", "NEU")).toBe("/NEU/org");
+ });
+
+ it("does not double-apply the company prefix", () => {
+ expect(applyCompanyPrefix("/NEU/company/export", "NEU")).toBe("/NEU/company/export");
+ });
+
+ it("normalizes prefixed company export file URLs for parsing", () => {
+ expect(toCompanyRelativePath("/NEU/company/export/files/agents/ceo/AGENTS.md")).toBe(
+ "/company/export/files/agents/ceo/AGENTS.md",
+ );
+ });
+
// Regression for PAP-10257: Team Catalog navigation (auto-select + row/file
// clicks) produces company-relative `/teams-catalog/<key>` paths. Without
// `teams-catalog` in the board-route allowlist, `extractCompanyPrefixFromPath`
diff --git a/ui/src/pages/CompanyExport.tsx b/ui/src/pages/CompanyExport.tsx
index 7bca198761..bad6bc3dce 100644
--- a/ui/src/pages/CompanyExport.tsx
+++ b/ui/src/pages/CompanyExport.tsx
@@ -20,6 +20,7 @@ import { Button } from "@/components/ui/button";
import { EmptyState } from "../components/EmptyState";
import { PageSkeleton } from "../components/PageSkeleton";
import { MarkdownBody } from "../components/MarkdownBody";
+import { toCompanyRelativePath } from "@/lib/company-routes";
import { cn } from "../lib/utils";
import { queryKeys } from "../lib/queryKeys";
import { createZipArchive } from "../lib/zip";
@@ -559,9 +560,10 @@ function ExportPreviewPane({
/** Extract the file path from the current URL pathname (after /company/export/files/) */
function filePathFromLocation(pathname: string): string | null {
const marker = "/company/export/files/";
- const idx = pathname.indexOf(marker);
+ const relativePathname = toCompanyRelativePath(pathname);
+ const idx = relativePathname.indexOf(marker);
if (idx === -1) return null;
- const filePath = decodeURIComponent(pathname.slice(idx + marker.length));
+ const filePath = decodeURIComponent(relativePathname.slice(idx + marker.length));
return filePath || null;
}
diff --git a/ui/src/pages/CompanySettings.tsx b/ui/src/pages/CompanySettings.tsx
index a174b63366..25862d5e8d 100644
--- a/ui/src/pages/CompanySettings.tsx
+++ b/ui/src/pages/CompanySettings.tsx
@@ -10,6 +10,7 @@ import { companiesApi } from "../api/companies";
import { assetsApi } from "../api/assets";
import { instanceSettingsApi } from "../api/instanceSettings";
import { queryKeys } from "../lib/queryKeys";
+import { Link } from "@/lib/router";
import { Button } from "@/components/ui/button";
import { Settings, CloudUpload, Download, Upload } from "lucide-react";
import { CompanyPatternIcon } from "../components/CompanyPatternIcon";
@@ -374,28 +375,28 @@ export function CompanySettings() {
<div className="rounded-md border border-border px-4 py-4">
<p className="text-sm text-muted-foreground">
Import and export have moved to dedicated pages accessible from the{" "}
- <a href="/org" className="underline hover:text-foreground">Org Chart</a> header.
+ <Link to="/org" className="underline hover:text-foreground">Org Chart</Link> header.
</p>
<div className="mt-3 flex flex-wrap items-center gap-2">
{cloudSyncEnabled ? (
<Button size="sm" asChild>
- <a href="/company/settings/cloud-upstream">
+ <Link to="/company/settings/cloud-upstream">
<CloudUpload className="mr-1.5 h-3.5 w-3.5" />
Send to Paperclip Cloud
- </a>
+ </Link>
</Button>
) : null}
<Button size="sm" variant="outline" asChild>
- <a href="/company/export">
+ <Link to="/company/export">
<Download className="mr-1.5 h-3.5 w-3.5" />
Export
- </a>
+ </Link>
</Button>
<Button size="sm" variant="outline" asChild>
- <a href="/company/import">
+ <Link to="/company/import">
<Upload className="mr-1.5 h-3.5 w-3.5" />
Import
- </a>
+ </Link>
</Button>
</div>
</div>