Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Inbox: keep the message index under the size limit, and type the test cards

milind-sonic775e804ad86
diff --git a/server/message-db.ts b/server/message-db.ts
index 169058ee10..fac481690c 100644
--- a/server/message-db.ts
+++ b/server/message-db.ts
@@ -564,8 +564,7 @@ export function attentionRows(since: number): AttentionRow[] {
/** Every card still open, oldest first, whenever it was asked. */
export function openCardRows(): Array<{ threadId: string; id: string; at: number; card: string | null; fromBotId: string | null }> {
return db().prepare(
- "SELECT thread_id AS threadId, id, at, json_extract(json, '$.card') AS card, json_extract(json, '$.from.botId') AS fromBotId " +
- `FROM messages INDEXED BY messages_work_at WHERE ${WORK_KINDS} AND kind = 'options' ` +
+ `SELECT thread_id AS threadId, id, at, json_extract(json, '$.card') AS card, json_extract(json, '$.from.botId') AS fromBotId FROM messages INDEXED BY messages_work_at WHERE ${WORK_KINDS} AND kind = 'options' ` +
"AND json_extract(json, '$.card.requestId') IS NOT NULL AND json_extract(json, '$.card.answered') IS NULL AND coalesce(json_extract(json, '$.card.dismissed'), 0) = 0 " +
"AND coalesce(json_extract(json, '$.card.expired'), 0) = 0 AND json_extract(json, '$.helperIntro') IS NULL AND json_extract(json, '$.inbox') IS NULL ORDER BY at",
).all() as Array<{ threadId: string; id: string; at: number; card: string | null; fromBotId: string | null }>;
diff --git a/src/components/inbox/InboxReading.dom.test.ts b/src/components/inbox/InboxReading.dom.test.ts
index 27e2b7709a..9393bf4280 100644
--- a/src/components/inbox/InboxReading.dom.test.ts
+++ b/src/components/inbox/InboxReading.dom.test.ts
@@ -92,7 +92,7 @@ describe("the inbox's words", () => {
});
it("keys a password, a sign-in and an app to connect by what the line waits on the person for", () => {
- const secret: InboxRow = { ...news, kind: "ask", tab: "needs-you", secret: { target: "custom", label: "Stripe key", description: "", placeholder: "", helpUrl: "", requestKey: "k" } as InboxRow["secret"] };
+ const secret: InboxRow = { ...news, kind: "ask", tab: "needs-you", secret: { target: "custom", label: "Stripe key", description: "", placeholder: "", helpUrl: "", requestKey: "k" } as unknown as InboxRow["secret"] };
const signIn: InboxRow = { ...news, kind: "ask", tab: "needs-you", signIn: { url: "https://shop.test", site: "shop.test", place: "browser" } as InboxRow["signIn"] };
const connect: InboxRow = { ...news, kind: "ask", tab: "needs-you", connector: { label: "Gmail", description: "Read mail", resumeKey: "r1" } as InboxRow["connector"] };
expect(answerKindOf(secret)).toBe("password");
@@ -193,7 +193,7 @@ describe("a line read in full", () => {
it("answers a password, a sign-in and an app to connect with the chat's own card for each", async () => {
const base = { ...news, kind: "ask" as const, tab: "needs-you" as const };
const rows: InboxRow[] = [
- { ...base, id: "pw", secret: { target: "custom", label: "Stripe key", description: "For the billing report", placeholder: "sk_live_…", helpUrl: "", requestKey: "k", reason: "To read invoices" } as InboxRow["secret"] },
+ { ...base, id: "pw", secret: { target: "custom", label: "Stripe key", description: "For the billing report", placeholder: "sk_live_…", helpUrl: "", requestKey: "k", reason: "To read invoices" } as unknown as InboxRow["secret"] },
{ ...base, id: "si", signIn: { url: "https://shop.test", site: "shop.test", place: "browser", reason: "To see the order" } as InboxRow["signIn"] },
{ ...base, id: "co", connector: { label: "Gmail", description: "Read mail", resumeKey: "r1", status: "required" } as InboxRow["connector"] },
];