Skip to content

Refactor: Simplify navigation and slash command handling - #381

Merged
criptogus merged 1 commit into
mainfrom
claude/fix-menu-chat-issues-GaYMK
Jan 28, 2026
Merged

Refactor: Simplify navigation and slash command handling#381
criptogus merged 1 commit into
mainfrom
claude/fix-menu-chat-issues-GaYMK

Conversation

@criptogus

Copy link
Copy Markdown
Owner

📋 Description

This PR refactors navigation logic in the AppSidebar component and improves slash command handling in CommandInput. The changes remove unnecessary programmatic navigation that was overriding React Router's built-in NavLink functionality, and add proper slash command execution support.

Key Changes:

AppSidebar.tsx:

  • Removed unused useNavigate hook import and usage
  • Simplified NavLink onClick handlers to rely on React Router's native navigation
  • Removed e.preventDefault() calls that were preventing default NavLink behavior
  • Removed debug console.logs and unnecessary setTimeout delays for mobile sidebar closing
  • Cleaned up comments and removed redundant "FIX" annotations

CommandInput.tsx:

  • Added proper slash command detection and execution in the submit handler
  • Slash commands (starting with /) are now intercepted and executed via onCommandExecute callback
  • Added error handling and user feedback for command execution failures
  • Cleaned up comments and removed redundant "FIX" annotations
  • Maintained synchronous message sending behavior for non-command inputs

🎯 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style update (formatting, renaming)
  • ♻️ Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test update
  • 🔧 Configuration change
  • 🏗️ Infrastructure change

🔗 Related Issues

✅ Checklist

Code Quality

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have removed console.logs and debug code

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested on multiple browsers (if frontend change)
  • I have tested with Docker

Documentation

  • I have updated the documentation accordingly
  • I have updated the CHANGELOG.md
  • I have added/updated code comments where necessary
  • I have updated the README if needed

Dependencies

  • I have not added any new dependencies, or I have justified them
  • I have updated package-lock.json/bun.lockb if dependencies changed

Security

  • I have not exposed any sensitive information (API keys, passwords, etc.)
  • I have considered security implications of my changes
  • I have not introduced any security vulnerabilities

🧪 How Has This Been Tested?

Manual testing recommended for:

  • Navigation between sidebar links on desktop and mobile
  • Slash command execution in the command input
  • Mobile sidebar closing behavior after navigation
  • Error handling for failed command execution

📝 Additional Notes

The refactoring leverages React Router's built-in NavLink functionality instead of manually managing navigation with useNavigate(). This is a cleaner approach that:

  • Reduces code complexity
  • Eliminates race conditions from setTimeout delays
  • Properly integrates with React Router's active link detection
  • Maintains the same user-facing behavior

The slash command handling addition enables proper command execution flow while maintaining backward compatibility with regular message sending.

👀 Reviewer Notes

Areas needing special attention:

  • Verify that sidebar navigation works correctly on both desktop and mobile
  • Test slash command execution with various command formats
  • Ensure mobile sidebar closes immediately after navigation (no delay)
  • Confirm that NavLink active states are still properly detected

Questions for reviewers:

  • Are there any edge cases with the slash command detection that should be handled?
  • Should there be additional validation for slash commands before execution?

https://claude.ai/code/session_01QyDFbYooCiwJNR7CjdcW3Y

- Sidebar: Remove preventDefault() and manual navigate() from NavLinks
  The NavLink component from React Router handles navigation internally.
  Using preventDefault() + navigate() was breaking the native behavior.
  Now only close sidebar on mobile without blocking navigation.

- Chat: Add slash command detection in handleSubmit
  Previously, all input was sent via onSendMessage even for commands.
  Now checks if input starts with '/' and calls onCommandExecute instead.
  This properly executes commands like /task instead of sending as text.

https://claude.ai/code/session_01QyDFbYooCiwJNR7CjdcW3Y
@criptogus
criptogus merged commit b5e744f into main Jan 28, 2026
0 of 6 checks passed
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