Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • fixed popover issue in custom tools modal, removed the ability to update if no changes made

Type of Change

  • Bug fix
  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 20, 2026 7:51am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

This PR fixes popover keyboard navigation issues when input fields are focused and adds change tracking to the custom tool modal to prevent accidental data loss.

Key Changes:

  • Popover keyboard fix: Added input focus detection in PopoverContent to prevent arrow key navigation from interfering when typing in input fields, text areas, or contenteditable elements
  • Custom tool modal improvements:
    • Added change tracking by storing initial values (initialJsonSchema, initialFunctionCode)
    • Implemented unsaved changes detection with a discard confirmation dialog
    • Disabled save button when no changes are made in edit mode
    • Refactored validation logic into reusable validateSchema() function that returns both validity and error messages
    • Improved keyboard handling: changed break to return for Arrow/Enter/Escape keys to prevent event fallthrough
    • Removed unused schemaPromptSummary and codePromptSummary state
    • Added onStreamStart callbacks to clear editors before AI generation
  • Color picker improvements: Added onColorChange callback, improved focus ring styling, and fixed Space/Enter key event propagation
  • Minor fixes: Added e.stopPropagation() in workspace header rename input, made code editor minHeight optional
  • Color standardization: Updated text colors from --text-tertiary to --text-secondary across 10+ modal components for visual consistency

Confidence Score: 4/5

  • Safe to merge with one keyboard handling fix needed
  • The PR successfully addresses popover keyboard interference and adds robust change tracking. One logical issue found: Space/Tab keys in custom-tool-modal parameter dropdown need e.preventDefault() to avoid unintended browser behavior. The validation refactor is well-structured, change tracking logic is sound, and color standardization is straightforward. Most changes improve UX without affecting core functionality.
  • Pay close attention to custom-tool-modal.tsx line 692-695 - needs preventDefault() added for Space/Tab keys

Important Files Changed

Filename Overview
apps/sim/components/emcn/components/popover/popover.tsx Added input focus detection to prevent keyboard navigation interference when typing
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/custom-tool-modal/custom-tool-modal.tsx Major refactor: added change tracking, discard alert, improved validation, and keyboard handling fixes
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/context-menu/context-menu.tsx Improved color picker keyboard navigation with event propagation fixes and visual focus indicators
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx Added event propagation stop to prevent keyboard interference when renaming
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/code-editor/code-editor.tsx Made minHeight optional and conditional to avoid setting undefined inline styles

Sequence Diagram

sequenceDiagram
    participant User
    participant CustomToolModal
    participant PopoverContent
    participant ValidationSystem
    participant ChangeTracking

    User->>CustomToolModal: Opens modal (new or edit)
    CustomToolModal->>ChangeTracking: Store initial values
    
    User->>CustomToolModal: Types in schema editor
    CustomToolModal->>PopoverContent: Shows parameter dropdown
    PopoverContent->>PopoverContent: Check if input focused
    Note over PopoverContent: New: Skip keyboard nav if input focused
    
    User->>PopoverContent: Presses Arrow/Enter/Space
    PopoverContent->>CustomToolModal: Navigate/select parameter
    CustomToolModal->>CustomToolModal: Insert parameter
    
    User->>CustomToolModal: Modifies schema/code
    CustomToolModal->>ValidationSystem: Validate schema
    ValidationSystem->>CustomToolModal: Return validation result
    CustomToolModal->>ChangeTracking: Check for changes
    ChangeTracking->>CustomToolModal: Enable/disable save button
    
    User->>CustomToolModal: Attempts to close
    CustomToolModal->>ChangeTracking: Check hasUnsavedChanges
    alt Has unsaved changes
        CustomToolModal->>User: Show discard alert
        User->>CustomToolModal: Confirm or cancel
    else No unsaved changes
        CustomToolModal->>User: Close immediately
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

cursor[bot]

This comment was marked as outdated.

@waleedlatif1
Copy link
Collaborator Author

@greptile

cursor[bot]

This comment was marked as outdated.

@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

cursor[bot]

This comment was marked as outdated.

@waleedlatif1 waleedlatif1 merged commit 84691fc into staging Jan 20, 2026
7 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/customtools branch January 20, 2026 07:52
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

variant='tertiary'
onClick={handleSave}
disabled={!isSchemaValid || !!schemaError}
disabled={!isSchemaValid || !!schemaError || !hasChanges}
Copy link

Choose a reason for hiding this comment

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

Cancel button bypasses unsaved changes confirmation

Medium Severity

The Cancel buttons call handleClose directly instead of handleCloseAttempt, bypassing the newly-added unsaved changes confirmation. This creates inconsistent behavior where pressing Escape or clicking outside shows a discard confirmation dialog, but clicking Cancel closes immediately without warning, potentially causing users to lose their work unexpectedly.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

2 participants