Skip to content

add wsh tab commands (create, rename, focus)#3333

Open
doyled-it wants to merge 3 commits into
wavetermdev:mainfrom
doyled-it:feat/wsh-tab-commands
Open

add wsh tab commands (create, rename, focus)#3333
doyled-it wants to merge 3 commits into
wavetermdev:mainfrom
doyled-it:feat/wsh-tab-commands

Conversation

@doyled-it
Copy link
Copy Markdown

Closes #3285.

Summary

Adds three new wsh subcommands 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 -w is omitted.
  • wsh tab rename [-t <tabid>] <name> — renames a tab; defaults --tab to WAVETERM_TABID.
  • wsh tab focus <tabid> — activates a tab from anywhere (cross-tab, unlike wsh focusblock which is current-tab only).

Motivation

WorkspaceService.CreateTab / SetActiveTab already exist in the Go service layer and are reachable from the renderer via the HTTP /wave/service endpoint, but that endpoint is gated by an X-AuthKey UUID 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

  • Added CreateTabCommand(ctx, CommandCreateTabData) (string, error) and FocusTabCommand(ctx, tabId string) error to WshRpcInterface in pkg/wshrpc/wshrpctypes.go.
  • Implemented handlers in pkg/wshrpc/wshserver/wshserver.go that delegate to wcore.CreateTab / wcore.SetActiveTab and fan out the same wps.Broker.SendUpdateEvents + wcore.SendActiveTabUpdate calls the existing WorkspaceService.CreateTab / SetActiveTab paths use — so the visible tab actually switches in Electron, not just the DB row.
  • The pre-existing UpdateTabNameCommand RPC is reused for wsh tab rename; no new server method was needed for that.
  • task generate was run to regenerate wshclient.go, gotypes.d.ts, and wshclientapi.ts.
  • Added cmd/wsh/cmd/wshcmd-tab.go with cobra subcommands following the conventions in the add-wshcmd skill guide (activity tracking, preRunSetupRpcClient, DisableFlagsInUseLine, etc.).
  • Docs added in docs/docs/wsh-reference.mdx.

Examples

# Create a tab in the current workspace and switch to it
wsh tab create

# Create a named tab and capture its id
tabid=$(wsh tab create --name "build-output")

# Create a background tab in a specific workspace
wsh tab create -w 9b1d... -n "logs" --no-activate

# Rename the current tab
wsh tab rename "agent-1"

# Activate a tab by id from anywhere
wsh tab focus "$tabid"

Tests

  • pkg/wshrpc/wshrpc_tab_test.go — 4 tests verifying the new command declarations are correctly registered in GenerateWshCommandDeclMap(), that arg/return shapes match expectations, and that CommandCreateTabData carries the expected JSON tags.
  • All existing tests still pass (go test ./pkg/wshrpc/ ./cmd/wsh/cmd/).

Test plan

  • go build ./... clean
  • go test ./pkg/wshrpc/ ./cmd/wsh/cmd/ passes
  • task generate produces no further diff after the manual edits
  • Manual smoke test inside a running Wave Terminal: wsh tab create, wsh tab rename, wsh tab focus

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.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 27, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 192e3531-f675-459a-acc5-29bee4bdc70f

📥 Commits

Reviewing files that changed from the base of the PR and between a6b9005 and 01b5dbe.

📒 Files selected for processing (1)
  • pkg/wshrpc/wshserver/wshserver.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/wshrpc/wshserver/wshserver.go

Walkthrough

This 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding three new wsh tab subcommands (create, rename, focus) for tab management.
Description check ✅ Passed The description is detailed and directly related to the changeset, explaining the new wsh tab commands, their motivation, implementation approach, and examples.
Linked Issues check ✅ Passed The PR implements the minimum requested capabilities from issue #3285: wsh tab create, wsh tab rename, and wsh tab focus. However, wsh tab list and wsh tab delete are not included, nor are workspace commands.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the three new tab subcommands and their supporting infrastructure (types, RPC methods, CLI, docs, tests).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 27, 2026

Code Review Summary

The 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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 021db67 and fba9315.

📒 Files selected for processing (8)
  • cmd/wsh/cmd/wshcmd-tab.go
  • docs/docs/wsh-reference.mdx
  • frontend/app/store/wshclientapi.ts
  • frontend/types/gotypes.d.ts
  • pkg/wshrpc/wshclient/wshclient.go
  • pkg/wshrpc/wshrpc_tab_test.go
  • pkg/wshrpc/wshrpctypes.go
  • pkg/wshrpc/wshserver/wshserver.go

Comment thread frontend/types/gotypes.d.ts
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.
@doyled-it
Copy link
Copy Markdown
Author

Added Meta map[string]string to CommandCreateTabData and a repeatable --meta key=value flag to wsh tab create. The metadata is applied to the new tab via the same path Wave uses internally (wstore.UpdateObjectMeta). Tests updated. Pushed as a6b9005.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between fba9315 and a6b9005.

📒 Files selected for processing (6)
  • cmd/wsh/cmd/wshcmd-tab.go
  • docs/docs/wsh-reference.mdx
  • frontend/types/gotypes.d.ts
  • pkg/wshrpc/wshrpc_tab_test.go
  • pkg/wshrpc/wshrpctypes.go
  • pkg/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

Comment thread pkg/wshrpc/wshserver/wshserver.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.
@doyled-it
Copy link
Copy Markdown
Author

Flagging that the two failing checks (merge-gatekeeper and Kilo Code Review) both appear to be the same upstream-config issue — Kilo's check fails with a generic "Kilo Code Review failed" output (and previously failed with "Selected model is no longer available"), and merge-gatekeeper is blocked because Kilo is in its required list.

The CLA is now signed and CodeRabbit's two findings have been addressed. Happy to rebase or push tweaks if anything else comes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add 'wsh tab create' (and 'wsh workspace create') for scriptable tab/workspace setup

2 participants