Skip to content

Implement Queue Manager Agent with subreddit-specific queue clearing#24

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-23
Draft

Implement Queue Manager Agent with subreddit-specific queue clearing#24
Copilot wants to merge 3 commits intomainfrom
copilot/fix-23

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 8, 2025

This PR implements a comprehensive Queue Manager Agent to solve the issue where the host queue would accumulate hundreds of items, causing the live feed to stop updating when subreddits were removed from the control panel but their related posts remained in various queues.

Problem

The original issue was that removing subreddits from the control panel only updated the UI configuration but left related posts in both the host narration queue and scheduler's scheduled posts. This led to:

  • Queue lengths of hundreds of items
  • Live feed performance degradation
  • Stale content from removed subreddits continuing to process
  • No visibility into queue status for debugging

Solution

The implementation extends existing queue functionality with a centralized Queue Manager Agent that coordinates clearing operations across multiple services:

Core Components Added

  • QueueManagerService - Centralized orchestrator for queue operations across services
  • QueueManagerStore - Zustand store for state management and UI integration
  • Enhanced HostAgentService with clearQueueBySubreddit() and getQueueBySubreddit() methods
  • Enhanced SchedulerService with clearScheduledPostsBySubreddit() functionality
  • Updated Controls UI with real-time queue status and management controls

Key Features

  1. Automatic Queue Clearing: When a subreddit is removed via the × button, all related posts are automatically cleared from both the narration queue and scheduled posts
  2. Real-time Queue Status: New UI section shows total queue items and top 3 subreddits with counts
  3. Manual Queue Management: "Clear All" button for complete queue clearing when needed
  4. Error Resilience: Queue operations are non-blocking and include comprehensive error handling
  5. Comprehensive Logging: Detailed console output with emojis for operation visibility

Implementation Highlights

The solution maintains minimal code changes by extending existing services rather than creating entirely new systems. The handleRemoveSubreddit() function now:

const handleRemoveSubreddit = async (subreddit: string) => {
  // Remove from UI configuration
  const updatedEnabledDefaults = enabledDefaults.filter(s => s !== subreddit);
  setEnabledDefaults(updatedEnabledDefaults);
  
  // Clear queue items for this subreddit  
  try {
    const result = await clearQueueBySubreddit(subreddit);
    console.log(`✅ Queue cleared for r/${subreddit}: ${result.totalCleared} items`);
  } catch (error) {
    console.warn(`⚠️ Failed to clear queue for r/${subreddit}:`, error);
  }
};

Testing

A comprehensive test suite validates the functionality:

  • Initial state: Multiple subreddits with posts in both queues
  • Subreddit removal: Correctly clears only related posts
  • Final state: Clean queues containing only active subreddit content

The Queue Manager Agent ensures optimal live feed performance by maintaining clean, focused queues that automatically adapt to subreddit configuration changes.

Fixes #23.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/SMNB/SMNB/smnb/node_modules/next/dist/compiled/jest-worker/processChild.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 8, 2025 14:49
Co-authored-by: acdc-digital <127530566+acdc-digital@users.noreply.github.com>
Co-authored-by: acdc-digital <127530566+acdc-digital@users.noreply.github.com>
Copilot AI changed the title [WIP] New queue Agent, or extended queue functionality Implement Queue Manager Agent with subreddit-specific queue clearing Sep 8, 2025
Copilot AI requested a review from acdc-digital September 8, 2025 14:54
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.

New queue Agent, or extended queue functionality

2 participants