Skip to content

Conversation

@Behzad-rabiei
Copy link
Member

@Behzad-rabiei Behzad-rabiei commented Sep 9, 2025

Summary by CodeRabbit

  • New Features

    • Enabled proper handling when updating the Hivemind module connected to a Website platform, improving reliability and consistency during updates.
    • Continued support for Hivemind with MediaWiki remains unchanged.
  • Chores

    • Updated CI pipeline to use a new reusable workflow. No user-facing impact.

@coderabbitai
Copy link

coderabbitai bot commented Sep 9, 2025

Walkthrough

CI workflow now points to a different reusable workflow file. In code, updateModule re-enables a conditional branch to handle the Hivemind + Website case via handleHivemindWebsiteCase, alongside existing Hivemind + MediaWiki handling. No public interfaces changed.

Changes

Cohort / File(s) Summary
CI workflow reference update
.github/workflows/ci.yml
Switches reusable workflow from TogetherCrew/operations/.github/workflows/ci.yml@main to TogetherCrew/operations/.github/workflows/ci2.yml@main. No other changes.
Module service: Hivemind platform handling
src/services/module.service.ts
Activates previously commented logic: when updating and existing platform exists, if module.name === ModuleNames.Hivemind and new platform is PlatformNames.Website, calls handleHivemindWebsiteCase(newPlatform). Maintains MediaWiki path. Imports reordered/formatted.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Caller
  participant S as module.service.updateModule
  participant EP as existingPlatform
  participant HPW as handleHivemindWebsiteCase
  participant HPM as handleHivemindMediaWikiCase

  C->>S: updateModule(module, newPlatform)
  alt existing platform present
    S->>EP: read existingPlatform metadata
    alt module=Hivemind AND newPlatform=Website
      S->>HPW: handleHivemindWebsiteCase(newPlatform)
      HPW-->>S: updated platform state
    else module=Hivemind AND newPlatform=MediaWiki
      S->>HPM: handleHivemindMediaWikiCase(newPlatform)
      HPM-->>S: updated platform state
    end
    S->>EP: update metadata as needed
  else no existing platform
    S-->>C: proceed with standard creation/update
  end
  S-->>C: return result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • cyri113

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request currently lacks a description that outlines the changes made to the CI workflow configuration and the service logic for handling the Hivemind website case, leaving reviewers without context on what this PR introduces. Please add a descriptive pull request summary that briefly explains the update to reference ci2.yml in the CI workflow and the activation of the Hivemind website handling in the module service.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “fix: handle hivemind website case” clearly and concisely summarizes the primary functional change in the updateModule logic, follows conventional commit styling, and immediately conveys the main intent without extraneous details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

A whisk of whiskers, a hop in the night,
CI points anew, the pipelines alight.
Hivemind listens—Website knocks—“Come through!”
MediaWiki waves, “I’m ready too.”
Code paths tidy, carrots in a row—
Thump-thump approves: to prod we go! 🥕✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch activate-website-hivemind-module-workflow

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.

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: 0

🧹 Nitpick comments (6)
.github/workflows/ci.yml (1)

9-9: Pin reusable workflow ci2.yml to a specific commit SHA
Verified ci2.yml supports on: workflow_call and includes the CC_TEST_REPORTER_ID secret; use a fixed commit SHA instead of @main for reproducibility:

- uses: TogetherCrew/operations/.github/workflows/ci2.yml@main
+ uses: TogetherCrew/operations/.github/workflows/ci2.yml@<pinned-commit-sha>
src/services/module.service.ts (5)

97-99: Hivemind + Website path re-enabled—good; minor duplication with the next branch

Tiny cleanup to reduce repeated module.name === ModuleNames.Hivemind checks:

-      if (module.name === ModuleNames.Hivemind && newPlatform.name === PlatformNames.Website) {
-        await handleHivemindWebsiteCase(newPlatform);
-      }
-      if (module.name === ModuleNames.Hivemind && newPlatform.name === PlatformNames.MediaWiki) {
-        await handleHivemindMediaWikiCase(newPlatform);
-      }
+      if (module.name === ModuleNames.Hivemind) {
+        if (newPlatform.name === PlatformNames.Website) {
+          await handleHivemindWebsiteCase(newPlatform);
+        } else if (newPlatform.name === PlatformNames.MediaWiki) {
+          await handleHivemindMediaWikiCase(newPlatform);
+        }
+      }

115-139: Avoid orphan schedules on partial failure (create succeeds, save fails)

If createWebsiteSchedule succeeds but platformDoc.save() fails, the schedule is left running without a persisted scheduleId.

Add compensation and rethrow:

   if (isActivated === true) {
     if (!existingScheduleId) {
-      const scheduleId = await websiteService.coreService.createWebsiteSchedule(platform.platform);
-      platformDoc.set('metadata.scheduleId', scheduleId);
-
-      await platformDoc.save();
+      let scheduleId: string | null = null;
+      try {
+        scheduleId = await websiteService.coreService.createWebsiteSchedule(platform.platform);
+        platformDoc.set('metadata.scheduleId', scheduleId);
+        await platformDoc.save();
+      } catch (err) {
+        if (scheduleId) {
+          await websiteService.coreService.deleteWebsiteSchedule(scheduleId).catch(() => {});
+        }
+        throw err;
+      }
     }
   } else if (isActivated === false) {

Per prior learning, upstream handles thrown errors from updateModule, so this preserves that contract while preventing leaked schedules.


115-139: Add light observability around schedule changes

Log schedule create/delete/terminate decisions with platform and community IDs for auditability and easier incident triage.

I can add structured logs (e.g., pino) with minimal noise if you want.


93-107: Tests for Website activation toggle

Please add unit/integration tests covering:

  • activate: creates schedule and persists metadata.scheduleId when absent
  • deactivate: deletes schedule, terminates workflow, nulls metadata.scheduleId
  • idempotency: repeated activate/deactivate are no-ops

I can scaffold Jest tests with service mocks for websiteService and platformService.


9-10: No changes needed for websiteService shape

  • The src/services/website module’s default export exposes coreService, which provides createWebsiteSchedule, deleteWebsiteSchedule, and terminateWebsiteWorkflow as expected.
  • Optional: introduce a TypeScript interface for coreService to enforce its API at compile time.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e81a1ac and 8123fc2.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml (1 hunks)
  • src/services/module.service.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-10-09T08:57:20.287Z
Learnt from: Behzad-rabiei
PR: TogetherCrew/api#350
File: src/services/module.service.ts:55-71
Timestamp: 2024-10-09T08:57:20.287Z
Learning: Error handling for the `updateModule` function in `src/services/module.service.ts` is managed by the parent function, as indicated by user Behzad-rabiei.

Applied to files:

  • src/services/module.service.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: ci / build-push / Build + Push Image
🔇 Additional comments (1)
src/services/module.service.ts (1)

3-5: Import reorg looks fine

No functional impact.

@Behzad-rabiei Behzad-rabiei merged commit 4e4b4c1 into main Sep 9, 2025
3 checks passed
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