Fix portal assets and QA action authentication
Test, build, and deploy ComfyUI Jobs / test-build (push) Failing after 25s
Test, build, and deploy ComfyUI Jobs / deploy (push) Skipped
Test, build, and deploy ComfyUI Jobs / browser-test (push) Skipped
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 4s

This commit is contained in:
2026-10-26 14:43:42 +00:00
parent 96be6412a8
commit a3ce474996
3 changed files with 19 additions and 4 deletions
+2 -2
View File
@@ -180,7 +180,7 @@ jobs:
- name: Track browser failures in Gitea
if: always()
env:
GITEA_API_TOKEN: ${{ secrets.COMFYUI_PORTAL_ISSUE_TOKEN }}
GITEA_API_TOKEN: ${{ github.token }}
GITEA_REPOSITORY: ${{ gitea.repository }}
GITEA_RUN_ID: ${{ gitea.run_id }}
GITEA_SHA: ${{ gitea.sha }}
@@ -203,6 +203,6 @@ jobs:
github-server-url: https://git.dumas.ddns.net
- name: Check automated QA blockers
env:
GITEA_API_TOKEN: ${{ secrets.COMFYUI_PORTAL_ISSUE_TOKEN }}
GITEA_API_TOKEN: ${{ github.token }}
GITEA_REPOSITORY: ${{ gitea.repository }}
run: npm run qa:gate
+1 -1
View File
@@ -119,8 +119,8 @@ app.post('/api/comfy/switch-version', async (req, res) => { const user = require
app.get('/api/jobs/:promptId', async (req, res) => { if (!requireUser(req, res)) return; try { const history = await comfyJson(`/history/${encodeURIComponent(req.params.promptId)}`); const entry = history?.[req.params.promptId] || history; if (!entry) return res.status(404).json({ error: 'Job not found' }); res.json({ job: jobFromHistory(req.params.promptId, entry) }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI job' }); } });
app.get('/api/assets/meta', async (req, res) => { if (!requireUser(req, res)) return; const filename = String(req.query.filename || ''); const subfolder = String(req.query.subfolder || ''); const type = String(req.query.type || 'output'); if (!filename || !['output', 'input', 'temp'].includes(type) || filename.includes('..') || subfolder.includes('..')) return res.status(400).json({ error: 'Invalid asset reference' }); try { const response = await fetch(comfyUrl(`/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${encodeURIComponent(type)}`)); if (!response.ok) return res.status(response.status).json({ error: 'Asset unavailable' }); const buffer = Buffer.from(await response.arrayBuffer()); let width = null; let height = null; try { const image = await sharp(buffer).metadata(); width = image.width || null; height = image.height || null; } catch { /* Video metadata is not available from sharp. */ } res.json({ width, height, sizeBytes: buffer.length }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read asset metadata' }); } });
app.get('/api/assets', async (req, res) => { if (!requireUser(req, res)) return; const filename = String(req.query.filename || ''); const subfolder = String(req.query.subfolder || ''); const type = String(req.query.type || 'output'); if (!filename || !['output', 'input', 'temp'].includes(type) || filename.includes('..') || subfolder.includes('..')) return res.status(400).json({ error: 'Invalid asset reference' }); try { const response = await fetch(comfyUrl(`/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${encodeURIComponent(type)}`)); if (!response.ok) return res.status(response.status).send('Asset unavailable'); res.setHeader('Content-Type', response.headers.get('content-type') || 'application/octet-stream'); res.setHeader('Content-Disposition', 'inline'); res.setHeader('Cache-Control', 'private, max-age=300'); res.send(Buffer.from(await response.arrayBuffer())); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI asset' }); } });
app.use((req, res, next) => { if (req.path.startsWith('/login') || req.path.startsWith('/api/')) return next(); if (!currentUser(req)) return res.redirect('/login'); next(); });
app.use(express.static(browserDir, { index: false }));
app.use((req, res, next) => { if (req.path.startsWith('/login') || req.path.startsWith('/api/')) return next(); if (!currentUser(req)) return res.redirect('/login'); next(); });
app.use((_req, res) => { if (!fs.existsSync(indexHtml)) return res.status(500).send('Build output missing.'); res.type('html').send(fs.readFileSync(indexHtml, 'utf8')); });
if (require.main === module) { startComfyProgressSocket(); app.listen(port, () => console.log(`ComfyUiPortal Next listening on ${port}`)); }
module.exports = { app, jobFromHistory, statusFromHistory };
+16 -1
View File
@@ -1,6 +1,21 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { jobFromHistory, statusFromHistory } = require('./server');
const fs = require('node:fs');
const path = require('node:path');
const { app, jobFromHistory, statusFromHistory } = require('./server');
test('serves frontend assets before authentication redirects', async (t) => {
const server = app.listen(0);
t.after(() => server.close());
await new Promise((resolve) => server.once('listening', resolve));
const port = server.address().port;
const index = fs.readFileSync(path.join(__dirname, 'frontend', 'dist', 'browser', 'index.html'), 'utf8');
const asset = index.match(/src="([^"]+\.js)"/)?.[1];
assert.ok(asset, 'the built frontend should reference a JavaScript asset');
const response = await fetch(`http://127.0.0.1:${port}/${asset}`);
assert.equal(response.status, 200);
assert.match(response.headers.get('content-type') || '', /javascript/);
});
test('maps completed ComfyUI history into a read-only job summary', () => {
const job = jobFromHistory('abc123', { prompt: [1, 'abc123', { '7': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: 'portrait.safetensors' } } }, { title: 'Portrait' }], status: { completed: true, messages: [['execution_start', { timestamp: 1000 }], ['execution_success', { timestamp: 3250 }]] }, outputs: { '7': { images: [{ filename: 'result.png', subfolder: '', type: 'output' }] } } });