refactor(chat): remove weekly limit flow

This commit is contained in:
2026-07-01 13:12:14 +08:00
parent d1ccf3631e
commit f6e7adbe96
9 changed files with 33 additions and 89 deletions
@@ -143,43 +143,6 @@ describe("sendResponseToUiMessage", () => {
});
describe("applyHttpSendOutput", () => {
it("removes the optimistic user message when the weekly limit is reached", () => {
const context = makeChatState({
messages: [
{
content: "hello",
isFromAI: false,
date: "2026-06-25",
},
],
});
const nextState = applyHttpSendOutput(context, {
response: makeResponse({
reply: "",
messageId: "",
lockDetail: {
locked: true,
showContent: false,
showUpgrade: true,
reason: "weekly_limit",
hint: "Free message limit reached.",
detail: {
type: "weekly_msg_limit",
usedThisWeek: 3,
limit: 3,
},
},
}),
reply: null,
});
expect(nextState.messages).toEqual([]);
expect(nextState.isReplyingAI).toBe(false);
expect(nextState.upgradePromptVisible).toBe(true);
expect(nextState.upgradeReason).toBe("weekly_limit");
});
it("stores insufficient credit state and removes failed optimistic messages", () => {
const context = makeChatState({
messages: [
@@ -363,7 +326,7 @@ describe("countLockedHistoryMessages", () => {
isFromAI: true,
date: "2026-06-29",
locked: true,
lockReason: "weekly_limit",
lockReason: "insufficient_credits",
},
{
content: "user text",
@@ -767,7 +767,7 @@ describe("chatMachine transitions", () => {
actor.stop();
});
it("clears the weekly limit prompt after payment succeeds", async () => {
it("clears the insufficient credits prompt after payment succeeds", async () => {
const actor = createActor(createTestChatMachine()).start();
actor.send({ type: "ChatUserLogin", token: "token" });
@@ -789,12 +789,12 @@ describe("chatMachine transitions", () => {
locked: true,
showContent: false,
showUpgrade: true,
reason: "weekly_limit",
hint: "Free message limit reached.",
reason: "insufficient_credits",
hint: "Insufficient credits.",
detail: {
type: "weekly_msg_limit",
usedThisWeek: 3,
limit: 3,
requiredCredits: 2,
currentCredits: 0,
shortfallCredits: 2,
},
},
canSendMessage: false,
@@ -808,7 +808,9 @@ describe("chatMachine transitions", () => {
});
expect(actor.getSnapshot().context.upgradePromptVisible).toBe(true);
expect(actor.getSnapshot().context.upgradeReason).toBe("weekly_limit");
expect(actor.getSnapshot().context.upgradeReason).toBe(
"insufficient_credits",
);
expect(actor.getSnapshot().context.canSendMessage).toBe(false);
actor.send({ type: "ChatPaymentSucceeded" });