@estiva-app/interop 0.49.0 → 0.51.0

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.
@@ -38,14 +38,15 @@ export interface SearchFileReferencesOptions extends Omit<FileCandidatesOptions,
38
38
  limit?: number;
39
39
  }
40
40
  /**
41
- * The files whose **current** title holds `text`, as the search tier.
41
+ * The files whose **current** title — or, for an issue, current ref (CON-33)
42
+ * — holds `text`, as the search tier.
42
43
  *
43
- * The relay indexes a root's `title` and a rename's `value` (relay ticket
44
- * 6fea004e); neither is the current title on its own — a root keeps the name
45
- * it was created with, and a rename found by an old word may since have been
46
- * renamed again. So a hit is only an address: each is read back as its root
47
- * and changes, folded through its app's manifest, and kept only when what it
48
- * is called now matches what was typed.
44
+ * The relay indexes a root's `title` and `ref` and a change's `value` for those
45
+ * fields (SPEC §5.2); none is the current one on its own — a root keeps the
46
+ * name it was created with, and a rename found by an old word may since have
47
+ * been renamed again. So a hit is only an address: each is read back as its
48
+ * root and changes, folded through its app's manifest, and kept only when what
49
+ * it is called now matches what was typed.
49
50
  *
50
51
  * Roots and renames are asked for separately, so a burst of renames cannot
51
52
  * crowd every root out of the answer, and with buzz's prefix mode, so the word
@@ -1 +1 @@
1
- {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,OAAO,EACb,MAAM,iBAAiB,CAAA;AAKxB,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAIxE,CAAA;AAcD,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,0FAA0F;IAC1F,EAAE,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,CAAC,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACtD,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,EAAE,KAAK,EAAE,EAAE,EAAE,GAAE,qBAA0B,GACxC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA6B/B;AAED,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC;IACpF,2FAA2F;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,EAAE,KAAU,EAAE,GAAG,OAAO,EAAE,GAAE,2BAAgC,GAC3D,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAqB/B"}
@@ -12,7 +12,7 @@
12
12
  * never a row, so nothing unreadable is offered. An archived file is offered
13
13
  * at the lowest priority, and so is an issue in an archived project.
14
14
  */
15
- import { FILE_TIER, fileReference, KIND_CHANGE, referenceMatch, } from '@estiva-app/conversation';
15
+ import { FILE_TIER, fileReference, KIND_CHANGE, referenceMatch, refMatch, } from '@estiva-app/conversation';
16
16
  import { isClosedStatus, KIND_BARE_FILE, resolveForeignRoots, } from './projection.js';
17
17
  const KIND_PROJECT = 30850;
18
18
  const KIND_ISSUE = 30851;
@@ -29,6 +29,11 @@ const offerable = (object) => !!object &&
29
29
  !object.unreachable &&
30
30
  typeOf(object.kind) !== undefined &&
31
31
  !!object.slots.title?.value.trim();
32
+ /**
33
+ * An issue's current ref (`CON-33`, SPEC §6.1) — the manifest slot that folds
34
+ * the `ref` field — so typing it finds the issue. Only an issue has one.
35
+ */
36
+ const refOf = (object) => object.kind === KIND_ISSUE ? object.meta.find((slot) => slot.field === 'ref')?.value.trim() || undefined : undefined;
32
37
  /**
33
38
  * Rows for resolved files, all in one tier.
34
39
  *
@@ -57,14 +62,17 @@ export async function fileCandidates(objects, tier, query, { cache, at } = {}) {
57
62
  }
58
63
  return files.map((o) => {
59
64
  const parent = o.kind === KIND_ISSUE && o.parentRef ? parents.get(o.parentRef) : undefined;
65
+ const ref = refOf(o);
60
66
  return {
61
67
  id: o.address,
62
68
  uri: fileReference(o.address),
63
69
  type: typeOf(o.kind),
64
70
  kind: o.kind,
65
71
  title: o.slots.title.value,
66
- caption: parent?.slots.title?.value ?? '',
72
+ // An issue reads "CON-33 · Conversation standard": the ref first, so a hit by ref shows it (Miky, 2026-10-05).
73
+ caption: [ref, parent?.slots.title?.value].filter(Boolean).join(' · '),
67
74
  tier,
75
+ ...(ref ? { search: ref } : {}),
68
76
  ...(isClosedStatus(o.slots.status) ? { closed: true } : {}),
69
77
  ...(o.archived || parent?.archived ? { archived: true } : {}),
70
78
  ...(at?.has(o.address) ? { at: at.get(o.address) } : {}),
@@ -73,14 +81,20 @@ export async function fileCandidates(objects, tier, query, { cache, at } = {}) {
73
81
  }
74
82
  const tagOf = (event, name) => event.tags.find((t) => t[0] === name)?.[1];
75
83
  /**
76
- * The files whose **current** title holds `text`, as the search tier.
84
+ * The file a `kind:1851` hit names, when it is one the relay indexes for `[`
85
+ * (SPEC §5.2): a title change on any file, a ref change only on an issue.
86
+ */
87
+ const searchedChange = (field, address) => field === 'title' || (field === 'ref' && address?.startsWith(`${KIND_ISSUE}:`)) ? address : undefined;
88
+ /**
89
+ * The files whose **current** title — or, for an issue, current ref (CON-33)
90
+ * — holds `text`, as the search tier.
77
91
  *
78
- * The relay indexes a root's `title` and a rename's `value` (relay ticket
79
- * 6fea004e); neither is the current title on its own — a root keeps the name
80
- * it was created with, and a rename found by an old word may since have been
81
- * renamed again. So a hit is only an address: each is read back as its root
82
- * and changes, folded through its app's manifest, and kept only when what it
83
- * is called now matches what was typed.
92
+ * The relay indexes a root's `title` and `ref` and a change's `value` for those
93
+ * fields (SPEC §5.2); none is the current one on its own — a root keeps the
94
+ * name it was created with, and a rename found by an old word may since have
95
+ * been renamed again. So a hit is only an address: each is read back as its
96
+ * root and changes, folded through its app's manifest, and kept only when what
97
+ * it is called now matches what was typed.
84
98
  *
85
99
  * Roots and renames are asked for separately, so a burst of renames cannot
86
100
  * crowd every root out of the answer, and with buzz's prefix mode, so the word
@@ -100,9 +114,7 @@ export async function searchFileReferences(text, query, { limit = 32, ...options
100
114
  const at = new Map();
101
115
  for (const hit of hits) {
102
116
  const address = hit.kind === KIND_CHANGE
103
- ? tagOf(hit, 'field') === 'title'
104
- ? tagOf(hit, 'a')
105
- : undefined
117
+ ? searchedChange(tagOf(hit, 'field'), tagOf(hit, 'a'))
106
118
  : typeOf(hit.kind) && `${hit.kind}:${hit.pubkey}:${tagOf(hit, 'd') ?? ''}`;
107
119
  if (!address || !typeOf(Number(address.split(':')[0])))
108
120
  continue;
@@ -111,7 +123,7 @@ export async function searchFileReferences(text, query, { limit = 32, ...options
111
123
  if (at.size === 0)
112
124
  return [];
113
125
  const objects = await resolveForeignRoots([...at.keys()], query, options.cache);
114
- const matching = objects.filter((o) => o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0);
126
+ const matching = objects.filter((o) => (o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0) || refMatch(refOf(o), wanted) > 0);
115
127
  return fileCandidates(matching, FILE_TIER.search, query, { ...options, at });
116
128
  }
117
129
  //# sourceMappingURL=references.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,GAGf,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,GAIpB,MAAM,iBAAiB,CAAA;AAExB,MAAM,YAAY,GAAG,KAAK,CAAA;AAC1B,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,sEAAsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAA4C;IAC3E,CAAC,YAAY,CAA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C,IAAI,EAAE,EAAE,CAAA;QAC9E,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAAE,SAAQ;QAChE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAA;IACjE,CAAC;IACD,IAAI,EAAE,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IAC/E,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5I,OAAO,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAA;AAC9E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/interop",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "description": "Render and act on another app's objects from its published NIP-89 manifest. The owner defines the projection; the consumer decides how it looks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,11 +47,11 @@
47
47
  "prepublishOnly": "npm run build"
48
48
  },
49
49
  "peerDependencies": {
50
- "@estiva-app/conversation": ">=0.5.0",
50
+ "@estiva-app/conversation": ">=0.6.1",
51
51
  "@estiva-app/protocol": ">=0.24.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@estiva-app/conversation": ">=0.5.0",
54
+ "@estiva-app/conversation": ">=0.6.1",
55
55
  "@estiva-app/protocol": ">=0.24.0",
56
56
  "typescript": "~5.9.3"
57
57
  }
package/src/projection.ts CHANGED
@@ -30,7 +30,7 @@ import { planPlaceFile, planUnlistFile, type FolderRef } from './folders.js'
30
30
  the copy that lived here — a `kind:9` is never a comment (CON-20 migrated
31
31
  them), a reply is never a root, and `ts` is trusted only inside its own second.
32
32
  */
33
- import { byOrder, isCommentOn, orderingMs } from '@estiva-app/conversation'
33
+ import { anchorsOf, byOrder, isCommentOn, isReply, orderingMs } from '@estiva-app/conversation'
34
34
 
35
35
  /** Query the relay. Returns matching events; shape mirrors the HTTP bridge. */
36
36
  export type QueryFn = (filters: Record<string, unknown>[]) => Promise<SignedEvent[]>
@@ -357,12 +357,24 @@ function rootOf(event: SignedEvent): string {
357
357
  * discussion. A badge counting them said "3" beside an issue with one comment.
358
358
  * See `@estiva-app/conversation`'s `isCommentOn` for the per-kind rule, which
359
359
  * this passes the owner's declared comment kinds (§7.3).
360
+ *
361
+ * ## `replies`: the threads under those comments too (CON-34)
362
+ *
363
+ * A dot judges replies by their thread (SPEC §11.3), and a reply never comes
364
+ * back for `#a`: its lowercase tags name its parent comment, and the file is
365
+ * only in its uppercase `A` (§6.4). Asked with `replies`, each file gets a
366
+ * second filter by `#A`, and a reply is kept when its root is one of the
367
+ * comments this read found for the file — the root decides (C11), so a reply
368
+ * in a thread that only mentions the file, or under a root older than the
369
+ * limit, is not here. The messages are then roots and replies, told apart by
370
+ * `root === id`; a consumer that counts comments must not ask for them.
360
371
  */
361
372
  export async function conversationsOf(
362
373
  files: ForeignObject[],
363
374
  query: QueryFn,
364
375
  /** Warm from the read that produced these files; see {@link ProjectionCache}. */
365
376
  cache?: ProjectionCache,
377
+ options: { replies?: boolean } = {},
366
378
  ): Promise<Record<string, ConversationMessage[]>> {
367
379
  const addressed = files.flatMap((file) => {
368
380
  if (!file.address) return []
@@ -410,16 +422,31 @@ export async function conversationsOf(
410
422
  const conversations: Record<string, ConversationMessage[]> = {}
411
423
  for (const a of asked) conversations[a.ref] = []
412
424
 
425
+ const filters: Record<string, unknown>[] = asked.flatMap((a) =>
426
+ options.replies
427
+ ? [a.filter, { kinds: [KIND_COMMENT], '#A': [a.address], limit: CONVERSATION_LIMIT }]
428
+ : [a.filter],
429
+ )
430
+ /** The file in this list an event is a comment on (§6.4), by every `a` it carries. */
431
+ const commentedFile = (event: SignedEvent): string | undefined =>
432
+ event.tags
433
+ .filter((t) => t[0] === 'a' && t[1] && refOf.has(t[1]) && isCommentOn(event, t[1], kindsOf.get(t[1])))
434
+ .map((t) => refOf.get(t[1]))
435
+ .find((found) => found !== undefined)
436
+ /** Replies, kept until every root is in: which file a reply is in is its root's. */
437
+ const replies: SignedEvent[] = []
413
438
  const seen = new Set<string>()
414
- for (let start = 0; start < asked.length; start += MAX_FILTERS_PER_QUERY) {
415
- const events = await query(
416
- asked.slice(start, start + MAX_FILTERS_PER_QUERY).map((a) => a.filter),
417
- )
439
+ for (let start = 0; start < filters.length; start += MAX_FILTERS_PER_QUERY) {
440
+ const events = await query(filters.slice(start, start + MAX_FILTERS_PER_QUERY))
418
441
  for (const event of events) {
419
442
  // A relay may answer one event under two filters; counting it twice would
420
443
  // inflate the badge above what the panel then shows.
421
444
  if (seen.has(event.id)) continue
422
445
  seen.add(event.id)
446
+ if (options.replies && isReply(event)) {
447
+ replies.push(event)
448
+ continue
449
+ }
423
450
  /*
424
451
  Every `a` tag, not the first one.
425
452
 
@@ -434,15 +461,47 @@ export async function conversationsOf(
434
461
  came back for both; it belongs to the one whose discussion it is, and to
435
462
  neither when it merely mentions them. `isCommentOn` is §6.4's rule.
436
463
  */
437
- const ref = event.tags
438
- .filter((t) => t[0] === 'a' && t[1] && refOf.has(t[1]) && isCommentOn(event, t[1], kindsOf.get(t[1])))
439
- .map((t) => refOf.get(t[1]))
440
- .find((found) => found !== undefined)
464
+ const ref = commentedFile(event)
441
465
  if (ref !== undefined) {
442
466
  conversations[ref].push({ id: event.id, at: event.created_at, by: event.pubkey, root: rootOf(event) })
443
467
  }
444
468
  }
445
469
  }
470
+ if (replies.length > 0) {
471
+ /*
472
+ Each root by its own id only, never by the event its `E` names: any comment
473
+ on another file could carry this thread's root there and take its replies
474
+ (review, foundation#112). The ids are unique, so nothing overwrites.
475
+ */
476
+ const fileOfRoot = new Map<string, string>()
477
+ for (const [ref, messages] of Object.entries(conversations)) {
478
+ for (const m of messages) if (m.root === m.id) fileOfRoot.set(m.id, ref)
479
+ }
480
+ const addressOf = new Map(asked.map((a) => [a.ref, a.address]))
481
+ // A reply in a file's thread names that file in its `A` (§6.4), so one that
482
+ // does not is not counted there, whatever root it claims.
483
+ const inList = replies.filter((event) => anchorsOf(event).some((address) => refOf.has(address)))
484
+ /*
485
+ A new reply in an old thread: its root is past the `#a` limit, so this
486
+ read did not find it — on a busy file, exactly the reply the dot exists
487
+ for. Those roots are asked by id in one request, capped at the limit so
488
+ replies naming made-up roots cannot multiply the reads, and decide as any
489
+ root does (C11). Listed for attribution only, not as messages.
490
+ */
491
+ const missing = [...new Set(inList.map(rootOf).filter((root) => !fileOfRoot.has(root)))].slice(0, CONVERSATION_LIMIT)
492
+ if (missing.length > 0) {
493
+ for (const root of await query([{ ids: missing, limit: missing.length }])) {
494
+ const ref = commentedFile(root)
495
+ if (ref !== undefined && !fileOfRoot.has(root.id)) fileOfRoot.set(root.id, ref)
496
+ }
497
+ }
498
+ for (const event of inList) {
499
+ const root = rootOf(event)
500
+ const ref = fileOfRoot.get(root)
501
+ if (ref === undefined || !anchorsOf(event).includes(addressOf.get(ref) as string)) continue
502
+ conversations[ref].push({ id: event.id, at: event.created_at, by: event.pubkey, root })
503
+ }
504
+ }
446
505
  for (const messages of Object.values(conversations)) messages.sort((a, b) => a.at - b.at || (a.id < b.id ? -1 : 1))
447
506
  return conversations
448
507
  }
package/src/references.ts CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  fileReference,
18
18
  KIND_CHANGE,
19
19
  referenceMatch,
20
+ refMatch,
20
21
  type ReferenceCandidate,
21
22
  type ReferenceType,
22
23
  } from '@estiva-app/conversation'
@@ -51,6 +52,13 @@ const offerable = (object: ForeignObject | null | undefined): object is Addresse
51
52
  typeOf(object.kind) !== undefined &&
52
53
  !!object.slots.title?.value.trim()
53
54
 
55
+ /**
56
+ * An issue's current ref (`CON-33`, SPEC §6.1) — the manifest slot that folds
57
+ * the `ref` field — so typing it finds the issue. Only an issue has one.
58
+ */
59
+ const refOf = (object: ForeignObject): string | undefined =>
60
+ object.kind === KIND_ISSUE ? object.meta.find((slot) => slot.field === 'ref')?.value.trim() || undefined : undefined
61
+
54
62
  export interface FileCandidatesOptions {
55
63
  cache?: ProjectionCache
56
64
  /** When each address was last written or read, in seconds — newer first within a tier. */
@@ -86,14 +94,17 @@ export async function fileCandidates(
86
94
  }
87
95
  return files.map((o) => {
88
96
  const parent = o.kind === KIND_ISSUE && o.parentRef ? parents.get(o.parentRef) : undefined
97
+ const ref = refOf(o)
89
98
  return {
90
99
  id: o.address,
91
100
  uri: fileReference(o.address),
92
101
  type: typeOf(o.kind)!,
93
102
  kind: o.kind,
94
103
  title: o.slots.title!.value,
95
- caption: parent?.slots.title?.value ?? '',
104
+ // An issue reads "CON-33 · Conversation standard": the ref first, so a hit by ref shows it (Miky, 2026-10-05).
105
+ caption: [ref, parent?.slots.title?.value].filter(Boolean).join(' · '),
96
106
  tier,
107
+ ...(ref ? { search: ref } : {}),
97
108
  ...(isClosedStatus(o.slots.status) ? { closed: true } : {}),
98
109
  ...(o.archived || parent?.archived ? { archived: true } : {}),
99
110
  ...(at?.has(o.address) ? { at: at.get(o.address) } : {}),
@@ -109,14 +120,22 @@ export interface SearchFileReferencesOptions extends Omit<FileCandidatesOptions,
109
120
  const tagOf = (event: { tags: string[][] }, name: string) => event.tags.find((t) => t[0] === name)?.[1]
110
121
 
111
122
  /**
112
- * The files whose **current** title holds `text`, as the search tier.
123
+ * The file a `kind:1851` hit names, when it is one the relay indexes for `[`
124
+ * (SPEC §5.2): a title change on any file, a ref change only on an issue.
125
+ */
126
+ const searchedChange = (field: string | undefined, address: string | undefined) =>
127
+ field === 'title' || (field === 'ref' && address?.startsWith(`${KIND_ISSUE}:`)) ? address : undefined
128
+
129
+ /**
130
+ * The files whose **current** title — or, for an issue, current ref (CON-33)
131
+ * — holds `text`, as the search tier.
113
132
  *
114
- * The relay indexes a root's `title` and a rename's `value` (relay ticket
115
- * 6fea004e); neither is the current title on its own — a root keeps the name
116
- * it was created with, and a rename found by an old word may since have been
117
- * renamed again. So a hit is only an address: each is read back as its root
118
- * and changes, folded through its app's manifest, and kept only when what it
119
- * is called now matches what was typed.
133
+ * The relay indexes a root's `title` and `ref` and a change's `value` for those
134
+ * fields (SPEC §5.2); none is the current one on its own — a root keeps the
135
+ * name it was created with, and a rename found by an old word may since have
136
+ * been renamed again. So a hit is only an address: each is read back as its
137
+ * root and changes, folded through its app's manifest, and kept only when what
138
+ * it is called now matches what was typed.
120
139
  *
121
140
  * Roots and renames are asked for separately, so a burst of renames cannot
122
141
  * crowd every root out of the answer, and with buzz's prefix mode, so the word
@@ -140,15 +159,13 @@ export async function searchFileReferences(
140
159
  for (const hit of hits) {
141
160
  const address =
142
161
  hit.kind === KIND_CHANGE
143
- ? tagOf(hit, 'field') === 'title'
144
- ? tagOf(hit, 'a')
145
- : undefined
162
+ ? searchedChange(tagOf(hit, 'field'), tagOf(hit, 'a'))
146
163
  : typeOf(hit.kind) && `${hit.kind}:${hit.pubkey}:${tagOf(hit, 'd') ?? ''}`
147
164
  if (!address || !typeOf(Number(address.split(':')[0]))) continue
148
165
  at.set(address, Math.max(at.get(address) ?? 0, hit.created_at))
149
166
  }
150
167
  if (at.size === 0) return []
151
168
  const objects = await resolveForeignRoots([...at.keys()], query, options.cache)
152
- const matching = objects.filter((o) => o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0)
169
+ const matching = objects.filter((o) => (o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0) || refMatch(refOf(o), wanted) > 0)
153
170
  return fileCandidates(matching, FILE_TIER.search, query, { ...options, at })
154
171
  }