Skip to content

Multi-instance pane_title_marker collision causes ask to send to wrong pane #153

@xdbh13

Description

@xdbh13

Bug Description

When running multiple CCB instances simultaneously (e.g. in separate git worktrees), ask codex silently sends messages to the wrong Codex pane. The command appears to succeed but Codex shows no activity, and the task hangs indefinitely.

Root Cause

All CCB instances use the same hardcoded pane_title_marker: "CCB-Codex" (line 2113, 2399 in ccb). When multiple Codex panes exist, find_pane_by_title_marker() in terminal.py (line 584) returns the first pane whose title starts with the marker -- which may belong to a different CCB instance.

Additionally, stale panes from previous sessions that retain the "CCB-Codex" title can also cause false matches, even in single-instance scenarios.

Steps to Reproduce

  1. Start CCB in directory A: cd /path/to/project-a && ccb codex claude
  2. Start CCB in directory B (e.g. a worktree): cd /path/to/project-b && ccb codex claude
  3. In directory B's Claude session, run /ask codex "create hello.py"
  4. Expected: Codex in directory B receives the task
  5. Actual: Message is sent to directory A's Codex pane (or a stale pane), directory B's Codex shows no activity, task hangs

Suggested Fix

Make pane_title_marker unique per project by including the project hash (already computed in __init__):

# Before (ccb line 2113, 2399):
pane_title_marker = "CCB-Codex"

# After:
pane_title_marker = f"CCB-Codex-{self.project_id[:8]}"

This also applies to WezTerm path (line 1256):

# Before:
pane_title_marker = f"CCB-{provider.capitalize()}"

# After:
pane_title_marker = f"CCB-{provider.capitalize()}-{self.project_id[:8]}"

Using project_id[:8] (a hash) is more robust than Path.cwd().name because:

  • Git worktrees with the same parent project name would still get unique markers
  • Special characters in directory names are avoided

Environment

  • CCB version: v5.2.6
  • Terminal: tmux
  • OS: macOS (Darwin 25.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions