Skip to content

fix: default max detour to 5 minutes#57

Merged
GeiserX merged 1 commit into
mainfrom
fix/default-max-detour
Jun 8, 2026
Merged

fix: default max detour to 5 minutes#57
GeiserX merged 1 commit into
mainfrom
fix/default-max-detour

Conversation

@GeiserX

@GeiserX GeiserX commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • maxDetour now defaults to 5 min (was "no limit") on initial load and resets to 5 on fuel change, so users see only worthwhile stops by default. The slider still goes up to "no limit".
  • Adds regression tests confirming the autocomplete dropdown closes on selection (component-level + full SearchPanel, with real focus/pointer semantics).

Test plan

  • tsc clean
  • 475 tests pass (node + components)

Summary by CodeRabbit

  • Bug Fixes

    • Fixed detour distance constraint to reset to default value when changing fuel selection.
  • Tests

    • Added test coverage for autocomplete dropdown behavior in search functionality.

Show only worthwhile stops by default — maxDetour now starts at 5 min
(and resets to 5 on fuel change) instead of "no limit". Users can still
widen it via the slider. Adds autocomplete/search-panel regression tests
for dropdown-closes-on-select.
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR changes the default detour time constraint in the home client from null to 5 minutes and resets it to 5 instead of null when fuel type changes. Two new test suites validate that autocomplete suggestion dropdowns close after selecting a result in both AutocompleteInput and SearchPanel components.

Changes

Default detour constraint

Layer / File(s) Summary
maxDetour initialization and reset
src/components/home-client.tsx
maxDetour state is initialized to 5 and resets to 5 on fuel change instead of null, establishing a 5-minute default detour constraint.

Autocomplete dropdown closure tests

Layer / File(s) Summary
AutocompleteInput dropdown closure test
src/components/search/autocomplete-input.test.tsx
Test suite validates dropdown closure after selecting a destination result, with cases for standard selection and location-mode selection.
SearchPanel dropdown closure test
src/components/search/search-panel.test.tsx
Test verifies that selecting a geocoded origin result closes the suggestions dropdown in the search panel.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: defaulting maxDetour to 5 minutes instead of null/no limit.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/default-max-detour

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/search/autocomplete-input.test.tsx`:
- Around line 10-15: The test constant RESULT is missing the
PhotonResult.country property and is being force-cast with "as PhotonResult", so
update the object literal for RESULT to include country: null explicitly (and
remove the unnecessary type assertion if preferred) so the value matches the
PhotonResult shape in strict mode; refer to the constant name RESULT and the
PhotonResult type to locate and fix the object definition in
autocomplete-input.test.tsx.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b2b8adac-450d-4dd3-a213-e48583f4e13b

📥 Commits

Reviewing files that changed from the base of the PR and between 35c1e4f and 1492161.

📒 Files selected for processing (3)
  • src/components/home-client.tsx
  • src/components/search/autocomplete-input.test.tsx
  • src/components/search/search-panel.test.tsx

Comment on lines +10 to +15
const RESULT: PhotonResult = {
name: "Madrid",
city: "Madrid",
state: "Comunidad de Madrid",
coordinates: [-3.7, 40.4],
} as PhotonResult;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Explicitly declare country: null to satisfy strict mode.

The as PhotonResult cast bypasses TypeScript's requirement that all properties be explicitly present in strict mode. The country field is omitted, so at runtime it will be undefined rather than null.

🔧 Proposed fix
 const RESULT: PhotonResult = {
   name: "Madrid",
   city: "Madrid",
   state: "Comunidad de Madrid",
+  country: null,
   coordinates: [-3.7, 40.4],
 } as PhotonResult;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/search/autocomplete-input.test.tsx` around lines 10 - 15, The
test constant RESULT is missing the PhotonResult.country property and is being
force-cast with "as PhotonResult", so update the object literal for RESULT to
include country: null explicitly (and remove the unnecessary type assertion if
preferred) so the value matches the PhotonResult shape in strict mode; refer to
the constant name RESULT and the PhotonResult type to locate and fix the object
definition in autocomplete-input.test.tsx.

@GeiserX GeiserX merged commit d07e920 into main Jun 8, 2026
8 checks passed
@GeiserX GeiserX deleted the fix/default-max-detour branch June 8, 2026 08:52
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