Skip to content

feat: implement prompt queue management (CLI-33) - #677

Merged
dwash96 merged 23 commits into
cecli-dev:v1.5.0from
szmania:cli-33-queue-prompts
Sep 8, 2026
Merged

feat: implement prompt queue management (CLI-33)#677
dwash96 merged 23 commits into
cecli-dev:v1.5.0from
szmania:cli-33-queue-prompts

Conversation

@szmania

@szmania szmania commented Sep 7, 2026

Copy link
Copy Markdown

Purpose

This PR implements the prompt queue management feature (CLI-33), allowing users to queue prompts for deferred processing, view the queue, insert prompts at specific positions, and selectively remove items.

Changes

  • Core Logic (cecli/commands/core.py):
    • Added prompt_queue (list), _queue_counter (int), _queue_lock (ThreadSafeEvent), and _processing_queue (bool) to the Commands class.
    • Implemented _process_queued_prompts(preproc), which iterates through the queue and executes each item using coder.run_one.
    • Updated Commands.execute to trigger the queue processing in the finally block, ensuring it runs as soon as a command finishes.
    • Added helper methods: _enqueue_prompt, _insert_prompt, _dequeue_prompt, _get_queue_length, and _clear_queue.
  • New Commands:
    • /queue <text>: Adds a prompt to the FIFO queue and returns the assigned position.
    • /insert-queue [index] <text>: Inserts a prompt at a specific position in the queue (front by default, or at a given index).
    • /list-queue: Displays all currently queued prompts with their IDs and timestamps.
    • /remove-queue <index|*>: Removes a specific prompt by index or clears the entire queue using a wildcard. Includes an interactive selection mode if no index is provided.
  • Registration:
    • Updated cecli/commands/__init__.py to import and register the new commands in the CommandRegistry.

Design Considerations

  • Session-bound: The queue is in-memory and session-specific, ensuring it does not persist across restarts.
  • Thread Safety: Used asyncio.Lock (via ThreadSafeEvent patterns where appropriate) to ensure safe concurrent access to the queue.
  • Recursion Guard: Implemented a guard to ensure management commands (/queue, /insert-queue, /list-queue, /remove-queue) do not accidentally trigger auto-processing recursively.
  • Safety Limits: Added a hard limit of 100 items and a character limit (10,000) to prevent memory exhaustion or infinite loops.

Documentation

  • Updated cecli/website/docs/usage/commands.md to document the /insert-queue command alongside the other queue management commands.

Testing

  • Unit tests for queue logic in core.py.
  • Integration tests for command classes.
  • E2E tests for full queue lifecycle.
  • Regression tests for existing command integrity.

@dwash96
dwash96 changed the base branch from main to v1.5.0 September 8, 2026 10:41
@dwash96
dwash96 merged commit d6d4059 into cecli-dev:v1.5.0 Sep 8, 2026
12 checks passed
@dwash96 dwash96 mentioned this pull request Sep 8, 2026
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