-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix timezone issue #1147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix timezone issue #1147
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
apps/web/utils/ai/meeting-briefs/generate-briefing.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| import { describe, it, expect, vi } from "vitest"; | ||
| import type { MeetingBriefingData } from "@/utils/meeting-briefs/gather-context"; | ||
|
|
||
| vi.mock("server-only", () => ({})); | ||
| vi.mock("@/utils/llms/model", () => ({ getModel: vi.fn() })); | ||
| vi.mock("@/utils/llms", () => ({ createGenerateObject: vi.fn() })); | ||
| vi.mock("@/utils/stringify-email", () => ({ | ||
| stringifyEmailSimple: vi.fn( | ||
| (email) => | ||
| `From: ${email.from}\nSubject: ${email.subject}\nBody: ${email.content}`, | ||
| ), | ||
| })); | ||
| vi.mock("@/utils/get-email-from-message", () => ({ | ||
| getEmailForLLM: vi.fn((msg) => ({ | ||
| from: msg.headers?.from || "unknown", | ||
| subject: msg.headers?.subject || "no subject", | ||
| content: msg.textPlain || "no content", | ||
| })), | ||
| })); | ||
|
|
||
| vi.doUnmock("@/utils/date"); | ||
|
|
||
| import { buildPrompt } from "./generate-briefing"; | ||
|
|
||
| describe("buildPrompt timezone handling", () => { | ||
| it("formats past meeting times in the user's timezone (not UTC)", () => { | ||
| // This test documents the timezone bug fix: | ||
| // - Calendar API stores times in UTC | ||
| // - A 4 PM BRT meeting is stored as 7 PM UTC | ||
| // - The prompt should show 4 PM (user's local time), not 7 PM (UTC) | ||
|
|
||
| const meetingAt4pmBRT = new Date("2024-12-30T19:00:00Z"); // 7 PM UTC = 4 PM BRT | ||
|
|
||
| const briefingData: MeetingBriefingData = { | ||
| event: { | ||
| id: "upcoming", | ||
| title: "Strategy Review", | ||
| description: "Discuss Q1 roadmap", | ||
| startTime: new Date("2024-12-31T21:00:00Z"), | ||
| endTime: new Date("2024-12-31T22:00:00Z"), | ||
| attendees: [ | ||
| { email: "user@company.com" }, | ||
| { email: "client@acme.com", name: "John Smith" }, | ||
| ], | ||
| }, | ||
| externalGuests: [{ email: "client@acme.com", name: "John Smith" }], | ||
| emailThreads: [], | ||
| pastMeetings: [ | ||
| { | ||
| id: "past-1", | ||
| title: "Previous Call", | ||
| description: "Discussed partnership opportunities", | ||
| startTime: meetingAt4pmBRT, | ||
| endTime: new Date("2024-12-30T20:00:00Z"), | ||
| attendees: [{ email: "client@acme.com", name: "John Smith" }], | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const prompt = buildPrompt(briefingData, "America/Sao_Paulo"); | ||
|
|
||
| // The past meeting should show "4:00 PM" (Brazil time), NOT "7:00 PM" (UTC) | ||
| expect(prompt).toMatchInlineSnapshot(` | ||
| "Please prepare a concise briefing for this meeting. | ||
|
|
||
| <upcoming_meeting> | ||
| Title: Strategy Review | ||
| Description: Discuss Q1 roadmap | ||
| </upcoming_meeting> | ||
|
|
||
| <guest_context> | ||
| <guest> | ||
| Name: John Smith | ||
| Email: client@acme.com | ||
|
|
||
| <recent_meetings> | ||
| <meeting> | ||
| Title: Previous Call | ||
| Date: Dec 30, 2024 at 4:00 PM | ||
| Description: Discussed partnership opportunities | ||
| </meeting> | ||
|
|
||
| </recent_meetings> | ||
| </guest> | ||
|
|
||
| </guest_context> | ||
|
|
||
| Return the briefing as a JSON object with a "guests" array containing structured information for each guest." | ||
| `); | ||
| }); | ||
|
|
||
| it("shows no prior context for new contacts", () => { | ||
| const briefingData: MeetingBriefingData = { | ||
| event: { | ||
| id: "upcoming", | ||
| title: "Intro Meeting", | ||
| startTime: new Date("2024-12-31T21:00:00Z"), | ||
| endTime: new Date("2024-12-31T22:00:00Z"), | ||
| attendees: [ | ||
| { email: "user@company.com" }, | ||
| { email: "newcontact@other.com", name: "New Person" }, | ||
| ], | ||
| }, | ||
| externalGuests: [{ email: "newcontact@other.com", name: "New Person" }], | ||
| emailThreads: [], | ||
| pastMeetings: [], | ||
| }; | ||
|
|
||
| const prompt = buildPrompt(briefingData, "America/Sao_Paulo"); | ||
|
|
||
| expect(prompt).toMatchInlineSnapshot(` | ||
| "Please prepare a concise briefing for this meeting. | ||
|
|
||
| <upcoming_meeting> | ||
| Title: Intro Meeting | ||
|
|
||
| </upcoming_meeting> | ||
|
|
||
| <guest_context> | ||
| <guest> | ||
| Name: New Person | ||
| Email: newcontact@other.com | ||
|
|
||
| <no_prior_context>This appears to be a new contact with no prior email, meeting, or public profile history.</no_prior_context> | ||
| </guest> | ||
|
|
||
| </guest_context> | ||
|
|
||
| Return the briefing as a JSON object with a "guests" array containing structured information for each guest." | ||
| `); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Missing
onSuccessinuseCallbackdependency array. TheonSuccessprop is used inside theonSubmitcallback but is not listed in the dependency array[rules, executeItems, executeSchedule]. This will cause stale closure issues if the parent component provides a differentonSuccesscallback on re-render.Prompt for AI agents
✅ Addressed in
3ea9607There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 3ea9607 addressed this comment by adding
onSuccessto the useCallback dependency array. The dependency array was updated from[rules, executeItems, executeSchedule]to[rules, executeItems, executeSchedule, onSuccess], which resolves the stale closure issue that was identified.