refactor(poc): Gemini review fixes — simplify isPocSessionDeadStop + reuse http.Client#36
Conversation
…+ 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
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors 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 SimulationPanelsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
Summary
Addresses the two medium-priority findings from Gemini's review of #35.
Fix 1 —
isPocSessionDeadStopsimplificationReplace
any()closure allocation with a direct type check +contains():Fix 2 — Shared
http.ClientinSimulationPanelOwn a single
http.Clientfor the widget lifetime, enabling TCP keep-alive across all simulation steps. Close it indispose().Test plan
poc_simulation_test.dartpassflutter 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: