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

Method GetUserInput

pkg/userinput/userinput.go:107–142  ·  view source on GitHub ↗
(ctx context.Context, request *UserInputRequest)

Source from the content-addressed store, hash-verified

105}
106
107func (p *FrontendProvider) GetUserInput(ctx context.Context, request *UserInputRequest) (*UserInputResponse, error) {
108 id, uiCh := MainUserInputHandler.registerChannel()
109 defer MainUserInputHandler.unregisterChannel(id)
110 request.RequestId = id
111 request.TimeoutMs = int(utilfn.TimeoutFromContext(ctx, 30*time.Second).Milliseconds())
112
113 scopes, scopesErr := determineScopes(ctx)
114 if scopesErr != nil {
115 log.Printf("user input scopes could not be found: %v", scopesErr)
116 blocklogger.Infof(ctx, "user input scopes could not be found: %v", scopesErr)
117 allWindows, err := wstore.DBGetAllOIDsByType(ctx, "window")
118 if err != nil {
119 blocklogger.Infof(ctx, "unable to find windows for user input: %v", err)
120 return nil, fmt.Errorf("unable to find windows for user input: %v", err)
121 }
122 scopes = allWindows
123 }
124
125 MainUserInputHandler.sendRequestToFrontend(request, scopes)
126
127 var response *UserInputResponse
128 var err error
129 select {
130 case resp := <-uiCh:
131 log.Printf("checking received: %v", resp.RequestId)
132 response = resp
133 case <-ctx.Done():
134 return nil, fmt.Errorf("timed out waiting for user input")
135 }
136
137 if response.ErrorMsg != "" {
138 err = errors.New(response.ErrorMsg)
139 }
140
141 return response, err
142}
143
144func GetUserInput(ctx context.Context, request *UserInputRequest) (*UserInputResponse, error) {
145 return defaultProvider.GetUserInput(ctx, request)

Callers

nothing calls this directly

Calls 7

TimeoutFromContextFunction · 0.92
InfofFunction · 0.92
DBGetAllOIDsByTypeFunction · 0.92
determineScopesFunction · 0.85
registerChannelMethod · 0.80
unregisterChannelMethod · 0.80
sendRequestToFrontendMethod · 0.80

Tested by

no test coverage detected