Skip to content

Conversation

@comfy-pr-bot
Copy link
Member

Summary

Improves the bot message filtering system to prevent debugging messages from being shown to users in Slack. Users will now only see clean, relevant task progress without internal system messages.

Problem

The bot currently shows debugging messages like "retrying the slack upload...", local file paths, timestamps, and other system internals to end users in Slack channels. These messages are confusing and not relevant to users.

Solution

Created a comprehensive message filtering system that automatically removes debugging information before displaying to users:

New Files

  • bot/utils/filterDebugMessages.ts: Core filtering utility with filterInternalThoughts() and getFilteredContent() functions
  • bot/utils/filterDebugMessages.spec.ts: Comprehensive test suite with 18 tests (all passing)

What Gets Filtered

  1. Retry/upload messages ("retrying the slack upload...")
  2. File paths (/repos/, /home/, /tmp/)
  3. Process info (PID: 12345, exit code: 0)
  4. Timestamps ([2024-01-09T10:30:45], etc.)
  5. ANSI escape codes and terminal control characters
  6. System commands (bun run, npm install, node_modules)
  7. Git internals (git fetch, HEAD is now at)
  8. Debug logging ([DEBUG], [TRACE], [VERBOSE])
  9. Stack traces (at functionName (...))

Changes

  • bot/index.ts (lines ~1061-1117): Integrated filtering into Slack update flow

    • Filters terminal output before sending to my_internal_thoughts
    • Logs filtered-out content to BOT-LOGS.md for debugging
    • Enhanced prompt instructions with explicit examples
  • CLAUDE.md: Added comprehensive documentation section on message filtering

    • Usage examples
    • Integration details
    • Benefits and testing instructions

Testing

bun test bot/utils/filterDebugMessages.spec.ts

All 18 tests passing ✅

Benefits

  • Cleaner User Experience: Users only see relevant task progress
  • Debugging Preserved: Filtered content logged to BOT-LOGS.md
  • Reduced Confusion: No more system messages confusing users
  • Consistent Output: Standardized filtering across all bot responses

Stats

  • 4 files changed
  • 554 insertions, 3 deletions
  • 18 comprehensive tests

🤖 Generated with Claude Code

snomiao and others added 30 commits January 8, 2026 01:58
…dling

## Bot Skills Implementation

Created comprehensive bot skills system with CLI tools:

**Slack Skills** (`bot/slack/`):
- `msg-update.ts`: Update Slack messages programmatically
- `msg-read-thread.ts`: Read entire Slack threads with markdown conversion
- `parseSlackMessageToMarkdown.ts`: Convert Slack formatting to Markdown
- `slackTsToISO.ts`: Convert Slack timestamps to ISO 8601 format
- Full test coverage with `.spec.ts` files (16 tests passing)

**Notion Skills** (`bot/`):
- `notion-search.ts`: Search Notion docs from Comfy-Org workspace

**Documentation**:
- `bot/README.md`: Complete usage guide for all skills
- `bot/BUGFIX.md`: Detailed bug fixes documentation
- Updated `CLAUDE.md` with bot skills section

## Bug Fixes

### Fix 1: App Mention Event Schema Mismatch
- Made `client_msg_id` optional (Slack doesn't always include it)
- Added `attachments` field for message unfurls
- Events with attachments now process correctly

### Fix 2: WebSocket System Messages
- Added handlers for "hello" (connection acknowledgment)
- Added handlers for "disconnect" messages
- Only truly unhandled messages are logged as `MSG_NOT_MATCHED`

## Files Modified
- `bot/index.ts`: Fixed event schema and WebSocket message handling
- `CLAUDE.md`: Added ComfyPR Bot Skills documentation section

## Security
- All environment variables properly referenced
- No tokens or secrets committed
- Log files excluded via `.gitignore`

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add .env, logs/, repos/, and TODO.md to ignore list.
Add comment about .env vs .env.local usage.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add CS_ORIGIN, CS_TOKEN, and PRBOT_PORT environment variables
with placeholder values for local override.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Document master-worker bot architecture pattern
- Add coding sub-agent (pr-bot) usage documentation
- Add comprehensive TODO tracking and resolution workflow
- Update bot skills to clarify READ-ONLY access for master agent
- List priority TODOs across the project

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

Co-Authored-By: Claude <noreply@anthropic.com>
Replace PyTorch/ComfyUI setup with Debian-based Bun runtime.
Install Node.js via nvm and Bun for executing bot services.
Configure entrypoint to run bot/index.ts.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Document new bot/cli.ts unified CLI with yargs.
Update Notion search path references.
Add common command examples for PR, Slack, and Notion operations.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Reorganize Notion utilities into dedicated directory.
Move bot/notion-search.ts to bot/notion/search.ts for better organization.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add bot/registry/search.ts for searching ComfyUI custom nodes
via the registry API.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add bot/code/ directory with:
- pr-bot.ts: CLI for spawning coding sub-agents on GitHub repos
- issue-search.ts: Search GitHub issues across Comfy-Org
- coding/pr-agent.ts: Core logic for repository cloning and agent spawning
- coding/pr-agent.spec.ts: Test suite for pr-agent
- coding/README.md: Documentation for coding sub-agent system

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add bot/comfy-codesearch/README.md documenting the code search
service integration for searching ComfyUI repositories.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add bot/slack/ utilities:
- file.ts: Upload/download files, get file info, post messages with files
- parseSlackUrl.ts: Parse Slack message URLs to extract channel and timestamp
- stream.ts: Placeholder for Slack chat streaming (TODO)

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add bot/cli.ts as consolidated entry point for all bot commands:
- GitHub: pr (spawn sub-agent), issue-search
- Registry: search custom nodes
- Slack: update, read-thread, upload/download files
- Notion: search (placeholder)

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add YAML output format instead of JSON
- Include file attachments, message attachments, and reactions in output
- Export readSlackThread function for reuse
- Move import.meta.main block to top of file

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add comprehensive logging with metadata and context
- Implement master-worker architecture documentation in agent prompt
- Add skills for code search, registry search, issue search, and pr-bot
- Enhance Slack integration with better error handling
- Add repository context for Comfy-Org projects
- Improve agent spawning with detailed instructions
- Add TODO tracking and progress reporting capabilities
- Refactor message handling and response formatting
- Add support for Claude Code integration

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add dependencies:
- @slack/socket-mode for Slack Socket Mode support
- execa for process execution
- faker for test data generation
- terminal-render for console output
- Update @slack/web-api and zod

Add pr-bot bin entry point and dev:bot script.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Change cache paths from '.cache/' to './.cache/' for consistency
and clarity in github, notion, and slack cache stores.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add bot service with Bun runtime and Claude credentials mount
- Remove deprecated gh-service
- Mount project directory and Claude credentials for bot

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

Co-Authored-By: Claude <noreply@anthropic.com>
Remove unused run/github-webhook-event-type/index.ts file.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add .claude/skills/ directory with skill definitions:
- github-pr-bot: Spawn coding sub-agents for code changes
- github-issue-search: Search GitHub issues
- code-search: Search ComfyUI codebase
- registry-search: Search custom nodes registry
- slack-msg-update: Update Slack messages
- slack-thread-reader: Read Slack threads
- notion-search: Search Notion documentation
- pr-bot-cli: Unified PR bot CLI

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add app/api/webhook/github/ Next.js API route:
- route.ts: Handle GitHub webhook events with signature verification
- webhook-events.ts: Store events in SQLite database
- setup-indexes.ts: Create database indexes for efficient querying
- test-webhook.ts: Test utility for webhook endpoint
- route.spec.ts: Test suite for webhook handler
- README.md and USAGE_EXAMPLES.md: Documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Use standard 'text' parameter instead of non-standard 'markdown_text'
- Update all slack.chat.postMessage and slack.chat.update calls
- Change CLI from 'codex-yes' to 'claude-yes'
- Fix dev:bot script to watch specific file

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Added codes/ directory to gitignore (temporary cloned repos)
- Added tmp/ directory to gitignore (temporary working files)
- Prevents accidental commit of temporary data
- Implemented RestartManager class that watches for file changes
- Only restarts when bot is idle (no active tasks)
- Includes debouncing (1s) and idle checking (5s intervals)
- Comprehensive test suite with 6 passing tests
- Interactive example demonstrating restart behavior
- Replaces problematic --watch flag that interrupted tasks
- Tests for addWorkingTask() and removeWorkingTask() helpers
- Validates duplicate prevention logic
- Tests multiple concurrent tasks handling
- All 5 tests passing
- Uses in-memory Keyv store for testing
- Added helper functions addWorkingTask() and removeWorkingTask()
- Replaced database queries with lightweight state key 'current-working-tasks'
- Updated --continue logic to read from working tasks state
- Integrated RestartManager for smart auto-restart on file changes
- Add task to working list when started (after quick response)
- Remove task from working list when completed or stopped by user
- Faster resume on restart, no database scanning needed
- Added 'slack upload' as alias for 'slack upload-file'
- Fixed yargs command matching issue by reordering commands
- Updated examples to use shorter pr-bot slack upload syntax
- Moved upload command after post-with-files to fix partial matching
- Created bot/up.sh as new location for startup script
- Added deprecation notice to bot-start.sh
- bot-start.sh now shows warning and redirects to bot/up.sh
- Kept bot-start.sh for backward compatibility
- Both scripts have executable permissions
- Added comprehensive user guide (RESTART.md)
- Added implementation summary (RESTART-SUMMARY.md)
- Added flow diagrams and workflows (RESTART-FLOW.md)
- Added quick reference guide (RESTART-QUICKREF.md)
- Documents usage, configuration, troubleshooting
- Includes comparison with --watch flag
- Comprehensive guide to new working tasks system
- Documents state structure and task lifecycle
- Explains resume on restart behavior
- Includes benefits comparison with old approach
- Troubleshooting and future improvements section
snomiao and others added 9 commits January 8, 2026 07:15
- Added Working Tasks State Management section
- Updated Smart Restart Manager documentation
- Updated file paths to reference docs/ directory
- Updated bot/up.sh references (formerly bot-start.sh)
- Added usage examples and state structure
- Added null/undefined check before calling tr.write()
- Prevents TypeError when chunk is undefined
- Fixes runtime error: 'undefined is not an object (evaluating data.length)'
- Added stderr logging to capture process errors
- Added stdout/stderr availability checks
- Added buffer undefined/null checks with logging
- Added terminal render error handling with detailed logging
- Convert undefined buffers to empty strings to prevent crashes
- Log chunk type and length on terminal render errors

This will help diagnose why chunks are undefined in production.
…g shown to users

- Created filterDebugMessages utility to remove debugging info from terminal output
- Filters: retry messages, file paths, timestamps, ANSI codes, process info, git internals
- Updated bot/index.ts to use filterInternalThoughts() before sending to Slack
- Added logging of filtered content to BOT-LOGS.md for debugging
- Enhanced prompt instructions with explicit examples of filtered patterns
- Added comprehensive test suite with 18 tests covering all filter patterns
- Updated CLAUDE.md documentation with usage examples and benefits

This ensures users only see clean, relevant task progress without internal debugging messages.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Jan 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
comfy-pr Error Error Jan 9, 2026 6:46am

Base automatically changed from sno-bot to main January 15, 2026 12:50
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.

3 participants