MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / BootstrapStarterLayout

Function BootstrapStarterLayout

pkg/wcore/layout.go:144–178  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

142}
143
144func BootstrapStarterLayout(ctx context.Context) error {
145 ctx, cancelFn := context.WithTimeout(ctx, 2*time.Second)
146 defer cancelFn()
147 client, err := wstore.DBGetSingleton[*waveobj.Client](ctx)
148 if err != nil {
149 log.Printf("unable to find client: %v\n", err)
150 return fmt.Errorf("unable to find client: %w", err)
151 }
152
153 if len(client.WindowIds) < 1 {
154 return fmt.Errorf("error bootstrapping layout, no windows exist")
155 }
156
157 windowId := client.WindowIds[0]
158
159 window, err := wstore.DBMustGet[*waveobj.Window](ctx, windowId)
160 if err != nil {
161 return fmt.Errorf("error getting window: %w", err)
162 }
163
164 workspace, err := wstore.DBMustGet[*waveobj.Workspace](ctx, window.WorkspaceId)
165 if err != nil {
166 return fmt.Errorf("error getting workspace: %w", err)
167 }
168
169 tabId := workspace.ActiveTabId
170
171 starterLayout := GetStarterLayout()
172 err = ApplyPortableLayout(ctx, tabId, starterLayout, false)
173 if err != nil {
174 return fmt.Errorf("error applying starter layout: %w", err)
175 }
176
177 return nil
178}

Callers 1

AgreeTosMethod · 0.92

Calls 3

DBMustGetFunction · 0.92
GetStarterLayoutFunction · 0.85
ApplyPortableLayoutFunction · 0.85

Tested by

no test coverage detected