-
Notifications
You must be signed in to change notification settings - Fork 10
Add @mention notifications and stop command #4
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
dangerousbeans
wants to merge
5
commits into
timoconnellaus:main
Choose a base branch
from
dangerousbeans:feature/mention-notifications
base: main
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7b2a06e
Improve Discord bot reliability and Claude Code integration
dangerousbeans ae7b1b6
Add @mention notifications and improvements
dangerousbeans deb0e0d
Increase timeout from 5 to 30 minutes
dangerousbeans 9a618bb
checkpoint
dangerousbeans 36866d6
new design
dangerousbeans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Session Discovery Feature | ||
|
|
||
| This feature automatically detects running Claude Code sessions and creates corresponding Discord channels for them. | ||
|
|
||
| ## How It Works | ||
|
|
||
| When the Discord bot starts up, it: | ||
|
|
||
| 1. **Scans for Running Claude Processes** | ||
| - Uses `ps aux` to find Claude Code processes | ||
| - Uses `pwdx` to get the working directory of each process | ||
| - Filters out the bot's own directory | ||
|
|
||
| 2. **Creates Discord Channels** | ||
| - Converts working directory paths to Discord-friendly channel names | ||
| - Creates a "claude-code" category if it doesn't exist | ||
| - Creates channels under that category for each discovered session | ||
| - If a channel already exists, sends a notification instead | ||
|
|
||
| 3. **Channel Name Conversion** | ||
| - `/home/user/projects/my-app` → `#my-app` | ||
| - `/home/user/Soffi/Main Project` → `#main-project` | ||
| - Sanitizes to lowercase, alphanumeric + dashes/underscores | ||
|
|
||
| ## Example | ||
|
|
||
| If you have Claude Code running in these directories: | ||
| - `/home/user/projects/soffi-main` | ||
| - `/home/user/projects/discord-bot` | ||
|
|
||
| The bot will create: | ||
| ``` | ||
| 📁 claude-code (category) | ||
| └─ #soffi-main | ||
| └─ #discord-bot | ||
| ``` | ||
|
|
||
| Each channel will show: | ||
| - 🔍 Session Discovered | ||
| - Working Directory: `/home/user/projects/soffi-main` | ||
| - Process ID: 1234 | ||
| - Message: "You can now interact with this session by sending messages here!" | ||
|
|
||
| ## Files Modified | ||
|
|
||
| - **`src/services/session-discovery.ts`** - New service for discovering sessions | ||
| - **`src/bot/client.ts`** - Integrated session discovery on startup | ||
| - **`src/index.ts`** - Pass baseFolder to DiscordBot | ||
| - **`test/services/session-discovery.test.ts`** - Comprehensive test suite | ||
| - **`test/bot/client.test.ts`** - Updated tests for new constructor parameter | ||
|
|
||
| ## Benefits | ||
|
|
||
| 1. **Seamless Integration** - Existing sessions are automatically discoverable | ||
| 2. **No Manual Setup** - Channels are created automatically | ||
| 3. **Clear Organization** - All Claude Code channels grouped under one category | ||
| 4. **Process Tracking** - See which PID corresponds to each session | ||
| 5. **No Duplicates** - Handles existing channels gracefully | ||
|
|
||
| ## Running the Bot | ||
|
|
||
| To test the feature: | ||
|
|
||
| ```bash | ||
| # Make sure you have Claude Code sessions running in various directories | ||
| bun run src/index.ts | ||
| ``` | ||
|
|
||
| The bot will: | ||
| 1. Start the MCP Permission Server | ||
| 2. Discover existing Claude Code sessions | ||
| 3. Create Discord channels for each | ||
| 4. Log the results to console | ||
|
|
||
| ## Environment Requirements | ||
|
|
||
| Make sure these environment variables are set: | ||
| - `DISCORD_TOKEN` - Your Discord bot token | ||
| - `ALLOWED_USER_ID` - Discord user ID who can use the bot | ||
| - `BASE_FOLDER` - Base path where Claude Code operates | ||
|
|
||
| ## Notes | ||
|
|
||
| - The bot excludes its own directory from discovery | ||
| - Channel names are sanitized to be Discord-compatible | ||
| - Existing channels receive a "Session Detected" notification | ||
| - The feature runs once on bot startup (not continuously) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a blank line at the end of the file.
The dotenv-linter correctly identifies that the file should end with a blank line, which is a common convention for text files.
Apply this diff:
# MCP Server Port (optional, defaults to 3001) # Change this if port 3001 is already in use MCP_SERVER_PORT=3001 +📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 14-14: [EndingBlankLine] No blank line at the end of the file
(EndingBlankLine)
🤖 Prompt for AI Agents