-
Notifications
You must be signed in to change notification settings - Fork 150
feat(reminders): edit an existing reminder's description and time #5507
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
Open
evanhutnik
wants to merge
2
commits into
main
Choose a base branch
from
evan/reminders-edit-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
148 changes: 148 additions & 0 deletions
148
apps/web/src/features/next-soup/actions/make-edit-reminder-action.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,148 @@ | ||
| import type { EntityData, ReminderEntity } from '@entity'; | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| openReminderEditor: vi.fn(), | ||
| remindersEnabled: true, | ||
| })); | ||
|
|
||
| vi.mock('@app/features/reminders/reminder-composer', () => ({ | ||
| openReminderEditor: mocks.openReminderEditor, | ||
| })); | ||
|
|
||
| // Spread the original so the other flags in this module keep working; only the | ||
| // reminders gate is driven by the tests. Under vitest MODE is not | ||
| // 'development', so the real ENABLE_REMINDERS would resolve to false. | ||
| vi.mock('@core/constant/featureFlags', async (importOriginal) => ({ | ||
| ...(await importOriginal<typeof import('@core/constant/featureFlags')>()), | ||
| ENABLE_REMINDERS: () => mocks.remindersEnabled, | ||
| })); | ||
|
|
||
| import { makeEditReminderAction } from './make-edit-reminder-action'; | ||
|
|
||
| const NEXT_RUN = '2026-08-09T09:00:00.000Z'; | ||
|
|
||
| const reminder = (overrides: Partial<ReminderEntity> = {}) => | ||
| ({ | ||
| type: 'reminder', | ||
| id: 'rem-1', | ||
| name: 'Chase the contract', | ||
| description: 'Chase the contract', | ||
| ownerId: '', | ||
| scheduleType: 'once', | ||
| nextRunAt: NEXT_RUN, | ||
| enabled: true, | ||
| ...overrides, | ||
| }) as ReminderEntity; | ||
|
|
||
| const entity = (type: EntityData['type'], id = 'e1') => | ||
| ({ type, id, name: 'Thing' }) as EntityData; | ||
|
|
||
| describe('makeEditReminderAction', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| mocks.remindersEnabled = true; | ||
| }); | ||
|
|
||
| it('can run for a one-shot reminder', () => { | ||
| expect(makeEditReminderAction().canExecute(reminder())).toBe(true); | ||
| }); | ||
|
|
||
| it('cannot run for anything that is not a reminder', () => { | ||
| const { canExecute } = makeEditReminderAction(); | ||
|
|
||
| expect(canExecute(entity('document'))).toBe(false); | ||
| expect(canExecute(entity('email'))).toBe(false); | ||
| }); | ||
|
|
||
| // The composer only speaks one-shot schedules, so editing a recurring | ||
| // reminder through it would quietly turn a cron into a single firing. | ||
| it('cannot run for a recurring reminder', () => { | ||
| const recurring = reminder({ | ||
| scheduleType: 'recurring', | ||
| cron: '0 0 9 * * *', | ||
| timezone: 'UTC', | ||
| }); | ||
|
|
||
| expect(makeEditReminderAction().canExecute(recurring)).toBe(false); | ||
| }); | ||
|
|
||
| it('opens the editor with the reminder as the row knows it', () => { | ||
| makeEditReminderAction().execute([reminder()]); | ||
|
|
||
| expect(mocks.openReminderEditor).toHaveBeenCalledWith({ | ||
| id: 'rem-1', | ||
| description: 'Chase the contract', | ||
| remindAt: new Date(NEXT_RUN), | ||
| completed: false, | ||
| }); | ||
| }); | ||
|
|
||
| // A reschedule has to clear the done flag, so the editor needs to know the | ||
| // reminder was completed — see reminderEditPatch. | ||
| it('reports a completed reminder as completed', () => { | ||
| makeEditReminderAction().execute([ | ||
| reminder({ completedAt: '2026-08-08T10:00:00.000Z' }), | ||
| ]); | ||
|
|
||
| expect(mocks.openReminderEditor).toHaveBeenCalledWith( | ||
| expect.objectContaining({ completed: true }) | ||
| ); | ||
| }); | ||
|
|
||
| it('does nothing for an empty selection', () => { | ||
| makeEditReminderAction().execute([]); | ||
|
|
||
| expect(mocks.openReminderEditor).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| // The editor asks about one reminder's time, so a multi-select is not a | ||
| // batch — the menu only offers it for a single row. | ||
| it('uses only the first entity of a multi-selection', () => { | ||
| const first = reminder(); | ||
|
|
||
| makeEditReminderAction().execute([first, reminder({ id: 'rem-2' })]); | ||
|
|
||
| expect(mocks.openReminderEditor).toHaveBeenCalledOnce(); | ||
| expect(mocks.openReminderEditor).toHaveBeenCalledWith( | ||
| expect.objectContaining({ id: 'rem-1' }) | ||
| ); | ||
| }); | ||
|
|
||
| it('does not open the editor for a non-reminder', () => { | ||
| makeEditReminderAction().execute([entity('document')]); | ||
|
|
||
| expect(mocks.openReminderEditor).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('cannot run when the reminders flag is off', () => { | ||
| mocks.remindersEnabled = false; | ||
|
|
||
| expect(makeEditReminderAction().canExecute(reminder())).toBe(false); | ||
| }); | ||
|
|
||
| // execute re-checks the gate, so a command-menu entry left over from before | ||
| // the flag closed cannot still open the editor. | ||
| it('does not open the editor when the reminders flag is off', () => { | ||
| mocks.remindersEnabled = false; | ||
|
|
||
| makeEditReminderAction().execute([reminder()]); | ||
|
|
||
| expect(mocks.openReminderEditor).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| // The soup context menu and soup command menu both drive actions through | ||
| // executeWithSoup, so the action is unreachable from a list without it. | ||
| it('opens the editor when driven from a soup list', async () => { | ||
| await makeEditReminderAction().executeWithSoup( | ||
| [reminder()], | ||
| {} as Parameters< | ||
| ReturnType<typeof makeEditReminderAction>['executeWithSoup'] | ||
| >[1] | ||
| ); | ||
|
|
||
| expect(mocks.openReminderEditor).toHaveBeenCalledWith( | ||
| expect.objectContaining({ id: 'rem-1' }) | ||
| ); | ||
| }); | ||
| }); |
45 changes: 45 additions & 0 deletions
45
apps/web/src/features/next-soup/actions/make-edit-reminder-action.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,45 @@ | ||
| import { openReminderEditor } from '@app/features/reminders/reminder-composer'; | ||
| import { ENABLE_REMINDERS } from '@core/constant/featureFlags'; | ||
| import type { EntityData } from '@entity'; | ||
| import type { SoupState } from '../create-soup-state'; | ||
|
|
||
| /** | ||
| * Edit an existing reminder — its description, its time, or both. | ||
| * | ||
| * `execute` opens the composer prefilled rather than writing anything: both | ||
| * answers come from the user, so there is nothing to do until that modal | ||
| * resolves. Single-entity only, like creating one. | ||
| * | ||
| * Recurring reminders are excluded. The composer only speaks one-shot | ||
| * schedules, so editing one through it would quietly turn a cron into a single | ||
| * firing. Nothing in the product creates a recurring reminder today, so this | ||
| * excludes nothing a user can actually reach. | ||
| */ | ||
| export const makeEditReminderAction = () => { | ||
| const canExecute = (entity: EntityData): boolean => | ||
| ENABLE_REMINDERS() && | ||
| entity.type === 'reminder' && | ||
| entity.scheduleType === 'once'; | ||
|
|
||
| const execute = (entities: EntityData[]) => { | ||
| const [entity] = entities; | ||
| // Re-checked rather than assumed: a stale command-menu entry could | ||
| // otherwise still fire against a row that has since changed. | ||
| if (!entity || entity.type !== 'reminder' || !canExecute(entity)) return; | ||
|
|
||
| openReminderEditor({ | ||
| id: entity.id, | ||
| description: entity.description, | ||
| remindAt: new Date(entity.nextRunAt), | ||
| completed: entity.completedAt != null, | ||
| }); | ||
| }; | ||
|
|
||
| const executeWithSoup = async (entities: EntityData[], _soup: SoupState) => { | ||
| // Opening the composer doesn't change the list, so selection and focus are | ||
| // left where they are. | ||
| execute(entities); | ||
| }; | ||
|
|
||
| return { canExecute, execute, executeWithSoup }; | ||
| }; |
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
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.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: macro-inc/macro
Length of output: 2467
🏁 Script executed:
Repository: macro-inc/macro
Length of output: 309
🏁 Script executed:
Repository: macro-inc/macro
Length of output: 9523
🏁 Script executed:
Repository: macro-inc/macro
Length of output: 50371
🏁 Script executed:
Repository: macro-inc/macro
Length of output: 11592
Make Rename and Edit reminder mutually exclusive in the menu
makeRenameAction.canExecute()still returns true for reminder entities, so the Rename item can appear alongside Edit reminder and both useTOKENS.entity.action.rename. Addentity.type === 'reminder'to the rename eligibility or another exclusion that keeps reminder rows from showing the Rename action.🤖 Prompt for AI Agents