wavetermdev/waveterm · error
no active tab
Error message
no active tab
What it means
CreateBlock returns 'no active tab' when uiContext.ActiveTabId is an empty string. wcore.CreateBlock needs a parent tab to attach the new block to; without an active tab id the operation cannot proceed. It is a guard clause checked before any DB work.
Source
Thrown at pkg/service/objectservice/objectservice.go:84
orefObj, err := parseORef(orefStr)
if err != nil {
return nil, err
}
orefArr = append(orefArr, *orefObj)
}
return wstore.DBSelectORefs(ctx, orefArr)
}
func (svc *ObjectService) CreateBlock_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"uiContext", "blockDef", "rtOpts"},
ReturnDesc: "blockId",
}
}
func (svc *ObjectService) CreateBlock(uiContext waveobj.UIContext, blockDef *waveobj.BlockDef, rtOpts *waveobj.RuntimeOpts) (string, waveobj.UpdatesRtnType, error) {
if uiContext.ActiveTabId == "" {
return "", nil, fmt.Errorf("no active tab")
}
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancelFn()
ctx = waveobj.ContextWithUpdates(ctx)
blockData, err := wcore.CreateBlock(ctx, uiContext.ActiveTabId, blockDef, rtOpts)
if err != nil {
return "", nil, err
}
return blockData.OID, waveobj.ContextGetUpdatesRtn(ctx), nil
}
func (svc *ObjectService) DeleteBlock_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"uiContext", "blockId"},
}
}View on GitHub (pinned to a4447c1563)
Solutions
- Set uiContext.ActiveTabId to a valid existing tab id before calling CreateBlock
- Create/obtain a tab first (e.g. ensure the window has a tab) and use its id
- Guard the call site: skip block creation when no tab is active
Example fix
// before
svc.CreateBlock(uiContext, blockDef, rtOpts)
// after
if uiContext.ActiveTabId == "" {
uiContext.ActiveTabId = getOrCreateActiveTabId(ctx)
}
svc.CreateBlock(uiContext, blockDef, rtOpts) Defensive patterns
Strategy: validation
Validate before calling
if uiContext.ActiveTabId == "" { return fmt.Errorf("ActiveTabId must be set before CreateBlock") } Type guard
func hasActiveTab(uc waveobj.UIContext) bool { return uc.ActiveTabId != "" } Try / catch
if uiContext.ActiveTabId == "" {
return errors.New("no active tab")
}
blockId, _, err := svc.CreateBlock(uiContext, blockDef, rtOpts)
if err != nil { return err } Prevention
- Ensure a window/tab exists before issuing block creation
- Populate UIContext from the actual active window state
- In headless flows, create a tab explicitly first
When it happens
Trigger: Calling ObjectService.CreateBlock with a zero-value UIContext, a UIContext built outside a window/tab context, or after the active tab was closed leaving ActiveTabId stale-empty.
Common situations: Automated/headless invocation without a UI; running the call during app startup before any tab exists; losing track of the active tab in multi-window scenarios.
Related errors
- error deleting block: %w
- error getting tab blocks: %w
- beginning of file
- procinfo: process not found
- integer overflow
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/b506482fb2068e7c.
Report an issue: GitHub.