Skip to content

Document preamble setup order#45

Merged
leynos merged 3 commits intomainfrom
codex/fix-callback-handler-reset-in-with_preamble
Jun 15, 2025
Merged

Document preamble setup order#45
leynos merged 3 commits intomainfrom
codex/fix-callback-handler-reset-in-with_preamble

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 15, 2025

Summary

  • document that with_preamble must be called before registering callbacks
  • mention the call order in README
  • clarify the with_preamble doc comment

Testing

  • cargo clippy -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test
  • markdownlint README.md docs/preamble-validator.md
  • nixie docs/preamble-validator.md

https://chatgpt.com/codex/tasks/task_e_684e5eb84c8483228cc92a7eb717c0ab

Summary by Sourcery

Document the required call order for with_preamble to ensure callbacks are not dropped and clarify related API docs

Enhancements:

  • Refine the with_preamble method doc comment to explain when callbacks are dropped

Documentation:

  • Add a “Call Order” section to preamble-validator.md to state that with_preamble must be called before registering callbacks
  • Update README to instruct calling with_preamble::() before registering success or failure callbacks

Summary by CodeRabbit

  • Documentation
    • Clarified the required order of operations when using the preamble validation feature in the README.
    • Added a new section to the documentation explaining the correct sequence for configuring custom preamble types and registering callbacks.
    • Updated in-code documentation to highlight the consequences of calling certain methods in the wrong order.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 15, 2025

Warning

Rate limit exceeded

@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 22 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 86f495c and 17c5dbf.

📒 Files selected for processing (2)
  • docs/preamble-validator.md (1 hunks)
  • src/server.rs (1 hunks)

Walkthrough

This update clarifies the required order of method calls when configuring custom preamble validation in the WireframeServer. Documentation in the README, a dedicated markdown file, and a Rust doc comment now specify that with_preamble must be called before registering preamble-related callbacks, as calling it later resets any previously set callbacks.

Changes

File(s) Change Summary
README.md Added a line clarifying that with_preamble::<T>() must be called before registering preamble callbacks.
docs/preamble-validator.md Added a "Call Order" section explaining the required sequence for calling with_preamble and registering callbacks.
src/server.rs Revised the doc comment for with_preamble to clarify that calling it after handler registration drops existing callbacks.

Possibly related issues

Possibly related PRs

  • Implement preamble callback tests #28: This PR’s documentation clarifications about with_preamble ordering relate directly to the implementation and testing of the method and its callbacks in WireframeServer.

Poem

In the warren of code where the preambles dwell,
A rabbit reminds you, so all will be well:
"Call with_preamble first, before you declare
Your callbacks for success or failure there.
For if you forget, your handlers will hop—
Out of memory, with a silent plop!"
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 15, 2025

Reviewer's Guide

This PR clarifies the required invocation order for the with_preamble method by updating the preamble validator documentation, refining the inline doc comment in server.rs, and adding a note in the README to ensure callbacks are registered only after customizing the preamble.

Sequence Diagram: Correct Order for with_preamble and Callback Registration

sequenceDiagram
    actor Developer
    participant InitialServer as WireframeServer (default/old preamble)
    participant ConfiguredServer as WireframeServer (new preamble T)

    Developer->>InitialServer: 1. Call with_preamble<T>()
    activate InitialServer
    InitialServer-->>Developer: Returns ConfiguredServer instance
    deactivate InitialServer

    Developer->>ConfiguredServer: 2. Call on_preamble_decode_success(callback)
    activate ConfiguredServer
    ConfiguredServer-->>Developer: Success callback registered on ConfiguredServer
    deactivate ConfiguredServer

    Developer->>ConfiguredServer: 3. Call on_preamble_decode_failure(callback)
    activate ConfiguredServer
    ConfiguredServer-->>Developer: Failure callback registered on ConfiguredServer
    deactivate ConfiguredServer
Loading

File-Level Changes

Change Details Files
Documented call order in the preamble validator guide
  • Added a ‘## Call Order’ section
  • Specified that with_preamble must precede callback registration
  • Explained that prior callbacks on () are dropped
docs/preamble-validator.md
Refined the with_preamble method doc comment
  • Reworded to emphasize calling before handlers
  • Condensed callback-dropping warning
src/server.rs
Mentioned call order in README
  • Inserted a bullet advising with_preamble::<T>() be called before registering callbacks
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Gates Passed
6 Quality Gates Passed

See analysis details in CodeScene

Absence of Expected Change Pattern

  • wireframe/src/server.rs is usually changed with: wireframe/src/extractor.rs, wireframe/src/middleware.rs

Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (2)
src/server.rs (1)

91-91: Explicit doc clarifies call order, but align terminology
The new doc line clearly emphasises invocation order. For consistency with the README and other documentation, consider using “callbacks” instead of “handlers”.

docs/preamble-validator.md (1)

34-42: Call Order section effectively clarifies invocation sequence
This addition succinctly communicates the required method call sequence. For consistency with the README, you might specify WireframeServer::with_preamble::<T>() to emphasise the generic parameter.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 39f973a and 86f495c.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • docs/preamble-validator.md (1 hunks)
  • src/server.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (1)
README.md (1)

17-17: Explicit call order instruction enhances clarity
The added line clearly informs users of the required invocation sequence for with_preamble, aligning with updated documentation sections.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Gates Passed
6 Quality Gates Passed

See analysis details in CodeScene

Absence of Expected Change Pattern

  • wireframe/src/server.rs is usually changed with: wireframe/src/extractor.rs, wireframe/src/middleware.rs

Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

coderabbitai Bot added a commit that referenced this pull request Jun 15, 2025
Docstrings generation was requested by @leynos.

* #45 (comment)

The following files were modified:

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

coderabbitai Bot commented Jun 15, 2025

Note

Generated docstrings for this pull request at #46

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 15, 2025

@coderabbitai new github issue:

Tidy up this docstring in server.rs:

impl<F, T> WireframeServer<F, T>
where
    F: Fn() -> WireframeApp + Send + Sync + Clone + 'static,
    // `Decode` is generic over a context type; we use `()` here.
    T: bincode::Decode<()> + Send + 'static,
{
    /// Set the number of worker tasks to spawn for the server.
    ///
    /// Ensures at least one worker is configured.
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use wireframe::{app::WireframeApp, server::WireframeServer};
    ///
    /// let factory = || WireframeApp::new().unwrap();
    /// let server = WireframeServer::new(factory).workers(4);
    /// ```
    #[must_use]
    /// Sets the number of worker tasks to spawn, ensuring at least one worker is configured.
    ///
    /// Returns a new `WireframeServer` instance with the updated worker count. If `count` is less than 1, it defaults to 1.
    ///
    /// # Examples
    ///
    /// ```ignore
    /// use wireframe::{app::WireframeApp, server::WireframeServer};
    ///
    /// let factory = || WireframeApp::new().unwrap();
    /// let server = WireframeServer::new(factory).workers(4);
    /// assert_eq!(server.worker_count(), 4);
    /// let server = server.workers(0);
    /// assert_eq!(server.worker_count(), 1);
    /// ```
    pub fn workers(mut self, count: usize) -> Self {
        self.workers = count.max(1);
        self
    }

…e` (#46)

* 📝 Add docstrings to `codex/fix-callback-handler-reset-in-with_preamble`

Docstrings generation was requested by @leynos.

* #45 (comment)

The following files were modified:

* `src/server.rs`

* Tidy docstring

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Leynos <leynos@troubledskies.net>
Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Gates Passed
6 Quality Gates Passed

See analysis details in CodeScene

Absence of Expected Change Pattern

  • wireframe/src/server.rs is usually changed with: wireframe/src/extractor.rs, wireframe/src/middleware.rs

Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 15, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@leynos I'll create a GitHub issue for tidying up the duplicated docstring in server.rs.


🏁 Script executed:

#!/bin/bash
# Create a GitHub issue for the duplicated docstring cleanup
gh issue create \
  --title "Tidy up duplicated docstring for workers method in server.rs" \
  --body "The \`workers\` method in \`server.rs\` has duplicated documentation comments that should be consolidated into a single, clean docstring.

Currently there are two separate doc comment blocks:
1. A shorter description with a \`no_run\` example
2. A more detailed description with additional behavioural information and an \`ignore\` example

This creates confusion and should be tidied up into a single, well-structured docstring.

**Backlinks:**
- Related PR: https://github.com/leynos/wireframe/pull/45
- Original comment: https://github.com/leynos/wireframe/pull/45#issuecomment-$(gh api repos/leynos/wireframe/pulls/45/comments --jq '.[-1].id')" \
  --assignee leynos

Length of output: 802


@leynos I've successfully created GitHub issue #48 to address the duplicated docstring in the workers method: #48

The issue describes the problem with the two redundant doc comment blocks and has been assigned to you for follow-up action.

@leynos leynos merged commit d81ba91 into main Jun 15, 2025
2 of 3 checks passed
@leynos leynos deleted the codex/fix-callback-handler-reset-in-with_preamble branch June 15, 2025 09:45
@coderabbitai coderabbitai Bot mentioned this pull request Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant