Skip to content

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

address review (claude): parse every tqdm frame in a \r-redrawn chunk

[._.]/ Adam Eivyd6cf4f3e89e2
diff --git a/server/services/imageTo3d/trellis2.js b/server/services/imageTo3d/trellis2.js
index df29246835..8fb6e00fc0 100644
--- a/server/services/imageTo3d/trellis2.js
+++ b/server/services/imageTo3d/trellis2.js
@@ -415,7 +415,11 @@ export function runTrellis2Generate({
const promise = new Promise((resolve, reject) => {
const ingest = (buf) => {
outputTail = appendTail(outputTail, buf);
- for (const line of String(buf).split('\n')) {
+ // Split on \r AND \n: tqdm redraws its sampling bar in place with carriage
+ // returns, so a single chunk can carry several progress frames separated only
+ // by \r. Splitting on \n alone would treat them as one line and parse just the
+ // first (lowest) percent — under-reporting progress during the long sampling phase.
+ for (const line of String(buf).split(/[\r\n]+/)) {
const frame = parseGenerateProgress(line);
if (!frame) continue;
if (frame.assetPath) assetPath = frame.assetPath;
diff --git a/server/services/imageTo3d/trellis2.test.js b/server/services/imageTo3d/trellis2.test.js
index 0930497c1f..d95f6587a2 100644
--- a/server/services/imageTo3d/trellis2.test.js
+++ b/server/services/imageTo3d/trellis2.test.js
@@ -200,6 +200,28 @@ describe('runTrellis2Generate', () => {
]);
});
+ it('parses every tqdm frame in a \\r-redrawn chunk, not just the first', async () => {
+ // tqdm redraws the sampling bar in place with carriage returns, so one stdout
+ // chunk can carry several frames separated only by \r. Progress must reflect the
+ // LAST (highest) frame, not the first — otherwise sampling under-reports.
+ const child = makeChild();
+ const frames = [];
+ const { promise } = runTrellis2Generate({
+ imagePath: 'a.png',
+ outputPath: '/out/a.glb',
+ base: BASE,
+ exists: installed,
+ spawnImpl: () => child,
+ onProgress: (f) => frames.push(f),
+ });
+ child.stdout.emit('data', 'Sampling: 0%\rSampling: 50%\rSampling: 100%\r');
+ child.stdout.emit('data', ' Saved: /out/a.glb\n');
+ child.emit('close', 0);
+ await expect(promise).resolves.toEqual({ assetPath: '/out/a.glb' });
+ // 0/50/100 scale into the [10,50] band → 10/30/50; the last frame is 50.
+ expect(frames.map((f) => f.percent)).toEqual([10, 30, 50, 92]);
+ });
+
it('rejects on a non-zero exit', async () => {
const child = makeChild();
const { promise } = runTrellis2Generate({