@remit/ui 0.0.165 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -201,6 +201,27 @@ export const WithSimilarMessages: Story = {
201
201
  },
202
202
  };
203
203
 
204
+ /**
205
+ * Semantic search is off on this instance (#1068). The section states the
206
+ * setting, what turning it on buys — the Organize widen and semantic filters —
207
+ * and the command, rather than rendering nothing and reading as a sender
208
+ * nothing resembles.
209
+ */
210
+ export const SimilarMessagesOff: Story = {
211
+ args: {
212
+ data: base,
213
+ similarState: "off",
214
+ },
215
+ };
216
+
217
+ /** The runtime failure, for contrast: a retry might work, so it says no more. */
218
+ export const SimilarMessagesUnavailable: Story = {
219
+ args: {
220
+ data: base,
221
+ similarState: "error",
222
+ },
223
+ };
224
+
204
225
  /**
205
226
  * The spam quick actions are a contextual pair, decided by whether the message
206
227
  * carries a spam report — never by the mailbox it happens to sit in, since a
@@ -12,6 +12,11 @@ import {
12
12
  } from "lucide-react";
13
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";
@@ -165,12 +170,16 @@ export interface IntelligenceQuickActions {
165
170
  }
166
171
 
167
172
  /**
168
- * Async state for the similar-messages section. The host computes these from
169
- * the semantic-search query so the panel can show a skeleton while in flight
170
- * and "similarity search unavailable" on failure (the rest of the sidebar
171
- * 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.
172
181
  */
173
- export type SimilarState = "loading" | "error" | "ready";
182
+ export type SimilarState = "loading" | "error" | "off" | "ready";
174
183
 
175
184
  /**
176
185
  * The two halves of the panel. Sender is what this message is; Calendar is what
@@ -574,6 +583,18 @@ export function IntelligencePanel({
574
583
  <p className="text-xs text-fg-subtle">
575
584
  Similarity search unavailable
576
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>
577
598
  ) : (
578
599
  <ul className="-mx-1 space-y-1">
579
600
  {similar.map((s) => {
@@ -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
  )}
package/src/index.ts CHANGED
@@ -1083,6 +1083,12 @@ export {
1083
1083
  type SearchConversion,
1084
1084
  searchConversionNotice,
1085
1085
  } from "./lib/search-rule.js";
1086
+ export {
1087
+ SEMANTIC_OFF_BUYS,
1088
+ SEMANTIC_OFF_COMMAND,
1089
+ SEMANTIC_OFF_TITLE,
1090
+ semanticOffReason,
1091
+ } from "./lib/semantic-off.js";
1086
1092
  export {
1087
1093
  collapsibleDomain,
1088
1094
  deriveSenderClauses,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * What the surfaces backed by stored message vectors say on an instance with
3
+ * semantic search off (#1068).
4
+ *
5
+ * Off is a deployment setting, not a failure, so the copy names the command
6
+ * that changes it and what changing it buys: the Organize widen to similar
7
+ * mail, and filters that match on similarity. It deliberately promises nothing
8
+ * about the "Similar messages" panel filling — answering a typed query needs a
9
+ * query embedder no self-host image carries, so that panel is empty either way
10
+ * (deploy/vps/README.md, Search).
11
+ */
12
+ export const SEMANTIC_OFF_TITLE = "Semantic search is off on this instance.";
13
+
14
+ export const SEMANTIC_OFF_BUYS =
15
+ "On, it stores a vector for every message, which is what the Organize widen to similar mail and semantic filters read.";
16
+
17
+ export const SEMANTIC_OFF_COMMAND = "remit semantic on";
18
+
19
+ /** The same three facts as one line, for a surface with room for one. */
20
+ export const semanticOffReason = `${SEMANTIC_OFF_TITLE} ${SEMANTIC_OFF_BUYS} Run '${SEMANTIC_OFF_COMMAND}' on the server.`;