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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const baseArgs: AgentSettingsCompactionPageViewProps = {
],
providerTypeByID: new Map<string, string>([["prov-openai", "openai"]]),
organizations: [MockDefaultOrganization],
compactionModelIDByOrganization: new Map<string, string>(),
modelsError: undefined,
isLoadingModels: false,
thresholds: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { SectionHeader } from "./components/SectionHeader";
import { UserCompactionThresholdSettings } from "./components/UserCompactionThresholdSettings";

export type AgentSettingsCompactionPageViewProps = {
models: readonly TypesGen.ChatModel[] | undefined;
models: readonly TypesGen.ChatModel[];
providerTypeByID: ReadonlyMap<string, string>;
organizations: readonly TypesGen.Organization[];
compactionModelIDByOrganization?: ReadonlyMap<string, string>;
compactionModelIDByOrganization: ReadonlyMap<string, string>;
modelsError: unknown;
isLoadingModels: boolean;
thresholds: readonly TypesGen.UserChatCompactionThreshold[] | undefined;
Expand Down Expand Up @@ -41,7 +41,7 @@ export const AgentSettingsCompactionPageView: React.FC<
description="Customize when conversations with models are automatically compacted."
/>
<UserCompactionThresholdSettings
models={models ?? []}
models={models}
providerTypeByID={providerTypeByID}
organizations={organizations}
compactionModelIDByOrganization={compactionModelIDByOrganization}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const baseArgs: AgentSettingsPersonalSkillsPageViewProps = {
onDelete: fn(),
onDownload: fn(),
onExportAll: fn(),
isExportingAll: false,
};

const meta = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export type AgentSettingsPersonalSkillsPageViewProps = {
onDownload: (skill: UserSkillMetadata) => void;
onExportAll: () => void;
downloadingSkillName?: string;
isExportingAll?: boolean;
isExportingAll: boolean;
editorState?: PersonalSkillEditorState;
deleteState?: PersonalSkillDeleteState;
};
Expand Down Expand Up @@ -227,7 +227,7 @@ export const AgentSettingsPersonalSkillsPageView: React.FC<
onDownload,
onExportAll,
downloadingSkillName,
isExportingAll = false,
isExportingAll,
editorState,
deleteState,
}) => {
Expand Down
26 changes: 12 additions & 14 deletions site/src/pages/AgentsPage/AgentSettingsUserAgentsPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { SectionHeader } from "./components/SectionHeader";
export type AgentSettingsUserAgentsPageViewProps = {
overridesData?: TypesGen.UserChatPersonalModelOverridesResponse;
overridesError: unknown;
onRetryOverrides?: () => void;
isRetryingOverrides?: boolean;
onRetryOverrides: () => void;
isRetryingOverrides: boolean;
isLoadingOverrides: boolean;
modelOptions: readonly ModelSelectorOption[];
models: readonly TypesGen.ChatModel[];
Expand Down Expand Up @@ -45,7 +45,7 @@ export const AgentSettingsUserAgentsPageView: React.FC<
overridesData,
overridesError,
onRetryOverrides,
isRetryingOverrides = false,
isRetryingOverrides,
isLoadingOverrides,
modelOptions,
models,
Expand Down Expand Up @@ -95,17 +95,15 @@ export const AgentSettingsUserAgentsPageView: React.FC<
{overridesError ? (
<div className="flex flex-col gap-2">
<ErrorAlert error={overridesError} />
{onRetryOverrides && (
<Button
disabled={isRetryingOverrides}
onClick={onRetryOverrides}
size="sm"
type="button"
variant="outline"
>
Retry
</Button>
)}
<Button
disabled={isRetryingOverrides}
onClick={onRetryOverrides}
size="sm"
type="button"
variant="outline"
>
Retry
</Button>
</div>
) : null}
{!personalOverridesEnabled && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const meta: Meta<typeof AgentSetupNotice> = {
component: AgentSetupNotice,
args: {
organization: MockDefaultOrganization,
unsupportedProviderNames: [],
},
};

Expand Down
4 changes: 2 additions & 2 deletions site/src/pages/AgentsPage/components/AgentSetupNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type AgentSetupNoticeProps = {
organization?: Organization;
// Names of configured providers the harness cannot use, populated by
// the page only when no supported provider is configured.
unsupportedProviderNames?: readonly string[];
unsupportedProviderNames: readonly string[];
aiGatewayDisabled?: boolean;
};

Expand All @@ -29,7 +29,7 @@ export const AgentSetupNotice: React.FC<AgentSetupNoticeProps> = ({
providerCount,
modelCount,
organization,
unsupportedProviderNames = [],
unsupportedProviderNames,
aiGatewayDisabled,
}) => {
const hasProvider = providerCount > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {

type CompactOrgSelectorProps = {
value: Organization | null;
onChange?: (organization: Organization) => void;
onChange: (organization: Organization) => void;
options: readonly Organization[];
disabled?: boolean;
className?: string;
Expand Down Expand Up @@ -98,7 +98,7 @@ export const CompactOrgSelector: React.FC<CompactOrgSelectorProps> = ({
key={org.id}
value={`${org.display_name} ${org.name}`}
onSelect={() => {
onChange?.(org);
onChange(org);
setOpen(false);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { isUnsetModelRef } from "../../../utils/modelOptions";
import { asString } from "../../ChatElements/runtimeTypeUtils";

export const getModelDisplayName = (
lastModelConfigID: Chat["last_model_config_id"] | undefined,
lastModelConfigID: Chat["last_model_config_id"],
modelConfigs: readonly ChatModel[],
isLoadingModelConfigs = false,
) => {
if (isUnsetModelRef(lastModelConfigID)) {
return "Default model";
}

const normalizedModelConfigID = asString(lastModelConfigID).trim();
const normalizedModelConfigID = lastModelConfigID.trim();
const modelConfig = modelConfigs.find(
(config) => config.id === normalizedModelConfigID,
);
Expand Down
13 changes: 8 additions & 5 deletions site/src/pages/AgentsPage/components/ChimeButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { userEvent, within } from "storybook/test";
import { fn } from "storybook/test";
import { ChimeButton } from "./ChimeButton";

const meta: Meta<typeof ChimeButton> = {
title: "pages/AgentsPage/ChimeButton",
component: ChimeButton,
args: {
enabled: false,
onToggle: fn(),
},
};
export default meta;
type Story = StoryObj<typeof ChimeButton>;

export const Default: Story = {};

export const ToggleState: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.click(canvas.getByRole("button"));
export const Enabled: Story = {
args: {
enabled: true,
},
};
28 changes: 6 additions & 22 deletions site/src/pages/AgentsPage/components/ChimeButton.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,41 @@
import { Volume2Icon, VolumeOffIcon } from "lucide-react";
import { useState } from "react";
import { Button } from "#/components/Button/Button";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "#/components/Tooltip/Tooltip";
import { getChimeEnabled, setChimeEnabled } from "../utils/chime";

type ChimeButtonProps = {
enabled?: boolean;
onToggle?: () => void;
enabled: boolean;
onToggle: () => void;
};

export const ChimeButton: React.FC<ChimeButtonProps> = ({
enabled,
onToggle,
}) => {
const [internalEnabled, setInternalEnabled] = useState(getChimeEnabled);
const isControlled = enabled !== undefined && onToggle !== undefined;
const isEnabled = isControlled ? enabled : internalEnabled;

const handleClick = () => {
if (isControlled) {
onToggle();
return;
}
const next = !internalEnabled;
setInternalEnabled(next);
setChimeEnabled(next);
};

return (
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="subtle"
size="icon"
onClick={handleClick}
onClick={onToggle}
aria-label={
isEnabled ? "Mute completion chime" : "Enable completion chime"
enabled ? "Mute completion chime" : "Enable completion chime"
}
className="size-7 text-content-secondary hover:text-content-primary"
>
{isEnabled ? (
{enabled ? (
<Volume2Icon className="text-content-success" />
) : (
<VolumeOffIcon className="text-content-secondary" />
)}
</Button>
</TooltipTrigger>
<TooltipContent>
{isEnabled ? "Disable completion sound" : "Enable completion sound"}
{enabled ? "Disable completion sound" : "Enable completion sound"}
</TooltipContent>
</Tooltip>
);
Expand Down
4 changes: 2 additions & 2 deletions site/src/pages/AgentsPage/components/UsageIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ const UsageTriggerProgress: React.FC<{
const UsageRingProgress: React.FC<{
ariaLabel: string;
percent: number;
severity?: UsageSeverity;
severity: UsageSeverity;
icon: React.ReactNode;
}> = ({ ariaLabel, percent, severity = "normal", icon }) => {
}> = ({ ariaLabel, percent, severity, icon }) => {
const clampedPercent = clampPercentage(percent);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const meta = {
["provider-anthropic", "anthropic"],
]),
organizations: [modelsOrganization],
compactionModelIDByOrganization: new Map<string, string>(),
isLoadingModels: false,
thresholds: [],
isThresholdsLoading: false,
thresholdsError: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ type UserCompactionThresholdSettingsProps = {
* Organization ID to the model config the organization routes compaction
* through. Missing entries mean the chat model summarizes itself.
*/
compactionModelIDByOrganization?: ReadonlyMap<string, string>;
compactionModelIDByOrganization: ReadonlyMap<string, string>;
modelsError?: unknown;
isLoadingModels?: boolean;
isLoadingModels: boolean;
thresholds: readonly TypesGen.UserChatCompactionThreshold[] | undefined;
isThresholdsLoading: boolean;
thresholdsError: unknown;
Expand All @@ -60,8 +60,6 @@ type UserCompactionThresholdSettingsProps = {
onResetThreshold: (modelId: string) => Promise<unknown>;
};

const noCompactionOverrides: ReadonlyMap<string, string> = new Map();

const ContextCompactionHeader: React.FC = () => (
<div className="flex flex-col gap-2">
<h3 className="m-0 text-sm font-semibold text-content-primary">
Expand Down Expand Up @@ -94,7 +92,7 @@ export const UserCompactionThresholdSettings: React.FC<
models,
providerTypeByID,
organizations,
compactionModelIDByOrganization = noCompactionOverrides,
compactionModelIDByOrganization,
modelsError,
isLoadingModels,
thresholds,
Expand Down Expand Up @@ -267,7 +265,7 @@ export const UserCompactionThresholdSettings: React.FC<
);
const shouldShowActions =
hasAnyDrafts || hasAnyErrors || hasAnyPending || dirtyRows.length > 0;
const isTableLoading = isThresholdsLoading || isLoadingModels === true;
const isTableLoading = isThresholdsLoading || isLoadingModels;
const showRows =
!isTableLoading && thresholdsError == null && enabledModels.length > 0;
// A failed load is the alert above the table. The in-table empty state is
Expand Down
Loading
Loading