-
Notifications
You must be signed in to change notification settings - Fork 10
Refactoring and upgrades #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aknarts
wants to merge
18
commits into
master
Choose a base branch
from
upgrades-refactoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… to ActionSet Add support for horizontal_alignment, separator, and spacing fields to the ActionSet variant, along with corresponding setter methods. This provides better control over ActionSet visual layout and positioning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update major dependencies: - thiserror: 1.0.63 → 2.0.17 - tungstenite: 0.23.0 → 0.28.0 - tokio-tungstenite: 0.23.1 → 0.28.0 - rust-toolchain: 1.88 → stable (1.92.0) Fix compatibility with tungstenite 0.28 by converting String to Utf8Bytes using .into() in WebSocket text message sending. Verified with build, tests, clippy, and live testing with auto-reply example. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add JetBrains IDE directory to gitignore to prevent accidentally committing IDE configuration files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fix five critical issues identified in code analysis: 1. WebSocket auth: Replace .unwrap() with proper error handling - Serialization errors now propagate instead of panicking 2. Event validation: Convert assert_eq! to Result error - Library returns proper errors instead of panicking - Updated documentation from "Panics" to "Errors" 3. HTML parsing: Fix unsafe string slicing vulnerability - Added bounds validation before slicing - Extracted logic to extract_html_title() helper function - Prevents potential panic on malicious/malformed HTML 4. Device sorting: Eliminate repeated Utc::now() calls - Capture timestamp once before sort for deterministic results - Improves performance from O(n log n) calls to O(1) 5. AdaptiveCard builder: Replace .clone() with .take() - Eliminates unnecessary Vec clones in add_body() and add_action() - Resolves TODO comment about using take() All changes verified with tests, clippy, and builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Remove unused dependencies and reduce tokio feature set:
1. Remove lazy_static dependency (unused)
- Imported but never actually used in the codebase
- Can use std::sync::LazyLock if needed in future (Rust 1.80+)
2. Replace tokio "full" with targeted features
- Before: "full" (includes fs, process, signal, parking_lot, etc.)
- After: Only what's needed for this library:
* "macros" - for #[tokio::main] and #[tokio::test]
* "net" - for TcpStream (WebSocket connections)
* "time" - for timeout, Duration, Instant
* "rt-multi-thread" - for async runtime
Benefits:
- Reduced compile-time dependencies
- Smaller binary footprint
- Clearer dependency requirements
All tests, examples, and clippy checks pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Consolidate device error handling from 5 methods down to 3: Before (5 methods): - handle_get_devices_error() - dispatcher - handle_status_error() - handle Status errors - handle_status_text_error() - handle StatusText errors (duplicate logic) - handle_forbidden_error() - handle 403 errors - log_forbidden_error() - format 403 message After (3 methods): - handle_get_devices_error() - dispatcher with documentation - handle_device_status_error() - unified status error handling - handle_device_forbidden_error() - 403 handling with inline logging Changes: 1. Merged handle_status_error and handle_status_text_error into one - Eliminated duplicate 404/403 handling logic - Uses pattern matching to handle both Error::Status and Error::StatusText - Passes original error through for better error messages 2. Inlined log_forbidden_error into handle_device_forbidden_error - Reduced function call overhead - Improved code locality for error logging 3. Added comprehensive documentation to all error handling methods - Explains the fallback logic (404 → create device, 403 → attempt creation) - Documents expected behavior for each status code 4. Added missing documentation to error.rs - All Error variants now have doc comments - Includes usage examples and common scenarios - Documents HTTP status codes and their meanings - Explains rate limiting, OAuth scope errors, etc. Benefits: - Reduced code duplication - Clearer error handling flow - Better maintainability - Comprehensive API documentation All tests, examples, and clippy checks pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace verbose multi-line error messages with concise single-line logs: 1. Device 403 Forbidden error (lines 1067-1077): Before: 9 separate error! calls with ASCII art borders After: Single formatted error message with all relevant info 2. API response parsing error (lines 485-486): Before: Two error! calls After: Single error! with combined message 3. Device creation 403 error (line 622): Before: Very long single-line message After: Concise multi-line string with proper formatting 4. Membership lookup error (lines 970-972): Before: Three separate error! calls After: Single error! with combined context 5. Device creation failure (lines 1086-1087): Before: Two error! calls After: Single error! with both messages combined Benefits: - More professional logging output - Easier to grep and filter logs - Reduced log noise - All critical information still preserved - No ASCII art borders All tests, examples, and clippy checks pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Significantly expand test coverage by adding tests for pure functions and builders that don't require network calls or complex mocking. New tests added: Error module (10 tests): - test_error_from_string/str: Test From trait implementations - test_error_closed/status/status_text: Test error display messages - test_error_limited_with/without_retry: Test rate limiting errors - test_error_api/authentication/user_error: Test specific error types AdaptiveCard module (12 tests): - test_adaptive_card_new: Test card initialization - test_adaptive_card_add_body/action: Test builder methods - test_adaptive_card_add_multiple_*: Test multiple additions - test_card_element_text_block: Test element creation - test_card_element_set_*: Test setter methods (separator, spacing, horizontal_alignment) - test_card_element_action_set/container: Test element types - test_column_new: Test column initialization Types module (7 new tests): - test_global_id_from_uuid: Test UUID to GlobalId conversion - test_global_id_check_type_*: Test type validation - test_global_id_with_cluster: Test cluster specification - test_global_id_unknown_type_error: Test error handling - test_global_id_already_encoded: Test passthrough of encoded IDs - test_message_activity_is_created: Test activity type checks Test summary: - Before: 8 tests - After: 37 tests (29 new, +362% coverage) - All tests pass - No clippy warnings Benefits: - Better code confidence for refactoring - Catches regressions in core functionality - Documents expected behavior - Fast to run (no I/O, all pure functions) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Split the 1312-line adaptive_card.rs into a well-organized directory: - mod.rs (342 lines) - Core AdaptiveCard struct and Action enum - elements.rs (748 lines) - CardElement enum with all implementations - containers.rs (110 lines) - Column, Choice, and Fact structs - styles.rs (146 lines) - All style enums (Color, Spacing, etc.) Benefits: - Better code organization and maintainability - Easier to navigate and understand - Logical grouping of related types - All tests passing (37/37) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Split the 1305-line types.rs into a well-organized directory: - mod.rs (61 lines) - Module orchestration and re-exports - person.rs (62 lines) - Person and PhoneNumber types - room.rs (82 lines) - Room, RoomListParams, RoomType, SortRoomsBy - organization.rs (98 lines) - Organization, Team, Catalog, Destination - membership.rs (49 lines) - Membership and MembershipListParams - message.rs (136 lines) - Message types and parameters - device.rs (86 lines) - Device and Authorization types - attachment.rs (44 lines) - Attachment and AttachmentAction - event.rs (750 lines) - Event, Activity, GlobalId types with tests - api.rs (76 lines) - Internal Gettable trait and ListResult Benefits: - Better code organization and maintainability - Logical grouping of related types - Easier to navigate and find specific types - All tests passing (37/37) - Preserved all functionality including tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Split the large lib.rs file (1532 lines) into a well-organized client module with three files: - src/client/rest.rs (420 lines) - Low-level REST HTTP client - src/client/websocket.rs (147 lines) - WebSocket event stream - src/client/mod.rs (1086 lines) - Main Webex client Key changes: - Reduced lib.rs from 1532 to 54 lines (thin orchestrator) - Added AuthorizationType enum for flexible auth (None, Bearer, Basic) - Added api_post_form_urlencoded for OAuth device grant flow - Fixed GET requests to use query parameters instead of body - Fixed empty response handling for 204 No Content - Made client module public for auth.rs access - Updated auth.rs imports to use new module structure - All 37 tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The Webex struct was accidentally missing the Clone derive after the refactoring, breaking downstream code that depends on cloning Webex instances (e.g., OpsBot's Chat struct). All underlying types (RestClient, DeviceData, Arc<Mutex<...>>) already implement Clone, so adding #[derive(Clone)] restores the expected API. Fixes breaking change introduced in previous refactoring commit. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced the CI pipeline with the following changes: New jobs added: - Test: Run all 37 unit tests - Clippy: Run linter (warnings only, doesn't fail build) - Format: Check code formatting with rustfmt - Documentation: Verify docs build successfully Updates: - Updated actions/checkout from v3 to v4 - Fixed typo: "Buld" → "Build" - Added RUST_BACKTRACE=1 for better error messages - Split checks into separate jobs for better visibility Bug fixes: - Fixed Event struct duplication between types/mod.rs and types/event.rs - Event methods (activity_type, try_global_id) now accessible - All examples now compile successfully - Minor doc improvements (backticks for ColumnSet, dead_code, GlobalId) All CI checks now pass: ✅ Tests (37 passing) ✅ Format check ✅ Build crate ✅ Build examples ✅ Documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Bump version from 0.10.0 to 0.11.0 - Update AGENTS.md with refactored architecture: - Document new module organization (client/, types/, adaptive_card/) - Update toolchain version to 1.92 - Add section describing v0.11.0 refactoring changes - Fix broken doc link to AdaptiveCard in event.rs All tests pass, cargo doc builds with zero warnings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit addresses all 35 clippy errors from the strict lint configuration: - Add Default implementations for Column and RestClient structs - Add #[must_use] attributes to 28 builder methods that return Self - Replace wildcard imports with explicit imports in elements.rs and client/mod.rs - Refactor branches_sharing_code by hoisting response.text().await call - Convert handle_error_response from method to associated function - Update tests and examples to handle #[must_use] warnings with let _ = ... All changes maintain backward compatibility and improve API ergonomics by ensuring builder pattern return values are not accidentally discarded. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
During the refactoring to split lib.rs into rest.rs (commit 39f3a00), special handling for team 404 errors was accidentally lost. These errors are expected when a user isn't a member of any teams and should be logged at TRACE level, not ERROR level. Changes: - Add log_error() method to RestClient that checks error context - Team 404 "Could not find teams" errors now log at trace level - All other HTTP errors continue to log at error level - Preserves the original behavior from before refactoring This fixes the regression where users saw ERROR logs for normal/expected API responses when they weren't members of any Webex teams. Fixes: 39f3a00 (refactor(client): split lib.rs into client module structure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add git hooks infrastructure to ensure consistent code formatting: Added: - hooks/pre-commit: Automatically runs cargo fmt before commits - hooks/install.sh: Easy installation script for git hooks - hooks/README.md: Documentation for hook usage and installation - Updated CLAUDE.md with hook installation instructions The pre-commit hook will: - Check if code needs formatting - Run cargo fmt --all if needed - Automatically add formatted files to the commit - Prevent commits with formatting issues Installation: ./hooks/install.sh This ensures all commits have properly formatted code and prevents cargo fmt CI failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should be a drop-in replacement and no changes should be needed, but things have certainly moved around quite a bit