Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Use Helmet for Cyclops page titles (#7176)

r33drichards7322615bd39e
diff --git a/libs/fleet/e2e/feature-flags.spec.ts b/libs/fleet/e2e/feature-flags.spec.ts
index 2ab18c0832..d54bbaed28 100644
--- a/libs/fleet/e2e/feature-flags.spec.ts
+++ b/libs/fleet/e2e/feature-flags.spec.ts
@@ -50,6 +50,7 @@ test.describe("feature flag admin route", () => {
await expect(page).toHaveURL(/\/admin\/feature-flags$/)
await expect(page.getByRole("heading", { name: "Feature flags" })).toBeVisible()
await expect(page.getByText("Admin only · Feature flagged", { exact: true })).toBeVisible()
+ await expect(page).toHaveTitle("Feature flags · Cua")
})
test("redirects non-admin direct navigation without requesting admin flags", async ({
diff --git a/libs/fleet/e2e/pools.spec.ts b/libs/fleet/e2e/pools.spec.ts
index fce962e2b4..126c56b106 100644
--- a/libs/fleet/e2e/pools.spec.ts
+++ b/libs/fleet/e2e/pools.spec.ts
@@ -38,6 +38,7 @@ test.describe("Pools page header", () => {
const status = page.getByRole("columnheader", { name: "Status" })
await expect(mesh).toHaveCount(0)
+ await expect(page).toHaveTitle("Pools · Cua")
await expect(page.locator(".cua-pagehead canvas")).toHaveCount(0)
const [topNavigationBox, navigationBox, headerBox, tableBox] = await Promise.all([
topNavigation.boundingBox(),
diff --git a/libs/fleet/e2e/settings.spec.ts b/libs/fleet/e2e/settings.spec.ts
index 07d4f28462..2618593d5a 100644
--- a/libs/fleet/e2e/settings.spec.ts
+++ b/libs/fleet/e2e/settings.spec.ts
@@ -25,6 +25,7 @@ for (const viewport of [
await page.goto("/settings")
await expectSharedPageShell(page)
+ await expect(page).toHaveTitle("Settings · Cua")
await expect(page.getByLabel("Display name")).toBeHidden()
expect(
await page.locator("html").evaluate(
diff --git a/libs/fleet/index.html b/libs/fleet/index.html
index 5f5d351427..b5956a94f8 100644
--- a/libs/fleet/index.html
+++ b/libs/fleet/index.html
@@ -9,7 +9,7 @@
<link rel="icon" href="/favicon.ico" sizes="32x32" />
<link rel="icon" href="/favicon.png" type="image/png" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
- <title>Pools</title>
+ <title>Pools · Cua</title>
</head>
<body>
<!-- Runtime config injected by nginx envsubst (see nginx.conf
diff --git a/libs/fleet/package.json b/libs/fleet/package.json
index 7ca9e478ff..d0b4d54620 100644
--- a/libs/fleet/package.json
+++ b/libs/fleet/package.json
@@ -31,6 +31,7 @@
"keycloak-js": "^25.0.6",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+ "react-helmet-async": "^3.0.0",
"react-router-dom": "^6.28.0",
"@cloudscape-design/chat-components": "^1.0.157",
"just-bash": "^3.2.0",
diff --git a/libs/fleet/pnpm-lock.yaml b/libs/fleet/pnpm-lock.yaml
index 59b2308d76..4475bfe560 100644
--- a/libs/fleet/pnpm-lock.yaml
+++ b/libs/fleet/pnpm-lock.yaml
@@ -58,6 +58,9 @@ importers:
react-dom:
specifier: ^18.3.1
version: 18.3.1([email protected])
+ react-helmet-async:
+ specifier: ^3.0.0
+ version: 3.0.0([email protected])
react-router-dom:
specifier: ^6.28.0
@@ -1218,6 +1221,9 @@ packages:
resolution: {integrity: sha512-m3Ofv/X/tV8Y3tHXLohcuVuhWKo7BBq62cqY15etqmLxg2DZ34AGGgQDeR+SCta2+zICb1NX83af0GJmbQ1++g==}
+ resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==}
+
resolution: {integrity: sha512-R5SnVLJmgYYvf2F2ZgwSBnelz5G4q5AxIC277GDfUaNbrZKNANcBC7RHqYYePlszf4kBolVkJauG0ZjHHFh55g==}
engines: {node: '>= 12'}
@@ -1462,6 +1468,14 @@ packages:
peerDependencies:
react: ^18.3.1
+ resolution: {integrity: sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==}
+
+ resolution: {integrity: sha512-nA3IEZfXiclgrz4KLxAhqJqIfFDuvzQwlKwpdmzZIuC1KNSghDEIXmyU0TKtbM+NafnkICcwx8CECFrZ/sL/1w==}
+ peerDependencies:
+ react: ^16.6.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
@@ -1545,6 +1559,9 @@ packages:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
+ resolution: {integrity: sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==}
+
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
engines: {node: '>=8'}
@@ -2789,6 +2806,10 @@ snapshots:
'@formatjs/icu-messageformat-parser': 2.11.4
tslib: 2.8.1
+ dependencies:
+ loose-envify: 1.4.0
+
@@ -3028,6 +3049,15 @@ snapshots:
react: 18.3.1
scheduler: 0.23.2
+
+ dependencies:
+ invariant: 2.2.4
+ react: 18.3.1
+ react-fast-compare: 3.2.2
+ shallowequal: 1.1.0
+
@@ -3154,6 +3184,8 @@ snapshots:
+
dependencies:
shebang-regex: 3.0.0
diff --git a/libs/fleet/src/App.tsx b/libs/fleet/src/App.tsx
index 09ea04f246..78f4267928 100644
--- a/libs/fleet/src/App.tsx
+++ b/libs/fleet/src/App.tsx
@@ -15,7 +15,15 @@ import TopNavigation from "@cloudscape-design/components/top-navigation";
import Flashbar, {
type FlashbarProps,
} from "@cloudscape-design/components/flashbar";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import {
+ type ReactNode,
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
+import { Helmet } from "react-helmet-async";
import { PoolsList } from "./pages/PoolsList";
import { ClaimDetail } from "./pages/ClaimDetail";
import { PoolDetail } from "./pages/PoolDetail";
@@ -45,6 +53,17 @@ import {
const VERSION_CHECK_INTERVAL_MS = 60_000;
+function TitledPage({ title, children }: { title: string; children: ReactNode }) {
+ return (
+ <>
+ <Helmet>
+ <title>{title} · Cua</title>
+ </Helmet>
+ {children}
+ </>
+ );
+}
+
function useMediaQuery(query: string): boolean {
const [matches, setMatches] = useState(
() => window.matchMedia(query).matches,
@@ -181,27 +200,6 @@ function ShellLayout({
previousPath.current = location.pathname;
}, [location.pathname, mobile]);
- useEffect(() => {
- const path = location.pathname;
- const pageTitle =
- path === "/usage"
- ? "Usage"
- : path.startsWith("/agent")
- ? "Threads"
- : path === "/user-keys"
- ? "User API keys"
- : path === "/settings"
- ? "Settings"
- : path === "/pools/new"
- ? "New pool"
- : path.includes("/claims/")
- ? "Claim details"
- : path.startsWith("/pools/")
- ? "Pool details"
- : "Pools";
- document.title = `${pageTitle} · Cua`;
- }, [location.pathname]);
-
return (
<div className="cua-dashboard-theme cua-shell">
<div id="cua-shell-topnav" className="cua-shell__topnav">
@@ -317,29 +315,103 @@ export function App() {
<Routes>
<Route element={<Shell />}>
<Route index element={<Navigate to="/pools" replace />} />
- <Route path="/pools" element={<PoolsList />} />
- <Route path="/pools/new" element={<PoolNew />} />
+ <Route
+ path="/pools"
+ element={
+ <TitledPage title="Pools">
+ <PoolsList />
+ </TitledPage>
+ }
+ />
+ <Route
+ path="/pools/new"
+ element={
+ <TitledPage title="New pool">
+ <PoolNew />
+ </TitledPage>
+ }
+ />
<Route
path="/pools/templates"
element={<Navigate to="/pools" replace />}
/>
- <Route path="/pools/:namespace/:name" element={<PoolDetail />} />
- <Route path="/user-keys" element={<UserApiKeys />} />
- <Route path="/settings" element={<Settings />} />
- <Route path="/usage" element={<BillingUsagePage />} />
- <Route path="/agent" element={<ChatRoute />} />
- <Route path="/agent/archived" element={<ArchivedThreadsRoute />} />
- <Route path="/agent/:threadId" element={<ChatRoute />} />
+ <Route
+ path="/pools/:namespace/:name"
+ element={
+ <TitledPage title="Pool details">
+ <PoolDetail />
+ </TitledPage>
+ }
+ />
+ <Route
+ path="/user-keys"
+ element={
+ <TitledPage title="User API keys">
+ <UserApiKeys />
+ </TitledPage>
+ }
+ />
+ <Route
+ path="/settings"
+ element={
+ <TitledPage title="Settings">
+ <Settings />
+ </TitledPage>
+ }
+ />
+ <Route
+ path="/usage"
+ element={
+ <TitledPage title="Usage">
+ <BillingUsagePage />
+ </TitledPage>
+ }
+ />
+ <Route
+ path="/agent"
+ element={
+ <TitledPage title="Threads">
+ <ChatRoute />
+ </TitledPage>
+ }
+ />
+ <Route
+ path="/agent/archived"
+ element={
+ <TitledPage title="Threads">
+ <ArchivedThreadsRoute />
+ </TitledPage>
+ }
+ />
+ <Route
+ path="/agent/:threadId"
+ element={
+ <TitledPage title="Threads">
+ <ChatRoute />
+ </TitledPage>
+ }
+ />
<Route
path="/billing"
element={<Navigate to="/settings" replace />}
/>
<Route element={<AdminRoute />}>
- <Route path="/admin/feature-flags" element={<FeatureFlags />} />
+ <Route
+ path="/admin/feature-flags"
+ element={
+ <TitledPage title="Feature flags">
+ <FeatureFlags />
+ </TitledPage>
+ }
+ />
</Route>
<Route
path="/pools/:namespace/:poolName/claims/:claimName"
- element={<ClaimDetail />}
+ element={
+ <TitledPage title="Claim details">
+ <ClaimDetail />
+ </TitledPage>
+ }
/>
<Route path="/modules" element={<Navigate to="/pools" replace />} />
<Route
diff --git a/libs/fleet/src/main.tsx b/libs/fleet/src/main.tsx
index 8cbc1d8f4d..ea3569e423 100644
--- a/libs/fleet/src/main.tsx
+++ b/libs/fleet/src/main.tsx
@@ -7,6 +7,7 @@ import { applyTheme } from "@cloudscape-design/components/theming"
import urbanistFont from "@cua/design/assets/fonts/urbanist-normal-latin.woff2"
import monoFont from "@cua/design/assets/fonts/jetbrains-mono-normal-latin.woff2"
import displayFont from "@cua/design/assets/fonts/instrument-serif-normal-latin.woff2"
+import { HelmetProvider } from "react-helmet-async"
import { App } from "./App"
import { AuthProvider } from "./auth/AuthProvider"
import "./shell.css"
@@ -55,8 +56,10 @@ for (const href of [urbanistFont, monoFont, displayFont]) {
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
- <AuthProvider>
- <App />
- </AuthProvider>
+ <HelmetProvider>
+ <AuthProvider>
+ <App />
+ </AuthProvider>
+ </HelmetProvider>
</React.StrictMode>,
)