(
context: SearchContext,
state: SessionState,
)
| 211 | } |
| 212 | |
| 213 | function buildBoundaryLookup( |
| 214 | context: SearchContext, |
| 215 | state: SessionState, |
| 216 | ): Map<string, BoundaryReference> { |
| 217 | const lookup = new Map<string, BoundaryReference>() |
| 218 | |
| 219 | for (const [messageRef, messageId] of state.messageIds.byRef) { |
| 220 | const rawMessage = context.rawMessagesById.get(messageId) |
| 221 | if (!rawMessage) { |
| 222 | continue |
| 223 | } |
| 224 | if (isIgnoredUserMessage(rawMessage)) { |
| 225 | continue |
| 226 | } |
| 227 | |
| 228 | const rawIndex = context.rawIndexById.get(messageId) |
| 229 | if (rawIndex === undefined) { |
| 230 | continue |
| 231 | } |
| 232 | lookup.set(messageRef, { |
| 233 | kind: "message", |
| 234 | rawIndex, |
| 235 | messageId, |
| 236 | }) |
| 237 | } |
| 238 | |
| 239 | const summaries = Array.from(context.summaryByBlockId.values()).sort( |
| 240 | (a, b) => a.blockId - b.blockId, |
| 241 | ) |
| 242 | for (const summary of summaries) { |
| 243 | const anchorMessage = context.rawMessagesById.get(summary.anchorMessageId) |
| 244 | if (!anchorMessage) { |
| 245 | continue |
| 246 | } |
| 247 | if (isIgnoredUserMessage(anchorMessage)) { |
| 248 | continue |
| 249 | } |
| 250 | |
| 251 | const rawIndex = context.rawIndexById.get(summary.anchorMessageId) |
| 252 | if (rawIndex === undefined) { |
| 253 | continue |
| 254 | } |
| 255 | const blockRef = formatBlockRef(summary.blockId) |
| 256 | if (!lookup.has(blockRef)) { |
| 257 | lookup.set(blockRef, { |
| 258 | kind: "compressed-block", |
| 259 | rawIndex, |
| 260 | blockId: summary.blockId, |
| 261 | anchorMessageId: summary.anchorMessageId, |
| 262 | }) |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | return lookup |
| 267 | } |
no test coverage detected