AppView in a box as a Vite plugin thing hatk.dev
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: resolve correct block by CID in firehose commit indexing

The indexer scanned all blocks for the first matching $type, so
multi-record commits (e.g. applyWrites with multiple photos) indexed
every op with the same first block's data. Look up each op's specific
block by its CID instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+27 -25
+1 -1
packages/hatk/package.json
··· 1 1 { 2 2 "name": "@hatk/hatk", 3 - "version": "0.0.1-alpha.56", 3 + "version": "0.0.1-alpha.57", 4 4 "license": "MIT", 5 5 "bin": { 6 6 "hatk": "dist/cli.js"
+26 -24
packages/hatk/src/indexer.ts
··· 433 433 continue 434 434 } 435 435 436 - for (const [cid, data] of blocks) { 437 - try { 438 - const { value: record } = cborDecode(data) 439 - if (record?.$type === collection) { 440 - const validationError = validateRecord(getLexiconArray(), collection, record) 441 - if (validationError) { 442 - emit('indexer', 'validation_skip', { 443 - uri, 444 - collection, 445 - path: validationError.path, 446 - error: validationError.message, 447 - }) 448 - break 449 - } 450 - const item = { collection, uri, cid, authorDid: did, record } 436 + const opCid = typeof op.cid === 'string' ? op.cid : op.cid?.$link 437 + if (!opCid) continue 438 + const data = blocks.get(opCid) 439 + if (!data) continue 451 440 452 - // If DID is mid-backfill, buffer instead of writing directly 453 - if (pendingBuffers.has(did)) { 454 - pendingBuffers.get(did)!.push(item) 455 - } else { 456 - bufferWrite(item) 457 - } 458 - break 441 + try { 442 + const { value: record } = cborDecode(data) 443 + if (record?.$type === collection) { 444 + const validationError = validateRecord(getLexiconArray(), collection, record) 445 + if (validationError) { 446 + emit('indexer', 'validation_skip', { 447 + uri, 448 + collection, 449 + path: validationError.path, 450 + error: validationError.message, 451 + }) 452 + continue 453 + } 454 + const item = { collection, uri, cid: opCid, authorDid: did, record } 455 + 456 + // If DID is mid-backfill, buffer instead of writing directly 457 + if (pendingBuffers.has(did)) { 458 + pendingBuffers.get(did)!.push(item) 459 + } else { 460 + bufferWrite(item) 459 461 } 460 - } catch {} 461 - } 462 + } 463 + } catch {} 462 464 } 463 465 }