MCPcopy
hub / github.com/wavetermdev/waveterm / ApplyPortableLayout

Function ApplyPortableLayout

pkg/wcore/layout.go:116–142  ·  view source on GitHub ↗
(ctx context.Context, tabId string, layout PortableLayout, recordTelemetry bool)

Source from the content-addressed store, hash-verified

114}
115
116func ApplyPortableLayout(ctx context.Context, tabId string, layout PortableLayout, recordTelemetry bool) error {
117 actions := make([]waveobj.LayoutActionData, len(layout)+1)
118 actions[0] = waveobj.LayoutActionData{ActionType: LayoutActionDataType_ClearTree}
119 for i := 0; i < len(layout); i++ {
120 layoutAction := layout[i]
121
122 blockData, err := CreateBlockWithTelemetry(ctx, tabId, layoutAction.BlockDef, &waveobj.RuntimeOpts{}, recordTelemetry)
123 if err != nil {
124 return fmt.Errorf("unable to create block to apply portable layout to tab %s: %w", tabId, err)
125 }
126
127 actions[i+1] = waveobj.LayoutActionData{
128 ActionType: LayoutActionDataType_InsertAtIndex,
129 BlockId: blockData.OID,
130 IndexArr: &layoutAction.IndexArr,
131 NodeSize: layoutAction.Size,
132 Focused: layoutAction.Focused,
133 }
134 }
135
136 err := QueueLayoutActionForTab(ctx, tabId, actions...)
137 if err != nil {
138 return fmt.Errorf("unable to queue layout actions for portable layout: %w", err)
139 }
140
141 return nil
142}
143
144func BootstrapStarterLayout(ctx context.Context) error {
145 ctx, cancelFn := context.WithTimeout(ctx, 2*time.Second)

Callers 2

CreateTabFunction · 0.85
BootstrapStarterLayoutFunction · 0.85

Calls 2

CreateBlockWithTelemetryFunction · 0.85
QueueLayoutActionForTabFunction · 0.85

Tested by

no test coverage detected