Skip to content

CPLAT-11161: resolve refs against the tmux window ccx runs in, not the client's active window - #148

Merged
gavin-jeong merged 1 commit into
masterfrom
fix/refs-current-window
Jul 30, 2026
Merged

CPLAT-11161: resolve refs against the tmux window ccx runs in, not the client's active window#148
gavin-jeong merged 1 commit into
masterfrom
fix/refs-current-window

Conversation

@gavin-jeong

@gavin-jeong gavin-jeong commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

JIRA: https://sendbird.atlassian.net/browse/CPLAT-11161

Problem

ccx refs resolved the session to scan by asking tmux for the client's active window (#{session_name}|#{window_index}) and collecting Claude panes only from that window. When a Claude session runs in a background window of the same tmux client (common during a multi-window build), ccx refs matched sessions from the foreground window instead of its own — surfacing unrelated PRs or reporting "no PR/Jira references found in session".

Reproduced

  • Claude session in pane %143, window local|9, cwd /Users/gavin.jeong/src/keyolk/ccx
  • tmux client active window: local|2 (which contained a live Claude at soda-k8s/.worktree/cohome)
  • Before: ccx refsError: no PR/Jira references found in session (scanned the soda-k8s session)
  • After: ccx refs → correctly lists this session's PRs (cohome-k8s#150, ccx#52/56/99, CPLAT-1234, …)

Fix

CurrentWindowClaudes now walks this process's own PPID chain to the tmux pane that hosts it (reusing the walkToPane/batchPPIDMap helpers MarkLiveSessions already uses) and pins the window from that pane. The client-active window remains as a fallback when the pane can't be determined (e.g. a wrapper re-parented the process beyond tmux's view).

Extracted claudesInWindow/findPaneByPID so the window-selection logic is testable without a live tmux. Added TestFindPaneByPID and TestClaudesInWindowFiltersByWindow.

Test plan

  • go build ./...
  • go test ./internal/tmux/ ./internal/cli/ ./internal/session/
  • Manual: ccx refs --plain from a background-window Claude session now returns that session's own refs

…lient's active window

CurrentWindowClaudes asked tmux for the client's active window
("#{session_name}|#{window_index}") and scanned only that window's panes
for Claude processes. A Claude session running in a background window of the
same client (common during a multi-window build) then matched sessions from
the foreground window instead of its own, so `ccx refs` surfaced unrelated
PRs or reported "no PR/Jira references found".

Walk this process's own PPID chain to the tmux pane that hosts it (reusing
the walkToPane/batchPPIDMap helpers MarkLiveSessions already uses) and pin
the window from that pane. The client-active window remains as a fallback
when the pane can't be determined (e.g. a wrapper re-parented the process
beyond tmux's view).

Extracted claudesInWindow/findPaneByPID so the window-selection logic is
testable without a live tmux.
@gavin-jeong
gavin-jeong deleted the fix/refs-current-window branch July 30, 2026 22:03
@gavin-jeong gavin-jeong changed the title fix(cli): resolve refs against the tmux window ccx runs in, not the client's active window CPLAT-11161: resolve refs against the tmux window ccx runs in, not the client's active window Jul 30, 2026
@gavin-jeong
gavin-jeong restored the fix/refs-current-window branch July 30, 2026 23:21
@gavin-jeong gavin-jeong reopened this Jul 30, 2026
@Kairo-Kim Kairo-Kim added the auto-review/approved Auto-approved by the Slack auto-reviewer bot label Jul 30, 2026
@gavin-jeong
gavin-jeong merged commit b815ab3 into master Jul 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-review/approved Auto-approved by the Slack auto-reviewer bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants