Skip to content

Conversation

@IGN-Styly
Copy link
Member

@IGN-Styly IGN-Styly commented Jun 30, 2025

Summary by CodeRabbit

  • New Features
    • Introduced the ability to retrieve tasks with pagination and filtering by task state (Queued, Processing, Solved).
    • Added support for viewing multiple tasks at once, with options to specify page and page size.
    • Tasks can now be filtered by namespace and task identifier.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 30, 2025

Warning

Rate limit exceeded

@IGN-Styly has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 74c3e98 and 62098e1.

📒 Files selected for processing (1)
  • src/bin/server.rs (2 hunks)

Walkthrough

A new paginated task querying feature was introduced, including a GetTasks RPC method and supporting message types and enums in the protobuf definition. The server implementation now handles paginated and state-filtered task retrieval, with authentication checks and response formatting. No other existing methods or control flow were modified.

Changes

File(s) Change Summary
proto/engine.proto Added GetTasks RPC, TaskState enum, TaskPageRequest, TaskPage messages; reordered CreateTask; added commented-out DeleteTask.
src/bin/server.rs Implemented async get_tasks handler for paginated, state-filtered task retrieval with authentication; updated imports.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant EngineService
    participant Auth
    participant TaskStore

    Client->>EngineService: GetTasks(TaskPageRequest)
    EngineService->>Auth: CheckAuth(request)
    alt Auth Success
        EngineService->>TaskStore: Retrieve tasks by namespace, task, state
        TaskStore-->>EngineService: Task list
        EngineService->>EngineService: Paginate and format tasks
        EngineService-->>Client: TaskPage (paginated tasks)
    else Auth Failure
        EngineService-->>Client: PermissionDenied error
    end
Loading

Possibly related PRs

  • Pagination #25: Both PRs add and implement the GetTasks RPC method with pagination and task state filtering in proto/engine.proto and the corresponding async handler in src/bin/server.rs.

Poem

In the warren of tasks, a new path appears,
With pages and states, through all of the years.
Now rabbits can query, and hop with delight,
Paginated answers, all sorted just right.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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 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
Contributor

@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 (2)
proto/engine.proto (2)

14-14: Remove unused empty message or add fields.

The TaskSelector message is defined but empty and not used anywhere in the current implementation. Either remove it if it's not needed, or add the intended fields if this is incomplete work.

-message TaskSelector {}

9-9: Consider removing commented code or adding a TODO.

The commented-out DeleteTask RPC suggests incomplete work. Either implement it, remove it, or add a TODO comment explaining the planned implementation.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 44d9f88 and 7a27443.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • proto/engine.proto (1 hunks)
  • src/bin/server.rs (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/bin/server.rs (1)
src/lib.rs (2)
  • get_auth (12-19)
  • get_uid (3-10)
🔇 Additional comments (4)
proto/engine.proto (2)

15-19: Good enum design for task states.

The TaskState enum appropriately represents the task lifecycle with clear, meaningful values.


20-34: Well-structured pagination messages.

The TaskPageRequest and TaskPage messages are well-designed for pagination with appropriate field types and clear naming conventions.

src/bin/server.rs (2)

10-15: Clean import additions.

The new imports properly support the added functionality and are well-organized.


35-47: Authentication and error handling look solid.

The authentication check using Events::CheckAuth and proper error responses with logging are well implemented.

Comment on lines 50 to 135
let q: Vec<proto::Task> = match data.clone().state() {
TaskState::Processing => {
match api
.executing_tasks
.clone()
.tasks
.get(&(data.namespace.clone(), data.task.clone()))
{
Some(tasks) => {
let mut d = tasks.clone();
d.sort_by_key(|f| f.id.clone());
d.iter()
.map(|f| proto::Task {
id: f.id.clone(),
task_id: vec![data.namespace.clone(), data.task.clone()].join(":"),
task_payload: f.bytes.clone(),
payload: Vec::new(),
})
.collect()
}
None => {
info!(
"Namespace {:?} and task {:?} not found in Processing state",
data.namespace, data.task
);
Vec::new()
}
}
}
TaskState::Queued => {
match api
.task_queue
.clone()
.tasks
.get(&(data.namespace.clone(), data.task.clone()))
{
Some(tasks) => {
let mut d = tasks.clone();
d.sort_by_key(|f| f.id.clone());
d.iter()
.map(|f| proto::Task {
id: f.id.clone(),
task_id: vec![data.namespace.clone(), data.task.clone()].join(":"),
task_payload: f.bytes.clone(),
payload: Vec::new(),
})
.collect()
}
None => {
info!(
"Namespace {:?} and task {:?} not found in Queued state",
data.namespace, data.task
);
Vec::new()
}
}
}
TaskState::Solved => {
match api
.solved_tasks
.clone()
.tasks
.get(&(data.namespace.clone(), data.task.clone()))
{
Some(tasks) => {
let mut d = tasks.clone();
d.sort_by_key(|f| f.id.clone());
d.iter()
.map(|f| proto::Task {
id: f.id.clone(),
task_id: vec![data.namespace.clone(), data.task.clone()].join(":"),
task_payload: f.bytes.clone(),
payload: Vec::new(),
})
.collect()
}
None => {
info!(
"Namespace {:?} and task {:?} not found in Solved state",
data.namespace, data.task
);
Vec::new()
}
}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor to eliminate code duplication.

The three match arms contain nearly identical logic with only different collection access. This violates DRY principles and makes maintenance difficult.

Consider extracting the common logic:

+fn get_tasks_by_state(
+    tasks: Option<&Vec<impl Clone + TaskLike>>, 
+    namespace: &str, 
+    task: &str
+) -> Vec<proto::Task> {
+    match tasks {
+        Some(task_list) => {
+            let mut sorted_tasks = task_list.clone();
+            sorted_tasks.sort_by_key(|f| f.id());
+            sorted_tasks.iter()
+                .map(|f| proto::Task {
+                    id: f.id(),
+                    task_id: format!("{}:{}", namespace, task),
+                    task_payload: f.bytes(),
+                    payload: Vec::new(),
+                })
+                .collect()
+        }
+        None => {
+            info!("Namespace {:?} and task {:?} not found in requested state", namespace, task);
+            Vec::new()
+        }
+    }
+}

let q: Vec<proto::Task> = match data.state() {
    TaskState::Processing => get_tasks_by_state(
        api.executing_tasks.tasks.get(&(data.namespace.clone(), data.task.clone())),
        &data.namespace, &data.task
    ),
    TaskState::Queued => get_tasks_by_state(
        api.task_queue.tasks.get(&(data.namespace.clone(), data.task.clone())),
        &data.namespace, &data.task
    ),
    TaskState::Solved => get_tasks_by_state(
        api.solved_tasks.tasks.get(&(data.namespace.clone(), data.task.clone())),
        &data.namespace, &data.task
    ),
};

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/bin/server.rs between lines 50 and 135, the match arms for
TaskState::Processing, TaskState::Queued, and TaskState::Solved contain nearly
identical code that differs only in which task collection is accessed. To fix
this, extract the common logic into a helper function or closure that takes the
relevant task collection as input and returns the sorted and mapped
Vec<proto::Task>. Then, in the match arms, simply call this helper with the
appropriate collection, reducing duplication and improving maintainability.

coderabbitai bot added a commit that referenced this pull request Jun 30, 2025
Docstrings generation was requested by @IGN-Styly.

* #27 (comment)

The following files were modified:

* `src/bin/server.rs`
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 30, 2025

Note

Generated docstrings for this pull request at #28

@IGN-Styly IGN-Styly merged commit 19a9b74 into main Jun 30, 2025
1 of 4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jul 31, 2025
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