@copilotkit/react-textarea 1.51.4-next.7 → 1.51.4

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 (250) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +18 -12
  3. package/dist/{chunk-D47EKHIF.mjs → chunk-2X3CZVEP.mjs} +9 -3
  4. package/dist/chunk-2X3CZVEP.mjs.map +1 -0
  5. package/dist/{chunk-GU5LTWGL.mjs → chunk-3WLGLZTY.mjs} +19 -13
  6. package/dist/chunk-3WLGLZTY.mjs.map +1 -0
  7. package/dist/{chunk-DRV2FOHZ.mjs → chunk-7GZWOXE4.mjs} +2 -2
  8. package/dist/chunk-7GZWOXE4.mjs.map +1 -0
  9. package/dist/{chunk-NAFNY4FL.mjs → chunk-7V4ORVQX.mjs} +1 -1
  10. package/dist/chunk-7V4ORVQX.mjs.map +1 -0
  11. package/dist/{chunk-ECR45NSD.mjs → chunk-A6YGJFQI.mjs} +9 -2
  12. package/dist/chunk-A6YGJFQI.mjs.map +1 -0
  13. package/dist/{chunk-WGWQRALG.mjs → chunk-AHNPJMBR.mjs} +10 -3
  14. package/dist/chunk-AHNPJMBR.mjs.map +1 -0
  15. package/dist/{chunk-VSVQZUPW.mjs → chunk-ARLBRSB7.mjs} +23 -7
  16. package/dist/chunk-ARLBRSB7.mjs.map +1 -0
  17. package/dist/{chunk-72GJNLCO.mjs → chunk-AZ7RF6ED.mjs} +5 -5
  18. package/dist/chunk-AZ7RF6ED.mjs.map +1 -0
  19. package/dist/{chunk-I72DKFHD.mjs → chunk-CFCMZVQ2.mjs} +29 -7
  20. package/dist/chunk-CFCMZVQ2.mjs.map +1 -0
  21. package/dist/{chunk-T6MTDQZ7.mjs → chunk-CMKGYQFX.mjs} +1 -1
  22. package/dist/chunk-CMKGYQFX.mjs.map +1 -0
  23. package/dist/{chunk-DFTV4TST.mjs → chunk-DZMQBOPG.mjs} +1 -1
  24. package/dist/chunk-DZMQBOPG.mjs.map +1 -0
  25. package/dist/{chunk-CLGAJCZ5.mjs → chunk-E7C63KQP.mjs} +10 -6
  26. package/dist/chunk-E7C63KQP.mjs.map +1 -0
  27. package/dist/{chunk-GQN2HYFJ.mjs → chunk-EGBZSVLK.mjs} +5 -2
  28. package/dist/{chunk-GQN2HYFJ.mjs.map → chunk-EGBZSVLK.mjs.map} +1 -1
  29. package/dist/{chunk-3QJOFG3V.mjs → chunk-FTG7P3NP.mjs} +1 -1
  30. package/dist/chunk-FTG7P3NP.mjs.map +1 -0
  31. package/dist/{chunk-KMVGEY7Q.mjs → chunk-IBZTDP72.mjs} +9 -4
  32. package/dist/chunk-IBZTDP72.mjs.map +1 -0
  33. package/dist/{chunk-4PDYALMP.mjs → chunk-LYNGBKJR.mjs} +9 -3
  34. package/dist/chunk-LYNGBKJR.mjs.map +1 -0
  35. package/dist/{chunk-DL3JWL2E.mjs → chunk-M7GTVHFB.mjs} +26 -8
  36. package/dist/chunk-M7GTVHFB.mjs.map +1 -0
  37. package/dist/chunk-MQBPYOOZ.mjs +97 -0
  38. package/dist/chunk-MQBPYOOZ.mjs.map +1 -0
  39. package/dist/{chunk-6SGWO63I.mjs → chunk-MQXYWOE2.mjs} +3 -3
  40. package/dist/chunk-MQXYWOE2.mjs.map +1 -0
  41. package/dist/{chunk-F2ULK22F.mjs → chunk-NFMCLTJU.mjs} +1 -1
  42. package/dist/chunk-NFMCLTJU.mjs.map +1 -0
  43. package/dist/{chunk-F6RLSVG3.mjs → chunk-O4WCM57A.mjs} +1 -1
  44. package/dist/chunk-O4WCM57A.mjs.map +1 -0
  45. package/dist/{chunk-4NHVQZ67.mjs → chunk-PDFIUPCS.mjs} +1 -1
  46. package/dist/chunk-PDFIUPCS.mjs.map +1 -0
  47. package/dist/{chunk-7NOLZ5T3.mjs → chunk-SWX3MRZ4.mjs} +31 -22
  48. package/dist/chunk-SWX3MRZ4.mjs.map +1 -0
  49. package/dist/{chunk-QJNFNPWH.mjs → chunk-TGN3YVSO.mjs} +2 -2
  50. package/dist/chunk-TGN3YVSO.mjs.map +1 -0
  51. package/dist/{chunk-LYB4B6MK.mjs → chunk-UB4Y22EF.mjs} +4 -2
  52. package/dist/chunk-UB4Y22EF.mjs.map +1 -0
  53. package/dist/{chunk-ZQSEYPNN.mjs → chunk-UIBUYQPG.mjs} +7 -2
  54. package/dist/chunk-UIBUYQPG.mjs.map +1 -0
  55. package/dist/{chunk-AJ5OMEXM.mjs → chunk-VBPZTMXB.mjs} +2 -2
  56. package/dist/{chunk-EJGGLWWR.mjs → chunk-VH7INUR5.mjs} +1 -1
  57. package/dist/{chunk-EJGGLWWR.mjs.map → chunk-VH7INUR5.mjs.map} +1 -1
  58. package/dist/{chunk-7LSRNPNI.mjs → chunk-VVRGAA43.mjs} +1 -1
  59. package/dist/chunk-VVRGAA43.mjs.map +1 -0
  60. package/dist/{chunk-YLFAIYRY.mjs → chunk-VYLLLBUP.mjs} +1 -1
  61. package/dist/chunk-VYLLLBUP.mjs.map +1 -0
  62. package/dist/{chunk-2QDCE7PD.mjs → chunk-WXKPRNNO.mjs} +1 -1
  63. package/dist/chunk-WXKPRNNO.mjs.map +1 -0
  64. package/dist/{chunk-JLOABKLH.mjs → chunk-YINY56BI.mjs} +2 -2
  65. package/dist/{chunk-23Q6A46J.mjs → chunk-ZBP4SABT.mjs} +22 -8
  66. package/dist/chunk-ZBP4SABT.mjs.map +1 -0
  67. package/dist/{chunk-H5ZNEKUR.mjs → chunk-ZWI5KPQ5.mjs} +2 -2
  68. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +154 -86
  69. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  70. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +29 -29
  71. package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
  72. package/dist/components/base-copilot-textarea/render-element.mjs +1 -1
  73. package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -1
  74. package/dist/components/base-copilot-textarea/render-placeholder.mjs +1 -1
  75. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -1
  76. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +2 -2
  77. package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +1 -1
  78. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +1 -1
  79. package/dist/components/copilot-textarea/copilot-textarea.js +190 -95
  80. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  81. package/dist/components/copilot-textarea/copilot-textarea.mjs +34 -34
  82. package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +1 -1
  83. package/dist/components/hovering-toolbar/hovering-editor-provider.js +3 -1
  84. package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -1
  85. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +1 -1
  86. package/dist/components/hovering-toolbar/hovering-toolbar-components.js +57 -63
  87. package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
  88. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +1 -1
  89. package/dist/components/hovering-toolbar/hovering-toolbar.js +117 -77
  90. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
  91. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +15 -15
  92. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +60 -14
  93. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
  94. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +11 -11
  95. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +60 -14
  96. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
  97. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +12 -12
  98. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.d.ts +1 -1
  99. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +14 -3
  100. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
  101. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +3 -3
  102. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +60 -14
  103. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
  104. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +12 -12
  105. package/dist/components/index.js +190 -95
  106. package/dist/components/index.js.map +1 -1
  107. package/dist/components/index.mjs +34 -34
  108. package/dist/components/manual-ui/chip-with-icon.d.ts +1 -1
  109. package/dist/components/manual-ui/chip-with-icon.js +13 -2
  110. package/dist/components/manual-ui/chip-with-icon.js.map +1 -1
  111. package/dist/components/manual-ui/chip-with-icon.mjs +13 -2
  112. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  113. package/dist/components/source-search-box/source-search-box.js +28 -5
  114. package/dist/components/source-search-box/source-search-box.js.map +1 -1
  115. package/dist/components/source-search-box/source-search-box.mjs +4 -4
  116. package/dist/components/ui/button.js +7 -1
  117. package/dist/components/ui/button.js.map +1 -1
  118. package/dist/components/ui/button.mjs +2 -2
  119. package/dist/components/ui/command.js +47 -9
  120. package/dist/components/ui/command.js.map +1 -1
  121. package/dist/components/ui/command.mjs +3 -3
  122. package/dist/components/ui/dialog.js +27 -5
  123. package/dist/components/ui/dialog.js.map +1 -1
  124. package/dist/components/ui/dialog.mjs +2 -2
  125. package/dist/components/ui/label.js +7 -1
  126. package/dist/components/ui/label.js.map +1 -1
  127. package/dist/components/ui/label.mjs +2 -2
  128. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +18 -4
  129. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
  130. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +4 -4
  131. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +1 -1
  132. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +2 -2
  133. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
  134. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +2 -2
  135. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +6 -1
  136. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
  137. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
  138. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +25 -7
  139. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  140. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +1 -1
  141. package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
  142. package/dist/hooks/misc/use-autosize-textarea.mjs +1 -1
  143. package/dist/index.js +190 -95
  144. package/dist/index.js.map +1 -1
  145. package/dist/index.mjs +35 -35
  146. package/dist/index.umd.js +16 -16
  147. package/dist/index.umd.js.map +1 -1
  148. package/dist/lib/debouncer.js.map +1 -1
  149. package/dist/lib/debouncer.mjs +1 -1
  150. package/dist/lib/editor-to-text.js.map +1 -1
  151. package/dist/lib/editor-to-text.mjs +1 -1
  152. package/dist/lib/get-text-around-cursor.js.map +1 -1
  153. package/dist/lib/get-text-around-cursor.mjs +1 -1
  154. package/dist/lib/slatejs-edits/clear-autocompletions.js +4 -1
  155. package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
  156. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +1 -1
  157. package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -1
  158. package/dist/lib/slatejs-edits/with-partial-history.mjs +1 -1
  159. package/dist/lib/stream-promise-flatten.js.map +1 -1
  160. package/dist/lib/stream-promise-flatten.mjs +1 -1
  161. package/dist/lib/utils.js.map +1 -1
  162. package/dist/lib/utils.mjs +1 -1
  163. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +1 -1
  164. package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
  165. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +3 -3
  166. package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
  167. package/dist/types/autosuggestions-config/editing-api-config.mjs +1 -1
  168. package/dist/types/autosuggestions-config/index.js.map +1 -1
  169. package/dist/types/autosuggestions-config/index.mjs +3 -3
  170. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +1 -1
  171. package/dist/types/base/base-autosuggestions-config.js.map +1 -1
  172. package/dist/types/base/base-autosuggestions-config.mjs +1 -1
  173. package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
  174. package/dist/types/base/editor-autocomplete-state.js.map +1 -1
  175. package/dist/types/base/editor-autocomplete-state.mjs +2 -2
  176. package/dist/types/base/index.js.map +1 -1
  177. package/dist/types/base/index.mjs +1 -1
  178. package/dist/types/index.js.map +1 -1
  179. package/dist/types/index.mjs +3 -3
  180. package/package.json +8 -8
  181. package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +30 -10
  182. package/src/components/base-copilot-textarea/render-element.tsx +6 -2
  183. package/src/components/base-copilot-textarea/render-placeholder.tsx +3 -1
  184. package/src/components/base-copilot-textarea/use-add-branding-css.tsx +3 -1
  185. package/src/components/copilot-textarea/copilot-textarea.tsx +15 -9
  186. package/src/components/hovering-toolbar/hovering-editor-provider.tsx +3 -1
  187. package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +63 -52
  188. package/src/components/hovering-toolbar/hovering-toolbar.tsx +21 -5
  189. package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +13 -7
  190. package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +7 -2
  191. package/src/components/manual-ui/chip-with-icon.tsx +12 -3
  192. package/src/components/source-search-box/source-search-box.tsx +12 -2
  193. package/src/components/ui/button.tsx +13 -5
  194. package/src/components/ui/command.tsx +17 -4
  195. package/src/components/ui/dialog.tsx +23 -5
  196. package/src/components/ui/label.tsx +7 -2
  197. package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +35 -9
  198. package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +5 -1
  199. package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +5 -1
  200. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +9 -2
  201. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +24 -6
  202. package/src/hooks/misc/use-autosize-textarea.tsx +4 -1
  203. package/src/lib/debouncer.ts +3 -1
  204. package/src/lib/editor-to-text.ts +5 -2
  205. package/src/lib/get-text-around-cursor.ts +14 -2
  206. package/src/lib/slatejs-edits/clear-autocompletions.ts +4 -1
  207. package/src/lib/slatejs-edits/with-partial-history.ts +10 -3
  208. package/src/lib/stream-promise-flatten.ts +3 -1
  209. package/src/lib/utils.ts +6 -2
  210. package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +3 -2
  211. package/src/types/autosuggestions-config/autosuggestions-config.tsx +20 -5
  212. package/src/types/autosuggestions-config/editing-api-config.tsx +2 -1
  213. package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +4 -1
  214. package/src/types/base/base-autosuggestions-config.tsx +10 -4
  215. package/src/types/base/base-copilot-textarea-props.tsx +4 -2
  216. package/tsconfig.json +1 -1
  217. package/tsup.config.ts +5 -1
  218. package/dist/chunk-23Q6A46J.mjs.map +0 -1
  219. package/dist/chunk-2IWVZ4PP.mjs +0 -103
  220. package/dist/chunk-2IWVZ4PP.mjs.map +0 -1
  221. package/dist/chunk-2QDCE7PD.mjs.map +0 -1
  222. package/dist/chunk-3QJOFG3V.mjs.map +0 -1
  223. package/dist/chunk-4NHVQZ67.mjs.map +0 -1
  224. package/dist/chunk-4PDYALMP.mjs.map +0 -1
  225. package/dist/chunk-6SGWO63I.mjs.map +0 -1
  226. package/dist/chunk-72GJNLCO.mjs.map +0 -1
  227. package/dist/chunk-7LSRNPNI.mjs.map +0 -1
  228. package/dist/chunk-7NOLZ5T3.mjs.map +0 -1
  229. package/dist/chunk-CLGAJCZ5.mjs.map +0 -1
  230. package/dist/chunk-D47EKHIF.mjs.map +0 -1
  231. package/dist/chunk-DFTV4TST.mjs.map +0 -1
  232. package/dist/chunk-DL3JWL2E.mjs.map +0 -1
  233. package/dist/chunk-DRV2FOHZ.mjs.map +0 -1
  234. package/dist/chunk-ECR45NSD.mjs.map +0 -1
  235. package/dist/chunk-F2ULK22F.mjs.map +0 -1
  236. package/dist/chunk-F6RLSVG3.mjs.map +0 -1
  237. package/dist/chunk-GU5LTWGL.mjs.map +0 -1
  238. package/dist/chunk-I72DKFHD.mjs.map +0 -1
  239. package/dist/chunk-KMVGEY7Q.mjs.map +0 -1
  240. package/dist/chunk-LYB4B6MK.mjs.map +0 -1
  241. package/dist/chunk-NAFNY4FL.mjs.map +0 -1
  242. package/dist/chunk-QJNFNPWH.mjs.map +0 -1
  243. package/dist/chunk-T6MTDQZ7.mjs.map +0 -1
  244. package/dist/chunk-VSVQZUPW.mjs.map +0 -1
  245. package/dist/chunk-WGWQRALG.mjs.map +0 -1
  246. package/dist/chunk-YLFAIYRY.mjs.map +0 -1
  247. package/dist/chunk-ZQSEYPNN.mjs.map +0 -1
  248. /package/dist/{chunk-AJ5OMEXM.mjs.map → chunk-VBPZTMXB.mjs.map} +0 -0
  249. /package/dist/{chunk-JLOABKLH.mjs.map → chunk-YINY56BI.mjs.map} +0 -0
  250. /package/dist/{chunk-H5ZNEKUR.mjs.map → chunk-ZWI5KPQ5.mjs.map} +0 -0
@@ -33,13 +33,13 @@ export const HoveringInsertionPromptBoxCore = ({
33
33
  const { getDocumentsContext } = useCopilotContext();
34
34
 
35
35
  const [editSuggestion, setEditSuggestion] = useState<string>("");
36
- const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);
36
+ const [suggestionIsLoading, setSuggestionIsLoading] =
37
+ useState<boolean>(false);
37
38
 
38
39
  const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>("");
39
40
 
40
- const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(
41
- null,
42
- );
41
+ const [generatingSuggestion, setGeneratingSuggestion] =
42
+ useState<ReadableStream<string> | null>(null);
43
43
 
44
44
  const adjustmentTextAreaRef = useRef<HTMLTextAreaElement>(null);
45
45
  const suggestionTextAreaRef = useRef<HTMLTextAreaElement>(null);
@@ -88,7 +88,8 @@ export const HoveringInsertionPromptBoxCore = ({
88
88
 
89
89
  // Scroll to the bottom of the textarea. We call this here to make sure scroll-to-bottom is synchronous with the state update.
90
90
  if (suggestionTextAreaRef.current) {
91
- suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
91
+ suggestionTextAreaRef.current.scrollTop =
92
+ suggestionTextAreaRef.current.scrollHeight;
92
93
  }
93
94
  return newSuggestion;
94
95
  });
@@ -251,14 +252,19 @@ export const HoveringInsertionPromptBoxCore = ({
251
252
  <div className="w-full flex flex-col items-start relative gap-2">
252
253
  {AdjustmentPromptComponent}
253
254
  {filePointers.length > 0 && (
254
- <IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />
255
+ <IncludedFilesPreview
256
+ includedFiles={filePointers}
257
+ setIncludedFiles={setFilePointers}
258
+ />
255
259
  )}
256
260
  {sourceSearchWord !== undefined && (
257
261
  <SourceSearchBox
258
262
  searchTerm={sourceSearchWord}
259
263
  suggestedFiles={suggestedFiles}
260
264
  onSelectedFile={(filePointer) => {
261
- setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), ""));
265
+ setAdjustmentPrompt(
266
+ adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), ""),
267
+ );
262
268
  setFilePointers((prev) => [...prev, filePointer]);
263
269
 
264
270
  // focus back on the adjustment prompt, and move the cursor to the end
@@ -23,7 +23,9 @@ export const IncludedFilesPreview = ({
23
23
  key={`file-${filePointer.sourceApplication}.${filePointer.name}`}
24
24
  filePointer={filePointer}
25
25
  onDelete={() => {
26
- setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));
26
+ setIncludedFiles((prev) =>
27
+ prev.filter((fp) => fp !== filePointer),
28
+ );
27
29
  }}
28
30
  />
29
31
  );
@@ -38,7 +40,10 @@ export interface FileChipPreviewProps {
38
40
  onDelete: () => void;
39
41
  }
40
42
 
41
- export const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {
43
+ export const FileChipPreview = ({
44
+ filePointer,
45
+ onDelete,
46
+ }: FileChipPreviewProps) => {
42
47
  return (
43
48
  <Chip
44
49
  label={filePointer.name}
@@ -4,12 +4,21 @@ export interface ChipWithIconProps {
4
4
  iconUrl: string;
5
5
  }
6
6
 
7
- export const ChipWithIcon = ({ label, onDelete, iconUrl }: ChipWithIconProps) => {
7
+ export const ChipWithIcon = ({
8
+ label,
9
+ onDelete,
10
+ iconUrl,
11
+ }: ChipWithIconProps) => {
8
12
  return (
9
13
  <span className="inline-flex items-center px-3 py-1 rounded-full bg-slate-200 text-sm font-medium text-white">
10
- {iconUrl && <img src={iconUrl} alt="icon" className="w-4 h-4 rounded-full mr-2" />}
14
+ {iconUrl && (
15
+ <img src={iconUrl} alt="icon" className="w-4 h-4 rounded-full mr-2" />
16
+ )}
11
17
  {label}
12
- <button className="ml-2 text-white hover:text-gray-200 focus:outline-none" onClick={onDelete}>
18
+ <button
19
+ className="ml-2 text-white hover:text-gray-200 focus:outline-none"
20
+ onClick={onDelete}
21
+ >
13
22
  x
14
23
  </button>
15
24
  </span>
@@ -11,7 +11,14 @@ import {
11
11
  CommandShortcut,
12
12
  } from "../ui/command";
13
13
 
14
- import { Calculator, Calendar, CreditCard, Settings, Smile, User } from "lucide-react";
14
+ import {
15
+ Calculator,
16
+ Calendar,
17
+ CreditCard,
18
+ Settings,
19
+ Smile,
20
+ User,
21
+ } from "lucide-react";
15
22
 
16
23
  import { DocumentPointer } from "@copilotkit/react-core";
17
24
 
@@ -110,7 +117,10 @@ export function Logo({
110
117
  height: string;
111
118
  }) {
112
119
  return (
113
- <div className="flex items-center justify-center" style={{ width: width, height: height }}>
120
+ <div
121
+ className="flex items-center justify-center"
122
+ style={{ width: width, height: height }}
123
+ >
114
124
  {children}
115
125
  </div>
116
126
  );
@@ -10,9 +10,12 @@ const buttonVariants = cva(
10
10
  variants: {
11
11
  variant: {
12
12
  default: "bg-primary text-primary-foreground hover:bg-primary/90",
13
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
15
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
13
+ destructive:
14
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90",
15
+ outline:
16
+ "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
17
+ secondary:
18
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
16
19
  ghost: "hover:bg-accent hover:text-accent-foreground",
17
20
  link: "text-primary underline-offset-4 hover:underline",
18
21
  },
@@ -31,7 +34,8 @@ const buttonVariants = cva(
31
34
  );
32
35
 
33
36
  export interface ButtonProps
34
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
37
+ extends
38
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
35
39
  VariantProps<typeof buttonVariants> {
36
40
  asChild?: boolean;
37
41
  }
@@ -40,7 +44,11 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
40
44
  ({ className, variant, size, asChild = false, ...props }, ref) => {
41
45
  const Comp = asChild ? Slot : "button";
42
46
  return (
43
- <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
47
+ <Comp
48
+ className={cn(buttonVariants({ variant, size, className }))}
49
+ ref={ref}
50
+ {...props}
51
+ />
44
52
  );
45
53
  },
46
54
  );
@@ -58,7 +58,10 @@ const CommandList = React.forwardRef<
58
58
  >(({ className, ...props }, ref) => (
59
59
  <CommandPrimitive.List
60
60
  ref={ref}
61
- className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)}
61
+ className={cn(
62
+ "max-h-[300px] overflow-y-auto overflow-x-hidden pb-2",
63
+ className,
64
+ )}
62
65
  {...props}
63
66
  />
64
67
  ));
@@ -69,7 +72,11 @@ const CommandEmpty = React.forwardRef<
69
72
  React.ElementRef<typeof CommandPrimitive.Empty>,
70
73
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
71
74
  >((props, ref) => (
72
- <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
75
+ <CommandPrimitive.Empty
76
+ ref={ref}
77
+ className="py-6 text-center text-sm"
78
+ {...props}
79
+ />
73
80
  ));
74
81
 
75
82
  CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
@@ -118,10 +125,16 @@ const CommandItem = React.forwardRef<
118
125
 
119
126
  CommandItem.displayName = CommandPrimitive.Item.displayName;
120
127
 
121
- const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
128
+ const CommandShortcut = ({
129
+ className,
130
+ ...props
131
+ }: React.HTMLAttributes<HTMLSpanElement>) => {
122
132
  return (
123
133
  <span
124
- className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
134
+ className={cn(
135
+ "ml-auto text-xs tracking-widest text-muted-foreground",
136
+ className,
137
+ )}
125
138
  {...props}
126
139
  />
127
140
  );
@@ -59,14 +59,29 @@ const DialogContent = React.forwardRef<
59
59
  ));
60
60
  DialogContent.displayName = DialogPrimitive.Content.displayName;
61
61
 
62
- const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
63
- <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
62
+ const DialogHeader = ({
63
+ className,
64
+ ...props
65
+ }: React.HTMLAttributes<HTMLDivElement>) => (
66
+ <div
67
+ className={cn(
68
+ "flex flex-col space-y-1.5 text-center sm:text-left",
69
+ className,
70
+ )}
71
+ {...props}
72
+ />
64
73
  );
65
74
  DialogHeader.displayName = "DialogHeader";
66
75
 
67
- const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
76
+ const DialogFooter = ({
77
+ className,
78
+ ...props
79
+ }: React.HTMLAttributes<HTMLDivElement>) => (
68
80
  <div
69
- className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
81
+ className={cn(
82
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
83
+ className,
84
+ )}
70
85
  {...props}
71
86
  />
72
87
  );
@@ -78,7 +93,10 @@ const DialogTitle = React.forwardRef<
78
93
  >(({ className, ...props }, ref) => (
79
94
  <DialogPrimitive.Title
80
95
  ref={ref}
81
- className={cn("text-lg font-semibold leading-none tracking-tight", className)}
96
+ className={cn(
97
+ "text-lg font-semibold leading-none tracking-tight",
98
+ className,
99
+ )}
82
100
  {...props}
83
101
  />
84
102
  ));
@@ -10,9 +10,14 @@ const labelVariants = cva(
10
10
 
11
11
  const Label = React.forwardRef<
12
12
  React.ElementRef<typeof LabelPrimitive.Root>,
13
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
13
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
14
+ VariantProps<typeof labelVariants>
14
15
  >(({ className, ...props }, ref) => (
15
- <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
16
+ <LabelPrimitive.Root
17
+ ref={ref}
18
+ className={cn(labelVariants(), className)}
19
+ {...props}
20
+ />
16
21
  ));
17
22
  Label.displayName = LabelPrimitive.Root.displayName;
18
23
 
@@ -17,8 +17,12 @@ export interface UseAutosuggestionsResult {
17
17
 
18
18
  export function useAutosuggestions(
19
19
  debounceTime: number,
20
- shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean,
21
- shouldAcceptAutosuggestionOnTouch: (event: React.TouchEvent<HTMLDivElement>) => boolean,
20
+ shouldAcceptAutosuggestionOnKeyPress: (
21
+ event: React.KeyboardEvent<HTMLDivElement>,
22
+ ) => boolean,
23
+ shouldAcceptAutosuggestionOnTouch: (
24
+ event: React.TouchEvent<HTMLDivElement>,
25
+ ) => boolean,
22
26
  autosuggestionFunction: AutosuggestionsBareFunction,
23
27
  insertAutocompleteSuggestion: (suggestion: AutosuggestionState) => void,
24
28
  disableWhenEmpty: boolean,
@@ -34,7 +38,10 @@ export function useAutosuggestions(
34
38
  editorAutocompleteState: EditorAutocompleteState,
35
39
  abortSignal: AbortSignal,
36
40
  ) => Promise<void> = useCallback(
37
- async (editorAutocompleteState: EditorAutocompleteState, abortSignal: AbortSignal) => {
41
+ async (
42
+ editorAutocompleteState: EditorAutocompleteState,
43
+ abortSignal: AbortSignal,
44
+ ) => {
38
45
  // early return if disabled
39
46
  if (disabled) {
40
47
  return;
@@ -49,7 +56,10 @@ export function useAutosuggestions(
49
56
  }
50
57
 
51
58
  // fetch the suggestion
52
- const suggestion = await autosuggestionFunction(editorAutocompleteState, abortSignal);
59
+ const suggestion = await autosuggestionFunction(
60
+ editorAutocompleteState,
61
+ abortSignal,
62
+ );
53
63
 
54
64
  // We'll assume for now that the autocomplete function might or might not respect the abort signal.
55
65
  if (!suggestion || abortSignal.aborted) {
@@ -61,11 +71,19 @@ export function useAutosuggestions(
61
71
  point: editorAutocompleteState.cursorPoint,
62
72
  });
63
73
  },
64
- [autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled],
74
+ [
75
+ autosuggestionFunction,
76
+ setCurrentAutocompleteSuggestion,
77
+ disableWhenEmpty,
78
+ disabled,
79
+ ],
65
80
  );
66
81
 
67
82
  const debouncedFunction = useMemo(
68
- () => new Debouncer<[editorAutocompleteState: EditorAutocompleteState]>(debounceTime),
83
+ () =>
84
+ new Debouncer<[editorAutocompleteState: EditorAutocompleteState]>(
85
+ debounceTime,
86
+ ),
69
87
  [debounceTime],
70
88
  );
71
89
 
@@ -111,12 +129,20 @@ export function useAutosuggestions(
111
129
  );
112
130
 
113
131
  const keyDownOrTouchHandler = useCallback(
114
- (event: React.KeyboardEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>) => {
132
+ (
133
+ event:
134
+ | React.KeyboardEvent<HTMLDivElement>
135
+ | React.TouchEvent<HTMLDivElement>,
136
+ ) => {
115
137
  if (currentAutocompleteSuggestion) {
116
138
  const shouldAcceptSuggestion =
117
139
  event.type === "touchstart"
118
- ? shouldAcceptAutosuggestionOnTouch(event as React.TouchEvent<HTMLDivElement>)
119
- : shouldAcceptAutosuggestionOnKeyPress(event as React.KeyboardEvent<HTMLDivElement>);
140
+ ? shouldAcceptAutosuggestionOnTouch(
141
+ event as React.TouchEvent<HTMLDivElement>,
142
+ )
143
+ : shouldAcceptAutosuggestionOnKeyPress(
144
+ event as React.KeyboardEvent<HTMLDivElement>,
145
+ );
120
146
 
121
147
  if (shouldAcceptSuggestion) {
122
148
  event.preventDefault();
@@ -35,7 +35,11 @@ const shouldSave: ShouldSaveToHistory = (op, prev) => {
35
35
  return false;
36
36
  }
37
37
 
38
- if (op.type == "set_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
38
+ if (
39
+ op.type == "set_node" &&
40
+ "type" in op.properties &&
41
+ op.properties.type === excludedNodeType
42
+ ) {
39
43
  return false;
40
44
  }
41
45
 
@@ -60,7 +60,11 @@ export function usePopulateCopilotTextareaRef(
60
60
  get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {
61
61
  return target.get(target, propKey);
62
62
  },
63
- set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {
63
+ set(
64
+ target: any,
65
+ propKey: keyof CustomMethods | keyof HTMLElement,
66
+ value: any,
67
+ ) {
64
68
  return target.set(target, propKey, value);
65
69
  },
66
70
  };
@@ -35,10 +35,17 @@ export function useMakeStandardAutosuggestionFunction(
35
35
  ): AutosuggestionsBareFunction {
36
36
  const runtimeClient = { generateCopilotResponse: (...args: any[]) => {} };
37
37
  const { getContextString, copilotApiConfig } = useCopilotContext();
38
- const { chatApiEndpoint: url, publicApiKey, credentials, properties } = copilotApiConfig;
38
+ const {
39
+ chatApiEndpoint: url,
40
+ publicApiKey,
41
+ credentials,
42
+ properties,
43
+ } = copilotApiConfig;
39
44
  const headers = {
40
45
  ...copilotApiConfig.headers,
41
- ...(publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {}),
46
+ ...(publicApiKey
47
+ ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey }
48
+ : {}),
42
49
  };
43
50
  const { maxTokens, stop, temperature = 0 } = apiConfig;
44
51
 
@@ -39,7 +39,9 @@ export function useMakeStandardInsertionOrEditingFunction(
39
39
  insertionApiConfig: InsertionsApiConfig,
40
40
  editingApiConfig: EditingApiConfig,
41
41
  ): Generator_InsertionOrEditingSuggestion {
42
- const runtimeClient: any = { generateCopilotResponse: (...args: any[]) => {} };
42
+ const runtimeClient: any = {
43
+ generateCopilotResponse: (...args: any[]) => {},
44
+ };
43
45
  const { getContextString, copilotApiConfig } = useCopilotContext();
44
46
  const headers = {
45
47
  ...(copilotApiConfig.publicApiKey
@@ -63,7 +65,9 @@ export function useMakeStandardInsertionOrEditingFunction(
63
65
  break;
64
66
  }
65
67
 
66
- const messages = convertGqlOutputToMessages(value.generateCopilotResponse.messages);
68
+ const messages = convertGqlOutputToMessages(
69
+ value.generateCopilotResponse.messages,
70
+ );
67
71
 
68
72
  let newContent = "";
69
73
 
@@ -121,7 +125,9 @@ export function useMakeStandardInsertionOrEditingFunction(
121
125
  actions: [],
122
126
  url: window.location.href,
123
127
  },
124
- messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),
128
+ messages: convertMessagesToGqlInput(
129
+ filterAgentStateMessages(messages),
130
+ ),
125
131
  metadata: {
126
132
  requestType: CopilotRequestType.TextareaCompletion,
127
133
  },
@@ -179,7 +185,9 @@ export function useMakeStandardInsertionOrEditingFunction(
179
185
  actions: [],
180
186
  url: window.location.href,
181
187
  },
182
- messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),
188
+ messages: convertMessagesToGqlInput(
189
+ filterAgentStateMessages(messages),
190
+ ),
183
191
  metadata: {
184
192
  requestType: CopilotRequestType.TextareaCompletion,
185
193
  },
@@ -203,9 +211,19 @@ export function useMakeStandardInsertionOrEditingFunction(
203
211
  abortSignal: AbortSignal,
204
212
  ) => {
205
213
  if (editorState.selectedText === "") {
206
- return await insertionFunction(editorState, insertionPrompt, documents, abortSignal);
214
+ return await insertionFunction(
215
+ editorState,
216
+ insertionPrompt,
217
+ documents,
218
+ abortSignal,
219
+ );
207
220
  } else {
208
- return await editingFunction(editorState, insertionPrompt, documents, abortSignal);
221
+ return await editingFunction(
222
+ editorState,
223
+ insertionPrompt,
224
+ documents,
225
+ abortSignal,
226
+ );
209
227
  }
210
228
  },
211
229
  [insertionFunction, editingFunction],
@@ -1,7 +1,10 @@
1
1
  import { Ref, RefObject, useEffect } from "react";
2
2
 
3
3
  // Updates the height of a <textarea> when the value changes.
4
- const useAutosizeTextArea = (textAreaRef: RefObject<HTMLTextAreaElement | null>, value: string) => {
4
+ const useAutosizeTextArea = (
5
+ textAreaRef: RefObject<HTMLTextAreaElement | null>,
6
+ value: string,
7
+ ) => {
5
8
  useEffect(() => {
6
9
  if (textAreaRef.current !== null) {
7
10
  // We need to reset the height momentarily to get the correct scrollHeight for the textarea
@@ -1,4 +1,6 @@
1
- export type AsyncFunction<T extends any[]> = (...args: [...T, AbortSignal]) => Promise<void>;
1
+ export type AsyncFunction<T extends any[]> = (
2
+ ...args: [...T, AbortSignal]
3
+ ) => Promise<void>;
2
4
 
3
5
  export class Debouncer<T extends any[]> {
4
6
  private timeoutId?: ReturnType<typeof setTimeout>;
@@ -28,7 +28,8 @@ function nodeChildrenToTextComponents(
28
28
  }
29
29
 
30
30
  const isNeighbourOfInline =
31
- indeciesOfInlineElements.has(index - 1) || indeciesOfInlineElements.has(index + 1);
31
+ indeciesOfInlineElements.has(index - 1) ||
32
+ indeciesOfInlineElements.has(index + 1);
32
33
  if (isNeighbourOfInline) {
33
34
  return (node as any).text !== "";
34
35
  }
@@ -52,7 +53,9 @@ function nodeChildrenToTextComponents(
52
53
  .reduce((acc, val) => acc.concat(val), []);
53
54
  }
54
55
 
55
- export const editorToText = (editor: BaseEditor & ReactEditor & HistoryEditor) => {
56
+ export const editorToText = (
57
+ editor: BaseEditor & ReactEditor & HistoryEditor,
58
+ ) => {
56
59
  const flattened = nodeChildrenToTextComponents(editor, editor.children);
57
60
 
58
61
  const text = flattened.map((textComponent) => textComponent.text).join("\n");
@@ -1,4 +1,14 @@
1
- import { Editor, Node, Path, Range, Text, Element, BasePoint, BaseRange, Point } from "slate";
1
+ import {
2
+ Editor,
3
+ Node,
4
+ Path,
5
+ Range,
6
+ Text,
7
+ Element,
8
+ BasePoint,
9
+ BaseRange,
10
+ Point,
11
+ } from "slate";
2
12
  import { EditorAutocompleteState } from "../types/base/editor-autocomplete-state";
3
13
 
4
14
  export interface EditorTextState {
@@ -9,7 +19,9 @@ export interface EditorTextState {
9
19
  textAfterCursor: string;
10
20
  }
11
21
 
12
- export function getTextAroundCollapsedCursor(editor: Editor): EditorAutocompleteState | null {
22
+ export function getTextAroundCollapsedCursor(
23
+ editor: Editor,
24
+ ): EditorAutocompleteState | null {
13
25
  const { selection } = editor;
14
26
  if (!selection || !Range.isCollapsed(selection)) {
15
27
  return null;
@@ -13,7 +13,10 @@ export function clearAutocompletionsFromEditor(editor: CustomEditor) {
13
13
  try {
14
14
  Transforms.removeNodes(editor, { at: path });
15
15
  } catch (e) {
16
- console.log("CopilotTextarea.clearAutocompletionsFromEditor: error removing node", e);
16
+ console.log(
17
+ "CopilotTextarea.clearAutocompletionsFromEditor: error removing node",
18
+ e,
19
+ );
17
20
  }
18
21
  }
19
22
  }
@@ -3,7 +3,10 @@ import { HistoryEditor } from "slate-history";
3
3
 
4
4
  // Copy-pasted from `https://github.com/ianstormtaylor/slate/blob/main/packages/slate-history/src/with-history.ts`
5
5
  // With one exception: the `shouldSave` function is passed in as an argument to `withPartialHistory` instead of being hardcoded
6
- export type ShouldSaveToHistory = (op: Operation, prev: Operation | undefined) => boolean;
6
+ export type ShouldSaveToHistory = (
7
+ op: Operation,
8
+ prev: Operation | undefined,
9
+ ) => boolean;
7
10
 
8
11
  export const withPartialHistory = <T extends Editor>(
9
12
  editor: T,
@@ -66,7 +69,8 @@ export const withPartialHistory = <T extends Editor>(
66
69
  const { operations, history } = e;
67
70
  const { undos } = history;
68
71
  const lastBatch = undos[undos.length - 1];
69
- const lastOp = lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
72
+ const lastOp =
73
+ lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
70
74
  let save = HistoryEditor.isSaving(e);
71
75
  let merge = HistoryEditor.isMerging(e);
72
76
 
@@ -140,7 +144,10 @@ const shouldMerge = (op: Operation, prev: Operation | undefined): boolean => {
140
144
  return false;
141
145
  };
142
146
 
143
- export const defaultShouldSave = (op: Operation, prev: Operation | undefined): boolean => {
147
+ export const defaultShouldSave = (
148
+ op: Operation,
149
+ prev: Operation | undefined,
150
+ ): boolean => {
144
151
  if (op.type === "set_selection") {
145
152
  return false;
146
153
  }
@@ -8,7 +8,9 @@
8
8
  * @returns {ReadableStream<A>} - The flattened stream.
9
9
  */
10
10
 
11
- export function streamPromiseFlatten<A>(promise: Promise<ReadableStream<A>>): ReadableStream<A> {
11
+ export function streamPromiseFlatten<A>(
12
+ promise: Promise<ReadableStream<A>>,
13
+ ): ReadableStream<A> {
12
14
  return new ReadableStream<A>({
13
15
  async start(controller) {
14
16
  try {
package/src/lib/utils.ts CHANGED
@@ -5,7 +5,10 @@ export function cn(...inputs: ClassValue[]) {
5
5
  return twMerge(clsx(inputs));
6
6
  }
7
7
 
8
- export async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {
8
+ export async function fetcher<JSON = any>(
9
+ input: RequestInfo,
10
+ init?: RequestInit,
11
+ ): Promise<JSON> {
9
12
  const res = await fetch(input, init);
10
13
 
11
14
  if (!res.ok) {
@@ -34,7 +37,8 @@ export function formatDate(input: string | number | Date): string {
34
37
  }
35
38
 
36
39
  export const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>
37
- arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
40
+ arr1.length === arr2.length &&
41
+ arr1.every((value, index) => value === arr2[index]);
38
42
 
39
43
  export function nullableCompatibleEqualityCheck<T>(
40
44
  naiveEqualityCheck: (a: T, b: T) => boolean,
@@ -9,8 +9,9 @@ export interface SuggestionsApiConfigUserSpecified extends Partial<SuggestionsAp
9
9
  export interface InsertionsApiConfigUserSpecified extends Partial<InsertionsApiConfig> {}
10
10
 
11
11
  // Mostly mirrors a partial AutosuggestionsConfig, but with some fields MANDATORY.
12
- export interface AutosuggestionsConfigUserSpecified
13
- extends Partial<Omit<AutosuggestionsConfig, "chatApiConfigs" | "textareaPurpose">> {
12
+ export interface AutosuggestionsConfigUserSpecified extends Partial<
13
+ Omit<AutosuggestionsConfig, "chatApiConfigs" | "textareaPurpose">
14
+ > {
14
15
  textareaPurpose: string; // the user MUST specify textareaPurpose - it's not optional
15
16
  chatApiConfigs: {
16
17
  suggestionsApiConfig?: SuggestionsApiConfigUserSpecified;