Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds helper text to chat input field #139

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ jobs:
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version_spec: minor
10 changes: 8 additions & 2 deletions packages/jupyter-ai/src/components/chat-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ type ChatInputProps = {
toggleIncludeSelection: () => unknown;
replaceSelection: boolean;
toggleReplaceSelection: () => unknown;
helperText: JSX.Element
sx?: SxProps<Theme>;
};

export function ChatInput(props: ChatInputProps): JSX.Element {

function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
if (event.key === 'Enter' && event.shiftKey) {
props.onSend();
Expand All @@ -35,7 +37,7 @@ export function ChatInput(props: ChatInputProps): JSX.Element {
}
return (
<Box sx={props.sx}>
<Box sx={{ display: 'flex' }}>
<Box sx={{ display: 'flex'}}>
<TextField
value={props.value}
onChange={e => props.onChange(e.target.value)}
Expand All @@ -50,8 +52,12 @@ export function ChatInput(props: ChatInputProps): JSX.Element {
<SendIcon />
</IconButton>
</InputAdornment>
),
)
}}
FormHelperTextProps={{
sx: {marginLeft: 'auto', marginRight: 0}
}}
helperText={props.value.length > 2 ? props.helperText : ' '}
/>
</Box>
{props.hasSelection && (
Expand Down
5 changes: 3 additions & 2 deletions packages/jupyter-ai/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ function ChatBody({ chatHandler }: ChatBodyProps): JSX.Element {
sx={{
paddingLeft: 4,
paddingRight: 4,
paddingTop: 2,
paddingBottom: 2,
paddingTop: 3.5,
paddingBottom: 0,
borderTop: '1px solid var(--jp-border-color1)'
}}
helperText={<span><b>Press Shift</b> + <b>Enter</b> to submit message</span>}
/>
</Box>
);
Expand Down