Skip to content

Cpk 2443 travel demo - #1913

Merged
copilotkit-support merged 3 commits into
mainfrom
CPK-2443-Travel-Demo
Jun 6, 2025
Merged

copilotkit-support merged 3 commits into
mainfrom
CPK-2443-Travel-Demo

Conversation

@copilotkit-support

@copilotkit-support copilotkit-support commented Jun 2, 2025 •

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR addresses the demo ticket #2443. This allows the addition of checkboxes and updated dropdown UI

  • I have read the Contribution Guide
  • If the PR changes or adds functionality, I have updated the relevant documentation

Summary by CodeRabbit

  • New Features

    • Enhanced trip editing and adding workflows with interactive selection of places within trips.
    • Place cards now support checkboxes for selecting places to add or edit.
    • Action buttons handle selected places for both add and edit actions.
  • Improvements

    • Visual indication of the selected trip in the trip selector is now shown with bold styling instead of disabling the menu item.
    • The trip editor now clearly displays only the places that differ between trips for easier comparison.
  • Bug Fixes

    • Ensured a default trip is always selected to prevent issues with undefined trip IDs.
  • Refactor

    • Improved state management and prop passing to ensure components receive the latest trip and selection data.
  • Style

    • Minor formatting and layout adjustments for consistency.
  • Chores

    • Removed unnecessary trailing newlines from several files.

…logic in trips.py, and add checkbox visibility control in PlaceCard component
…logic in trips.py, and add checkbox visibility control in PlaceCard component
@linear

linear Bot commented Jun 2, 2025

Copy link
Copy Markdown

@vercel

vercel Bot commented Jun 2, 2025 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ag2-feature-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
ag2-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
coagents-starter-crewai-flows ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
copilot-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
copilot-kit-qd8p ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
copilot-kit-wq8x ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
copilot-mastra-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
copilotkit-feature-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
copilotkit-mastra-feature-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
demo-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
examples-coagents-ai-travel-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
examples-coagents-research-canvas-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 10:37am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
examples-coagents-ai-researcher-ui ⬜️ Ignored (Inspect) Visit Preview Jun 6, 2025 10:37am

@tylerslaton

Copy link
Copy Markdown
Contributor

Hey @orca-copilotkit I gave this a test. Some initial feedback.

  1. If I select a collection of items, I notice that those selections are not respected by the LLM. For example, if I select a subset of suggestions then it will still add all of them.
  2. When the agent is editing a trip, we should only include the delta of suggestions to include. I.E if I have a trip with 3 places already selected, then the suggestion from the agent should only include what is new.

@tylerslaton tylerslaton closed this Jun 2, 2025
@tylerslaton tylerslaton reopened this Jun 2, 2025
…ort in ActionButtons and EditTrips components, and update trips filtering logic in trips.py
@changesets-bot-copilotkit

Copy link
Copy Markdown

⏭️ Changeset Not Required

Latest commit: 76b5d00

No changes in this PR affected the @copilitkit/* packages. Merging this PR will not cause a version bump for any packages.

Changeset is not required for this PR.

@coderabbitai

coderabbitai Bot commented Jun 6, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce interactive selection of places within trips in the coagents travel example. The UI components for adding and editing trips now support selecting specific places via checkboxes, with the selection state managed in React and passed to action handlers. The backend logic in trips.py is updated to parse and process these selections, handling different modes for adding or editing trips. Visual and behavioral updates to components ensure checkboxes are conditionally shown, and trip selection UI is improved.

Changes

File(s) Change Summary
agent/travel/trips.py Added JSON parsing and conditional logic in perform_trips_node to handle selected places and modes; updated handle_add_trips to set selected_trip_id after adding trips; minor formatting changes.
ui/components/PlaceCard.tsx Enhanced to support optional checkbox display with new props: checked, onCheck, and shouldShowCheckbox. Checkbox state and handler are integrated into the component layout.
ui/components/MapCanvas.tsx, ui/components/PlaceForMap.tsx Updated PlaceCard usage to explicitly set shouldShowCheckbox={false} to hide checkboxes in map-related contexts.
ui/components/humanInTheLoop/ActionButtons.tsx Refactored to accept selectedPlaceIds and type props; updated approve handler to serialize selected IDs and mode; added logging of selection state.
ui/components/humanInTheLoop/AddTrips.tsx Added state for tracking selected place IDs; checkboxes in PlaceCard reflect and update this state; passes selection to ActionButtons.
ui/components/humanInTheLoop/EditTrips.tsx Accepts trips and selectedTripId as props; tracks selected places; computes and renders only differing places; integrates checkbox selection and passes to ActionButtons with type="edit".
ui/lib/hooks/use-trips.tsx Ensures default selected_trip_id is always set; updates how EditTrips is rendered for copilot actions to pass current trips and selected trip ID as props.
ui/components/TripSelect.tsx Changes selected trip menu item to be visually distinct (bold, dark text) instead of disabled, allowing interaction with all items.
ui/components/EditPlace.tsx, ui/components/PlaceForm.tsx, ui/components/SearchProgress.tsx, ui/components/TripContent.tsx Removed trailing newlines; no functional changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AddTrips/EditTrips UI
    participant PlaceCard
    participant ActionButtons
    participant Backend (trips.py)

    User->>AddTrips/EditTrips UI: Selects/deselects places (checkboxes)
    AddTrips/EditTrips UI->>PlaceCard: Renders with checked/onCheck props
    User->>ActionButtons: Clicks Approve
    ActionButtons->>Backend (trips.py): Sends selectedPlaceIds + mode (edit/add)
    Backend (trips.py)->>Backend (trips.py): Parses selection and mode, updates trip state accordingly
Loading

Suggested reviewers

  • tylerslaton
  • mme
✨ 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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

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.

@github-actions

github-actions Bot commented Jun 6, 2025 •

Copy link
Copy Markdown
Contributor

Preview environments destroyed for this pull request.

@github-actions

github-actions Bot commented Jun 6, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

Status: ✅ Passed (View Run)

Commit: efcf3e0

Duration: 347.2s

Total Tests: 32

Pass Rate: 100.0%

Failed Tests: 0

🔍 Detailed Results

coagents-research-canvas

CoAgents Research Canvas (UI) - Local Depenencies

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
CrewAI chromium ✅ PASSED -
OpenAI (LGC Python in-memory) chromium ✅ PASSED -
Anthropic (LGC Python in-memory) chromium ✅ PASSED -
OpenAI (LGC JS in-memory) chromium ✅ PASSED -
Anthropic (LGC JS in-memory) chromium ✅ PASSED -

coagents-qa-native

CoAgents QA Native (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
OpenAI (LGC Python) chromium ✅ PASSED -
Anthropic (LGC Python) chromium ✅ PASSED -
OpenAI (LGC JS) chromium ✅ PASSED -
Anthropic (LGC JS) chromium ✅ PASSED -

coagents-qa-text

CoAgents QA Text (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
OpenAI (LGC Python) chromium ✅ PASSED -
Anthropic (LGC Python) chromium ✅ PASSED -
OpenAI (LGC JS) chromium ✅ PASSED -
Anthropic (LGC JS) chromium ✅ PASSED -

coagents-routing

CoAgents Routing (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
OpenAI (LGC Python) chromium ✅ PASSED -
Anthropic (LGC Python) chromium ✅ PASSED -
OpenAI (LGC JS) chromium ✅ PASSED -
Anthropic (LGC JS) chromium ✅ PASSED -

next-openai

Next OpenAI - Self Hosted

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
Google Generative AI chromium ✅ PASSED -
LangChain (OpenAI) chromium ✅ PASSED -
LangChain (Anthropic) chromium ✅ PASSED -
LangChain (Gemini) chromium ✅ PASSED -
Groq chromium ✅ PASSED -

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🧹 Nitpick comments (4)
examples/coagents-travel/agent/travel/trips.py (1)

99-99: Remove unnecessary f-string prefix.

The f-string doesn't contain any placeholders.

-    return AIMessage(content=f"Successfully updated the trip(s)!")
+    return AIMessage(content="Successfully updated the trip(s)!")
🧰 Tools
🪛 Ruff (0.11.9)

99-99: f-string without any placeholders

Remove extraneous f prefix

(F541)

examples/coagents-travel/ui/components/humanInTheLoop/AddTrips.tsx (1)

8-8: Remove unused import.

The useTrips import is not used in this component.

-import { useEffect, useState } from "react";
-import { useTrips } from "@/lib/hooks/use-trips";
+import { useState } from "react";
examples/coagents-travel/ui/components/humanInTheLoop/ActionButtons.tsx (1)

16-18: Remove debug logging.

The useEffect with console.log should be removed from production code.

-  useEffect(() => {
-    console.log(selectedPlaceIds,"btn");
-  }, [selectedPlaceIds]);
examples/coagents-travel/ui/components/PlaceCard.tsx (1)

16-18: Consider adding prop validation for checkbox functionality.

The new checkbox-related props are well-defined, but consider adding TypeScript constraints or runtime validation to ensure type safety.

Consider updating the prop types to be more explicit:

- checked?: boolean;
- onCheck?: (checked: boolean) => void;
+ checked?: boolean;
+ onCheck?: (checked: boolean | string) => void;

The Checkbox component's onCheckedChange might accept boolean | string based on typical UI library patterns.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a2b0e7 and 76b5d00.

📒 Files selected for processing (13)
  • examples/coagents-travel/agent/travel/trips.py (4 hunks)
  • examples/coagents-travel/ui/components/EditPlace.tsx (1 hunks)
  • examples/coagents-travel/ui/components/MapCanvas.tsx (2 hunks)
  • examples/coagents-travel/ui/components/PlaceCard.tsx (3 hunks)
  • examples/coagents-travel/ui/components/PlaceForMap.tsx (2 hunks)
  • examples/coagents-travel/ui/components/PlaceForm.tsx (1 hunks)
  • examples/coagents-travel/ui/components/SearchProgress.tsx (1 hunks)
  • examples/coagents-travel/ui/components/TripContent.tsx (1 hunks)
  • examples/coagents-travel/ui/components/TripSelect.tsx (1 hunks)
  • examples/coagents-travel/ui/components/humanInTheLoop/ActionButtons.tsx (1 hunks)
  • examples/coagents-travel/ui/components/humanInTheLoop/AddTrips.tsx (3 hunks)
  • examples/coagents-travel/ui/components/humanInTheLoop/EditTrips.tsx (2 hunks)
  • examples/coagents-travel/ui/lib/hooks/use-trips.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
examples/coagents-travel/ui/components/MapCanvas.tsx (1)
examples/coagents-travel/ui/components/PlaceCard.tsx (1)
  • PlaceCard (21-64)
examples/coagents-travel/ui/components/humanInTheLoop/AddTrips.tsx (2)
examples/coagents-travel/ui/components/PlaceCard.tsx (1)
  • PlaceCard (21-64)
examples/coagents-travel/ui/components/humanInTheLoop/ActionButtons.tsx (1)
  • ActionButtons (14-51)
examples/coagents-travel/ui/lib/hooks/use-trips.tsx (1)
examples/coagents-travel/ui/components/humanInTheLoop/EditTrips.tsx (1)
  • EditTrips (16-65)
🪛 Ruff (0.11.9)
examples/coagents-travel/agent/travel/trips.py

99-99: f-string without any placeholders

Remove extraneous f prefix

(F541)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Build Images (next-openai, next-openai)
  • GitHub Check: Build Images (coagents-qa-native, ui)
  • GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-qa-text, ui)
  • GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-routing, ui)
  • GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-research-canvas, ui)
  • GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
🔇 Additional comments (20)
examples/coagents-travel/ui/components/PlaceForm.tsx (1)

98-98: Trivial change: removed trailing newline
No functional impact—this is just an EOF cleanup.

examples/coagents-travel/ui/components/PlaceCard.tsx (5)

7-7: LGTM: Proper import addition.

The Checkbox component import is correctly added.


42-45: LGTM: Well-structured layout for actions and checkbox.

The flex layout properly accommodates both the existing actions and the new checkbox. The conditional rendering of the checkbox is correctly implemented with the shouldShowCheckbox prop.

However, consider enhancing accessibility:

-              {shouldShowCheckbox && <Checkbox checked={checked} onCheckedChange={onCheck} />}
+              {shouldShowCheckbox && <Checkbox checked={checked} onCheckedChange={onCheck} aria-label={checkboxAriaLabel || `Select ${place.name}`} />}

7-7: LGTM: Checkbox import added correctly.

The import for the Checkbox component is properly added.


21-21: LGTM: Function signature updated correctly.

The function signature properly includes all new props with appropriate default value for shouldShowCheckbox.


42-45:

Details

✅ Verification successful

Verify checkbox integration with selection handling.

The checkbox implementation looks correct, but based on the PR objectives, there are known issues with selection handling where the LLM doesn't respect user selections. Ensure the onCheck callback properly updates the selection state that will be passed to the backend.

Let me verify how the checkbox state is being used in parent components:


🏁 Script executed:

#!/bin/bash
# Description: Check how PlaceCard checkbox props are used in parent components

# Search for PlaceCard usage with checkbox-related props
rg -A 10 -B 5 "PlaceCard.*checked|onCheck|shouldShowCheckbox" --type tsx --type ts

# Search for selection state management in related components
rg -A 5 -B 5 "selectedPlaceIds|selection" --type tsx --type ts

Length of output: 205


🏁 Script executed:

#!/bin/bash
# Locate all usages of PlaceCard in the codebase
rg "PlaceCard" -A5 -B5

# Find where onCheck callback is defined or passed down
rg "onCheck" -A5 -B5

# Search for selection state management variables and their updates
rg "selectedPlaceIds" -A5 -B5
rg "selection" -A5 -B5

Length of output: 79050


Checkbox selection handling verified

  • In AddTrips and EditTrips, the onCheck callback (handleCheck) correctly adds/removes place IDs in the selectedPlaceIds state.
  • ActionButtons receives selectedPlaceIds and serializes/passes them to the backend via its handler.

No further changes required.

examples/coagents-travel/ui/components/EditPlace.tsx (2)

68-68: LGTM: Minor formatting improvement.

Removal of trailing newline improves code consistency.


68-68: Minor formatting change - no functional impact.

Removal of trailing newline is a minor formatting improvement.

examples/coagents-travel/ui/components/SearchProgress.tsx (2)

32-32: LGTM: Minor formatting improvement.

Removal of trailing newline improves code consistency.


32-32: Minor formatting change - no functional impact.

Removal of trailing newline is a minor formatting improvement.

examples/coagents-travel/ui/components/PlaceForMap.tsx (3)

57-57: LGTM: Appropriate checkbox disabling for map context.

Correctly disables checkboxes in the map context where they would be inappropriate for the user experience. This demonstrates proper usage of the new shouldShowCheckbox prop.


57-66:

Details

✅ Verification successful

Verify integration with broader selection system.

While the UI changes look correct, based on the PR feedback about selection handling issues, ensure that the broader selection state management properly handles the interaction between map-displayed places and the selection system used in other components.


🏁 Script executed:

#!/bin/bash
# Description: Check how place selection is handled across different components
# Expected: Find consistent selection state management between components

# Search for selectedPlaceIds usage across components
rg -A 5 "selectedPlaceIds" --type ts --type tsx

# Search for onCheck handlers and selection logic
rg -A 5 "onCheck" --type ts --type tsx

# Look for trip editing and selection logic
rg -A 10 "EditTrips|AddTrips" --type ts --type tsx

Length of output: 223


Let’s retry the search without relying on ripgrep’s built-in types (which don’t include .tsx by default):


🏁 Script executed:

#!/bin/bash
# Search for selection state usage in both .ts and .tsx files
rg -A5 selectedPlaceIds -g '*.ts' -g '*.tsx'
rg -A5 onCheck          -g '*.ts' -g '*.tsx'
rg -A10 'EditTrips|AddTrips' -g '*.ts' -g '*.tsx'

Length of output: 21596


Selection integration verified

I confirmed that selection state is managed locally within the trip‐editor components and that map‐displayed places explicitly disable the checkbox:

• In examples/coagents-travel/ui/components/humanInTheLoop/AddTrips.tsx and EditTrips.tsx, you use a selectedPlaceIds state, handleCheck, and pass both to PlaceCard.
• PlaceCard.tsx supports checked/onCheck props but defaults shouldShowCheckbox to false in the map view (PlaceForMap.tsx), preventing any map‐based selection.
• No other global or shared selection context (e.g. via hooks or context) is in use.

If you intend to allow selecting places directly on the map, you’ll need to wire up checked and onCheck from the parent. Otherwise, the current isolation of selection logic to the Add/Edit flows is correct and there are no outstanding integration issues.


57-57: LGTM: Appropriately disables checkbox in map context.

Disabling the checkbox display for map-based place cards is the correct approach, as selection functionality would be inappropriate in this viewing context.

examples/coagents-travel/ui/components/TripContent.tsx (1)

26-26: LGTM! Minor formatting cleanup.

Removing the trailing newline is a standard code formatting improvement with no functional impact.

examples/coagents-travel/ui/components/MapCanvas.tsx (1)

57-57: LGTM! Appropriate UX decision.

Disabling checkboxes in map tooltips is the correct approach - checkboxes would be inappropriate and confusing in this context where users are just viewing place information on the map.

examples/coagents-travel/ui/components/TripSelect.tsx (1)

22-27: LGTM! Improved user experience.

Changing from disabled to styled selected items is a good UX improvement. Users can now re-select the current trip if needed, while still having clear visual indication of which trip is selected.

examples/coagents-travel/agent/travel/trips.py (1)

71-71: Good addition for state consistency.

Setting the selected_trip_id when adding trips ensures proper state management and UI synchronization.

examples/coagents-travel/ui/components/humanInTheLoop/AddTrips.tsx (1)

17-28: Well-implemented selection state management.

The selectedPlaceIds state and handleCheck function properly manage place selection using a Set for efficient lookups and updates.

examples/coagents-travel/ui/components/humanInTheLoop/EditTrips.tsx (2)

31-37: Well-implemented delta calculation.

The getDelta function correctly computes the symmetric difference between place arrays, showing only places that differ between the current trip and selected trip.


55-61: Proper integration with ActionButtons.

The component correctly passes selectedPlaceIds and type="edit" to ActionButtons, enabling proper serialization of edit mode operations.

};

export function PlaceCard({ place, actions, onMouseEnter, onMouseLeave, className, number }: PlaceCardProps) {
export function PlaceCard({ place, actions, onMouseEnter, onMouseLeave, className, number, checked, onCheck, shouldShowCheckbox = true }: PlaceCardProps) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update function signature to include new accessibility prop.

If implementing the accessibility improvement, update the function signature accordingly.

-export function PlaceCard({ place, actions, onMouseEnter, onMouseLeave, className, number, checked, onCheck, shouldShowCheckbox = true }: PlaceCardProps) {
+export function PlaceCard({ place, actions, onMouseEnter, onMouseLeave, className, number, checked, onCheck, shouldShowCheckbox = true, checkboxAriaLabel }: PlaceCardProps) {
🤖 Prompt for AI Agents
In examples/coagents-travel/ui/components/PlaceCard.tsx at line 21, the function
signature for PlaceCard needs to be updated to include the new accessibility
prop. Add the new accessibility prop to the list of destructured props in the
function parameters to ensure it is accepted and can be used within the
component.

Comment on lines +16 to +18
checked?: boolean;
onCheck?: (checked: boolean) => void;
shouldShowCheckbox?: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider improving accessibility with proper labeling.

The checkbox props are well-typed, but the checkbox may lack proper accessibility attributes. Consider adding an aria-label or associating it with descriptive text for screen readers.

  checked?: boolean;
- onCheck?: (checked: boolean) => void;
+ onCheck?: (checked: boolean) => void;
+ checkboxAriaLabel?: string;
  shouldShowCheckbox?: boolean;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
checked?: boolean;
onCheck?: (checked: boolean) => void;
shouldShowCheckbox?: boolean;
checked?: boolean;
onCheck?: (checked: boolean) => void;
checkboxAriaLabel?: string;
shouldShowCheckbox?: boolean;
🤖 Prompt for AI Agents
In examples/coagents-travel/ui/components/PlaceCard.tsx around lines 16 to 18,
the checkbox input lacks proper accessibility labeling. To fix this, add an
appropriate aria-label attribute to the checkbox or associate it with a visible
label element that describes its purpose, ensuring screen readers can identify
the checkbox function clearly.

},
],
renderAndWait: EditTrips,
renderAndWait: (props) => EditTrips({ ...props, trips: state.trips, selectedTripId: state.selected_trip_id as string }),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix unsafe type assertion that could cause runtime errors.

The type assertion state.selected_trip_id as string is unsafe since selected_trip_id can be null (as defined in the context type and set via setSelectedTripId). This could cause runtime errors in the EditTrips component.

Handle the null case properly:

-    renderAndWait: (props) => EditTrips({ ...props, trips: state.trips, selectedTripId: state.selected_trip_id as string }),
+    renderAndWait: (props) => EditTrips({ ...props, trips: state.trips, selectedTripId: state.selected_trip_id || "" }),

Or ensure EditTrips can handle null selectedTripId:

-    renderAndWait: (props) => EditTrips({ ...props, trips: state.trips, selectedTripId: state.selected_trip_id as string }),
+    renderAndWait: (props) => EditTrips({ ...props, trips: state.trips, selectedTripId: state.selected_trip_id }),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
renderAndWait: (props) => EditTrips({ ...props, trips: state.trips, selectedTripId: state.selected_trip_id as string }),
renderAndWait: (props) =>
EditTrips({
...props,
trips: state.trips,
- selectedTripId: state.selected_trip_id as string,
+ selectedTripId: state.selected_trip_id || "",
}),
🤖 Prompt for AI Agents
In examples/coagents-travel/ui/lib/hooks/use-trips.tsx at line 73, the code
unsafely asserts state.selected_trip_id as a string, but this value can be null,
risking runtime errors. To fix this, remove the type assertion and instead
handle the null case explicitly by either providing a fallback value when
passing selectedTripId to EditTrips or updating EditTrips to accept and
correctly handle a null selectedTripId.

initialState: {
trips: defaultTrips,
selected_trip_id: defaultTrips[0].id,
selected_trip_id: defaultTrips[0].id || "1",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix hardcoded fallback to use actual default trip ID.

The hardcoded fallback "1" assumes the first default trip has ID "1", but this may not be true. This could cause the selected trip to not match any actual trip.

Use the actual default trip ID:

-      selected_trip_id: defaultTrips[0].id || "1",
+      selected_trip_id: defaultTrips[0]?.id || defaultTrips[0]?.id || "1",

Better yet, ensure defaultTrips is never empty or handle the empty case explicitly:

-      selected_trip_id: defaultTrips[0].id || "1",
+      selected_trip_id: defaultTrips.length > 0 ? defaultTrips[0].id : null,

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

🤖 Prompt for AI Agents
In examples/coagents-travel/ui/lib/hooks/use-trips.tsx at line 28, replace the
hardcoded fallback "1" for selected_trip_id with a proper check to ensure
defaultTrips is not empty before accessing defaultTrips[0].id. If defaultTrips
can be empty, handle that case explicitly by providing a safe fallback or
conditional logic to avoid referencing an undefined ID.

Comment on lines +25 to +37
if tool_message.content != "SEND":
args = ai_message.tool_calls[0].get("args", {})
trips = args.get("trips", [])
lst = json.loads(tool_message.content)
editMode = tool_message.content.split("|||")[1]
lst = lst.split("|||")[0]
lst = lst.split(",")
filtered_lst = [item for item in trips[0]["places"] if item["id"] in lst]
if editMode.strip().lower() == 'editmode"':
existing_places = next(x for x in state["trips"] if x["id"] == args["trips"][0]["id"])["places"]
args["trips"][0]["places"] =existing_places + filtered_lst
else:
args["trips"][0]["places"] = filtered_lst

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical syntax error and parsing logic issues.

Multiple critical issues in the parsing logic:

  1. Syntax Error (Line 33): Mismatched quotes in 'editmode"' - should be 'editmode'
  2. Logic Error (Lines 29-30): editMode is extracted from tool_message.content.split("|||")[1] but then lst is reassigned from the split, overwriting the JSON.loads result
  3. Missing Error Handling: JSON parsing could fail if tool_message.content is not valid JSON

Apply this diff to fix the critical issues:

-    if tool_message.content != "SEND":
-        args = ai_message.tool_calls[0].get("args", {})
-        trips = args.get("trips", [])
-        lst = json.loads(tool_message.content)
-        editMode = tool_message.content.split("|||")[1]
-        lst = lst.split("|||")[0]
-        lst = lst.split(",")
-        filtered_lst = [item for item in trips[0]["places"] if item["id"] in lst]
-        if editMode.strip().lower() == 'editmode"':
+    if tool_message.content != "SEND":
+        try:
+            args = ai_message.tool_calls[0].get("args", {})
+            trips = args.get("trips", [])
+            content_parts = tool_message.content.split("|||")
+            if len(content_parts) >= 2:
+                place_ids_json = content_parts[0] 
+                edit_mode = content_parts[1]
+                place_ids = json.loads(place_ids_json)
+                filtered_lst = [item for item in trips[0]["places"] if item["id"] in place_ids]
+                if edit_mode.strip().lower() == 'editmode':
+                    existing_places = next(x for x in state["trips"] if x["id"] == args["trips"][0]["id"])["places"]
+                    args["trips"][0]["places"] = existing_places + filtered_lst
+                else:
+                    args["trips"][0]["places"] = filtered_lst
+        except (json.JSONDecodeError, IndexError, KeyError) as e:
+            # Log error and fall back to default behavior
+            pass

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

🤖 Prompt for AI Agents
In examples/coagents-travel/agent/travel/trips.py around lines 25 to 37, fix the
syntax error by correcting the mismatched quotes in the editMode comparison to
use consistent single quotes. Adjust the parsing logic to first split
tool_message.content by "|||", assign the JSON part to a variable, then parse it
with json.loads without overwriting it. Also, add error handling around the JSON
parsing to catch and handle invalid JSON content gracefully.

Comment on lines +39 to +44
<PlaceCard
key={place.id}
place={place}
checked={selectedPlaceIds.has(place.id)}
onCheck={(checked) => handleCheck(place.id, checked as boolean)}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add defensive programming for place IDs.

Consider adding a check to ensure places have valid IDs before rendering checkboxes.

              <PlaceCard
                key={place.id}
                place={place}
-                checked={selectedPlaceIds.has(place.id)}
-                onCheck={(checked) => handleCheck(place.id, checked as boolean)}
+                checked={place.id ? selectedPlaceIds.has(place.id) : false}
+                onCheck={place.id ? (checked) => handleCheck(place.id, checked as boolean) : undefined}
              />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<PlaceCard
key={place.id}
place={place}
checked={selectedPlaceIds.has(place.id)}
onCheck={(checked) => handleCheck(place.id, checked as boolean)}
/>
<PlaceCard
key={place.id}
place={place}
checked={place.id ? selectedPlaceIds.has(place.id) : false}
onCheck={place.id ? (checked) => handleCheck(place.id, checked as boolean) : undefined}
/>
🤖 Prompt for AI Agents
In examples/coagents-travel/ui/components/humanInTheLoop/AddTrips.tsx around
lines 39 to 44, the code assumes all places have valid IDs when rendering
PlaceCard components. Add a defensive check to verify that each place has a
valid, non-null, and non-undefined ID before rendering the PlaceCard and
handling its checked state. This can be done by filtering out places without
valid IDs or conditionally rendering PlaceCard only if place.id is valid.

Comment on lines +34 to +44
if (selectedPlaceIds) {
if(type == "edit"){
console.log(Array.from(selectedPlaceIds), "selectedPlaceIds")
handler?.(JSON.stringify(Array.from(selectedPlaceIds)+"|||editMode"));
} else {
console.log(Array.from(selectedPlaceIds), "selectedPlaceIds")
handler?.(JSON.stringify(Array.from(selectedPlaceIds)+"|||addMode"));
}
} else {
handler?.("SEND");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix JSON serialization and comparison operator.

Critical issues in the serialization logic:

  1. Incorrect JSON serialization: Concatenating string to array before JSON.stringify
  2. Loose equality: Using == instead of ===
  3. Inconsistent format: The serialized format doesn't match backend parsing expectations

Apply this diff to fix the serialization:

          if (selectedPlaceIds) {
-            if(type == "edit"){
-              console.log(Array.from(selectedPlaceIds), "selectedPlaceIds")
-              handler?.(JSON.stringify(Array.from(selectedPlaceIds)+"|||editMode"));
+            if(type === "edit"){
+              handler?.(JSON.stringify(Array.from(selectedPlaceIds)) + "|||editMode");
            } else {
-              console.log(Array.from(selectedPlaceIds), "selectedPlaceIds")
-              handler?.(JSON.stringify(Array.from(selectedPlaceIds)+"|||addMode"));
+              handler?.(JSON.stringify(Array.from(selectedPlaceIds)) + "|||addMode");
            }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (selectedPlaceIds) {
if(type == "edit"){
console.log(Array.from(selectedPlaceIds), "selectedPlaceIds")
handler?.(JSON.stringify(Array.from(selectedPlaceIds)+"|||editMode"));
} else {
console.log(Array.from(selectedPlaceIds), "selectedPlaceIds")
handler?.(JSON.stringify(Array.from(selectedPlaceIds)+"|||addMode"));
}
} else {
handler?.("SEND");
}
if (selectedPlaceIds) {
if (type === "edit") {
handler?.(JSON.stringify(Array.from(selectedPlaceIds)) + "|||editMode");
} else {
handler?.(JSON.stringify(Array.from(selectedPlaceIds)) + "|||addMode");
}
} else {
handler?.("SEND");
}
🤖 Prompt for AI Agents
In examples/coagents-travel/ui/components/humanInTheLoop/ActionButtons.tsx
around lines 34 to 44, fix the JSON serialization by creating an object with the
selectedPlaceIds array and mode string as separate properties before calling
JSON.stringify, instead of concatenating the array and string. Also, replace the
loose equality operator (==) with strict equality (===) wherever applicable to
ensure accurate comparisons. This will align the serialized format with backend
parsing expectations and correct the comparison logic.

Comment on lines +47 to +49
<PlaceCard key={place.id} place={place}
onCheck={(checked) => handleCheck(place.id, checked as boolean)}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing checked prop for PlaceCard.

The PlaceCard component is missing the checked prop to reflect the selection state.

            {getDelta(trip.places, trips.find((t) => t.id === selectedTripId)?.places || []).map((place) => (
              <PlaceCard key={place.id} place={place}
+                checked={selectedPlaceIds.has(place.id)}
                onCheck={(checked) => handleCheck(place.id, checked as boolean)}
              />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<PlaceCard key={place.id} place={place}
onCheck={(checked) => handleCheck(place.id, checked as boolean)}
/>
<PlaceCard key={place.id} place={place}
checked={selectedPlaceIds.has(place.id)}
onCheck={(checked) => handleCheck(place.id, checked as boolean)}
/>
🤖 Prompt for AI Agents
In examples/coagents-travel/ui/components/humanInTheLoop/EditTrips.tsx around
lines 47 to 49, the PlaceCard component is missing the checked prop that
indicates its selection state. Fix this by passing a checked prop to PlaceCard,
setting it to the current selection state for the given place.id, so the
component correctly reflects whether it is selected or not.

This branch was successfully deployed

13 active deployments
Preview – docs — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – examples-coagents-ai-travel-app — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – examples-coagents-research-canvas-ui — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – copilot-mastra-starter — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – copilot-kit-wq8x — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – copilot-kit — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – coagents-starter-crewai-flows — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – ag2-starter — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – ag2-feature-viewer — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – copilotkit-feature-viewer — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – copilotkit-mastra-feature-viewer — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – demo-viewer — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
Preview – copilot-kit-qd8p — 76b5d001 Deployed Jun 6, 2025 by vercel[bot]
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.

2 participants