Repository navigation
feat: ^X J puts terminal tabs in list order (tmux, iTerm) - #376
Merged
Merged
Conversation
^X J moves the tabs of live sessions into the order the ccs list shows them: tmux windows within each tmux session, iTerm tabs within each iTerm window. Only tabs holding a listed session move, among the places they already hold, so ccs's own tab and plain shells stay put. A split tab goes where its first listed session would. It runs only when pressed. tmux uses swap-window -d, then selects the window that was current again. iTerm's AppleScript can't move a tab (setting a tab's index errors, and move reports success but changes nothing), so ccs talks to iTerm's API itself: a websocket on its unix socket, a cookie from AppleScript, and hand-encoded protobuf for ListSessions and ReorderTabs. No new dependencies, but it needs Enable Python API on. macOS Terminal is left out: its tabs can't be moved without scripting clicks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Opus 5.5 ✨
Ctrl+X Jputs the terminal tabs of live sessions in the order the ccs list shows them: pins first, put-away sessions last, children right after their parent. With a search typed, it uses the matches as shown.What moves
How, per terminal (checked on this Mac)
swap-window -d, then the window that was current is selected again (-dkeeps the current slot selected, which would otherwise show a different window). Tried on a throwawaytmux -Lserver.set index of taberrors, andmove tab 3 to before tab 1reports success but changes nothing. iTerm's API can: ccs talks to it directly over a websocket on~/Library/Application Support/iTerm2/private/socket, gets a cookie from AppleScript'srequest cookie and key(no prompt), and hand-encodes protobufListSessions(106) andReorderTabs(125). That adds no dependencies and needs no Python. Session ttys come from AppleScript, matched by session unique id. It needs iTerm > Settings > General > Magic > Enable Python API; without it ccs says where to turn it on. Tried end to end against a throwaway iTerm window: three tabs reordered as asked, with other windows untouched.move tabfails with "AppleEvent handler failed". Only GUI scripting through System Events could do it, which isn't reliable.The key
^X J. The mnemonic letters were taken: O (orchestrator), T (table), A (auto-focus), S (snooze), L (list), M (move into topics) and R (restart). Only J, V and Z were free.Tests
internal/sessions/taborder_test.go: which tab goes where (slotOrder: other tabs stay put, split tabs), tmux grouping and the swap plan,OrderTabswith stubbed tmux and a fake iTerm API, protobuf parsing of a nested split tree, and the websocket client against a fake iTerm on a pipe (handshake headers, ping/pong, skipping someone else's answer, a reorder error status, a refused handshake).internal/tui/live_test.go:^X Jpasses the ttys of live terminal sessions in list order and skips background, app and exited sessions; refuses outside tmux and iTerm; never runs twice at once; reports the result.TestMainin both packages stubs the new terminal hooks (TmuxRun,ITermAPI,ITermSessionTTYs,ITermCookie,OrderTabs), so tests never touch a real terminal.Docs:
shortcuts(),--help, README and AGENTS.md.🤖 Generated with Claude Code