MCPcopy Create free account
hub / github.com/chieapp/chie / constructor

Method constructor

src/view/text-window.ts:19–67  ·  view source on GitHub ↗
(mode, text: string, index?: number, service?: BaseChatService)

Source from the content-addressed store, hash-verified

17 defaultButton: gui.Button;
18
19 constructor(mode, text: string, index?: number, service?: BaseChatService) {
20 super({pressEscToClose: true});
21 this.mode = mode;
22 this.text = text;
23 this.index = index;
24 this.service = service;
25
26 this.contentView.setStyle({
27 padding: basicStyle.padding,
28 gap: basicStyle.padding,
29 });
30 this.window.setTitle('Raw Message Text');
31 this.window.setContentSize({width: 200, height: 300});
32
33 this.input = new InputView();
34 this.input.view.setStyle({flex: 1});
35 this.input.entry.setFont(ChatView.font);
36 this.input.entry.setText(text);
37 this.contentView.addChildView(this.input.view);
38
39 const buttonsArea = new ButtonsArea();
40 this.contentView.addChildView(buttonsArea.view);
41
42 if (this.mode.startsWith('edit')) {
43 buttonsArea.addButton('Modify').onClick = () => {
44 service.updateMessage({content: this.input.entry.getText()}, index);
45 this.window.close();
46 };
47 }
48 if (this.mode.endsWith('regenerate')) {
49 buttonsArea.addButton('Modify and Regenerate').onClick = () => {
50 service.updateMessage({content: this.input.entry.getText()}, index);
51 service.regenerateFrom(index + 1);
52 this.window.close();
53 };
54 }
55 if (this.mode == 'prompt') {
56 buttonsArea.addButton('OK');
57 } else {
58 buttonsArea.addButton('Copy').onClick = () => {
59 gui.Clipboard.get().setText(this.input.entry.getText());
60 };
61 }
62 buttonsArea.addCloseButton();
63
64 // First button is default button.
65 this.defaultButton = buttonsArea.row.childAt(0) as gui.Button;
66 this.defaultButton.makeDefault();
67 }
68
69 destructor() {
70 super.destructor();

Callers

nothing calls this directly

Calls 6

addButtonMethod · 0.95
addCloseButtonMethod · 0.95
setTextMethod · 0.80
updateMessageMethod · 0.80
closeMethod · 0.80
setTitleMethod · 0.45

Tested by

no test coverage detected