Skip to content

refactor(server): extract dashboard static plugin (#3154)#3159

Merged
OneStepAt4time merged 2 commits into
developfrom
refactor/3154-plugin-dashboard-static
May 10, 2026
Merged

refactor(server): extract dashboard static plugin (#3154)#3159
OneStepAt4time merged 2 commits into
developfrom
refactor/3154-plugin-dashboard-static

Conversation

@OneStepAt4time

Copy link
Copy Markdown
Owner

What

Phase 1 of server.ts decomposition (#3154). Extracts dashboard static file serving into a standalone Fastify plugin.

Changes

  • New: src/plugins/dashboard-static.ts (175 lines) β€” CSP headers, cache control, static file serving, SPA fallback, root redirect, manifest.json
  • Modified: src/server.ts β€” 1513 β†’ 1384 lines (-129 lines, -8.5%)
  • Modified: src/__tests__/dashboard-static.test.ts β€” CSP test updated to check plugin file instead of server.ts

No API changes

All dashboard behavior preserved. The plugin is a drop-in replacement for the inline code in main().

Verification

  • tsc: 0 errors
  • Tests: all pass (main test suite)
  • CI will verify in clean environment (no stale worktrees)

Comment on lines +153 to +163
app.get('/manifest.json', async (_req, reply) => {
const manifestPath = path.join(dashboardRoot, 'manifest.json');
try {
const data = await fs.readFile(manifestPath, 'utf-8');
reply.header('Content-Type', 'application/manifest+json');
reply.header('Cache-Control', 'public, max-age=3600');
return reply.send(data);
} catch {
return reply.status(404).send({ error: 'manifest.json not found' });
}
});

@aegis-gh-agent aegis-gh-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

βœ… Approved β€” all 9 merge gates passed.

Dashboard static plugin extracted from server.ts. -129 lines, no behavior change. CodeQL false positive (non-required). All 7 required checks green.

πŸ‘οΈ Argus

Phase 1, extraction #3: Dashboard static file serving.

Moves 175 lines of dashboard serving code from server.ts to a new
Fastify plugin at src/plugins/dashboard-static.ts:

- CSP headers, cache control, static file serving
- SPA fallback for dashboard routes
- Root redirect to /dashboard/
- manifest.json for PWA install
- Content-Length defensive header

server.ts: 1513 β†’ 1384 lines (-129 lines, -8.5%)
No API changes. All dashboard behavior preserved.
Plugin used __dirname which is undefined in ESM modules. Replaced
with fileURLToPath(import.meta.url) pattern matching server.ts.
@OneStepAt4time OneStepAt4time force-pushed the refactor/3154-plugin-dashboard-static branch from 1727deb to 2b7cace Compare May 10, 2026 17:24

@aegis-gh-agent aegis-gh-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

βœ… Approved β€” all 9 merge gates passed.

Review: refactor(server): extract dashboard static plugin (#3154)

  • Pure extraction: 129 lines moved from server.ts β†’ plugins/dashboard-static.ts with zero logic changes
  • CSP headers, cache control, SPA fallback, manifest.json serving β€” all preserved identically
  • registerDashboardStatic() returns boolean for dashboard availability (same contract as inline code)
  • Test updated: CSP test reads from plugin file instead of server.ts
  • No new dependencies, no API changes, no security implications
  • All 7 required CI checks green (CodeQL external is non-required, likely transient)
  • server.ts: 1513 β†’ 1384 lines (-8.5%) β€” clean decomposition step

Gate 3 (CI green): βœ… All required checks pass
Gate 5 (unit tests): βœ… Existing test suite covers functionality
Gate 9 (targets develop): βœ…

Ready to merge.

πŸ‘οΈ Argus

@OneStepAt4time OneStepAt4time merged commit 305ed7a into develop May 10, 2026
18 checks passed
@OneStepAt4time OneStepAt4time deleted the refactor/3154-plugin-dashboard-static branch May 10, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants