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
address review (claude): stop gating the entry walk on runId, which excluded every imported direction
[._.]/ Adam Eivy8b7647002d36
diff --git a/server/services/sprites/walk.js b/server/services/sprites/walk.jsindex 9e709a4394..3aaea3ff5c 100644--- a/server/services/sprites/walk.js+++ b/server/services/sprites/walk.js@@ -118,6 +118,16 @@ function normalizeStripPreview(recordId, run) {return { ...run, stripPreview: { ...run.stripPreview, stripPath } };}+// PortOS stamps `id` on every run record it writes; imported source-pipeline+// records don't carry one at all (see importer.test.js's fixtures). The run+// DIRECTORY is the run id under both layouts, so fall back to it — the client+// keys the run list by `id`, and an undefined id would collide every idless+// run into one entry. In-memory only, like normalizeStripPreview.+function normalizeRunRecord(recordId, run, runDirRel) {+ const withId = run.id ? run : { ...run, id: runDirRel.split('/')[1] };+ return normalizeStripPreview(recordId, withId);+}+// Strip candidates on an imported redraw manifest, in preference order. The// clean straight-alpha derivative comes first so the preview matches native// runs (which are always transparent); the keyed matte is the last resort@@ -163,7 +173,10 @@ async function loadRedrawRun(recordId, direction, entry) {schemaVersion: 1,kind: 'imported-redraw-walk-cycle',status: 'approved',- id: entry.runId,+ // Imported entries carry no runId (it is an approveWalkDirection field),+ // so fall back to the manifest path — stable across reads and unique per+ // direction, which is all the client's list key needs.+ id: entry.runId || manifestRel,characterId: recordId,direction,createdAt: entry.approvedAt,@@ -206,7 +219,7 @@ async function loadRunForEntry(recordId, direction, entry) {const runDirRel = RUN_DIR_MATCH.exec(layoutPath)?.[0];if (runDirRel) {const run = await loadRunRecordAt(recordId, runDirRel);- return run ? normalizeStripPreview(recordId, run) : null;+ return run ? normalizeRunRecord(recordId, run, runDirRel) : null;}return loadRedrawRun(recordId, direction, entry);}@@ -235,7 +248,13 @@ export async function getWalkState(recordId) {// unconditionally — a rejected/pending entry must not surface as an// approved run next to live Generate/Approve buttons. A rejected grok// entry still surfaces via the scan below, with its own real status.- .filter(([, entry]) => entry?.status === 'approved' && entry.runId+ //+ // Deliberately NOT gated on `entry.runId`: that field is written only by+ // approveWalkDirection, so IMPORTED entries — the whole population this+ // read path exists for — never carry one (importer.test.js's walk-set+ // fixtures are runId-less). Gating on it filtered out every imported+ // direction and made the layout dispatch below unreachable for them.+ .filter(([, entry]) => entry?.status === 'approved'&& (entry.runPath || entry.runManifest)).map(([direction, entry]) => loadRunForEntry(recordId, direction, entry)),)).filter(Boolean);@@ -244,10 +263,12 @@ export async function getWalkState(recordId) {const scannedRuns = (await Promise.all((await scanPromise).filter((e) => e.isDirectory() && e.name.startsWith('walk-') && !resolvedRunIds.has(e.name))- .map((e) => loadRunRecord(recordId, e.name)),+ .map((e) => loadRunRecord(recordId, e.name)+ .then((run) => (run ? normalizeRunRecord(recordId, run, runRelPath(e.name)) : null))),)).filter(Boolean)- .filter((run) => !resolvedRunIds.has(run.id))- .map((run) => normalizeStripPreview(recordId, run));+ // Second pass: a record whose own `id` differs from its directory name is+ // already covered by an entry that named it by id.+ .filter((run) => !resolvedRunIds.has(run.id));const allRuns = [...entryRuns, ...scannedRuns].sort((a, b) => runCreatedAtMs(b.createdAt) - runCreatedAtMs(a.createdAt));diff --git a/server/services/sprites/walk.test.js b/server/services/sprites/walk.test.jsindex 53bb42f791..c357452041 100644--- a/server/services/sprites/walk.test.js+++ b/server/services/sprites/walk.test.js@@ -471,6 +471,51 @@ describe('getWalkState', () => {});});+ // The shape the importer ACTUALLY writes: `runId` is stamped only by+ // approveWalkDirection, so a copied source-pipeline walk set carries just+ // status/runPath/runManifest (see importer.test.js's fixtures). Gating the+ // entry walk on `entry.runId` would filter out every imported direction —+ // exactly the population this read path exists for.+ it('resolves an imported entry that carries no runId, keying the run by its directory', async () => {+ const id = await characterWithLockedAnchors(newId(), ['east']);+ const runId = 'walk-east-noid0001';+ const runDir = join(TEST_ROOT, 'sprites', id, 'runs', runId, 'generated');+ await mkdir(runDir, { recursive: true });+ await writeFile(join(runDir, 'strip.png'), 'imported-strip');+ // Imported run records carry no `id` field either.+ await writeFile(join(TEST_ROOT, 'sprites', id, 'runs', runId, 'animation-run.json'), JSON.stringify({+ kind: 'grok-walk-animation-run',+ status: 'candidate',+ characterId: id,+ direction: 'east',+ stripPreview: {+ path: `art-source/sprites/${id}/runs/${runId}/generated/strip.png`,+ frameCount: 8, fps: 12, cellWidth: 384, cellHeight: 384, row: 0, startColumn: 0,+ },+ }));+ await mkdir(join(TEST_ROOT, 'sprites', id, 'walk'), { recursive: true });+ await writeFile(join(TEST_ROOT, 'sprites', id, 'walk', `${id}-walk-selection-v1.json`), JSON.stringify({+ schemaVersion: 1,+ kind: 'reviewed-directional-walk-selection',+ characterId: id,+ status: 'in-progress',+ directions: {+ east: {+ status: 'approved',+ runPath: `art-source/sprites/${id}/runs/${runId}`,+ runManifest: `art-source/sprites/${id}/runs/${runId}/generated/manifest.json`,+ },+ },+ }));++ const { runs } = await getWalkState(id);+ expect(runs).toHaveLength(1);+ // The run directory IS the run id under both layouts, so an idless+ // imported record still gets a stable key for the client's list.+ expect(runs[0].id).toBe(runId);+ expect(runs[0].stripPreview.stripPath).toBe(`runs/${runId}/generated/strip.png`);+ });+// A `runs/`-layout entry whose record is missing on disk must surface// nothing rather than a half-shaped run — the grok scan can't cover it.it('surfaces nothing for a runs/<run-id>/ entry with no run record on disk', async () => {@@ -577,6 +622,25 @@ describe('getWalkState', () => {expect(runs[0].postprocessManifest).toBeUndefined();});+ // Same importer-shape guard as the runs/ layout above: a copied redraw+ // entry has no runId, so the synthesized run keys off its manifest path.+ it('synthesizes a redraw run for an imported entry that carries no runId', async () => {+ const id = newId();+ await characterWithRedrawEast(id);+ const selectionAbs = join(TEST_ROOT, 'sprites', id, 'walk', `${id}-walk-selection-v1.json`);+ const selection = JSON.parse(await readFile(selectionAbs, 'utf8'));+ delete selection.directions.east.runId;+ await writeFile(selectionAbs, JSON.stringify(selection));++ const { runs } = await getWalkState(id);+ expect(runs).toHaveLength(1);+ expect(runs[0]).toMatchObject({+ id: REDRAW_MANIFEST_REL,+ kind: 'imported-redraw-walk-cycle',+ stripPreview: { stripPath: 'imagegen/v19/clean-alpha.png', frameCount: 12 },+ });+ });+it('ignores a traversal-shaped runManifest', async () => {const id = newId();await characterWithRedrawEast(id);