Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(web): move asFilePageTab off the client boundary (#1936)

Raghav Chamadiyac6b0104289db
diff --git a/packages/ui/src/files/file-page-tabs.ts b/packages/ui/src/files/file-page-tabs.ts
index 5593d6ff8..15c57e154 100644
--- a/packages/ui/src/files/file-page-tabs.ts
+++ b/packages/ui/src/files/file-page-tabs.ts
@@ -102,6 +102,18 @@ export function fileTabsFor(data: FileDetailResponse): FileTabDef[] {
});
}
+/** Narrow a `?tab=` string to a tab this page actually renders.
+ *
+ * Lives here rather than beside `FilePage`: that module is `"use client"`, so
+ * every export of it is a client reference, and a server component that
+ * imported this one got "it's not possible to invoke a client function from
+ * the server" instead of a tab id. */
+export function asFilePageTab(value: string | undefined): FilePageTab | undefined {
+ return value && (FILE_PAGE_TABS as readonly string[]).includes(value)
+ ? (value as FilePageTab)
+ : undefined;
+}
+
/** The tab a `?tab=` value resolves to, given what this file actually has.
* A deep link to Decisions on an ungoverned file lands on Overview rather
* than on a tab that is not in the row. */
diff --git a/packages/ui/src/files/file-page.tsx b/packages/ui/src/files/file-page.tsx
index 430d0dc74..a49aa3ec8 100644
--- a/packages/ui/src/files/file-page.tsx
+++ b/packages/ui/src/files/file-page.tsx
@@ -2,7 +2,7 @@
import { useState, type ReactNode } from "react";
import { ViewTabs } from "../shared/view-tabs";
-import { FILE_PAGE_TABS, type FilePageTab, type FileTabDef } from "./file-page-tabs";
+import type { FilePageTab, FileTabDef } from "./file-page-tabs";
export interface FilePageProps {
/**
@@ -71,11 +71,3 @@ export function FilePage({ header, tabs, panels, initialTab, onTabChange }: File
</div>
);
}
-
-/** Narrow a `?tab=` string to a tab this page actually renders. Exported for
- * server components that need it before the shell mounts. */
-export function asFilePageTab(value: string | undefined): FilePageTab | undefined {
- return value && (FILE_PAGE_TABS as readonly string[]).includes(value)
- ? (value as FilePageTab)
- : undefined;
-}