feat: improve assistant interactions

This commit is contained in:
ajnart committed 2026-08-04 13:21:39 +02:00
1 parent 1642a862d9
commit 8e557fb9fd
25 files changed
+1345 -244

No files matched your search

@@ -0,0 +1,18 @@
// @vitest-environment node
import { describe, expect, test } from "vitest";
import { getCalendarMonthRange } from "./calendar";
describe("getCalendarMonthRange", () => {
test("treats month 5 as May and includes the calendar overflow days", () => {
const { startDate, endDate } = getCalendarMonthRange(2025, 5);
expect(startDate.getFullYear()).toBe(2025);
expect(startDate.getMonth()).toBe(3);
expect(startDate.getDate()).toBe(25);
expect(endDate.getFullYear()).toBe(2025);
expect(endDate.getMonth()).toBe(5);
expect(endDate.getDate()).toBe(6);
});
});
+10 -7
View File
@@ -6,6 +6,14 @@ import type { CalendarEvent, RadarrReleaseType } from "@homarr/integrations/type
import { createIntegrationRequestHandler } from "./lib/integration-request-handler";
export const getCalendarMonthRange = (year: number, month: number) => {
const zeroBasedMonth = month - 1;
return {
startDate: dayjs().year(year).month(zeroBasedMonth).startOf("month").subtract(6, "days").toDate(),
endDate: dayjs().year(year).month(zeroBasedMonth).endOf("month").add(6, "days").toDate(),
};
};
export const calendarMonthRequestHandler = createIntegrationRequestHandler<
CalendarEvent[],
IntegrationKindByCategory<"calendar">,
@@ -14,13 +22,8 @@ export const calendarMonthRequestHandler = createIntegrationRequestHandler<
async requestAsync(integration, input) {
const integrationInstance = await createIntegrationAsync(integration);
// Calendar component shows up to 6 days before and after the month, for example if 1. of january is sunday, it shows the last 6 days of december.
const startDate = dayjs().year(input.year).month(input.month).startOf("month").subtract(6, "days");
const endDate = dayjs().year(input.year).month(input.month).endOf("month").add(6, "days");
const { startDate, endDate } = getCalendarMonthRange(input.year, input.month);
return await integrationInstance.getCalendarEventsAsync(
startDate.toDate(),
endDate.toDate(),
input.showUnmonitored,
);
return await integrationInstance.getCalendarEventsAsync(startDate, endDate, input.showUnmonitored);
},
});