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.

feat(cyclops-cs): show pool states on usage page (#7185)

r33drichardsed8c360ae77a
diff --git a/libs/fleet/agent.test.ts b/libs/fleet/agent.test.ts
index 4ecd30dee6..8a88b5f490 100644
--- a/libs/fleet/agent.test.ts
+++ b/libs/fleet/agent.test.ts
@@ -115,7 +115,7 @@ test("listPools help defines the linked table presentation", async () => {
const result = await sdkShell().exec("listPools -h")
assert.equal(result.exitCode, 0)
- assert.match(result.stdout, /Pool \| Replicas \| Available \| Phase/)
+ assert.match(result.stdout, /Pool \| Replicas \| Available \| Status/)
assert.match(result.stdout, /Omit Namespace/)
assert.match(result.stdout, /Markdown link/)
assert.match(result.stdout, /\/pools\/<URL-encoded namespace>\/<URL-encoded pool name>/)
@@ -124,8 +124,8 @@ test("listPools help defines the linked table presentation", async () => {
test("exposes SDK methods as composable bash commands", async () => {
const shell = sdkShell({
listPools: async () => [
- { name: "beta", namespace: "team", phase: "Ready" },
- { name: "alpha", namespace: "team", phase: "Pending" },
+ { name: "beta", namespace: "team", status: { label: "Healthy" } },
+ { name: "alpha", namespace: "team", status: { label: "Unknown" } },
],
})
diff --git a/libs/fleet/e2e/agent-chat.spec.ts b/libs/fleet/e2e/agent-chat.spec.ts
index 183dbac090..c145d71d46 100644
--- a/libs/fleet/e2e/agent-chat.spec.ts
+++ b/libs/fleet/e2e/agent-chat.spec.ts
@@ -595,7 +595,7 @@ test("renders and sanitizes Markdown in user and assistant messages", async ({
id: "markdown-assistant",
role: "assistant",
content: [
- "| Pool | Replicas | Available | Phase |",
+ "| Pool | Replicas | Available | Status |",
"| --- | ---: | ---: | --- |",
"| [demo](/pools/team/demo) | 2 | 1 | Ready |",
"",
@@ -1371,7 +1371,7 @@ test("parses fragmented unterminated NDJSON and rejects malformed final events",
await page.goto("/pools");
const result = await page.evaluate(async () => {
- const api = await import("/src/sdk/chat.ts");
+ const api = await import("/src/api/chat.ts");
const originalFetch = window.fetch;
const encode = (value: string) => new TextEncoder().encode(value);
const stream = (chunks: string[]) =>
diff --git a/libs/fleet/e2e/fixtures/feature-flags-harness.tsx b/libs/fleet/e2e/fixtures/feature-flags-harness.tsx
index 3ee5891c50..7e1191d2b4 100644
--- a/libs/fleet/e2e/fixtures/feature-flags-harness.tsx
+++ b/libs/fleet/e2e/fixtures/feature-flags-harness.tsx
@@ -2,7 +2,7 @@ import { createRoot } from "react-dom/client"
import { BrowserRouter, Route, Routes } from "react-router-dom"
import { useState } from "react"
import { AdminRoute } from "../../src/components/AdminRoute"
-import { fetchFeatureFlags } from "../../src/sdk/featureFlags"
+import { fetchFeatureFlags } from "../../src/api/featureFlags"
import {
FeatureFlagProvider,
useFeatureFlags,
diff --git a/libs/fleet/e2e/sdk-builders.spec.ts b/libs/fleet/e2e/sdk-builders.spec.ts
index d78882b542..53e94d507e 100644
--- a/libs/fleet/e2e/sdk-builders.spec.ts
+++ b/libs/fleet/e2e/sdk-builders.spec.ts
@@ -18,10 +18,10 @@ test.describe("SDK builders", () => {
test("builds client, claim, and user-key records", async ({ page }) => {
const result = await page.evaluate(async () => {
const { buildClientConfiguration, ensureSdkInitialized } = await import(
- "/src/sdk/client.ts"
+ "/src/auth/cyclops-client.ts"
)
- const { buildClaimRequest } = await import("/src/sdk/claims.ts")
- const { buildUserApiKeyRequest } = await import("/src/sdk/userKeys.ts")
+ const { buildClaimRequest } = await import("/src/fleet/claims.ts")
+ const { buildUserApiKeyRequest } = await import("/src/fleet/userKeys.ts")
await ensureSdkInitialized()
const pool = {
apiVersion: "osgym.cua.ai/v1alpha1",
@@ -65,9 +65,9 @@ test.describe("SDK builders", () => {
test("builds nested pool and template requests", async ({ page }) => {
const result = await page.evaluate(async () => {
- const { ensureSdkInitialized } = await import("/src/sdk/client.ts")
- const { buildPoolRequest, buildTemplateRequest } = await import("/src/sdk/pools.ts")
- const { Firmware, ServiceProtocol } = await import("/src/sdk/generated.ts")
+ const { ensureSdkInitialized } = await import("/src/auth/cyclops-client.ts")
+ const { buildPoolRequest, buildTemplateRequest } = await import("/src/fleet/pools.ts")
+ const { Firmware, ServiceProtocol } = await import("/sdk-bindings/ts-uniffi-browser/ts/index.web.ts")
await ensureSdkInitialized()
const values = {
cpu: 4,
@@ -126,8 +126,8 @@ test.describe("SDK builders", () => {
test("rebuilds template services without mutation", async ({ page }) => {
const result = await page.evaluate(async () => {
- const { ensureSdkInitialized } = await import("/src/sdk/client.ts")
- const { rebuildTemplateWithServices } = await import("/src/sdk/pools.ts")
+ const { ensureSdkInitialized } = await import("/src/auth/cyclops-client.ts")
+ const { rebuildTemplateWithServices } = await import("/src/fleet/pools.ts")
const {
Firmware,
ImagePullPolicy,
@@ -135,7 +135,7 @@ test.describe("SDK builders", () => {
PreservedJson,
RuntimeKind,
SandboxServiceBuilder,
- } = await import("/src/sdk/generated.ts")
+ } = await import("/sdk-bindings/ts-uniffi-browser/ts/index.web.ts")
await ensureSdkInitialized()
const originalService = new SandboxServiceBuilder()
.name("old")
@@ -308,8 +308,8 @@ test.describe("SDK builders", () => {
})
const result = await page.evaluate(async () => {
- const { createPool } = await import("/src/sdk/pools.ts")
- const { SdkError } = await import("/src/sdk/generated.ts")
+ const { createPool } = await import("/src/fleet/pools.ts")
+ const { SdkError } = await import("/sdk-bindings/ts-uniffi-browser/ts/index.web.ts")
try {
await createPool("rollback-pool", {
cpu: 1,
diff --git a/libs/fleet/e2e/sdk-models.unit.ts b/libs/fleet/e2e/sdk-models.unit.ts
index 8de6928c27..85ae825759 100644
--- a/libs/fleet/e2e/sdk-models.unit.ts
+++ b/libs/fleet/e2e/sdk-models.unit.ts
@@ -1,10 +1,9 @@
-import { deriveWarmPoolPhase } from "../src/sdk/status.js"
import type {
Conversation,
ConversationSummary,
listConversations,
setConversationArchived,
-} from "../src/sdk/chat.js"
+} from "../src/api/chat.js"
function assertEqual<T>(actual: T, expected: T, message: string): void {
if (actual !== expected) {
@@ -12,27 +11,6 @@ function assertEqual<T>(actual: T, expected: T, message: string): void {
}
}
-assertEqual(
- deriveWarmPoolPhase(0, { replicas: 0, readyReplicas: 0 }),
- "Ready",
- "a reconciled zero-sized pool is healthy",
-)
-assertEqual(
- deriveWarmPoolPhase(0, undefined),
- "Provisioning",
- "a pool without observed status is still provisioning",
-)
-assertEqual(
- deriveWarmPoolPhase(2, { replicas: 2, readyReplicas: 1 }),
- "Provisioning",
- "a partially ready pool is provisioning",
-)
-assertEqual(
- deriveWarmPoolPhase(2, { replicas: 2, readyReplicas: 2 }),
- "Ready",
- "a fully ready pool is healthy",
-)
-
const archivedAt = "2026-08-16T20:20:00.000Z"
const archivedConversation: ConversationSummary = {
id: "archived-conversation",
diff --git a/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.ts b/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.ts
index f854af0b8f..2b102d910a 100644
--- a/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.ts
+++ b/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.ts
@@ -43,6 +43,7 @@ import {
FfiConverterUInt8,
RustBuffer,
UniffiAbstractObject,
+ UniffiEnum,
UniffiError,
UniffiInternalError,
UniffiResult,
@@ -86,6 +87,102 @@ const uniffiIsDebug =
// Public interface members begin here.
+export function healthyPoolDisplayStatus(): PoolDisplayStatus {
+ return ((__rb: Uint8Array) => {
+ try {
+ return FfiConverterTypePoolDisplayStatus.lift(__rb);
+ } finally {
+ nativeModule().rustbuffer_free(__rb);
+ }
+ })(
+ uniffiCaller.rustCall(
+ /*caller:*/ (callStatus) => {
+ return nativeModule().ubrn_uniffi_cyclops_sdk_fn_func_healthy_pool_display_status(
+ callStatus,
+ );
+ },
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ ),
+ );
+}
+
+export function poolDisplayStatus(pool: Pool): PoolDisplayStatus {
+ return ((__rb: Uint8Array) => {
+ try {
+ return FfiConverterTypePoolDisplayStatus.lift(__rb);
+ } finally {
+ nativeModule().rustbuffer_free(__rb);
+ }
+ })(
+ uniffiCaller.rustCall(
+ /*caller:*/ (callStatus) => {
+ return nativeModule().ubrn_uniffi_cyclops_sdk_fn_func_pool_display_status(
+ FfiConverterTypePool.lower(pool, nativeModule().rustbuffer_alloc),
+ callStatus,
+ );
+ },
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ ),
+ );
+}
+
+export function removedPoolDisplayStatus(): PoolDisplayStatus {
+ return ((__rb: Uint8Array) => {
+ try {
+ return FfiConverterTypePoolDisplayStatus.lift(__rb);
+ } finally {
+ nativeModule().rustbuffer_free(__rb);
+ }
+ })(
+ uniffiCaller.rustCall(
+ /*caller:*/ (callStatus) => {
+ return nativeModule().ubrn_uniffi_cyclops_sdk_fn_func_removed_pool_display_status(
+ callStatus,
+ );
+ },
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ ),
+ );
+}
+
+export function terminatingPoolDisplayStatus(): PoolDisplayStatus {
+ return ((__rb: Uint8Array) => {
+ try {
+ return FfiConverterTypePoolDisplayStatus.lift(__rb);
+ } finally {
+ nativeModule().rustbuffer_free(__rb);
+ }
+ })(
+ uniffiCaller.rustCall(
+ /*caller:*/ (callStatus) => {
+ return nativeModule().ubrn_uniffi_cyclops_sdk_fn_func_terminating_pool_display_status(
+ callStatus,
+ );
+ },
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ ),
+ );
+}
+
+export function unknownPoolDisplayStatus(): PoolDisplayStatus {
+ return ((__rb: Uint8Array) => {
+ try {
+ return FfiConverterTypePoolDisplayStatus.lift(__rb);
+ } finally {
+ nativeModule().rustbuffer_free(__rb);
+ }
+ })(
+ uniffiCaller.rustCall(
+ /*caller:*/ (callStatus) => {
+ return nativeModule().ubrn_uniffi_cyclops_sdk_fn_func_unknown_pool_display_status(
+ callStatus,
+ );
+ },
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ ),
+ );
+}
+
const stringConverter = (() => {
const encoder = new TextEncoder();
const decoder = new TextDecoder();
@@ -1001,6 +1098,104 @@ const FfiConverterTypeNewUserApiKey = (() => {
return new FFIConverter();
})();
+export enum PoolDisplayStatusKind {
+ Healthy,
+ ScaledToZero,
+ Removed,
+ Terminating,
+ Unknown,
+}
+
+const FfiConverterTypePoolDisplayStatusKind = (() => {
+ const ordinalConverter = FfiConverterInt32;
+ type TypeName = PoolDisplayStatusKind;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ switch (ordinalConverter.read(from)) {
+ case 1:
+ return PoolDisplayStatusKind.Healthy;
+ case 2:
+ return PoolDisplayStatusKind.ScaledToZero;
+ case 3:
+ return PoolDisplayStatusKind.Removed;
+ case 4:
+ return PoolDisplayStatusKind.Terminating;
+ case 5:
+ return PoolDisplayStatusKind.Unknown;
+ default:
+ throw new UniffiInternalError.UnexpectedEnumCase();
+ }
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ switch (value) {
+ case PoolDisplayStatusKind.Healthy:
+ return ordinalConverter.write(1, into);
+ case PoolDisplayStatusKind.ScaledToZero:
+ return ordinalConverter.write(2, into);
+ case PoolDisplayStatusKind.Removed:
+ return ordinalConverter.write(3, into);
+ case PoolDisplayStatusKind.Terminating:
+ return ordinalConverter.write(4, into);
+ case PoolDisplayStatusKind.Unknown:
+ return ordinalConverter.write(5, into);
+ }
+ }
+ allocationSize(value: TypeName): number {
+ return ordinalConverter.allocationSize(0);
+ }
+ }
+ return new FFIConverter();
+})();
+
+export type PoolDisplayStatus = {
+ kind: PoolDisplayStatusKind;
+ label: string;
+ indicator: string;
+};
+
+/**
+ * Generated factory for {@link PoolDisplayStatus} record objects.
+ */
+export const PoolDisplayStatus = (() => {
+ const defaults = () => ({});
+ const create = (() => {
+ return uniffiCreateRecord<PoolDisplayStatus, ReturnType<typeof defaults>>(
+ defaults,
+ );
+ })();
+ return Object.freeze({
+ create,
+ new: create,
+ defaults: () => Object.freeze(defaults()) as Partial<PoolDisplayStatus>,
+ });
+})();
+
+const FfiConverterTypePoolDisplayStatus = (() => {
+ type TypeName = PoolDisplayStatus;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ return {
+ kind: FfiConverterTypePoolDisplayStatusKind.read(from),
+ label: FfiConverterString.read(from),
+ indicator: FfiConverterString.read(from),
+ };
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ FfiConverterTypePoolDisplayStatusKind.write(value.kind, into);
+ FfiConverterString.write(value.label, into);
+ FfiConverterString.write(value.indicator, into);
+ }
+ allocationSize(value: TypeName): number {
+ return (
+ FfiConverterTypePoolDisplayStatusKind.allocationSize(value.kind) +
+ FfiConverterString.allocationSize(value.label) +
+ FfiConverterString.allocationSize(value.indicator)
+ );
+ }
+ }
+ return new FFIConverter();
+})();
+
export type Sandbox = {
namespace: string;
claim: string;
@@ -5548,6 +5743,46 @@ function uniffiEnsureInitialized() {
bindingsContractVersion,
);
}
+ if (
+ nativeModule().ubrn_uniffi_cyclops_sdk_checksum_func_healthy_pool_display_status() !==
+ 3094
+ ) {
+ throw new UniffiInternalError.ApiChecksumMismatch(
+ "uniffi_cyclops_sdk_checksum_func_healthy_pool_display_status",
+ );
+ }
+ if (
+ nativeModule().ubrn_uniffi_cyclops_sdk_checksum_func_pool_display_status() !==
+ 8587
+ ) {
+ throw new UniffiInternalError.ApiChecksumMismatch(
+ "uniffi_cyclops_sdk_checksum_func_pool_display_status",
+ );
+ }
+ if (
+ nativeModule().ubrn_uniffi_cyclops_sdk_checksum_func_removed_pool_display_status() !==
+ 48761
+ ) {
+ throw new UniffiInternalError.ApiChecksumMismatch(
+ "uniffi_cyclops_sdk_checksum_func_removed_pool_display_status",
+ );
+ }
+ if (
+ nativeModule().ubrn_uniffi_cyclops_sdk_checksum_func_terminating_pool_display_status() !==
+ 41320
+ ) {
+ throw new UniffiInternalError.ApiChecksumMismatch(
+ "uniffi_cyclops_sdk_checksum_func_terminating_pool_display_status",
+ );
+ }
+ if (
+ nativeModule().ubrn_uniffi_cyclops_sdk_checksum_func_unknown_pool_display_status() !==
+ 39929
+ ) {
+ throw new UniffiInternalError.ApiChecksumMismatch(
+ "uniffi_cyclops_sdk_checksum_func_unknown_pool_display_status",
+ );
+ }
if (
nativeModule().ubrn_uniffi_cyclops_sdk_checksum_method_accesstokenprovider_get_access_token() !==
1180
@@ -6173,6 +6408,8 @@ export default Object.freeze({
FfiConverterTypeNamespace,
FfiConverterTypeNewUserApiKey,
FfiConverterTypePool,
+ FfiConverterTypePoolDisplayStatus,
+ FfiConverterTypePoolDisplayStatusKind,
FfiConverterTypeResourceMetadata,
FfiConverterTypeSandbox,
FfiConverterTypeSdkBuildError,
diff --git a/libs/fleet/sdk/src/lib.rs b/libs/fleet/sdk/src/lib.rs
index c879983b15..86aee8a493 100644
--- a/libs/fleet/sdk/src/lib.rs
+++ b/libs/fleet/sdk/src/lib.rs
@@ -5,6 +5,7 @@ mod namespaces;
mod pools;
mod routes;
mod services;
+mod status;
mod templates;
mod transport;
mod types;
@@ -16,6 +17,10 @@ pub use error::{
bounded_body,
};
pub use routes::validate_dns_label;
+pub use status::{
+ PoolDisplayStatus, PoolDisplayStatusKind, healthy_pool_display_status, pool_display_status,
+ removed_pool_display_status, terminating_pool_display_status, unknown_pool_display_status,
+};
pub use transport::{AccessTokenProvider, HttpClient};
pub use types::{
Claim, CreateClaimRequest, CreateClaimRequestBuilder, CreatePoolRequest,
diff --git a/libs/fleet/sdk/src/status.rs b/libs/fleet/sdk/src/status.rs
new file mode 100644
index 0000000000..bae0ee6dc9
--- /dev/null
+++ b/libs/fleet/sdk/src/status.rs
@@ -0,0 +1,122 @@
+use crate::Pool;
+use serde::{Deserialize, Serialize};
+
+const HEALTHY_INDICATOR: &str = "#2ea043";
+const SCALED_TO_ZERO_INDICATOR: &str = "#a371f7";
+const REMOVED_INDICATOR: &str = "#8b949e";
+const OTHER_INDICATOR: &str = "#d29922";
+
+#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, uniffi::Enum)]
+pub enum PoolDisplayStatusKind {
+ Healthy,
+ ScaledToZero,
+ Removed,
+ Terminating,
+ Unknown,
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)]
+pub struct PoolDisplayStatus {
+ pub kind: PoolDisplayStatusKind,
+ pub label: String,
+ pub indicator: String,
+}
+
+fn display_status(kind: PoolDisplayStatusKind, label: &str, indicator: &str) -> PoolDisplayStatus {
+ PoolDisplayStatus {
+ kind,
+ label: label.into(),
+ indicator: indicator.into(),
+ }
+}
+
+#[uniffi::export]
+pub fn pool_display_status(pool: Pool) -> PoolDisplayStatus {
+ if pool.spec.replicas == 0 {
+ return display_status(
+ PoolDisplayStatusKind::ScaledToZero,
+ "Scaled to zero",
+ SCALED_TO_ZERO_INDICATOR,
+ );
+ }
+ if pool.status.is_none() {
+ return unknown_pool_display_status();
+ }
+ healthy_pool_display_status()
+}
+
+#[uniffi::export]
+pub fn healthy_pool_display_status() -> PoolDisplayStatus {
+ display_status(PoolDisplayStatusKind::Healthy, "Healthy", HEALTHY_INDICATOR)
+}
+
+#[uniffi::export]
+pub fn removed_pool_display_status() -> PoolDisplayStatus {
+ display_status(PoolDisplayStatusKind::Removed, "Removed", REMOVED_INDICATOR)
+}
+
+#[uniffi::export]
+pub fn terminating_pool_display_status() -> PoolDisplayStatus {
+ display_status(
+ PoolDisplayStatusKind::Terminating,
+ "Terminating",
+ OTHER_INDICATOR,
+ )
+}
+
+#[uniffi::export]
+pub fn unknown_pool_display_status() -> PoolDisplayStatus {
+ display_status(PoolDisplayStatusKind::Unknown, "Unknown", OTHER_INDICATOR)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::ResourceMetadata;
+ use cyclops_sdk_schema::OSGymSandboxWarmPoolStatus;
+
+ fn pool(replicas: u32, status: Option<OSGymSandboxWarmPoolStatus>) -> Pool {
+ Pool {
+ api_version: "osgym.cua.ai/v1alpha1".into(),
+ kind: "OSGymSandboxWarmPool".into(),
+ metadata: ResourceMetadata {
+ namespace: "default".into(),
+ name: "pool".into(),
+ labels: None,
+ creation_timestamp: None,
+ },
+ spec: serde_json::from_value(serde_json::json!({
+ "replicas": replicas,
+ "sandboxTemplateRef": { "name": "pool-template" },
+ }))
+ .unwrap(),
+ status,
+ }
+ }
+
+ #[test]
+ fn fully_claimed_pool_is_healthy() {
+ let status = OSGymSandboxWarmPoolStatus {
+ replicas: Some(1),
+ ready_replicas: Some(0),
+ selector: None,
+ };
+ let display = pool_display_status(pool(1, Some(status)));
+ assert_eq!(display.kind, PoolDisplayStatusKind::Healthy);
+ assert_eq!(display.label, "Healthy");
+ assert_eq!(display.indicator, HEALTHY_INDICATOR);
+ }
+
+ #[test]
+ fn scaled_to_zero_and_unknown_have_sdk_owned_descriptors() {
+ assert_eq!(
+ pool_display_status(pool(0, Some(OSGymSandboxWarmPoolStatus::default()))).kind,
+ PoolDisplayStatusKind::ScaledToZero
+ );
+ assert_eq!(
+ pool_display_status(pool(1, None)).kind,
+ PoolDisplayStatusKind::Unknown
+ );
+ assert_eq!(removed_pool_display_status().indicator, REMOVED_INDICATOR);
+ }
+}
diff --git a/libs/fleet/src/sdk/adminFeatureFlags.ts b/libs/fleet/src/api/adminFeatureFlags.ts
similarity index 100%
rename from libs/fleet/src/sdk/adminFeatureFlags.ts
rename to libs/fleet/src/api/adminFeatureFlags.ts
diff --git a/libs/fleet/src/sdk/billing.ts b/libs/fleet/src/api/billing.ts
similarity index 100%
rename from libs/fleet/src/sdk/billing.ts
rename to libs/fleet/src/api/billing.ts
diff --git a/libs/fleet/src/sdk/chat.ts b/libs/fleet/src/api/chat.ts
similarity index 100%
rename from libs/fleet/src/sdk/chat.ts
rename to libs/fleet/src/api/chat.ts
diff --git a/libs/fleet/src/sdk/featureFlags.ts b/libs/fleet/src/api/featureFlags.ts
similarity index 100%
rename from libs/fleet/src/sdk/featureFlags.ts
rename to libs/fleet/src/api/featureFlags.ts
diff --git a/libs/fleet/src/sdk/githubTrustPolicies.ts b/libs/fleet/src/api/githubTrustPolicies.ts
similarity index 100%
rename from libs/fleet/src/sdk/githubTrustPolicies.ts
rename to libs/fleet/src/api/githubTrustPolicies.ts
diff --git a/libs/fleet/src/sdk/usage.ts b/libs/fleet/src/api/usage.ts
similarity index 100%
rename from libs/fleet/src/sdk/usage.ts
rename to libs/fleet/src/api/usage.ts
diff --git a/libs/fleet/src/sdk/client.ts b/libs/fleet/src/auth/cyclops-client.ts
similarity index 91%
rename from libs/fleet/src/sdk/client.ts
rename to libs/fleet/src/auth/cyclops-client.ts
index 0a2dd233d5..712198e93f 100644
--- a/libs/fleet/src/sdk/client.ts
+++ b/libs/fleet/src/auth/cyclops-client.ts
@@ -1,10 +1,10 @@
-import { getToken } from "../auth/keycloak"
+import { getToken } from "./keycloak"
import {
CyclopsClient,
CyclopsTokenProviderConfigurationBuilder,
uniffiInitAsync,
type CyclopsTokenProviderConfiguration,
-} from "./generated"
+} from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
const sdkInitialization = uniffiInitAsync()
diff --git a/libs/fleet/src/browser-sdk-commands.ts b/libs/fleet/src/browser-sdk-commands.ts
index c84af64752..263a108264 100644
--- a/libs/fleet/src/browser-sdk-commands.ts
+++ b/libs/fleet/src/browser-sdk-commands.ts
@@ -57,9 +57,9 @@ const SDK_COMMAND_HELP: Record<BrowserSdkCommandName, BrowserCommandHelp> = {
listPools: {
summary: "List all pools visible to the current user.",
usage: "listPools",
- output: "A JSON array with name, namespace, replicas, availableCount, and phase for each pool.",
+ output: "A JSON array with name, namespace, replicas, availableCount, and status for each pool.",
presentation: [
- "Use a concise Markdown table with exactly these columns: Pool | Replicas | Available | Phase.",
+ "Use a concise Markdown table with exactly these columns: Pool | Replicas | Available | Status.",
"Omit Namespace; it is implementation detail and redundant in this listing.",
"Render each pool name as a Markdown link to /pools/<URL-encoded namespace>/<URL-encoded pool name>.",
"After the table, summarize the total pool count and total available sandboxes in one sentence.",
diff --git a/libs/fleet/src/chat/ChatThreadsContext.tsx b/libs/fleet/src/chat/ChatThreadsContext.tsx
index d4479f76d9..cc3afce036 100644
--- a/libs/fleet/src/chat/ChatThreadsContext.tsx
+++ b/libs/fleet/src/chat/ChatThreadsContext.tsx
@@ -19,7 +19,7 @@ import {
setConversationArchived,
type Conversation,
type ConversationSummary,
-} from "../sdk/chat"
+} from "../api/chat"
interface ChatThreadsContextValue {
activeThreads: ConversationSummary[]
diff --git a/libs/fleet/src/components/FeatureFlagContext.tsx b/libs/fleet/src/components/FeatureFlagContext.tsx
index b54707c3f2..62ad0cfd4f 100644
--- a/libs/fleet/src/components/FeatureFlagContext.tsx
+++ b/libs/fleet/src/components/FeatureFlagContext.tsx
@@ -7,7 +7,7 @@ import {
useState,
type ReactNode,
} from "react"
-import { fetchFeatureFlags, type FeatureFlags } from "../sdk/featureFlags"
+import { fetchFeatureFlags, type FeatureFlags } from "../api/featureFlags"
import { isLocalVisualPreview } from "../local-visual-preview"
import { DEFAULT_USAGE_PRICING } from "../usagePricing"
diff --git a/libs/fleet/src/components/PoolStatus.css b/libs/fleet/src/components/PoolStatus.css
new file mode 100644
index 0000000000..0122d33f81
--- /dev/null
+++ b/libs/fleet/src/components/PoolStatus.css
@@ -0,0 +1,14 @@
+.cua-pool-status {
+ display: inline-flex;
+ gap: 8px;
+ align-items: center;
+}
+
+.cua-pool-status__dot {
+ display: inline-block;
+ flex: 0 0 auto;
+ width: 9px;
+ height: 9px;
+ border: 1px solid rgba(255, 255, 255, 0.22);
+ border-radius: 50%;
+}
diff --git a/libs/fleet/src/components/PoolStatus.tsx b/libs/fleet/src/components/PoolStatus.tsx
index 8d73f62c63..cd7c755473 100644
--- a/libs/fleet/src/components/PoolStatus.tsx
+++ b/libs/fleet/src/components/PoolStatus.tsx
@@ -1,29 +1,40 @@
-import StatusIndicator, {
- type StatusIndicatorProps,
-} from "@cloudscape-design/components/status-indicator"
-import type { PoolStatus } from "../sdk/status"
+import type { CSSProperties } from "react"
+import type { PoolDisplayStatus } from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
+import "./PoolStatus.css"
-const POOL_STATUS_TYPE: Record<PoolStatus["kind"], StatusIndicatorProps.Type> = {
- healthy: "success",
- provisioning: "in-progress",
- terminating: "in-progress",
- unknown: "pending",
+function indicatorStyle(status: PoolDisplayStatus): CSSProperties {
+ return { backgroundColor: status.indicator }
+}
+
+export function PoolStatusDot({ status }: { status: PoolDisplayStatus }) {
+ return (
+ <span
+ aria-label={status.label}
+ className="cua-pool-status__dot"
+ role="img"
+ style={indicatorStyle(status)}
+ title={status.label}
+ />
+ )
}
export function PoolStatusPill({
status,
compact = false,
}: {
- status: PoolStatus
+ status: PoolDisplayStatus
compact?: boolean
}) {
return (
- <span title={compact ? status.label : undefined}>
- <StatusIndicator type={POOL_STATUS_TYPE[status.kind]}>
- <span className={compact ? "cua-visually-hidden" : undefined}>
- {status.label}
- </span>
- </StatusIndicator>
+ <span className="cua-pool-status" title={compact ? status.label : undefined}>
+ <span
+ aria-hidden="true"
+ className="cua-pool-status__dot"
+ style={indicatorStyle(status)}
+ />
+ <span className={compact ? "cua-visually-hidden" : undefined}>
+ {status.label}
+ </span>
</span>
)
}
diff --git a/libs/fleet/src/sdk/claims.ts b/libs/fleet/src/fleet/claims.ts
similarity index 94%
rename from libs/fleet/src/sdk/claims.ts
rename to libs/fleet/src/fleet/claims.ts
index 97c3885406..2ee81500d1 100644
--- a/libs/fleet/src/sdk/claims.ts
+++ b/libs/fleet/src/fleet/claims.ts
@@ -4,8 +4,8 @@ import {
type CreateClaimRequest,
type CyclopsClient,
type Pool,
-} from "./generated"
-import { withClient } from "./client"
+} from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
+import { withClient } from "../auth/cyclops-client"
import type { Claim } from "./models"
import { isLocalVisualPreview } from "../local-visual-preview"
diff --git a/libs/fleet/src/sdk/instances.ts b/libs/fleet/src/fleet/instances.ts
similarity index 100%
rename from libs/fleet/src/sdk/instances.ts
rename to libs/fleet/src/fleet/instances.ts
diff --git a/libs/fleet/src/sdk/models.ts b/libs/fleet/src/fleet/models.ts
similarity index 90%
rename from libs/fleet/src/sdk/models.ts
rename to libs/fleet/src/fleet/models.ts
index 97359d731f..e1702cfe2a 100644
--- a/libs/fleet/src/sdk/models.ts
+++ b/libs/fleet/src/fleet/models.ts
@@ -1,3 +1,5 @@
+import type { PoolDisplayStatus } from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
+
export interface PoolService {
name: string
targetPort: number
@@ -28,8 +30,8 @@ export interface PoolSummary {
name: string
namespace: string
replicas: number
- phase: string
availableCount: number
+ status: PoolDisplayStatus
}
export interface PoolData extends PoolSummary, PoolTemplateConfig {
diff --git a/libs/fleet/src/sdk/pools.ts b/libs/fleet/src/fleet/pools.ts
similarity index 94%
rename from libs/fleet/src/sdk/pools.ts
rename to libs/fleet/src/fleet/pools.ts
index 0de62f161a..b6b8d4158f 100644
--- a/libs/fleet/src/sdk/pools.ts
+++ b/libs/fleet/src/fleet/pools.ts
@@ -5,6 +5,7 @@ import {
OsGymSandboxTemplateSpecBuilder,
OsGymSandboxWarmPoolSpecBuilder,
PreservedJson,
+ poolDisplayStatus,
SandboxServiceBuilder,
SandboxTemplateRefBuilder,
ServiceProtocol,
@@ -23,9 +24,9 @@ import {
type VmTemplateBuilderLike,
type WarmPoolAutoscaling,
type WarmPoolAutoscalingBuilderLike,
-} from "./generated"
-import { withClient } from "./client"
-import { deriveWarmPoolPhase } from "./status"
+} from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
+import { ensureSdkInitialized, withClient } from "../auth/cyclops-client"
+import { applyPoolTombstones } from "./status"
import type {
PoolData,
PoolService,
@@ -58,8 +59,8 @@ function poolSummary(pool: Pool): PoolSummary {
name: pool.metadata.name,
namespace: pool.metadata.namespace,
replicas: pool.spec.replicas,
- phase: deriveWarmPoolPhase(pool.spec.replicas, pool.status),
availableCount: pool.status?.readyReplicas ?? 0,
+ status: poolDisplayStatus(pool),
}
}
@@ -106,7 +107,10 @@ export async function listNamespaces(): Promise<Namespace[]> {
}
export async function listPools(): Promise<PoolSummary[]> {
- if (isLocalVisualPreview()) return listLocalVisualPreviewPools()
+ if (isLocalVisualPreview()) {
+ await ensureSdkInitialized()
+ return applyPoolTombstones(await listLocalVisualPreviewPools())
+ }
return withClient(async client => {
const namespaces = await listNamespacesWith(client)
const pools = await Promise.all(
@@ -118,7 +122,9 @@ export async function listPools(): Promise<PoolSummary[]> {
}
}),
)
- return pools.flat().map(poolSummary).sort((a, b) => a.name.localeCompare(b.name))
+ return applyPoolTombstones(
+ pools.flat().map(poolSummary).sort((a, b) => a.name.localeCompare(b.name)),
+ )
})
}
@@ -140,6 +146,7 @@ async function getPoolWith(
export async function getPool(namespace: string, name: string): Promise<PoolData> {
if (isLocalVisualPreview()) {
+ await ensureSdkInitialized()
const pool = getLocalVisualPreviewPool(namespace, name)
if (!pool) throw new Error(`Preview pool ${namespace}/${name} was not found`)
return pool
diff --git a/libs/fleet/src/fleet/status.ts b/libs/fleet/src/fleet/status.ts
new file mode 100644
index 0000000000..aeeabc5981
--- /dev/null
+++ b/libs/fleet/src/fleet/status.ts
@@ -0,0 +1,35 @@
+import {
+ removedPoolDisplayStatus,
+ terminatingPoolDisplayStatus,
+ unknownPoolDisplayStatus,
+ type PoolDisplayStatus,
+} from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
+import type { PoolSummary } from "./models"
+
+export function historicalPoolStatus(
+ poolId: string,
+ currentPools: PoolSummary[] | null,
+): PoolDisplayStatus {
+ if (!currentPools) return unknownPoolDisplayStatus()
+ return currentPools.find(
+ pool => `${pool.namespace}:${pool.name}` === poolId,
+ )?.status ?? removedPoolDisplayStatus()
+}
+
+const tombstones = new Set<string>()
+
+export function tombstonePool(name: string): void {
+ tombstones.add(name)
+}
+
+export function applyPoolTombstones(pools: PoolSummary[]): PoolSummary[] {
+ const names = new Set(pools.map(pool => pool.name))
+ for (const tombstone of tombstones) {
+ if (!names.has(tombstone)) tombstones.delete(tombstone)
+ }
+ return pools.map(pool =>
+ tombstones.has(pool.name)
+ ? { ...pool, status: terminatingPoolDisplayStatus() }
+ : pool,
+ )
+}
diff --git a/libs/fleet/src/sdk/userKeys.ts b/libs/fleet/src/fleet/userKeys.ts
similarity index 89%
rename from libs/fleet/src/sdk/userKeys.ts
rename to libs/fleet/src/fleet/userKeys.ts
index d3b287cd8f..47656f0078 100644
--- a/libs/fleet/src/sdk/userKeys.ts
+++ b/libs/fleet/src/fleet/userKeys.ts
@@ -3,11 +3,11 @@ import {
type CreateUserApiKeyRequest,
type NewUserApiKey,
type UserApiKey,
-} from "./generated"
-import { withClient } from "./client"
+} from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
+import { withClient } from "../auth/cyclops-client"
import { isLocalVisualPreview } from "../local-visual-preview"
-export type { NewUserApiKey, UserApiKey } from "./generated"
+export type { NewUserApiKey, UserApiKey } from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
let localVisualPreviewKeys: UserApiKey[] = [
{
diff --git a/libs/fleet/src/local-visual-preview.ts b/libs/fleet/src/local-visual-preview.ts
index cbaed5b0eb..d9d5c9ecfe 100644
--- a/libs/fleet/src/local-visual-preview.ts
+++ b/libs/fleet/src/local-visual-preview.ts
@@ -1,14 +1,15 @@
-import type { PoolData, PoolSummary } from "./sdk/models"
+import type { PoolData, PoolSummary } from "./fleet/models"
+import { healthyPoolDisplayStatus } from "../sdk-bindings/ts-uniffi-browser/ts/index.web"
import type {
BillingUsage,
UsagePoint,
UsageRangeMonths,
-} from "./sdk/billing"
+} from "./api/billing"
import type {
ChatMessage,
Conversation,
ConversationSummary,
-} from "./sdk/chat"
+} from "./api/chat"
export function isLocalVisualPreview(): boolean {
const localPreview =
@@ -28,20 +29,23 @@ export function localVisualPreviewPath(path: string): string {
return `${path}${path.includes("?") ? "&" : "?"}cua-visual-preview`
}
-export const localVisualPreviewPools: PoolSummary[] = [
- { name: "prod-web-fleet", namespace: "preview", replicas: 120, availableCount: 118, phase: "Ready" },
- { name: "prod-api-fleet", namespace: "preview", replicas: 80, availableCount: 79, phase: "Ready" },
- { name: "staging-web-fleet", namespace: "preview", replicas: 40, availableCount: 38, phase: "Ready" },
- { name: "staging-api-fleet", namespace: "preview", replicas: 30, availableCount: 28, phase: "Scaling" },
- { name: "dev-tools-fleet", namespace: "preview", replicas: 20, availableCount: 20, phase: "Ready" },
- { name: "eval-runner-fleet", namespace: "preview", replicas: 16, availableCount: 14, phase: "Scaling" },
- { name: "batch-jobs-fleet", namespace: "preview", replicas: 64, availableCount: 60, phase: "Degraded" },
- { name: "canary-fleet", namespace: "preview", replicas: 8, availableCount: 8, phase: "Ready" },
- { name: "infra-maint-fleet", namespace: "preview", replicas: 12, availableCount: 10, phase: "Degraded" },
- { name: "data-pipeline-fleet", namespace: "preview", replicas: 24, availableCount: 22, phase: "Ready" },
- { name: "browser-agent-fleet", namespace: "preview", replicas: 32, availableCount: 31, phase: "Ready" },
- { name: "desktop-agent-fleet", namespace: "preview", replicas: 18, availableCount: 17, phase: "Ready" },
-]
+function localVisualPreviewPools(): PoolSummary[] {
+ const status = healthyPoolDisplayStatus()
+ return [
+ { name: "prod-web-fleet", namespace: "preview", replicas: 120, availableCount: 118, status },
+ { name: "prod-api-fleet", namespace: "preview", replicas: 80, availableCount: 79, status },
+ { name: "staging-web-fleet", namespace: "preview", replicas: 40, availableCount: 38, status },
+ { name: "staging-api-fleet", namespace: "preview", replicas: 30, availableCount: 28, status },
+ { name: "dev-tools-fleet", namespace: "preview", replicas: 20, availableCount: 20, status },
+ { name: "eval-runner-fleet", namespace: "preview", replicas: 16, availableCount: 14, status },
+ { name: "batch-jobs-fleet", namespace: "preview", replicas: 64, availableCount: 60, status },
+ { name: "canary-fleet", namespace: "preview", replicas: 8, availableCount: 8, status },
+ { name: "infra-maint-fleet", namespace: "preview", replicas: 12, availableCount: 10, status },
+ { name: "data-pipeline-fleet", namespace: "preview", replicas: 24, availableCount: 22, status },
+ { name: "browser-agent-fleet", namespace: "preview", replicas: 32, availableCount: 31, status },
+ { name: "desktop-agent-fleet", namespace: "preview", replicas: 18, availableCount: 17, status },
+ ]
+}
export async function listLocalVisualPreviewPools(): Promise<PoolSummary[]> {
const state = new URLSearchParams(window.location.search).get(
@@ -52,14 +56,14 @@ export async function listLocalVisualPreviewPools(): Promise<PoolSummary[]> {
}
if (state === "empty") return []
if (state === "error") throw new Error("Synthetic preview error")
- return localVisualPreviewPools
+ return localVisualPreviewPools()
}
export function getLocalVisualPreviewPool(
namespace: string,
name: string,
): PoolData | undefined {
- const summary = localVisualPreviewPools.find(
+ const summary = localVisualPreviewPools().find(
pool => pool.namespace === namespace && pool.name === name,
)
if (!summary) return undefined
diff --git a/libs/fleet/src/pages/AgentChat.tsx b/libs/fleet/src/pages/AgentChat.tsx
index 8d7a67b6da..44e40d4627 100644
--- a/libs/fleet/src/pages/AgentChat.tsx
+++ b/libs/fleet/src/pages/AgentChat.tsx
@@ -15,7 +15,7 @@ import SpaceBetween from "@cloudscape-design/components/space-between";
import StatusIndicator from "@cloudscape-design/components/status-indicator";
import { MarkdownMessage } from "../components/MarkdownMessage";
import { PageShell } from "../components/PageShell";
-import { createClaim, deleteClaim, getClaim, listClaims } from "../sdk/claims";
+import { createClaim, deleteClaim, getClaim, listClaims } from "../fleet/claims";
import {
createPool,
deletePool,
@@ -23,8 +23,8 @@ import {
listNamespaces,
listPools,
updatePoolServices,
-} from "../sdk/pools";
-import { createUserKey, deleteUserKey, listUserKeys } from "../sdk/userKeys";
+} from "../fleet/pools";
+import { createUserKey, deleteUserKey, listUserKeys } from "../fleet/userKeys";
import {
ChatApiError,
getConversation,
@@ -33,7 +33,7 @@ import {
type ChatToolCall,
type Conversation,
type ConversationSummary,
-} from "../sdk/chat";
+} from "../api/chat";
import {
BrowserBashAgent,
type BashToolResult,
diff --git a/libs/fleet/src/pages/ArchivedThreads.tsx b/libs/fleet/src/pages/ArchivedThreads.tsx
index b33fadf5ae..41e9aaaa0f 100644
--- a/libs/fleet/src/pages/ArchivedThreads.tsx
+++ b/libs/fleet/src/pages/ArchivedThreads.tsx
@@ -7,7 +7,7 @@ import Header from "@cloudscape-design/components/header";
import SpaceBetween from "@cloudscape-design/components/space-between";
import { displayThreadTitle, useChatThreads } from "../chat/ChatThreadsContext";
import { localVisualPreviewPath } from "../local-visual-preview";
-import { listConversations, type ConversationSummary } from "../sdk/chat";
+import { listConversations, type ConversationSummary } from "../api/chat";
import { PageShell } from "../components/PageShell";
import "./AgentChat.css";
diff --git a/libs/fleet/src/pages/Billing.tsx b/libs/fleet/src/pages/Billing.tsx
index 799a9ac1da..46f531d76f 100644
--- a/libs/fleet/src/pages/Billing.tsx
+++ b/libs/fleet/src/pages/Billing.tsx
@@ -9,7 +9,7 @@ import SpaceBetween from "@cloudscape-design/components/space-between";
import Spinner from "@cloudscape-design/components/spinner";
import { useEffect, useState } from "react";
import { CuaButton } from "../components/CuaButton";
-import { billingApi, type BillingSummary } from "../sdk/billing";
+import { billingApi, type BillingSummary } from "../api/billing";
function cardBrand(brand: string) {
return brand ? brand[0].toUpperCase() + brand.slice(1) : "Card";
diff --git a/libs/fleet/src/pages/BillingUsage.css b/libs/fleet/src/pages/BillingUsage.css
index c9c9733554..5c3059c926 100644
--- a/libs/fleet/src/pages/BillingUsage.css
+++ b/libs/fleet/src/pages/BillingUsage.css
@@ -174,6 +174,13 @@
font-variant-numeric: tabular-nums;
}
+.usage-pool-name {
+ display: inline-flex;
+ gap: 9px;
+ align-items: center;
+ min-width: 0;
+}
+
.usage-empty {
padding: 48px 0;
border-block: 1px solid var(--cua-color-border-subtle, rgba(255, 255, 255, 0.14));
diff --git a/libs/fleet/src/pages/BillingUsage.tsx b/libs/fleet/src/pages/BillingUsage.tsx
index 510149f59c..21e131de2e 100644
--- a/libs/fleet/src/pages/BillingUsage.tsx
+++ b/libs/fleet/src/pages/BillingUsage.tsx
@@ -3,14 +3,18 @@ import Input from "@cloudscape-design/components/input"
import Select from "@cloudscape-design/components/select"
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { CuaButton } from "../components/CuaButton"
+import { PoolStatusDot } from "../components/PoolStatus"
import { useFeatureFlags } from "../components/FeatureFlagContext"
import { PageEmpty, PageError } from "../components/PageState"
import { PageShell } from "../components/PageShell"
+import type { PoolSummary } from "../fleet/models"
+import { listPools } from "../fleet/pools"
+import { historicalPoolStatus } from "../fleet/status"
import {
usageApi,
type UsageOverviewResponse,
type UsageTimeframe,
-} from "../sdk/usage"
+} from "../api/usage"
import "./BillingUsage.css"
import { reservedResourceCostUSD } from "../usagePricing"
@@ -58,6 +62,7 @@ export function BillingUsagePage() {
const [activeSubject, setActiveSubject] = useState<string | null>(null)
const [subjectError, setSubjectError] = useState("")
const [overview, setOverview] = useState<UsageOverviewResponse | null>(null)
+ const [currentPools, setCurrentPools] = useState<PoolSummary[] | null>(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState(false)
const loadStarted = useRef(0)
@@ -68,9 +73,13 @@ export function BillingUsagePage() {
setLoading(true)
setError(false)
try {
- const value = await usageApi.overview(timeframe, activeSubject ?? undefined)
+ const [value, poolsResult] = await Promise.all([
+ usageApi.overview(timeframe, activeSubject ?? undefined),
+ listPools().catch(() => null),
+ ])
const initialLoadMS = performance.now() - loadStarted.current
setOverview(value)
+ setCurrentPools(poolsResult)
requestAnimationFrame(() => {
requestAnimationFrame(() => {
performance.mark("usage-dashboard-ready")
@@ -241,14 +250,22 @@ export function BillingUsagePage() {
</tr>
</thead>
<tbody>
- {pools.map(pool => (
- <tr className="usage-breakdown__row" key={pool.id}>
- <td>{pool.name}</td>
- <td data-label="Reserved CPU"><strong>{resourceHours(pool.cpu.provisioned, "core-h")}</strong></td>
- <td data-label="Reserved memory"><strong>{resourceHours(pool.memory.provisioned, "GiB-h")}</strong></td>
- <td data-label="Cost"><strong>{moneyFormatter.format(pool.reservedCostUSD)}</strong></td>
- </tr>
- ))}
+ {pools.map(pool => {
+ const status = historicalPoolStatus(pool.id, currentPools)
+ return (
+ <tr className="usage-breakdown__row" key={pool.id}>
+ <td>
+ <span className="usage-pool-name">
+ <PoolStatusDot status={status} />
+ <span>{pool.name}</span>
+ </span>
+ </td>
+ <td data-label="Reserved CPU"><strong>{resourceHours(pool.cpu.provisioned, "core-h")}</strong></td>
+ <td data-label="Reserved memory"><strong>{resourceHours(pool.memory.provisioned, "GiB-h")}</strong></td>
+ <td data-label="Cost"><strong>{moneyFormatter.format(pool.reservedCostUSD)}</strong></td>
+ </tr>
+ )
+ })}
</tbody>
</table>
</section>
diff --git a/libs/fleet/src/pages/ClaimDetail.tsx b/libs/fleet/src/pages/ClaimDetail.tsx
index da5cd44c3d..3e1968f7df 100644
--- a/libs/fleet/src/pages/ClaimDetail.tsx
+++ b/libs/fleet/src/pages/ClaimDetail.tsx
@@ -10,9 +10,9 @@ import SpaceBetween from "@cloudscape-design/components/space-between"
import StatusIndicator from "@cloudscape-design/components/status-indicator"
import { useFlash } from "../components/FlashContext"
import { DesktopPane } from "../components/DesktopPane"
-import { deleteClaim, getClaim } from "../sdk/claims"
-import type { Claim } from "../sdk/models"
-import { getPool } from "../sdk/pools"
+import { deleteClaim, getClaim } from "../fleet/claims"
+import type { Claim } from "../fleet/models"
+import { getPool } from "../fleet/pools"
import { CuaButton } from "../components/CuaButton"
import { PageEmpty, PageError } from "../components/PageState"
import { PageShell } from "../components/PageShell"
diff --git a/libs/fleet/src/pages/FeatureFlags.tsx b/libs/fleet/src/pages/FeatureFlags.tsx
index 3bf7be08f4..a8db22edcf 100644
--- a/libs/fleet/src/pages/FeatureFlags.tsx
+++ b/libs/fleet/src/pages/FeatureFlags.tsx
@@ -30,7 +30,7 @@ import {
type FeatureFlagOwnership,
type FeatureFlagValueType,
type JSONValue,
-} from "../sdk/adminFeatureFlags"
+} from "../api/adminFeatureFlags"
const TERRAFORM_FEATURE_FLAGS_URL =
"https://github.com/trycua/cloud/tree/main/terraform/aws/feature-flags"
diff --git a/libs/fleet/src/pages/PoolDetail.tsx b/libs/fleet/src/pages/PoolDetail.tsx
index 2eb18103b6..5ae88d2071 100644
--- a/libs/fleet/src/pages/PoolDetail.tsx
+++ b/libs/fleet/src/pages/PoolDetail.tsx
@@ -15,11 +15,11 @@ import Table from "@cloudscape-design/components/table"
import Tabs from "@cloudscape-design/components/tabs"
import { useFlash } from "../components/FlashContext"
import { PoolStatusPill } from "../components/PoolStatus"
-import { createClaim as createSdkClaim, deleteClaim, listClaims } from "../sdk/claims"
-import { listPoolInstances } from "../sdk/instances"
-import type { Claim, PoolData, PoolInstance } from "../sdk/models"
-import { deletePool, getPool, updatePoolServices } from "../sdk/pools"
-import { derivePoolStatus, tombstonePool } from "../sdk/status"
+import { createClaim as createSdkClaim, deleteClaim, listClaims } from "../fleet/claims"
+import { listPoolInstances } from "../fleet/instances"
+import type { Claim, PoolData, PoolInstance } from "../fleet/models"
+import { deletePool, getPool, updatePoolServices } from "../fleet/pools"
+import { tombstonePool } from "../fleet/status"
import { CuaButton } from "../components/CuaButton"
import { PageEmpty, PageError } from "../components/PageState"
import { PageShell } from "../components/PageShell"
@@ -95,13 +95,11 @@ export function PoolDetail() {
)
}
- const status = derivePoolStatus(pool)
-
return (
<PageShell
eyebrow="Fleet / Pool"
title={pool.name}
- description={<PoolStatusPill status={status} />}
+ description={<PoolStatusPill status={pool.status} />}
secondaryActions={
<SpaceBetween direction="horizontal" size="xs">
<CuaButton
diff --git a/libs/fleet/src/pages/PoolNew.tsx b/libs/fleet/src/pages/PoolNew.tsx
index ad2a63e193..b9f3cc2e29 100644
--- a/libs/fleet/src/pages/PoolNew.tsx
+++ b/libs/fleet/src/pages/PoolNew.tsx
@@ -12,8 +12,8 @@ import Select from "@cloudscape-design/components/select"
import SpaceBetween from "@cloudscape-design/components/space-between"
import Toggle from "@cloudscape-design/components/toggle"
import { useFlash } from "../components/FlashContext"
-import { createPool } from "../sdk/pools"
-import type { PoolTemplateConfig } from "../sdk/models"
+import { createPool } from "../fleet/pools"
+import type { PoolTemplateConfig } from "../fleet/models"
import { CuaButton } from "../components/CuaButton"
import { PageShell } from "../components/PageShell"
diff --git a/libs/fleet/src/pages/PoolsList.tsx b/libs/fleet/src/pages/PoolsList.tsx
index ba7d58acf2..0f5c643537 100644
--- a/libs/fleet/src/pages/PoolsList.tsx
+++ b/libs/fleet/src/pages/PoolsList.tsx
@@ -9,24 +9,21 @@ import Pagination from "@cloudscape-design/components/pagination"
import PropertyFilter from "@cloudscape-design/components/property-filter"
import SpaceBetween from "@cloudscape-design/components/space-between"
import Table from "@cloudscape-design/components/table"
-import { deletePool, getPool, listPools } from "../sdk/pools"
+import { deletePool, getPool, listPools } from "../fleet/pools"
import { localVisualPreviewPath } from "../local-visual-preview"
-import {
- derivePoolStatus,
- reconcileTombstones,
- tombstonePool,
-} from "../sdk/status"
+import { tombstonePool } from "../fleet/status"
import { PoolStatusPill } from "../components/PoolStatus"
import { useFlash } from "../components/FlashContext"
import { CuaButton } from "../components/CuaButton"
import { PageEmpty } from "../components/PageState"
import { PageShell } from "../components/PageShell"
+import type { PoolSummary } from "../fleet/models"
interface PoolRow {
name: string
namespace: string
replicas: number
- phase: string
+ status: PoolSummary["status"]
availableCount: number
statusText: string
}
@@ -59,11 +56,10 @@ export function PoolsList() {
setLoading(true)
try {
const poolList = await listPools()
- reconcileTombstones(poolList.map(p => p.name))
setRows(
poolList.map(p => ({
...p,
- statusText: derivePoolStatus(p).kind,
+ statusText: p.status.label,
})),
)
} catch (e) {
@@ -104,7 +100,7 @@ export function PoolsList() {
}
}
- // A list row only carries summary fields (name/replicas/phase/available),
+ // A list row only carries summary fields,
// so fetch the full pool spec (cpu/ram/image/services) before navigating —
// otherwise the New pool form falls back to defaults. Mirrors the Duplicate
// action on the pool detail page, which passes the full getPool result.
@@ -317,7 +313,7 @@ export function PoolsList() {
header: "Status",
cell: p => (
<PoolStatusPill
- status={derivePoolStatus(p)}
+ status={p.status}
compact={compactTable}
/>
),
diff --git a/libs/fleet/src/pages/Settings.tsx b/libs/fleet/src/pages/Settings.tsx
index ed2bf7b9ac..9a03e73ad4 100644
--- a/libs/fleet/src/pages/Settings.tsx
+++ b/libs/fleet/src/pages/Settings.tsx
@@ -29,7 +29,7 @@ import {
type GitHubTrustPolicy,
githubTrustPoliciesApi,
namespacesApi,
-} from "../sdk/githubTrustPolicies"
+} from "../api/githubTrustPolicies"
import { BillingSettings } from "./Billing"
export function Settings() {
diff --git a/libs/fleet/src/pages/UserApiKeys.tsx b/libs/fleet/src/pages/UserApiKeys.tsx
index ed958939ac..21b4b0b2e7 100644
--- a/libs/fleet/src/pages/UserApiKeys.tsx
+++ b/libs/fleet/src/pages/UserApiKeys.tsx
@@ -27,8 +27,8 @@ import {
listUserKeys,
type NewUserApiKey,
type UserApiKey,
-} from "../sdk/userKeys"
-import { listNamespaces } from "../sdk/pools"
+} from "../fleet/userKeys"
+import { listNamespaces } from "../fleet/pools"
import { errorMessage } from "../error-message"
import { CuaButton } from "../components/CuaButton"
import { useFlash } from "../components/FlashContext"
diff --git a/libs/fleet/src/sdk/generated.ts b/libs/fleet/src/sdk/generated.ts
deleted file mode 100644
index 6cca520300..0000000000
--- a/libs/fleet/src/sdk/generated.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "../../sdk-bindings/ts-uniffi-browser/ts/index.web"
diff --git a/libs/fleet/src/sdk/status.ts b/libs/fleet/src/sdk/status.ts
deleted file mode 100644
index efa84125ed..0000000000
--- a/libs/fleet/src/sdk/status.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-export interface WarmPoolObservedStatus {
- replicas?: number
- readyReplicas?: number
-}
-
-export function deriveWarmPoolPhase(
- specReplicas: number,
- status: WarmPoolObservedStatus | undefined,
-): "Ready" | "Provisioning" {
- if (!status) return "Provisioning"
- const expected = status.replicas ?? specReplicas
- return (status.readyReplicas ?? 0) >= expected ? "Ready" : "Provisioning"
-}
-
-const tombstones = new Set<string>()
-
-export function tombstonePool(name: string): void {
- tombstones.add(name)
-}
-
-export function reconcileTombstones(present: Iterable<string>): void {
- const names = new Set(present)
- for (const tombstone of tombstones) {
- if (!names.has(tombstone)) tombstones.delete(tombstone)
- }
-}
-
-export function isTombstoned(name: string): boolean {
- return tombstones.has(name)
-}
-
-export type PoolStatus =
- | { kind: "healthy"; label: "Healthy" }
- | { kind: "provisioning"; label: "Provisioning" }
- | { kind: "terminating"; label: "Terminating" }
- | { kind: "unknown"; label: "Unknown" }
-
-export function derivePoolStatus(pool: { name: string; phase: string }): PoolStatus {
- if (isTombstoned(pool.name)) {
- return { kind: "terminating", label: "Terminating" }
- }
- const phase = (pool.phase ?? "").toLowerCase()
- if (phase === "ready") return { kind: "healthy", label: "Healthy" }
- if (phase === "provisioning") {
- return { kind: "provisioning", label: "Provisioning" }
- }
- return { kind: "unknown", label: "Unknown" }
-}
diff --git a/libs/fleet/tests/design-package-boundary.test.mjs b/libs/fleet/tests/design-package-boundary.test.mjs
index 0991678fe7..d9e530adab 100644
--- a/libs/fleet/tests/design-package-boundary.test.mjs
+++ b/libs/fleet/tests/design-package-boundary.test.mjs
@@ -122,9 +122,9 @@ test("dashboard activates the shared theme through supported boundaries", async
test("account preview data stays behind the fail-closed visual-preview gate", async () => {
const files = await Promise.all(
[
- "src/sdk/userKeys.ts",
- "src/sdk/githubTrustPolicies.ts",
- "src/sdk/billing.ts",
+ "src/fleet/userKeys.ts",
+ "src/api/githubTrustPolicies.ts",
+ "src/api/billing.ts",
"src/components/FeatureFlagContext.tsx",
].map(relativePath =>
readFile(path.join(cyclopsRoot, relativePath), "utf8"),
@@ -146,3 +146,29 @@ test("account preview data stays behind the fail-closed visual-preview gate", as
assert.match(files[1], /request<GitHubTrustPolicyListResponse>/)
assert.match(files[2], /billingRequest<BillingSummary>/)
})
+
+test("frontend imports the generated UniFFI SDK without an src/sdk proxy", async () => {
+ await assert.rejects(
+ readdir(path.join(cyclopsRoot, "src/sdk")),
+ error => error?.code === "ENOENT",
+ )
+
+ const sources = await Promise.all(
+ [
+ "src/auth/cyclops-client.ts",
+ "src/fleet/claims.ts",
+ "src/fleet/pools.ts",
+ "src/fleet/userKeys.ts",
+ ].map(relativePath =>
+ readFile(path.join(cyclopsRoot, relativePath), "utf8"),
+ ),
+ )
+
+ for (const source of sources) {
+ assert.match(
+ source,
+ /sdk-bindings\/ts-uniffi-browser\/ts\/index\.web/,
+ )
+ assert.doesNotMatch(source, /src\/sdk|\.\/generated/)
+ }
+})
diff --git a/libs/fleet/tsconfig.sdk-models.json b/libs/fleet/tsconfig.sdk-models.json
index d323a3a965..0fadca2521 100644
--- a/libs/fleet/tsconfig.sdk-models.json
+++ b/libs/fleet/tsconfig.sdk-models.json
@@ -18,7 +18,6 @@
},
"files": [
"e2e/sdk-models.unit.ts",
- "e2e/mock-chat-api.spec.ts",
- "src/sdk/status.ts"
+ "e2e/mock-chat-api.spec.ts"
]
}