Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
hide child chunk scraps from the user-facing list and stats count
[._.]/ Adam Eivy2f41c552bfbc
diff --git a/server/services/catalogDB.js b/server/services/catalogDB.jsindex c07db65fa4..66e21793d5 100644--- a/server/services/catalogDB.js+++ b/server/services/catalogDB.js@@ -271,10 +271,14 @@ export async function getScrap(id) {return rowToScrap(result.rows[0]);}+// `parent_scrap_id IS NULL` hides child chunk rows from the user-facing list —+// a long paste that chunked into a parent + N children should surface as ONE+// scrap (the parent carries the full text), not N+1 entries. Children are an+// internal extraction detail reached only via listChildScraps.export async function listScraps({ limit = 50, offset = 0 } = {}) {const result = await query(`SELECT * FROM catalog_scraps- WHERE deleted = false+ WHERE deleted = false AND parent_scrap_id IS NULLORDER BY created_at DESCLIMIT $1 OFFSET $2`,[limit, offset],@@ -1515,7 +1519,9 @@ export async function getCatalogBundleForRef(refKind, refId) {export async function getCatalogStats() {const [byTypeResult, scrapResult, withEmb] = await Promise.all([query(`SELECT type, COUNT(*) AS count FROM catalog_ingredients WHERE deleted = false GROUP BY type`),- query(`SELECT COUNT(*) AS count FROM catalog_scraps WHERE deleted = false`),+ // Count only parent/standalone scraps — child chunk rows are an internal+ // extraction detail and would inflate the user-facing scrap count.+ query(`SELECT COUNT(*) AS count FROM catalog_scraps WHERE deleted = false AND parent_scrap_id IS NULL`),query(`SELECT COUNT(*) AS count FROM catalog_ingredients WHERE deleted = false AND embedding IS NOT NULL`),]);const byType = {};diff --git a/server/services/catalogDB.test.js b/server/services/catalogDB.test.jsindex 8f7bdd145d..971ccf8181 100644--- a/server/services/catalogDB.test.js+++ b/server/services/catalogDB.test.js@@ -277,6 +277,15 @@ describe.skipIf(!dbReady)('catalogDB (Postgres CRUD round-trip)', () => {});// Lossless: concatenating child slices reproduces the original text.expect(children.map((c) => c.rawText).join('')).toBe(rawText);++ // The user-facing list hides child chunks — the parent appears, the+ // children do not (they're an internal extraction detail).+ const { items } = await catalogDB.listScraps({ limit: 200 });+ const listedIds = new Set(items.map((s) => s.id));+ expect(listedIds.has(parent.id)).toBe(true);+ for (const child of children) {+ expect(listedIds.has(child.id), `child ${child.id} leaked into listScraps`).toBe(false);+ }});it('exportSliceForRef bundles ingredients + scraps + refs for a ref', async () => {