@remit/ui 0.0.189 → 0.0.191

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.189",
3
+ "version": "0.0.191",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -922,6 +922,9 @@ export const ChipGallery: ChipStory = {
922
922
  <div className="space-y-2">
923
923
  <FilterPreviewCount preview={{ status: "loading" }} />
924
924
  <FilterPreviewCount preview={READY(0)} />
925
+ <FilterPreviewCount
926
+ preview={{ status: "ready", count: 0, indexEmpty: true }}
927
+ />
925
928
  <FilterPreviewCount preview={READY(412)} />
926
929
  <FilterPreviewCount preview={READY(47, true)} />
927
930
  <FilterPreviewCount
@@ -431,6 +431,30 @@ describe("FilterPreviewCount", () => {
431
431
  assert.doesNotMatch(html, /role="alert"/);
432
432
  });
433
433
 
434
+ // A zero counted against an index that holds nothing is not the same
435
+ // statement as a zero counted against the mail (#452), and reading it as one
436
+ // talks the user out of a rule that would match plenty.
437
+ it("says the index is still filling rather than that nothing matches", () => {
438
+ const html = render(
439
+ createElement(FilterPreviewCount, {
440
+ preview: { status: "ready", count: 0, indexEmpty: true },
441
+ }),
442
+ );
443
+ assert.match(html, /Still indexing/);
444
+ assert.doesNotMatch(html, /No mail matches yet/);
445
+ assert.doesNotMatch(html, /role="alert"/);
446
+ });
447
+
448
+ it("does not mark the empty-index line as recounting", () => {
449
+ const html = render(
450
+ createElement(FilterPreviewCount, {
451
+ preview: { status: "ready", count: 0, stale: true, indexEmpty: true },
452
+ }),
453
+ );
454
+ assert.match(html, /Still indexing/);
455
+ assert.doesNotMatch(html, /recounting/);
456
+ });
457
+
434
458
  it("counts many matches", () => {
435
459
  const html = render(
436
460
  createElement(FilterPreviewCount, {
@@ -116,10 +116,15 @@ export interface LabelOption {
116
116
  * The live match count (RFC 038 D1). `stale` marks a count the editor already
117
117
  * moved past — a clause changed after it was counted, so the number on screen
118
118
  * is the previous rule's until the next preview lands.
119
+ *
120
+ * `indexEmpty` is the server saying the semantic index had nothing to answer
121
+ * with (issue #452). A zero counted against an empty index is a fact about the
122
+ * index, not about the rule, and reading it as "no mail matches" talks a user
123
+ * out of a rule that will match plenty once indexing catches up.
119
124
  */
120
125
  export type PreviewCount =
121
126
  | { status: "loading" }
122
- | { status: "ready"; count: number; stale?: boolean }
127
+ | { status: "ready"; count: number; stale?: boolean; indexEmpty?: boolean }
123
128
  | { status: "error"; reason: string };
124
129
 
125
130
  const clauseFieldLabels: Record<ClauseField, string> = {
@@ -225,6 +230,11 @@ export function matchJoinWord(operator: MatchOperator): string {
225
230
  export function previewCountSummary(preview: PreviewCount): string {
226
231
  if (preview.status === "loading") return "Counting matches…";
227
232
  if (preview.status === "error") return preview.reason;
233
+ // An index with nothing in it counted nothing, so there is no count to mark
234
+ // as recounting. The sentence is about the index, not about the rule, and it
235
+ // reads the same whichever predicate is on screen.
236
+ if (preview.indexEmpty)
237
+ return "Still indexing — nothing to match against yet";
228
238
  if (preview.count === 0) return "No mail matches yet";
229
239
  const noun = preview.count === 1 ? "message" : "messages";
230
240
  const base = `${preview.count} ${noun} match`;