feat: add sesh window command for tmux window management#345
feat: add sesh window command for tmux window management#345fenngwd wants to merge 7 commits intojoshmedeski:mainfrom
Conversation
提交内容由AI生成 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add ListWindows(targetSession string) to the Tmux interface and RealTmux implementation. Reuse existing separator variable from list.go to avoid naming conflict. Note: implementation file named list_tmux_win.go because Go treats filenames ending in _windows.go as Windows-only build constraints. Commit content generated by AI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Commit content generated by AI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
提交内容由AI生成 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
提交内容由AI生成 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Just to clarify, how would this feature be used? Can you clarify it's purpose in the README and some basic instructions for how to use it, thanks. |
There was a problem hiding this comment.
Pull request overview
Adds a new sesh window / sesh w command to list, switch to, and create tmux windows within a session, aligning window UX with existing session-oriented commands.
Changes:
- Introduces
model.TmuxWindowand tmux-layer support for listing windows and selecting a window. - Adds a new Cobra command
sesh windowand registers it in the root command. - Adds unit tests for the new tmux window list/select functions.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tmux/tmux.go |
Extends the Tmux interface with window list/select capabilities needed by the CLI. |
tmux/list_tmux_win.go |
Implements ListWindows() using tmux list-windows parsing into TmuxWindow. |
tmux/list_tmux_win_test.go |
Adds tests for window listing, target session flag behavior, and parsing. |
tmux/select_win.go |
Implements SelectWindow() using tmux select-window. |
tmux/select_win_test.go |
Adds a unit test ensuring the correct tmux command is executed. |
model/tmux_window.go |
Adds the window model used across tmux + CLI layers. |
seshcli/window.go |
Introduces the window subcommand wiring together list/select/create behaviors. |
seshcli/root_command.go |
Registers the new window command at the root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
seshcli/window.go
Outdated
| newWindowArgs := []string{"new-window", "-n", windowName, "-c", absPath} | ||
| if targetSession != "" { | ||
| newWindowArgs = append(newWindowArgs, "-t", targetSession) | ||
| } | ||
| if _, err := base.Shell.Cmd("tmux", newWindowArgs...); err != nil { |
There was a problem hiding this comment.
This command shells out directly via base.Shell.Cmd("tmux", ...) to create a window, bypassing the tmux.Tmux abstraction. That makes the CLI harder to unit test (no tmux mock) and duplicates tmux command construction outside the tmux package. Consider adding a tmux-layer method that supports creating a window in an optional target session (e.g., extend NewWindow or add NewWindowInSession) and calling that instead.
| newWindowArgs := []string{"new-window", "-n", windowName, "-c", absPath} | |
| if targetSession != "" { | |
| newWindowArgs = append(newWindowArgs, "-t", targetSession) | |
| } | |
| if _, err := base.Shell.Cmd("tmux", newWindowArgs...); err != nil { | |
| if _, err := base.Tmux.NewWindowInSession(windowName, absPath, targetSession); err != nil { |
tmux/list_tmux_win.go
Outdated
|
|
||
| output, err := t.shell.ListCmd("tmux", args...) | ||
| if err != nil { | ||
| return []*model.TmuxWindow{}, nil |
There was a problem hiding this comment.
ListWindows swallows errors from t.shell.ListCmd and returns an empty slice with a nil error. This makes it impossible for callers to distinguish between “no windows” and a real failure (e.g., tmux not available, permission issues, malformed args). Consider returning the original err (or only suppressing the specific 'no server running' case) so CLI code can surface failures appropriately.
| return []*model.TmuxWindow{}, nil | |
| return nil, err |
tmux/tmux.go
Outdated
| SwitchClient(targetSession string) (string, error) | ||
| CapturePane(targetSession string) (string, error) | ||
| NextWindow() (string, error) | ||
| SelectWindow(name string) (string, error) |
There was a problem hiding this comment.
The SelectWindow method parameter is named name, but callers can pass a full tmux target like session:window (see seshcli/window.go). Renaming the parameter to something like target/targetWindow would better reflect actual usage and reduce confusion for future callers.
| SelectWindow(name string) (string, error) | |
| SelectWindow(targetWindow string) (string, error) |
| targetSession, _ := cmd.Flags().GetString("session") | ||
| jsonOutput, _ := cmd.Flags().GetBool("json") | ||
| _ = jsonOutput | ||
|
|
There was a problem hiding this comment.
The --json/-j flag is parsed but intentionally ignored (_ = jsonOutput), so users can enable it with no observable effect. Either implement JSON output for list mode or return a clear error when --json is provided to avoid a silent no-op.
提交内容由AI生成 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
提交内容由AI生成 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the feedback! I've added a Window management section to the README with examples covering:
I also addressed the 4 Copilot review suggestions in the latest commit:
|
Summary
Closes #282
Adds a new
sesh window(aliasw) subcommand for listing and managing tmux windows within a session, mirroring the UX ofsesh listandsesh connect.Features
sesh window— list all windows in the current tmux session (one per line)sesh window <name>— switch to an existing window by namesesh window <path>— create a new window at the given directory (name = basename)--session / -sflag to target a session other than the current one--json / -jflag reserved for JSON output in list modeImplementation
model/tmux_window.go— newTmuxWindowdata type (Name, Path, Index, Active)tmux/list_tmux_win.go+ tests —ListWindows(targetSession string)usingtmux list-windowstmux/select_win.go+ tests —SelectWindow(name string)usingtmux select-windowseshcli/window.go— cobra command wired to the aboveseshcli/root_command.go— registered in root commandTesting
Unit tests follow the same mock-based pattern as the existing
tmuxpackage tests. All 14 packages pass.