@jupyter/chat 0.19.0-alpha.0 → 0.19.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/lib/active-cell-manager.js +4 -2
  2. package/lib/components/attachments.js +3 -3
  3. package/lib/components/chat.d.ts +3 -7
  4. package/lib/components/chat.js +9 -5
  5. package/lib/components/code-blocks/code-toolbar.js +8 -28
  6. package/lib/components/code-blocks/copy-button.js +4 -11
  7. package/lib/components/index.d.ts +1 -0
  8. package/lib/components/index.js +1 -0
  9. package/lib/components/input/buttons/attach-button.js +3 -10
  10. package/lib/components/input/buttons/cancel-button.js +6 -10
  11. package/lib/components/input/buttons/save-edit-button.js +6 -13
  12. package/lib/components/input/buttons/send-button.js +6 -23
  13. package/lib/components/input/buttons/stop-button.js +6 -23
  14. package/lib/components/input/chat-input.d.ts +0 -20
  15. package/lib/components/input/chat-input.js +21 -18
  16. package/lib/components/messages/footer.d.ts +5 -5
  17. package/lib/components/messages/footer.js +7 -2
  18. package/lib/components/messages/header.js +10 -8
  19. package/lib/components/messages/message-renderer.d.ts +0 -10
  20. package/lib/components/messages/message-renderer.js +5 -3
  21. package/lib/components/messages/message.d.ts +8 -4
  22. package/lib/components/messages/message.js +4 -2
  23. package/lib/components/messages/messages.d.ts +1 -39
  24. package/lib/components/messages/messages.js +31 -13
  25. package/lib/components/messages/navigation.d.ts +1 -2
  26. package/lib/components/messages/navigation.js +2 -1
  27. package/lib/components/messages/toolbar.js +12 -26
  28. package/lib/components/messages/welcome.d.ts +10 -2
  29. package/lib/components/messages/welcome.js +2 -1
  30. package/lib/components/mui-extras/tooltipped-button.d.ts +28 -1
  31. package/lib/components/mui-extras/tooltipped-button.js +34 -6
  32. package/lib/components/mui-extras/tooltipped-icon-button.d.ts +6 -1
  33. package/lib/components/mui-extras/tooltipped-icon-button.js +8 -7
  34. package/lib/context.d.ts +3 -2
  35. package/lib/context.js +9 -2
  36. package/lib/index.d.ts +1 -0
  37. package/lib/index.js +1 -0
  38. package/lib/tokens.d.ts +11 -0
  39. package/lib/tokens.js +9 -0
  40. package/lib/types.d.ts +4 -0
  41. package/lib/widgets/chat-widget.d.ts +5 -0
  42. package/lib/widgets/chat-widget.js +6 -0
  43. package/lib/widgets/multichat-panel.d.ts +1 -6
  44. package/lib/widgets/multichat-panel.js +3 -13
  45. package/package.json +1 -1
  46. package/src/active-cell-manager.ts +3 -1
  47. package/src/components/attachments.tsx +3 -3
  48. package/src/components/chat.tsx +13 -24
  49. package/src/components/code-blocks/code-toolbar.tsx +29 -55
  50. package/src/components/code-blocks/copy-button.tsx +13 -20
  51. package/src/components/index.ts +1 -0
  52. package/src/components/input/buttons/attach-button.tsx +5 -13
  53. package/src/components/input/buttons/cancel-button.tsx +11 -18
  54. package/src/components/input/buttons/save-edit-button.tsx +13 -22
  55. package/src/components/input/buttons/send-button.tsx +13 -34
  56. package/src/components/input/buttons/stop-button.tsx +13 -34
  57. package/src/components/input/chat-input.tsx +24 -38
  58. package/src/components/messages/footer.tsx +12 -10
  59. package/src/components/messages/header.tsx +23 -17
  60. package/src/components/messages/message-renderer.tsx +5 -13
  61. package/src/components/messages/message.tsx +4 -7
  62. package/src/components/messages/messages.tsx +73 -97
  63. package/src/components/messages/navigation.tsx +3 -3
  64. package/src/components/messages/toolbar.tsx +19 -33
  65. package/src/components/messages/welcome.tsx +13 -2
  66. package/src/components/mui-extras/tooltipped-button.tsx +44 -5
  67. package/src/components/mui-extras/tooltipped-icon-button.tsx +22 -6
  68. package/src/context.ts +15 -5
  69. package/src/index.ts +1 -0
  70. package/src/tokens.ts +24 -0
  71. package/src/types.ts +4 -0
  72. package/src/widgets/chat-widget.tsx +8 -0
  73. package/src/widgets/multichat-panel.tsx +7 -26
@@ -64,13 +64,8 @@ export declare class MultiChatPanel extends SidePanel {
64
64
  private _onExpansionToggled;
65
65
  private _chatNamesChanged;
66
66
  private _sectionAdded;
67
- private _rmRegistry;
68
- private _themeManager?;
69
- private _chatCommandRegistry?;
70
- private _attachmentOpenerRegistry?;
67
+ private _chatOptions;
71
68
  private _inputToolbarFactory?;
72
- private _messageFooterRegistry?;
73
- private _welcomeMessage?;
74
69
  private _updateChatListDebouncer;
75
70
  private _createModel?;
76
71
  private _getChatNames?;
@@ -43,13 +43,8 @@ export class MultiChatPanel extends SidePanel {
43
43
  this.title.icon = chatIcon;
44
44
  this.title.caption = 'Jupyter Chat'; // TODO: i18n/
45
45
  this.addClass(SIDEPANEL_CLASS);
46
- this._rmRegistry = options.rmRegistry;
47
- this._themeManager = options.themeManager;
48
- this._chatCommandRegistry = options.chatCommandRegistry;
49
- this._attachmentOpenerRegistry = options.attachmentOpenerRegistry;
46
+ this._chatOptions = options;
50
47
  this._inputToolbarFactory = options.inputToolbarFactory;
51
- this._messageFooterRegistry = options.messageFooterRegistry;
52
- this._welcomeMessage = options.welcomeMessage;
53
48
  this._getChatNames = options.getChatNames;
54
49
  this._createModel = options.createModel;
55
50
  this._openInMain = options.openInMain;
@@ -116,13 +111,8 @@ export class MultiChatPanel extends SidePanel {
116
111
  // Create a new widget.
117
112
  const widget = new ChatWidget({
118
113
  model,
119
- rmRegistry: this._rmRegistry,
120
- themeManager: this._themeManager,
121
- chatCommandRegistry: this._chatCommandRegistry,
122
- attachmentOpenerRegistry: this._attachmentOpenerRegistry,
114
+ ...this._chatOptions,
123
115
  inputToolbarRegistry,
124
- messageFooterRegistry: this._messageFooterRegistry,
125
- welcomeMessage: this._welcomeMessage,
126
116
  area: 'sidebar'
127
117
  });
128
118
  const section = new ChatSection({
@@ -365,6 +355,6 @@ function ChatSelect({ chatNamesChanged, handleChange }) {
365
355
  setChatNames(chatNames);
366
356
  });
367
357
  return (React.createElement(HTMLSelect, { onChange: handleChange, value: "-" },
368
- React.createElement("option", { value: "-" }, "Open a chat"),
358
+ React.createElement("option", { value: "-", disabled: true, hidden: true }, "Open a chat"),
369
359
  Object.keys(chatNames).map(name => (React.createElement("option", { value: chatNames[name] }, name)))));
370
360
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter/chat",
3
- "version": "0.19.0-alpha.0",
3
+ "version": "0.19.0-alpha.2",
4
4
  "description": "A package that provides UI components that can be used to create a chat in a Jupyterlab extension.",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -267,7 +267,9 @@ export class ActiveCellManager implements IActiveCellManager {
267
267
  activeCell: Cell<ICellModel> | null
268
268
  ): void => {
269
269
  if (this._activeCell !== activeCell) {
270
- this._activeCell?.model.stateChanged.disconnect(this._cellStateChange);
270
+ if (!this._activeCell?.disposed) {
271
+ this._activeCell?.model.stateChanged.disconnect(this._cellStateChange);
272
+ }
271
273
  this._activeCell = activeCell;
272
274
 
273
275
  activeCell?.ready.then(() => {
@@ -5,12 +5,12 @@
5
5
 
6
6
  import CloseIcon from '@mui/icons-material/Close';
7
7
  import { Box, Button, Tooltip } from '@mui/material';
8
- import React, { useContext } from 'react';
8
+ import React from 'react';
9
9
  import { PathExt } from '@jupyterlab/coreutils';
10
10
  import { UUID } from '@lumino/coreutils';
11
11
 
12
+ import { useChatContext } from '../context';
12
13
  import { IAttachment } from '../types';
13
- import { AttachmentOpenerContext } from '../context';
14
14
 
15
15
  const ATTACHMENT_CLASS = 'jp-chat-attachment';
16
16
  const ATTACHMENT_CLICKABLE_CLASS = 'jp-chat-attachment-clickable';
@@ -87,7 +87,7 @@ export type AttachmentProps = AttachmentsProps & {
87
87
  */
88
88
  export function AttachmentPreview(props: AttachmentProps): JSX.Element {
89
89
  const remove_tooltip = 'Remove attachment';
90
- const attachmentOpenerRegistry = useContext(AttachmentOpenerContext);
90
+ const { attachmentOpenerRegistry } = useChatContext();
91
91
  const isClickable = !!attachmentOpenerRegistry?.get(props.attachment.type);
92
92
 
93
93
  return (
@@ -18,7 +18,7 @@ import {
18
18
  } from './input';
19
19
  import { JlThemeProvider } from './jl-theme-provider';
20
20
  import { ChatMessages } from './messages';
21
- import { AttachmentOpenerContext } from '../context';
21
+ import { ChatReactContext } from '../context';
22
22
  import { IChatModel } from '../model';
23
23
  import {
24
24
  IAttachmentOpenerRegistry,
@@ -27,7 +27,7 @@ import {
27
27
  } from '../registers';
28
28
  import { ChatArea } from '../types';
29
29
 
30
- export function ChatBody(props: Chat.IChatBodyProps): JSX.Element {
30
+ export function ChatBody(props: Chat.IChatProps): JSX.Element {
31
31
  const { model } = props;
32
32
  let { inputToolbarRegistry } = props;
33
33
  if (!inputToolbarRegistry) {
@@ -36,17 +36,14 @@ export function ChatBody(props: Chat.IChatBodyProps): JSX.Element {
36
36
  // const horizontalPadding = props.area === 'main' ? 8 : 4;
37
37
  const horizontalPadding = 4;
38
38
 
39
+ const contextValue: Chat.IChatProps = {
40
+ ...props,
41
+ inputToolbarRegistry
42
+ };
43
+
39
44
  return (
40
- <AttachmentOpenerContext.Provider value={props.attachmentOpenerRegistry}>
41
- <ChatMessages
42
- rmRegistry={props.rmRegistry}
43
- model={model}
44
- chatCommandRegistry={props.chatCommandRegistry}
45
- inputToolbarRegistry={inputToolbarRegistry}
46
- messageFooterRegistry={props.messageFooterRegistry}
47
- welcomeMessage={props.welcomeMessage}
48
- area={props.area}
49
- />
45
+ <ChatReactContext.Provider value={contextValue}>
46
+ <ChatMessages />
50
47
  <ChatInput
51
48
  sx={{
52
49
  paddingLeft: horizontalPadding,
@@ -55,17 +52,13 @@ export function ChatBody(props: Chat.IChatBodyProps): JSX.Element {
55
52
  paddingBottom: 0
56
53
  }}
57
54
  model={model.input}
58
- chatCommandRegistry={props.chatCommandRegistry}
59
- toolbarRegistry={inputToolbarRegistry}
60
- area={props.area}
61
- chatModel={model}
62
55
  />
63
- </AttachmentOpenerContext.Provider>
56
+ </ChatReactContext.Provider>
64
57
  );
65
58
  }
66
59
 
67
60
  export function Chat(props: Chat.IOptions): JSX.Element {
68
- const [view, setView] = useState<Chat.View>(props.chatView || Chat.View.chat);
61
+ const [view, setView] = useState<Chat.View>(Chat.View.chat);
69
62
  return (
70
63
  <JlThemeProvider themeManager={props.themeManager ?? null}>
71
64
  <Box
@@ -117,7 +110,7 @@ export namespace Chat {
117
110
  /**
118
111
  * The props for the chat body component.
119
112
  */
120
- export interface IChatBodyProps {
113
+ export interface IChatProps {
121
114
  /**
122
115
  * The chat model.
123
116
  */
@@ -155,15 +148,11 @@ export namespace Chat {
155
148
  /**
156
149
  * The options to build the Chat UI.
157
150
  */
158
- export interface IOptions extends IChatBodyProps {
151
+ export interface IOptions extends IChatProps {
159
152
  /**
160
153
  * The theme manager.
161
154
  */
162
155
  themeManager?: IThemeManager | null;
163
- /**
164
- * The view to render.
165
- */
166
- chatView?: View;
167
156
  /**
168
157
  * A settings panel that can be used for dedicated settings (e.g. jupyter-ai)
169
158
  */
@@ -4,10 +4,11 @@
4
4
  */
5
5
 
6
6
  import { addAboveIcon, addBelowIcon } from '@jupyterlab/ui-components';
7
- import { Box, IconButton, Tooltip } from '@mui/material';
7
+ import { Box } from '@mui/material';
8
8
  import React, { useEffect, useState } from 'react';
9
9
 
10
10
  import { CopyButton } from './copy-button';
11
+ import { TooltippedIconButton } from '../mui-extras';
11
12
  import { IActiveCellManager } from '../../active-cell-manager';
12
13
  import { replaceCellIcon } from '../../icons';
13
14
  import { IChatModel } from '../../model';
@@ -114,24 +115,15 @@ function InsertAboveButton(props: ToolbarButtonProps) {
114
115
  : 'Insert above active cell (no active cell)';
115
116
 
116
117
  return (
117
- <Tooltip title={tooltip} placement="top" arrow>
118
- <span>
119
- <IconButton
120
- className={props.className}
121
- onClick={() => props.activeCellManager?.insertAbove(props.content)}
122
- disabled={!props.activeCellAvailable}
123
- aria-label={tooltip}
124
- sx={{
125
- lineHeight: 0,
126
- '&.Mui-disabled': {
127
- opacity: 0.5
128
- }
129
- }}
130
- >
131
- <addAboveIcon.react height="16px" width="16px" />
132
- </IconButton>
133
- </span>
134
- </Tooltip>
118
+ <TooltippedIconButton
119
+ className={props.className}
120
+ tooltip={tooltip}
121
+ onClick={() => props.activeCellManager?.insertAbove(props.content)}
122
+ disabled={!props.activeCellAvailable}
123
+ inputToolbar={false}
124
+ >
125
+ <addAboveIcon.react height="16px" width="16px" />
126
+ </TooltippedIconButton>
135
127
  );
136
128
  }
137
129
 
@@ -141,24 +133,15 @@ function InsertBelowButton(props: ToolbarButtonProps) {
141
133
  : 'Insert below active cell (no active cell)';
142
134
 
143
135
  return (
144
- <Tooltip title={tooltip} placement="top" arrow>
145
- <span>
146
- <IconButton
147
- className={props.className}
148
- disabled={!props.activeCellAvailable}
149
- onClick={() => props.activeCellManager?.insertBelow(props.content)}
150
- aria-label={tooltip}
151
- sx={{
152
- lineHeight: 0,
153
- '&.Mui-disabled': {
154
- opacity: 0.5
155
- }
156
- }}
157
- >
158
- <addBelowIcon.react height="16px" width="16px" />
159
- </IconButton>
160
- </span>
161
- </Tooltip>
136
+ <TooltippedIconButton
137
+ className={props.className}
138
+ tooltip={tooltip}
139
+ disabled={!props.activeCellAvailable}
140
+ onClick={() => props.activeCellManager?.insertBelow(props.content)}
141
+ inputToolbar={false}
142
+ >
143
+ <addBelowIcon.react height="16px" width="16px" />
144
+ </TooltippedIconButton>
162
145
  );
163
146
  }
164
147
 
@@ -187,23 +170,14 @@ function ReplaceButton(props: ToolbarButtonProps) {
187
170
  };
188
171
 
189
172
  return (
190
- <Tooltip title={tooltip} placement="top" arrow>
191
- <span>
192
- <IconButton
193
- className={props.className}
194
- disabled={disabled}
195
- onClick={replace}
196
- aria-label={tooltip}
197
- sx={{
198
- lineHeight: 0,
199
- '&.Mui-disabled': {
200
- opacity: 0.5
201
- }
202
- }}
203
- >
204
- <replaceCellIcon.react height="16px" width="16px" />
205
- </IconButton>
206
- </span>
207
- </Tooltip>
173
+ <TooltippedIconButton
174
+ className={props.className}
175
+ tooltip={tooltip}
176
+ disabled={disabled}
177
+ onClick={replace}
178
+ inputToolbar={false}
179
+ >
180
+ <replaceCellIcon.react height="16px" width="16px" />
181
+ </TooltippedIconButton>
208
182
  );
209
183
  }
@@ -3,10 +3,10 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
 
6
+ import { copyIcon } from '@jupyterlab/ui-components';
6
7
  import React, { useState, useCallback, useRef } from 'react';
7
8
 
8
- import { copyIcon } from '@jupyterlab/ui-components';
9
- import { IconButton, Tooltip } from '@mui/material';
9
+ import { TooltippedIconButton } from '../mui-extras';
10
10
 
11
11
  enum CopyStatus {
12
12
  None,
@@ -61,23 +61,16 @@ export function CopyButton(props: CopyButtonProps): JSX.Element {
61
61
  const tooltip = COPYBTN_TEXT_BY_STATUS[copyStatus];
62
62
 
63
63
  return (
64
- <Tooltip title={tooltip} placement="top" arrow>
65
- <span>
66
- <IconButton
67
- disabled={isCopyDisabled}
68
- className={props.className}
69
- onClick={copy}
70
- aria-label="Copy to clipboard"
71
- sx={{
72
- lineHeight: 0,
73
- '&.Mui-disabled': {
74
- opacity: 0.5
75
- }
76
- }}
77
- >
78
- <copyIcon.react height="16px" width="16px" />
79
- </IconButton>
80
- </span>
81
- </Tooltip>
64
+ <TooltippedIconButton
65
+ disabled={isCopyDisabled}
66
+ className={props.className}
67
+ tooltip={tooltip}
68
+ placement="top"
69
+ onClick={copy}
70
+ aria-label="Copy to clipboard"
71
+ inputToolbar={false}
72
+ >
73
+ <copyIcon.react height="16px" width="16px" />
74
+ </TooltippedIconButton>
82
75
  );
83
76
  }
@@ -9,4 +9,5 @@ export * from './code-blocks';
9
9
  export * from './input';
10
10
  export * from './jl-theme-provider';
11
11
  export * from './messages';
12
+ export * from './mui-extras';
12
13
  export * from './scroll-container';
@@ -8,7 +8,7 @@ import AttachFileIcon from '@mui/icons-material/AttachFile';
8
8
  import React from 'react';
9
9
 
10
10
  import { InputToolbarRegistry } from '../toolbar-registry';
11
- import { TooltippedButton } from '../../mui-extras/tooltipped-button';
11
+ import { TooltippedIconButton } from '../../mui-extras';
12
12
 
13
13
  const ATTACH_BUTTON_CLASS = 'jp-chat-attach-button';
14
14
 
@@ -47,23 +47,15 @@ export function AttachButton(
47
47
  };
48
48
 
49
49
  return (
50
- <TooltippedButton
50
+ <TooltippedIconButton
51
51
  onClick={onclick}
52
52
  tooltip={tooltip}
53
- buttonProps={{
54
- size: 'small',
55
- variant: 'text',
53
+ iconButtonProps={{
56
54
  title: tooltip,
57
55
  className: ATTACH_BUTTON_CLASS
58
56
  }}
59
- sx={{
60
- width: '24px',
61
- height: '24px',
62
- minWidth: '24px',
63
- color: 'gray'
64
- }}
65
57
  >
66
- <AttachFileIcon sx={{ fontSize: '16px ' }} />
67
- </TooltippedButton>
58
+ <AttachFileIcon />
59
+ </TooltippedIconButton>
68
60
  );
69
61
  }
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import CloseIcon from '@mui/icons-material/Close';
7
- import { IconButton, Tooltip } from '@mui/material';
8
7
  import React from 'react';
9
8
 
10
9
  import { InputToolbarRegistry } from '../toolbar-registry';
10
+ import { TooltippedIconButton } from '../../mui-extras';
11
11
 
12
12
  const CANCEL_BUTTON_CLASS = 'jp-chat-cancel-button';
13
13
 
@@ -22,22 +22,15 @@ export function CancelButton(
22
22
  }
23
23
  const tooltip = 'Cancel editing';
24
24
  return (
25
- <Tooltip title={tooltip} placement="top" arrow>
26
- <span>
27
- <IconButton
28
- onClick={props.model.cancel}
29
- className={CANCEL_BUTTON_CLASS}
30
- aria-label={tooltip}
31
- sx={{
32
- width: '24px',
33
- height: '24px',
34
- padding: 0,
35
- lineHeight: 0
36
- }}
37
- >
38
- <CloseIcon sx={{ fontSize: '16px' }} />
39
- </IconButton>
40
- </span>
41
- </Tooltip>
25
+ <TooltippedIconButton
26
+ onClick={props.model.cancel}
27
+ tooltip={tooltip}
28
+ iconButtonProps={{
29
+ title: tooltip,
30
+ className: CANCEL_BUTTON_CLASS
31
+ }}
32
+ >
33
+ <CloseIcon />
34
+ </TooltippedIconButton>
42
35
  );
43
36
  }
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import CheckIcon from '@mui/icons-material/Check';
7
- import { IconButton, Tooltip } from '@mui/material';
8
7
  import React, { useEffect, useState } from 'react';
9
8
 
10
9
  import { InputToolbarRegistry } from '../toolbar-registry';
10
+ import { TooltippedIconButton } from '../../mui-extras';
11
11
 
12
12
  const SAVE_EDIT_BUTTON_CLASS = 'jp-chat-save-edit-button';
13
13
 
@@ -50,26 +50,17 @@ export function SaveEditButton(
50
50
  }
51
51
 
52
52
  return (
53
- <Tooltip title={tooltip} placement="top" arrow>
54
- <span>
55
- <IconButton
56
- onClick={save}
57
- disabled={disabled}
58
- className={SAVE_EDIT_BUTTON_CLASS}
59
- aria-label={tooltip}
60
- sx={{
61
- width: '24px',
62
- height: '24px',
63
- padding: 0,
64
- lineHeight: 0,
65
- '&.Mui-disabled': {
66
- opacity: 0.5
67
- }
68
- }}
69
- >
70
- <CheckIcon sx={{ fontSize: '16px' }} />
71
- </IconButton>
72
- </span>
73
- </Tooltip>
53
+ <TooltippedIconButton
54
+ onClick={save}
55
+ tooltip={tooltip}
56
+ disabled={disabled}
57
+ iconButtonProps={{
58
+ title: tooltip,
59
+ className: SAVE_EDIT_BUTTON_CLASS
60
+ }}
61
+ aria-label={tooltip}
62
+ >
63
+ <CheckIcon />
64
+ </TooltippedIconButton>
74
65
  );
75
66
  }
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward';
7
- import { Button, Tooltip } from '@mui/material';
8
7
  import React, { useEffect, useState } from 'react';
9
8
 
10
9
  import { InputToolbarRegistry } from '../toolbar-registry';
10
+ import { TooltippedIconButton } from '../../mui-extras';
11
11
  import { IInputModel, InputModel } from '../../../input-model';
12
12
 
13
13
  const SEND_BUTTON_CLASS = 'jp-chat-send-button';
@@ -69,38 +69,17 @@ export function SendButton(
69
69
  }
70
70
 
71
71
  return (
72
- <Tooltip title={tooltip} placement="top" arrow>
73
- <span>
74
- <Button
75
- onClick={send}
76
- disabled={disabled}
77
- size="small"
78
- variant="contained"
79
- className={SEND_BUTTON_CLASS}
80
- aria-label={tooltip}
81
- sx={{
82
- backgroundColor: 'var(--jp-brand-color1)',
83
- color: 'white',
84
- minWidth: '24px',
85
- width: '24px',
86
- height: '24px',
87
- borderRadius: '4px',
88
- boxShadow: 'none',
89
- lineHeight: 0,
90
- '&:hover': {
91
- backgroundColor: 'var(--jp-brand-color0)',
92
- boxShadow: 'none'
93
- },
94
- '&.Mui-disabled': {
95
- backgroundColor: 'var(--jp-border-color2)',
96
- color: 'var(--jp-ui-font-color3)',
97
- opacity: 0.5
98
- }
99
- }}
100
- >
101
- <ArrowUpwardIcon sx={{ fontSize: '16px' }} />
102
- </Button>
103
- </span>
104
- </Tooltip>
72
+ <TooltippedIconButton
73
+ onClick={send}
74
+ tooltip={tooltip}
75
+ disabled={disabled}
76
+ iconButtonProps={{
77
+ title: tooltip,
78
+ className: SEND_BUTTON_CLASS
79
+ }}
80
+ aria-label={tooltip}
81
+ >
82
+ <ArrowUpwardIcon />
83
+ </TooltippedIconButton>
105
84
  );
106
85
  }
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import StopIcon from '@mui/icons-material/Stop';
7
- import { Button, Tooltip } from '@mui/material';
8
7
  import React, { useEffect, useState } from 'react';
9
8
 
10
9
  import { InputToolbarRegistry } from '../toolbar-registry';
10
+ import { TooltippedIconButton } from '../../mui-extras';
11
11
 
12
12
  const STOP_BUTTON_CLASS = 'jp-chat-stop-button';
13
13
 
@@ -51,38 +51,17 @@ export function StopButton(
51
51
  }
52
52
 
53
53
  return (
54
- <Tooltip title={tooltip} placement="top" arrow>
55
- <span>
56
- <Button
57
- onClick={stop}
58
- disabled={disabled}
59
- size="small"
60
- variant="contained"
61
- className={STOP_BUTTON_CLASS}
62
- aria-label={tooltip}
63
- sx={{
64
- backgroundColor: 'var(--jp-error-color1)',
65
- color: 'white',
66
- minWidth: '24px',
67
- width: '24px',
68
- height: '24px',
69
- borderRadius: '4px',
70
- boxShadow: 'none',
71
- lineHeight: 0,
72
- '&:hover': {
73
- backgroundColor: 'var(--jp-error-color0)',
74
- boxShadow: 'none'
75
- },
76
- '&.Mui-disabled': {
77
- backgroundColor: 'var(--jp-border-color2)',
78
- color: 'var(--jp-ui-font-color3)',
79
- opacity: 0.5
80
- }
81
- }}
82
- >
83
- <StopIcon sx={{ fontSize: '16px' }} />
84
- </Button>
85
- </span>
86
- </Tooltip>
54
+ <TooltippedIconButton
55
+ onClick={stop}
56
+ tooltip={tooltip}
57
+ disabled={disabled}
58
+ iconButtonProps={{
59
+ title: tooltip,
60
+ className: STOP_BUTTON_CLASS
61
+ }}
62
+ aria-label={tooltip}
63
+ >
64
+ <StopIcon />
65
+ </TooltippedIconButton>
87
66
  );
88
67
  }