Skip to content

refactor(poc): Gemini review fixes — simplify isPocSessionDeadStop + reuse http.Client#36

Merged
cemal-yilmaz-bt merged 1 commit into
f/pluginfrom
fix/flutter-poc-tests-and-docs
Jun 1, 2026
Merged

refactor(poc): Gemini review fixes — simplify isPocSessionDeadStop + reuse http.Client#36
cemal-yilmaz-bt merged 1 commit into
f/pluginfrom
fix/flutter-poc-tests-and-docs

Conversation

@cemal-yilmaz-bt

@cemal-yilmaz-bt cemal-yilmaz-bt commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses the two medium-priority findings from Gemini's review of #35.

Fix 1 — isPocSessionDeadStop simplification

Replace any() closure allocation with a direct type check + contains():

// before
final isSessionDead = sessionDeadAuthIds.any(
  (id) => step is PocSimHostStep && step.auth == id,
);
// after
final isSessionDead =
    step is PocSimHostStep && sessionDeadAuthIds.contains(step.auth);

Fix 2 — Shared http.Client in SimulationPanel

Own a single http.Client for the widget lifetime, enabling TCP keep-alive across all simulation steps. Close it in dispose().

Test plan

  • Existing 15 unit tests in poc_simulation_test.dart pass
  • flutter analyze — no issues

🤖 Generated with Claude Code

Summary by Sourcery

Simplify PoC simulation session-dead detection and reuse a shared HTTP client across simulation steps.

Enhancements:

  • Streamline isPocSessionDeadStop by replacing the closure-based search with a direct type and auth ID membership check.
  • Allow runPocSimStep to accept an optional shared http.Client for networked steps.
  • Make SimulationPanel own a single http.Client for its lifetime and close it on dispose to enable connection reuse across auto steps.

…+ reuse http.Client

- isPocSessionDeadStop: replace any() closure with type check + contains()
- SimulationPanel: shared http.Client for TCP keep-alive across sim steps
- runPocSimStep: optional http.Client? param threaded to _runFetch
@cemal-yilmaz-bt
cemal-yilmaz-bt merged commit 0723761 into f/plugin Jun 1, 2026
1 check passed
@sourcery-ai

sourcery-ai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the PoC simulation logic by simplifying the session-dead check and updating the simulation step runner to optionally reuse a shared http.Client owned by SimulationPanel for better connection reuse and lifecycle management.

Sequence diagram for shared http.Client usage in SimulationPanel

sequenceDiagram
    participant SimulationPanelState
    participant HttpClient as http.Client
    participant runPocSimStep
    participant _runFetch

    activate SimulationPanelState
    SimulationPanelState->>HttpClient: new http.Client()

    loop for each PocSimFetchStep in _autoSteps
        SimulationPanelState->>runPocSimStep: runPocSimStep(morph, cfg, step, HttpClient)
        runPocSimStep->>_runFetch: _runFetch(step, cfg.mockApiBaseUrl, HttpClient)
        _runFetch-->>runPocSimStep: PocSimStepResult
        runPocSimStep-->>SimulationPanelState: PocSimStepResult
    end

    SimulationPanelState->>HttpClient: close()
    deactivate SimulationPanelState
Loading

File-Level Changes

Change Details Files
Simplified the PoC session-dead detection logic to avoid unnecessary closure allocation and make the condition clearer.
  • Replaced use of sessionDeadAuthIds.any with a direct type check for PocSimHostStep combined with sessionDeadAuthIds.contains on step.auth
  • Kept existing detail string checks for specific error substrings while relying on the new isSessionDead predicate
poc/flutter-poc/lib/poc_simulation.dart
Updated simulation step execution to accept an optional http.Client and wired SimulationPanel to manage and reuse a single client instance across steps.
  • Extended runPocSimStep to take an optional http.Client parameter and pass it through to _runFetch for fetch steps
  • Imported package:http in SimulationPanel and added a private http.Client field initialized for the widget lifetime
  • Overrode dispose in SimulationPanel state to close the shared http.Client before calling super.dispose
  • Updated the auto-run loop to call runPocSimStep with the shared http.Client instance
poc/flutter-poc/lib/poc_simulation.dart
poc/flutter-poc/lib/widgets/simulation_panel.dart

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

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 224efdc1-741d-46c6-b2fe-911fb1243f64

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/flutter-poc-tests-and-docs

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.

@cemal-yilmaz-bt
cemal-yilmaz-bt deleted the fix/flutter-poc-tests-and-docs branch June 1, 2026 14:59

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the session dead check in isPocSessionDeadStop to use contains instead of any. It also introduces a persistent http.Client in _SimulationPanelState that is properly disposed of and passed to runPocSimStep to reuse connections. There are no review comments, and I have no additional feedback to provide.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

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.

1 participant