@remit/web-client 0.0.313 → 0.0.314

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,14 @@ import type {
14
14
  RemitImapCalendarSuggestionResponse,
15
15
  } from "@remit/api-http-client/types.gen.ts";
16
16
  import { type IntelligenceData, IntelligencePanel } from "@remit/ui";
17
+ import {
18
+ type AnyRouter,
19
+ createMemoryHistory,
20
+ createRootRoute,
21
+ createRoute,
22
+ createRouter,
23
+ RouterProvider,
24
+ } from "@tanstack/react-router";
17
25
  import { createElement } from "react";
18
26
  import { createDomHarness, type DomHarness } from "@/test-support/dom";
19
27
  import { makeThreadMessage } from "@/test-support/fixtures";
@@ -261,3 +269,130 @@ describe("the invitation beside the open message", () => {
261
269
  assert.deepEqual(dismissed[0].body, { muteSender: true });
262
270
  });
263
271
  });
272
+
273
+ (globalThis as { self?: typeof globalThis }).self ??= globalThis;
274
+
275
+ const READING = "33333333-3333-4333-8333-333333333333";
276
+
277
+ const routedMount = async (
278
+ items: RemitImapCalendarSuggestionResponse[],
279
+ ): Promise<AnyRouter> => {
280
+ http = mockFetch((call: HttpCall): unknown => {
281
+ if (call.path.endsWith("/calendars")) return { items: calendars };
282
+ if (call.path.endsWith("/messages/msg-1/calendar-suggestions"))
283
+ return { items };
284
+ return { items: [] };
285
+ });
286
+ const rootRoute = createRootRoute({ component: Harness });
287
+ const routeTree = rootRoute.addChildren([
288
+ createRoute({
289
+ getParentRoute: () => rootRoute,
290
+ path: "/mail",
291
+ component: () => null,
292
+ }),
293
+ createRoute({
294
+ getParentRoute: () => rootRoute,
295
+ path: "/calendar/$view/$date/suggestion/$suggestionId",
296
+ component: () => null,
297
+ }),
298
+ ]);
299
+ const router = createRouter({
300
+ routeTree,
301
+ history: createMemoryHistory({ initialEntries: ["/mail"] }),
302
+ }) as unknown as AnyRouter;
303
+ await router.load();
304
+ harness = createDomHarness();
305
+ harness.renderApp(createElement(RouterProvider, { router }));
306
+ await harness.waitFor(
307
+ () => harness?.text().includes("Quarterly review") === true,
308
+ "the invitation to be drawn",
309
+ );
310
+ return router;
311
+ };
312
+
313
+ const answered = (): HttpCall[] =>
314
+ (http?.calls ?? []).filter((call) => call.method === "POST");
315
+
316
+ describe("changing a suggestion beside the message before adding it", () => {
317
+ it("opens the editor for a reading from the thread on the day it falls", async () => {
318
+ const router = await routedMount([
319
+ invitation("Pending"),
320
+ {
321
+ ...invitation("Pending"),
322
+ suggestionId: READING,
323
+ source: "TextHeuristic",
324
+ summary: "Lunch with Sam",
325
+ },
326
+ ]);
327
+ await harness?.waitFor(
328
+ () => harness?.text().includes("Lunch with Sam") === true,
329
+ "the reading to be drawn",
330
+ );
331
+
332
+ press("Change first");
333
+ await harness?.waitFor(
334
+ () => router.state.location.pathname.includes(READING),
335
+ "the editor to be opened",
336
+ );
337
+
338
+ assert.equal(
339
+ router.state.location.pathname,
340
+ `/calendar/day/2026-09-01/suggestion/${READING}`,
341
+ );
342
+ assert.deepEqual(answered(), []);
343
+ });
344
+
345
+ it("sends an invitation nobody could put on a clock to the editor instead of adding it", async () => {
346
+ const router = await routedMount([
347
+ { ...invitation("Pending"), zoneCertainty: "Ambiguous" },
348
+ ]);
349
+
350
+ press("Add to calendar");
351
+ await harness?.waitFor(
352
+ () => router.state.location.pathname.includes(SUGGESTION),
353
+ "the editor to be opened",
354
+ );
355
+
356
+ assert.equal(
357
+ router.state.location.pathname,
358
+ `/calendar/day/2026-09-01/suggestion/${SUGGESTION}`,
359
+ );
360
+ assert.deepEqual(answered(), []);
361
+ });
362
+
363
+ it("applies a cancellation read out of the thread, and offers no editor for it", async () => {
364
+ const router = await routedMount([
365
+ invitation("Accepted"),
366
+ {
367
+ ...invitation("Pending"),
368
+ suggestionId: READING,
369
+ source: "TextHeuristic",
370
+ method: "Cancel",
371
+ zoneCertainty: "Ambiguous",
372
+ summary: "Lunch with Sam",
373
+ },
374
+ ]);
375
+ await harness?.waitFor(
376
+ () => harness?.text().includes("Lunch with Sam") === true,
377
+ "the reading to be drawn",
378
+ );
379
+ const card = harness?.query('article[aria-label="Lunch with Sam"]');
380
+ if (!card) throw new Error("the reading's card is not drawn");
381
+ const buttons = [...card.querySelectorAll("button")];
382
+ assert.equal(
383
+ buttons.some((button) => button.textContent?.includes("Change first")),
384
+ false,
385
+ );
386
+ const add = buttons.find((button) =>
387
+ button.textContent?.includes("Add to calendar"),
388
+ );
389
+ if (!add) throw new Error("the reading offers no Add");
390
+ harness?.click(add);
391
+
392
+ await harness?.waitFor(
393
+ () => answered().some((call) => call.path.endsWith(`/${READING}/accept`)),
394
+ "the cancellation to be applied",
395
+ );
396
+ assert.equal(router.state.location.pathname, "/mail");
397
+ });
398
+ });
@@ -50,7 +50,10 @@ import {
50
50
  toCalendarInvite,
51
51
  toEventSuggestion,
52
52
  } from "@/lib/calendar-suggestion";
53
- import { useOpenEventOnCalendar } from "@/routing";
53
+ import {
54
+ useChangeSuggestionOnCalendar,
55
+ useOpenEventOnCalendar,
56
+ } from "@/routing";
54
57
 
55
58
  /** What the reader is in the middle of, for one message and no other. */
56
59
  interface Working {
@@ -107,6 +110,7 @@ export function useIntelligenceCalendar(
107
110
  const answers = useCalendarSuggestionAnswers();
108
111
 
109
112
  const openEvent = useOpenEventOnCalendar();
113
+ const changeOnCalendar = useChangeSuggestionOnCalendar();
110
114
 
111
115
  const [held, setHeld] = useState<Working>(() => fresh(messageId));
112
116
  const working = held.messageId === messageId ? held : fresh(messageId);
@@ -238,14 +242,34 @@ export function useIntelligenceCalendar(
238
242
  : "Couldn't read the invitations in this message. Reopen it to try again.";
239
243
 
240
244
  const cancellation = invitation?.method === "Cancel";
245
+ const changeFirst = (suggestionId: string) => {
246
+ const suggestion = suggestions.find(
247
+ (candidate) => candidate.suggestionId === suggestionId,
248
+ );
249
+ if (suggestion) changeOnCalendar(suggestionDate(suggestion), suggestionId);
250
+ };
251
+ const unplaced = (suggestionId: string): boolean => {
252
+ const suggestion = suggestions.find(
253
+ (candidate) => candidate.suggestionId === suggestionId,
254
+ );
255
+ return (
256
+ suggestion?.zoneCertainty === "Ambiguous" &&
257
+ suggestion.method !== "Cancel"
258
+ );
259
+ };
241
260
  const pickedText =
242
261
  date === "" ? "" : slotsAsText(date, slots, working.picked);
243
262
 
244
263
  const actions: IntelligenceCalendarActions = {
245
- onAddInvite: () =>
264
+ onAddInvite: () => {
265
+ if (unplaced(invitationId)) {
266
+ changeFirst(invitationId);
267
+ return;
268
+ }
246
269
  answer(invitationId, "add this to your calendar", () =>
247
270
  answers.accept(invitationId, defaultCalendarId),
248
- ),
271
+ );
272
+ },
249
273
  onTentativeInvite: cancellation
250
274
  ? undefined
251
275
  : () =>
@@ -281,10 +305,17 @@ export function useIntelligenceCalendar(
281
305
  ? () =>
282
306
  replyWithText({ threadId: thread.threadId, messageId }, pickedText)
283
307
  : undefined,
284
- onAddSuggestion: (suggestionId) =>
308
+ onAddSuggestion: (suggestionId) => {
309
+ if (unplaced(suggestionId)) {
310
+ changeFirst(suggestionId);
311
+ return;
312
+ }
285
313
  answer(suggestionId, "add this to your calendar", () =>
286
314
  answers.accept(suggestionId, defaultCalendarId),
287
- ),
315
+ );
316
+ },
317
+ onReviewSuggestion:
318
+ readings[0]?.method === "Cancel" ? undefined : changeFirst,
288
319
  onDismissSuggestion: (suggestionId) =>
289
320
  answer(suggestionId, "dismiss this", () =>
290
321
  answers.dismiss(suggestionId, false),
@@ -113,10 +113,19 @@ describe("toEventSuggestion", () => {
113
113
  suggestion({ zoneCertainty: "Ambiguous", source: "TextHeuristic" }),
114
114
  { ...context, sender: "Organizer" },
115
115
  );
116
- assert.match(reading.ambiguity, /hours out/);
116
+ assert.match(reading.ambiguity, /Add opens the editor/);
117
117
  assert.equal(reading.zoneCertainty, "ambiguous");
118
118
  assert.ok(reading.confidence < 1);
119
119
  });
120
+
121
+ it("promises no editor for a cancellation, which Add applies as it is", () => {
122
+ const reading = toEventSuggestion(
123
+ suggestion({ zoneCertainty: "Ambiguous", method: "Cancel" }),
124
+ { ...context, sender: "Organizer" },
125
+ );
126
+ assert.match(reading.ambiguity, /could not be resolved/);
127
+ assert.doesNotMatch(reading.ambiguity, /editor/);
128
+ });
120
129
  });
121
130
 
122
131
  describe("clashesOver", () => {
@@ -47,7 +47,10 @@ const ZONES: Record<CalendarSuggestion["zoneCertainty"], ZoneCertainty> = {
47
47
  };
48
48
 
49
49
  const AMBIGUOUS_ZONE =
50
- "The invitation named a time zone nothing could resolve, so this time may be hours out.";
50
+ "The invitation's time zone could not be resolved. Add opens the editor so you can set the time.";
51
+
52
+ const AMBIGUOUS_CANCELLATION =
53
+ "The invitation's time zone could not be resolved.";
51
54
 
52
55
  /** Where the card stands, or nothing when there is no card left to draw. */
53
56
  export interface InviteStanding {
@@ -163,6 +166,13 @@ export function toCalendarInvite(
163
166
  };
164
167
  }
165
168
 
169
+ function ambiguityOf(suggestion: CalendarSuggestion): string {
170
+ if (suggestion.zoneCertainty !== "Ambiguous") return "";
171
+ return suggestion.method === "Cancel"
172
+ ? AMBIGUOUS_CANCELLATION
173
+ : AMBIGUOUS_ZONE;
174
+ }
175
+
166
176
  export function toEventSuggestion(
167
177
  suggestion: CalendarSuggestion,
168
178
  context: Omit<InviteContext, "senderName"> & { sender: string },
@@ -179,7 +189,7 @@ export function toEventSuggestion(
179
189
  sender: context.sender,
180
190
  senderAddress: suggestion.organizer,
181
191
  confidence: isFromInvitation(suggestion) ? 1 : 0.6,
182
- ambiguity: suggestion.zoneCertainty === "Ambiguous" ? AMBIGUOUS_ZONE : "",
192
+ ambiguity: ambiguityOf(suggestion),
183
193
  suggestedCalendarId: context.calendarId,
184
194
  timeZone: "",
185
195
  zoneCertainty: ZONES[suggestion.zoneCertainty],
@@ -55,6 +55,7 @@ import { Route as MailOutboxComposeChar123OutboxMessageIdChar125RouteImport } fr
55
55
  import { Route as MailOutboxDraftOutboxMessageIdRouteImport } from './routes/mail/outbox/draft/$outboxMessageId'
56
56
  import { Route as CalendarViewDateCalendarObjectIdIndexRouteImport } from './routes/calendar/$view.$date/$calendarObjectId/index'
57
57
  import { Route as CalendarViewDateCalendarObjectIdRecurrenceIdRouteImport } from './routes/calendar/$view.$date/$calendarObjectId/$recurrenceId'
58
+ import { Route as CalendarViewDateSuggestionSuggestionIdRouteImport } from './routes/calendar/$view.$date/suggestion.$suggestionId'
58
59
  import { Route as MailMailboxIdThreadIdMessageIdModeChar123OutboxMessageIdChar125RouteImport } from './routes/mail/$mailboxId/$threadId/$messageId/$mode.{-$outboxMessageId}'
59
60
  import { Route as MailBriefThreadIdMessageIdModeChar123OutboxMessageIdChar125RouteImport } from './routes/mail/brief/$threadId/$messageId/$mode.{-$outboxMessageId}'
60
61
  import { Route as MailFlaggedThreadIdMessageIdModeChar123OutboxMessageIdChar125RouteImport } from './routes/mail/flagged/$threadId/$messageId/$mode.{-$outboxMessageId}'
@@ -302,6 +303,12 @@ const CalendarViewDateCalendarObjectIdRecurrenceIdRoute =
302
303
  path: '/$recurrenceId',
303
304
  getParentRoute: () => CalendarViewDateCalendarObjectIdRoute,
304
305
  } as any)
306
+ const CalendarViewDateSuggestionSuggestionIdRoute =
307
+ CalendarViewDateSuggestionSuggestionIdRouteImport.update({
308
+ id: '/suggestion/$suggestionId',
309
+ path: '/suggestion/$suggestionId',
310
+ getParentRoute: () => CalendarViewDateRoute,
311
+ } as any)
305
312
  const MailMailboxIdThreadIdMessageIdModeChar123OutboxMessageIdChar125Route =
306
313
  MailMailboxIdThreadIdMessageIdModeChar123OutboxMessageIdChar125RouteImport.update(
307
314
  {
@@ -373,6 +380,7 @@ export interface FileRoutesByFullPath {
373
380
  '/mail/brief/$threadId/': typeof MailBriefThreadIdIndexRoute
374
381
  '/mail/flagged/$threadId/': typeof MailFlaggedThreadIdIndexRoute
375
382
  '/calendar/$view/$date/$calendarObjectId/$recurrenceId': typeof CalendarViewDateCalendarObjectIdRecurrenceIdRoute
383
+ '/calendar/$view/$date/suggestion/$suggestionId': typeof CalendarViewDateSuggestionSuggestionIdRoute
376
384
  '/calendar/$view/$date/$calendarObjectId/': typeof CalendarViewDateCalendarObjectIdIndexRoute
377
385
  '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}': typeof MailMailboxIdThreadIdMessageIdModeChar123OutboxMessageIdChar125Route
378
386
  '/mail/brief/$threadId/$messageId/$mode/{-$outboxMessageId}': typeof MailBriefThreadIdMessageIdModeChar123OutboxMessageIdChar125Route
@@ -412,6 +420,7 @@ export interface FileRoutesByTo {
412
420
  '/mail/brief/$threadId': typeof MailBriefThreadIdIndexRoute
413
421
  '/mail/flagged/$threadId': typeof MailFlaggedThreadIdIndexRoute
414
422
  '/calendar/$view/$date/$calendarObjectId/$recurrenceId': typeof CalendarViewDateCalendarObjectIdRecurrenceIdRoute
423
+ '/calendar/$view/$date/suggestion/$suggestionId': typeof CalendarViewDateSuggestionSuggestionIdRoute
415
424
  '/calendar/$view/$date/$calendarObjectId': typeof CalendarViewDateCalendarObjectIdIndexRoute
416
425
  '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}': typeof MailMailboxIdThreadIdMessageIdModeChar123OutboxMessageIdChar125Route
417
426
  '/mail/brief/$threadId/$messageId/$mode/{-$outboxMessageId}': typeof MailBriefThreadIdMessageIdModeChar123OutboxMessageIdChar125Route
@@ -464,6 +473,7 @@ export interface FileRoutesById {
464
473
  '/mail/brief/$threadId/': typeof MailBriefThreadIdIndexRoute
465
474
  '/mail/flagged/$threadId/': typeof MailFlaggedThreadIdIndexRoute
466
475
  '/calendar/$view/$date/$calendarObjectId/$recurrenceId': typeof CalendarViewDateCalendarObjectIdRecurrenceIdRoute
476
+ '/calendar/$view/$date/suggestion/$suggestionId': typeof CalendarViewDateSuggestionSuggestionIdRoute
467
477
  '/calendar/$view/$date/$calendarObjectId/': typeof CalendarViewDateCalendarObjectIdIndexRoute
468
478
  '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}': typeof MailMailboxIdThreadIdMessageIdModeChar123OutboxMessageIdChar125Route
469
479
  '/mail/brief/$threadId/$messageId/$mode/{-$outboxMessageId}': typeof MailBriefThreadIdMessageIdModeChar123OutboxMessageIdChar125Route
@@ -517,6 +527,7 @@ export interface FileRouteTypes {
517
527
  | '/mail/brief/$threadId/'
518
528
  | '/mail/flagged/$threadId/'
519
529
  | '/calendar/$view/$date/$calendarObjectId/$recurrenceId'
530
+ | '/calendar/$view/$date/suggestion/$suggestionId'
520
531
  | '/calendar/$view/$date/$calendarObjectId/'
521
532
  | '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}'
522
533
  | '/mail/brief/$threadId/$messageId/$mode/{-$outboxMessageId}'
@@ -556,6 +567,7 @@ export interface FileRouteTypes {
556
567
  | '/mail/brief/$threadId'
557
568
  | '/mail/flagged/$threadId'
558
569
  | '/calendar/$view/$date/$calendarObjectId/$recurrenceId'
570
+ | '/calendar/$view/$date/suggestion/$suggestionId'
559
571
  | '/calendar/$view/$date/$calendarObjectId'
560
572
  | '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}'
561
573
  | '/mail/brief/$threadId/$messageId/$mode/{-$outboxMessageId}'
@@ -607,6 +619,7 @@ export interface FileRouteTypes {
607
619
  | '/mail/brief/$threadId/'
608
620
  | '/mail/flagged/$threadId/'
609
621
  | '/calendar/$view/$date/$calendarObjectId/$recurrenceId'
622
+ | '/calendar/$view/$date/suggestion/$suggestionId'
610
623
  | '/calendar/$view/$date/$calendarObjectId/'
611
624
  | '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}'
612
625
  | '/mail/brief/$threadId/$messageId/$mode/{-$outboxMessageId}'
@@ -946,6 +959,13 @@ declare module '@tanstack/react-router' {
946
959
  preLoaderRoute: typeof CalendarViewDateCalendarObjectIdRecurrenceIdRouteImport
947
960
  parentRoute: typeof CalendarViewDateCalendarObjectIdRoute
948
961
  }
962
+ '/calendar/$view/$date/suggestion/$suggestionId': {
963
+ id: '/calendar/$view/$date/suggestion/$suggestionId'
964
+ path: '/suggestion/$suggestionId'
965
+ fullPath: '/calendar/$view/$date/suggestion/$suggestionId'
966
+ preLoaderRoute: typeof CalendarViewDateSuggestionSuggestionIdRouteImport
967
+ parentRoute: typeof CalendarViewDateRoute
968
+ }
949
969
  '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}': {
950
970
  id: '/mail/$mailboxId/$threadId/$messageId/$mode/{-$outboxMessageId}'
951
971
  path: '/$mode/{-$outboxMessageId}'
@@ -992,6 +1012,7 @@ interface CalendarViewDateRouteChildren {
992
1012
  CalendarViewDateCalendarObjectIdRoute: typeof CalendarViewDateCalendarObjectIdRouteWithChildren
993
1013
  CalendarViewDateNewRoute: typeof CalendarViewDateNewRoute
994
1014
  CalendarViewDateIndexRoute: typeof CalendarViewDateIndexRoute
1015
+ CalendarViewDateSuggestionSuggestionIdRoute: typeof CalendarViewDateSuggestionSuggestionIdRoute
995
1016
  }
996
1017
 
997
1018
  const CalendarViewDateRouteChildren: CalendarViewDateRouteChildren = {
@@ -999,6 +1020,8 @@ const CalendarViewDateRouteChildren: CalendarViewDateRouteChildren = {
999
1020
  CalendarViewDateCalendarObjectIdRouteWithChildren,
1000
1021
  CalendarViewDateNewRoute: CalendarViewDateNewRoute,
1001
1022
  CalendarViewDateIndexRoute: CalendarViewDateIndexRoute,
1023
+ CalendarViewDateSuggestionSuggestionIdRoute:
1024
+ CalendarViewDateSuggestionSuggestionIdRoute,
1002
1025
  }
1003
1026
 
1004
1027
  const CalendarViewDateRouteWithChildren =
@@ -0,0 +1,22 @@
1
+ // biome-ignore lint/style/useFilenamingConvention: TanStack Router convention
2
+ import { createFileRoute } from "@tanstack/react-router";
3
+ import { ChangeCalendarSuggestion } from "@/components/calendar/ChangeCalendarSuggestion";
4
+ import { useCalendarNavigation, useChangingSuggestionId } from "@/routing";
5
+
6
+ function ChangeSuggestionRoute() {
7
+ const suggestionId = useChangingSuggestionId();
8
+ const { closeEvent } = useCalendarNavigation();
9
+ if (suggestionId === undefined) return null;
10
+ return (
11
+ <ChangeCalendarSuggestion
12
+ suggestionId={suggestionId}
13
+ onClose={closeEvent}
14
+ />
15
+ );
16
+ }
17
+
18
+ export const Route = createFileRoute(
19
+ "/calendar/$view/$date/suggestion/$suggestionId",
20
+ )({
21
+ component: ChangeSuggestionRoute,
22
+ });
@@ -86,8 +86,14 @@ function CalendarView({ isPhone }: { isPhone: boolean }) {
86
86
  const drawsGrid = !calendarViewMountsAgenda(view);
87
87
  const { events, colorByCalendarId, isLoading, error, retry, instanceOf } =
88
88
  useCalendarData({ view, date, calendarIds, enabled: drawsGrid });
89
- const { goToView, goToToday, step, openEvent, openComposer } =
90
- useCalendarNavigation();
89
+ const {
90
+ goToView,
91
+ goToToday,
92
+ step,
93
+ openEvent,
94
+ openComposer,
95
+ changeSuggestionFirst,
96
+ } = useCalendarNavigation();
91
97
  const openedEvent = useOpenCalendarEvent();
92
98
  const isWriting = useIsWritingEvent();
93
99
  // Held in state rather than read back from storage each render: how much of
@@ -123,7 +129,7 @@ function CalendarView({ isPhone }: { isPhone: boolean }) {
123
129
  events={events}
124
130
  colorByCalendarId={colorByCalendarId}
125
131
  agenda={<AgendaView density={density} onPickSlot={pickSlot} />}
126
- waiting={<PendingSuggestions />}
132
+ waiting={<PendingSuggestions onChangeFirst={changeSuggestionFirst} />}
127
133
  isLoading={isLoading}
128
134
  error={error}
129
135
  onRetry={retry}
@@ -31,6 +31,7 @@ import { Route as EventIndexRoute } from "./$view.$date/$calendarObjectId/index.
31
31
  import { Route as EventRoute } from "./$view.$date/$calendarObjectId.js";
32
32
  import { Route as ReadingPaneRoute } from "./$view.$date/index.js";
33
33
  import { Route as ComposeRoute } from "./$view.$date/new.js";
34
+ import { Route as SuggestionRoute } from "./$view.$date/suggestion.$suggestionId.js";
34
35
  import { Route as ViewRoute } from "./$view.$date.js";
35
36
  import { Route as CalendarIndexRoute } from "./index.js";
36
37
 
@@ -68,6 +69,10 @@ eventRoute.addChildren([
68
69
  viewRoute.addChildren([
69
70
  attach(ReadingPaneRoute, { path: "/", getParentRoute: () => viewRoute }),
70
71
  attach(ComposeRoute, { path: "new", getParentRoute: () => viewRoute }),
72
+ attach(SuggestionRoute, {
73
+ path: "suggestion/$suggestionId",
74
+ getParentRoute: () => viewRoute,
75
+ }),
71
76
  eventRoute,
72
77
  ]);
73
78
  const routeTree = rootRoute.addChildren([
@@ -253,6 +258,19 @@ describe("the composer and the open event cannot both be addressed", () => {
253
258
  assert.equal(mounted.routeIds.includes("/calendar/$view/$date/new"), false);
254
259
  });
255
260
 
261
+ it("mounts the editor for a suggestion, and nothing of the event route", () => {
262
+ const mounted = match("/calendar/day/2026-06-11/suggestion/sug_1");
263
+ assert.equal(
264
+ mounted.routeIds.at(-1),
265
+ "/calendar/$view/$date/suggestion/$suggestionId",
266
+ );
267
+ assert.equal(mounted.params.suggestionId, "sug_1");
268
+ assert.equal(
269
+ mounted.routeIds.some((id) => id.includes("$calendarObjectId")),
270
+ false,
271
+ );
272
+ });
273
+
256
274
  it("keeps the series matched under one of its occurrences", () => {
257
275
  const mounted = match(
258
276
  "/calendar/week/2026-06-10/evt_1/2026-06-11T09%3A15%3A00%2B02%3A00",
@@ -9,6 +9,8 @@ import {
9
9
  import { useRetainOpenPanels } from "./fragment";
10
10
 
11
11
  const VIEW_ROUTE = "/calendar/$view/$date" as const;
12
+ const SUGGESTION_ROUTE =
13
+ "/calendar/$view/$date/suggestion/$suggestionId" as const;
12
14
 
13
15
  /** Which zoom the calendar is at, on which day, over which calendars. */
14
16
  export interface CalendarAddress {
@@ -67,12 +69,21 @@ export function useOpenCalendarEvent(): OpenCalendarEvent | undefined {
67
69
  }
68
70
 
69
71
  /** Whether the composer is up, which is a route rather than a flag. */
72
+ export function useChangingSuggestionId(): string | undefined {
73
+ return useParams({ from: SUGGESTION_ROUTE, shouldThrow: false })
74
+ ?.suggestionId;
75
+ }
76
+
70
77
  export function useIsWritingEvent(): boolean {
71
78
  const composer = useParams({
72
79
  from: "/calendar/$view/$date/new",
73
80
  shouldThrow: false,
74
81
  });
75
- return composer !== undefined;
82
+ const changing = useParams({
83
+ from: SUGGESTION_ROUTE,
84
+ shouldThrow: false,
85
+ });
86
+ return composer !== undefined || changing !== undefined;
76
87
  }
77
88
 
78
89
  export interface CalendarNavigation {
@@ -97,6 +108,7 @@ export interface CalendarNavigation {
97
108
  openEvent: (calendarObjectId: string, recurrenceId?: string) => void;
98
109
  closeEvent: () => void;
99
110
  openComposer: () => void;
111
+ changeSuggestionFirst: (suggestionId: string, date: string) => void;
100
112
  }
101
113
 
102
114
  /**
@@ -161,6 +173,13 @@ export function useCalendarNavigation(): CalendarNavigation {
161
173
  search: true,
162
174
  hash: retainPanels,
163
175
  }),
176
+ changeSuggestionFirst: (suggestionId: string, on: string) =>
177
+ navigate({
178
+ to: SUGGESTION_ROUTE,
179
+ params: { view, date: on, suggestionId },
180
+ search: true,
181
+ hash: retainPanels,
182
+ }),
164
183
  }),
165
184
  [goTo, navigate, retainPanels, view, date],
166
185
  );
@@ -194,3 +213,19 @@ export function useOpenEventOnCalendar(): (
194
213
  [navigate],
195
214
  );
196
215
  }
216
+
217
+ export function useChangeSuggestionOnCalendar(): (
218
+ date: string,
219
+ suggestionId: string,
220
+ ) => void {
221
+ const navigate = useNavigate();
222
+ return useCallback(
223
+ (date: string, suggestionId: string) => {
224
+ navigate({
225
+ to: SUGGESTION_ROUTE,
226
+ params: { view: "day", date, suggestionId },
227
+ });
228
+ },
229
+ [navigate],
230
+ );
231
+ }
@@ -9,6 +9,8 @@ export {
9
9
  type OpenCalendarEvent,
10
10
  useCalendarAddress,
11
11
  useCalendarNavigation,
12
+ useChangeSuggestionOnCalendar,
13
+ useChangingSuggestionId,
12
14
  useIsWritingEvent,
13
15
  useOpenCalendarEvent,
14
16
  useOpenEventOnCalendar,