Improve object registry delete address issue #144#145
Improve object registry delete address issue #144#145AumPatel1 wants to merge 4 commits intoplexe-ai:mainfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR enhances the ObjectRegistry delete method with improved error handling and optional confirmation features, alongside better scroll behavior for the chat UI. The ObjectRegistry changes address issue #144 by adding a confirm parameter that defaults to False for backward compatibility. When enabled, it displays item details and prompts for user confirmation before deletion. The error handling now shows available items of the same type when an item isn't found, making debugging significantly easier for developers working directly with the registry.
The UI improvements implement smart scroll behavior in the chat interface. The system now tracks user scroll position and only auto-scrolls to bottom for AI responses when users haven't manually scrolled up. This prevents interrupting users who are reading previous messages while maintaining expected behavior for active conversations.
Both changes integrate well with the existing codebase - the ObjectRegistry maintains its core functionality while adding developer-friendly features, and the UI enhancement builds on the existing React-based chat interface without breaking existing message handling patterns.
Important Files Changed
Files Modified
| Filename | Score | Overview |
|---|---|---|
| plexe/core/object_registry.py | 2/5 | Enhanced delete method with confirmation prompt and improved error messages showing available items |
| plexe/ui/index.html | 4/5 | Added smart scroll behavior to prevent auto-scroll interruption when users are reading chat history |
Confidence score: 2/5
- This PR has significant concerns due to the interactive
input()call in ObjectRegistry that could break in non-interactive environments - Score lowered primarily due to the confirmation feature using blocking user input which is problematic for automated systems, tests, and server deployments
- Pay close attention to plexe/core/object_registry.py - the
input()call on line 142 needs careful consideration for production usage
Sequence Diagram
sequenceDiagram
participant User
participant ObjectRegistry
participant Logger
participant Console
User->>ObjectRegistry: "delete(t, name, confirm=False)"
alt Item exists in registry
ObjectRegistry->>ObjectRegistry: "Check if URI exists"
alt confirm=True
ObjectRegistry->>Console: "Print item details"
Console->>User: "Show deletion confirmation"
User->>Console: "Enter y/n response"
Console->>ObjectRegistry: "Return user response"
alt User confirms (y)
ObjectRegistry->>ObjectRegistry: "Delete item from _items"
ObjectRegistry->>Logger: "Log successful deletion"
else User cancels (n)
ObjectRegistry->>Logger: "Log cancellation"
ObjectRegistry->>User: "Return without deletion"
end
else confirm=False (default)
ObjectRegistry->>ObjectRegistry: "Delete item from _items"
ObjectRegistry->>Logger: "Log successful deletion"
end
else Item not found
ObjectRegistry->>ObjectRegistry: "list_by_type(t)"
ObjectRegistry->>ObjectRegistry: "Build helpful error message"
ObjectRegistry->>Logger: "Log warning with available items"
ObjectRegistry->>User: "Raise KeyError with suggestions"
end
2 files reviewed, no comments
This PR improves the ObjectRegistry delete method by adding better error handling and optional confirmation features. When an item is not found, the error message now shows available items of the same type, making debugging much easier. An optional confirmation parameter (defaulting to False for backward compatibility) allows users to see item details before deletion, preventing accidental deletions. The changes maintain full backward compatibility - existing code continues to work without modification, and the new features are only active when explicitly requested. This improvement primarily benefits developers using ObjectRegistry directly and advanced Plexe users who need registry management, while not affecting end users who interact through AI agents. The enhancement provides a better developer experience without adding friction to existing workflows.