Skip to content

Conversation

@Umupa
Copy link

@Umupa Umupa commented Dec 21, 2025

Related Issue

Fixes #26

Problem

The notification feature UI was displayed but did not work for users without ccmate hooks configured in ~/.claude/settings.json.

Root Cause:
The startup logic only called update_claude_code_hook(), which updates existing hooks but never adds them if missing.

Solution

This PR adds intelligent hook initialization:

Changes Made

  1. New Function (src-tauri/src/commands.rs)

    • Added check_claude_code_hooks_exist() to detect if ccmate hooks are present in Claude settings
  2. Updated Startup Logic (src-tauri/src/lib.rs)

    • Detects hook presence on startup
    • If hooks exist → updates to latest version
    • If hooks missing → automatically adds them
    • Fallback mechanism if detection fails

Code Quality

  • ✅ TypeScript type checking passed (pnpm tsc --noEmit)
  • ✅ Follows conventional commit format
  • ✅ Minimal changes (69 additions, 5 deletions)
  • ✅ No breaking changes

Impact

Users without ccmate hooks (new installations, manual deletions, config migrations) will now automatically get hooks configured on first launch, making notifications work immediately.

Previously, the startup logic only called update_claude_code_hook()
which updates existing ccmate hooks but never adds them if missing.
This caused notification features to silently fail for users without
hooks configured, despite the UI showing notification settings.

Changes:
- Add check_claude_code_hooks_exist() to detect hook presence
- Update startup logic to add hooks if missing, update if existing
- Add fallback to ensure hooks are added even if detection fails

Fixes the issue where users without ccmate hooks (new installations,
manual deletions, or config migrations) could not receive notifications
even though the notification settings UI was functional.
@djyde
Copy link
Owner

djyde commented Dec 21, 2025

have you tested it?

@Umupa
Copy link
Author

Umupa commented Dec 22, 2025

have you tested it?你测试过吗?

Yes, I've tested it with 3 scenarios:

  • Scenario 1: No hooks configured (hooks: {})
  • Scenario 2: User custom hooks exist
  • Scenario 3: Existing ccmate hooks

Here is some application log

1、Adding Hooks

✅ System tray icon created successfully!
Setting up app...
Initializing app config...
initialize_app_config called
Starting hook server...
Checking if app config directory exists: /Users/lalaorya/.ccconfig
Checking Claude Code hooks...
App config directory already exists
Checking if Claude directory exists: /Users/lalaorya/.claude
No hooks found, adding Claude Code hooks...
🚀 Starting hook server on 127.0.0.1:59948
✅ Hook server listening on http://localhost:59948
Claude backup already exists, skipping backup
App config initialized successfully
✅ Claude Code hooks added successfully
✅ Claude Code hooks added successfully
2025-12-22 10:23:55.779 cc-mate[50069:23652127] +[IMKClient subclass]: chose IMKClient_Modern
2025-12-22 10:23:55.779 cc-mate[50069:23652127] +[IMKInputSession subclass]: chose IMKInputSession_Modern
[baseline-browser-mapping] The data in this module is over two months old.  To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
🔍 Checking for updates...
📱 App version: 0.3.4
🏷️  App identifier: CC Mate
✅ Updater initialized successfully
📡 Checking update endpoint: https://github.com/djyde/ccmate-release/releases/latest/download/latest.json
✅ No updates available - you're on the latest version
 ELIFECYCLE  Command failed.
 ELIFECYCLE  Command failed.

2、Updating Hooks

✅ System tray icon created successfully!
Setting up app...
Initializing app config...
Starting hook server...
initialize_app_config called
Checking Claude Code hooks...
Checking if app config directory exists: /Users/lalaorya/.ccconfig
App config directory already exists
Checking if Claude directory exists: /Users/lalaorya/.claude
Claude backup already exists, skipping backup
App config initialized successfully
Hooks found, updating to latest version...
🔄 Updated Notification hook command: curl -s -X POST http://localhost:59948/claude_code/hooks -H 'Content-Type: application/json' --data-binary @- 2>/dev/null || echo
🔄 Updated Stop hook command: curl -s -X POST http://localhost:59948/claude_code/hooks -H 'Content-Type: application/json' --data-binary @- 2>/dev/null || echo
🔄 Updated PreToolUse hook command: curl -s -X POST http://localhost:59948/claude_code/hooks -H 'Content-Type: application/json' --data-binary @- 2>/dev/null || echo
🚀 Starting hook server on 127.0.0.1:59948
✅ Hook server listening on http://localhost:59948
✅ Claude Code hooks updated successfully
✅ Claude Code hooks updated successfully
2025-12-22 10:31:21.080 cc-mate[54496:23671220] +[IMKClient subclass]: chose IMKClient_Modern
2025-12-22 10:31:21.080 cc-mate[54496:23671220] +[IMKInputSession subclass]: chose IMKInputSession_Modern
[baseline-browser-mapping] The data in this module is over two months old.  To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
🔍 Checking for updates...
📱 App version: 0.3.4
🏷️  App identifier: CC Mate

After testing, the settings.json hooks configuration looks like this:

"hooks": {
   "Notification": [
     {
       "hooks": [
         {
           "type": "command",
           "command": "curl -s -X POST http://localhost:59948/claude_code/hooks -H 'Content-Type: application/json' --data-binary @- 2>/dev/null || echo"
         }
       ]
     }
   ],
   "PreToolUse": [
     {
       "hooks": [
         {
           "type": "command",
           "command": "curl -s -X POST http://localhost:59948/claude_code/hooks -H 'Content-Type: application/json' --data-binary @- 2>/dev/null || echo"
         }
       ]
     }
   ],
   "SessionEnd": [
     {
       "hooks": [
         {
           "type": "command",
           "command": "curl -s -X POST http://localhost:59948/claude_code/hooks -H 'Content-Type: application/json' --data-binary @- 2>/dev/null || echo"
         }
       ]
     }
   ],
   "Stop": [
     {
       "hooks": [
         {
           "type": "command",
           "command": "curl -s -X POST http://localhost:59948/claude_code/hooks -H 'Content-Type: application/json' --data-binary @- 2>/dev/null || echo"
         }
       ]
     }
   ]
 }

Notification effect

image image

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.

Notification feature silently fails for users without hooks configured

2 participants