Skip to content

Commit fd40e25

Browse files
committed
Fix hardcoded bumps
1 parent 45711af commit fd40e25

File tree

1 file changed

+9
-6
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components

1 file changed

+9
-6
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components/usage-limit-actions.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import { isHosted } from '@/lib/core/config/feature-flags'
88
import { useSubscriptionData, useUpdateUsageLimit } from '@/hooks/queries/subscription'
99
import { useCopilotStore } from '@/stores/panel/copilot/store'
1010

11-
/**
12-
* Component that displays actionable UI when a user hits their usage limit
13-
* Shows button options to increase limit or button to upgrade plan
14-
* After updating limit, retries the original user query
15-
*/
11+
const LIMIT_INCREMENTS = [0, 50, 100] as const
12+
13+
function roundUpToNearest50(value: number): number {
14+
return Math.ceil(value / 50) * 50
15+
}
16+
1617
export function UsageLimitActions() {
1718
const { data: subscriptionData } = useSubscriptionData()
1819
const updateUsageLimitMutation = useUpdateUsageLimit()
@@ -23,7 +24,9 @@ export function UsageLimitActions() {
2324
const [selectedAmount, setSelectedAmount] = useState<number | null>(null)
2425
const [isHidden, setIsHidden] = useState(false)
2526

26-
const limitOptions = [50, 100, 150]
27+
const currentLimit = subscription?.usage_limit ?? 0
28+
const baseLimit = roundUpToNearest50(currentLimit) || 50
29+
const limitOptions = LIMIT_INCREMENTS.map((increment) => baseLimit + increment)
2730

2831
const handleUpdateLimit = async (newLimit: number) => {
2932
setSelectedAmount(newLimit)

0 commit comments

Comments
 (0)