Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/commands/blueprint/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ const ListBlueprintsUI = ({

// Fetch function for pagination hook
const fetchPage = React.useCallback(
async (params: { limit: number; startingAt?: string }) => {
async (params: {
limit: number;
startingAt?: string;
includeTotalCount?: boolean;
}) => {
const client = getClient();
const pageBlueprints: BlueprintListItem[] = [];

// Build query params
const queryParams: Record<string, unknown> = {
limit: params.limit,
// Only request total_count on first page (expensive for backend)
include_total_count: params.includeTotalCount === true,
};
if (params.startingAt) {
queryParams.starting_after = params.startingAt;
Expand All @@ -131,7 +137,9 @@ const ListBlueprintsUI = ({
// Fetch ONE page only
const page = (await client.blueprints.list(
queryParams,
)) as unknown as BlueprintsCursorIDPage<BlueprintListItem>;
)) as unknown as BlueprintsCursorIDPage<BlueprintListItem> & {
total_count?: number;
};

// Extract data and create defensive copies
if (page.blueprints && Array.isArray(page.blueprints)) {
Expand All @@ -148,7 +156,7 @@ const ListBlueprintsUI = ({
const result = {
items: pageBlueprints,
hasMore: page.has_more || false,
totalCount: pageBlueprints.length,
totalCount: page.total_count,
};

return result;
Expand Down Expand Up @@ -356,7 +364,11 @@ const ListBlueprintsUI = ({
// Calculate pagination info for display
const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));
const startIndex = currentPage * PAGE_SIZE;
const endIndex = startIndex + blueprints.length;
const endIndex = Math.min(startIndex + blueprints.length, totalCount);
const showingRange =
endIndex === startIndex + 1
? `${startIndex + 1}`
: `${startIndex + 1}-${endIndex}`;

const executeOperation = async (
blueprintOverride?: BlueprintListItem,
Expand Down Expand Up @@ -883,7 +895,7 @@ const ListBlueprintsUI = ({
data={blueprints}
keyExtractor={(blueprint: BlueprintListItem) => blueprint.id}
selectedIndex={selectedIndex}
title={`blueprints[${hasMore ? `${totalCount}+` : totalCount}]`}
title={`blueprints[${totalCount}]`}
columns={blueprintColumns}
emptyState={
<Text color={colors.textDim}>
Expand All @@ -897,7 +909,7 @@ const ListBlueprintsUI = ({
{!showPopup && (
<Box marginTop={1} paddingX={1}>
<Text color={colors.primary} bold>
{figures.hamburger} {hasMore ? `${totalCount}+` : totalCount}
{figures.hamburger} {totalCount}
</Text>
<Text color={colors.textDim} dimColor>
{" "}
Expand All @@ -915,8 +927,7 @@ const ListBlueprintsUI = ({
</Text>
) : (
<Text color={colors.textDim} dimColor>
Page {currentPage + 1} of{" "}
{hasMore ? `${totalPages}+` : totalPages}
Page {currentPage + 1} of {totalPages}
</Text>
)}
</>
Expand All @@ -926,8 +937,7 @@ const ListBlueprintsUI = ({
•{" "}
</Text>
<Text color={colors.textDim} dimColor>
Showing {startIndex + 1}-{endIndex} of{" "}
{hasMore ? `${totalCount}+` : totalCount}
Showing {showingRange} of {totalCount}
</Text>
{search.submittedSearchQuery && (
<>
Expand Down
28 changes: 18 additions & 10 deletions src/commands/devbox/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,19 @@ const ListDevboxesUI = ({

// Fetch function for pagination hook
const fetchPage = React.useCallback(
async (params: { limit: number; startingAt?: string }) => {
async (params: {
limit: number;
startingAt?: string;
includeTotalCount?: boolean;
}) => {
const client = getClient();
const pageDevboxes: Devbox[] = [];

// Build query params
const queryParams: Record<string, unknown> = {
limit: params.limit,
// Only request total_count on first page (expensive for backend)
include_total_count: params.includeTotalCount === true,
};
if (params.startingAt) {
queryParams.starting_after = params.startingAt;
Expand All @@ -99,7 +105,7 @@ const ListDevboxesUI = ({
// Fetch ONE page only
const page = (await client.devboxes.list(
queryParams,
)) as unknown as DevboxesCursorIDPage<Devbox>;
)) as unknown as DevboxesCursorIDPage<Devbox> & { total_count?: number };

// Extract data and create defensive copies using JSON serialization
if (page.devboxes && Array.isArray(page.devboxes)) {
Expand All @@ -111,7 +117,7 @@ const ListDevboxesUI = ({
const result = {
items: pageDevboxes,
hasMore: page.has_more || false,
totalCount: pageDevboxes.length,
totalCount: page.total_count,
};

return result;
Expand Down Expand Up @@ -419,7 +425,11 @@ const ListDevboxesUI = ({
// Calculate pagination info for display
const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));
const startIndex = currentPage * PAGE_SIZE;
const endIndex = startIndex + devboxes.length;
const endIndex = Math.min(startIndex + devboxes.length, totalCount);
const showingRange =
endIndex === startIndex + 1
? `${startIndex + 1}`
: `${startIndex + 1}-${endIndex}`;

// Filter operations based on devbox status
const hasTunnel = !!(
Expand Down Expand Up @@ -709,7 +719,7 @@ const ListDevboxesUI = ({
data={devboxes}
keyExtractor={(devbox: Devbox) => devbox.id}
selectedIndex={selectedIndex}
title="devboxes"
title={`devboxes[${totalCount}]`}
columns={tableColumns}
emptyState={
<Text color={colors.textDim}>
Expand All @@ -723,7 +733,7 @@ const ListDevboxesUI = ({
{!showPopup && (
<Box marginTop={1} paddingX={1}>
<Text color={colors.primary} bold>
{figures.hamburger} {hasMore ? `${totalCount}+` : totalCount}
{figures.hamburger} {totalCount}
</Text>
<Text color={colors.textDim} dimColor>
{" "}
Expand All @@ -741,8 +751,7 @@ const ListDevboxesUI = ({
</Text>
) : (
<Text color={colors.textDim} dimColor>
Page {currentPage + 1} of{" "}
{hasMore ? `${totalPages}+` : totalPages}
Page {currentPage + 1} of {totalPages}
</Text>
)}
</>
Expand All @@ -752,8 +761,7 @@ const ListDevboxesUI = ({
•{" "}
</Text>
<Text color={colors.textDim} dimColor>
Showing {startIndex + 1}-{endIndex} of{" "}
{hasMore ? `${totalCount}+` : totalCount}
Showing {showingRange} of {totalCount}
</Text>
{search.submittedSearchQuery && (
<>
Expand Down
30 changes: 20 additions & 10 deletions src/commands/gateway-config/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,19 @@ const ListGatewayConfigsUI = ({

// Fetch function for pagination hook
const fetchPage = React.useCallback(
async (params: { limit: number; startingAt?: string }) => {
async (params: {
limit: number;
startingAt?: string;
includeTotalCount?: boolean;
}) => {
const client = getClient();
const pageConfigs: GatewayConfigListItem[] = [];

// Build query params
const queryParams: Record<string, unknown> = {
limit: params.limit,
// Only request total_count on first page (expensive for backend)
include_total_count: params.includeTotalCount === true,
};
if (params.startingAt) {
queryParams.starting_after = params.startingAt;
Expand All @@ -140,7 +146,9 @@ const ListGatewayConfigsUI = ({
// Fetch ONE page only
const page = (await client.gatewayConfigs.list(
queryParams,
)) as unknown as GatewayConfigsCursorIDPage<GatewayConfigListItem>;
)) as unknown as GatewayConfigsCursorIDPage<GatewayConfigListItem> & {
total_count?: number;
};

// Extract data and create defensive copies
if (page.gateway_configs && Array.isArray(page.gateway_configs)) {
Expand All @@ -163,7 +171,7 @@ const ListGatewayConfigsUI = ({
const result = {
items: pageConfigs,
hasMore: page.has_more || false,
totalCount: pageConfigs.length,
totalCount: page.total_count,
};

return result;
Expand Down Expand Up @@ -304,7 +312,11 @@ const ListGatewayConfigsUI = ({
// Calculate pagination info for display
const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));
const startIndex = currentPage * PAGE_SIZE;
const endIndex = startIndex + configs.length;
const endIndex = Math.min(startIndex + configs.length, totalCount);
const showingRange =
endIndex === startIndex + 1
? `${startIndex + 1}`
: `${startIndex + 1}-${endIndex}`;

const executeOperation = async (
config: GatewayConfigListItem,
Expand Down Expand Up @@ -653,7 +665,7 @@ const ListGatewayConfigsUI = ({
data={configs}
keyExtractor={(config: GatewayConfigListItem) => config.id}
selectedIndex={selectedIndex}
title={`gateway_configs[${hasMore ? `${totalCount}+` : totalCount}]`}
title={`gateway_configs[${totalCount}]`}
columns={columns}
emptyState={
<Text color={colors.textDim}>
Expand All @@ -668,7 +680,7 @@ const ListGatewayConfigsUI = ({
{!showPopup && (
<Box marginTop={1} paddingX={1}>
<Text color={colors.primary} bold>
{figures.hamburger} {hasMore ? `${totalCount}+` : totalCount}
{figures.hamburger} {totalCount}
</Text>
<Text color={colors.textDim} dimColor>
{" "}
Expand All @@ -686,8 +698,7 @@ const ListGatewayConfigsUI = ({
</Text>
) : (
<Text color={colors.textDim} dimColor>
Page {currentPage + 1} of{" "}
{hasMore ? `${totalPages}+` : totalPages}
Page {currentPage + 1} of {totalPages}
</Text>
)}
</>
Expand All @@ -697,8 +708,7 @@ const ListGatewayConfigsUI = ({
•{" "}
</Text>
<Text color={colors.textDim} dimColor>
Showing {startIndex + 1}-{endIndex} of{" "}
{hasMore ? `${totalCount}+` : totalCount}
Showing {showingRange} of {totalCount}
</Text>
{search.submittedSearchQuery && (
<>
Expand Down
30 changes: 20 additions & 10 deletions src/commands/mcp-config/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,18 @@ const ListMcpConfigsUI = ({
const nameWidth = Math.min(80, Math.max(15, remainingWidth));

const fetchPage = React.useCallback(
async (params: { limit: number; startingAt?: string }) => {
async (params: {
limit: number;
startingAt?: string;
includeTotalCount?: boolean;
}) => {
const client = getClient();
const pageConfigs: McpConfigListItem[] = [];

const queryParams: Record<string, unknown> = {
limit: params.limit,
// Only request total_count on first page (expensive for backend)
include_total_count: params.includeTotalCount === true,
};
if (params.startingAt) {
queryParams.starting_after = params.startingAt;
Expand All @@ -119,7 +125,9 @@ const ListMcpConfigsUI = ({

const page = (await client.mcpConfigs.list(
queryParams,
)) as unknown as McpConfigsCursorIDPage<McpConfigListItem>;
)) as unknown as McpConfigsCursorIDPage<McpConfigListItem> & {
total_count?: number;
};

if (page.mcp_configs && Array.isArray(page.mcp_configs)) {
page.mcp_configs.forEach((m: McpConfigListItem) => {
Expand All @@ -139,7 +147,7 @@ const ListMcpConfigsUI = ({
return {
items: pageConfigs,
hasMore: page.has_more || false,
totalCount: pageConfigs.length,
totalCount: page.total_count,
};
},
[search.submittedSearchQuery],
Expand Down Expand Up @@ -266,7 +274,11 @@ const ListMcpConfigsUI = ({

const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));
const startIndex = currentPage * PAGE_SIZE;
const endIndex = startIndex + configs.length;
const endIndex = Math.min(startIndex + configs.length, totalCount);
const showingRange =
endIndex === startIndex + 1
? `${startIndex + 1}`
: `${startIndex + 1}-${endIndex}`;

const executeOperation = async (
config: McpConfigListItem,
Expand Down Expand Up @@ -580,7 +592,7 @@ const ListMcpConfigsUI = ({
data={configs}
keyExtractor={(config: McpConfigListItem) => config.id}
selectedIndex={selectedIndex}
title={`mcp_configs[${hasMore ? `${totalCount}+` : totalCount}]`}
title={`mcp_configs[${totalCount}]`}
columns={columns}
emptyState={
<Text color={colors.textDim}>
Expand All @@ -593,7 +605,7 @@ const ListMcpConfigsUI = ({
{!showPopup && (
<Box marginTop={1} paddingX={1}>
<Text color={colors.primary} bold>
{figures.hamburger} {hasMore ? `${totalCount}+` : totalCount}
{figures.hamburger} {totalCount}
</Text>
<Text color={colors.textDim} dimColor>
{" "}
Expand All @@ -611,8 +623,7 @@ const ListMcpConfigsUI = ({
</Text>
) : (
<Text color={colors.textDim} dimColor>
Page {currentPage + 1} of{" "}
{hasMore ? `${totalPages}+` : totalPages}
Page {currentPage + 1} of {totalPages}
</Text>
)}
</>
Expand All @@ -622,8 +633,7 @@ const ListMcpConfigsUI = ({
•{" "}
</Text>
<Text color={colors.textDim} dimColor>
Showing {startIndex + 1}-{endIndex} of{" "}
{hasMore ? `${totalCount}+` : totalCount}
Showing {showingRange} of {totalCount}
</Text>
{search.submittedSearchQuery && (
<>
Expand Down
Loading
Loading