Skip to content

feat(ppt): Add PPT generation content planner - #786

Merged
murdore merged 1 commit into
juspay:releasefrom
Tafheem-Ahemad-Juspay:release
Jan 23, 2026
Merged

murdore merged 1 commit into
juspay:releasefrom
Tafheem-Ahemad-Juspay:release

Conversation

@Tafheem-Ahemad-Juspay

@Tafheem-Ahemad-Juspay Tafheem-Ahemad-Juspay commented Jan 22, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Description

What does this PR do?

Adds comprehensive foundation for AI-powered PowerPoint presentation generation using pptxgenjs. This PR establishes constants, content planning, and validation needed for the PPT generation pipeline.

Related Issues

Does this PR close any issues?

Fixes #(issue number)
Closes #(issue number)
Relates to #(issue number)

Type of Change

Please select the type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement
  • Build/CI configuration
  • Other (please describe):

Motivation and Context

Why is this change needed? What problem does it solve?

Provide context for reviewers:

  • Background information
  • Use case or scenario
  • Links to relevant discussions or documentation
  • Screenshots/GIFs (if UI-related)

Changes Made

What specific changes were made?

Provide a bullet-point list of the key changes:

  • Added X functionality to Y component
  • Modified Z behavior to handle edge case A
  • Updated documentation in file B
  • Refactored C for better performance

Breaking Changes

Does this PR introduce breaking changes?

  • No breaking changes
  • Yes, breaking changes (describe below)

If yes, describe:

  • What breaks?
  • Migration path for users
  • Deprecation warnings added?

Testing

How has this been tested?

Please describe the tests you ran and their results:

  • Unit tests added/updated
  • Integration tests added/updated
  • E2E tests pass
  • Manual testing completed
  • Tested with multiple providers: [list providers]
  • Tested on multiple platforms: [list platforms]

Test Coverage

  • All new code is covered by tests
  • Existing tests pass
  • Coverage percentage maintained or improved

Manual Testing Steps

Provide steps for manual testing:

  1. Set up environment with [...]
  2. Run command [...]
  3. Verify that [...]
  4. Check that [...]

Code Quality

Have you followed code quality standards?

  • Code follows the project's style guidelines (ESLint passes)
  • Code is properly formatted (Prettier applied)
  • Self-review of code completed
  • No console.log statements (using logger instead)
  • No hardcoded API keys or secrets
  • TypeScript strict mode compliance
  • Proper error handling implemented
  • TODO/FIXME comments reference issues

Documentation

Have you updated documentation?

  • JSDoc comments added/updated for public APIs
  • README.md updated (if needed)
  • Documentation in /docs updated (if needed)
  • Code examples added/updated (if needed)
  • CHANGELOG.md updated (if applicable)
  • Migration guide provided (if breaking changes)

Commit Message Format

Does your commit follow semantic commit conventions?

  • Commit message follows format: type(scope): description
  • Valid type used: feat, fix, docs, style, refactor, test, chore, build, ci, perf, revert
  • Scope specified (e.g., providers, cli, docs, middleware)

Example: feat(providers): add support for LiteLLM proxy

Dependencies

Does this PR add, update, or remove dependencies?

  • No dependency changes
  • Dependencies added (list below)
  • Dependencies updated (list below)
  • Dependencies removed (list below)

If yes, list dependencies and justification:

package-name@version - Reason for adding/updating

Performance Impact

Does this change affect performance?

  • No performance impact
  • Performance improved (provide metrics)
  • Performance degraded (justify why acceptable)

If applicable, provide benchmark results:

Before: X ms
After: Y ms
Improvement: Z%

Security Considerations

Are there any security implications?

  • No security implications
  • Security review needed
  • Security vulnerability fixed

If applicable, describe:

  • Security measures implemented
  • Potential risks mitigated
  • Compliance considerations (HIPAA, SOC2, GDPR)

Deployment Notes

Special deployment instructions?

  • No special deployment steps
  • Requires environment variable changes (list below)
  • Requires database migration
  • Requires Redis schema update
  • Other (describe below)

Screenshots / Videos

If applicable, add screenshots or videos to demonstrate changes:

[Add screenshots or videos here]

Reviewer Checklist

For reviewers:

  • Code follows project style and conventions
  • Changes are well-documented
  • Tests provide adequate coverage
  • No obvious performance issues
  • No security vulnerabilities introduced
  • Breaking changes are properly documented
  • Documentation is clear and accurate

Additional Notes

Any additional information for reviewers:

[Add any extra context, concerns, or questions here]


Pre-submission Checklist

Before submitting, ensure you have:

  • Read and followed the Contributing Guidelines
  • Verified all automated pre-commit checks pass
  • Tested changes locally with pnpm test
  • Built the project successfully with pnpm build
  • Run pnpm run validate:all and all checks pass
  • Reviewed your own code for obvious issues
  • Ensured commit messages follow semantic format
  • Updated relevant documentation
  • Added tests for new functionality
  • Checked that CI/CD pipeline passes (after creating PR)

Thank you for contributing to NeuroLink!

Summary by CodeRabbit

  • New Features
    • Add PPT generation with five design themes and theme-aware image styling.
    • AI-driven content planning producing structured slide plans with titles, layouts, speaker notes, and image prompts.
    • Audience and tone options to tailor content and messaging.
    • Flexible slide types and layout selection with sensible defaults.
    • Validation for page/topic limits and aspect ratios, plus generation timeouts and concurrency controls.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds a PPT generation feature: new public types and validation, theme/layout/constants, AI-driven content planning with parsing/validation/post-processing, central export barrel, input validation tweaks, and extensive unit tests for the PPT surface.

Changes

Cohort / File(s) Summary
Type System Foundation
src/lib/types/pptTypes.ts
Adds comprehensive PPT public types, error class and codes, validation constants, PPTGenerationContext extraction, and many PPTX-compatible type definitions.
Constants & Configuration
src/lib/features/ppt/constants.ts
New THEMES, layout mappings, slide-type categories (diagram/image), audience/tone guidelines, AI prompt builders, image prompt enhancer, validation lists, and timeouts/concurrency constants.
Content Planning Logic
src/lib/features/ppt/contentPlanner.ts
New generateContentPlan workflow: prompt construction, AI call, response parsing, validation/normalization, and post-processing utilities (ensureTitleSlide, ensureThankYouSlide, postProcessPlan).
Public API Aggregation
src/lib/features/ppt/index.ts, src/lib/features/ppt/types.ts
Barrel modules re-exporting PPT types, constants, and content-planning functions to form the public feature surface.
Parameter Validation Updates
src/lib/utils/parameterValidation.ts
Adds defaulting/suggestion logic for PPT options (theme, audience, tone) when omitted.
Test Coverage
test/unit/ppt-generation.test.ts
Large suite of unit tests covering types, themes, layouts, prompts, validation, error handling, context extraction, and edge cases.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ContentPlanner as Content Planner
    participant Constants
    participant AIProvider as AI Provider
    participant Parser
    participant Validator

    Client->>ContentPlanner: generateContentPlan(context, provider)
    ContentPlanner->>Constants: buildContentPlanningPrompt(context)
    Constants-->>ContentPlanner: structured prompt
    ContentPlanner->>AIProvider: call with prompt
    AIProvider-->>ContentPlanner: raw AI response
    ContentPlanner->>Parser: parseAIResponse(response)
    Parser-->>ContentPlanner: parsed JSON
    ContentPlanner->>Validator: validateContentPlan(parsed)
    Validator-->>ContentPlanner: normalized ContentPlan
    ContentPlanner->>ContentPlanner: postProcessPlan (title + thank you slides)
    ContentPlanner-->>Client: validated ContentPlan
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

released

Suggested reviewers

  • murdore

Poem

🐰 Themes in rows and slides in flight,
Prompts prepared by gentle light,
Types snug in tidy stacks,
Slides hop forward—no looking back,
A rabbit cheers the PPT tonight! 🎨✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(ppt): Add PPT generation content planner' accurately describes the main objective—adding a content planner for PPT generation. It is concise, clear, and directly reflects the substantial additions across multiple files (constants, content planning, types, validation).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@src/lib/features/ppt/constants.ts`:
- Around line 441-459: Update the prompt comments and constant identifiers in
src/lib/features/ppt/constants.ts to fix typos and clarify instructions: correct
the misspelled constant name VLAID_THEMES to VALID_THEMES (and update any
references), fix the unclear sentence "if these properties are not mention ,
then chose from the things , else use the user-defined values" to a clear
statement like "If audience, tone, or theme are not provided, select defaults
from VALID_AUDIENCES, VALID_TONES, and VALID_THEMES; otherwise use the
user-provided values", and clean up other minor typos (e.g., "VLAID_THEMES" →
"VALID_THEMES", "mention" → "mentioned", "chose" → "choose", "VLAID"
occurrences) so the SLIDE STRUCTURE and VALID_* arrays (VALID_AUDIENCES,
VALID_TONES) are grammatically correct and unambiguous for the planner.

In `@src/lib/features/ppt/contentPlanner.ts`:
- Around line 347-367: Replace the raw string prompt and direct await of
provider.generate with a MessageBuilder-constructed message and wrap the
provider call with withTimeout; specifically, stop using
buildContentPlanningPrompt to pass a raw prompt into provider.generate and
instead create the messages via MessageBuilder (include the same content that
buildContentPlanningPrompt produced and set the system message to
CONTENT_PLANNING_SYSTEM_PROMPT), then call withTimeout(provider.generate({...})
, CONTENT_PLANNING_TIMEOUT_MS) so the call respects the enforced timeout; keep
the existing provider options (temperature, maxTokens, disableTools) when
invoking provider.generate and reference MessageBuilder, withTimeout,
CONTENT_PLANNING_SYSTEM_PROMPT, CONTENT_PLANNING_TIMEOUT_MS,
buildContentPlanningPrompt (for content to port over), and provider.generate to
locate the changes.

In `@src/lib/types/pptTypes.ts`:
- Around line 661-728: The extraction currently only preserves Buffer logos and
drops string logo paths/URLs; update the PPTGenerationContext.logo type to allow
Buffer | string and modify extractPPTContext to assign pptOptions.logoPath when
it's a string (e.g., else if typeof pptOptions.logoPath === "string" then logo =
pptOptions.logoPath), while keeping the existing branches that handle Buffer and
file-like objects (check "data" field). Ensure the returned object from
extractPPTContext uses this logo value and update any relevant type references
(PPTGenerationContext and usages of logo) so downstream code can accept a string
URL or Buffer.

In `@test/unit/ppt-generation.test.ts`:
- Around line 7-50: The import of PPTOutputOptions in the test file should be a
type-only import because it’s only used in type positions; update the import
statement that currently lists PPTOutputOptions among the values imported from
"../../src/lib/types/pptTypes.js" to use a type-only import (e.g., import type {
PPTOutputOptions } from "...") while leaving the rest of the runtime imports
unchanged so only PPTOutputOptions is imported purely for types.

Comment thread src/lib/features/ppt/constants.ts
Comment thread src/lib/features/ppt/contentPlanner.ts
Comment thread src/lib/types/pptTypes.ts
Comment thread test/unit/ppt-generation.test.ts
@Tafheem-Ahemad-Juspay

Tafheem-Ahemad-Juspay commented Jan 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jan 22, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/lib/features/ppt/constants.ts`:
- Around line 18-149: THEMES currently stores color strings with a leading "#"
which is incompatible with pptxgenjs's expected 6-character hex format; update
the THEMES object (symbol THEMES in src/lib/features/ppt/constants.ts) so all
color values are stored without the "#" prefix, or alternatively ensure any
consumer of themes (e.g., where themes are applied to slides) calls the existing
normalizeHexColor helper before passing values to pptxgenjs; locate uses of
THEMES and the theme application code and either strip the "#" in the THEMES
entries or add normalizeHexColor(...) calls where colors are handed to pptxgenjs
APIs.
♻️ Duplicate comments (2)
src/lib/features/ppt/contentPlanner.ts (1)

347-367: Adopt MessageBuilder + withTimeout for the planning call.

The prompt is built as raw strings and provider.generate is awaited directly. The project guidelines require MessageBuilder for message construction and withTimeout to enforce timeouts even if a provider ignores the timeout option. Based on coding guidelines, route prompt construction through MessageBuilder and wrap the async call with withTimeout.

src/lib/features/ppt/constants.ts (1)

441-459: Fix prompt typos to avoid confusing the planner.

The prompt still contains unclear grammar on line 442: "if these properties are not mention , then chose from the things". This was flagged in a previous review and acknowledged but may not be fully addressed.

🧹 Nitpick comments (4)
src/lib/types/pptTypes.ts (1)

1236-1244: Hex color validation may reject valid shorthand colors.

The isValidHexColor function only accepts 6-character hex codes. While pptxgenjs typically uses 6-character hex without #, consider documenting this constraint clearly or handling 3-character shorthand expansion if users might provide shorthand.

src/lib/features/ppt/contentPlanner.ts (2)

36-125: Duplicate type/layout sets create maintenance risk.

VALID_SLIDE_TYPES and VALID_SLIDE_LAYOUTS duplicate the type definitions from pptTypes.ts. If the SlideType or SlideLayout union types are updated, these sets must be manually synchronized.

Consider deriving these sets from the source of truth or exporting them from pptTypes.ts to avoid drift.

♻️ Suggested approach

Export the valid sets from pptTypes.ts alongside the types:

// In pptTypes.ts
export const ALL_SLIDE_TYPES: readonly SlideType[] = [
  "title", "section-header", /* ... all types */
] as const;

export const ALL_SLIDE_LAYOUTS: readonly SlideLayout[] = [
  "title-centered", "title-bottom", /* ... all layouts */
] as const;

Then import and use in contentPlanner.ts:

import { ALL_SLIDE_TYPES, ALL_SLIDE_LAYOUTS } from "./types.js";
const VALID_SLIDE_TYPES = new Set(ALL_SLIDE_TYPES);
const VALID_SLIDE_LAYOUTS = new Set(ALL_SLIDE_LAYOUTS);

424-448: Helper functions mutate input parameter.

ensureTitleSlide and ensureThankYouSlide modify the plan.slides array in-place via spread assignment to array indices. While the functions return the plan, the mutation side-effect can surprise callers who expect pure functions.

♻️ Suggested immutable approach
 export function ensureTitleSlide(plan: ContentPlan): ContentPlan {
   if (plan.slides.length > 0 && plan.slides[0].type !== "title") {
-    plan.slides[0] = {
-      ...plan.slides[0],
-      type: "title",
-      layout: "title-centered",
-    };
+    const newSlides = [...plan.slides];
+    newSlides[0] = {
+      ...newSlides[0],
+      type: "title",
+      layout: "title-centered",
+    };
+    return { ...plan, slides: newSlides };
   }
   return plan;
 }
test/unit/ppt-generation.test.ts (1)

89-99: Use explicit invalid literal types instead of as any for cleaner test assertions.

Static analysis flags the as any casts. While acceptable in tests for invalid inputs, using explicit string literals with type assertions is more precise and avoids the linter warnings.

♻️ Suggested fix
     it("should reject invalid theme/audience/tone", () => {
       expect(
-        validatePPTOutputOptions({ pages: 10, theme: "invalid" as any }),
+        validatePPTOutputOptions({ pages: 10, theme: "invalid" as PPTOutputOptions["theme"] }),
       ).not.toBeNull();
       expect(
-        validatePPTOutputOptions({ pages: 10, audience: "invalid" as any }),
+        validatePPTOutputOptions({ pages: 10, audience: "invalid" as PPTOutputOptions["audience"] }),
       ).not.toBeNull();
       expect(
-        validatePPTOutputOptions({ pages: 10, tone: "invalid" as any }),
+        validatePPTOutputOptions({ pages: 10, tone: "invalid" as PPTOutputOptions["tone"] }),
       ).not.toBeNull();
     });

Or alternatively, cast the entire object:

validatePPTOutputOptions({ pages: 10, theme: "invalid" } as PPTOutputOptions)

Comment thread src/lib/features/ppt/constants.ts
- Implement AI content planner generating structured ContentPlan from topics
- Add 5 presentation themes (modern, corporate, creative, minimal, dark)
- Add validation with default value suggestions for theme/audience/tone
- Add comprehensive type system aligned with pptxgenjs API (charts, tables, timelines)
@murdore
murdore merged commit 695b92c into juspay:release Jan 23, 2026
7 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 8.38.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants