Skip to content

Commit b4f11e5

Browse files
Disallow message sending before session is ready
1 parent 380966d commit b4f11e5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/components/AssistantView.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import ReactDOM from 'react-dom';
55
import InlineInput from './InlineInput';
66
import ProfilePictureView from './ProfilePictureView';
77
import SessionController, { SessionControllerEventListener } from '../controllers/SessionController';
8-
import { TableInfo } from '../models/TableInfo';
98
import TablePreview from '../table/TablePreview';
109

1110
import { ChatMessage } from '../models/ChatMessage';
1211
import { SessionState } from '../models/SessionState';
12+
import { TableInfo } from '../models/TableInfo';
1313

1414
import IconExpand from '../images/icon_expand.svg'
1515
import LogoInverted from '../images/logo_inverted.svg'
@@ -144,14 +144,14 @@ class AssistantView extends React.Component<Props, State> implements SessionCont
144144
}
145145
}) }
146146
</div>
147-
{modalContent && ReactDOM.createPortal(
148-
<div style={{ position: 'absolute', top: 0, left: 0, width: '100vw', height: '100vh', backgroundColor: 'rgba(0, 0, 0, 0.75)', zIndex: 10000, boxSizing: 'border-box', padding: '32px', display: 'flex', alignItems: 'center', justifyContent: 'center' }} onClick={() => this.setState({ modalContent: null })}>
147+
{ modalContent && ReactDOM.createPortal(
148+
<div style={{ position: 'absolute', top: '0px', left: '0px', width: '100vw', height: '100vh', backgroundColor: 'rgba(0, 0, 0, 0.75)', zIndex: 10000, boxSizing: 'border-box', padding: '32px', display: 'flex', alignItems: 'center', justifyContent: 'center' }} onClick={() => this.setState({ modalContent: null })}>
149149
<div style={{ maxWidth: '100%', maxHeight: '100%' }}>
150150
<TableView table={modalContent} style={{ maxHeight: 'calc(100vh - 64px)' }} />
151151
</div>
152152
</div>,
153153
document.body
154-
)}
154+
) }
155155
</div>
156156
} else if (sessionState == 'initializing' || sessionState == 'waiting_for_data' || sessionState == 'validating_data') {
157157
return <div style={{ width: '100%', height: '100%', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }}>
@@ -178,8 +178,8 @@ class AssistantView extends React.Component<Props, State> implements SessionCont
178178

179179
sendChatMessage() {
180180
const message = this.inputRef.current?.getContent() ?? null;
181-
const { isProcessing } = this.state;
182-
if (!message || message.length == 0 || isProcessing) { return; }
181+
const { sessionState, isProcessing } = this.state;
182+
if (!message || message.length == 0 || isProcessing || sessionState != 'ready') { return; }
183183
this.inputRef.current?.clear();
184184
SessionController.getInstance().sendChatMessage(message);
185185
}

0 commit comments

Comments
 (0)