add wsh tab commands (create, rename, focus)#3333
Conversation
Adds three new wsh subcommands so external tooling can orchestrate tabs programmatically: - wsh tab create [-w workspaceid] [-n name] [--no-activate] - wsh tab rename [-t tabid] <name> - wsh tab focus <tabid> Wires CreateTabCommand and FocusTabCommand through WshRpcInterface, with handlers in wshserver that delegate to wcore.CreateTab / wcore.SetActiveTab and fan out the same UpdateEvents + SendActiveTabUpdate the existing WorkspaceService.CreateTab path uses, so the visible tab actually switches. The pre-existing UpdateTabNameCommand is reused for rename. CreateTab defaults the workspace id to the caller's workspace (resolved via the rpc context's blockid) when -w is omitted. Includes unit tests for the new command declarations and JSON tags, plus docs in wsh-reference.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR implements tab management end-to-end: new RPC methods and CommandCreateTabData (with Meta), server handlers that resolve implicit workspace IDs and broadcast updates, Go client wrappers, frontend types and RPC API wrappers, CLI subcommands (tab create/rename/focus) with flags and timeouts, unit tests for command registration and JSON tags, and documentation updates. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review SummaryThe review did not run because the selected model is no longer available. Choose another model in Kilo Code review settings: https://app.kilo.ai/code-reviews |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/types/gotypes.d.ts`:
- Around line 319-323: CommandCreateTabData lacks the requested meta payload;
add an optional meta field to the type (e.g., meta?: Record<string,string>) so
the RPC can carry key=value pairs from `wsh tab create`; update any code that
constructs or forwards CommandCreateTabData (RPC serializers/clients and any
builders for tab creation) to accept and pass through this meta object
unchanged, and ensure TypeScript callers validate/serialize meta as string
key/value pairs before sending.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4ba41dbb-7a51-488c-98e5-ce9b87490c03
📒 Files selected for processing (8)
cmd/wsh/cmd/wshcmd-tab.godocs/docs/wsh-reference.mdxfrontend/app/store/wshclientapi.tsfrontend/types/gotypes.d.tspkg/wshrpc/wshclient/wshclient.gopkg/wshrpc/wshrpc_tab_test.gopkg/wshrpc/wshrpctypes.gopkg/wshrpc/wshserver/wshserver.go
Allows callers to pre-populate tab metadata at creation time via --meta key=value (repeatable), addressing the meta payload capability requested in wavetermdev#3285. The new field is optional and additive; existing call sites continue to work unchanged.
|
Added |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/wshrpc/wshserver/wshserver.go`:
- Around line 218-227: The meta update failure currently returns an error while
leaving the created tab (tabId) persisted; change this so callers don't get a
failed creation with an orphaned tab by either: (A) attempt a rollback after
wstore.UpdateObjectMeta fails — call the appropriate deletion API (e.g.
wstore.DeleteObject(ctx, tabORef) or wcore.DeleteTab(ctx, tabId)) and if that
deletion errors, log both the metaErr and rollbackErr and return the original
metaErr; or (B) if rollback is not desirable, log the metaErr with context and
still return the created tabId (instead of returning an error) so callers see
success; update the code paths around wcore.CreateTab, tabORef and
wstore.UpdateObjectMeta to implement one of these behaviors and ensure errors
are logged with full details.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 455f29d7-3fd7-45bc-a06d-cf73f8e63f36
📒 Files selected for processing (6)
cmd/wsh/cmd/wshcmd-tab.godocs/docs/wsh-reference.mdxfrontend/types/gotypes.d.tspkg/wshrpc/wshrpc_tab_test.gopkg/wshrpc/wshrpctypes.gopkg/wshrpc/wshserver/wshserver.go
✅ Files skipped from review due to trivial changes (1)
- docs/docs/wsh-reference.mdx
🚧 Files skipped from review as they are similar to previous changes (3)
- frontend/types/gotypes.d.ts
- pkg/wshrpc/wshrpctypes.go
- cmd/wsh/cmd/wshcmd-tab.go
When the auxiliary meta update fails after a successful tab creation, log the error with context but return the tabId. This avoids orphan tabs from retry loops that would otherwise see a failed creation despite the tab being persisted. Users can re-apply meta with wsh setmeta if needed.
|
Flagging that the two failing checks ( The CLA is now signed and CodeRabbit's two findings have been addressed. Happy to rebase or push tweaks if anything else comes up. |
Closes #3285.
Summary
Adds three new
wshsubcommands so external tooling can orchestrate tabs programmatically:wsh tab create [-w <workspaceid>] [-n <name>] [--no-activate]— creates a tab and prints its id to stdout. Defaults the workspace to the caller's workspace (resolved from the RPC context's blockid) when-wis omitted.wsh tab rename [-t <tabid>] <name>— renames a tab; defaults--tabtoWAVETERM_TABID.wsh tab focus <tabid>— activates a tab from anywhere (cross-tab, unlikewsh focusblockwhich is current-tab only).Motivation
WorkspaceService.CreateTab/SetActiveTabalready exist in the Go service layer and are reachable from the renderer via the HTTP/wave/serviceendpoint, but that endpoint is gated by anX-AuthKeyUUID that only Electron's main process has. There was no way for an external tool (a wsh script, a sibling app, an AI coding-agent harness) to create a tab, name it, and switch focus to it.This blocks tools like https://github.com/doyled-it/wavecrest that want to spawn a tab per agent session, name it after the session, and click-to-focus from a dashboard card.
Implementation notes
CreateTabCommand(ctx, CommandCreateTabData) (string, error)andFocusTabCommand(ctx, tabId string) errortoWshRpcInterfaceinpkg/wshrpc/wshrpctypes.go.pkg/wshrpc/wshserver/wshserver.gothat delegate towcore.CreateTab/wcore.SetActiveTaband fan out the samewps.Broker.SendUpdateEvents+wcore.SendActiveTabUpdatecalls the existingWorkspaceService.CreateTab/SetActiveTabpaths use — so the visible tab actually switches in Electron, not just the DB row.UpdateTabNameCommandRPC is reused forwsh tab rename; no new server method was needed for that.task generatewas run to regeneratewshclient.go,gotypes.d.ts, andwshclientapi.ts.cmd/wsh/cmd/wshcmd-tab.gowith cobra subcommands following the conventions in theadd-wshcmdskill guide (activity tracking,preRunSetupRpcClient,DisableFlagsInUseLine, etc.).docs/docs/wsh-reference.mdx.Examples
Tests
pkg/wshrpc/wshrpc_tab_test.go— 4 tests verifying the new command declarations are correctly registered inGenerateWshCommandDeclMap(), that arg/return shapes match expectations, and thatCommandCreateTabDatacarries the expected JSON tags.go test ./pkg/wshrpc/ ./cmd/wsh/cmd/).Test plan
go build ./...cleango test ./pkg/wshrpc/ ./cmd/wsh/cmd/passestask generateproduces no further diff after the manual editswsh tab create,wsh tab rename,wsh tab focus