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

Method constructor

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

Source from the content-addressed store, hash-verified

62 #textWindows: Record<number, TextWindow> = {};
63
64 constructor() {
65 super();
66
67 this.view.setStyle({flex: 1});
68 if (process.platform == 'win32')
69 this.view.setBackgroundColor('#D3D3D3');
70
71 this.messagesView = new MessagesView();
72 this.messagesView.view.setStyle({flex: 1});
73 this.messagesView.browser.addBinding('focusEntry', this.onFocus.bind(this));
74 this.messagesView.browser.addBinding('showTextAt', this.#showTextAt.bind(this));
75 this.messagesView.browser.addBinding('regenerateFrom', this.#regenerateFrom.bind(this));
76 this.messagesView.browser.addBinding('resendLastMessage', this.#resendLastMessage.bind(this));
77 this.messagesView.browser.addBinding('copyTextAt', this.#copyTextAt.bind(this));
78 this.messagesView.browser.addBinding('sendReply', this.#sendReply.bind(this));
79 this.messagesView.browser.addBinding('refreshToken', this.#refreshToken.bind(this));
80 this.messagesView.browser.addBinding('clearConversation', this.#clearConversation.bind(this));
81 this.messagesView.browser.endAddingBindings();
82 this.messagesView.onDomReady.connect(this.#onDomReady.bind(this));
83 this.view.addChildView(this.messagesView.view);
84
85 // Font style should be the same with messages.
86 if (!ChatView.font)
87 ChatView.font = gui.Font.create(gui.Font.default().getName(), 15, 'normal', 'normal');
88
89 this.toolbar = gui.Container.create();
90 this.toolbar.setStyle({
91 flexDirection: 'row',
92 marginLeft: basicStyle.padding,
93 marginTop: basicStyle.padding / 2,
94 marginBottom: basicStyle.padding / 2,
95 });
96 this.view.addChildView(this.toolbar);
97
98 this.clearButton = new IconButton('trash');
99 this.clearButton.view.setTooltip('Clear conversation');
100 this.clearButton.onClick = this.#clearConversation.bind(this);
101 this.toolbar.addChildView(this.clearButton.view);
102
103 this.exportButton = new IconButton('export');
104 this.exportButton.view.setTooltip('Export conversation');
105 this.exportButton.onClick = () => runExportMenu(this.exportButton.view, this.service);
106 this.toolbar.addChildView(this.exportButton.view);
107
108 this.input = new InputView();
109 this.input.view.setStyle({marginTop: 0, margin: basicStyle.padding});
110 this.input.entry.setFont(ChatView.font);
111 // Calculate height for 1 and 5 lines.
112 if (!ChatView.entryHeights) {
113 this.input.entry.setText('1');
114 const min = this.input.entry.getTextBounds().height;
115 this.input.entry.setText('1\n2\n3\n4\n5');
116 const max = this.input.entry.getTextBounds().height;
117 this.input.entry.setText('');
118 ChatView.entryHeights = {min, max};
119 }
120 this.input.setAutoResize(ChatView.entryHeights);
121 this.input.entry.onTextChange = this.#resetUIState.bind(this);

Callers

nothing calls this directly

Calls 7

runExportMenuFunction · 0.90
getTooltipForModeFunction · 0.85
setBackgroundColorMethod · 0.80
setTextMethod · 0.80
setAutoResizeMethod · 0.80
setEntryEnabledMethod · 0.80
addButtonMethod · 0.45

Tested by

no test coverage detected