[Query Copilot] Version 2 initial code (#1566)
* Query Copilot Sidecar initial commit * additional improvements with the Welcome pop * Additional implementation and messages for sidecar * introducing copilot version * Renaming from car to bar * Image names changed * fixing PR errors * additional changes related with the versions * Additional implementations and fixes * Removing unused interface * Additional styling changes and state management * Additional changes related with Sidebar --------- Co-authored-by: Predrag Klepic <v-prklepic@microsoft.com>
|
@ -1,3 +1,3 @@
|
||||||
<svg width="10" height="14" viewBox="0 0 10 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="12" height="14" viewBox="0 0 12 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M10 2.5C10 3.88071 7.76142 5 5 5C2.23858 5 0 3.88071 0 2.5C0 1.11929 2.23858 0 5 0C7.76142 0 10 1.11929 10 2.5ZM0 11.5V4.487C1.057 5.413 2.864 6 5 6C7.136 6 8.943 5.413 10 4.487V11.5C10 12.925 7.851 14 5 14C2.149 14 0 12.925 0 11.5Z" fill="#0078D4"/>
|
<path d="M10 2.5C10 3.88071 7.76142 5 5 5C2.23858 5 0 3.88071 0 2.5C0 1.11929 2.23858 0 5 0C7.76142 0 10 1.11929 10 2.5ZM0 11.5V4.487C1.057 5.413 2.864 6 5 6C7.136 6 8.943 5.413 10 4.487V11.5C10 12.925 7.851 14 5 14C2.149 14 0 12.925 0 11.5Z" fill="#0078D4"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 363 B After Width: | Height: | Size: 363 B |
|
@ -1,3 +1,3 @@
|
||||||
<svg width="13" height="17" viewBox="0 0 13 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="12" height="14" viewBox="0 0 12 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M4.21207 0C3.73772 0 3.32085 0.314446 3.19054 0.770537L0.940937 8.64415C0.747029 9.32283 1.25663 9.99841 1.96246 9.99841H3.22974L2.06002 14.6773C1.79611 15.7329 3.10089 16.4551 3.85526 15.6726L12.5318 6.81506L12.5354 6.81137C13.1762 6.1436 12.7152 5 11.7688 5H9.20509L10.4665 1.40582L10.469 1.39836C10.6983 0.710426 10.1863 0 9.46114 0H4.21207Z" fill="#0078D4"/>
|
<path d="M4.21207 0C3.73772 0 3.32085 0.314446 3.19054 0.770537L0.940937 8.64415C0.747029 9.32283 1.25663 9.99841 1.96246 9.99841H3.22974L2.06002 14.6773C1.79611 15.7329 3.10089 16.4551 3.85526 15.6726L12.5318 6.81506L12.5354 6.81137C13.1762 6.1436 12.7152 5 11.7688 5H9.20509L10.4665 1.40582L10.469 1.39836C10.6983 0.710426 10.1863 0 9.46114 0H4.21207Z" fill="#0078D4"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 475 B |
|
@ -0,0 +1,34 @@
|
||||||
|
<svg width="20" height="22" viewBox="0 0 20 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M7.79997 1.36139L9.59997 1.54445V6.72957L6.71997 7.39864L5.75998 8.71588V10.7866C5.75998 12.178 6.51265 13.4605 7.72739 14.139L10.4421 15.6554L5.75997 18.1318L3.81352 18.4092L1.96738 17.378C0.75264 16.6995 -3.05176e-05 15.417 -3.05176e-05 14.0256V7.97332C-3.05176e-05 6.58155 0.753043 5.29871 1.9683 4.62034L7.3904 1.59367L7.38722 1.59591L7.79997 1.36139Z" fill="url(#paint0_radial_1157_162756)"/>
|
||||||
|
<path d="M7.79997 1.36139L9.59997 1.54445V6.72957L6.71997 7.39864L5.75998 8.71588V10.7866C5.75998 12.178 6.51265 13.4605 7.72739 14.139L10.4421 15.6554L5.75997 18.1318L3.81352 18.4092L1.96738 17.378C0.75264 16.6995 -3.05176e-05 15.417 -3.05176e-05 14.0256V7.97332C-3.05176e-05 6.58155 0.753043 5.29871 1.9683 4.62034L7.3904 1.59367L7.38722 1.59591L7.79997 1.36139Z" fill="url(#paint1_linear_1157_162756)"/>
|
||||||
|
<path d="M13.4397 8.11841L18.2397 10.9984L19.1997 11.9584V14.025C19.1997 15.4164 18.447 16.6989 17.2323 17.3774L11.4723 20.5948C10.3085 21.2448 8.89088 21.2448 7.72711 20.5948L1.96711 17.3774C1.85515 17.3149 1.74713 17.2472 1.64325 17.1748L1.96708 17.3557C3.13085 18.0057 4.54849 18.0057 5.71226 17.3557L11.4723 14.1383C12.687 13.4598 13.4397 12.1773 13.4397 10.7859V8.11841Z" fill="url(#paint2_radial_1157_162756)"/>
|
||||||
|
<path d="M13.4397 8.11841L18.2397 10.9984L19.1997 11.9584V14.025C19.1997 15.4164 18.447 16.6989 17.2323 17.3774L11.4723 20.5948C10.3085 21.2448 8.89088 21.2448 7.72711 20.5948L1.96711 17.3774C1.85515 17.3149 1.74713 17.2472 1.64325 17.1748L1.96708 17.3557C3.13085 18.0057 4.54849 18.0057 5.71226 17.3557L11.4723 14.1383C12.687 13.4598 13.4397 12.1773 13.4397 10.7859V8.11841Z" fill="url(#paint3_linear_1157_162756)"/>
|
||||||
|
<path d="M17.2316 4.62014L11.4716 1.40484C10.3083 0.755475 8.89151 0.755475 7.72821 1.40484L7.38921 1.59407C6.37448 2.30824 5.75989 3.47665 5.75989 4.73397V8.74548L7.72821 7.64674C8.89151 6.99738 10.3083 6.99738 11.4716 7.64674L17.2316 10.862C18.4192 11.525 19.1654 12.7652 19.1987 14.1202C19.1995 14.0886 19.1999 14.057 19.1999 14.0254V7.97311C19.1999 6.58134 18.4468 5.29851 17.2316 4.62014Z" fill="url(#paint4_radial_1157_162756)"/>
|
||||||
|
<path d="M17.2316 4.62014L11.4716 1.40484C10.3083 0.755475 8.89151 0.755475 7.72821 1.40484L7.38921 1.59407C6.37448 2.30824 5.75989 3.47665 5.75989 4.73397V8.74548L7.72821 7.64674C8.89151 6.99738 10.3083 6.99738 11.4716 7.64674L17.2316 10.862C18.4192 11.525 19.1654 12.7652 19.1987 14.1202C19.1995 14.0886 19.1999 14.057 19.1999 14.0254V7.97311C19.1999 6.58134 18.4468 5.29851 17.2316 4.62014Z" fill="url(#paint5_linear_1157_162756)"/>
|
||||||
|
<defs>
|
||||||
|
<radialGradient id="paint0_radial_1157_162756" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(8.1032 6.84805) rotate(112.544) scale(14.0711 11.584)">
|
||||||
|
<stop offset="0.206732" stop-color="#4995D0"/>
|
||||||
|
<stop offset="0.875628" stop-color="#0078D4"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="paint1_linear_1157_162756" x1="6.63744" y1="16.8883" x2="5.87214" y2="15.464" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0.9999" stop-color="#0078D4"/>
|
||||||
|
<stop offset="1" stop-color="#0078D4" stop-opacity="0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient id="paint2_radial_1157_162756" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(4.13968 15.6306) rotate(-3.9995) scale(14.7718 9.27561)">
|
||||||
|
<stop offset="0.140029" stop-color="#80C8FF"/>
|
||||||
|
<stop offset="0.952721" stop-color="#0078D4"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="paint3_linear_1157_162756" x1="16.1362" y1="10.2483" x2="15.3298" y2="11.6531" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0.9999" stop-color="#3F8AC3"/>
|
||||||
|
<stop offset="1" stop-color="#8C66BA" stop-opacity="0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient id="paint4_radial_1157_162756" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(15.9793 10.7505) rotate(-138.33) scale(13.6809 7.80282)">
|
||||||
|
<stop stop-color="#7BC6FF"/>
|
||||||
|
<stop offset="0.839255" stop-color="#0078D4"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="paint5_linear_1157_162756" x1="5.75989" y1="6.14584" x2="7.32799" y2="6.14584" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0.9999" stop-color="#0078D4"/>
|
||||||
|
<stop offset="1" stop-color="#436DCD" stop-opacity="0"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.2 KiB |
|
@ -0,0 +1,29 @@
|
||||||
|
<svg width="121" height="94" viewBox="0 0 121 94" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path opacity="0.3" d="M3.25029 80.7474H97.1699C97.8805 80.7474 98.5648 80.471 99.078 79.9578C99.5913 79.4446 99.8676 78.7603 99.8676 78.0497V13.8575C99.8676 12.3704 98.3148 11.0018 96.2224 11.0018L4.53992 12.3968C4.18461 12.3968 3.84247 12.4626 3.51348 12.5942C3.18449 12.7389 2.89498 12.9231 2.64495 13.1863C2.39492 13.4364 2.19752 13.7259 2.05277 14.0549C1.90801 14.3838 1.85538 14.7392 1.85538 15.0813L0.552582 78.076C0.552582 78.7866 0.82893 79.4709 1.34215 79.971C1.85537 80.471 2.53967 80.7474 3.25029 80.7474Z" fill="#1F1D20"/>
|
||||||
|
<path d="M96.9332 9.80411H2.67139C1.19752 9.80411 0 11.0016 0 12.4755V76.7993C0 78.2732 1.19752 79.4707 2.67139 79.4707H96.9463C98.4202 79.4707 99.6177 78.2732 99.6177 76.7993V12.4755C99.6045 11.0016 98.407 9.80411 96.9332 9.80411Z" fill="url(#paint0_linear_1157_163007)"/>
|
||||||
|
<path d="M95.6963 13.7121H50.1379V74.904H95.6963V13.7121Z" fill="white"/>
|
||||||
|
<path d="M50.7829 13.7121H5.22461V74.904H50.7829V13.7121Z" fill="#CDCDD0"/>
|
||||||
|
<path d="M14.3309 0V60.6918C14.3309 60.6918 26.4903 59.4811 36.3468 64.4291C46.2165 69.3771 50.7829 74.8514 50.7829 74.8514V14.1465C50.7829 14.1465 45.0979 6.90876 36.3468 4.23737C29.2275 2.05289 14.3309 0 14.3309 0Z" fill="#EAEAEA"/>
|
||||||
|
<path d="M59.1387 42.9135L56.2699 41.6633L53.388 42.9135V9.80411H59.1387V42.9135Z" fill="url(#paint1_linear_1157_163007)"/>
|
||||||
|
<path opacity="0.15" d="M86.7212 25.6883H66.7713C65.9028 25.6883 65.2053 26.3989 65.2053 27.2543C65.2053 28.1228 65.9159 28.8202 66.7713 28.8202H86.7212C87.5897 28.8202 88.2872 28.1096 88.2872 27.2543C88.3003 26.3857 87.5897 25.6883 86.7212 25.6883Z" fill="#1F1D20"/>
|
||||||
|
<path opacity="0.15" d="M86.7212 32.5045H66.7713C65.9028 32.5045 65.2053 33.2151 65.2053 34.0705C65.2053 34.939 65.9159 35.6365 66.7713 35.6365H86.7212C87.5897 35.6365 88.2872 34.9258 88.2872 34.0705C88.3003 33.2019 87.5897 32.5045 86.7212 32.5045Z" fill="#1F1D20"/>
|
||||||
|
<path opacity="0.15" fill-rule="evenodd" clip-rule="evenodd" d="M66.7715 39.3336H86.695C87.5636 39.3336 88.261 40.0442 88.261 40.8995C88.261 41.7681 87.5504 42.4655 86.695 42.4655H66.7715C65.903 42.4655 65.2055 41.7549 65.2055 40.8995C65.1923 40.0442 65.8898 39.3336 66.7715 39.3336Z" fill="#1F1D20"/>
|
||||||
|
<path d="M86.7212 25.1614H66.7713C65.9028 25.1614 65.2053 25.872 65.2053 26.7273C65.2053 27.5959 65.9159 28.2933 66.7713 28.2933H86.7212C87.5897 28.2933 88.2872 27.5827 88.2872 26.7273C88.3003 25.8588 87.5897 25.1614 86.7212 25.1614Z" fill="#50E6FF"/>
|
||||||
|
<path d="M86.7212 31.9917H66.7713C65.9028 31.9917 65.2053 32.7023 65.2053 33.5577C65.2053 34.4262 65.9159 35.1237 66.7713 35.1237H86.7212C87.5897 35.1237 88.2872 34.4131 88.2872 33.5577C88.3003 32.6892 87.5897 31.9917 86.7212 31.9917Z" fill="#32B0E7"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M66.7715 38.808H86.695C87.5636 38.808 88.261 39.5186 88.261 40.3739C88.261 41.2425 87.5504 41.9399 86.695 41.9399H66.7715C65.903 41.9531 65.2055 41.2293 65.2055 40.3739C65.1923 39.5186 65.8898 38.808 66.7715 38.808Z" fill="#185A97"/>
|
||||||
|
<path opacity="0.2" d="M120.295 60.2875H80.476V85.9653C80.476 87.0514 81.3515 87.9269 82.4375 87.9269H86.6156V94L92.733 87.9269H118.333C119.419 87.9269 120.295 87.0514 120.295 85.9653V60.2875Z" fill="#1F1D21"/>
|
||||||
|
<path d="M118.965 58.6804H81.8058C81.0744 58.6804 80.476 59.2788 80.476 60.0103V84.9898C80.476 85.7213 81.0744 86.3197 81.8058 86.3197H86.6156V92.3928L92.733 86.3197H118.965C119.696 86.3197 120.295 85.7213 120.295 84.9898V60.0103C120.295 59.2788 119.696 58.6804 118.965 58.6804Z" fill="#49C8EF"/>
|
||||||
|
<path d="M106.564 67.8017H94.1846C93.697 67.8017 93.298 68.2006 93.298 68.6883C93.298 69.1759 93.697 69.5748 94.1846 69.5748H106.564C107.051 69.5748 107.45 69.1759 107.45 68.6883C107.45 68.2006 107.051 67.8017 106.564 67.8017Z" fill="#C3F1FF"/>
|
||||||
|
<path d="M106.564 71.6913H94.1846C93.697 71.6913 93.298 72.0903 93.298 72.5779C93.298 73.0655 93.697 73.4645 94.1846 73.4645H106.564C107.051 73.4645 107.45 73.0655 107.45 72.5779C107.45 72.1014 107.051 71.6913 106.564 71.6913Z" fill="#C3F1FF"/>
|
||||||
|
<path d="M106.564 75.6026H94.1846C93.697 75.6026 93.298 76.0016 93.298 76.4892C93.298 76.9768 93.697 77.3758 94.1846 77.3758H106.564C107.051 77.3758 107.45 76.9768 107.45 76.4892C107.45 75.9905 107.051 75.6026 106.564 75.6026Z" fill="#C3F1FF"/>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="paint0_linear_1157_163007" x1="49.8133" y1="14.2868" x2="49.8133" y2="85.0398" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#007ED8"/>
|
||||||
|
<stop offset="0.7065" stop-color="#002D4C"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="paint1_linear_1157_163007" x1="36.5785" y1="-9.69372" x2="104.813" y2="115.29" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#007ED8"/>
|
||||||
|
<stop offset="0.7065" stop-color="#002D4C"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.6 KiB |
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="20" height="22" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M12.5849 1.28273C11.0125 0.262814 8.98746 0.262813 7.41509 1.28273L2.16509 4.68813C0.8149 5.56393 0 7.06384 0 8.6732V13.3268C0 14.9361 0.814898 16.4361 2.16509 17.3119L7.41509 20.7173C8.98746 21.7372 11.0125 21.7372 12.5849 20.7173L17.8349 17.3119C19.1851 16.4361 20 14.9361 20 13.3268V8.6732C20 7.06384 19.1851 5.56393 17.8349 4.68813L12.5849 1.28273ZM9.50097 2.05627C10.2759 1.93601 11.0848 2.09764 11.7686 2.54117L17.0186 5.94657C17.9424 6.54581 18.5 7.57205 18.5 8.6732V11.3955C18.287 11.1926 18.0465 11.0117 17.7802 10.8585L11.8647 7.4571C10.7104 6.79343 9.29086 6.79152 8.13486 7.45209L7.5 7.81487V4.41942C7.5 3.54181 8.01028 2.74428 8.80712 2.37651L9.50097 2.05627ZM17.8644 15.2257L17.7932 15.3503C17.5776 15.6214 17.3172 15.8597 17.0186 16.0534L11.7686 19.4588C10.6928 20.1567 9.30721 20.1567 8.23138 19.4588L5.86807 17.9259C6.11557 17.8361 6.35595 17.7193 6.58487 17.5754L12.2457 14.0172C13.3374 13.3309 14 12.1318 14 10.8423V10.4152L17.0324 12.1589C18.1077 12.7771 18.4798 14.1489 17.8644 15.2257ZM12.5 9.55272V10.8423C12.5 11.616 12.1025 12.3354 11.4474 12.7472L10.0303 13.6379L8.57078 12.7398C7.90535 12.3303 7.5 11.6049 7.5 10.8235V9.54249L8.87907 8.75445C9.57267 8.35811 10.4244 8.35926 11.1169 8.75746L12.5 9.55272ZM8.61445 14.5279L5.78662 16.3054C5.02045 16.787 4.04031 16.7627 3.29894 16.2437L2.5521 15.721C1.88767 15.1111 1.5 14.245 1.5 13.3268V8.6732C1.5 7.57205 2.05756 6.5458 2.98138 5.94657L6.0268 3.97116C6.00907 4.11873 6 4.26836 6 4.41942V10.8235C6 12.1258 6.67558 13.3348 7.78463 14.0173L8.61445 14.5279Z" fill="#0078D4"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
|
@ -1,3 +1,4 @@
|
||||||
|
import { useDatabases } from "Explorer/useDatabases";
|
||||||
import { Action } from "Shared/Telemetry/TelemetryConstants";
|
import { Action } from "Shared/Telemetry/TelemetryConstants";
|
||||||
import { traceOpen } from "Shared/Telemetry/TelemetryProcessor";
|
import { traceOpen } from "Shared/Telemetry/TelemetryProcessor";
|
||||||
import { ReactTabKind, useTabs } from "hooks/useTabs";
|
import { ReactTabKind, useTabs } from "hooks/useTabs";
|
||||||
|
@ -146,6 +147,8 @@ export const createCollectionContextMenuButton = (
|
||||||
export const createSampleCollectionContextMenuButton = (): TreeNodeMenuItem[] => {
|
export const createSampleCollectionContextMenuButton = (): TreeNodeMenuItem[] => {
|
||||||
const items: TreeNodeMenuItem[] = [];
|
const items: TreeNodeMenuItem[] = [];
|
||||||
if (userContext.apiType === "SQL") {
|
if (userContext.apiType === "SQL") {
|
||||||
|
const copilotVersion = userContext.features.copilotVersion;
|
||||||
|
if (copilotVersion === "v1.0") {
|
||||||
items.push({
|
items.push({
|
||||||
iconSrc: AddSqlQueryIcon,
|
iconSrc: AddSqlQueryIcon,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
@ -154,6 +157,14 @@ export const createSampleCollectionContextMenuButton = (): TreeNodeMenuItem[] =>
|
||||||
},
|
},
|
||||||
label: "New SQL Query",
|
label: "New SQL Query",
|
||||||
});
|
});
|
||||||
|
} else if (copilotVersion === "v2.0") {
|
||||||
|
const sampleCollection = useDatabases.getState().sampleDataResourceTokenCollection;
|
||||||
|
items.push({
|
||||||
|
iconSrc: AddSqlQueryIcon,
|
||||||
|
onClick: () => sampleCollection && sampleCollection.onNewQueryClick(sampleCollection, undefined),
|
||||||
|
label: "New SQL Query",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
|
|
@ -0,0 +1,243 @@
|
||||||
|
import { IButtonStyles, IconButton, Image, Stack, Text, TextField } from "@fluentui/react";
|
||||||
|
import { SamplePrompts, SamplePromptsProps } from "Explorer/QueryCopilot/SamplePrompts/SamplePrompts";
|
||||||
|
import { WelcomeSidebarPopup } from "Explorer/QueryCopilot/Sidebar/WelcomeSidebarPopup";
|
||||||
|
import { useQueryCopilot } from "hooks/useQueryCopilot";
|
||||||
|
import React from "react";
|
||||||
|
import CopilotIcon from "../../../../images/CopilotSidebarLogo.svg";
|
||||||
|
import HintIcon from "../../../../images/Hint.svg";
|
||||||
|
|
||||||
|
const sampleChatMessages: string[] = [
|
||||||
|
"Write a query to return last 10 records in the database",
|
||||||
|
'Write a query to return all records in this table created in the last thirty days which also have the record owner as "Contoso"',
|
||||||
|
];
|
||||||
|
|
||||||
|
const promptStyles: IButtonStyles = {
|
||||||
|
root: { border: "5px", selectors: { ":hover": { outline: "1px dashed #605e5c" } } },
|
||||||
|
label: { fontWeight: 400, textAlign: "left", paddingLeft: 8 },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const QueryCopilotSidebar: React.FC = (): JSX.Element => {
|
||||||
|
const {
|
||||||
|
setWasCopilotUsed,
|
||||||
|
showCopilotSidebar,
|
||||||
|
setShowCopilotSidebar,
|
||||||
|
userPrompt,
|
||||||
|
setUserPrompt,
|
||||||
|
chatMessages,
|
||||||
|
setChatMessages,
|
||||||
|
showWelcomeSidebar,
|
||||||
|
isSamplePromptsOpen,
|
||||||
|
setIsSamplePromptsOpen,
|
||||||
|
} = useQueryCopilot();
|
||||||
|
|
||||||
|
const sampleProps: SamplePromptsProps = {
|
||||||
|
isSamplePromptsOpen: isSamplePromptsOpen,
|
||||||
|
setIsSamplePromptsOpen: setIsSamplePromptsOpen,
|
||||||
|
setTextBox: setUserPrompt,
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSendMessage = () => {
|
||||||
|
if (userPrompt.trim() !== "") {
|
||||||
|
setChatMessages([...chatMessages, userPrompt]);
|
||||||
|
setUserPrompt("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleInputChange = (value: string) => {
|
||||||
|
setUserPrompt(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEnterKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
if (event.key === "Enter" && !event.shiftKey) {
|
||||||
|
event.preventDefault();
|
||||||
|
handleSendMessage();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (showCopilotSidebar) {
|
||||||
|
setWasCopilotUsed(true);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack style={{ width: "100%", height: "100%", backgroundColor: "#FAFAFA", overflow: "auto" }}>
|
||||||
|
<Stack style={{ margin: "15px 0px 0px 0px", padding: "5px" }}>
|
||||||
|
<Stack style={{ display: "flex", justifyContent: "space-between" }} horizontal verticalAlign="center">
|
||||||
|
<Stack horizontal verticalAlign="center">
|
||||||
|
<Image src={CopilotIcon} />
|
||||||
|
<Text style={{ marginLeft: "5px", fontWeight: "bold" }}>Copilot</Text>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
background: "#f0f0f0",
|
||||||
|
fontSize: "10px",
|
||||||
|
padding: "2px 4px",
|
||||||
|
marginLeft: "5px",
|
||||||
|
borderRadius: "8px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Preview
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
<IconButton
|
||||||
|
onClick={() => setShowCopilotSidebar(false)}
|
||||||
|
iconProps={{ iconName: "Cancel" }}
|
||||||
|
title="Exit"
|
||||||
|
ariaLabel="Exit"
|
||||||
|
style={{ color: "#424242", verticalAlign: "middle" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
{showWelcomeSidebar ? (
|
||||||
|
<Stack.Item styles={{ root: { textAlign: "center", verticalAlign: "middle" } }}>
|
||||||
|
<WelcomeSidebarPopup />
|
||||||
|
</Stack.Item>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Stack horizontalAlign="center" style={{ color: "#707070" }} tokens={{ padding: 8, childrenGap: 8 }}>
|
||||||
|
{new Date().toLocaleDateString("en-US", {
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
})}{" "}
|
||||||
|
{new Date().toLocaleTimeString("en-US", {
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
hour12: true,
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
<Stack style={{ flexGrow: 1, display: "flex", flexDirection: "column" }}>
|
||||||
|
<div style={{ flexGrow: 1, overflowY: "auto" }}>
|
||||||
|
<Stack
|
||||||
|
tokens={{ padding: 16, childrenGap: 12 }}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "white",
|
||||||
|
margin: "5px 10px",
|
||||||
|
borderRadius: "8px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text variant="medium">
|
||||||
|
Hello, I am Cosmos Db's copilot assistant. I can help you do the following things:
|
||||||
|
</Text>
|
||||||
|
<Stack tokens={{ childrenGap: 8 }}>
|
||||||
|
<Stack horizontal style={{ marginLeft: "15px" }} tokens={{ childrenGap: 8 }}>
|
||||||
|
<Text style={{ fontSize: "16px", lineHeight: "16px", verticalAlign: "middle" }}>•</Text>
|
||||||
|
<Text style={{ verticalAlign: "middle" }}>Generate queries based upon prompt you suggest</Text>
|
||||||
|
</Stack>
|
||||||
|
<Stack horizontal style={{ marginLeft: "15px" }} tokens={{ childrenGap: 8 }}>
|
||||||
|
<Text style={{ fontSize: "16px", lineHeight: "16px", verticalAlign: "middle" }}>•</Text>
|
||||||
|
<Text style={{ verticalAlign: "middle" }}>
|
||||||
|
Explain and provide alternate queries for a query suggested by you
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
<Stack horizontal style={{ marginLeft: "15px" }} tokens={{ childrenGap: 8 }}>
|
||||||
|
<Text style={{ fontSize: "16px", lineHeight: "16px", verticalAlign: "middle" }}>•</Text>
|
||||||
|
<Text style={{ verticalAlign: "middle" }}>Help answer questions about Cosmos DB</Text>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
<Text variant="medium">
|
||||||
|
To get started, ask me a question or use one of the sample prompts to generate a query. AI-generated
|
||||||
|
content may be incorrect.
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
{chatMessages.map((message, index) => (
|
||||||
|
<Stack
|
||||||
|
key={index}
|
||||||
|
horizontalAlign="center"
|
||||||
|
tokens={{ padding: 8, childrenGap: 8 }}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#E0E7FF",
|
||||||
|
borderRadius: "8px",
|
||||||
|
margin: "5px 10px",
|
||||||
|
textAlign: "start",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{message}
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{chatMessages.length === 0 && (
|
||||||
|
<Stack
|
||||||
|
horizontalAlign="end"
|
||||||
|
verticalAlign="end"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
padding: "10px",
|
||||||
|
margin: "10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
onClick={() => handleInputChange(sampleChatMessages[0])}
|
||||||
|
style={{
|
||||||
|
cursor: "pointer",
|
||||||
|
border: "1.5px solid #B0BEFF",
|
||||||
|
width: "100%",
|
||||||
|
padding: "2px",
|
||||||
|
borderRadius: "4px",
|
||||||
|
marginBottom: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{sampleChatMessages[0]}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
onClick={() => handleInputChange(sampleChatMessages[1])}
|
||||||
|
style={{
|
||||||
|
cursor: "pointer",
|
||||||
|
border: "1.5px solid #B0BEFF",
|
||||||
|
width: "100%",
|
||||||
|
padding: "2px",
|
||||||
|
borderRadius: "4px",
|
||||||
|
marginBottom: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{sampleChatMessages[1]}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
horizontal
|
||||||
|
horizontalAlign="end"
|
||||||
|
verticalAlign="end"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
borderRadius: "20px",
|
||||||
|
background: "white",
|
||||||
|
padding: "5px",
|
||||||
|
margin: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
<Image src={HintIcon} styles={promptStyles} onClick={() => setIsSamplePromptsOpen(true)} />
|
||||||
|
<SamplePrompts sampleProps={sampleProps} />
|
||||||
|
</Stack>
|
||||||
|
<TextField
|
||||||
|
placeholder="Write your own prompt or ask a question"
|
||||||
|
value={userPrompt}
|
||||||
|
onChange={(_, newValue) => handleInputChange(newValue)}
|
||||||
|
onKeyDown={handleEnterKeyPress}
|
||||||
|
multiline
|
||||||
|
resizable={false}
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
width: "100%",
|
||||||
|
height: "80px",
|
||||||
|
borderRadius: "20px",
|
||||||
|
padding: "8px",
|
||||||
|
border: "none",
|
||||||
|
outline: "none",
|
||||||
|
marginLeft: "10px",
|
||||||
|
},
|
||||||
|
fieldGroup: { border: "none" },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<IconButton iconProps={{ iconName: "Send" }} onClick={handleSendMessage} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,127 @@
|
||||||
|
import { Image, Link, PrimaryButton, Stack, Text } from "@fluentui/react";
|
||||||
|
import { useQueryCopilot } from "hooks/useQueryCopilot";
|
||||||
|
import React from "react";
|
||||||
|
import Database from "../../../../images/CopilotDatabase.svg";
|
||||||
|
import Flash from "../../../../images/CopilotFlash.svg";
|
||||||
|
import CopilotSidebarWelcomeIllustration from "../../../../images/CopilotSidebarWelcomeIllustration.svg";
|
||||||
|
import Thumb from "../../../../images/CopilotThumb.svg";
|
||||||
|
|
||||||
|
export const WelcomeSidebarPopup: React.FC = (): JSX.Element => {
|
||||||
|
const { setShowWelcomeSidebar } = useQueryCopilot();
|
||||||
|
|
||||||
|
const hideModal = () => {
|
||||||
|
setShowWelcomeSidebar(false);
|
||||||
|
window.localStorage.setItem("showWelcomeSidebar", "false");
|
||||||
|
};
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const showWelcomeSidebar = window.localStorage.getItem("showWelcomeSidebar");
|
||||||
|
setShowWelcomeSidebar(showWelcomeSidebar && showWelcomeSidebar === "false" ? false : true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
overflow: "auto",
|
||||||
|
backgroundColor: "#FAFAFA",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
margin: "20px 10px",
|
||||||
|
padding: "20px",
|
||||||
|
maxHeight: "100%",
|
||||||
|
boxSizing: "border-box",
|
||||||
|
borderRadius: "20px",
|
||||||
|
backgroundColor: "white",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack horizontalAlign="center" verticalAlign="center">
|
||||||
|
<Image src={CopilotSidebarWelcomeIllustration} />
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Stack>
|
||||||
|
<Stack.Item align="center" style={{ marginBottom: "10px" }}>
|
||||||
|
<Text className="title bold">Welcome to Copilot in CosmosDB</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item style={{ marginBottom: "15px" }}>
|
||||||
|
<Stack>
|
||||||
|
<Stack horizontal>
|
||||||
|
<Stack.Item align="start">
|
||||||
|
<Image src={Flash} />
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item align="center" style={{ marginLeft: "10px" }}>
|
||||||
|
<Text style={{ fontWeight: 600 }}>
|
||||||
|
Let copilot do the work for you
|
||||||
|
<br />
|
||||||
|
</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
<Stack.Item style={{ textAlign: "start", marginLeft: "25px" }}>
|
||||||
|
<Text>
|
||||||
|
Ask Copilot to generate a query by describing the query in your words.
|
||||||
|
<br />
|
||||||
|
<Link href="http://aka.ms/cdb-copilot-learn-more">Learn more</Link>
|
||||||
|
</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item style={{ marginBottom: "15px" }}>
|
||||||
|
<Stack>
|
||||||
|
<Stack horizontal>
|
||||||
|
<Stack.Item align="start">
|
||||||
|
<Image src={Thumb} />
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item align="center" style={{ marginLeft: "10px" }}>
|
||||||
|
<Text style={{ fontWeight: 600 }}>
|
||||||
|
Use your judgement
|
||||||
|
<br />
|
||||||
|
</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
<Stack.Item style={{ textAlign: "start", marginLeft: "25px" }}>
|
||||||
|
<Text>
|
||||||
|
AI-generated content can have mistakes. Make sure it’s accurate and appropriate before using it.
|
||||||
|
<br />
|
||||||
|
<Link href="http://aka.ms/cdb-copilot-preview-terms">Read preview terms</Link>
|
||||||
|
</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item style={{ marginBottom: "15px" }}>
|
||||||
|
<Stack>
|
||||||
|
<Stack horizontal>
|
||||||
|
<Stack.Item align="start">
|
||||||
|
<Image src={Database} />
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item align="center" style={{ marginLeft: "10px" }}>
|
||||||
|
<Text style={{ fontWeight: 600 }}>
|
||||||
|
Copilot currently works only a sample database
|
||||||
|
<br />
|
||||||
|
</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
<Stack.Item style={{ textAlign: "start", marginLeft: "25px" }}>
|
||||||
|
<Text>
|
||||||
|
Copilot is setup on a sample database we have configured for you at no cost
|
||||||
|
<br />
|
||||||
|
<Link href="http://aka.ms/cdb-copilot-learn-more">Learn more</Link>
|
||||||
|
</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Stack>
|
||||||
|
<Stack.Item align="center">
|
||||||
|
<PrimaryButton style={{ width: "224px", height: "32px" }} onClick={hideModal}>
|
||||||
|
Get Started
|
||||||
|
</PrimaryButton>
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
</div>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
|
@ -148,7 +148,13 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
||||||
"Copilot is your AI buddy that helps you write Azure Cosmos DB queries like a pro. Try it using our sample data set now!"
|
"Copilot is your AI buddy that helps you write Azure Cosmos DB queries like a pro. Try it using our sample data set now!"
|
||||||
}
|
}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
const copilotVersion = userContext.features.copilotVersion;
|
||||||
|
if (copilotVersion === "v1.0") {
|
||||||
useTabs.getState().openAndActivateReactTab(ReactTabKind.QueryCopilot);
|
useTabs.getState().openAndActivateReactTab(ReactTabKind.QueryCopilot);
|
||||||
|
} else if (copilotVersion === "v2.0") {
|
||||||
|
const sampleCollection = useDatabases.getState().sampleDataResourceTokenCollection;
|
||||||
|
sampleCollection.onNewQueryClick(sampleCollection, undefined);
|
||||||
|
}
|
||||||
traceOpen(Action.OpenQueryCopilotFromSplashScreen, { apiType: userContext.apiType });
|
traceOpen(Action.OpenQueryCopilotFromSplashScreen, { apiType: userContext.apiType });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
import { FeedOptions } from "@azure/cosmos";
|
import { FeedOptions } from "@azure/cosmos";
|
||||||
|
import { QueryCopilotSidebar } from "Explorer/QueryCopilot/Sidebar/QueryCopilotSidebar";
|
||||||
import { QueryResultSection } from "Explorer/Tabs/QueryTab/QueryResultSection";
|
import { QueryResultSection } from "Explorer/Tabs/QueryTab/QueryResultSection";
|
||||||
|
import { useDatabases } from "Explorer/useDatabases";
|
||||||
|
import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot";
|
||||||
import React, { Fragment } from "react";
|
import React, { Fragment } from "react";
|
||||||
import SplitterLayout from "react-splitter-layout";
|
import SplitterLayout from "react-splitter-layout";
|
||||||
import "react-splitter-layout/lib/index.css";
|
import "react-splitter-layout/lib/index.css";
|
||||||
|
import LaunchCopilot from "../../../../images/CopilotTabIcon.svg";
|
||||||
import ExecuteQueryIcon from "../../../../images/ExecuteQuery.svg";
|
import ExecuteQueryIcon from "../../../../images/ExecuteQuery.svg";
|
||||||
import SaveQueryIcon from "../../../../images/save-cosmos.svg";
|
import SaveQueryIcon from "../../../../images/save-cosmos.svg";
|
||||||
import { NormalizedEventKey } from "../../../Common/Constants";
|
import { NormalizedEventKey } from "../../../Common/Constants";
|
||||||
|
@ -72,12 +76,15 @@ interface IQueryTabStates {
|
||||||
error: string;
|
error: string;
|
||||||
isExecutionError: boolean;
|
isExecutionError: boolean;
|
||||||
isExecuting: boolean;
|
isExecuting: boolean;
|
||||||
|
showCopilotSidebar: boolean;
|
||||||
|
isCopilotTabActive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class QueryTabComponent extends React.Component<IQueryTabComponentProps, IQueryTabStates> {
|
export default class QueryTabComponent extends React.Component<IQueryTabComponentProps, IQueryTabStates> {
|
||||||
public queryEditorId: string;
|
public queryEditorId: string;
|
||||||
public executeQueryButton: Button;
|
public executeQueryButton: Button;
|
||||||
public saveQueryButton: Button;
|
public saveQueryButton: Button;
|
||||||
|
public launchCopilotButton: Button;
|
||||||
public splitterId: string;
|
public splitterId: string;
|
||||||
public isPreferredApiMongoDB: boolean;
|
public isPreferredApiMongoDB: boolean;
|
||||||
public isCloseClicked: boolean;
|
public isCloseClicked: boolean;
|
||||||
|
@ -94,6 +101,9 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
error: "",
|
error: "",
|
||||||
isExecutionError: this.props.isExecutionError,
|
isExecutionError: this.props.isExecutionError,
|
||||||
isExecuting: false,
|
isExecuting: false,
|
||||||
|
showCopilotSidebar: useQueryCopilot.getState().showCopilotSidebar,
|
||||||
|
isCopilotTabActive:
|
||||||
|
useDatabases.getState().sampleDataResourceTokenCollection.databaseId === this.props.collection.databaseId,
|
||||||
};
|
};
|
||||||
this.isCloseClicked = false;
|
this.isCloseClicked = false;
|
||||||
this.splitterId = this.props.tabId + "_splitter";
|
this.splitterId = this.props.tabId + "_splitter";
|
||||||
|
@ -111,6 +121,11 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
visible: isSaveQueryBtnEnabled,
|
visible: isSaveQueryBtnEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.launchCopilotButton = {
|
||||||
|
enabled: userContext.apiType === "SQL" && true,
|
||||||
|
visible: userContext.apiType === "SQL" && true,
|
||||||
|
};
|
||||||
|
|
||||||
this.props.tabsBaseInstance.updateNavbarWithTabsButtons();
|
this.props.tabsBaseInstance.updateNavbarWithTabsButtons();
|
||||||
props.onTabAccessor({
|
props.onTabAccessor({
|
||||||
onTabClickEvent: this.onTabClick.bind(this),
|
onTabClickEvent: this.onTabClick.bind(this),
|
||||||
|
@ -121,6 +136,9 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
|
|
||||||
public onCloseClick(isClicked: boolean): void {
|
public onCloseClick(isClicked: boolean): void {
|
||||||
this.isCloseClicked = isClicked;
|
this.isCloseClicked = isClicked;
|
||||||
|
if (useQueryCopilot.getState().wasCopilotUsed && this.state.isCopilotTabActive) {
|
||||||
|
useQueryCopilot.getState().resetQueryCopilotStates();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCurrentEditorQuery(): string {
|
public getCurrentEditorQuery(): string {
|
||||||
|
@ -146,6 +164,10 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
useSidePanel.getState().openSidePanel("Save Query", <SaveQueryPane explorer={this.props.collection.container} />);
|
useSidePanel.getState().openSidePanel("Save Query", <SaveQueryPane explorer={this.props.collection.container} />);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public launchQueryCopilotChat = (): void => {
|
||||||
|
useQueryCopilot.getState().setShowCopilotSidebar(!useQueryCopilot.getState().showCopilotSidebar);
|
||||||
|
};
|
||||||
|
|
||||||
public onSavedQueriesClick = (): void => {
|
public onSavedQueriesClick = (): void => {
|
||||||
useSidePanel
|
useSidePanel
|
||||||
.getState()
|
.getState()
|
||||||
|
@ -269,6 +291,18 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.launchCopilotButton.visible && this.state.isCopilotTabActive) {
|
||||||
|
const label = "Launch Copilot";
|
||||||
|
buttons.push({
|
||||||
|
iconSrc: LaunchCopilot,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: this.launchQueryCopilotChat,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
ariaLabel: label,
|
||||||
|
hasPopup: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,11 +340,23 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private unsubscribeCopilotSidebar: () => void;
|
||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
|
this.unsubscribeCopilotSidebar = useQueryCopilot.subscribe((state: QueryCopilotState) => {
|
||||||
|
if (this.state.showCopilotSidebar !== state.showCopilotSidebar) {
|
||||||
|
this.setState({ showCopilotSidebar: state.showCopilotSidebar });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): JSX.Element {
|
componentWillUnmount(): void {
|
||||||
|
this.unsubscribeCopilotSidebar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private getEditorAndQueryResult(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="tab-pane" id={this.props.tabId} role="tabpanel">
|
<div className="tab-pane" id={this.props.tabId} role="tabpanel">
|
||||||
|
@ -343,4 +389,19 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<div style={{ display: "flex", flexDirection: "row", height: "100%" }}>
|
||||||
|
<div style={{ width: this.state.showCopilotSidebar ? "70%" : "100%", height: "100%" }}>
|
||||||
|
{this.getEditorAndQueryResult()}
|
||||||
|
</div>
|
||||||
|
{this.state.showCopilotSidebar && this.state.isCopilotTabActive && (
|
||||||
|
<div style={{ width: "30%", height: "100%" }}>
|
||||||
|
<QueryCopilotSidebar />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ export type Features = {
|
||||||
readonly loadLegacyMongoShellFromBE: boolean;
|
readonly loadLegacyMongoShellFromBE: boolean;
|
||||||
readonly enableCopilot: boolean;
|
readonly enableCopilot: boolean;
|
||||||
readonly enableNPSSurvey: boolean;
|
readonly enableNPSSurvey: boolean;
|
||||||
|
readonly copilotVersion?: string;
|
||||||
|
|
||||||
// can be set via both flight and feature flag
|
// can be set via both flight and feature flag
|
||||||
autoscaleDefault: boolean;
|
autoscaleDefault: boolean;
|
||||||
|
@ -106,6 +107,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
||||||
loadLegacyMongoShellFromBE: "true" === get("loadlegacymongoshellfrombe"),
|
loadLegacyMongoShellFromBE: "true" === get("loadlegacymongoshellfrombe"),
|
||||||
enableCopilot: "true" === get("enablecopilot"),
|
enableCopilot: "true" === get("enablecopilot"),
|
||||||
enableNPSSurvey: "true" === get("enablenpssurvey"),
|
enableNPSSurvey: "true" === get("enablenpssurvey"),
|
||||||
|
copilotVersion: get("copilotVersion") ? get("copilotVersion") : "v1.0",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { QueryResults } from "Contracts/ViewModels";
|
||||||
import { guid } from "Explorer/Tables/Utilities";
|
import { guid } from "Explorer/Tables/Utilities";
|
||||||
import create, { UseStore } from "zustand";
|
import create, { UseStore } from "zustand";
|
||||||
|
|
||||||
interface QueryCopilotState {
|
export interface QueryCopilotState {
|
||||||
generatedQuery: string;
|
generatedQuery: string;
|
||||||
likeQuery: boolean;
|
likeQuery: boolean;
|
||||||
userPrompt: string;
|
userPrompt: string;
|
||||||
|
@ -26,6 +26,10 @@ interface QueryCopilotState {
|
||||||
showCopyPopup: boolean;
|
showCopyPopup: boolean;
|
||||||
showErrorMessageBar: boolean;
|
showErrorMessageBar: boolean;
|
||||||
generatedQueryComments: string;
|
generatedQueryComments: string;
|
||||||
|
wasCopilotUsed: boolean;
|
||||||
|
showWelcomeSidebar: boolean;
|
||||||
|
showCopilotSidebar: boolean;
|
||||||
|
chatMessages: string[];
|
||||||
|
|
||||||
openFeedbackModal: (generatedQuery: string, likeQuery: boolean, userPrompt: string) => void;
|
openFeedbackModal: (generatedQuery: string, likeQuery: boolean, userPrompt: string) => void;
|
||||||
closeFeedbackModal: () => void;
|
closeFeedbackModal: () => void;
|
||||||
|
@ -50,6 +54,11 @@ interface QueryCopilotState {
|
||||||
setshowCopyPopup: (showCopyPopup: boolean) => void;
|
setshowCopyPopup: (showCopyPopup: boolean) => void;
|
||||||
setShowErrorMessageBar: (showErrorMessageBar: boolean) => void;
|
setShowErrorMessageBar: (showErrorMessageBar: boolean) => void;
|
||||||
setGeneratedQueryComments: (generatedQueryComments: string) => void;
|
setGeneratedQueryComments: (generatedQueryComments: string) => void;
|
||||||
|
setWasCopilotUsed: (wasCopilotUsed: boolean) => void;
|
||||||
|
setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => void;
|
||||||
|
setShowCopilotSidebar: (showCopilotSidebar: boolean) => void;
|
||||||
|
setChatMessages: (chatMessages: string[]) => void;
|
||||||
|
|
||||||
resetQueryCopilotStates: () => void;
|
resetQueryCopilotStates: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +87,10 @@ export const useQueryCopilot: QueryCopilotStore = create((set) => ({
|
||||||
showCopyPopup: false,
|
showCopyPopup: false,
|
||||||
showErrorMessageBar: false,
|
showErrorMessageBar: false,
|
||||||
generatedQueryComments: "",
|
generatedQueryComments: "",
|
||||||
|
wasCopilotUsed: false,
|
||||||
|
showWelcomeSidebar: true,
|
||||||
|
showCopilotSidebar: false,
|
||||||
|
chatMessages: [],
|
||||||
|
|
||||||
openFeedbackModal: (generatedQuery: string, likeQuery: boolean, userPrompt: string) =>
|
openFeedbackModal: (generatedQuery: string, likeQuery: boolean, userPrompt: string) =>
|
||||||
set({ generatedQuery, likeQuery, userPrompt, showFeedbackModal: true }),
|
set({ generatedQuery, likeQuery, userPrompt, showFeedbackModal: true }),
|
||||||
|
@ -104,6 +117,10 @@ export const useQueryCopilot: QueryCopilotStore = create((set) => ({
|
||||||
setshowCopyPopup: (showCopyPopup: boolean) => set({ showCopyPopup }),
|
setshowCopyPopup: (showCopyPopup: boolean) => set({ showCopyPopup }),
|
||||||
setShowErrorMessageBar: (showErrorMessageBar: boolean) => set({ showErrorMessageBar }),
|
setShowErrorMessageBar: (showErrorMessageBar: boolean) => set({ showErrorMessageBar }),
|
||||||
setGeneratedQueryComments: (generatedQueryComments: string) => set({ generatedQueryComments }),
|
setGeneratedQueryComments: (generatedQueryComments: string) => set({ generatedQueryComments }),
|
||||||
|
setWasCopilotUsed: (wasCopilotUsed: boolean) => set({ wasCopilotUsed }),
|
||||||
|
setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => set({ showWelcomeSidebar }),
|
||||||
|
setShowCopilotSidebar: (showCopilotSidebar: boolean) => set({ showCopilotSidebar }),
|
||||||
|
setChatMessages: (chatMessages: string[]) => set({ chatMessages }),
|
||||||
|
|
||||||
resetQueryCopilotStates: () => {
|
resetQueryCopilotStates: () => {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
|
@ -130,6 +147,9 @@ export const useQueryCopilot: QueryCopilotStore = create((set) => ({
|
||||||
showCopyPopup: false,
|
showCopyPopup: false,
|
||||||
showErrorMessageBar: false,
|
showErrorMessageBar: false,
|
||||||
generatedQueryComments: "",
|
generatedQueryComments: "",
|
||||||
|
wasCopilotUsed: false,
|
||||||
|
showCopilotSidebar: false,
|
||||||
|
chatMessages: [],
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|