feat: Add slash commands and help dialog

- Restore slash command autocomplete (type "/" to see suggestions)
- Add /compact command to trigger context compaction
- Add /clear command to clear chat history
- Add /help command with styled modal dialog
- Add HelpDialog component with command list
- Add system event handler for context warnings
- Add debug logging for all Claude events to /tmp/claude-events-debug.jsonl

TODO: Parse context warning from Claude events when identified

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-18 10:49:47 +01:00
parent a3fcc3cb7f
commit 7156f1aaa0
6 changed files with 229 additions and 8 deletions

View File

@@ -389,6 +389,33 @@ export function SessionProvider({ children }) {
break;
}
case 'system': {
// System events from Claude - log full event for debugging
console.log(`[${sessionId}] System event:`, event.subtype, JSON.stringify(event, null, 2));
// Check for context info in system init event
if (event.subtype === 'init') {
// Log all fields to find context info
console.log(`[${sessionId}] System init fields:`, Object.keys(event));
}
// Parse context message if present
if (event.message) {
const contextMatch = event.message.match(/Context left[^:]*:\s*(\d+)%/i);
if (contextMatch) {
const contextLeft = parseInt(contextMatch[1], 10);
console.log(`[${sessionId}] Context left:`, contextLeft + '%');
updateSession(sessionId, (session) => ({
stats: {
...(session.stats || {}),
contextLeftPercent: contextLeft,
},
}));
}
}
break;
}
default:
console.log(`[${sessionId}] Unhandled claude event:`, type, event);
}
@@ -795,6 +822,16 @@ export function SessionProvider({ children }) {
updateSession(sessionId, { unreadCount: 0 });
}, [updateSession]);
// Set compacting state
const setCompacting = useCallback((sessionId, value) => {
updateSession(sessionId, {
stats: {
...(sessions[sessionId]?.stats || {}),
isCompacting: value,
},
});
}, [updateSession, sessions]);
// Change permission mode
const changePermissionMode = useCallback((sessionId, mode) => {
const ws = wsRefs.current[sessionId];
@@ -900,6 +937,7 @@ export function SessionProvider({ children }) {
sendMessage,
stopGeneration,
clearMessages,
setCompacting,
// Permissions
changePermissionMode,
@@ -909,7 +947,7 @@ export function SessionProvider({ children }) {
createSession, closeSession, removeSession, renameSession, updateSessionConfig,
setFocusedSessionId, markAsRead, reorderTabs, addToSplit, removeFromSplit, clearSplit,
connectSession, disconnectSession, startClaudeSession, stopClaudeSession,
sendMessage, stopGeneration, clearMessages, changePermissionMode, respondToPermission,
sendMessage, stopGeneration, clearMessages, setCompacting, changePermissionMode, respondToPermission,
]);
return (