🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(ui): add settings deep links to cmd+k (#5680)
Marc Klingen738df01ab77b
diff --git a/web/src/features/command-k-menu/CommandMenu.tsx b/web/src/features/command-k-menu/CommandMenu.tsxindex 3d7d579cfa..d7d5ac743d 100644--- a/web/src/features/command-k-menu/CommandMenu.tsx+++ b/web/src/features/command-k-menu/CommandMenu.tsx@@ -15,6 +15,9 @@ import { env } from "@/src/env.mjs";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useDebounce } from "@/src/hooks/useDebounce";import { useCommandMenu } from "@/src/features/command-k-menu/CommandMenuProvider";+import { useProjectSettingsPages } from "@/src/pages/project/[projectId]/settings";+import { useOrganizationSettingsPages } from "@/src/pages/organization/[organizationId]/settings";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";export function CommandMenu({mainNavigation,@@ -24,6 +27,26 @@ export function CommandMenu({const { open, setOpen } = useCommandMenu();const router = useRouter();const { allProjectItems } = useNavigationItems();+ const settingsPages = useProjectSettingsPages();+ const orgSettingsPages = useOrganizationSettingsPages();+ const { organization, project } = useQueryProjectOrOrganization();++ const projectSettingsItems = settingsPages+ .filter((page) => page.show !== false && !("href" in page))+ .map((page) => ({+ title: `Project Settings > ${page.title}`,+ url: `/project/${project?.id}/settings${page.slug === "index" ? "" : `/${page.slug}`}`,+ keywords: page.cmdKKeywords || [],+ }));++ const orgSettingsItems = orgSettingsPages+ .filter((page) => page.show !== false && !("href" in page))+ .map((page) => ({+ title: `Organization Settings > ${page.title}`,+ url: `/organization/${organization?.id}/settings${page.slug === "index" ? "" : `/${page.slug}`}`,+ keywords: page.cmdKKeywords || [],+ }));+const capture = usePostHogClientCapture();const debouncedSearchChange = useDebounce(@@ -80,8 +103,12 @@ export function CommandMenu({onOpenChange={setOpen}filter={(value, search, keywords) => {const extendValue = value + " " + keywords?.join(" ");- if (extendValue.toLowerCase().includes(search.toLowerCase())) return 1;- return 0;+ const searchTerms = search.toLowerCase().split(" ");+ return searchTerms.every((term) =>+ extendValue.toLowerCase().includes(term),+ )+ ? 1+ : 0;}}><CommandInput@@ -137,6 +164,56 @@ export function CommandMenu({</CommandGroup></>)}+ {projectSettingsItems.length > 0 && (+ <>+ <CommandSeparator />+ <CommandGroup heading="Project Settings">+ {projectSettingsItems.map((item) => (+ <CommandItem+ key={item.url}+ value={item.title}+ keywords={item.keywords}+ onSelect={() => {+ router.push(item.url);+ capture("cmd_k_menu:navigated", {+ type: "project_settings",+ title: item.title,+ url: item.url,+ });+ setOpen(false);+ }}+ >+ {item.title}+ </CommandItem>+ ))}+ </CommandGroup>+ </>+ )}+ {orgSettingsItems.length > 0 && (+ <>+ <CommandSeparator />+ <CommandGroup heading="Organization Settings">+ {orgSettingsItems.map((item) => (+ <CommandItem+ key={item.url}+ value={item.title}+ keywords={item.keywords}+ onSelect={() => {+ router.push(item.url);+ capture("cmd_k_menu:navigated", {+ type: "organization_settings",+ title: item.title,+ url: item.url,+ });+ setOpen(false);+ }}+ >+ {item.title}+ </CommandItem>+ ))}+ </CommandGroup>+ </>+ )}</CommandList></CommandDialog>);diff --git a/web/src/pages/organization/[organizationId]/settings/index.tsx b/web/src/pages/organization/[organizationId]/settings/index.tsxindex d32bb4fd7d..e59cfc2b29 100644--- a/web/src/pages/organization/[organizationId]/settings/index.tsx+++ b/web/src/pages/organization/[organizationId]/settings/index.tsx@@ -11,12 +11,96 @@ import { DeleteOrganizationButton } from "@/src/features/organizations/componentimport { BillingSettings } from "@/src/ee/features/billing/components/BillingSettings";import { useHasEntitlement } from "@/src/features/entitlements/hooks";import ContainerPage from "@/src/components/layouts/container-page";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";++type OrganizationSettingsPage = {+ title: string;+ slug: string;+ show?: boolean | (() => boolean);+ cmdKKeywords?: string[];+} & ({ content: React.ReactNode } | { href: string });++export function useOrganizationSettingsPages(): OrganizationSettingsPage[] {+ const { organization } = useQueryProjectOrOrganization();+ const showBillingSettings = useHasEntitlement("cloud-billing");++ if (!organization) return [];++ return getOrganizationSettingsPages({+ organization,+ showBillingSettings,+ });+}++export const getOrganizationSettingsPages = ({+ organization,+ showBillingSettings,+}: {+ organization: { id: string; name: string };+ showBillingSettings: boolean;+}): OrganizationSettingsPage[] => [+ {+ title: "General",+ slug: "index",+ cmdKKeywords: ["name", "id", "delete"],+ content: (+ <div className="flex flex-col gap-6">+ <RenameOrganization />+ <div>+ <Header title="Debug Information" />+ <JSONView+ title="Metadata"+ json={{ name: organization.name, id: organization.id }}+ />+ </div>+ <SettingsDangerZone+ items={[+ {+ title: "Delete this organization",+ description:+ "Once you delete an organization, there is no going back. Please be certain.",+ button: <DeleteOrganizationButton />,+ },+ ]}+ />+ </div>+ ),+ },+ {+ title: "Members",+ slug: "members",+ cmdKKeywords: ["invite", "user", "rbac"],+ content: (+ <div className="flex flex-col gap-6">+ <div>+ <Header title="Organization Members" />+ <MembersTable orgId={organization.id} />+ </div>+ <div>+ <MembershipInvitesPage orgId={organization.id} />+ </div>+ </div>+ ),+ },+ {+ title: "Billing",+ slug: "billing",+ cmdKKeywords: ["payment", "subscription", "plan", "invoice"],+ content: <BillingSettings />,+ show: showBillingSettings,+ },+ {+ title: "Projects",+ slug: "projects",+ href: `/organization/${organization.id}`,+ },+];const OrgSettingsPage = () => {const organization = useQueryOrganization();const router = useRouter();const { page } = router.query;- const showBillingSettings = useHasEntitlement("cloud-billing");+ const pages = useOrganizationSettingsPages();if (!organization) return null;@@ -28,60 +112,7 @@ const OrgSettingsPage = () => {><PagedSettingsContaineractiveSlug={page as string | undefined}- pages={[- {- title: "General",- slug: "index",- content: (- <div className="flex flex-col gap-6">- <RenameOrganization />- <div>- <Header title="Debug Information" />- <JSONView- title="Metadata"- json={{ name: organization.name, id: organization.id }}- />- </div>- <SettingsDangerZone- items={[- {- title: "Delete this organization",- description:- "Once you delete an organization, there is no going back. Please be certain.",- button: <DeleteOrganizationButton />,- },- ]}- />- </div>- ),- },- {- title: "Members",- slug: "members",- content: (- <div className="flex flex-col gap-6">- <div>- <Header title="Organization Members" />- <MembersTable orgId={organization.id} />- </div>- <div>- <MembershipInvitesPage orgId={organization.id} />- </div>- </div>- ),- },- {- title: "Billing",- slug: "billing",- content: <BillingSettings />,- show: showBillingSettings,- },- {- title: "Projects",- slug: "projects",- href: `/organization/${organization.id}`,- },- ]}+ pages={pages}/></ContainerPage>);diff --git a/web/src/pages/project/[projectId]/settings/index.tsx b/web/src/pages/project/[projectId]/settings/index.tsxindex ce86d4b994..4df6920566 100644--- a/web/src/pages/project/[projectId]/settings/index.tsx+++ b/web/src/pages/project/[projectId]/settings/index.tsx@@ -26,12 +26,163 @@ import { ModelsSettings } from "@/src/features/models/components/ModelSettings";import ConfigureRetention from "@/src/features/projects/components/ConfigureRetention";import ContainerPage from "@/src/components/layouts/container-page";-export default function SettingsPage() {- const { project, organization } = useQueryProject();+type ProjectSettingsPage = {+ title: string;+ slug: string;+ show?: boolean | (() => boolean);+ cmdKKeywords?: string[];+} & ({ content: React.ReactNode } | { href: string });++export function useProjectSettingsPages(): ProjectSettingsPage[] {const router = useRouter();+ const { project, organization } = useQueryProject();const showBillingSettings = useHasEntitlement("cloud-billing");const showRetentionSettings = useHasEntitlement("data-retention");++ if (!project || !organization || !router.query.projectId) {+ return [];+ }++ return getProjectSettingsPages({+ project,+ organization,+ showBillingSettings,+ showRetentionSettings,+ });+}++export const getProjectSettingsPages = ({+ project,+ organization,+ showBillingSettings,+ showRetentionSettings,+}: {+ project: { id: string; name: string };+ organization: { id: string; name: string };+ showBillingSettings: boolean;+ showRetentionSettings: boolean;+}): ProjectSettingsPage[] => [+ {+ title: "General",+ slug: "index",+ cmdKKeywords: ["name", "id", "delete", "transfer", "ownership"],+ content: (+ <div className="flex flex-col gap-6">+ <HostNameProject />+ <RenameProject />+ {showRetentionSettings && <ConfigureRetention />}+ <div>+ <Header title="Debug Information" />+ <JSONView+ title="Metadata"+ json={{+ project: { name: project.name, id: project.id },+ org: { name: organization.name, id: organization.id },+ }}+ />+ </div>+ <SettingsDangerZone+ items={[+ {+ title: "Transfer ownership",+ description:+ "Transfer this project to another organization where you have the ability to create projects.",+ button: <TransferProjectButton />,+ },+ {+ title: "Delete this project",+ description:+ "Once you delete a project, there is no going back. Please be certain.",+ button: <DeleteProjectButton />,+ },+ ]}+ />+ </div>+ ),+ },+ {+ title: "API Keys",+ slug: "api-keys",+ cmdKKeywords: ["auth"],+ content: (+ <div className="flex flex-col gap-6">+ <ApiKeyList projectId={project.id} />+ <LlmApiKeyList projectId={project.id} />+ </div>+ ),+ },+ {+ title: "Models",+ slug: "models",+ cmdKKeywords: ["cost", "token"],+ content: <ModelsSettings projectId={project.id} />,+ },+ {+ title: "Scores / Evaluation",+ slug: "scores",+ cmdKKeywords: ["config"],+ content: <ScoreConfigSettings projectId={project.id} />,+ },+ {+ title: "Members",+ slug: "members",+ cmdKKeywords: ["invite", "user"],+ content: (+ <div>+ <Header title="Project Members" />+ <div>+ <MembersTable+ orgId={organization.id}+ project={{ id: project.id, name: project.name }}+ />+ </div>+ <div>+ <MembershipInvitesPage+ orgId={organization.id}+ projectId={project.id}+ />+ </div>+ </div>+ ),+ },+ {+ title: "Integrations",+ slug: "integrations",+ cmdKKeywords: ["posthog"],+ content: <Integrations projectId={project.id} />,+ },+ {+ title: "Exports",+ slug: "exports",+ cmdKKeywords: ["csv", "download", "json", "batch"],+ content: <BatchExportsSettingsPage projectId={project.id} />,+ },+ {+ title: "Audit Logs",+ slug: "audit-logs",+ cmdKKeywords: ["trail"],+ content: <AuditLogsSettingsPage projectId={project.id} />,+ },+ {+ title: "Billing",+ slug: "billing",+ href: `/organization/${organization.id}/settings/billing`,+ show: showBillingSettings,+ },+ {+ title: "Organization Settings",+ slug: "organization",+ href: `/organization/${organization.id}/settings`,+ },+];++export default function SettingsPage() {+ const { project, organization } = useQueryProject();+ const router = useRouter();+ const pages = useProjectSettingsPages();+if (!project || !organization) return null;+return (<ContainerPageheaderProps={{@@ -40,112 +191,7 @@ export default function SettingsPage() {><PagedSettingsContaineractiveSlug={router.query.page as string | undefined}- pages={[- {- title: "General",- slug: "index",- content: (- <div className="flex flex-col gap-6">- <HostNameProject />- <RenameProject />- {showRetentionSettings && <ConfigureRetention />}- <div>- <Header title="Debug Information" />- <JSONView- title="Metadata"- json={{- project: { name: project.name, id: project.id },- org: { name: organization.name, id: organization.id },- }}- />- </div>- <SettingsDangerZone- items={[- {- title: "Transfer ownership",- description:- "Transfer this project to another organization where you have the ability to create projects.",- button: <TransferProjectButton />,- },- {- title: "Delete this project",- description:- "Once you delete a project, there is no going back. Please be certain.",- button: <DeleteProjectButton />,- },- ]}- />- </div>- ),- },- {- title: "API Keys",- slug: "api-keys",- content: (- <div className="flex flex-col gap-6">- <ApiKeyList projectId={project.id} />- <LlmApiKeyList projectId={project.id} />- </div>- ),- },- {- title: "Models",- slug: "models",- content: <ModelsSettings projectId={project.id} />,- },- {- title: "Scores / Evaluation",- slug: "scores",- content: <ScoreConfigSettings projectId={project.id} />,- },- {- title: "Members",- slug: "members",- content: (- <div>- <Header title="Project Members" />- <div>- <MembersTable- orgId={organization.id}- project={{ id: project.id, name: project.name }}- />- </div>- <div>- <MembershipInvitesPage- orgId={organization.id}- projectId={project.id}- />- </div>- </div>- ),- },- {- title: "Integrations",- slug: "integrations",- content: <Integrations projectId={project.id} />,- },- {- title: "Exports",- slug: "exports",- content: <BatchExportsSettingsPage projectId={project.id} />,- },- {- title: "Audit Logs",- slug: "audit-logs",- content: <AuditLogsSettingsPage projectId={project.id} />,- },- {- title: "Billing",- slug: "billing",- href: `/organization/${organization.id}/settings/billing`,- show: showBillingSettings,- },- {- title: "Organization Settings",- slug: "organization",- href: `/organization/${organization.id}/settings`,- },- ]}+ pages={pages}/></ContainerPage>);