feat(wsh): add 'tab list' and 'tab move' commands for scriptable tab management (#3426)
## Summary This PR adds two new wsh subcommands under `wsh tab` to make tabs scriptable from the command line, addressing #3425. ### New commands **`wsh tab list`** (alias: `ls`) — lists tabs in the current workspace with their ids, names, and indices. - Defaults to the current workspace from `WAVETERM_WORKSPACEID`, overridable with `--workspace <id>` - Supports `--json` flag for machine-readable output - Example: ``` $ wsh tab list INDEX TAB ID NAME 0 550e8400-e29b-41d4-a716-446655440000 Terminal 1 650e8400-e29b-41d4-a716-446655440001 google.com ``` **`wsh tab move <tabid> --index <n>`** — moves a tab to the specified 0-based position within its workspace. - Validates that the tab exists in the workspace and that the index is in range - Guards against dropping/adding tabs (the set of tab ids is preserved exactly) - No-op when the tab is already at the target index - Example: ``` $ wsh tab move 650e8400-e29b-41d4-a716-446655440001 --index 0 moved tab 650e8400-... from index 1 to 0 ``` ### Bug fix - Fixed a small bug in `wsh workspace list` where the `workspaceId` field was being printed to stderr instead of stdout due to a `WriteStderr`/`WriteStdout` typo. ### Testing - Added unit tests for the tab reordering logic (`reorderTabIds`) covering 8 scenarios: first↔last, left/right moves, adjacent swaps, and two-element arrays - All existing tests in `cmd/wsh/cmd/` continue to pass - `go build ./cmd/wsh/...` and `go vet ./cmd/wsh/...` clean - `gofmt` verified Closes #3425
J
Jason-Shen2 committed
3ad0acadf852117a13d666b96e42af7db973acdf
Parent: 35dc57f
Committed by GitHub <noreply@github.com>
on 7/29/2026, 6:04:38 PM