Skip to content

Commit 20187db

Browse files
committed
fix(tmux): deduplicate panes from linked windows
`tmux list-panes -a` returns one entry per session-pane combination. When a pane exists in multiple sessions (via link-window or session groups), M.panes() produced duplicate entries because the same physical pane appears multiple times. Since skid is derived from pane_pid, this triggers the assert in session/init.lua:142. Skip already-seen pane_id values so each physical pane is returned only once.
1 parent 208e1c5 commit 20187db

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lua/sidekick/cli/session/tmux.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ function M.panes(opts)
8989
local cmd = opts.cmd or { "tmux", "list-panes", "-a", "-F", PANE_FORMAT }
9090
local lines = Util.exec(cmd, { notify = opts.notify == true })
9191
local panes = {} ---@type sidekick.tmux.Pane[]
92+
local seen = {} ---@type table<string,boolean>
9293
for _, line in ipairs(lines or {}) do
9394
local session_id, id, pid, session_name, cwd = line:match("^(%$%d+):(%%%d+):(%d+):(.-):(.*)$")
94-
if id and pid and session_name and cwd then
95+
if id and pid and session_name and cwd and not seen[id] then
96+
seen[id] = true
9597
pid = assert(tonumber(pid), "invalid tmux pane_pid: " .. pid) --[[@as number]]
9698
---@class sidekick.tmux.Pane
9799
panes[#panes + 1] = {

0 commit comments

Comments
 (0)