nyxcore-systems
6 min read

Late-Night Code Sprints: Fortifying nyxCore with Smart Workflows, Persistent Reports & Rock-Solid Live Updates

A deep dive into a recent development sprint where we tackled critical bug fixes, introduced powerful reporting features, and refined our AI-driven workflow engine for a more robust and user-friendly experience in nyxCore.

AIDevelopmentFrontendBackendPrismaSSEPDFRefactoringWorkflowTech DebtTypeScriptPython

The late hours of a development session often yield some of the most satisfying breakthroughs. This past week, we dove deep into nyxCore, our AI-powered development assistant, with a clear mission: enhance reliability, empower users with better reporting, and make our AI workflows even smarter. It was a session filled with both "aha!" moments and a few head-scratching challenges, but we emerged stronger, pushing a significant set of improvements to production.

The Mission: A More Robust & Intelligent nyxCore

Our primary goals for this sprint were ambitious:

  • Solve the dreaded SSE reconnect issue for our auto-fix and refactor features, ensuring live updates are truly live.
  • Inject context automatically into custom AI workflows, making them more intuitive and powerful.
  • Introduce report persistence and PDF export, transforming ephemeral insights into shareable documents.
  • Refine our UI for a more polished user experience.

And I'm thrilled to report: mission accomplished!

The Breakthroughs: What We Shipped

Let's unpack the key features and fixes that went live:

1. Smarter AI Workflow Context Injection

One of the core strengths of nyxCore is its ability to drive custom AI workflows. We wanted to make these even more seamless. Now, our workflow engine automatically injects relevant context (like previous step outputs) into prompts.

  • How it works: We implemented buildAutoContext() in src/server/services/workflow-engine.ts. This proactively gathers information from earlier steps.
  • The fallback: If a prompt doesn't explicitly reference {{steps.*}}, resolvePrompt() now intelligently looks for available context, ensuring the AI always has a rich understanding of the current state.
  • Impact: Developers can now build more sophisticated custom workflows with less manual prompt engineering, leading to more accurate and relevant AI outputs.

2. Bulletproof Live Updates with SSE Reconnect

Imagine initiating an auto-fix or refactor, switching tabs for a moment, and coming back to a frozen progress bar. That was the challenge with our Server-Sent Events (SSE) for auto-fix and refactor operations.

  • The Problem: Our SSE endpoints for these features would send a one-shot "refresh" message and then close if the run wasn't pending. If a user disconnected (e.g., switched tabs) and reconnected, the server-side pipeline was still running, but the client would hit a status !== "pending" guard on reconnect and get no further updates.
  • The Fix: We've refactored src/app/api/v1/events/auto-fix/[id]/route.ts and src/app/api/v1/events/refactor/[id]/route.ts. Now, for active (non-terminal) runs, the client will poll the database every 3 seconds to fetch the latest status. Once a run reaches a terminal state, a final done event is explicitly sent.
  • Impact: Users now experience truly live, uninterrupted updates, even if they navigate away and return. No more guessing if your AI-driven fix is still running!

3. Reports Reimagined: Persistence & PDF Export

Previously, generated reports were ephemeral. Now, they're a first-class citizen in nyxCore.

  • Report Persistence: We introduced a new Report Prisma model with robust Row-Level Security (RLS). All generateReport mutations now automatically persist the report to the database. This means you can revisit past insights anytime.
  • Comprehensive Report Management: A new tRPC router (src/server/trpc/routers/reports.ts) provides full CRUD operations (list, get, delete) for your saved reports.
  • One-Click PDF Export: This was a big one! We built scripts/md2pdf.py using md2pdf-mermaid and Playwright Chromium. This script converts our Markdown reports (including Mermaid diagrams!) into professional-looking PDFs.
  • Integrated Download: A new /api/v1/reports/pdf POST endpoint allows for seamless PDF generation. Users can now download both the raw Markdown and a polished PDF directly from the ReportGeneratorModal and the ReportsTab viewer Sheet.
  • Enhanced Report Header: The ReportGeneratorModal header now dynamically displays projectName + reportType + date instead of a static "nyxCore," providing immediate context.

4. Minor but Mighty Tweaks

  • QR Code URL Update: The QR code for reports now points to nyxcore.cloud, reflecting our new domain.
  • .venv/ in .gitignore: A small but important housekeeping item to keep our repository clean.

Lessons from the Trenches: Our Debugging Diaries

Not everything was smooth sailing. We hit a couple of recurring snags that serve as valuable reminders for any developer working with complex stacks:

The Prisma Migration Tango: db push vs. Custom Types

  • The Challenge: After adding the new Report model to our Prisma schema, a prisma db push --accept-data-loss (which we sometimes use in dev for quick iterations) would drop our critical embedding vector(1536) column on the workflow_insights table. This is because vector is an unsupported type by Prisma's migration engine, so it assumes it's a "foreign" column to be removed.
  • The Workaround & Lesson: We had to develop a specific post-migration step: ALTER TABLE workflow_insights ADD COLUMN IF NOT EXISTS embedding vector(1536); followed by recreating the HNSW index.
  • Key Takeaway: Always be mindful of how your ORM handles custom database types. Sometimes, manual schema adjustments or specific migration strategies are needed post-db push to preserve specialized columns.

The Missing Prisma Client: Cannot read properties of undefined

  • The Challenge: After adding the Report model, attempts to generate a report immediately failed with Cannot read properties of undefined (reading 'create') in our auto-fix.ts service.
  • The Root Cause: The Prisma client wasn't regenerated, so it didn't "know" about the new Report model. Our application code was trying to call prisma.report.create() on an undefined object.
  • The Fix & Lesson: A simple npm run db:generate fixed it, regenerating the Prisma client with the updated schema.
  • Key Takeaway: After any schema change (even a db push), always ensure you run db:generate to keep your Prisma client in sync with your database. Our dev-start.sh script now includes this automatically to prevent future headaches.

What's Next for nyxCore?

With these foundational improvements in place, our gaze turns to the next set of exciting features:

  1. Persona Chooser Refactor: We're building a unified <PersonaPicker> component. This will feature collapsible sections, rich persona cards with portraits, traits, specialization paths, and exp/levels. The goal is to replace all existing persona selectors across the application with a more engaging and informative experience, guiding users through an expert team phd → discuss → best approach → implement pattern.
  2. Report Tab Styling: The new Reports tab in the project detail page needs to look as good as it functions. We'll be giving it a visual overhaul, ensuring it aligns perfectly with the nyx design system.
  3. Testing Custom Workflows: We'll be rigorously testing our new auto-context injection with complex custom workflows (e.g., analyse → review → generate prompt) to ensure maximum reliability and effectiveness.
  4. Exploring RAG for Policy Libraries: We're actively considering a RAG (Retrieval Augmented Generation)-based policy library per tenant (e.g., for DSGVO, ISO 27001 compliance). User feedback confirms RAG is a superior approach to purely LLM-based solutions for this use case.

This session was a testament to the continuous evolution of nyxCore. We're committed to building a robust, intelligent, and user-friendly platform that empowers developers to do their best work. Stay tuned for more updates as we continue to push the boundaries!