feat(app): Enhanced slash commands with app navigation and fixes#543
Open
benzntech wants to merge 1 commit intoslopus:mainfrom
Open
feat(app): Enhanced slash commands with app navigation and fixes#543benzntech wants to merge 1 commit intoslopus:mainfrom
benzntech wants to merge 1 commit intoslopus:mainfrom
Conversation
Author
Additional Note: Telegram IntegrationThis PR also lays the groundwork for Telegram Mini App slash commands. While the full Telegram integration (files like
The Telegram-specific files can be added in a follow-up PR once this foundation is merged. Testing in Telegram Web Appimport { useCommandHandler } from '@/hooks/useCommandHandler';
import { useTelegram } from '@/hooks/useTelegram';
function ChatInput() {
const { isTelegramWebApp } = useTelegram();
const { executeCommandItem } = useCommandHandler({
onSdkCommand: (cmd) => sendMessageToCLI(`/${cmd}`)
});
// Commands work seamlessly in Telegram
// Haptic feedback automatically provided
}Let me know if you'd like the full Telegram integration included or prefer it as a separate PR! |
This PR improves the slash command system with context-aware navigation commands, bug fixes, and better code quality. ## Changes ### New Features - Add app navigation commands (/home, /sessions, /profiles, /settings, /help) - Context-aware command display (includeAppCommands flag) - Command handler hook with Telegram integration - Haptic feedback for Telegram Web App - Command source tracking (builtin/sdk/app) ### Bug Fixes - Fix slopus#182: Removed filter that only showed commands starting with 'c' - Remove 'help' from IGNORED_COMMANDS to prevent conflicts - Improve duplicate command detection (checks all commands, not just defaults) - Fix React dependency arrays to prevent unnecessary re-renders ### Code Quality - Export command name constants to avoid duplication - Add onSdkCommand callback for clear API contract - Better TypeScript types with source field ## Testing - TypeScript type checking passes - Fuzzy search works across all commands - App navigation commands work in web and Telegram - No duplicate commands in autocomplete - Haptic feedback works in Telegram - Help command shows different UI in web vs Telegram ## Related Issues - Fixes slopus#182 (commands filtered by first letter) - Addresses slopus#14 (slash command handling - reviewed ignore list) - Compatible with PR slopus#495 (preset messages)
9e0672b to
92dfdea
Compare
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
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.
Summary
This PR enhances the slash command system with context-aware app navigation commands, bug fixes from code review, and improved code quality. The implementation is inspired by HAPI's extensible architecture while maintaining existing patterns.
New Features
1. App Navigation Commands
Add navigation slash commands that work in both web app and Telegram:
/home- Navigate to home screen/sessions- View all active sessions/profiles- Manage profiles/settings- Open settings/help- Show help (context-aware: alert in Telegram, navigation in web)2. Context-Aware Display
3. Command Handler Hook
New
useCommandHandlerhook with:CommandIteminterface4. Command Source Tracking
Bug Fixes
Fix #182: Commands filtered by first letter
Problem: Only commands starting with 'c' appeared in autocomplete (iOS bug)
Solution: Fuse.js fuzzy search searches across all command names and descriptions, not filtered by first letter.
Code:
Remove 'help' Conflict
Problem:
helpwas in bothIGNORED_COMMANDSandAPP_COMMANDSSolution: Removed from ignore list since we provide it as an app navigation command.
Improved Duplicate Detection
Problem: Only checked DEFAULT_COMMANDS for duplicates, could miss conflicts with APP_COMMANDS
Solution:
Fixed React Dependency Arrays
Problem:
optionsobject in dependencies caused unnecessary re-rendersSolution: Destructure callbacks at hook top level:
Code Quality Improvements
1. Exported Command Constants
Before: Command lists duplicated in two files
After: Single source of truth
2. Clear SDK Command API
Before: SDK commands had no handler (unclear behavior)
After: Explicit callback:
Documentation
SLASH_COMMANDS.md
Complete implementation guide with:
CODE_REVIEW_FIXES.md
All fixes applied with before/after code examples and migration guide.
RELATED_ISSUES.md
Analysis of existing issues and PRs:
Testing
Performance
✅ Optimized dependency arrays
✅ Fuse.js fuzzy search (typo-tolerant)
✅ No caching issues (reads fresh from session metadata)
Backward Compatibility
✅ No breaking changes except:
onSdkCommandcallback (previously unclear)includeAppCommandsdefaults tofalse(opt-in)Related Issues & PRs
Migration Guide
For Existing Code Using Autocomplete
Before:
After:
For SDK Command Handling
Before:
After:
Next Steps (Future Work)
~/.claude/commands/like HAPI/h→/help,/s→/sessionsSummary: This PR provides a production-ready slash command system with app navigation, fixes existing bugs, and improves code quality. The implementation is backward-compatible with clear migration paths.