Skip to content

🚀 release: v1.0.0-beta.6#11

Merged
warengonzaga merged 20 commits intomainfrom
dev
Aug 9, 2025
Merged

🚀 release: v1.0.0-beta.6#11
warengonzaga merged 20 commits intomainfrom
dev

Conversation

@warengonzaga
Copy link
Member

@warengonzaga warengonzaga commented Aug 9, 2025

Summary by CodeRabbit

  • New Features

    • Introduced advanced file attachment correlation, enabling accurate detection and processing of file uploads across platforms.
    • Redis queue events now include detailed attachment metadata (presence, count, size, types, names).
  • Improvements

    • Enhanced webhook processing with buffering and correlation for file events with uncertain sources.
    • Logging improvements for webhook requests, validation errors, and Redis queue operations.
    • Updated environment variable validation for stricter platform specification.
  • Documentation

    • Expanded README with details on file attachment correlation, configuration changes, migration guide, and troubleshooting.
    • Updated .env.example with clearer guidance on required environment variables.
  • Chores

    • Added new chat mode configuration for software development guidance.
    • Updated dependencies and versioning.
    • Ignored new context directory in version control.

warengonzaga and others added 19 commits August 4, 2025 15:13
Bumps [form-data](https://github.com/form-data/form-data) from 4.0.3 to 4.0.4.
- [Release notes](https://github.com/form-data/form-data/releases)
- [Changelog](https://github.com/form-data/form-data/blob/master/CHANGELOG.md)
- [Commits](form-data/form-data@v4.0.3...v4.0.4)

---
updated-dependencies:
- dependency-name: form-data
  dependency-version: 4.0.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
…ata-4.0.4

Bump form-data from 4.0.3 to 4.0.4
Copilot AI review requested due to automatic review settings August 9, 2025 15:03
@warengonzaga warengonzaga self-assigned this Aug 9, 2025
@warengonzaga warengonzaga moved this to In Progress in Unthread Partnership Aug 9, 2025
@warengonzaga warengonzaga moved this from In Progress to In Review in Unthread Partnership Aug 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This is a major feature release (v1.0.0-beta.6) that introduces revolutionary file attachment correlation capabilities to the Unthread webhook server. The release eliminates "unknown" source platform issues for file uploads by implementing intelligent correlation between message events and file attachment events.

Key changes include:

  • File Attachment Correlation System: New utility that links file uploads with their originating platforms using memory-based correlation
  • Enhanced Attachment Metadata: Rich file summaries with counts, sizes, types, and names for easier integration
  • Required TARGET_PLATFORM Configuration: Stricter validation to prevent conflicts with reserved platform values

Reviewed Changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/fileAttachmentCorrelation.ts New correlation utility implementing memory-based caching and buffering for file attachment source detection
src/types/index.ts Enhanced type definitions adding attachment metadata and correlation data structures
src/services/webhookService.ts Integrated correlation system with enhanced platform detection and attachment metadata generation
src/services/redisService.ts Enhanced logging for transformed webhook events
src/controllers/webhookController.ts Improved logging with emoji indicators for better debugging
src/config/env.ts Added TARGET_PLATFORM validation preventing reserved value conflicts
src/app.ts Updated LogEngine configuration for improved local debugging
package.json Version bump to 1.0.0-beta.6 and LogEngine upgrade to 2.2.0
README.md Comprehensive documentation updates highlighting new file correlation features
.github/chatmodes/WG Code Builder.chatmode.md New development chat mode configuration
.env.example Updated with required TARGET_PLATFORM configuration and examples

@coderabbitai
Copy link

coderabbitai bot commented Aug 9, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Sir, this update introduces a comprehensive file attachment correlation system to the Unthread Webhook Server. It refines environment validation, enhances logging, updates documentation, and integrates a new utility for correlating file events with their source platforms. Several configuration, code, and documentation files were modified or added to support these operational advancements.

Changes

Cohort / File(s) Change Summary
Documentation & Configuration
.env.example, README.md, .gitignore, package.json
Updated environment variable documentation and requirements, introduced advanced file attachment correlation feature in documentation, ignored context/ directory, bumped package and dependency versions.
Chat Mode Addition
.github/chatmodes/WG Code Builder.chatmode.md
Added new chat mode configuration for "WG Code Builder," detailing agent behavior, principles, and communication style.
Logging Enhancements
src/app.ts, src/controllers/webhookController.ts, src/services/redisService.ts
Improved logging: configured debug mode, added detailed request and event logs, and refined log messages for event handling and error reporting.
Environment Validation
src/config/env.ts
Enforced strict validation and normalization of the TARGET_PLATFORM environment variable, removing defaults and checking for reserved names.
Type Definitions
src/types/index.ts
Expanded platform source types, introduced attachment metadata interfaces, and added types for file attachment correlation and buffering.
Webhook Service & Correlation Logic
src/services/webhookService.ts, src/utils/fileAttachmentCorrelation.ts
Integrated a new utility for file attachment correlation, added event buffering and correlation logic, enriched event metadata, refactored platform detection, and introduced resource cleanup.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • 🚀 release: v1.0.0-beta.5 #7: Introduced TARGET_PLATFORM as a required environment variable with example values in .env.railway; closely related to environment configuration validation in this update.

Suggested labels

maintainers only, release

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57c39e3 and 7dfe16d.

📒 Files selected for processing (2)
  • src/types/index.ts (3 hunks)
  • src/utils/fileAttachmentCorrelation.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/types/index.ts
  • src/utils/fileAttachmentCorrelation.ts
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai auto title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (12)
.gitignore (1)

143-145: Context folder now ignored — confirm no runtime dependency and mirror in container ignores

Sensible to keep ephemeral correlation/context assets out of VCS, Sir. Please verify nothing in context/ is required at build/test time, and consider adding the same pattern to .dockerignore (and any deployment ignore lists) to keep images lean.

src/config/env.ts (1)

8-29: Solid runtime validation — extract and reuse reserved set for consistency and type-safety

Nicely fail-fast and normalized to lowercase. To avoid drift across files and enable better hinting, hoist the reserved set and reuse it.

Apply:

+// Centralize reserved platforms for reuse across codebase and docs
+export const RESERVED_TARGET_PLATFORMS = ['dashboard', 'unknown', 'buffered'] as const;
+
 function validateTargetPlatform(platform: string | undefined): string {
@@
-    const cleanPlatform = platform.trim().toLowerCase(); // Convert to lowercase for canonical format
-    const reservedPlatforms = ['dashboard', 'unknown', 'buffered'];
+    const cleanPlatform = platform.trim().toLowerCase(); // Convert to lowercase for canonical format
+    const reservedPlatforms = RESERVED_TARGET_PLATFORMS;
.github/chatmodes/WG Code Builder.chatmode.md (1)

80-80: Fix markdownlint MD036: render the quote as a blockquote, not emphasized text

A blockquote reads better and silences lint.

Apply:

-*\"The expert in anything was once a beginner who refused to give up.\" - Helen Hayes*
+> "The expert in anything was once a beginner who refused to give up." — Helen Hayes
src/types/index.ts (4)

56-57: PlatformSource typing: literal union redundancy and intent clarity

string | 'buffered' is effectively just string. If you want to call out reserved sources explicitly, centralize and reuse a reserved set; otherwise, keep it purely string for clarity.

Option A (centralize reserved values):

+export const RESERVED_PLATFORM_VALUES = ['dashboard', 'unknown', 'buffered'] as const;
+export type ReservedPlatform = typeof RESERVED_PLATFORM_VALUES[number];
-export type PlatformSource = string | 'buffered';
+export type PlatformSource = string | ReservedPlatform;

129-134: Use PlatformSource for sourcePlatform

Tighten the type to align with the rest of the model.

Apply:

-export interface FileAttachmentCorrelationEntry {
-  sourcePlatform: string;
+export interface FileAttachmentCorrelationEntry {
+  sourcePlatform: PlatformSource;
   messageEventId: string;
   timestamp: number;
 }

136-146: Timer type compatibility: prefer ReturnType over NodeJS.Timeout

Keeps types portable between Node/DOM typing sets and avoids ambient Node dependency leaks.

Apply:

 export interface FileAttachmentBufferedEvent {
   eventData: UnthreadWebhookEvent;
   correlationKey: string;
   bufferedAt: number;
-  timeoutId: NodeJS.Timeout;
+  timeoutId: ReturnType<typeof setTimeout>;
 }
@@
 export interface FileAttachmentBufferedEvents {
   events: FileAttachmentBufferedEvent[];
-  sharedTimeoutId: NodeJS.Timeout;
+  sharedTimeoutId: ReturnType<typeof setTimeout>;
 }

67-81: AttachmentMetadata naming clarity and forward-compat

Looks good. Minor clarity: types can be misread as TypeScript types. Consider mimeTypes, keeping types as a deprecated alias for a release for non-breaking change.

Apply:

 export interface AttachmentMetadata {
   /** True if data.files array exists and has content, false otherwise */
   hasFiles: boolean;
   /** Number of files in data.files array (0 when hasFiles is false) */
   fileCount: number;
   /** Total size in bytes of all files combined (0 when hasFiles is false) */
   totalSize: number;
-  /** Unique MIME types of all files (empty array when hasFiles is false) */
-  types: string[];
+  /** Unique MIME types of all files (empty array when hasFiles is false) */
+  mimeTypes: string[];
+  /** Deprecated: use mimeTypes */
+  types?: string[];
   /** Names of all files (empty array when hasFiles is false) */
   names: string[];
 }

Follow-up: map types -> mimeTypes at construction time to preserve backward compatibility.

README.md (1)

317-338: Encoding artefacts detected in headings

Headings show the replacement character before “Recent Updates” and “🙏 Sponsor”. Please replace with the intended emoji or remove to keep the README pristine.

src/utils/fileAttachmentCorrelation.ts (3)

15-19: Consider externalising TTL constants for flexibility

Sir, your hard-coded timing values (TTL, buffer timeout, cleanup interval) lock behaviour at compile-time. Surfacing them as constructor parameters or env-driven config would let operations tune performance without a code deploy.


200-249: Redundant clearTimeout calls inflate overhead

Inside the existing-buffer branch, you clear existing.sharedTimeoutId at Line 202, and then immediately clear it again at Line 240 after potential duplicates handling. The first invalidation is sufficient; the second is superfluous and costs an extra native call.

-      // Clear existing timeout
-      clearTimeout(existing.sharedTimeoutId);
...
-      // Clear existing timeout before creating new one
-      if (existing.sharedTimeoutId) {
-        clearTimeout(existing.sharedTimeoutId);
-      }

223-228: Avoid null as any to keep type safety immaculate

Setting timeoutId: null as any bypasses the compiler. Declaring timeoutId?: NodeJS.Timeout (optional) or initialising with undefined keeps typings pure and removes the unchecked cast.

Also applies to: 252-257

src/services/webhookService.ts (1)

75-98: Attachments field may be undefined downstream

transformEvent only attaches message.attachments when hasFiles is true. Consumers expecting the key to exist will need extra guards. Consider always emitting the object with hasFiles flag to simplify parsing on the other end.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a097ae and 57c39e3.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (12)
  • .env.example (1 hunks)
  • .github/chatmodes/WG Code Builder.chatmode.md (1 hunks)
  • .gitignore (1 hunks)
  • README.md (8 hunks)
  • package.json (2 hunks)
  • src/app.ts (1 hunks)
  • src/config/env.ts (1 hunks)
  • src/controllers/webhookController.ts (2 hunks)
  • src/services/redisService.ts (1 hunks)
  • src/services/webhookService.ts (5 hunks)
  • src/types/index.ts (3 hunks)
  • src/utils/fileAttachmentCorrelation.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: warengonzaga
PR: wgtechlabs/unthread-webhook-server#7
File: README.md:53-58
Timestamp: 2025-06-22T15:52:25.095Z
Learning: In the unthread-webhook-server repository README.md, the Railway deploy link URL uses "unthread-webhook-ser" instead of the full "unthread-webhook-server" - this is intentional shortening, not a typo.
📚 Learning: 2025-06-22T15:52:25.095Z
Learnt from: warengonzaga
PR: wgtechlabs/unthread-webhook-server#7
File: README.md:53-58
Timestamp: 2025-06-22T15:52:25.095Z
Learning: In the unthread-webhook-server repository README.md, the Railway deploy link URL uses "unthread-webhook-ser" instead of the full "unthread-webhook-server" - this is intentional shortening, not a typo.

Applied to files:

  • package.json
  • README.md
🧬 Code Graph Analysis (1)
src/utils/fileAttachmentCorrelation.ts (1)
src/types/index.ts (5)
  • FileAttachmentCorrelationEntry (130-134)
  • FileAttachmentBufferedEvents (143-146)
  • UnthreadWebhookEvent (16-22)
  • PlatformSource (57-57)
  • FileAttachmentBufferedEvent (136-141)
🪛 markdownlint-cli2 (0.17.2)
.github/chatmodes/WG Code Builder.chatmode.md

80-80: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (4)
src/config/env.ts (1)

31-37: Confirm TARGET_PLATFORM is set in all environments
Certainly, sir. I’ve scanned the repository and confirmed that TARGET_PLATFORM is now mandatory:

• src/config/env.ts (lines 10–14): validateTargetPlatform throws if TARGET_PLATFORM is missing or empty.
• README.md (lines 125–133): Documents the breaking change and migration guide.
• .env.example (lines 9–12): Supplies a sample value (consider adding a “required” comment for clarity).
• .env.railway (line 4): Explicitly marks TARGET_PLATFORM as required.

Please verify that your CI/CD pipelines, local development .env, and all deployment environments (Railway, Docker, etc.) define a valid TARGET_PLATFORM (e.g., discord, telegram, slack). Failure to do so will prevent the application from starting.

package.json (1)

3-3: Major-version dependency bump – confirm compatibility

Madam/Sir, the jump to @wgtechlabs/log-engine@2.2.0 may include breaking changes. Kindly verify that all logger invocations across the project conform to the v2 API before shipping. I can run a quick repository scan if you wish.

Also applies to: 35-35

.env.example (1)

7-11: Clear and helpful platform guidance – well done

The expanded commentary removes ambiguity around TARGET_PLATFORM. No action required.

src/services/webhookService.ts (1)

60-68: Possible double “processed” mark for buffered events

You mark the event as processed before buffering (markEventProcessed Line 62). When correlation later succeeds, continueEventProcessing marks it again (Line 267). If markEventProcessed isn’t idempotent, this could skew metrics or trigger errors. Verify idempotency or gate the second call.

@warengonzaga warengonzaga merged commit d9b6c95 into main Aug 9, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Unthread Partnership Aug 9, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants