Skip to content

Commit 3efa513

Browse files
authored
fix: making usage limits for all users (#519)
* fix: making usage limits for all users * fix: remove unused imports * fix: hiding upgrade button if not FREE tier & messages adjusted
1 parent 7f0a9a6 commit 3efa513

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

refact-agent/gui/src/features/AgentUsage/AgentUsage.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ export const AgentUsage: React.FC = () => {
2727
return `You have reached your usage limit of ${maxAgentUsageAmount} messages a day.
2828
You can ${
2929
toolUse === "agent" ? "use agent" : "send messages"
30-
} again tomorrow, or upgrade to PRO.`;
30+
} again tomorrow${plan === "FREE" ? ", or upgrade to PRO." : "."}`;
3131
}
3232

3333
if (agentUsageAmount <= 5) {
34-
return `You have left only ${agentUsageAmount} messages left today. To remove
35-
the limit upgrade to PRO.`;
34+
return `You have left only ${agentUsageAmount} messages left today.${
35+
plan === "FREE" ? " To remove the limit upgrade to PRO." : ""
36+
}`;
3637
}
3738

3839
return `You have ${agentUsageAmount} ${
@@ -58,16 +59,18 @@ export const AgentUsage: React.FC = () => {
5859
>
5960
<ReloadIcon />
6061
</IconButton>
61-
<LinkButton
62-
size="2"
63-
variant="outline"
64-
href="https://refact.smallcloud.ai/pro"
65-
target="_blank"
66-
onClick={startPollingForUser}
67-
className={styles.upgrade_button}
68-
>
69-
Upgrade now
70-
</LinkButton>
62+
{plan === "FREE" && (
63+
<LinkButton
64+
size="2"
65+
variant="outline"
66+
href="https://refact.smallcloud.ai/pro"
67+
target="_blank"
68+
onClick={startPollingForUser}
69+
className={styles.upgrade_button}
70+
>
71+
Upgrade now
72+
</LinkButton>
73+
)}
7174
</Flex>
7275
</Flex>
7376
</Card>

refact-agent/gui/src/hooks/useCapsForToolUse.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { selectThreadToolUse } from "../features/Chat/Thread/selectors";
33
import {
44
useAppSelector,
55
useGetCapsQuery,
6-
useGetUser,
76
useAgentUsage,
87
useAppDispatch,
98
} from ".";
@@ -23,7 +22,6 @@ export function useCapsForToolUse() {
2322
const caps = useGetCapsQuery();
2423
const toolUse = useAppSelector(selectThreadToolUse);
2524
const usage = useAgentUsage();
26-
const user = useGetUser();
2725
const dispatch = useAppDispatch();
2826

2927
const defaultCap = caps.data?.code_chat_default_model ?? "";
@@ -65,7 +63,6 @@ export function useCapsForToolUse() {
6563
}, [caps.data?.code_chat_models, toolUse]);
6664

6765
const usableModelsForPlan = useMemo(() => {
68-
if (user.data?.inference !== "FREE") return usableModels;
6966
if (!usage.aboveUsageLimit && toolUse === "agent") return usableModels;
7067
return usableModels.map((model) => {
7168
if (!PAID_AGENT_LIST.includes(model)) return model;
@@ -77,7 +74,7 @@ export function useCapsForToolUse() {
7774
toolUse !== "agent" ? `${model} (Available in agent)` : undefined,
7875
};
7976
});
80-
}, [user.data?.inference, usableModels, usage.aboveUsageLimit, toolUse]);
77+
}, [usableModels, usage.aboveUsageLimit, toolUse]);
8178

8279
useEffect(() => {
8380
if (

0 commit comments

Comments
 (0)