Skip to content

Commit

Permalink
Moves helperText down; removes debug stmts
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonWeill committed May 15, 2023
1 parent ce86ed0 commit 5bb9e58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 7 additions & 2 deletions packages/jupyter-ai/src/components/chat-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type ChatInputProps = {
toggleIncludeSelection: () => unknown;
replaceSelection: boolean;
toggleReplaceSelection: () => unknown;
helperText: JSX.Element
sendWithShiftEnter: boolean;
sx?: SxProps<Theme>;
};
Expand All @@ -39,6 +38,12 @@ export function ChatInput(props: ChatInputProps): JSX.Element {
event.preventDefault();
}
}

// Set the helper text based on whether Shift+Enter is used for sending.
const helperText = props.sendWithShiftEnter
? <span>Press <b>Shift</b>+<b>Enter</b> to send message</span>
: <span>Press <b>Shift</b>+<b>Enter</b> to add a new line</span>;

return (
<Box sx={props.sx}>
<Box sx={{ display: 'flex'}}>
Expand All @@ -61,7 +66,7 @@ export function ChatInput(props: ChatInputProps): JSX.Element {
FormHelperTextProps={{
sx: {marginLeft: 'auto', marginRight: 0}
}}
helperText={props.value.length > 2 ? props.helperText : ' '}
helperText={props.value.length > 2 ? helperText : ' '}
/>
</Box>
{props.hasSelection && (
Expand Down
8 changes: 0 additions & 8 deletions packages/jupyter-ai/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ function ChatBody({ chatHandler, setChatView: chatViewHandler }: ChatBodyProps):
useEffect(() => {
async function getConfig() {
const config = await AiService.getConfig();

console.log('in getConfig(), config.send_with_shift_enter is: ', config.send_with_shift_enter);
setSendWithShiftEnter(config.send_with_shift_enter ?? true);
}

Expand Down Expand Up @@ -151,7 +149,6 @@ function ChatBody({ chatHandler, setChatView: chatViewHandler }: ChatBodyProps):
);
}

console.log('About to render component; sendWithShiftEnter: ', sendWithShiftEnter);
return (
<>
<ScrollContainer sx={{ flexGrow: 1 }}>
Expand All @@ -178,11 +175,6 @@ function ChatBody({ chatHandler, setChatView: chatViewHandler }: ChatBodyProps):
borderTop: '1px solid var(--jp-border-color1)'
}}
sendWithShiftEnter={sendWithShiftEnter}
helperText={
sendWithShiftEnter
? <span>Press <kbd>Shift</kbd>+<kbd>Enter</kbd> to submit message</span>
: <span>Press <kbd>Shift</kbd>+<kbd>Enter</kbd> to add a new line</span>
}
/>
</>
);
Expand Down

0 comments on commit 5bb9e58

Please sign in to comment.