mirror of
https://github.com/wavetermdev/waveterm
synced 2026-04-21 14:37:16 +00:00
`WindowService.MoveBlockToNewWindow` appears to be unreferenced, and its
supporting path had become isolated. This change removes that dead RPC
surface and the backend/eventbus helpers that existed only for that
flow.
- **Window service cleanup (backend RPC)**
- Removed `MoveBlockToNewWindow_Meta` and `MoveBlockToNewWindow` from
`pkg/service/windowservice/windowservice.go`.
- Dropped now-unused imports tied to that method (`log`, `eventbus`).
- **Store cleanup**
- Removed `MoveBlockToTab` from `pkg/wstore/wstore.go`.
- Removed now-unused `utilfn` import from the same file.
- **Eventbus cleanup**
- Removed unused event constant `WSEvent_ElectronNewWindow`.
- Removed `getWindowWatchesForWindowId` and `BusyWaitForWindowId`, which
were only used by the deleted move-to-new-window path.
- Removed now-unused `time` import.
- **Generated frontend service surface**
- Regenerated service bindings and removed
`WindowServiceType.MoveBlockToNewWindow(...)` from
`frontend/app/store/services.ts`.
Example of removed RPC surface:
```ts
// removed from frontend/app/store/services.ts
MoveBlockToNewWindow(currentTabId: string, blockId: string): Promise<void> {
return WOS.callBackendService("window", "MoveBlockToNewWindow", Array.from(arguments))
}
```
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/wavetermdev/waveterm/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
112 lines
3.1 KiB
Go
112 lines
3.1 KiB
Go
// Copyright 2025, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package windowservice
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/wavetermdev/waveterm/pkg/panichandler"
|
|
"github.com/wavetermdev/waveterm/pkg/tsgen/tsgenmeta"
|
|
"github.com/wavetermdev/waveterm/pkg/waveobj"
|
|
"github.com/wavetermdev/waveterm/pkg/wcore"
|
|
"github.com/wavetermdev/waveterm/pkg/wps"
|
|
"github.com/wavetermdev/waveterm/pkg/wstore"
|
|
)
|
|
|
|
const DefaultTimeout = 2 * time.Second
|
|
|
|
type WindowService struct{}
|
|
|
|
func (svc *WindowService) GetWindow_Meta() tsgenmeta.MethodMeta {
|
|
return tsgenmeta.MethodMeta{
|
|
ArgNames: []string{"windowId"},
|
|
}
|
|
}
|
|
|
|
func (svc *WindowService) GetWindow(windowId string) (*waveobj.Window, error) {
|
|
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
|
|
defer cancelFn()
|
|
window, err := wstore.DBGet[*waveobj.Window](ctx, windowId)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error getting window: %w", err)
|
|
}
|
|
return window, nil
|
|
}
|
|
|
|
func (svc *WindowService) CreateWindow_Meta() tsgenmeta.MethodMeta {
|
|
return tsgenmeta.MethodMeta{
|
|
ArgNames: []string{"ctx", "winSize", "workspaceId"},
|
|
}
|
|
}
|
|
|
|
func (svc *WindowService) CreateWindow(ctx context.Context, winSize *waveobj.WinSize, workspaceId string) (*waveobj.Window, error) {
|
|
window, err := wcore.CreateWindow(ctx, winSize, workspaceId)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error creating window: %w", err)
|
|
}
|
|
return window, nil
|
|
}
|
|
|
|
func (svc *WindowService) SetWindowPosAndSize_Meta() tsgenmeta.MethodMeta {
|
|
return tsgenmeta.MethodMeta{
|
|
Desc: "set window position and size",
|
|
ArgNames: []string{"ctx", "windowId", "pos", "size"},
|
|
}
|
|
}
|
|
|
|
func (ws *WindowService) SetWindowPosAndSize(ctx context.Context, windowId string, pos *waveobj.Point, size *waveobj.WinSize) (waveobj.UpdatesRtnType, error) {
|
|
if pos == nil && size == nil {
|
|
return nil, nil
|
|
}
|
|
ctx = waveobj.ContextWithUpdates(ctx)
|
|
win, err := wstore.DBMustGet[*waveobj.Window](ctx, windowId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if pos != nil {
|
|
win.Pos = *pos
|
|
}
|
|
if size != nil {
|
|
win.WinSize = *size
|
|
}
|
|
win.IsNew = false
|
|
err = wstore.DBUpdate(ctx, win)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return waveobj.ContextGetUpdatesRtn(ctx), nil
|
|
}
|
|
|
|
func (svc *WindowService) SwitchWorkspace_Meta() tsgenmeta.MethodMeta {
|
|
return tsgenmeta.MethodMeta{
|
|
ArgNames: []string{"ctx", "windowId", "workspaceId"},
|
|
}
|
|
}
|
|
|
|
func (svc *WindowService) SwitchWorkspace(ctx context.Context, windowId string, workspaceId string) (*waveobj.Workspace, error) {
|
|
ctx = waveobj.ContextWithUpdates(ctx)
|
|
ws, err := wcore.SwitchWorkspace(ctx, windowId, workspaceId)
|
|
|
|
updates := waveobj.ContextGetUpdatesRtn(ctx)
|
|
go func() {
|
|
defer func() {
|
|
panichandler.PanicHandler("WindowService:SwitchWorkspace:SendUpdateEvents", recover())
|
|
}()
|
|
wps.Broker.SendUpdateEvents(updates)
|
|
}()
|
|
return ws, err
|
|
}
|
|
|
|
func (svc *WindowService) CloseWindow_Meta() tsgenmeta.MethodMeta {
|
|
return tsgenmeta.MethodMeta{
|
|
ArgNames: []string{"ctx", "windowId", "fromElectron"},
|
|
}
|
|
}
|
|
|
|
func (svc *WindowService) CloseWindow(ctx context.Context, windowId string, fromElectron bool) error {
|
|
ctx = waveobj.ContextWithUpdates(ctx)
|
|
return wcore.CloseWindow(ctx, windowId, fromElectron)
|
|
}
|