MCPcopy Create free account
hub / github.com/chieapp/chie / #resetUIState

Method #resetUIState

src/view/chat-view.ts:274–308  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272
273 // Set the input and button to ready to send state.
274 #resetUIState() {
275 this.onFocus();
276 // Button states.
277 if (this.service.history.length > 0) {
278 this.clearButton.setEnabled(!this.service.pending);
279 this.exportButton.setEnabled(true);
280 } else {
281 this.clearButton.setEnabled(false);
282 this.exportButton.setEnabled(false);
283 }
284 // Can only refresh if there was error.
285 if (this.service.lastError) {
286 this.#setButtonMode('refresh');
287 return;
288 }
289 // Can only stop if there is pending message.
290 if (this.service.pending) {
291 this.#setButtonMode('stop');
292 return;
293 }
294 // Show refresh button if can regenerate and there is no input.
295 if (this.service.canRegenerateLastResponse() &&
296 this.input.entry.getText().length == 0) {
297 this.#setButtonMode('refresh');
298 return;
299 }
300 // Show refresh button if last message is from user, this usually means
301 // the last message failed to send.
302 if (this.service.getLastMessage()?.role == ChatRole.User) {
303 this.#setButtonMode('refresh');
304 return;
305 }
306 // Otherwise ready to send.
307 this.#setButtonMode('send');
308 }
309
310 // User presses Enter in the reply entry.
311 #onEnter() {

Callers 5

loadServiceMethod · 0.95
#onDomReadyMethod · 0.95
#onMessageBeginMethod · 0.95
#onMessageErrorMethod · 0.95
#onMessageEndMethod · 0.95

Calls 2

onFocusMethod · 0.95
#setButtonModeMethod · 0.95

Tested by

no test coverage detected