@remit/ui 0.0.164 → 0.0.166

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/src/components/calendar-clash-strip.render.test.ts +51 -0
  3. package/src/components/calendar-clash-strip.stories.tsx +56 -0
  4. package/src/components/calendar-clash-strip.tsx +64 -0
  5. package/src/components/calendar-invite-card.render.test.ts +110 -0
  6. package/src/components/calendar-invite-card.stories.tsx +132 -0
  7. package/src/components/calendar-invite-card.tsx +288 -0
  8. package/src/components/calendar-parse-badge.render.test.ts +40 -0
  9. package/src/components/calendar-parse-badge.stories.tsx +46 -0
  10. package/src/components/calendar-parse-badge.tsx +59 -0
  11. package/src/components/calendar-slot-offers.render.test.ts +67 -0
  12. package/src/components/calendar-slot-offers.stories.tsx +79 -0
  13. package/src/components/calendar-slot-offers.tsx +67 -0
  14. package/src/components/calendar-suggestion-deck.render.test.ts +69 -0
  15. package/src/components/calendar-suggestion-deck.stories.tsx +165 -0
  16. package/src/components/calendar-suggestion-deck.tsx +116 -0
  17. package/src/components/calendar-types.ts +57 -0
  18. package/src/components/event-suggestion-card.tsx +8 -1
  19. package/src/components/intelligence-calendar-fixtures.ts +384 -0
  20. package/src/components/intelligence-calendar.deck-zone-gate.test.ts +142 -0
  21. package/src/components/intelligence-calendar.render.test.ts +122 -0
  22. package/src/components/intelligence-calendar.tsx +288 -0
  23. package/src/components/intelligence-panel-calendar.stories.tsx +401 -0
  24. package/src/components/intelligence-panel.render.test.ts +64 -1
  25. package/src/components/intelligence-panel.stories.tsx +21 -0
  26. package/src/components/intelligence-panel.tab-strip.test.ts +163 -0
  27. package/src/components/intelligence-panel.tsx +265 -179
  28. package/src/components/intelligence-section.tsx +24 -0
  29. package/src/components/selection-wizard.render.test.ts +32 -0
  30. package/src/components/selection-wizard.tsx +28 -12
  31. package/src/index.ts +46 -0
  32. package/src/lib/semantic-off.ts +20 -0
@@ -10,12 +10,24 @@ import {
10
10
  Star,
11
11
  X,
12
12
  } from "lucide-react";
13
- import type { ReactElement, ReactNode } from "react";
13
+ import { type ReactElement, type ReactNode, useId, useState } from "react";
14
14
  import { cn } from "../lib/cn.js";
15
+ import {
16
+ SEMANTIC_OFF_BUYS,
17
+ SEMANTIC_OFF_COMMAND,
18
+ SEMANTIC_OFF_TITLE,
19
+ } from "../lib/semantic-off.js";
15
20
  import { categoryTone, type ThreadCategory } from "./app-shell-types.js";
16
21
  import { Avatar } from "./avatar.js";
17
22
  import { Badge } from "./badge.js";
18
23
  import { Button } from "./button.js";
24
+ import {
25
+ IntelligenceCalendar,
26
+ type IntelligenceCalendarActions,
27
+ type IntelligenceCalendarData,
28
+ } from "./intelligence-calendar.js";
29
+ import { IntelligenceSection } from "./intelligence-section.js";
30
+ import { SegmentedControl } from "./segmented-control.js";
19
31
 
20
32
  /* ------------------------------------------------------------------ */
21
33
  /* The fourth pane: mail intelligence. Driven by real backend signals */
@@ -158,12 +170,42 @@ export interface IntelligenceQuickActions {
158
170
  }
159
171
 
160
172
  /**
161
- * Async state for the similar-messages section. The host computes these from
162
- * the semantic-search query so the panel can show a skeleton while in flight
163
- * and "similarity search unavailable" on failure (the rest of the sidebar
164
- * still renders). Defaults to "ready" when omitted.
173
+ * State of the similar-messages section. The host computes these from the
174
+ * semantic-search query so the panel can show a skeleton while in flight and
175
+ * "similarity search unavailable" on failure (the rest of the sidebar still
176
+ * renders). Defaults to "ready" when omitted.
177
+ *
178
+ * "off" is not a failure and not a slow query: this instance stores no message
179
+ * vectors, and it says so with the command that changes it. Without it the
180
+ * section renders nothing at all, which reads as a sender nothing resembles.
181
+ */
182
+ export type SimilarState = "loading" | "error" | "off" | "ready";
183
+
184
+ /**
185
+ * The two halves of the panel. Sender is what this message is; Calendar is what
186
+ * it would cost. They are tabs rather than one long column because the second
187
+ * half only matters while a decision about time is open, and because both hosts
188
+ * — the rail at 1280 and up, the drawer below it — mount this same component
189
+ * and so inherit whatever the strip does.
165
190
  */
166
- export type SimilarState = "loading" | "error" | "ready";
191
+ export type IntelligenceTabId = "sender" | "calendar";
192
+
193
+ const tabOptions: { value: IntelligenceTabId; label: string }[] = [
194
+ { value: "sender", label: "Sender" },
195
+ { value: "calendar", label: "Calendar" },
196
+ ];
197
+
198
+ /**
199
+ * The calendar tab's data and its callbacks, which arrive together or not at
200
+ * all: a tab whose buttons cannot be serviced is a row of dead controls, so a
201
+ * host with no calendar wiring gets no tab strip.
202
+ */
203
+ export interface IntelligenceCalendarSurface {
204
+ data: IntelligenceCalendarData;
205
+ actions: IntelligenceCalendarActions;
206
+ /** The event the day list shows as selected; empty when none is. */
207
+ selectedEventId?: string;
208
+ }
167
209
 
168
210
  export interface IntelligencePanelProps {
169
211
  data: IntelligenceData;
@@ -202,6 +244,15 @@ export interface IntelligencePanelProps {
202
244
  reportSpamPending?: boolean;
203
245
  /** True while a "Not spam" (undo) press is in flight. Same treatment as `reportSpamPending`. */
204
246
  notSpamPending?: boolean;
247
+ /** The calendar half. Omit it and the panel is the Sender stack alone. */
248
+ calendar?: IntelligenceCalendarSurface;
249
+ /** The tab showing. Omit to let the panel hold the choice itself. */
250
+ tab?: IntelligenceTabId;
251
+ onTabChange?: (tab: IntelligenceTabId) => void;
252
+ /** Which tab a panel holding its own choice opens on. */
253
+ defaultTab?: IntelligenceTabId;
254
+ /** Larger hit targets, for the drawer host on a touch screen. */
255
+ touch?: boolean;
205
256
  }
206
257
 
207
258
  const trustLabel: Record<
@@ -213,27 +264,6 @@ const trustLabel: Record<
213
264
  vip: { label: "VIP", tone: "accent" },
214
265
  };
215
266
 
216
- function Section({
217
- label,
218
- children,
219
- className,
220
- }: {
221
- label: string;
222
- children: ReactNode;
223
- className?: string;
224
- }) {
225
- return (
226
- <section
227
- className={cn("border-b border-line px-row-inset py-3", className)}
228
- >
229
- <h3 className="text-2xs font-semibold uppercase tracking-wider text-fg-subtle">
230
- {label}
231
- </h3>
232
- <div className="mt-2">{children}</div>
233
- </section>
234
- );
235
- }
236
-
237
267
  function SenderCard({ sender }: { sender: SenderIntel }) {
238
268
  const trust = trustLabel[sender.trust];
239
269
  // Engagement clause renders only when counters are present. When the API
@@ -397,8 +427,18 @@ export function IntelligencePanel({
397
427
  hideCloseButton = false,
398
428
  reportSpamPending = false,
399
429
  notSpamPending = false,
430
+ calendar,
431
+ tab,
432
+ onTabChange,
433
+ defaultTab = "sender",
434
+ touch,
400
435
  }: IntelligencePanelProps) {
401
436
  const { sender, authenticity, category, flags = {}, similar } = data;
437
+ const [ownTab, setOwnTab] = useState<IntelligenceTabId>(defaultTab);
438
+ const tabStripName = useId();
439
+ const activeTab = tab ?? ownTab;
440
+ const calendarTab =
441
+ calendar !== undefined && activeTab === "calendar" ? calendar : undefined;
402
442
 
403
443
  return (
404
444
  <aside
@@ -423,169 +463,215 @@ export function IntelligencePanel({
423
463
  )}
424
464
  </header>
425
465
 
426
- <Section label="Sender">
427
- <SenderCard sender={sender} />
428
- </Section>
466
+ {calendar && (
467
+ <div className="flex shrink-0 justify-center border-b border-line px-row-inset py-2">
468
+ <SegmentedControl
469
+ name={tabStripName}
470
+ aria-label="What this panel is showing"
471
+ size="sm"
472
+ options={tabOptions}
473
+ value={activeTab}
474
+ onChange={(next) => {
475
+ if (tab === undefined) setOwnTab(next);
476
+ onTabChange?.(next);
477
+ }}
478
+ />
479
+ </div>
480
+ )}
429
481
 
430
- <Section label="Authenticity">
431
- <Authenticity auth={authenticity} onShowSimilar={onShowSimilar} />
432
- </Section>
482
+ {calendarTab && (
483
+ <IntelligenceCalendar
484
+ data={calendarTab.data}
485
+ actions={calendarTab.actions}
486
+ selectedEventId={calendarTab.selectedEventId}
487
+ touch={touch}
488
+ />
489
+ )}
433
490
 
434
- <Section label="Category">
435
- <div className="flex items-center gap-2">
436
- <Badge tone={categoryTone[category.value]}>{category.value}</Badge>
437
- {category.overridden && (
438
- <span className="text-2xs text-fg-subtle">your override</span>
439
- )}
440
- <button
441
- type="button"
442
- className={cn(
443
- "ml-auto text-2xs text-accent hover:underline",
444
- !actions?.onReclassify &&
445
- "cursor-not-allowed opacity-50 hover:no-underline",
446
- )}
447
- disabled={!actions?.onReclassify}
448
- onClick={actions?.onReclassify}
449
- >
450
- reclassify
451
- </button>
452
- </div>
453
- </Section>
491
+ {calendarTab === undefined && (
492
+ <>
493
+ <IntelligenceSection label="Sender">
494
+ <SenderCard sender={sender} />
495
+ </IntelligenceSection>
454
496
 
455
- <Section label="Quick actions">
456
- <div className="flex flex-wrap gap-1.5">
457
- <QuickAction
458
- icon={<Star className="size-3.5" />}
459
- label="VIP"
460
- active={flags.vip}
461
- onClick={actions?.onToggleVip}
462
- />
463
- <QuickAction
464
- icon={<BellOff className="size-3.5" />}
465
- label="Mute"
466
- active={flags.muted}
467
- onClick={actions?.onToggleMute}
468
- />
469
- {actions?.onNotSpam && (
470
- <QuickAction
471
- icon={<MailCheck className="size-3.5" />}
472
- label={notSpamPending ? "Undoing…" : "Not spam"}
473
- active
474
- onClick={actions.onNotSpam}
475
- pending={notSpamPending}
476
- />
477
- )}
478
- {actions?.onReportSpam && (
479
- <QuickAction
480
- icon={<ShieldX className="size-3.5" />}
481
- label={reportSpamPending ? "Reporting…" : "Report spam"}
482
- danger
483
- onClick={actions.onReportSpam}
484
- pending={reportSpamPending}
485
- />
486
- )}
487
- <QuickAction
488
- icon={<MailX className="size-3.5" />}
489
- label="Unsubscribe"
490
- active={flags.unsubscribed}
491
- onClick={actions?.onToggleUnsubscribe}
492
- />
493
- </div>
494
- {actions?.onNotSpam && (
495
- <p className="mt-1.5 text-2xs text-fg-subtle">
496
- You reported this message as spam
497
- </p>
498
- )}
499
- </Section>
497
+ <IntelligenceSection label="Authenticity">
498
+ <Authenticity auth={authenticity} onShowSimilar={onShowSimilar} />
499
+ </IntelligenceSection>
500
500
 
501
- {(similarState !== "ready" || similar.length > 0) && (
502
- <Section label="Similar messages">
503
- {similarState === "loading" ? (
504
- <div className="animate-pulse space-y-2">
505
- {Array.from({ length: 3 }).map((_, i) => (
506
- // biome-ignore lint/suspicious/noArrayIndexKey: list is static, no stable id
507
- <div key={i} className="space-y-1">
508
- <div className="h-3 w-3/4 rounded bg-surface-sunken" />
509
- <div className="h-2.5 w-1/2 rounded bg-surface-sunken" />
510
- </div>
511
- ))}
501
+ <IntelligenceSection label="Category">
502
+ <div className="flex items-center gap-2">
503
+ <Badge tone={categoryTone[category.value]}>
504
+ {category.value}
505
+ </Badge>
506
+ {category.overridden && (
507
+ <span className="text-2xs text-fg-subtle">your override</span>
508
+ )}
509
+ <button
510
+ type="button"
511
+ className={cn(
512
+ "ml-auto text-2xs text-accent hover:underline",
513
+ !actions?.onReclassify &&
514
+ "cursor-not-allowed opacity-50 hover:no-underline",
515
+ )}
516
+ disabled={!actions?.onReclassify}
517
+ onClick={actions?.onReclassify}
518
+ >
519
+ reclassify
520
+ </button>
512
521
  </div>
513
- ) : similarState === "error" ? (
514
- <p className="text-xs text-fg-subtle">
515
- Similarity search unavailable
516
- </p>
517
- ) : (
518
- <ul className="-mx-1 space-y-1">
519
- {similar.map((s) => {
520
- const rowClass =
521
- "block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken";
522
- const ariaLabel = `Open message from ${s.fromName || "unknown sender"}: ${s.subject}`;
523
- const inner = (
524
- <>
525
- <div className="flex items-baseline justify-between gap-2">
526
- <span className="truncate text-xs font-medium text-fg">
527
- {s.fromName}
528
- </span>
529
- <span className="shrink-0 text-2xs text-fg-subtle tabular-nums">
530
- {s.timeLabel}
531
- </span>
532
- </div>
533
- <div className="truncate text-xs text-fg-muted">
534
- {s.subject}
522
+ </IntelligenceSection>
523
+
524
+ <IntelligenceSection label="Quick actions">
525
+ <div className="flex flex-wrap gap-1.5">
526
+ <QuickAction
527
+ icon={<Star className="size-3.5" />}
528
+ label="VIP"
529
+ active={flags.vip}
530
+ onClick={actions?.onToggleVip}
531
+ />
532
+ <QuickAction
533
+ icon={<BellOff className="size-3.5" />}
534
+ label="Mute"
535
+ active={flags.muted}
536
+ onClick={actions?.onToggleMute}
537
+ />
538
+ {actions?.onNotSpam && (
539
+ <QuickAction
540
+ icon={<MailCheck className="size-3.5" />}
541
+ label={notSpamPending ? "Undoing…" : "Not spam"}
542
+ active
543
+ onClick={actions.onNotSpam}
544
+ pending={notSpamPending}
545
+ />
546
+ )}
547
+ {actions?.onReportSpam && (
548
+ <QuickAction
549
+ icon={<ShieldX className="size-3.5" />}
550
+ label={reportSpamPending ? "Reporting…" : "Report spam"}
551
+ danger
552
+ onClick={actions.onReportSpam}
553
+ pending={reportSpamPending}
554
+ />
555
+ )}
556
+ <QuickAction
557
+ icon={<MailX className="size-3.5" />}
558
+ label="Unsubscribe"
559
+ active={flags.unsubscribed}
560
+ onClick={actions?.onToggleUnsubscribe}
561
+ />
562
+ </div>
563
+ {actions?.onNotSpam && (
564
+ <p className="mt-1.5 text-2xs text-fg-subtle">
565
+ You reported this message as spam
566
+ </p>
567
+ )}
568
+ </IntelligenceSection>
569
+
570
+ {(similarState !== "ready" || similar.length > 0) && (
571
+ <IntelligenceSection label="Similar messages">
572
+ {similarState === "loading" ? (
573
+ <div className="animate-pulse space-y-2">
574
+ {Array.from({ length: 3 }).map((_, i) => (
575
+ // biome-ignore lint/suspicious/noArrayIndexKey: list is static, no stable id
576
+ <div key={i} className="space-y-1">
577
+ <div className="h-3 w-3/4 rounded bg-surface-sunken" />
578
+ <div className="h-2.5 w-1/2 rounded bg-surface-sunken" />
535
579
  </div>
536
- <span className="mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle">
537
- {matchTone[s.matched]}
538
- </span>
539
- </>
540
- );
541
- return (
542
- <li key={s.id}>
543
- {similarLinkComponent ? (
544
- similarLinkComponent({
545
- mailboxId: s.mailboxId,
546
- threadId: s.threadId,
547
- messageId: s.id,
548
- className: rowClass,
549
- ariaLabel,
550
- children: inner,
551
- })
552
- ) : (
553
- <div className={rowClass}>{inner}</div>
554
- )}
555
- </li>
556
- );
557
- })}
558
- </ul>
580
+ ))}
581
+ </div>
582
+ ) : similarState === "error" ? (
583
+ <p className="text-xs text-fg-subtle">
584
+ Similarity search unavailable
585
+ </p>
586
+ ) : similarState === "off" ? (
587
+ <div className="space-y-1.5 text-xs text-fg-subtle">
588
+ <p className="text-fg-muted">{SEMANTIC_OFF_TITLE}</p>
589
+ <p>{SEMANTIC_OFF_BUYS}</p>
590
+ <p>
591
+ Run{" "}
592
+ <code className="rounded bg-surface-sunken px-1 py-px text-2xs text-fg-muted">
593
+ {SEMANTIC_OFF_COMMAND}
594
+ </code>{" "}
595
+ on the server.
596
+ </p>
597
+ </div>
598
+ ) : (
599
+ <ul className="-mx-1 space-y-1">
600
+ {similar.map((s) => {
601
+ const rowClass =
602
+ "block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken";
603
+ const ariaLabel = `Open message from ${s.fromName || "unknown sender"}: ${s.subject}`;
604
+ const inner = (
605
+ <>
606
+ <div className="flex items-baseline justify-between gap-2">
607
+ <span className="truncate text-xs font-medium text-fg">
608
+ {s.fromName}
609
+ </span>
610
+ <span className="shrink-0 text-2xs text-fg-subtle tabular-nums">
611
+ {s.timeLabel}
612
+ </span>
613
+ </div>
614
+ <div className="truncate text-xs text-fg-muted">
615
+ {s.subject}
616
+ </div>
617
+ <span className="mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle">
618
+ {matchTone[s.matched]}
619
+ </span>
620
+ </>
621
+ );
622
+ return (
623
+ <li key={s.id}>
624
+ {similarLinkComponent ? (
625
+ similarLinkComponent({
626
+ mailboxId: s.mailboxId,
627
+ threadId: s.threadId,
628
+ messageId: s.id,
629
+ className: rowClass,
630
+ ariaLabel,
631
+ children: inner,
632
+ })
633
+ ) : (
634
+ <div className={rowClass}>{inner}</div>
635
+ )}
636
+ </li>
637
+ );
638
+ })}
639
+ </ul>
640
+ )}
641
+ </IntelligenceSection>
559
642
  )}
560
- </Section>
561
- )}
562
643
 
563
- <Section label="Coming soon" className="border-b-0 opacity-70">
564
- <div className="space-y-2">
565
- <div className="flex items-start gap-2 rounded-md border border-dashed border-line p-2">
566
- <Sparkles className="mt-0.5 size-3.5 shrink-0 text-fg-subtle" />
567
- <div>
568
- <div className="text-xs font-medium text-fg-muted">
569
- Suggested actions
570
- </div>
571
- <div className="text-2xs text-fg-subtle">
572
- "Create a filter for messages like this" — on-device model
573
- </div>
574
- </div>
575
- </div>
576
- <div className="flex items-start gap-2 rounded-md border border-dashed border-line p-2">
577
- <Sparkles className="mt-0.5 size-3.5 shrink-0 text-fg-subtle" />
578
- <div>
579
- <div className="text-xs font-medium text-fg-muted">
580
- Thread summary
644
+ <IntelligenceSection
645
+ label="Coming soon"
646
+ className="border-b-0 opacity-70"
647
+ >
648
+ <div className="space-y-2">
649
+ <div className="flex items-start gap-2 rounded-md border border-dashed border-line p-2">
650
+ <Sparkles className="mt-0.5 size-3.5 shrink-0 text-fg-subtle" />
651
+ <div>
652
+ <div className="text-xs font-medium text-fg-muted">
653
+ Suggested actions
654
+ </div>
655
+ <div className="text-2xs text-fg-subtle">
656
+ "Create a filter for messages like this" — on-device model
657
+ </div>
658
+ </div>
581
659
  </div>
582
- <div className="text-2xs text-fg-subtle">
583
- One-paragraph digest — Bedrock
660
+ <div className="flex items-start gap-2 rounded-md border border-dashed border-line p-2">
661
+ <Sparkles className="mt-0.5 size-3.5 shrink-0 text-fg-subtle" />
662
+ <div>
663
+ <div className="text-xs font-medium text-fg-muted">
664
+ Thread summary
665
+ </div>
666
+ <div className="text-2xs text-fg-subtle">
667
+ One-paragraph digest — Bedrock
668
+ </div>
669
+ </div>
584
670
  </div>
585
671
  </div>
586
- </div>
587
- </div>
588
- </Section>
672
+ </IntelligenceSection>
673
+ </>
674
+ )}
589
675
  </aside>
590
676
  );
591
677
  }
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from "react";
2
+ import { cn } from "../lib/cn.js";
3
+
4
+ /** One labelled band of the intelligence panel, shared by both its tabs. */
5
+ export function IntelligenceSection({
6
+ label,
7
+ children,
8
+ className,
9
+ }: {
10
+ label: string;
11
+ children: ReactNode;
12
+ className?: string;
13
+ }) {
14
+ return (
15
+ <section
16
+ className={cn("border-b border-line px-row-inset py-3", className)}
17
+ >
18
+ <h3 className="text-2xs font-semibold uppercase tracking-wider text-fg-subtle">
19
+ {label}
20
+ </h3>
21
+ <div className="mt-2">{children}</div>
22
+ </section>
23
+ );
24
+ }
@@ -266,6 +266,38 @@ describe("MatchStepBody", () => {
266
266
  assert.match(html, /matching on the\s+senders instead/);
267
267
  });
268
268
 
269
+ // Off is a property of the deployment, so the door says what an operator can
270
+ // do about it rather than "unavailable right now", which invites a retry that
271
+ // cannot succeed (#1068).
272
+ it("names the setting and the command when semantic search is off", () => {
273
+ const html = renderToString(
274
+ createElement(MatchStepBody, {
275
+ ...matchProps,
276
+ semanticOff: true,
277
+ }),
278
+ );
279
+ assert.match(html, /opacity-55/);
280
+ assert.doesNotMatch(html, /disabled=""/);
281
+ assert.match(text(html), /Semantic search is off on this instance/);
282
+ assert.match(text(html), /remit semantic on/);
283
+ assert.doesNotMatch(text(html), /unavailable right now/);
284
+ });
285
+
286
+ it("supersedes the runtime failure copy, which would tell the user to retry", () => {
287
+ const html = renderToString(
288
+ createElement(MatchStepBody, {
289
+ ...matchProps,
290
+ semanticOff: true,
291
+ semanticUnavailable: true,
292
+ semanticErrorDetail: "no vector index",
293
+ semanticFallbackTaken: true,
294
+ }),
295
+ );
296
+ assert.doesNotMatch(text(html), /no vector index/);
297
+ assert.match(text(html), /Semantic search is off on this instance/);
298
+ assert.match(text(html), /Matching on the senders instead/);
299
+ });
300
+
269
301
  it("names what an escalated predicate covers instead of offering doors", () => {
270
302
  const html = renderToString(
271
303
  createElement(MatchStepBody, {
@@ -19,6 +19,7 @@ import {
19
19
  } from "lucide-react";
20
20
  import { Fragment, type ReactNode, useEffect, useId, useRef } from "react";
21
21
  import { cn } from "../lib/cn.js";
22
+ import { semanticOffReason } from "../lib/semantic-off.js";
22
23
  import {
23
24
  backExits,
24
25
  crossAccountMatchReason,
@@ -384,6 +385,12 @@ export interface MatchStepProps {
384
385
  * of the deployment: the door stays pressable and dimmed.
385
386
  */
386
387
  semanticUnavailable?: boolean;
388
+ /**
389
+ * Semantic search is off on this instance (#1068) — a deployment setting, so
390
+ * the door is dimmed for a reason an operator can act on rather than a
391
+ * failure the user should retry. It supersedes the runtime copy above.
392
+ */
393
+ semanticOff?: boolean;
387
394
  /**
388
395
  * What the mail server said when the widen was asked to run and failed. A
389
396
  * failure is a reason the door cannot run, so it dims the door like any other
@@ -408,6 +415,7 @@ export function MatchStepBody({
408
415
  accountId,
409
416
  onModeChange,
410
417
  semanticUnavailable,
418
+ semanticOff,
411
419
  semanticErrorDetail,
412
420
  semanticFallbackTaken,
413
421
  onSemanticFallback,
@@ -431,6 +439,7 @@ export function MatchStepBody({
431
439
  }
432
440
  const doors = matchDoorsFor(accountId);
433
441
  const widened = doors.length > 1;
442
+ const widenBlocked = semanticOff || semanticUnavailable;
434
443
  return (
435
444
  <>
436
445
  <div className="space-y-2">
@@ -448,25 +457,32 @@ export function MatchStepBody({
448
457
  {widened && (
449
458
  <ChoiceCard
450
459
  selected={mode === "similar"}
451
- unavailable={semanticUnavailable}
460
+ unavailable={widenBlocked}
452
461
  onSelect={
453
- semanticUnavailable
454
- ? onSemanticFallback
455
- : () => onModeChange("similar")
462
+ widenBlocked ? onSemanticFallback : () => onModeChange("similar")
456
463
  }
457
464
  title={matchDoorLabel("similar", selectedCount)}
458
465
  description={matchDoorHint("similar")}
459
466
  >
460
- {semanticErrorDetail && (
461
- <p role="status" className="px-1 text-2xs text-danger">
462
- Couldn't find similar messages: {semanticErrorDetail}
463
- </p>
464
- )}
465
- {semanticFallbackTaken && (
467
+ {semanticOff ? (
466
468
  <p role="status" className="px-1 text-2xs text-fg-subtle">
467
- Similar-mail matching is unavailable right now — matching on the
468
- senders instead.
469
+ {semanticOffReason}
470
+ {semanticFallbackTaken && " Matching on the senders instead."}
469
471
  </p>
472
+ ) : (
473
+ <>
474
+ {semanticErrorDetail && (
475
+ <p role="status" className="px-1 text-2xs text-danger">
476
+ Couldn't find similar messages: {semanticErrorDetail}
477
+ </p>
478
+ )}
479
+ {semanticFallbackTaken && (
480
+ <p role="status" className="px-1 text-2xs text-fg-subtle">
481
+ Similar-mail matching is unavailable right now — matching on
482
+ the senders instead.
483
+ </p>
484
+ )}
485
+ </>
470
486
  )}
471
487
  </ChoiceCard>
472
488
  )}