refactor(site/src/pages): name the organization rule in compaction override copy
Renames the window constant to match chatd's compactionOverrideWindowPercent, describes the remaining 20% as target headroom, rewords the override alert and popovers so the organization override is the subject, and drops the organization trigger's enabled check since the database rejects non-positive windows.
This commit is contained in:
1 parent
6e8efb9054
commit
c6f8750479
5 files changed
+19
-23
No files matched your search
@@ -139,7 +139,7 @@ const CompactionOverrideAlert: React.FC<CompactionOverrideAlertProps> = ({
|
||||
return (
|
||||
<Alert severity="warning">
|
||||
<AlertDescription>
|
||||
{`Chats using ${formatModelList(undercutModels.map(getModelLabel))} may compact earlier than their models' thresholds${offModelsNote} because ${getModelLabel(compactionModel)} compacts at ${organizationTrigger.trigger.thresholdPercent}% of its ${compactionModel.context_limit.toLocaleString("en-US")}-token window. Personal thresholds that trigger compaction sooner still apply first.`}
|
||||
{`Chats using ${formatModelList(undercutModels.map(getModelLabel))} may compact earlier than their models' thresholds${offModelsNote} because the organization override compacts chats at ${organizationTrigger.trigger.thresholdPercent}% of ${getModelLabel(compactionModel)}'s ${compactionModel.context_limit.toLocaleString("en-US")}-token window. Personal thresholds that trigger compaction sooner still apply first.`}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
);
|
||||
|
||||
@@ -8,11 +8,11 @@ import {
|
||||
import {
|
||||
bindingCompactionTriggerPoint,
|
||||
bindingCompactionTriggerSource,
|
||||
compactionOverrideWindowPercent,
|
||||
compactionPointAsPercent,
|
||||
compactionThresholdLabel,
|
||||
isCompactionPointBeyondWindow,
|
||||
type OrganizationCompactionTrigger,
|
||||
organizationOverrideWindowPercent,
|
||||
type ResolvedCompactionThreshold,
|
||||
resolveChatCompactionThreshold,
|
||||
resolveCompactionTriggersByOrganization,
|
||||
@@ -62,7 +62,7 @@ describe("compaction triggers", () => {
|
||||
// Binding cases must match TestBindingCompactionTriggerSource in
|
||||
// coderd/x/chatd/generation_preparer_internal_test.go.
|
||||
const override = (contextLimit: number) => ({
|
||||
thresholdPercent: organizationOverrideWindowPercent,
|
||||
thresholdPercent: compactionOverrideWindowPercent,
|
||||
contextLimit,
|
||||
});
|
||||
it.each([
|
||||
|
||||
@@ -32,9 +32,9 @@ export type ResolvedCompactionThreshold =
|
||||
|
||||
export const compactionDisabledThresholdPercent = 100;
|
||||
|
||||
// Mirrors chatd compactionOverrideWindowPercent: the remainder of the override
|
||||
// window is left for the summary prompt and summary.
|
||||
export const organizationOverrideWindowPercent = 80;
|
||||
// Mirrors chatd compactionOverrideWindowPercent. The remaining 20% is target
|
||||
// headroom for the summary prompt and summary, not a guaranteed fit.
|
||||
export const compactionOverrideWindowPercent = 80;
|
||||
|
||||
export const modelCompactionTrigger = (
|
||||
model: TypesGen.ChatModel,
|
||||
@@ -110,13 +110,9 @@ export const resolveOrganizationCompactionTrigger = (
|
||||
}
|
||||
|
||||
const trigger = {
|
||||
thresholdPercent: organizationOverrideWindowPercent,
|
||||
thresholdPercent: compactionOverrideWindowPercent,
|
||||
contextLimit: model.context_limit,
|
||||
};
|
||||
if (!isCompactionTriggerEnabled(trigger)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return { model, trigger, pointTokens: compactionTriggerPoint(trigger) };
|
||||
};
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import {
|
||||
withDashboardProvider,
|
||||
} from "#/testHelpers/storybook";
|
||||
import {
|
||||
compactionOverrideWindowPercent,
|
||||
type OrganizationCompactionTrigger,
|
||||
organizationOverrideWindowPercent,
|
||||
} from "../compactionTriggers";
|
||||
import { UserCompactionThresholdSettings } from "./UserCompactionThresholdSettings";
|
||||
|
||||
@@ -36,10 +36,10 @@ const organizationTriggerFor = (
|
||||
): OrganizationCompactionTrigger => ({
|
||||
model,
|
||||
trigger: {
|
||||
thresholdPercent: organizationOverrideWindowPercent,
|
||||
thresholdPercent: compactionOverrideWindowPercent,
|
||||
contextLimit: model.context_limit,
|
||||
},
|
||||
pointTokens: (model.context_limit * organizationOverrideWindowPercent) / 100,
|
||||
pointTokens: (model.context_limit * compactionOverrideWindowPercent) / 100,
|
||||
});
|
||||
const mockCompactionTrigger = organizationTriggerFor(MockCompactionChatModel);
|
||||
const mockCompactionTriggersByOrganizationID = new Map([
|
||||
|
||||
@@ -202,11 +202,11 @@ const EffectiveCompactionThreshold: React.FC<
|
||||
<HelpPopoverText>
|
||||
{isOrganizationPointBeyondWindow ? (
|
||||
<>
|
||||
{organizationModelName} compacts at{" "}
|
||||
The organization override compacts chats at{" "}
|
||||
{organizationTrigger.pointTokens.toLocaleString("en-US")}{" "}
|
||||
tokens ({organizationTrigger.trigger.thresholdPercent}% of
|
||||
its {organizationWindowLabel}-token window), beyond this
|
||||
model's{" "}
|
||||
tokens ({organizationTrigger.trigger.thresholdPercent}% of{" "}
|
||||
{organizationModelName}'s {organizationWindowLabel}
|
||||
-token window), beyond this model's{" "}
|
||||
{modelConfig.context_limit.toLocaleString("en-US")}
|
||||
-token window. Chats with this model do not compact
|
||||
automatically. Set a threshold below 100% to turn compaction
|
||||
@@ -214,11 +214,11 @@ const EffectiveCompactionThreshold: React.FC<
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{organizationModelName} compacts at{" "}
|
||||
{organizationTrigger.trigger.thresholdPercent}% of its{" "}
|
||||
{organizationWindowLabel}-token window, about{" "}
|
||||
{organizationTriggerPercentLabel}% of this model's
|
||||
window.
|
||||
The organization override compacts chats at{" "}
|
||||
{organizationTrigger.trigger.thresholdPercent}% of{" "}
|
||||
{organizationModelName}'s {organizationWindowLabel}
|
||||
-token window, about {organizationTriggerPercentLabel}% of
|
||||
this model's window.
|
||||
</>
|
||||
)}
|
||||
</HelpPopoverText>
|
||||
|
||||
Reference in new issue
Block a user