Add flag for showing cost tracking (#3090)

This commit is contained in:
Zane
2025-06-26 11:09:18 -07:00
committed by GitHub
parent 79553e0b8b
commit 2f19082661
4 changed files with 33 additions and 23 deletions

View File

@@ -10,6 +10,7 @@ import { useModelAndProvider } from '../ModelAndProviderContext';
import { Message } from '../../types/message';
import { ManualSummarizeButton } from '../context_management/ManualSummaryButton';
import { CostTracker } from './CostTracker';
import { COST_TRACKING_ENABLED } from '../../updates';
const TOKEN_LIMIT_DEFAULT = 128000; // fallback for custom models that the backend doesn't know about
const TOKEN_WARNING_THRESHOLD = 0.8; // warning shows at 80% of the token limit
@@ -223,12 +224,18 @@ export default function BottomMenu({
</div>
{/* Cost Tracker - no separator before it */}
<div className="flex items-center h-full ml-1">
<CostTracker inputTokens={inputTokens} outputTokens={outputTokens} sessionCosts={sessionCosts} />
</div>
{/* Separator between cost and model */}
<div className="w-[1px] h-4 bg-borderSubtle mx-1.5" />
{COST_TRACKING_ENABLED && (
<>
<div className="flex items-center h-full ml-1">
<CostTracker
inputTokens={inputTokens}
outputTokens={outputTokens}
sessionCosts={sessionCosts}
/>
</div>
<div className="w-[1px] h-4 bg-borderSubtle mx-1.5" />
</>
)}
{/* Model Selector Dropdown */}
<div className="flex items-center h-full">

View File

@@ -358,7 +358,7 @@ export default function MoreMenu({
subtitle="Browse your saved recipes"
icon={<FileText className="w-4 h-4" />}
>
Go to Recipe Library
Recipe Library
</MenuButton>
<MenuButton
onClick={() => {

View File

@@ -4,7 +4,7 @@ import { Button } from '../../ui/button';
import { Settings, RefreshCw, ExternalLink } from 'lucide-react';
import Modal from '../../Modal';
import UpdateSection from './UpdateSection';
import { UPDATES_ENABLED } from '../../../updates';
import { COST_TRACKING_ENABLED, UPDATES_ENABLED } from '../../../updates';
import { getApiUrl, getSecretKey } from '../../../config';
interface AppSettingsSectionProps {
@@ -274,24 +274,26 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
</div>
{/* Cost Tracking */}
<div className="flex items-center justify-between mb-4">
<div>
<h3 className="text-textStandard">Cost Tracking</h3>
<p className="text-xs text-textSubtle max-w-md mt-[2px]">
Show model pricing and usage costs
</p>
{COST_TRACKING_ENABLED && (
<div className="flex items-center justify-between mb-4">
<div>
<h3 className="text-textStandard">Cost Tracking</h3>
<p className="text-xs text-textSubtle max-w-md mt-[2px]">
Show model pricing and usage costs
</p>
</div>
<div className="flex items-center">
<Switch
checked={showPricing}
onCheckedChange={handleShowPricingToggle}
variant="mono"
/>
</div>
</div>
<div className="flex items-center">
<Switch
checked={showPricing}
onCheckedChange={handleShowPricingToggle}
variant="mono"
/>
</div>
</div>
)}
{/* Pricing Status - only show if cost tracking is enabled */}
{showPricing && (
{COST_TRACKING_ENABLED && showPricing && (
<>
<div className="flex items-center justify-between text-xs mb-2 px-4">
<span className="text-textSubtle">Pricing Source:</span>

View File

@@ -1 +1,2 @@
export const UPDATES_ENABLED = true;
export const COST_TRACKING_ENABLED = true;