@sourcegraph/cody-web 0.7.3 → 0.7.6

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.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
- import { g as getDefaultExportFromCjs, L as Ls, k as ke$1, a as ks, F as Fi$1, _ as _s, b as ds, c as bs, i as ii$1, q as qe$1, y as ys, x as xi$1, K as K$2, J as J$2, R as R$3, e as ws, B as B$2, f as g$5, h as h$4, j as _i, S as Ss, l as Br, m as ln, n as bi$1, v as vn, o as xn, N as Nn, r as mn, s as li$1, u as n$1, z as ns, M as M$4, D as Ds, A as le$2, E as c$4, G as oe$1, H as z$1, I as yi$1, W as W$2, U as Ue$1, O as I$2, P as Se$2, Q as O$2, V as F$1, X as Ni$1, Y as ee$1, Z as we$2, $ as b$2, a0 as T$3, a1 as s$2, a2 as o$4, a3 as w$3, a4 as i$1, a5 as k$3, a6 as D$5, a7 as p$8, a8 as m$7, a9 as S$4, aa as v$4, ab as P$2, ac as E$6, ad as Wi$1, ae as L$3, af as d$2, ag as a$3, ah as l$2, ai as f$2, aj as u$6, ak as r$6, al as t$2, am as displayPathBasename, an as FILE_CONTEXT_MENTION_PROVIDER, ao as SYMBOL_CONTEXT_MENTION_PROVIDER, ap as REMOTE_REPOSITORY_PROVIDER_URI, aq as REMOTE_FILE_PROVIDER_URI, ar as REMOTE_DIRECTORY_PROVIDER_URI, as as CURRENT_REPOSITORY_DIRECTORY_PROVIDER_URI, at as WEB_PROVIDER_URI, au as displayPath, av as displayLineRange, aw as displayPathDirname, ax as IGNORED_FILE_WARNING_LABEL, ay as LARGE_FILE_WARNING_LABEL, az as Ei$1, aA as xe$2, aB as V$2, aC as Es, aD as U$2, aE as e, aF as Ns, aG as an, aH as gs, aI as serializeContextItem, aJ as CONTEXT_ITEM_MENTION_NODE_TYPE, aK as contextItemMentionNodeDisplayText, C as ContextItemSource, aL as URI, aM as qr, aN as _$2, aO as TEMPLATE_INPUT_NODE_TYPE, aP as N$2, aQ as parseMentionQuery, aR as NO_SYMBOL_MATCHES_HELP_LABEL, aS as FILE_RANGE_TOOLTIP_LABEL, aT as proxyExtensionAPI, aU as createMessageAPIForWebview, aV as lodashExports, aW as memoizeLastValue, aX as toSerializedPromptEditorValue, aY as ri$1, aZ as scanForMentionTriggerInUserTextInput, a_ as fs, a$ as Ts, b0 as ps, b1 as hydrateAfterPostMessage, b2 as isCodyProUser, b3 as CodyIDE, b4 as webviewOpenURIForContextItem, b5 as commonjsGlobal, b6 as CodyTaskState, b7 as cryptoJsExports, b8 as isError, b9 as RateLimitError, ba as CODY_FEEDBACK_URL, bb as isDefined, bc as reformatBotMessageForChat, p as ps$1, bd as isAbortErrorOrSocketHangUp, be as isEqual, bf as serializedPromptEditorStateFromChatMessage, bg as contextItemsFromPromptEditorValue, bh as filterContextItemsFromPromptEditorValue, bi as pluralize, bj as isCodyProModel, bk as ModelTag, bl as CustomCommandType, bm as isMacOS, bn as textContentFromSerializedLexicalNode, bo as FAST_CHAT_INPUT_TOKEN_BUDGET, bp as deserializeContextItem, bq as View, br as truncateTextStart, bs as CHAT_INPUT_TOKEN_BUDGET, bt as ACCOUNT_USAGE_URL, bu as getRelativeChatPeriod, bv as browser, bw as isErrorLike, bx as setDisplayPathEnvInfo, by as PromptString } from "./browser-0yJ2hV_u.mjs";
5
+ import { g as getDefaultExportFromCjs, L as Ls, k as ke$1, a as ks, F as Fi$1, _ as _s, b as ds, c as bs, i as ii$1, q as qe$1, y as ys, x as xi$1, K as K$2, J as J$2, R as R$3, e as ws, B as B$2, f as g$5, h as h$4, j as _i, S as Ss, l as Br, m as ln, n as bi$1, v as vn, o as xn, N as Nn, r as mn, s as li$1, u as n$1, z as ns, M as M$4, D as Ds, A as le$2, E as c$4, G as oe$1, H as z$1, I as yi$1, W as W$2, U as Ue$1, O as I$2, P as Se$2, Q as O$2, V as F$1, X as Ni$1, Y as ee$1, Z as we$2, $ as b$2, a0 as T$3, a1 as s$2, a2 as o$4, a3 as w$3, a4 as i$1, a5 as k$3, a6 as D$5, a7 as p$8, a8 as m$7, a9 as S$4, aa as v$4, ab as P$2, ac as E$6, ad as Wi$1, ae as L$3, af as d$2, ag as a$3, ah as l$2, ai as f$2, aj as u$6, ak as r$6, al as t$2, am as displayPathBasename, an as FILE_CONTEXT_MENTION_PROVIDER, ao as SYMBOL_CONTEXT_MENTION_PROVIDER, ap as REMOTE_REPOSITORY_PROVIDER_URI, aq as REMOTE_FILE_PROVIDER_URI, ar as REMOTE_DIRECTORY_PROVIDER_URI, as as CURRENT_REPOSITORY_DIRECTORY_PROVIDER_URI, at as WEB_PROVIDER_URI, au as displayPath, av as displayLineRange, aw as displayPathDirname, ax as IGNORED_FILE_WARNING_LABEL, ay as LARGE_FILE_WARNING_LABEL, az as Ei$1, aA as xe$2, aB as V$2, aC as Es, aD as U$2, aE as e, aF as Ns, aG as an, aH as gs, aI as serializeContextItem, aJ as CONTEXT_ITEM_MENTION_NODE_TYPE, aK as contextItemMentionNodeDisplayText, C as ContextItemSource, aL as URI, aM as qr, aN as _$2, aO as TEMPLATE_INPUT_NODE_TYPE, aP as N$2, aQ as parseMentionQuery, aR as NO_SYMBOL_MATCHES_HELP_LABEL, aS as FILE_RANGE_TOOLTIP_LABEL, aT as createExtensionAPI, aU as createMessageAPIForWebview, aV as lodashExports, aW as memoizeLastValue, aX as toSerializedPromptEditorValue, aY as ri$1, aZ as scanForMentionTriggerInUserTextInput, a_ as fs, a$ as Ts, b0 as ps, b1 as hydrateAfterPostMessage, b2 as isCodyProUser, b3 as CodyIDE, b4 as webviewOpenURIForContextItem, b5 as commonjsGlobal, b6 as CodyTaskState, b7 as cryptoJsExports, b8 as isError, b9 as RateLimitError, ba as CODY_FEEDBACK_URL, bb as isDefined, bc as reformatBotMessageForChat, p as ps$1, bd as isAbortErrorOrSocketHangUp, be as isEqual, bf as serializedPromptEditorStateFromChatMessage, bg as contextItemsFromPromptEditorValue, bh as filterContextItemsFromPromptEditorValue, bi as pluralize, bj as isCodyProModel, bk as ModelTag, bl as isMacOS, bm as textContentFromSerializedLexicalNode, bn as FAST_CHAT_INPUT_TOKEN_BUDGET, bo as deserializeContextItem, bp as View, bq as ACCOUNT_USAGE_URL, br as getRelativeChatPeriod, bs as truncateTextStart, bt as CHAT_INPUT_TOKEN_BUDGET, bu as browser, bv as isErrorLike, bw as setDisplayPathEnvInfo, bx as PromptString } from "./browser-5V4RMNo3.mjs";
6
6
  import * as React from "react";
7
7
  import React__default, { createContext, useContext, useMemo, useLayoutEffect, useEffect, forwardRef, useState, useCallback, useRef, Suspense, createElement, memo, useImperativeHandle, Children, isValidElement, cloneElement, Fragment as Fragment$1, useReducer } from "react";
8
8
  var classnames = { exports: {} };
@@ -7844,6 +7844,31 @@ const Brain = createLucideIcon("Brain", [
7844
7844
  ["path", { d: "M6 18a4 4 0 0 1-1.967-.516", key: "2e4loj" }],
7845
7845
  ["path", { d: "M19.967 17.484A4 4 0 0 1 18 18", key: "159ez6" }]
7846
7846
  ]);
7847
+ /**
7848
+ * @license lucide-react v0.378.0 - ISC
7849
+ *
7850
+ * This source code is licensed under the ISC license.
7851
+ * See the LICENSE file in the root directory of this source tree.
7852
+ */
7853
+ const Bug = createLucideIcon("Bug", [
7854
+ ["path", { d: "m8 2 1.88 1.88", key: "fmnt4t" }],
7855
+ ["path", { d: "M14.12 3.88 16 2", key: "qol33r" }],
7856
+ ["path", { d: "M9 7.13v-1a3.003 3.003 0 1 1 6 0v1", key: "d7y7pr" }],
7857
+ [
7858
+ "path",
7859
+ {
7860
+ d: "M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",
7861
+ key: "xs1cw7"
7862
+ }
7863
+ ],
7864
+ ["path", { d: "M12 20v-9", key: "1qisl0" }],
7865
+ ["path", { d: "M6.53 9C4.6 8.8 3 7.1 3 5", key: "32zzws" }],
7866
+ ["path", { d: "M6 13H2", key: "82j7cp" }],
7867
+ ["path", { d: "M3 21c0-2.1 1.7-3.9 3.8-4", key: "4p0ekp" }],
7868
+ ["path", { d: "M20.97 5c0 2.1-1.6 3.8-3.5 4", key: "18gb23" }],
7869
+ ["path", { d: "M22 13h-4", key: "1jl80f" }],
7870
+ ["path", { d: "M17.2 17c2.1.1 3.8 1.9 3.8 4", key: "k3fwyw" }]
7871
+ ]);
7847
7872
  /**
7848
7873
  * @license lucide-react v0.378.0 - ISC
7849
7874
  *
@@ -7908,6 +7933,17 @@ const ChevronsUpDown = createLucideIcon("ChevronsUpDown", [
7908
7933
  ["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
7909
7934
  ["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
7910
7935
  ]);
7936
+ /**
7937
+ * @license lucide-react v0.378.0 - ISC
7938
+ *
7939
+ * This source code is licensed under the ISC license.
7940
+ * See the LICENSE file in the root directory of this source tree.
7941
+ */
7942
+ const CirclePlus = createLucideIcon("CirclePlus", [
7943
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
7944
+ ["path", { d: "M8 12h8", key: "1wcyev" }],
7945
+ ["path", { d: "M12 8v8", key: "napkw2" }]
7946
+ ]);
7911
7947
  /**
7912
7948
  * @license lucide-react v0.378.0 - ISC
7913
7949
  *
@@ -7929,6 +7965,20 @@ const Columns2 = createLucideIcon("Columns2", [
7929
7965
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
7930
7966
  ["path", { d: "M12 3v18", key: "108xh3" }]
7931
7967
  ]);
7968
+ /**
7969
+ * @license lucide-react v0.378.0 - ISC
7970
+ *
7971
+ * This source code is licensed under the ISC license.
7972
+ * See the LICENSE file in the root directory of this source tree.
7973
+ */
7974
+ const Combine = createLucideIcon("Combine", [
7975
+ ["rect", { width: "8", height: "8", x: "2", y: "2", rx: "2", key: "z1hh3n" }],
7976
+ ["path", { d: "M14 2c1.1 0 2 .9 2 2v4c0 1.1-.9 2-2 2", key: "83orz6" }],
7977
+ ["path", { d: "M20 2c1.1 0 2 .9 2 2v4c0 1.1-.9 2-2 2", key: "k86dmt" }],
7978
+ ["path", { d: "M10 18H5c-1.7 0-3-1.3-3-3v-1", key: "6vokjl" }],
7979
+ ["polyline", { points: "7 21 10 18 7 15", key: "1k02g0" }],
7980
+ ["rect", { width: "8", height: "8", x: "14", y: "14", rx: "2", key: "1fa9i4" }]
7981
+ ]);
7932
7982
  /**
7933
7983
  * @license lucide-react v0.378.0 - ISC
7934
7984
  *
@@ -7984,6 +8034,17 @@ const ExternalLink = createLucideIcon("ExternalLink", [
7984
8034
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
7985
8035
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
7986
8036
  ]);
8037
+ /**
8038
+ * @license lucide-react v0.378.0 - ISC
8039
+ *
8040
+ * This source code is licensed under the ISC license.
8041
+ * See the LICENSE file in the root directory of this source tree.
8042
+ */
8043
+ const FileQuestion = createLucideIcon("FileQuestion", [
8044
+ ["path", { d: "M12 17h.01", key: "p32p05" }],
8045
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z", key: "1mlx9k" }],
8046
+ ["path", { d: "M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3", key: "mhlwft" }]
8047
+ ]);
7987
8048
  /**
7988
8049
  * @license lucide-react v0.378.0 - ISC
7989
8050
  *
@@ -8012,6 +8073,23 @@ const FolderGit = createLucideIcon("FolderGit", [
8012
8073
  ["path", { d: "M14 13h3", key: "1dgedf" }],
8013
8074
  ["path", { d: "M7 13h3", key: "1pygq7" }]
8014
8075
  ]);
8076
+ /**
8077
+ * @license lucide-react v0.378.0 - ISC
8078
+ *
8079
+ * This source code is licensed under the ISC license.
8080
+ * See the LICENSE file in the root directory of this source tree.
8081
+ */
8082
+ const Hammer = createLucideIcon("Hammer", [
8083
+ ["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
8084
+ ["path", { d: "m18 15 4-4", key: "16gjal" }],
8085
+ [
8086
+ "path",
8087
+ {
8088
+ d: "m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",
8089
+ key: "b7pghm"
8090
+ }
8091
+ ]
8092
+ ]);
8015
8093
  /**
8016
8094
  * @license lucide-react v0.378.0 - ISC
8017
8095
  *
@@ -8050,6 +8128,17 @@ const Link$1 = createLucideIcon("Link", [
8050
8128
  ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
8051
8129
  ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
8052
8130
  ]);
8131
+ /**
8132
+ * @license lucide-react v0.378.0 - ISC
8133
+ *
8134
+ * This source code is licensed under the ISC license.
8135
+ * See the LICENSE file in the root directory of this source tree.
8136
+ */
8137
+ const MessageCircleCode = createLucideIcon("MessageCircleCode", [
8138
+ ["path", { d: "M10 9.5 8 12l2 2.5", key: "3mjy60" }],
8139
+ ["path", { d: "m14 9.5 2 2.5-2 2.5", key: "1bir2l" }],
8140
+ ["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22z", key: "k85zhp" }]
8141
+ ]);
8053
8142
  /**
8054
8143
  * @license lucide-react v0.378.0 - ISC
8055
8144
  *
@@ -8098,9 +8187,18 @@ const Option$2 = createLucideIcon("Option", [
8098
8187
  * This source code is licensed under the ISC license.
8099
8188
  * See the LICENSE file in the root directory of this source tree.
8100
8189
  */
8101
- const Plus = createLucideIcon("Plus", [
8102
- ["path", { d: "M5 12h14", key: "1ays0h" }],
8103
- ["path", { d: "M12 5v14", key: "s699le" }]
8190
+ const Pencil = createLucideIcon("Pencil", [
8191
+ ["path", { d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z", key: "5qss01" }],
8192
+ ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
8193
+ ]);
8194
+ /**
8195
+ * @license lucide-react v0.378.0 - ISC
8196
+ *
8197
+ * This source code is licensed under the ISC license.
8198
+ * See the LICENSE file in the root directory of this source tree.
8199
+ */
8200
+ const Play = createLucideIcon("Play", [
8201
+ ["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
8104
8202
  ]);
8105
8203
  /**
8106
8204
  * @license lucide-react v0.378.0 - ISC
@@ -8118,6 +8216,22 @@ const Settings = createLucideIcon("Settings", [
8118
8216
  ],
8119
8217
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
8120
8218
  ]);
8219
+ /**
8220
+ * @license lucide-react v0.378.0 - ISC
8221
+ *
8222
+ * This source code is licensed under the ISC license.
8223
+ * See the LICENSE file in the root directory of this source tree.
8224
+ */
8225
+ const ShieldCheck = createLucideIcon("ShieldCheck", [
8226
+ [
8227
+ "path",
8228
+ {
8229
+ d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
8230
+ key: "oel41y"
8231
+ }
8232
+ ],
8233
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
8234
+ ]);
8121
8235
  /**
8122
8236
  * @license lucide-react v0.378.0 - ISC
8123
8237
  *
@@ -8345,7 +8459,6 @@ function getGlobalPromptEditorConfig() {
8345
8459
  const CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
8346
8460
  const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && // @ts-ignore
8347
8461
  !window.MSStream;
8348
- CAN_USE_DOM && window.matchMedia("(pointer: coarse)").matches;
8349
8462
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
8350
8463
  const useIsFocused = () => {
8351
8464
  const [editor2] = u$5();
@@ -8517,7 +8630,7 @@ const MentionComponent = ({ nodeKey, node: node2, tooltip, icon: Icon2, classNam
8517
8630
  };
8518
8631
  }, [editor2, onArrowLeftPress, onArrowRightPress, onClick, onDelete, onBlur, onSelectionChange]);
8519
8632
  const content2 = /* @__PURE__ */ jsxs("span", { ref: ref2, className: composedClassNames, title: tooltipComponents ? void 0 : tooltip, children: [
8520
- Icon2 && /* @__PURE__ */ jsx(Icon2, { size: 14, strokeWidth: 2, className: iconClassName }),
8633
+ Icon2 && /* @__PURE__ */ jsx(Icon2, { size: 14, strokeWidth: 2, className: clsx$1(iconClassName, "tw-shrink-0") }),
8521
8634
  /* @__PURE__ */ jsx("span", { children: text2 })
8522
8635
  ] });
8523
8636
  if (!tooltipComponents) {
@@ -9030,6 +9143,14 @@ const MentionMenu = ({
9030
9143
  window.addEventListener("keydown", listener, { capture: true });
9031
9144
  return () => window.removeEventListener("keydown", listener, { capture: true });
9032
9145
  }, []);
9146
+ useEffect(() => {
9147
+ const listener = (e2) => {
9148
+ e2.preventDefault();
9149
+ e2.stopPropagation();
9150
+ };
9151
+ window.addEventListener("mousedown", listener, { capture: true });
9152
+ return () => window.removeEventListener("mousedown", listener, { capture: true });
9153
+ }, []);
9033
9154
  const onProviderSelect = useCallback(
9034
9155
  (value2) => {
9035
9156
  const provider = data.providers.find((p2) => commandRowValue$1(p2) === value2);
@@ -9217,21 +9338,17 @@ function useClientState() {
9217
9338
  const ChatMentionContext = createContext({
9218
9339
  resolutionMode: "local"
9219
9340
  });
9220
- const context$1 = createContext(void 0);
9341
+ const context = createContext(void 0);
9221
9342
  const ExtensionAPIProviderFromVSCodeAPI = ({ vscodeAPI, children: children2 }) => {
9222
- const extensionAPI = useMemo(() => {
9223
- const messageAPI = createMessageAPIForWebview(vscodeAPI);
9224
- return {
9225
- mentionMenuData: proxyExtensionAPI(messageAPI, "mentionMenuData"),
9226
- evaluatedFeatureFlag: proxyExtensionAPI(messageAPI, "evaluatedFeatureFlag"),
9227
- prompts: proxyExtensionAPI(messageAPI, "prompts")
9228
- };
9229
- }, [vscodeAPI]);
9230
- return /* @__PURE__ */ jsx(context$1.Provider, { value: extensionAPI, children: children2 });
9343
+ const extensionAPI = useMemo(
9344
+ () => createExtensionAPI(createMessageAPIForWebview(vscodeAPI)),
9345
+ [vscodeAPI]
9346
+ );
9347
+ return /* @__PURE__ */ jsx(context.Provider, { value: extensionAPI, children: children2 });
9231
9348
  };
9232
- context$1.Provider;
9349
+ context.Provider;
9233
9350
  function useExtensionAPI() {
9234
- const extensionAPI = useContext(context$1);
9351
+ const extensionAPI = useContext(context);
9235
9352
  if (!extensionAPI) {
9236
9353
  throw new Error(
9237
9354
  "useExtensionAPI must be used within an ExtensionAPIProviderFromVSCodeAPI or ExtensionAPIProviderForTestsOnly component"
@@ -9375,7 +9492,7 @@ function useCallMentionMenuData({
9375
9492
  const mentionQuery = useMemo(
9376
9493
  () => ({
9377
9494
  ...parseMentionQuery(query ?? "", provider),
9378
- includeRemoteRepositories: mentionSettings.resolutionMode === "remote"
9495
+ contextRemoteRepositoriesNames: mentionSettings.remoteRepositoriesNames
9379
9496
  }),
9380
9497
  [query, provider, mentionSettings]
9381
9498
  );
@@ -12839,6 +12956,19 @@ const $a093c7e1ec25a057$var$PORTAL_NAME = "TooltipPortal";
12839
12956
  const [$a093c7e1ec25a057$var$PortalProvider, $a093c7e1ec25a057$var$usePortalContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, {
12840
12957
  forceMount: void 0
12841
12958
  });
12959
+ const $a093c7e1ec25a057$export$7b36b8f925ab7497 = (props) => {
12960
+ const { __scopeTooltip, forceMount, children: children2, container: container2 } = props;
12961
+ const context2 = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, __scopeTooltip);
12962
+ return /* @__PURE__ */ createElement($a093c7e1ec25a057$var$PortalProvider, {
12963
+ scope: __scopeTooltip,
12964
+ forceMount
12965
+ }, /* @__PURE__ */ createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
12966
+ present: forceMount || context2.open
12967
+ }, /* @__PURE__ */ createElement($f1701beae083dbae$export$602eac185826482c, {
12968
+ asChild: true,
12969
+ container: container2
12970
+ }, children2)));
12971
+ };
12842
12972
  const $a093c7e1ec25a057$var$CONTENT_NAME = "TooltipContent";
12843
12973
  const $a093c7e1ec25a057$export$e9003e2be37ec060 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
12844
12974
  const portalContext = $a093c7e1ec25a057$var$usePortalContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
@@ -13136,6 +13266,7 @@ function $a093c7e1ec25a057$var$getHullPresorted(points) {
13136
13266
  const $a093c7e1ec25a057$export$2881499e37b75b9a = $a093c7e1ec25a057$export$f78649fb9ca566b8;
13137
13267
  const $a093c7e1ec25a057$export$be92b6f5f03c0fe9 = $a093c7e1ec25a057$export$28c660c63b792dea;
13138
13268
  const $a093c7e1ec25a057$export$41fb9f06171c75f4 = $a093c7e1ec25a057$export$8c610744efcf8a1d;
13269
+ const $a093c7e1ec25a057$export$602eac185826482c = $a093c7e1ec25a057$export$7b36b8f925ab7497;
13139
13270
  const $a093c7e1ec25a057$export$7c6e2c02157bb7d2 = $a093c7e1ec25a057$export$e9003e2be37ec060;
13140
13271
  const CLASS_PART_SEPARATOR = "-";
13141
13272
  function createClassUtils(config) {
@@ -15624,19 +15755,22 @@ function cn(...inputs) {
15624
15755
  const TooltipProvider = $a093c7e1ec25a057$export$2881499e37b75b9a;
15625
15756
  const Tooltip = $a093c7e1ec25a057$export$be92b6f5f03c0fe9;
15626
15757
  const TooltipTrigger = $a093c7e1ec25a057$export$41fb9f06171c75f4;
15627
- const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref2) => /* @__PURE__ */ jsx(
15628
- $a093c7e1ec25a057$export$7c6e2c02157bb7d2,
15629
- {
15630
- ref: ref2,
15631
- sideOffset,
15632
- className: cn(
15633
- "tw-z-50 tw-overflow-hidden tw-flex tw-items-center tw-rounded-md tw-border tw-border-border tw-leading-tight tw-bg-popover tw-px-3 tw-py-2 tw-text-sm tw-text-popover-foreground tw-max-w-72 tw-text-center tw-whitespace-pre-line tw-shadow-lg [&_kbd]:tw-ml-3 [&_kbd]:-tw-mr-1 [&_kbd]:tw-mt-[-4px] [&_kbd]:tw-mb-[-4px]",
15634
- className
15635
- ),
15636
- ...props,
15637
- children: props.children
15638
- }
15639
- ));
15758
+ const TooltipContent = React.forwardRef(({ portal, className, sideOffset = 4, ...props }, ref2) => {
15759
+ const Portal = portal ? $a093c7e1ec25a057$export$602eac185826482c : React.Fragment;
15760
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
15761
+ $a093c7e1ec25a057$export$7c6e2c02157bb7d2,
15762
+ {
15763
+ ref: ref2,
15764
+ sideOffset,
15765
+ className: cn(
15766
+ "tw-z-50 tw-overflow-hidden tw-flex tw-items-center tw-rounded-md tw-border tw-border-border tw-leading-tight tw-bg-popover tw-px-3 tw-py-2 tw-text-sm tw-text-popover-foreground tw-max-w-72 tw-text-center tw-whitespace-pre-line tw-shadow-lg [&_kbd]:tw-ml-3 [&_kbd]:-tw-mr-1 [&_kbd]:tw-mt-[-4px] [&_kbd]:tw-mb-[-4px]",
15767
+ className
15768
+ ),
15769
+ ...props,
15770
+ children: props.children
15771
+ }
15772
+ ) });
15773
+ });
15640
15774
  TooltipContent.displayName = $a093c7e1ec25a057$export$7c6e2c02157bb7d2.displayName;
15641
15775
  var U = 1, Y$1 = 0.9, H = 0.8, J = 0.17, p$1 = 0.1, u = 0.999, $ = 0.9999;
15642
15776
  var k$1 = 0.99, m = /[\\\/_+.#"@\[\(\{&]/, B = /[\\\/_+.#"@\[\(\{&]/g, K = /[\s-]/, X$1 = /[\s-]/g;
@@ -17212,18 +17346,25 @@ const Command = React.forwardRef(({ className, ...props }, ref2) => /* @__PURE__
17212
17346
  }
17213
17347
  ));
17214
17348
  Command.displayName = He.displayName;
17215
- const CommandInput = React.forwardRef(({ className, ...props }, ref2) => /* @__PURE__ */ jsx("div", { className: "tw-flex tw-items-center tw-border-b tw-border-b-border", "cmdk-input-wrapper": "", children: /* @__PURE__ */ jsx(
17216
- He.Input,
17349
+ const CommandInput = React.forwardRef(({ wrapperClassName, className, ...props }, ref2) => /* @__PURE__ */ jsx(
17350
+ "div",
17217
17351
  {
17218
- ref: ref2,
17219
- className: cn(
17220
- "tw-flex tw-w-full tw-border-solid tw-border tw-border-transparent tw-bg-transparent tw-pt-4 tw-pb-3 tw-px-3 tw-text-md tw-leading-none placeholder:tw-text-muted-foreground disabled:tw-cursor-not-allowed disabled:tw-opacity-50 focus:tw-outline-none",
17221
- className
17222
- ),
17223
- inputMode: "search",
17224
- ...props
17352
+ className: cn("tw-flex tw-items-center tw-border-b tw-border-b-border", wrapperClassName),
17353
+ "cmdk-input-wrapper": "",
17354
+ children: /* @__PURE__ */ jsx(
17355
+ He.Input,
17356
+ {
17357
+ ref: ref2,
17358
+ className: cn(
17359
+ "tw-flex tw-w-full tw-border-solid tw-border tw-border-transparent tw-bg-transparent tw-pt-4 tw-pb-3 tw-px-3 tw-text-md tw-leading-none placeholder:tw-text-muted-foreground disabled:tw-cursor-not-allowed disabled:tw-opacity-50 focus:tw-outline-none",
17360
+ className
17361
+ ),
17362
+ inputMode: "search",
17363
+ ...props
17364
+ }
17365
+ )
17225
17366
  }
17226
- ) }));
17367
+ ));
17227
17368
  CommandInput.displayName = He.Input.displayName;
17228
17369
  const CommandList = React.forwardRef(({ className, ...props }, ref2) => /* @__PURE__ */ jsx(
17229
17370
  He.List,
@@ -17278,7 +17419,7 @@ const CommandItem = React.forwardRef(({ className, tooltip, ...props }, ref2) =>
17278
17419
  {
17279
17420
  ref: ref2,
17280
17421
  className: cn(
17281
- "tw-relative tw-flex tw-cursor-pointer tw-select-none tw-items-center tw-rounded-sm tw-py-3 tw-px-2 tw-text-md tw-outline-none aria-selected:tw-bg-accent aria-selected:tw-text-accent-foreground hover:tw-bg-accent hover:tw-text-accent-foreground data-[disabled=true]:tw-pointer-events-none data-[disabled=true]:tw-opacity-50",
17422
+ "tw-relative tw-flex tw-cursor-pointer tw-select-none tw-items-center tw-rounded-sm tw-py-3 tw-px-2 tw-text-md tw-outline-none aria-selected:tw-bg-accent aria-selected:tw-text-accent-foreground hover:tw-bg-accent hover:tw-text-accent-foreground hover:tw-border-accent data-[disabled=true]:tw-pointer-events-none data-[disabled=true]:tw-opacity-50",
17282
17423
  className
17283
17424
  ),
17284
17425
  title: tooltip,
@@ -17288,6 +17429,16 @@ const CommandItem = React.forwardRef(({ className, tooltip, ...props }, ref2) =>
17288
17429
  return item2;
17289
17430
  });
17290
17431
  CommandItem.displayName = He.Item.displayName;
17432
+ const CommandRow = ({ className, ...props }) => /* @__PURE__ */ jsx(
17433
+ "div",
17434
+ {
17435
+ className: cn(
17436
+ "tw-flex tw-flex-wrap tw-select-none tw-items-center tw-gap-x-3 tw-gap-y-1 tw-text-md tw-outline-none [&:not(:last-child)]:tw-border-border [&:not(:last-child)]:tw-border-b [&_[cmdk-item]]:tw-whitespace-nowrap",
17437
+ className
17438
+ ),
17439
+ ...props
17440
+ }
17441
+ );
17291
17442
  const CommandLink = ({ href, className, children: children2, onSelect, ...props }) => {
17292
17443
  const linkRef = React.useRef(null);
17293
17444
  const isHandlingClick = React.useRef(false);
@@ -17415,10 +17566,10 @@ const COMMON_WRAPPERS = [
17415
17566
  value: promptEditorConfig
17416
17567
  }
17417
17568
  ];
17418
- const outerContainer = "_outer-container_xb9w0_1";
17419
- const errorContainer = "_error-container_xb9w0_11";
17420
- const error$1 = "_error_xb9w0_11";
17421
- const closeBtn = "_close-btn_xb9w0_29";
17569
+ const outerContainer = "_outer-container_hbzxh_1";
17570
+ const errorContainer = "_error-container_hbzxh_10";
17571
+ const error$1 = "_error_hbzxh_10";
17572
+ const closeBtn = "_close-btn_hbzxh_28";
17422
17573
  const styles$f = {
17423
17574
  outerContainer,
17424
17575
  errorContainer,
@@ -29746,11 +29897,16 @@ function useConfig() {
29746
29897
  }
29747
29898
  function useUserAccountInfo() {
29748
29899
  const value = useConfig();
29900
+ if (!value.authStatus.authenticated) {
29901
+ throw new Error(
29902
+ "useUserAccountInfo must be used within a ConfigProvider with authenticated user"
29903
+ );
29904
+ }
29749
29905
  return {
29750
29906
  isCodyProUser: isCodyProUser(value.authStatus),
29751
29907
  // Receive this value from the extension backend to make it work
29752
29908
  // with E2E tests where change the DOTCOM_URL via the env variable TESTING_DOTCOM_URL.
29753
- isDotComUser: value.authStatus.isDotCom,
29909
+ isDotComUser: value.isDotComUser,
29754
29910
  user: value.authStatus,
29755
29911
  ide: value.config.agentIDE ?? CodyIDE.VSCode
29756
29912
  };
@@ -29890,23 +30046,6 @@ const GeminiLogo = ({
29890
30046
  ]
29891
30047
  }
29892
30048
  );
29893
- const context = createContext({});
29894
- const ChatModelContextProvider = context.Provider;
29895
- function useChatModelContext() {
29896
- return useContext(context);
29897
- }
29898
- function useChatModelByID(model) {
29899
- const { chatModels } = useChatModelContext();
29900
- return (chatModels == null ? void 0 : chatModels.find((m2) => m2.id === model)) ?? (model ? {
29901
- id: model,
29902
- title: model,
29903
- provider: "unknown"
29904
- } : void 0);
29905
- }
29906
- function useCurrentChatModel() {
29907
- const { chatModels } = useChatModelContext();
29908
- return chatModels == null ? void 0 : chatModels[0];
29909
- }
29910
30049
  const path$2 = "_path_kr5rq_1";
29911
30050
  const excluded = "_excluded_kr5rq_7";
29912
30051
  const styles$e = {
@@ -30016,8 +30155,6 @@ const hoverSourceLabels = {
30016
30155
  selection: "from selected code",
30017
30156
  user: "via @-mention",
30018
30157
  terminal: "from terminal output",
30019
- uri: "from URI",
30020
- // todo(tim): what is this?
30021
30158
  history: "from git history",
30022
30159
  initial: "from open repo or file"
30023
30160
  };
@@ -30835,28 +30972,32 @@ const LoadingDots = () => /* @__PURE__ */ jsxs("div", { className: styles$d.dots
30835
30972
  /* @__PURE__ */ jsx("div", { className: styles$d.dot }),
30836
30973
  /* @__PURE__ */ jsx("div", { className: styles$d.dot })
30837
30974
  ] });
30838
- const Cell = ({
30839
- header: header2,
30840
- containerClassName,
30841
- contentClassName,
30842
- "aria-current": ariaCurrent,
30843
- "aria-disabled": ariaDisabled,
30844
- "data-testid": dataTestID,
30845
- children: children2
30846
- }) => /* @__PURE__ */ jsxs(
30847
- "div",
30848
- {
30849
- className: clsx$1("tw-flex tw-flex-col tw-gap-4", containerClassName),
30850
- role: "row",
30975
+ const Cell = forwardRef((props, ref2) => {
30976
+ const {
30977
+ header: header2,
30978
+ containerClassName,
30979
+ contentClassName,
30851
30980
  "aria-current": ariaCurrent,
30852
30981
  "aria-disabled": ariaDisabled,
30853
30982
  "data-testid": dataTestID,
30854
- children: [
30855
- /* @__PURE__ */ jsx("header", { className: "tw-flex tw-gap-4 tw-items-center [&_>_*]:tw-flex-shrink-0", children: header2 }),
30856
- /* @__PURE__ */ jsx("div", { className: clsx$1("tw-flex-1 tw-overflow-hidden", contentClassName), children: children2 })
30857
- ]
30858
- }
30859
- );
30983
+ children: children2
30984
+ } = props;
30985
+ return /* @__PURE__ */ jsxs(
30986
+ "div",
30987
+ {
30988
+ ref: ref2,
30989
+ className: clsx$1("tw-flex tw-flex-col tw-gap-4", containerClassName),
30990
+ role: "row",
30991
+ "aria-current": ariaCurrent,
30992
+ "aria-disabled": ariaDisabled,
30993
+ "data-testid": dataTestID,
30994
+ children: [
30995
+ /* @__PURE__ */ jsx("header", { className: "tw-flex tw-gap-4 tw-items-center [&_>_*]:tw-flex-shrink-0", children: header2 }),
30996
+ /* @__PURE__ */ jsx("div", { className: clsx$1("tw-flex-1 tw-overflow-hidden", contentClassName), children: children2 })
30997
+ ]
30998
+ }
30999
+ );
31000
+ });
30860
31001
  const CodyLogoBW = ({ size: size2, ...props }) => /* @__PURE__ */ jsxs(
30861
31002
  "svg",
30862
31003
  {
@@ -71789,13 +71930,14 @@ const FeedbackButtons = ({
71789
71930
  ] })
71790
71931
  ] });
71791
71932
  };
71792
- const BaseMessageCell = ({ speakerIcon, speakerTitle, content: content2, contentClassName, footer: footer2, className }) => /* @__PURE__ */ jsxs(
71933
+ const BaseMessageCell = ({ speakerIcon, speakerTitle, cellAction, content: content2, contentClassName, footer: footer2, className }) => /* @__PURE__ */ jsxs(
71793
71934
  Cell,
71794
71935
  {
71795
71936
  header: /* @__PURE__ */ jsxs(Fragment, { children: [
71796
71937
  speakerIcon,
71797
71938
  " ",
71798
- /* @__PURE__ */ jsx("span", { className: "tw-mt-[-1px] tw-font-semibold", children: speakerTitle })
71939
+ /* @__PURE__ */ jsx("span", { className: "tw-mt-[-1px] tw-font-semibold", children: speakerTitle }),
71940
+ /* @__PURE__ */ jsx("div", { className: "tw-ml-auto", children: cellAction })
71799
71941
  ] }),
71800
71942
  containerClassName: className,
71801
71943
  contentClassName,
@@ -72007,6 +72149,15 @@ function makeHumanMessageInfo({ humanMessage, assistantMessage }, humanEditorRef
72007
72149
  }
72008
72150
  };
72009
72151
  }
72152
+ function useChatModelByID(model) {
72153
+ const models = useExtensionAPI().models;
72154
+ const chatModels = useObservable(useMemo(() => models(), [models])).value;
72155
+ return (chatModels == null ? void 0 : chatModels.find((m2) => m2.id === model)) ?? (model ? {
72156
+ id: model,
72157
+ title: model,
72158
+ provider: "unknown"
72159
+ } : void 0);
72160
+ }
72010
72161
  const contextItem = "_context-item_13e3r_1";
72011
72162
  const contextItemMetadata = "_context-item-metadata_13e3r_6";
72012
72163
  const contextItemLink = "_context-item-link_13e3r_12";
@@ -72197,8 +72348,8 @@ const ContextCell = memo(
72197
72348
  },
72198
72349
  isEqual
72199
72350
  );
72200
- const userAvatar = "_user-avatar_tzwlo_1";
72201
- const sourcegraphGradientBorder = "_sourcegraph-gradient-border_tzwlo_12";
72351
+ const userAvatar = "_user-avatar_yacrp_1";
72352
+ const sourcegraphGradientBorder = "_sourcegraph-gradient-border_yacrp_10";
72202
72353
  const styles$7 = {
72203
72354
  userAvatar,
72204
72355
  sourcegraphGradientBorder
@@ -72254,8 +72405,9 @@ const InnerUserAvatar = ({
72254
72405
  "div",
72255
72406
  {
72256
72407
  title: title2,
72257
- className: clsx$1(styles$7.userAvatar, className),
72408
+ className: clsx$1(styles$7.userAvatar, "tw-bg-muted tw-text-muted-foreground", className),
72258
72409
  style: { width: `${size2}px`, height: `${size2}px` },
72410
+ "data-user-avatar": true,
72259
72411
  children: /* @__PURE__ */ jsx("span", { className: styles$7.initials, children: getInitials((user == null ? void 0 : user.displayName) || (user == null ? void 0 : user.username) || "") })
72260
72412
  }
72261
72413
  );
@@ -72942,375 +73094,6 @@ const optionByGroup = (options) => {
72942
73094
  }
72943
73095
  return [...groups.entries()].sort(([a2], [b2]) => groupOrder.indexOf(a2) - groupOrder.indexOf(b2)).map(([group, options2]) => ({ group, options: options2 }));
72944
73096
  };
72945
- const useDebounce = (value, delay) => {
72946
- const [debouncedValue, setDebouncedValue] = useState(value);
72947
- useEffect(() => {
72948
- const handler = setTimeout(() => setDebouncedValue(value), delay);
72949
- return () => clearTimeout(handler);
72950
- }, [delay, value]);
72951
- return debouncedValue;
72952
- };
72953
- function usePromptsQuery(query) {
72954
- const prompts = useExtensionAPI().prompts;
72955
- return useObservable(useMemo(() => prompts(query), [prompts, query]));
72956
- }
72957
- const PromptList = ({
72958
- onSelect: parentOnSelect,
72959
- onSelectActionLabels,
72960
- showSearch = true,
72961
- showOnlyPromptInsertableCommands,
72962
- showInitialSelectedItem = true,
72963
- showPromptLibraryUnsupportedMessage = true,
72964
- showCommandOrigins = false,
72965
- className,
72966
- commandListClassName,
72967
- telemetryLocation
72968
- }) => {
72969
- const telemetryRecorder = useTelemetryRecorder();
72970
- const telemetryPublicMetadata = {
72971
- [`in${telemetryLocation}`]: 1
72972
- };
72973
- const [query, setQuery] = useState("");
72974
- const debouncedQuery = useDebounce(query, 250);
72975
- const { value: result, error: error2 } = usePromptsQuery(debouncedQuery);
72976
- const onSelect = useCallback(
72977
- (rowValue) => {
72978
- var _a, _b, _c;
72979
- const prompt = (result == null ? void 0 : result.prompts.type) === "results" ? result.prompts.results.find(
72980
- (p2) => commandRowValue({ type: "prompt", value: p2 }) === rowValue
72981
- ) : void 0;
72982
- const codyCommand = prompt === void 0 ? (_a = result == null ? void 0 : result.commands) == null ? void 0 : _a.find(
72983
- (c2) => commandRowValue({ type: "command", value: c2 }) === rowValue
72984
- ) : void 0;
72985
- const entry = prompt ? { type: "prompt", value: prompt } : codyCommand ? { type: "command", value: codyCommand } : void 0;
72986
- if (!entry) {
72987
- return;
72988
- }
72989
- telemetryRecorder.recordEvent("cody.promptList", "select", {
72990
- metadata: {
72991
- isPrompt: prompt ? 1 : 0,
72992
- isCommand: codyCommand ? 1 : 0,
72993
- isCommandBuiltin: (codyCommand == null ? void 0 : codyCommand.type) === "default" ? 1 : 0,
72994
- isCommandCustom: (codyCommand == null ? void 0 : codyCommand.type) !== "default" ? 1 : 0,
72995
- ...telemetryPublicMetadata
72996
- },
72997
- privateMetadata: {
72998
- nameWithOwner: prompt ? prompt.nameWithOwner : void 0
72999
- }
73000
- });
73001
- if (result) {
73002
- telemetryRecorder.recordEvent("cody.promptList", "query", {
73003
- metadata: {
73004
- queryLength: debouncedQuery.length,
73005
- resultCount: (result.prompts.type === "results" ? result.prompts.results.length : 0) + (((_b = result.commands) == null ? void 0 : _b.length) ?? 0),
73006
- resultCountPromptsOnly: result.prompts.type === "results" ? result.prompts.results.length : 0,
73007
- resultCountCommandsOnly: ((_c = result.commands) == null ? void 0 : _c.length) ?? 0,
73008
- supportsPrompts: result.prompts.type !== "unsupported" ? 1 : 0,
73009
- hasUsePromptsQueryError: error2 ? 1 : 0,
73010
- hasPromptsResultError: result.prompts.type === "error" ? 1 : 0,
73011
- ...telemetryPublicMetadata
73012
- },
73013
- privateMetadata: {
73014
- query: debouncedQuery,
73015
- usePromptsQueryErrorMessage: error2 == null ? void 0 : error2.message,
73016
- promptsResultErrorMessage: result.prompts.type === "error" ? result.prompts.error : void 0
73017
- }
73018
- });
73019
- }
73020
- parentOnSelect(entry);
73021
- },
73022
- [
73023
- result,
73024
- telemetryRecorder.recordEvent,
73025
- parentOnSelect,
73026
- telemetryPublicMetadata,
73027
- debouncedQuery,
73028
- error2
73029
- ]
73030
- );
73031
- const endpointURL = new URL(useConfig().authStatus.endpoint);
73032
- const filteredCommands = showOnlyPromptInsertableCommands ? result == null ? void 0 : result.commands.filter((c2) => c2.type !== "default") : result == null ? void 0 : result.commands;
73033
- return /* @__PURE__ */ jsx(
73034
- Command,
73035
- {
73036
- loop: true,
73037
- tabIndex: 0,
73038
- className: clsx$1("focus:tw-outline-none", className),
73039
- shouldFilter: false,
73040
- defaultValue: showInitialSelectedItem ? void 0 : "xxx-no-item",
73041
- children: /* @__PURE__ */ jsxs(
73042
- CommandList,
73043
- {
73044
- className: clsx$1(
73045
- "[&_[cmdk-group]]:tw-pt-0 [&_[cmdk-group-heading]]:tw-flex [&_[cmdk-group-heading]]:tw-gap-2 [&_[cmdk-group-heading]]:tw-items-center [&_[cmdk-group-heading]]:!tw-min-h-[30px] [&_[cmdk-group-heading]]:tw--mx-2 [&_[cmdk-group-heading]]:tw-px-4 [&_[cmdk-group-heading]]:tw-mb-2 [&_[cmdk-group-heading]]:tw-bg-muted [&_[cmdk-group]]:!tw-border-0",
73046
- commandListClassName
73047
- ),
73048
- children: [
73049
- showSearch && /* @__PURE__ */ jsx(
73050
- CommandInput,
73051
- {
73052
- value: query,
73053
- onValueChange: setQuery,
73054
- placeholder: "Search...",
73055
- autoFocus: true
73056
- }
73057
- ),
73058
- result && result.prompts.type !== "unsupported" && /* @__PURE__ */ jsxs(
73059
- CommandGroup,
73060
- {
73061
- heading: /* @__PURE__ */ jsxs(Fragment, { children: [
73062
- /* @__PURE__ */ jsx("span", { children: "Prompt Library" }),
73063
- /* @__PURE__ */ jsx("div", { className: "tw-flex-grow" }),
73064
- /* @__PURE__ */ jsx(Button3, { variant: "ghost", size: "sm", asChild: true, children: /* @__PURE__ */ jsx(
73065
- "a",
73066
- {
73067
- href: new URL("/prompts", endpointURL).toString(),
73068
- target: "_blank",
73069
- rel: "noreferrer",
73070
- className: "!tw-text-[unset]",
73071
- children: "Manage"
73072
- }
73073
- ) }),
73074
- /* @__PURE__ */ jsx(
73075
- Button3,
73076
- {
73077
- variant: "ghost",
73078
- size: "sm",
73079
- className: "tw-flex tw-items-center tw-gap-0.5",
73080
- asChild: true,
73081
- children: /* @__PURE__ */ jsxs(
73082
- "a",
73083
- {
73084
- href: new URL("/prompts/new", endpointURL).toString(),
73085
- target: "_blank",
73086
- rel: "noreferrer",
73087
- className: "!tw-text-[unset]",
73088
- children: [
73089
- /* @__PURE__ */ jsx(Plus, { size: 12, strokeWidth: 1.25 }),
73090
- "New"
73091
- ]
73092
- }
73093
- )
73094
- }
73095
- )
73096
- ] }),
73097
- children: [
73098
- result.prompts.type === "results" ? /* @__PURE__ */ jsxs(Fragment, { children: [
73099
- result.prompts.results.length === 0 && /* @__PURE__ */ jsx(CommandLoading, { children: result.query === "" ? /* @__PURE__ */ jsxs(Fragment, { children: [
73100
- "Your Prompt Library is empty.",
73101
- " ",
73102
- /* @__PURE__ */ jsx(
73103
- "a",
73104
- {
73105
- href: new URL(
73106
- "/prompts/new",
73107
- endpointURL
73108
- ).toString(),
73109
- target: "_blank",
73110
- rel: "noreferrer",
73111
- children: "Add a prompt"
73112
- }
73113
- ),
73114
- " ",
73115
- "to reuse and share it."
73116
- ] }) : /* @__PURE__ */ jsx(Fragment, { children: "No prompts found" }) }),
73117
- result.prompts.results.map((prompt) => /* @__PURE__ */ jsx(
73118
- PromptCommandItem,
73119
- {
73120
- prompt,
73121
- onSelect,
73122
- selectActionLabel: onSelectActionLabels == null ? void 0 : onSelectActionLabels.prompt
73123
- },
73124
- prompt.id
73125
- ))
73126
- ] }) : null,
73127
- result.prompts.type === "error" && /* @__PURE__ */ jsxs(CommandLoading, { children: [
73128
- "Error: ",
73129
- result.prompts.error
73130
- ] })
73131
- ]
73132
- }
73133
- ),
73134
- result && filteredCommands && filteredCommands.length > 0 && /* @__PURE__ */ jsx(
73135
- CommandGroup,
73136
- {
73137
- heading: /* @__PURE__ */ jsxs(Fragment, { children: [
73138
- /* @__PURE__ */ jsx("span", { children: "Commands" }),
73139
- /* @__PURE__ */ jsx("div", { className: "tw-flex-grow" }),
73140
- hasCustomCommands(filteredCommands) && /* @__PURE__ */ jsx(Button3, { variant: "ghost", size: "sm", asChild: true, children: /* @__PURE__ */ jsx(
73141
- "a",
73142
- {
73143
- className: "!tw-text-[unset]",
73144
- href: "command:cody.menu.commands-settings",
73145
- children: "Manage"
73146
- }
73147
- ) })
73148
- ] }),
73149
- children: filteredCommands.map((command) => /* @__PURE__ */ jsx(
73150
- CodyCommandItem,
73151
- {
73152
- command,
73153
- onSelect,
73154
- selectActionLabel: onSelectActionLabels == null ? void 0 : onSelectActionLabels.command,
73155
- showCommandOrigins
73156
- },
73157
- command.key
73158
- ))
73159
- }
73160
- ),
73161
- showPromptLibraryUnsupportedMessage && result && result.prompts.type === "unsupported" && /* @__PURE__ */ jsxs(Fragment, { children: [
73162
- /* @__PURE__ */ jsx(CommandSeparator, { alwaysRender: true }),
73163
- /* @__PURE__ */ jsxs(CommandLoading, { className: "tw-px-4", children: [
73164
- "Prompt Library is not yet available on ",
73165
- endpointURL.hostname,
73166
- ". Ask your site admin to upgrade to Sourcegraph 5.6 or later."
73167
- ] })
73168
- ] }),
73169
- !result && !error2 && /* @__PURE__ */ jsx(CommandLoading, { className: "tw-px-4", children: "Loading..." }),
73170
- error2 && /* @__PURE__ */ jsxs(CommandLoading, { className: "tw-px-4", children: [
73171
- "Error: ",
73172
- error2.message || "unknown"
73173
- ] })
73174
- ]
73175
- }
73176
- )
73177
- }
73178
- );
73179
- };
73180
- function hasCustomCommands(commands) {
73181
- return commands.some(
73182
- (command) => command.type === CustomCommandType.Workspace || command.type === CustomCommandType.User
73183
- );
73184
- }
73185
- function commandRowValue(row2) {
73186
- return row2.type === "prompt" ? `prompt-${row2.value.id}` : `command-${row2.value.key}`;
73187
- }
73188
- const PromptCommandItem = ({ prompt, onSelect, selectActionLabel }) => /* @__PURE__ */ jsxs(
73189
- CommandItem,
73190
- {
73191
- value: commandRowValue({ type: "prompt", value: prompt }),
73192
- onSelect,
73193
- className: "!tw-items-start tw-group/[cmdk-item]",
73194
- children: [
73195
- /* @__PURE__ */ jsxs("div", { children: [
73196
- /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-gap-3 tw-w-full tw-items-start", children: [
73197
- /* @__PURE__ */ jsxs("span", { children: [
73198
- /* @__PURE__ */ jsxs("span", { className: "tw-text-muted-foreground", children: [
73199
- prompt.owner.namespaceName,
73200
- " / "
73201
- ] }),
73202
- /* @__PURE__ */ jsx("strong", { children: prompt.name })
73203
- ] }),
73204
- prompt.draft && /* @__PURE__ */ jsx(Badge3, { variant: "secondary", className: "tw-text-xxs tw-mt-0.5", children: "Draft" })
73205
- ] }),
73206
- prompt.description && /* @__PURE__ */ jsx("span", { className: "tw-text-xs tw-text-muted-foreground tw-text-nowrap tw-overflow-hidden tw-text-ellipsis tw-w-full", children: prompt.description })
73207
- ] }),
73208
- /* @__PURE__ */ jsx("div", { className: "tw-flex-grow" }),
73209
- selectActionLabel && /* @__PURE__ */ jsx(CommandItemAction, { label: selectActionLabel })
73210
- ]
73211
- }
73212
- );
73213
- const CodyCommandItem = ({ command, onSelect, selectActionLabel, showCommandOrigins }) => /* @__PURE__ */ jsxs(
73214
- CommandItem,
73215
- {
73216
- value: commandRowValue({ type: "command", value: command }),
73217
- onSelect,
73218
- className: "!tw-items-start tw-group/[cmdk-item]",
73219
- children: [
73220
- /* @__PURE__ */ jsxs("div", { children: [
73221
- /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-wrap tw-gap-3 tw-w-full tw-items-start", children: [
73222
- /* @__PURE__ */ jsx("strong", { className: "tw-whitespace-nowrap", children: command.type === "default" ? command.description : command.key }),
73223
- showCommandOrigins && command.type !== "default" && /* @__PURE__ */ jsx(Badge3, { variant: "secondary", className: "tw-text-xxs tw-mt-0.5 tw-whitespace-nowrap", children: command.type === CustomCommandType.User ? "Local User Settings" : "Workspace Settings" })
73224
- ] }),
73225
- command.type !== "default" && command.description && /* @__PURE__ */ jsx("span", { className: "tw-text-xs tw-text-muted-foreground tw-text-nowrap tw-overflow-hidden tw-text-ellipsis tw-w-full", children: command.description })
73226
- ] }),
73227
- /* @__PURE__ */ jsx("div", { className: "tw-flex-grow" }),
73228
- selectActionLabel && /* @__PURE__ */ jsx(CommandItemAction, { label: selectActionLabel })
73229
- ]
73230
- }
73231
- );
73232
- const CommandItemAction = ({
73233
- label,
73234
- className
73235
- }) => /* @__PURE__ */ jsxs(Tooltip, { children: [
73236
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
73237
- Button3,
73238
- {
73239
- type: "button",
73240
- variant: "default",
73241
- size: "xs",
73242
- className: clsx$1(
73243
- 'tw-tracking-tight tw-text-accent-foreground tw-opacity-30 tw-bg-transparent hover:tw-bg-transparent tw-invisible group-[[aria-selected="true"]]/[cmdk-item]:tw-visible group-hover/[cmdk-item]:tw-visible',
73244
- className
73245
- ),
73246
- children: label === "insert" ? "Insert" : "Run"
73247
- }
73248
- ) }),
73249
- /* @__PURE__ */ jsx(TooltipContent, { children: label === "insert" ? "Append prompt text to chat message" : "Run command on current selection in editor" })
73250
- ] });
73251
- const PromptListSuitedForNonPopover = ({ className, commandListClassName, ...props }) => /* @__PURE__ */ jsx(
73252
- PromptList,
73253
- {
73254
- ...props,
73255
- showSearch: false,
73256
- showInitialSelectedItem: false,
73257
- className: clsx$1("tw-w-full !tw-max-w-[unset] !tw-bg-[unset]", className),
73258
- commandListClassName: clsx$1("!tw-max-h-[unset]", commandListClassName)
73259
- }
73260
- );
73261
- const PromptSelectField = ({ onSelect, onCloseByEscape, className, __storybook__open }) => {
73262
- const telemetryRecorder = useTelemetryRecorder();
73263
- const onOpenChange = useCallback(
73264
- (open) => {
73265
- if (open) {
73266
- telemetryRecorder.recordEvent("cody.promptSelectField", "open", {});
73267
- }
73268
- },
73269
- [telemetryRecorder.recordEvent]
73270
- );
73271
- const onKeyDown = useCallback(
73272
- (event) => {
73273
- if (event.key === "Escape") {
73274
- onCloseByEscape == null ? void 0 : onCloseByEscape();
73275
- }
73276
- },
73277
- [onCloseByEscape]
73278
- );
73279
- return /* @__PURE__ */ jsx(
73280
- ToolbarPopoverItem,
73281
- {
73282
- role: "combobox",
73283
- iconEnd: "chevron",
73284
- className: cn("tw-justify-between", className),
73285
- __storybook__open,
73286
- tooltip: "Insert prompt from Prompt Library",
73287
- "aria-label": "Insert prompt",
73288
- popoverContent: (close) => /* @__PURE__ */ jsx(
73289
- PromptList,
73290
- {
73291
- onSelect: (item2) => {
73292
- onSelect(item2);
73293
- close();
73294
- },
73295
- onSelectActionLabels: { prompt: "insert", command: "insert" },
73296
- showSearch: true,
73297
- showOnlyPromptInsertableCommands: true,
73298
- showPromptLibraryUnsupportedMessage: true,
73299
- telemetryLocation: "PromptSelectField"
73300
- }
73301
- ),
73302
- popoverRootProps: { onOpenChange },
73303
- popoverContentProps: {
73304
- className: "tw-min-w-[325px] tw-w-[75vw] tw-max-w-[550px] !tw-p-0",
73305
- onKeyDown,
73306
- onCloseAutoFocus: (event) => {
73307
- event.preventDefault();
73308
- }
73309
- },
73310
- children: "Prompts"
73311
- }
73312
- );
73313
- };
73314
73097
  const isMac = isMacOS();
73315
73098
  function keyTextOrSvg(key) {
73316
73099
  const iconClassName = "tw-w-[1em] tw-h-[1em]";
@@ -73444,7 +73227,6 @@ const Toolbar = ({
73444
73227
  submitState,
73445
73228
  onGapClick,
73446
73229
  focusEditor,
73447
- appendTextToEditor,
73448
73230
  hidden: hidden2,
73449
73231
  className
73450
73232
  }) => {
@@ -73482,14 +73264,6 @@ const Toolbar = ({
73482
73264
  className: "tw-opacity-60 focus-visible:tw-opacity-100 hover:tw-opacity-100 tw-mr-2"
73483
73265
  }
73484
73266
  ),
73485
- /* @__PURE__ */ jsx(
73486
- PromptSelectFieldToolbarItem,
73487
- {
73488
- focusEditor,
73489
- appendTextToEditor,
73490
- className: "tw-ml-1 tw-mr-1"
73491
- }
73492
- ),
73493
73267
  /* @__PURE__ */ jsx(
73494
73268
  ModelSelectFieldToolbarItem,
73495
73269
  {
@@ -73512,31 +73286,25 @@ const Toolbar = ({
73512
73286
  )
73513
73287
  );
73514
73288
  };
73515
- const PromptSelectFieldToolbarItem = ({ focusEditor, appendTextToEditor, className }) => {
73516
- const onSelect = useCallback(
73517
- (item2) => {
73518
- appendTextToEditor(item2.type === "prompt" ? item2.value.definition.text : item2.value.prompt);
73519
- focusEditor == null ? void 0 : focusEditor();
73520
- },
73521
- [appendTextToEditor, focusEditor]
73522
- );
73523
- return /* @__PURE__ */ jsx(PromptSelectField, { onSelect, onCloseByEscape: focusEditor, className });
73524
- };
73525
73289
  const ModelSelectFieldToolbarItem = ({ userInfo, focusEditor, className }) => {
73526
- const { chatModels, onCurrentChatModelChange, serverSentModelsEnabled } = useChatModelContext();
73290
+ const config = useConfig();
73291
+ const api2 = useExtensionAPI();
73527
73292
  const onModelSelect = useCallback(
73528
73293
  (model) => {
73529
- onCurrentChatModelChange == null ? void 0 : onCurrentChatModelChange(model);
73294
+ api2.setChatModel(model.id).subscribe({
73295
+ error: (error2) => console.error("setChatModel:", error2)
73296
+ });
73530
73297
  focusEditor == null ? void 0 : focusEditor();
73531
73298
  },
73532
- [onCurrentChatModelChange, focusEditor]
73299
+ [api2.setChatModel, focusEditor]
73533
73300
  );
73534
- return !!(chatModels == null ? void 0 : chatModels.length) && (userInfo.isDotComUser || serverSentModelsEnabled) && onCurrentChatModelChange && /* @__PURE__ */ jsx(
73301
+ const { value: chatModels } = useObservable(useMemo(() => api2.models(), [api2.models]));
73302
+ return !!(chatModels == null ? void 0 : chatModels.length) && (userInfo.isDotComUser || config.configFeatures.serverSentModels) && /* @__PURE__ */ jsx(
73535
73303
  ModelSelectField,
73536
73304
  {
73537
73305
  models: chatModels,
73538
73306
  onModelSelect,
73539
- serverSentModelsEnabled: !!serverSentModelsEnabled,
73307
+ serverSentModelsEnabled: config.configFeatures.serverSentModels,
73540
73308
  userInfo,
73541
73309
  onCloseByEscape: focusEditor,
73542
73310
  className
@@ -73652,12 +73420,6 @@ const HumanMessageEditor = ({
73652
73420
  },
73653
73421
  [onGapClick]
73654
73422
  );
73655
- const appendTextToEditor = useCallback((text2) => {
73656
- if (!editorRef.current) {
73657
- throw new Error("No editorRef");
73658
- }
73659
- editorRef.current.appendText(text2);
73660
- }, []);
73661
73423
  const onMentionClick = useCallback(() => {
73662
73424
  if (!editorRef.current) {
73663
73425
  throw new Error("No editorRef");
@@ -73697,9 +73459,11 @@ const HumanMessageEditor = ({
73697
73459
  if (isSent) {
73698
73460
  return;
73699
73461
  }
73700
- if (editorRef.current) {
73701
- editorRef.current.appendText(appendTextToLastPromptEditor);
73702
- }
73462
+ requestAnimationFrame(() => {
73463
+ if (editorRef.current) {
73464
+ editorRef.current.appendText(appendTextToLastPromptEditor);
73465
+ }
73466
+ });
73703
73467
  }
73704
73468
  },
73705
73469
  [isSent]
@@ -73772,7 +73536,6 @@ const HumanMessageEditor = ({
73772
73536
  submitState,
73773
73537
  onGapClick,
73774
73538
  focusEditor,
73775
- appendTextToEditor,
73776
73539
  hidden: !focused2 && isSent,
73777
73540
  className: styles$6.toolbar
73778
73541
  }
@@ -73782,6 +73545,11 @@ const HumanMessageEditor = ({
73782
73545
  )
73783
73546
  );
73784
73547
  };
73548
+ function useCurrentChatModel() {
73549
+ var _a;
73550
+ const models = useExtensionAPI().models;
73551
+ return (_a = useObservable(useMemo(() => models(), [models])).value) == null ? void 0 : _a.at(0);
73552
+ }
73785
73553
  const HumanMessageCell = memo(
73786
73554
  ({
73787
73555
  message: message2,
@@ -73817,6 +73585,7 @@ const HumanMessageCell = memo(
73817
73585
  }
73818
73586
  ),
73819
73587
  speakerTitle: userInfo.user.displayName ?? userInfo.user.username,
73588
+ cellAction: isFirstMessage && /* @__PURE__ */ jsx(OpenInNewEditorAction, {}),
73820
73589
  content: /* @__PURE__ */ jsx(
73821
73590
  HumanMessageEditor,
73822
73591
  {
@@ -73843,6 +73612,31 @@ const HumanMessageCell = memo(
73843
73612
  },
73844
73613
  isEqual
73845
73614
  );
73615
+ const OpenInNewEditorAction = () => {
73616
+ const {
73617
+ config: { multipleWebviewsEnabled }
73618
+ } = useConfig();
73619
+ if (!multipleWebviewsEnabled) {
73620
+ return null;
73621
+ }
73622
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
73623
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
73624
+ "button",
73625
+ {
73626
+ type: "button",
73627
+ onClick: () => {
73628
+ getVSCodeAPI().postMessage({
73629
+ command: "command",
73630
+ id: "cody.chat.moveToEditor"
73631
+ });
73632
+ },
73633
+ className: "tw-flex tw-gap-3 tw-items-center tw-leading-none tw-opacity-80 hover:tw-opacity-100 tw-border-b-[1px] tw-border-transparent tw-transition tw-translate-y-[1px]",
73634
+ children: /* @__PURE__ */ jsx(Columns2, { size: 16, strokeWidth: 1.25, className: "tw-w-8 tw-h-8" })
73635
+ }
73636
+ ) }),
73637
+ /* @__PURE__ */ jsx(TooltipContent, { children: "Open in Editor" })
73638
+ ] });
73639
+ };
73846
73640
  const Transcript = (props) => {
73847
73641
  const {
73848
73642
  chatEnabled,
@@ -74116,18 +73910,399 @@ function useCollapsiblePanelOpenState(storageKey, initialOpen = false) {
74116
73910
  }
74117
73911
  ];
74118
73912
  }
73913
+ const MenuExample = ({ children: children2 }) => /* @__PURE__ */ jsx("span", { className: "tw-p-1 tw-rounded tw-border tw-border-keybinding-border tw-bg-keybinding-background tw-whitespace-nowrap", children: children2 });
73914
+ const FeatureRowInlineIcon = ({ Icon: Icon2 }) => /* @__PURE__ */ jsx(Icon2, { size: 16, strokeWidth: 1.25, className: "tw-flex-none tw-inline-flex tw-mt-1 tw-opacity-80" });
73915
+ const FeatureRow = ({ icon: icon2, children: children2 }) => /* @__PURE__ */ jsxs("div", { className: "tw-py-2 tw-px-4 tw-inline-flex tw-gap-3 tw-text-foreground tw-items-start", children: [
73916
+ /* @__PURE__ */ jsx(FeatureRowInlineIcon, { Icon: icon2 }),
73917
+ /* @__PURE__ */ jsx("div", { className: "tw-grow", children: children2 })
73918
+ ] });
73919
+ const localStorageKey = "chat.welcome-message-dismissed";
73920
+ const WelcomeMessage = ({
73921
+ IDE
73922
+ }) => {
73923
+ localStorage.removeItem(localStorageKey);
73924
+ return /* @__PURE__ */ jsx("div", { className: "tw-flex-1 tw-w-full tw-px-6 tw-transition-all", children: /* @__PURE__ */ jsxs(
73925
+ CollapsiblePanel,
73926
+ {
73927
+ storageKey: "chat-help",
73928
+ title: "Chat Help",
73929
+ className: "tw-mb-12 tw-mt-8",
73930
+ initialOpen: true,
73931
+ children: [
73932
+ IDE === CodyIDE.VSCode && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(FeatureRow, { icon: MessageSquarePlus, children: [
73933
+ "Start a new chat using ",
73934
+ /* @__PURE__ */ jsx(Kbd, { macOS: "opt+L", linuxAndWindows: "alt+L" }),
73935
+ " or the command ",
73936
+ /* @__PURE__ */ jsx(MenuExample, { children: "Cody: New Chat" })
73937
+ ] }) }),
73938
+ /* @__PURE__ */ jsxs(FeatureRow, { icon: AtSign, children: [
73939
+ "Type ",
73940
+ /* @__PURE__ */ jsx(Kbd, { macOS: "@", linuxAndWindows: "@" }),
73941
+ " to add context to your chat"
73942
+ ] }),
73943
+ IDE === CodyIDE.VSCode && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(FeatureRow, { icon: Text, children: [
73944
+ "To add code context from an editor, right click and use",
73945
+ " ",
73946
+ /* @__PURE__ */ jsx(MenuExample, { children: "Cody > Add File/Selection to Cody Chat" })
73947
+ ] }) }),
73948
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-justify-center tw-items-center tw-w-full tw-gap-10 tw-px-4 tw-pt-4 tw-pb-3 tw-mt-2 tw-border-t tw-border-button-border tw-transition-all", children: [
73949
+ /* @__PURE__ */ jsx(
73950
+ "a",
73951
+ {
73952
+ href: "https://docs.sourcegraph.com/cody",
73953
+ target: "_blank",
73954
+ rel: "noopener noreferrer",
73955
+ className: "tw-text-muted-foreground hover:tw-text-foreground",
73956
+ children: "Documentation"
73957
+ }
73958
+ ),
73959
+ /* @__PURE__ */ jsx(
73960
+ "a",
73961
+ {
73962
+ href: "https://help.sourcegraph.com",
73963
+ target: "_blank",
73964
+ rel: "noopener noreferrer",
73965
+ className: "tw-text-muted-foreground hover:tw-text-foreground",
73966
+ children: "Help & Support"
73967
+ }
73968
+ )
73969
+ ] })
73970
+ ]
73971
+ }
73972
+ ) });
73973
+ };
73974
+ const MARGIN = 200;
73975
+ function createScrollerAPI(element2) {
73976
+ return {
73977
+ root: element2,
73978
+ getObserveElement: () => element2.firstElementChild,
73979
+ getScrollTop: () => element2.scrollTop,
73980
+ getScrollHeight: () => element2.scrollHeight,
73981
+ getClientHeight: () => element2.getBoundingClientRect().height
73982
+ };
73983
+ }
73984
+ const ScrollDown = (props) => {
73985
+ const { scrollableParent, onClick: parentOnClick } = props;
73986
+ const [canScrollDown, setCanScrollDown] = useState(false);
73987
+ const scrollerAPI = useMemo(() => createScrollerAPI(scrollableParent), [scrollableParent]);
73988
+ useEffect(() => {
73989
+ function calculateScrollState() {
73990
+ const scrollTop = scrollerAPI.getScrollTop();
73991
+ const scrollHeight = scrollerAPI.getScrollHeight();
73992
+ const clientHeight = scrollerAPI.getClientHeight();
73993
+ setCanScrollDown(scrollTop + clientHeight < scrollHeight - MARGIN);
73994
+ }
73995
+ calculateScrollState();
73996
+ const resizeObserver = new ResizeObserver(() => {
73997
+ calculateScrollState();
73998
+ });
73999
+ resizeObserver.observe(scrollerAPI.getObserveElement());
74000
+ scrollerAPI.root.addEventListener("scroll", calculateScrollState);
74001
+ return () => {
74002
+ resizeObserver.disconnect();
74003
+ scrollerAPI.root.removeEventListener("scroll", calculateScrollState);
74004
+ };
74005
+ }, [scrollerAPI]);
74006
+ const onClick = useCallback(() => {
74007
+ setCanScrollDown(false);
74008
+ scrollerAPI.root.scrollTo({
74009
+ top: scrollerAPI.getScrollHeight()
74010
+ });
74011
+ parentOnClick == null ? void 0 : parentOnClick();
74012
+ }, [parentOnClick, scrollerAPI]);
74013
+ return canScrollDown ? /* @__PURE__ */ jsx("div", { className: "tw-sticky tw-bottom-0 tw-w-full tw-text-center tw-py-4", children: /* @__PURE__ */ jsxs(Button3, { variant: "outline", onClick, className: "tw-py-3 hover:tw-bg-primary-hover", children: [
74014
+ /* @__PURE__ */ jsx(ArrowDown, { size: 16 }),
74015
+ " Skip to end"
74016
+ ] }) }) : null;
74017
+ };
74018
+ const useDebounce = (value, delay) => {
74019
+ const [debouncedValue, setDebouncedValue] = useState(value);
74020
+ useEffect(() => {
74021
+ const handler = setTimeout(() => setDebouncedValue(value), delay);
74022
+ return () => clearTimeout(handler);
74023
+ }, [delay, value]);
74024
+ return debouncedValue;
74025
+ };
74026
+ function usePromptsQuery(query) {
74027
+ const prompts = useExtensionAPI().prompts;
74028
+ return useObservable(useMemo(() => prompts(query), [prompts, query]));
74029
+ }
74030
+ const PromptList = ({
74031
+ onSelect: parentOnSelect,
74032
+ onSwitchToPromptsTab,
74033
+ onSelectActionLabels,
74034
+ showSearch = true,
74035
+ showInitialSelectedItem = false,
74036
+ showPromptLibraryUnsupportedMessage = true,
74037
+ showCommandOrigins = false,
74038
+ className,
74039
+ commandListClassName,
74040
+ showSwitchToPromptAction = false,
74041
+ telemetryLocation
74042
+ }) => {
74043
+ var _a;
74044
+ const telemetryRecorder = useTelemetryRecorder();
74045
+ const telemetryPublicMetadata = {
74046
+ [`in${telemetryLocation}`]: 1
74047
+ };
74048
+ const [query, setQuery] = useState("");
74049
+ const debouncedQuery = useDebounce(query, 250);
74050
+ const { value: result, error: error2 } = usePromptsQuery(debouncedQuery);
74051
+ const onSelect = useCallback(
74052
+ (rowValue) => {
74053
+ var _a2, _b, _c;
74054
+ const prompt = (result == null ? void 0 : result.prompts.type) === "results" ? result.prompts.results.find(
74055
+ (p2) => commandRowValue({ type: "prompt", value: p2 }) === rowValue
74056
+ ) : void 0;
74057
+ const codyCommand = prompt === void 0 ? (_a2 = result == null ? void 0 : result.commands) == null ? void 0 : _a2.find(
74058
+ (c2) => commandRowValue({ type: "command", value: c2 }) === rowValue
74059
+ ) : void 0;
74060
+ const entry = prompt ? { type: "prompt", value: prompt } : codyCommand ? { type: "command", value: codyCommand } : void 0;
74061
+ if (!entry) {
74062
+ return;
74063
+ }
74064
+ telemetryRecorder.recordEvent("cody.promptList", "select", {
74065
+ metadata: {
74066
+ isPrompt: prompt ? 1 : 0,
74067
+ isCommand: codyCommand ? 1 : 0,
74068
+ isCommandBuiltin: (codyCommand == null ? void 0 : codyCommand.type) === "default" ? 1 : 0,
74069
+ isCommandCustom: (codyCommand == null ? void 0 : codyCommand.type) !== "default" ? 1 : 0,
74070
+ ...telemetryPublicMetadata
74071
+ },
74072
+ privateMetadata: {
74073
+ nameWithOwner: prompt ? prompt.nameWithOwner : void 0
74074
+ }
74075
+ });
74076
+ if (result) {
74077
+ telemetryRecorder.recordEvent("cody.promptList", "query", {
74078
+ metadata: {
74079
+ queryLength: debouncedQuery.length,
74080
+ resultCount: (result.prompts.type === "results" ? result.prompts.results.length : 0) + (((_b = result.commands) == null ? void 0 : _b.length) ?? 0),
74081
+ resultCountPromptsOnly: result.prompts.type === "results" ? result.prompts.results.length : 0,
74082
+ resultCountCommandsOnly: ((_c = result.commands) == null ? void 0 : _c.length) ?? 0,
74083
+ supportsPrompts: result.prompts.type !== "unsupported" ? 1 : 0,
74084
+ hasUsePromptsQueryError: error2 ? 1 : 0,
74085
+ hasPromptsResultError: result.prompts.type === "error" ? 1 : 0,
74086
+ ...telemetryPublicMetadata
74087
+ },
74088
+ privateMetadata: {
74089
+ query: debouncedQuery,
74090
+ usePromptsQueryErrorMessage: error2 == null ? void 0 : error2.message,
74091
+ promptsResultErrorMessage: result.prompts.type === "error" ? result.prompts.error : void 0
74092
+ }
74093
+ });
74094
+ }
74095
+ parentOnSelect(entry);
74096
+ },
74097
+ [
74098
+ result,
74099
+ telemetryRecorder.recordEvent,
74100
+ parentOnSelect,
74101
+ telemetryPublicMetadata,
74102
+ debouncedQuery,
74103
+ error2
74104
+ ]
74105
+ );
74106
+ const endpointURL = new URL(useConfig().authStatus.endpoint);
74107
+ const itemClassName = "tw-border tw-border-border !tw-rounded-lg !tw-p-4";
74108
+ return /* @__PURE__ */ jsx(
74109
+ Command,
74110
+ {
74111
+ loop: true,
74112
+ tabIndex: 0,
74113
+ className: clsx$1(
74114
+ "!tw-overflow-visible focus:tw-outline-none tw-border-0 !tw-max-w-[unset] tw-w-full !tw-h-[unset] !tw-bg-[unset]",
74115
+ className
74116
+ ),
74117
+ shouldFilter: false,
74118
+ disablePointerSelection: true,
74119
+ defaultValue: showInitialSelectedItem ? void 0 : "xxx-no-item",
74120
+ children: /* @__PURE__ */ jsxs(
74121
+ CommandList,
74122
+ {
74123
+ className: clsx$1(
74124
+ "!tw-max-h-[unset] !tw-overflow-visible [&_[cmdk-group]]:tw-pt-0 [&_[cmdk-group-heading]]:tw-flex [&_[cmdk-group-heading]]:tw-gap-2 [&_[cmdk-group-heading]]:tw-items-center [&_[cmdk-group-heading]]:!tw-min-h-[30px] [&_[cmdk-group-heading]]:tw--mx-2 [&_[cmdk-group-heading]]:tw-px-4 [&_[cmdk-group-heading]]:tw-mb-2 [&_[cmdk-group-heading]]:tw-bg-muted [&_[cmdk-group]]:!tw-border-0",
74125
+ commandListClassName
74126
+ ),
74127
+ children: [
74128
+ showSearch && /* @__PURE__ */ jsx(
74129
+ CommandInput,
74130
+ {
74131
+ value: query,
74132
+ onValueChange: setQuery,
74133
+ placeholder: "Search...",
74134
+ autoFocus: true,
74135
+ wrapperClassName: "!tw-border-0 tw-mb-3 tw-px-2",
74136
+ className: "!tw-border-border tw-rounded-md focus:!tw-border-ring !tw-py-3"
74137
+ }
74138
+ ),
74139
+ result && result.prompts.type !== "unsupported" && /* @__PURE__ */ jsxs(CommandGroup, { className: "[&_[cmdk-group-items]]:tw-space-y-4", children: [
74140
+ result.prompts.type === "results" ? /* @__PURE__ */ jsxs(Fragment, { children: [
74141
+ result.prompts.results.length === 0 && /* @__PURE__ */ jsx(CommandLoading, { children: result.query === "" ? /* @__PURE__ */ jsxs(Fragment, { children: [
74142
+ "Your Prompt Library is empty.",
74143
+ " ",
74144
+ /* @__PURE__ */ jsx(
74145
+ "a",
74146
+ {
74147
+ href: new URL(
74148
+ "/prompts/new",
74149
+ endpointURL
74150
+ ).toString(),
74151
+ target: "_blank",
74152
+ rel: "noreferrer",
74153
+ children: "Add a prompt"
74154
+ }
74155
+ ),
74156
+ " ",
74157
+ "to reuse and share it."
74158
+ ] }) : /* @__PURE__ */ jsx(Fragment, { children: "No prompts found" }) }),
74159
+ result.prompts.results.map((prompt) => /* @__PURE__ */ jsx(
74160
+ PromptCommandItem,
74161
+ {
74162
+ prompt,
74163
+ onSelect,
74164
+ selectActionLabel: onSelectActionLabels == null ? void 0 : onSelectActionLabels.prompt,
74165
+ className: itemClassName
74166
+ },
74167
+ prompt.id
74168
+ )),
74169
+ (_a = result == null ? void 0 : result.commands) == null ? void 0 : _a.map((command) => /* @__PURE__ */ jsx(
74170
+ CodyCommandItem,
74171
+ {
74172
+ command,
74173
+ onSelect,
74174
+ selectActionLabel: onSelectActionLabels == null ? void 0 : onSelectActionLabels.command,
74175
+ showCommandOrigins,
74176
+ className: itemClassName
74177
+ },
74178
+ command.key
74179
+ ))
74180
+ ] }) : null,
74181
+ result.prompts.type === "error" && /* @__PURE__ */ jsxs(CommandLoading, { children: [
74182
+ "Error: ",
74183
+ result.prompts.error
74184
+ ] })
74185
+ ] }),
74186
+ showPromptLibraryUnsupportedMessage && result && result.prompts.type === "unsupported" && /* @__PURE__ */ jsxs(Fragment, { children: [
74187
+ /* @__PURE__ */ jsx(CommandSeparator, { alwaysRender: true }),
74188
+ /* @__PURE__ */ jsxs(CommandLoading, { className: "tw-px-4", children: [
74189
+ "Prompt Library is not yet available on ",
74190
+ endpointURL.hostname,
74191
+ ". Ask your site admin to upgrade to Sourcegraph 5.6 or later."
74192
+ ] })
74193
+ ] }),
74194
+ !result && !error2 && /* @__PURE__ */ jsx(CommandLoading, { className: "tw-px-4", children: "Loading..." }),
74195
+ error2 && /* @__PURE__ */ jsxs(CommandLoading, { className: "tw-px-4", children: [
74196
+ "Error: ",
74197
+ error2.message || "unknown"
74198
+ ] }),
74199
+ showSwitchToPromptAction && /* @__PURE__ */ jsx(CommandRow, { className: "tw-items-center tw-justify-center tw-py-4", children: /* @__PURE__ */ jsx(Button3, { variant: "ghost", size: "sm", asChild: true, children: /* @__PURE__ */ jsx(
74200
+ "button",
74201
+ {
74202
+ type: "button",
74203
+ className: "!tw-text-muted-foreground !hover:tw-text-button-foreground",
74204
+ onClick: onSwitchToPromptsTab,
74205
+ children: "Switch to Prompt Library"
74206
+ }
74207
+ ) }) })
74208
+ ]
74209
+ }
74210
+ )
74211
+ }
74212
+ );
74213
+ };
74214
+ function commandRowValue(row2) {
74215
+ return row2.type === "prompt" ? `prompt-${row2.value.id}` : `command-${row2.value.key}`;
74216
+ }
74217
+ const PromptCommandItem = ({ prompt, onSelect, selectActionLabel, className }) => /* @__PURE__ */ jsxs(
74218
+ CommandItem,
74219
+ {
74220
+ value: commandRowValue({ type: "prompt", value: prompt }),
74221
+ onSelect,
74222
+ className: clsx$1("!tw-items-start tw-overflow-hidden tw-gap-3 tw-group/[cmdk-item]", className),
74223
+ children: [
74224
+ /* @__PURE__ */ jsx(
74225
+ UserAvatar,
74226
+ {
74227
+ user: {
74228
+ username: prompt.owner.namespaceName,
74229
+ displayName: prompt.owner.displayName ?? void 0
74230
+ },
74231
+ size: 22,
74232
+ className: "tw-flex-shrink-0 tw-text-xxs"
74233
+ }
74234
+ ),
74235
+ /* @__PURE__ */ jsxs("div", { className: "tw-text-nowrap tw-text-ellipsis tw-overflow-hidden", children: [
74236
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-text-nowrap tw-gap-3 tw-w-full tw-items-start tw-overflow-hidden", children: [
74237
+ /* @__PURE__ */ jsx("span", { className: "", children: prompt.name }),
74238
+ prompt.draft && /* @__PURE__ */ jsx(Badge3, { variant: "secondary", className: "tw-text-xxs tw-mt-0.5", children: "Draft" })
74239
+ ] }),
74240
+ prompt.description && /* @__PURE__ */ jsx("span", { className: "tw-text-muted-foreground tw-w-full", children: prompt.description })
74241
+ ] })
74242
+ ]
74243
+ }
74244
+ );
74245
+ const CodyCommandItem = ({ command, onSelect, selectActionLabel, showCommandOrigins, className }) => /* @__PURE__ */ jsxs(
74246
+ CommandItem,
74247
+ {
74248
+ value: commandRowValue({ type: "command", value: command }),
74249
+ onSelect,
74250
+ className: clsx$1("!tw-items-start tw-overflow-hidden tw-gap-3 tw-group/[cmdk-item]", className),
74251
+ children: [
74252
+ /* @__PURE__ */ jsx("div", { className: "tw-w-[22px] tw-flex-shrink-0", children: /* @__PURE__ */ jsx(
74253
+ CommandItemIcon,
74254
+ {
74255
+ command,
74256
+ size: 13,
74257
+ className: "tw-text-muted-foreground tw-mt-2 tw-mx-auto"
74258
+ }
74259
+ ) }),
74260
+ /* @__PURE__ */ jsxs("div", { className: "tw-text-nowrap tw-text-ellipsis tw-overflow-hidden", children: [
74261
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-wrap tw-gap-3 tw-w-full tw-items-start", children: [
74262
+ /* @__PURE__ */ jsx("span", { className: "tw-whitespace-nowrap", children: command.type === "default" ? command.description : command.key }),
74263
+ showCommandOrigins && command.type !== "default" && /* @__PURE__ */ jsx(Badge3, { variant: "secondary", className: "tw-text-xxs tw-mt-0.5 tw-whitespace-nowrap", children: "Custom Command" })
74264
+ ] }),
74265
+ command.type !== "default" && command.description && /* @__PURE__ */ jsx("span", { className: "tw-text-xs tw-text-muted-foreground tw-text-nowrap tw-overflow-hidden tw-text-ellipsis tw-w-full", children: command.description })
74266
+ ] })
74267
+ ]
74268
+ }
74269
+ );
74270
+ const CommandItemIcon = ({
74271
+ command,
74272
+ size: size2,
74273
+ className
74274
+ }) => {
74275
+ const Icon2 = iconForCommand(command);
74276
+ return /* @__PURE__ */ jsx(Icon2, { size: size2, className });
74277
+ };
74278
+ function iconForCommand(command) {
74279
+ var _a;
74280
+ return ((_a = ICON_KEYWORDS.find((icon2) => command.key.toLowerCase().includes(icon2.keyword))) == null ? void 0 : _a.icon) ?? Play;
74281
+ }
74282
+ const ICON_KEYWORDS = [
74283
+ { keyword: "edit", icon: Pencil },
74284
+ { keyword: "doc", icon: BookOpen },
74285
+ { keyword: "explain", icon: FileQuestion },
74286
+ { keyword: "test", icon: Hammer },
74287
+ { keyword: "fix", icon: Bug },
74288
+ { keyword: "debug", icon: Bug },
74289
+ { keyword: "secur", icon: ShieldCheck },
74290
+ { keyword: "refactor", icon: Combine },
74291
+ { keyword: "review", icon: MessageCircleCode }
74292
+ ];
74119
74293
  const PromptsTab = ({ setView }) => {
74120
74294
  const dispatchClientAction = useClientActionDispatcher();
74121
74295
  return /* @__PURE__ */ jsx("div", { className: "tw-overflow-auto tw-p-8", children: /* @__PURE__ */ jsx(
74122
- PromptListSuitedForNonPopover,
74296
+ PromptList,
74123
74297
  {
74124
74298
  onSelect: (item2) => onPromptSelectInPanel(item2, setView, dispatchClientAction),
74125
74299
  onSelectActionLabels: onPromptSelectInPanelActionLabels,
74126
74300
  showCommandOrigins: true,
74301
+ showSearch: true,
74302
+ showInitialSelectedItem: false,
74303
+ showSwitchToPromptAction: false,
74127
74304
  showPromptLibraryUnsupportedMessage: true,
74128
- showOnlyPromptInsertableCommands: false,
74129
- telemetryLocation: "PromptsTab",
74130
- className: "tw-border tw-border-border"
74305
+ telemetryLocation: "PromptsTab"
74131
74306
  }
74132
74307
  ) });
74133
74308
  };
@@ -74160,273 +74335,216 @@ const onPromptSelectInPanelActionLabels = {
74160
74335
  command: "run",
74161
74336
  prompt: "insert"
74162
74337
  };
74163
- const MenuExample = ({ children: children2 }) => /* @__PURE__ */ jsx("span", { className: "tw-p-1 tw-rounded tw-text-keybinding-foreground tw-border tw-border-keybinding-border tw-bg-keybinding-background tw-whitespace-nowrap", children: children2 });
74164
- const FeatureRowInlineIcon = ({ Icon: Icon2 }) => /* @__PURE__ */ jsx(Icon2, { size: 16, strokeWidth: 1.25, className: "tw-flex-none tw-inline-flex tw-mt-1 tw-opacity-80" });
74165
- const FeatureRow = ({ icon: icon2, children: children2 }) => /* @__PURE__ */ jsxs("div", { className: "tw-py-2 tw-px-4 tw-inline-flex tw-gap-3 tw-text-foreground tw-items-start", children: [
74166
- /* @__PURE__ */ jsx(FeatureRowInlineIcon, { Icon: icon2 }),
74167
- /* @__PURE__ */ jsx("div", { className: "tw-grow", children: children2 })
74168
- ] });
74169
- const localStorageKey = "chat.welcome-message-dismissed";
74170
- const WelcomeMessage = ({
74171
- IDE,
74172
- setView
74173
- }) => {
74174
- localStorage.removeItem(localStorageKey);
74175
- const dispatchClientAction = useClientActionDispatcher();
74176
- return /* @__PURE__ */ jsxs("div", { className: "tw-flex-1 tw-flex tw-flex-col tw-items-start tw-w-full tw-px-6 tw-gap-6 tw-transition-all", children: [
74177
- /* @__PURE__ */ jsx(
74178
- CollapsiblePanel,
74179
- {
74180
- storageKey: "prompts",
74181
- title: "Prompts & Commands",
74182
- className: "tw-mb-6",
74183
- contentClassName: "!tw-p-0 tw-overflow-clip",
74184
- initialOpen: true,
74185
- children: /* @__PURE__ */ jsx(
74186
- PromptListSuitedForNonPopover,
74187
- {
74188
- onSelect: (item2) => onPromptSelectInPanel(item2, setView, dispatchClientAction),
74189
- onSelectActionLabels: onPromptSelectInPanelActionLabels,
74190
- telemetryLocation: "PromptsTab",
74191
- showCommandOrigins: true,
74192
- showPromptLibraryUnsupportedMessage: false,
74193
- showOnlyPromptInsertableCommands: false,
74194
- className: "tw-rounded-none"
74195
- }
74196
- )
74338
+ const AccountTab = () => {
74339
+ const userInfo = useUserAccountInfo();
74340
+ const { user, isCodyProUser: isCodyProUser2, isDotComUser, ide } = userInfo;
74341
+ const { displayName, username, primaryEmail, endpoint } = user;
74342
+ if (ide === CodyIDE.VSCode) {
74343
+ return null;
74344
+ }
74345
+ const actions2 = [];
74346
+ actions2.push({
74347
+ text: "Switch Account...",
74348
+ onClick: useCallback(() => {
74349
+ if (userInfo.user.username) {
74350
+ getVSCodeAPI().postMessage({ command: "command", id: "cody.auth.switchAccount" });
74197
74351
  }
74198
- ),
74199
- /* @__PURE__ */ jsxs(
74200
- CollapsiblePanel,
74352
+ }, [userInfo])
74353
+ });
74354
+ if (isDotComUser) {
74355
+ actions2.push({
74356
+ text: "Manage Account",
74357
+ onClick: useCallback(() => {
74358
+ if (userInfo.user.username) {
74359
+ const uri = URI.parse(ACCOUNT_USAGE_URL.toString()).with({
74360
+ query: `cody_client_user=${encodeURIComponent(userInfo.user.username)}`
74361
+ });
74362
+ getVSCodeAPI().postMessage({ command: "links", value: uri.toString() });
74363
+ }
74364
+ }, [userInfo])
74365
+ });
74366
+ }
74367
+ actions2.push({
74368
+ text: "Settings",
74369
+ onClick: () => getVSCodeAPI().postMessage({ command: "command", id: "cody.status-bar.interacted" })
74370
+ });
74371
+ actions2.push({
74372
+ text: "Sign Out",
74373
+ onClick: () => getVSCodeAPI().postMessage({ command: "auth", authKind: "signout" })
74374
+ });
74375
+ return /* @__PURE__ */ jsxs("div", { className: "tw-overflow-auto tw-flex-1 tw-flex tw-flex-col tw-items-start tw-w-full tw-px-8 tw-py-6 tw-gap-6", children: [
74376
+ /* @__PURE__ */ jsx("h2", { children: "Account" }),
74377
+ /* @__PURE__ */ jsxs("div", { className: "tw-w-full tw-px-8 tw-py-4 tw-flex tw-flex-col tw-gap-4 tw-bg-popover tw-border tw-border-border tw-rounded-lg", children: [
74378
+ /* @__PURE__ */ jsx("div", { className: "tw-flex tw-justify-between tw-w-full tw-border-b tw-border-border tw-shadow-lg tw-shadow-border-500/50 tw-p-4 tw-pb-6", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-self-stretch", children: [
74379
+ /* @__PURE__ */ jsx(UserAvatar, { user, size: MESSAGE_CELL_AVATAR_SIZE }),
74380
+ /* @__PURE__ */ jsxs("div", { className: "tw-ml-4", children: [
74381
+ /* @__PURE__ */ jsx("p", { className: "tw-text-lg tw-font-semibold", children: displayName ?? username }),
74382
+ /* @__PURE__ */ jsx("p", { className: "tw-text-sm tw-text-muted-foreground", children: primaryEmail })
74383
+ ] })
74384
+ ] }) }),
74385
+ /* @__PURE__ */ jsxs("div", { className: "tw-grid tw-grid-cols-5 tw-gap-4", children: [
74386
+ /* @__PURE__ */ jsx("div", { children: "Plan:" }),
74387
+ /* @__PURE__ */ jsx("div", { className: "tw-text-muted-foreground tw-col-span-4", children: isDotComUser ? isCodyProUser2 ? "Cody Pro" : "Cody Free" : "Enterprise" }),
74388
+ /* @__PURE__ */ jsx("div", { children: "Endpoint:" }),
74389
+ /* @__PURE__ */ jsx("div", { className: "tw-text-muted-foreground tw-col-span-4", children: endpoint })
74390
+ ] })
74391
+ ] }),
74392
+ actions2.map((a2) => /* @__PURE__ */ jsx(
74393
+ Button3,
74201
74394
  {
74202
- storageKey: "chat-help",
74203
- title: "Chat Help",
74204
- className: "tw-mb-6 tw-mt-2",
74205
- initialOpen: true,
74206
- children: [
74207
- /* @__PURE__ */ jsxs(FeatureRow, { icon: AtSign, children: [
74208
- "Type ",
74209
- /* @__PURE__ */ jsx(Kbd, { macOS: "@", linuxAndWindows: "@" }),
74210
- " to add context to your chat"
74211
- ] }),
74212
- IDE === CodyIDE.VSCode && /* @__PURE__ */ jsxs(Fragment, { children: [
74213
- /* @__PURE__ */ jsxs(FeatureRow, { icon: Text, children: [
74214
- "To add code context from an editor, right click and use",
74215
- " ",
74216
- /* @__PURE__ */ jsx(MenuExample, { children: "Cody > Add File/Selection to Cody Chat" })
74217
- ] }),
74218
- /* @__PURE__ */ jsxs(FeatureRow, { icon: MessageSquarePlus, children: [
74219
- "Start a new chat using ",
74220
- /* @__PURE__ */ jsx(Kbd, { macOS: "opt+L", linuxAndWindows: "alt+L" })
74221
- ] }),
74222
- /* @__PURE__ */ jsxs(FeatureRow, { icon: Settings, children: [
74223
- "Customize chat settings with the ",
74224
- /* @__PURE__ */ jsx(FeatureRowInlineIcon, { Icon: Settings }),
74225
- " ",
74226
- "button, or see the",
74227
- " ",
74228
- /* @__PURE__ */ jsx("a", { href: "https://sourcegraph.com/docs/cody", children: "documentation" })
74229
- ] })
74230
- ] })
74231
- ]
74232
- }
74233
- )
74395
+ variant: "secondary",
74396
+ className: "tw-w-full tw-bg-popover tw-border tw-border-border",
74397
+ onClick: a2.onClick,
74398
+ title: a2.text,
74399
+ children: a2.text
74400
+ },
74401
+ a2.text
74402
+ ))
74234
74403
  ] });
74235
74404
  };
74236
- const MARGIN = 200;
74237
- function createScrollerAPI(element2) {
74238
- return {
74239
- root: element2,
74240
- getObserveElement: () => element2.firstElementChild,
74241
- getScrollTop: () => element2.scrollTop,
74242
- getScrollHeight: () => element2.scrollHeight,
74243
- getClientHeight: () => element2.getBoundingClientRect().height
74244
- };
74405
+ function getCreateNewChatCommand(options) {
74406
+ const { IDE, webviewType, multipleWebviewsEnabled } = options;
74407
+ return IDE === CodyIDE.Web ? "cody.chat.new" : webviewType === "sidebar" || !multipleWebviewsEnabled ? "cody.chat.newPanel" : "cody.chat.newEditorPanel";
74245
74408
  }
74246
- const ScrollDown = (props) => {
74247
- const { scrollableParent, onClick: parentOnClick } = props;
74248
- const [canScrollDown, setCanScrollDown] = useState(false);
74249
- const scrollerAPI = useMemo(() => createScrollerAPI(scrollableParent), [scrollableParent]);
74250
- useEffect(() => {
74251
- function calculateScrollState() {
74252
- const scrollTop = scrollerAPI.getScrollTop();
74253
- const scrollHeight = scrollerAPI.getScrollHeight();
74254
- const clientHeight = scrollerAPI.getClientHeight();
74255
- setCanScrollDown(scrollTop + clientHeight < scrollHeight - MARGIN);
74256
- }
74257
- calculateScrollState();
74258
- const resizeObserver = new ResizeObserver(() => {
74259
- calculateScrollState();
74260
- });
74261
- resizeObserver.observe(scrollerAPI.getObserveElement());
74262
- scrollerAPI.root.addEventListener("scroll", calculateScrollState);
74263
- return () => {
74264
- resizeObserver.disconnect();
74265
- scrollerAPI.root.removeEventListener("scroll", calculateScrollState);
74266
- };
74267
- }, [scrollerAPI]);
74268
- const onClick = useCallback(() => {
74269
- setCanScrollDown(false);
74270
- scrollerAPI.root.scrollTo({
74271
- top: scrollerAPI.getScrollHeight()
74272
- });
74273
- parentOnClick == null ? void 0 : parentOnClick();
74274
- }, [parentOnClick, scrollerAPI]);
74275
- return canScrollDown ? /* @__PURE__ */ jsx("div", { className: "tw-sticky tw-bottom-0 tw-w-full tw-text-center tw-py-4", children: /* @__PURE__ */ jsxs(Button3, { variant: "outline", onClick, className: "tw-py-3 hover:tw-bg-primary-hover", children: [
74276
- /* @__PURE__ */ jsx(ArrowDown, { size: 16 }),
74277
- " Skip to end"
74278
- ] }) }) : null;
74279
- };
74280
- const Chat = ({
74281
- messageInProgress,
74282
- transcript,
74283
- vscodeAPI,
74284
- isTranscriptError,
74285
- chatEnabled = true,
74286
- guardrails,
74287
- scrollableParent,
74288
- showWelcomeMessage = true,
74289
- showIDESnippetActions = true,
74290
- setView,
74291
- smartApplyEnabled
74409
+ const HistoryTab = ({
74410
+ userHistory,
74411
+ IDE,
74412
+ webviewType,
74413
+ multipleWebviewsEnabled,
74414
+ setView
74292
74415
  }) => {
74293
- const telemetryRecorder = useTelemetryRecorder();
74294
- const transcriptRef = useRef(transcript);
74295
- transcriptRef.current = transcript;
74296
- const userInfo = useUserAccountInfo();
74297
- const feedbackButtonsOnSubmit = useCallback(
74298
- (text2) => {
74299
- var _a, _b;
74300
- let FeedbackType;
74301
- ((FeedbackType2) => {
74302
- FeedbackType2[FeedbackType2["thumbsUp"] = 1] = "thumbsUp";
74303
- FeedbackType2[FeedbackType2["thumbsDown"] = 0] = "thumbsDown";
74304
- })(FeedbackType || (FeedbackType = {}));
74305
- telemetryRecorder.recordEvent("cody.feedback", "submit", {
74306
- metadata: {
74307
- feedbackType: text2 === "thumbsUp" ? 1 : 0,
74308
- lastChatUsedEmbeddings: ((_b = (_a = transcriptRef.current.at(-1)) == null ? void 0 : _a.contextFiles) == null ? void 0 : _b.some((file) => file.source === "embeddings")) ? 1 : 0,
74309
- recordsPrivateMetadataTranscript: userInfo.isDotComUser ? 1 : 0
74310
- },
74311
- privateMetadata: {
74312
- FeedbackText: text2,
74313
- // 🚨 SECURITY: chat transcripts are to be included only for DotCom users AND for V2 telemetry
74314
- // V2 telemetry exports privateMetadata only for DotCom users
74315
- // the condition below is an aditional safegaurd measure
74316
- responseText: userInfo.isDotComUser ? truncateTextStart(transcriptRef.current.toString(), CHAT_INPUT_TOKEN_BUDGET) : ""
74317
- }
74318
- });
74319
- },
74320
- [userInfo, telemetryRecorder]
74321
- );
74322
- const copyButtonOnSubmit = useCallback(
74323
- (text2, eventType = "Button") => {
74324
- const op = "copy";
74325
- const code2 = eventType === "Button" ? text2.replace(/\n$/, "") : text2;
74326
- vscodeAPI.postMessage({
74327
- command: op,
74328
- eventType,
74329
- text: code2
74330
- });
74331
- },
74332
- [vscodeAPI]
74416
+ const chatByPeriod = useMemo(
74417
+ () => userHistory.filter((chat2) => chat2.interactions.length).reverse().reduce((acc, chat2) => {
74418
+ const period = getRelativeChatPeriod(new Date(chat2.lastInteractionTimestamp));
74419
+ acc.set(period, [...acc.get(period) || [], chat2]);
74420
+ return acc;
74421
+ }, /* @__PURE__ */ new Map()),
74422
+ [userHistory]
74333
74423
  );
74334
- const insertButtonOnSubmit = useMemo(() => {
74335
- if (showIDESnippetActions) {
74336
- return (text2, newFile = false) => {
74337
- const op = newFile ? "newFile" : "insert";
74338
- vscodeAPI.postMessage({
74339
- command: op,
74340
- // remove the additional /n added by the text area at the end of the text
74341
- text: text2.replace(/\n$/, "")
74342
- });
74343
- };
74344
- }
74345
- return;
74346
- }, [vscodeAPI, showIDESnippetActions]);
74347
- const smartApply = useMemo(() => {
74348
- if (!showIDESnippetActions) {
74349
- return;
74350
- }
74351
- return {
74352
- onSubmit: (id2, text2, instruction, fileName) => {
74353
- vscodeAPI.postMessage({
74354
- command: "smartApplySubmit",
74355
- id: id2,
74356
- instruction: instruction == null ? void 0 : instruction.toString(),
74357
- // remove the additional /n added by the text area at the end of the text
74358
- code: text2.replace(/\n$/, ""),
74359
- fileName
74360
- });
74361
- },
74362
- onAccept: (id2) => {
74363
- vscodeAPI.postMessage({
74364
- command: "smartApplyAccept",
74365
- id: id2
74366
- });
74367
- },
74368
- onReject: (id2) => {
74369
- vscodeAPI.postMessage({
74370
- command: "smartApplyReject",
74371
- id: id2
74424
+ const onDeleteButtonClick = useCallback(
74425
+ (id2) => {
74426
+ if (userHistory.find((chat2) => chat2.id === id2)) {
74427
+ getVSCodeAPI().postMessage({
74428
+ command: "command",
74429
+ id: "cody.chat.history.clear",
74430
+ arg: id2
74372
74431
  });
74373
74432
  }
74374
- };
74375
- }, [vscodeAPI, showIDESnippetActions]);
74376
- const postMessage = useCallback((msg) => vscodeAPI.postMessage(msg), [vscodeAPI]);
74377
- useEffect(() => {
74378
- function handleKeyDown(event) {
74379
- if (event.key === "Escape" && messageInProgress) {
74380
- vscodeAPI.postMessage({ command: "abort" });
74381
- }
74382
- if (event.metaKey && event.key === "o") {
74383
- event.preventDefault();
74384
- event.stopPropagation();
74385
- }
74386
- }
74387
- window.addEventListener("keydown", handleKeyDown);
74388
- return () => {
74389
- window.removeEventListener("keydown", handleKeyDown);
74390
- };
74391
- }, [vscodeAPI, messageInProgress]);
74392
- useEffect(() => {
74393
- const onFocus = () => {
74394
- const sel = window.getSelection();
74395
- const focusNode = sel == null ? void 0 : sel.focusNode;
74396
- const focusElement = focusNode instanceof Element ? focusNode : focusNode == null ? void 0 : focusNode.parentElement;
74397
- const focusEditor = focusElement == null ? void 0 : focusElement.closest('[data-lexical-editor="true"]');
74398
- if (focusEditor) {
74399
- focusEditor.focus({ preventScroll: true });
74400
- }
74401
- };
74402
- window.addEventListener("focus", onFocus);
74403
- return () => {
74404
- window.removeEventListener("focus", onFocus);
74405
- };
74406
- }, []);
74407
- return /* @__PURE__ */ jsxs(Fragment, { children: [
74408
- !chatEnabled && /* @__PURE__ */ jsx("div", { className: styles$3.chatDisabled, children: "Cody chat is disabled by your Sourcegraph site administrator" }),
74409
- /* @__PURE__ */ jsx(
74410
- Transcript,
74433
+ },
74434
+ [userHistory]
74435
+ );
74436
+ const handleStartNewChat = () => {
74437
+ getVSCodeAPI().postMessage({
74438
+ command: "command",
74439
+ id: getCreateNewChatCommand({ IDE, webviewType, multipleWebviewsEnabled })
74440
+ });
74441
+ setView(View.Chat);
74442
+ };
74443
+ const chats = Array.from(chatByPeriod);
74444
+ return /* @__PURE__ */ jsxs("div", { className: "tw-px-8 tw-pt-6 tw-pb-12 tw-flex tw-flex-col tw-gap-10", children: [
74445
+ chats.map(([period, chats2]) => /* @__PURE__ */ jsx(
74446
+ CollapsiblePanel,
74411
74447
  {
74412
- transcript,
74413
- messageInProgress,
74414
- feedbackButtonsOnSubmit,
74415
- copyButtonOnSubmit,
74416
- insertButtonOnSubmit,
74417
- smartApply,
74418
- isTranscriptError,
74419
- userInfo,
74420
- chatEnabled,
74421
- postMessage,
74422
- guardrails,
74423
- smartApplyEnabled
74424
- }
74425
- ),
74426
- transcript.length === 0 && showWelcomeMessage && /* @__PURE__ */ jsx(WelcomeMessage, { IDE: userInfo.ide, setView }),
74427
- scrollableParent && /* @__PURE__ */ jsx(ScrollDown, { scrollableParent, onClick: focusLastHumanMessageEditor })
74448
+ storageKey: `history.${period}`,
74449
+ title: period,
74450
+ initialOpen: true,
74451
+ children: chats2.map(({ interactions, id: id2 }) => {
74452
+ var _a, _b, _c;
74453
+ const lastMessage = (_c = (_b = (_a = interactions[interactions.length - 1]) == null ? void 0 : _a.humanMessage) == null ? void 0 : _b.text) == null ? void 0 : _c.trim();
74454
+ return /* @__PURE__ */ jsxs("div", { className: "tw-inline-flex tw-justify-between", children: [
74455
+ /* @__PURE__ */ jsxs(
74456
+ Button3,
74457
+ {
74458
+ variant: "ghost",
74459
+ title: lastMessage,
74460
+ onClick: () => getVSCodeAPI().postMessage({
74461
+ command: "restoreHistory",
74462
+ chatID: id2
74463
+ }),
74464
+ className: "tw-text-left tw-truncate tw-w-full",
74465
+ children: [
74466
+ /* @__PURE__ */ jsx(
74467
+ MessageSquareText,
74468
+ {
74469
+ className: "tw-w-8 tw-h-8 tw-opacity-80",
74470
+ size: 16,
74471
+ strokeWidth: "1.25"
74472
+ }
74473
+ ),
74474
+ /* @__PURE__ */ jsx("span", { className: "tw-truncate tw-w-full", children: lastMessage })
74475
+ ]
74476
+ },
74477
+ id2
74478
+ ),
74479
+ /* @__PURE__ */ jsx(
74480
+ Button3,
74481
+ {
74482
+ variant: "ghost",
74483
+ title: "Delete chat",
74484
+ onClick: () => onDeleteButtonClick(id2),
74485
+ children: /* @__PURE__ */ jsx(
74486
+ Trash,
74487
+ {
74488
+ className: "tw-w-8 tw-h-8 tw-opacity-80",
74489
+ size: 16,
74490
+ strokeWidth: "1.25"
74491
+ }
74492
+ )
74493
+ },
74494
+ id2
74495
+ )
74496
+ ] }, id2);
74497
+ })
74498
+ },
74499
+ period
74500
+ )),
74501
+ chats.length === 0 && /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-col tw-items-center tw-mt-6", children: [
74502
+ /* @__PURE__ */ jsx(
74503
+ History,
74504
+ {
74505
+ size: 20,
74506
+ strokeWidth: 1.25,
74507
+ className: "tw-mb-5 tw-text-muted-foreground"
74508
+ }
74509
+ ),
74510
+ /* @__PURE__ */ jsx("span", { className: "tw-text-lg tw-mb-4 tw-text-muted-foreground", children: "You have no chat history" }),
74511
+ /* @__PURE__ */ jsxs("span", { className: "tw-text-sm tw-text-muted-foreground tw-mb-8", children: [
74512
+ "Explore all your previous chats here. Track and ",
74513
+ /* @__PURE__ */ jsx("br", {}),
74514
+ " search through what you’ve been working on."
74515
+ ] }),
74516
+ /* @__PURE__ */ jsxs(
74517
+ Button3,
74518
+ {
74519
+ size: "sm",
74520
+ variant: "secondary",
74521
+ "aria-label": "Start a new chat",
74522
+ className: "tw-px-4 tw-py-2",
74523
+ onClick: handleStartNewChat,
74524
+ children: [
74525
+ /* @__PURE__ */ jsx(MessageSquarePlus, { size: 16, className: "tw-w-8 tw-h-8", strokeWidth: 1.25 }),
74526
+ "Start a new chat"
74527
+ ]
74528
+ }
74529
+ )
74530
+ ] })
74428
74531
  ] });
74429
74532
  };
74533
+ const SettingsTab = () => {
74534
+ return /* @__PURE__ */ jsx("div", { className: "tw-overflow-auto tw-flex tw-flex-col tw-gap-4 tw-px-8 tw-mt-4", children: /* @__PURE__ */ jsx(
74535
+ Button3,
74536
+ {
74537
+ variant: "secondary",
74538
+ className: "tw-w-full tw-bg-popover",
74539
+ onClick: () => getVSCodeAPI().postMessage({
74540
+ command: "command",
74541
+ id: "cody.status-bar.interacted"
74542
+ }),
74543
+ children: "Cody Settings"
74544
+ },
74545
+ "settings"
74546
+ ) });
74547
+ };
74430
74548
  var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
74431
74549
  var EVENT_OPTIONS = { bubbles: false, cancelable: true };
74432
74550
  var GROUP_NAME = "RovingFocusGroup";
@@ -74806,245 +74924,24 @@ var Root2 = Tabs2;
74806
74924
  var List = TabsList;
74807
74925
  var Trigger = TabsTrigger;
74808
74926
  var Content = TabsContent;
74809
- const TabRoot = React__default.forwardRef(({ className, ...props }, ref2) => {
74810
- return /* @__PURE__ */ jsx(Root2, { ref: ref2, ...props, orientation: "vertical", className });
74811
- });
74812
- const TabContainer = React__default.forwardRef(({ className, ...props }, ref2) => {
74813
- return /* @__PURE__ */ jsx(
74814
- Content,
74815
- {
74816
- ref: ref2,
74817
- ...props,
74818
- className: "tw-h-full tw-flex tw-flex-col tw-overflow-auto tw-gap-4"
74819
- }
74820
- );
74821
- });
74822
- const AccountTab = () => {
74823
- const userInfo = useUserAccountInfo();
74824
- const { user, isCodyProUser: isCodyProUser2, isDotComUser, ide } = userInfo;
74825
- const { displayName, username, primaryEmail, endpoint } = user;
74826
- if (ide === CodyIDE.VSCode) {
74827
- return null;
74828
- }
74829
- const actions2 = [];
74830
- actions2.push({
74831
- text: "Switch Account...",
74832
- onClick: useCallback(() => {
74833
- if (userInfo.user.username) {
74834
- getVSCodeAPI().postMessage({ command: "command", id: "cody.auth.switchAccount" });
74835
- }
74836
- }, [userInfo])
74837
- });
74838
- if (isDotComUser) {
74839
- actions2.push({
74840
- text: "Manage Account",
74841
- onClick: useCallback(() => {
74842
- if (userInfo.user.username) {
74843
- const uri = URI.parse(ACCOUNT_USAGE_URL.toString()).with({
74844
- query: `cody_client_user=${encodeURIComponent(userInfo.user.username)}`
74845
- });
74846
- getVSCodeAPI().postMessage({ command: "links", value: uri.toString() });
74847
- }
74848
- }, [userInfo])
74849
- });
74850
- }
74851
- actions2.push({
74852
- text: "Settings",
74853
- onClick: () => getVSCodeAPI().postMessage({ command: "command", id: "cody.status-bar.interacted" })
74854
- });
74855
- actions2.push({
74856
- text: "Sign Out",
74857
- onClick: () => getVSCodeAPI().postMessage({ command: "auth", authKind: "signout" })
74858
- });
74859
- return /* @__PURE__ */ jsxs("div", { className: "tw-overflow-auto tw-flex-1 tw-flex tw-flex-col tw-items-start tw-w-full tw-px-8 tw-py-6 tw-gap-6", children: [
74860
- /* @__PURE__ */ jsx("h2", { children: "Account" }),
74861
- /* @__PURE__ */ jsxs("div", { className: "tw-w-full tw-px-8 tw-py-4 tw-flex tw-flex-col tw-gap-4 tw-bg-popover tw-border tw-border-border tw-rounded-lg", children: [
74862
- /* @__PURE__ */ jsx("div", { className: "tw-flex tw-justify-between tw-w-full tw-border-b tw-border-border tw-shadow-lg tw-shadow-border-500/50 tw-p-4 tw-pb-6", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-self-stretch", children: [
74863
- /* @__PURE__ */ jsx(UserAvatar, { user, size: MESSAGE_CELL_AVATAR_SIZE }),
74864
- /* @__PURE__ */ jsxs("div", { className: "tw-ml-4", children: [
74865
- /* @__PURE__ */ jsx("p", { className: "tw-text-lg tw-font-semibold", children: displayName ?? username }),
74866
- /* @__PURE__ */ jsx("p", { className: "tw-text-sm tw-text-muted-foreground", children: primaryEmail })
74867
- ] })
74868
- ] }) }),
74869
- /* @__PURE__ */ jsxs("div", { className: "tw-grid tw-grid-cols-5 tw-gap-4", children: [
74870
- /* @__PURE__ */ jsx("div", { children: "Plan:" }),
74871
- /* @__PURE__ */ jsx("div", { className: "tw-text-muted-foreground tw-col-span-4", children: isDotComUser ? isCodyProUser2 ? "Cody Pro" : "Cody Free" : "Enterprise" }),
74872
- /* @__PURE__ */ jsx("div", { children: "Endpoint:" }),
74873
- /* @__PURE__ */ jsx("div", { className: "tw-text-muted-foreground tw-col-span-4", children: endpoint })
74874
- ] })
74875
- ] }),
74876
- actions2.map((a2) => /* @__PURE__ */ jsx(
74877
- Button3,
74878
- {
74879
- variant: "secondary",
74880
- className: "tw-w-full tw-bg-popover tw-border tw-border-border",
74881
- onClick: a2.onClick,
74882
- title: a2.text,
74883
- children: a2.text
74884
- },
74885
- a2.text
74886
- ))
74887
- ] });
74888
- };
74889
- function getCreateNewChatCommand(options) {
74890
- const { IDE, webviewType, multipleWebviewsEnabled } = options;
74891
- return IDE === CodyIDE.Web ? "cody.chat.new" : webviewType === "sidebar" || !multipleWebviewsEnabled ? "cody.chat.newPanel" : "cody.chat.newEditorPanel";
74892
- }
74893
- const HistoryTab = ({
74894
- userHistory,
74895
- IDE,
74896
- webviewType,
74897
- multipleWebviewsEnabled,
74898
- setView
74899
- }) => {
74900
- const chatByPeriod = useMemo(
74901
- () => userHistory.filter((chat2) => chat2.interactions.length).reverse().reduce((acc, chat2) => {
74902
- const period = getRelativeChatPeriod(new Date(chat2.lastInteractionTimestamp));
74903
- acc.set(period, [...acc.get(period) || [], chat2]);
74904
- return acc;
74905
- }, /* @__PURE__ */ new Map()),
74906
- [userHistory]
74907
- );
74908
- const onDeleteButtonClick = useCallback(
74909
- (id2) => {
74910
- if (userHistory.find((chat2) => chat2.id === id2)) {
74911
- getVSCodeAPI().postMessage({
74912
- command: "command",
74913
- id: "cody.chat.history.clear",
74914
- arg: id2
74915
- });
74916
- }
74917
- },
74918
- [userHistory]
74919
- );
74920
- const handleStartNewChat = () => {
74921
- getVSCodeAPI().postMessage({
74922
- command: "command",
74923
- id: getCreateNewChatCommand({ IDE, webviewType, multipleWebviewsEnabled })
74924
- });
74925
- setView(View.Chat);
74926
- };
74927
- const chats = Array.from(chatByPeriod);
74928
- return /* @__PURE__ */ jsxs("div", { className: "tw-px-8 tw-pt-6 tw-pb-12 tw-flex tw-flex-col tw-gap-10", children: [
74929
- chats.map(([period, chats2]) => /* @__PURE__ */ jsx(
74930
- CollapsiblePanel,
74931
- {
74932
- storageKey: `history.${period}`,
74933
- title: period,
74934
- initialOpen: true,
74935
- children: chats2.map(({ interactions, id: id2 }) => {
74936
- var _a, _b, _c;
74937
- const lastMessage = (_c = (_b = (_a = interactions[interactions.length - 1]) == null ? void 0 : _a.humanMessage) == null ? void 0 : _b.text) == null ? void 0 : _c.trim();
74938
- return /* @__PURE__ */ jsxs("div", { className: "tw-inline-flex tw-justify-between", children: [
74939
- /* @__PURE__ */ jsxs(
74940
- Button3,
74941
- {
74942
- variant: "ghost",
74943
- title: lastMessage,
74944
- onClick: () => getVSCodeAPI().postMessage({
74945
- command: "restoreHistory",
74946
- chatID: id2
74947
- }),
74948
- className: "tw-text-left tw-truncate tw-w-full",
74949
- children: [
74950
- /* @__PURE__ */ jsx(
74951
- MessageSquareText,
74952
- {
74953
- className: "tw-w-8 tw-h-8 tw-opacity-80",
74954
- size: 16,
74955
- strokeWidth: "1.25"
74956
- }
74957
- ),
74958
- /* @__PURE__ */ jsx("span", { className: "tw-truncate tw-w-full", children: lastMessage })
74959
- ]
74960
- },
74961
- id2
74962
- ),
74963
- /* @__PURE__ */ jsx(
74964
- Button3,
74965
- {
74966
- variant: "ghost",
74967
- title: "Delete chat",
74968
- onClick: () => onDeleteButtonClick(id2),
74969
- children: /* @__PURE__ */ jsx(
74970
- Trash,
74971
- {
74972
- className: "tw-w-8 tw-h-8 tw-opacity-80",
74973
- size: 16,
74974
- strokeWidth: "1.25"
74975
- }
74976
- )
74977
- },
74978
- id2
74979
- )
74980
- ] }, id2);
74981
- })
74982
- },
74983
- period
74984
- )),
74985
- chats.length === 0 && /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-col tw-items-center tw-mt-6", children: [
74986
- /* @__PURE__ */ jsx(
74987
- History,
74988
- {
74989
- size: 20,
74990
- strokeWidth: 1.25,
74991
- className: "tw-mb-5 tw-text-muted-foreground"
74992
- }
74993
- ),
74994
- /* @__PURE__ */ jsx("span", { className: "tw-text-lg tw-mb-4 tw-text-muted-foreground", children: "You have no chat history" }),
74995
- /* @__PURE__ */ jsxs("span", { className: "tw-text-sm tw-text-muted-foreground tw-mb-8", children: [
74996
- "Explore all your previous chats here. Track and ",
74997
- /* @__PURE__ */ jsx("br", {}),
74998
- " search through what you’ve been working on."
74999
- ] }),
75000
- /* @__PURE__ */ jsxs(
75001
- Button3,
75002
- {
75003
- size: "sm",
75004
- variant: "secondary",
75005
- "aria-label": "Start a new chat",
75006
- className: "tw-px-4 tw-py-2",
75007
- onClick: handleStartNewChat,
75008
- children: [
75009
- /* @__PURE__ */ jsx(MessageSquarePlus, { size: 16, className: "tw-w-8 tw-h-8", strokeWidth: 1.25 }),
75010
- "Start a new chat"
75011
- ]
75012
- }
75013
- )
75014
- ] })
75015
- ] });
75016
- };
75017
- const SettingsTab = () => {
75018
- return /* @__PURE__ */ jsx("div", { className: "tw-overflow-auto tw-flex tw-flex-col tw-gap-4 tw-px-8 tw-mt-4", children: /* @__PURE__ */ jsx(
75019
- Button3,
75020
- {
75021
- variant: "secondary",
75022
- className: "tw-w-full tw-bg-popover",
75023
- onClick: () => getVSCodeAPI().postMessage({
75024
- command: "command",
75025
- id: "cody.status-bar.interacted"
75026
- }),
75027
- children: "Cody Settings"
75028
- },
75029
- "settings"
75030
- ) });
75031
- };
75032
- const tabsRoot = "_tabs-root_u8lyl_10";
75033
- const tabsContainer = "_tabs-container_u8lyl_15";
75034
- const tabs = "_tabs_u8lyl_10";
75035
- const subTabs = "_sub-tabs_u8lyl_34";
75036
- const tabActionLabel = "_tab-action-label_u8lyl_44";
75037
- const dialogOverlay = "_dialog-overlay_u8lyl_1";
75038
- const dialogContent = "_dialog-content_u8lyl_1";
75039
- const dialogTitle = "_dialog-title_u8lyl_1";
75040
- const dialogDescription = "_dialog-description_u8lyl_1";
75041
- const dialogFooter = "_dialog-footer_u8lyl_1";
74927
+ const tabsRoot = "_tabs-root_1e23y_10";
74928
+ const tabsContainer = "_tabs-container_1e23y_18";
74929
+ const tabs = "_tabs_1e23y_10";
74930
+ const subTabs = "_sub-tabs_1e23y_42";
74931
+ const tabActionLabel = "_tab-action-label_1e23y_53";
74932
+ const tabsRootCodyWeb = "_tabs-root--cody-web_1e23y_65";
74933
+ const dialogOverlay = "_dialog-overlay_1e23y_1";
74934
+ const dialogContent = "_dialog-content_1e23y_1";
74935
+ const dialogTitle = "_dialog-title_1e23y_1";
74936
+ const dialogDescription = "_dialog-description_1e23y_1";
74937
+ const dialogFooter = "_dialog-footer_1e23y_1";
75042
74938
  const styles$2 = {
75043
74939
  tabsRoot,
75044
74940
  tabsContainer,
75045
74941
  tabs,
75046
74942
  subTabs,
75047
74943
  tabActionLabel,
74944
+ tabsRootCodyWeb,
75048
74945
  dialogOverlay,
75049
74946
  dialogContent,
75050
74947
  dialogTitle,
@@ -75054,6 +74951,9 @@ const styles$2 = {
75054
74951
  const TabsBar = ({ currentView, setView, IDE, onDownloadChatClick }) => {
75055
74952
  var _a;
75056
74953
  const tabItems = useTabs({ IDE, onDownloadChatClick });
74954
+ const {
74955
+ config: { webviewType, multipleWebviewsEnabled }
74956
+ } = useConfig();
75057
74957
  const currentViewSubActions = ((_a = tabItems.find((tab2) => tab2.view === currentView)) == null ? void 0 : _a.subActions) ?? [];
75058
74958
  const handleClick = useCallback(
75059
74959
  (view, command, changesView) => {
@@ -75066,35 +74966,60 @@ const TabsBar = ({ currentView, setView, IDE, onDownloadChatClick }) => {
75066
74966
  },
75067
74967
  [setView]
75068
74968
  );
75069
- const handleSubActionClick = useCallback((action) => {
75070
- if (action.callback) {
75071
- action.callback();
75072
- } else {
75073
- getVSCodeAPI().postMessage({
75074
- command: "command",
75075
- id: action.command,
75076
- arg: action.arg
75077
- });
75078
- }
75079
- }, []);
75080
- return /* @__PURE__ */ jsx("div", { className: styles$2.tabsRoot, children: /* @__PURE__ */ jsxs(List, { "aria-label": "cody-webview", className: styles$2.tabsContainer, children: [
75081
- /* @__PURE__ */ jsx("div", { className: styles$2.tabs, children: tabItems.map(({ Icon: Icon2, view, command, title: title2, changesView }) => /* @__PURE__ */ jsx(Trigger, { value: view, asChild: true, children: /* @__PURE__ */ jsx(
75082
- TabButton,
75083
- {
75084
- Icon: Icon2,
75085
- view,
75086
- title: title2,
75087
- isActive: currentView === view,
75088
- onClick: () => handleClick(view, command, changesView),
75089
- "data-testid": `tab-${view}`
74969
+ const handleSubActionClick = useCallback(
74970
+ (action) => {
74971
+ if (action.callback) {
74972
+ action.callback();
74973
+ } else {
74974
+ getVSCodeAPI().postMessage({
74975
+ command: "command",
74976
+ id: action.command,
74977
+ arg: action.arg
74978
+ });
75090
74979
  }
75091
- ) }, view)) }),
74980
+ },
74981
+ []
74982
+ );
74983
+ return /* @__PURE__ */ jsx("div", { className: clsx$1(styles$2.tabsRoot, { [styles$2.tabsRootCodyWeb]: IDE === CodyIDE.Web }), children: /* @__PURE__ */ jsxs(List, { "aria-label": "cody-webview", className: styles$2.tabsContainer, children: [
74984
+ /* @__PURE__ */ jsxs("div", { className: styles$2.tabs, children: [
74985
+ tabItems.map(({ Icon: Icon2, view, command, title: title2, changesView }) => /* @__PURE__ */ jsx(Trigger, { value: view, asChild: true, children: /* @__PURE__ */ jsx(
74986
+ TabButton,
74987
+ {
74988
+ Icon: Icon2,
74989
+ view,
74990
+ title: title2,
74991
+ IDE,
74992
+ isActive: currentView === view,
74993
+ onClick: () => handleClick(view, command, changesView),
74994
+ "data-testid": `tab-${view}`
74995
+ }
74996
+ ) }, view)),
74997
+ /* @__PURE__ */ jsx("div", { className: "tw-ml-auto", children: /* @__PURE__ */ jsx(
74998
+ TabButton,
74999
+ {
75000
+ prominent: true,
75001
+ Icon: MessageSquarePlus,
75002
+ title: "New Chat",
75003
+ IDE,
75004
+ alwaysShowTitle: true,
75005
+ tooltipExtra: /* @__PURE__ */ jsx(Fragment, { children: IDE === CodyIDE.VSCode && /* @__PURE__ */ jsx(Kbd, { macOS: "shift+opt+l", linuxAndWindows: "shift+alt+l" }) }),
75006
+ onClick: () => handleSubActionClick({
75007
+ command: getCreateNewChatCommand({
75008
+ IDE,
75009
+ webviewType,
75010
+ multipleWebviewsEnabled
75011
+ })
75012
+ })
75013
+ }
75014
+ ) })
75015
+ ] }),
75092
75016
  /* @__PURE__ */ jsx("div", { className: styles$2.subTabs, children: currentViewSubActions.map((subAction) => /* @__PURE__ */ jsx(Fragment$1, { children: subAction.confirmation ? /* @__PURE__ */ jsx(
75093
75017
  ActionButtonWithConfirmation,
75094
75018
  {
75095
75019
  title: subAction.title,
75096
75020
  Icon: subAction.Icon,
75097
- alwaysShowTitle: subAction.alwaysShowTitle,
75021
+ IDE,
75022
+ alwaysShowTitle: true,
75098
75023
  tooltipExtra: subAction.tooltipExtra,
75099
75024
  dialogTitle: subAction.confirmation.title,
75100
75025
  dialogDescription: subAction.confirmation.description,
@@ -75106,18 +75031,20 @@ const TabsBar = ({ currentView, setView, IDE, onDownloadChatClick }) => {
75106
75031
  {
75107
75032
  Icon: subAction.Icon,
75108
75033
  title: subAction.title,
75109
- alwaysShowTitle: subAction.alwaysShowTitle,
75034
+ uri: subAction.uri,
75035
+ IDE,
75036
+ alwaysShowTitle: true,
75110
75037
  tooltipExtra: subAction.tooltipExtra,
75111
- onClick: () => handleSubActionClick(subAction),
75112
- prominent: true
75038
+ onClick: () => handleSubActionClick(subAction)
75113
75039
  }
75114
- ) }, subAction.command)) })
75040
+ ) }, `${subAction.command}/${subAction.uri ?? ""}`)) })
75115
75041
  ] }) });
75116
75042
  };
75117
75043
  const ActionButtonWithConfirmation = (props) => {
75118
75044
  const {
75119
75045
  title: title2,
75120
75046
  Icon: Icon2,
75047
+ IDE,
75121
75048
  prominent,
75122
75049
  alwaysShowTitle,
75123
75050
  tooltipExtra,
@@ -75136,6 +75063,7 @@ const ActionButtonWithConfirmation = (props) => {
75136
75063
  alwaysShowTitle,
75137
75064
  tooltipExtra,
75138
75065
  prominent,
75066
+ IDE,
75139
75067
  onClick: () => setState(true)
75140
75068
  }
75141
75069
  ),
@@ -75162,25 +75090,32 @@ const ActionButtonWithConfirmation = (props) => {
75162
75090
  ] })
75163
75091
  ] });
75164
75092
  };
75165
- const TabButton = forwardRef(
75166
- ({
75093
+ const TabButton = forwardRef((props, ref2) => {
75094
+ const {
75095
+ IDE,
75167
75096
  Icon: Icon2,
75168
75097
  isActive,
75169
75098
  onClick,
75099
+ uri,
75170
75100
  title: title2,
75171
75101
  alwaysShowTitle,
75172
75102
  tooltipExtra,
75173
75103
  prominent,
75174
75104
  "data-testid": dataTestId
75175
- }, ref2) => /* @__PURE__ */ jsxs(Tooltip, { children: [
75105
+ } = props;
75106
+ const Component = uri ? "a" : "button";
75107
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
75176
75108
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
75177
- "button",
75109
+ Component,
75178
75110
  {
75179
- type: "button",
75180
- onClick,
75111
+ type: uri ? void 0 : "button",
75112
+ onClick: uri ? void 0 : onClick,
75113
+ href: uri,
75114
+ target: "_blank",
75115
+ rel: "noopener noreferrer",
75181
75116
  ref: ref2,
75182
75117
  className: clsx$1(
75183
- "tw-flex tw-gap-3 tw-items-center tw-leading-none tw-py-3 tw-px-2 tw-opacity-80 hover:tw-opacity-100 tw-border-b-[1px] tw-border-transparent tw-transition tw-translate-y-[1px]",
75118
+ "tw-flex tw-gap-3 tw-items-center tw-leading-none tw-py-3 tw-px-2 !tw-font-normal !tw-text-inherit tw-opacity-80 hover:tw-opacity-100 tw-border-b-[1px] tw-border-transparent tw-transition tw-translate-y-[1px]",
75184
75119
  {
75185
75120
  "!tw-opacity-100 !tw-border-[var(--vscode-tab-activeBorderTop)]": isActive,
75186
75121
  "!tw-opacity-100": prominent
@@ -75193,18 +75128,18 @@ const TabButton = forwardRef(
75193
75128
  ]
75194
75129
  }
75195
75130
  ) }),
75196
- /* @__PURE__ */ jsxs(TooltipContent, { className: "md:tw-hidden", children: [
75131
+ /* @__PURE__ */ jsxs(TooltipContent, { portal: IDE === CodyIDE.Web, children: [
75197
75132
  title2,
75198
75133
  " ",
75199
75134
  tooltipExtra
75200
75135
  ] })
75201
- ] })
75202
- );
75136
+ ] });
75137
+ });
75203
75138
  TabButton.displayName = "TabButton";
75204
75139
  function useTabs(input) {
75205
75140
  const { IDE, onDownloadChatClick } = input;
75206
75141
  const {
75207
- config: { webviewType, multipleWebviewsEnabled }
75142
+ config: { multipleWebviewsEnabled, serverEndpoint }
75208
75143
  } = useConfig();
75209
75144
  return useMemo(
75210
75145
  () => [
@@ -75212,24 +75147,6 @@ function useTabs(input) {
75212
75147
  view: View.Chat,
75213
75148
  title: "Chat",
75214
75149
  Icon: MessagesSquare,
75215
- subActions: [
75216
- {
75217
- title: "New Chat",
75218
- alwaysShowTitle: true,
75219
- tooltipExtra: /* @__PURE__ */ jsx(Fragment, { children: IDE === CodyIDE.VSCode && /* @__PURE__ */ jsx(Kbd, { macOS: "shift+opt+l", linuxAndWindows: "shift+alt+l" }) }),
75220
- Icon: MessageSquarePlus,
75221
- command: getCreateNewChatCommand({
75222
- IDE,
75223
- webviewType,
75224
- multipleWebviewsEnabled
75225
- })
75226
- },
75227
- multipleWebviewsEnabled ? {
75228
- title: "Open in Editor",
75229
- Icon: Columns2,
75230
- command: "cody.chat.moveToEditor"
75231
- } : null
75232
- ].filter(isDefined),
75233
75150
  changesView: true
75234
75151
  },
75235
75152
  {
@@ -75238,13 +75155,13 @@ function useTabs(input) {
75238
75155
  Icon: History,
75239
75156
  subActions: [
75240
75157
  {
75241
- title: "Export History",
75158
+ title: "Export",
75242
75159
  Icon: Download,
75243
75160
  command: "cody.chat.history.export",
75244
75161
  callback: onDownloadChatClick
75245
75162
  },
75246
75163
  {
75247
- title: "Clear Chat History",
75164
+ title: "Delete all",
75248
75165
  Icon: Trash2,
75249
75166
  command: "cody.chat.history.clear",
75250
75167
  // Show Cody Chat UI confirmation modal with this message only for
@@ -75267,7 +75184,21 @@ function useTabs(input) {
75267
75184
  view: View.Prompts,
75268
75185
  title: IDE === CodyIDE.Web ? "Prompts" : "Prompts & Commands",
75269
75186
  Icon: BookText,
75270
- changesView: true
75187
+ changesView: true,
75188
+ subActions: [
75189
+ {
75190
+ title: "Create prompt",
75191
+ Icon: CirclePlus,
75192
+ command: "",
75193
+ uri: `${serverEndpoint}prompts/new`
75194
+ },
75195
+ {
75196
+ title: "Open prompts library",
75197
+ Icon: ExternalLink,
75198
+ command: "",
75199
+ uri: `${serverEndpoint}prompts`
75200
+ }
75201
+ ]
75271
75202
  },
75272
75203
  multipleWebviewsEnabled ? {
75273
75204
  view: View.Settings,
@@ -75283,9 +75214,195 @@ function useTabs(input) {
75283
75214
  changesView: IDE !== CodyIDE.VSCode
75284
75215
  } : null
75285
75216
  ].filter(isDefined),
75286
- [IDE, webviewType, onDownloadChatClick, multipleWebviewsEnabled]
75217
+ [IDE, onDownloadChatClick, multipleWebviewsEnabled, serverEndpoint]
75287
75218
  );
75288
75219
  }
75220
+ const Chat = ({
75221
+ IDE,
75222
+ messageInProgress,
75223
+ transcript,
75224
+ vscodeAPI,
75225
+ isTranscriptError,
75226
+ chatEnabled = true,
75227
+ guardrails,
75228
+ scrollableParent,
75229
+ showWelcomeMessage = true,
75230
+ showIDESnippetActions = true,
75231
+ setView,
75232
+ smartApplyEnabled
75233
+ }) => {
75234
+ const telemetryRecorder = useTelemetryRecorder();
75235
+ const transcriptRef = useRef(transcript);
75236
+ transcriptRef.current = transcript;
75237
+ const userInfo = useUserAccountInfo();
75238
+ const feedbackButtonsOnSubmit = useCallback(
75239
+ (text2) => {
75240
+ var _a, _b;
75241
+ let FeedbackType;
75242
+ ((FeedbackType2) => {
75243
+ FeedbackType2[FeedbackType2["thumbsUp"] = 1] = "thumbsUp";
75244
+ FeedbackType2[FeedbackType2["thumbsDown"] = 0] = "thumbsDown";
75245
+ })(FeedbackType || (FeedbackType = {}));
75246
+ telemetryRecorder.recordEvent("cody.feedback", "submit", {
75247
+ metadata: {
75248
+ feedbackType: text2 === "thumbsUp" ? 1 : 0,
75249
+ lastChatUsedEmbeddings: ((_b = (_a = transcriptRef.current.at(-1)) == null ? void 0 : _a.contextFiles) == null ? void 0 : _b.some((file) => file.source === "embeddings")) ? 1 : 0,
75250
+ recordsPrivateMetadataTranscript: userInfo.isDotComUser ? 1 : 0
75251
+ },
75252
+ privateMetadata: {
75253
+ FeedbackText: text2,
75254
+ // 🚨 SECURITY: chat transcripts are to be included only for DotCom users AND for V2 telemetry
75255
+ // V2 telemetry exports privateMetadata only for DotCom users
75256
+ // the condition below is an aditional safegaurd measure
75257
+ responseText: userInfo.isDotComUser ? truncateTextStart(transcriptRef.current.toString(), CHAT_INPUT_TOKEN_BUDGET) : ""
75258
+ }
75259
+ });
75260
+ },
75261
+ [userInfo, telemetryRecorder]
75262
+ );
75263
+ const copyButtonOnSubmit = useCallback(
75264
+ (text2, eventType = "Button") => {
75265
+ const op = "copy";
75266
+ const code2 = eventType === "Button" ? text2.replace(/\n$/, "") : text2;
75267
+ vscodeAPI.postMessage({
75268
+ command: op,
75269
+ eventType,
75270
+ text: code2
75271
+ });
75272
+ },
75273
+ [vscodeAPI]
75274
+ );
75275
+ const insertButtonOnSubmit = useMemo(() => {
75276
+ if (showIDESnippetActions) {
75277
+ return (text2, newFile = false) => {
75278
+ const op = newFile ? "newFile" : "insert";
75279
+ vscodeAPI.postMessage({
75280
+ command: op,
75281
+ // remove the additional /n added by the text area at the end of the text
75282
+ text: text2.replace(/\n$/, "")
75283
+ });
75284
+ };
75285
+ }
75286
+ return;
75287
+ }, [vscodeAPI, showIDESnippetActions]);
75288
+ const smartApply = useMemo(() => {
75289
+ if (!showIDESnippetActions) {
75290
+ return;
75291
+ }
75292
+ return {
75293
+ onSubmit: (id2, text2, instruction, fileName) => {
75294
+ vscodeAPI.postMessage({
75295
+ command: "smartApplySubmit",
75296
+ id: id2,
75297
+ instruction: instruction == null ? void 0 : instruction.toString(),
75298
+ // remove the additional /n added by the text area at the end of the text
75299
+ code: text2.replace(/\n$/, ""),
75300
+ fileName
75301
+ });
75302
+ },
75303
+ onAccept: (id2) => {
75304
+ vscodeAPI.postMessage({
75305
+ command: "smartApplyAccept",
75306
+ id: id2
75307
+ });
75308
+ },
75309
+ onReject: (id2) => {
75310
+ vscodeAPI.postMessage({
75311
+ command: "smartApplyReject",
75312
+ id: id2
75313
+ });
75314
+ }
75315
+ };
75316
+ }, [vscodeAPI, showIDESnippetActions]);
75317
+ const postMessage = useCallback((msg) => vscodeAPI.postMessage(msg), [vscodeAPI]);
75318
+ useEffect(() => {
75319
+ function handleKeyDown(event) {
75320
+ if (event.key === "Escape" && messageInProgress) {
75321
+ vscodeAPI.postMessage({ command: "abort" });
75322
+ }
75323
+ if (event.metaKey && event.key === "o") {
75324
+ event.preventDefault();
75325
+ event.stopPropagation();
75326
+ }
75327
+ }
75328
+ window.addEventListener("keydown", handleKeyDown);
75329
+ return () => {
75330
+ window.removeEventListener("keydown", handleKeyDown);
75331
+ };
75332
+ }, [vscodeAPI, messageInProgress]);
75333
+ useEffect(() => {
75334
+ const onFocus = () => {
75335
+ const sel = window.getSelection();
75336
+ const focusNode = sel == null ? void 0 : sel.focusNode;
75337
+ const focusElement = focusNode instanceof Element ? focusNode : focusNode == null ? void 0 : focusNode.parentElement;
75338
+ const focusEditor = focusElement == null ? void 0 : focusElement.closest('[data-lexical-editor="true"]');
75339
+ if (focusEditor) {
75340
+ focusEditor.focus({ preventScroll: true });
75341
+ }
75342
+ };
75343
+ window.addEventListener("focus", onFocus);
75344
+ return () => {
75345
+ window.removeEventListener("focus", onFocus);
75346
+ };
75347
+ }, []);
75348
+ const dispatchClientAction = useClientActionDispatcher();
75349
+ const handleScrollDownClick = useCallback(() => {
75350
+ if (transcript.length === 0) {
75351
+ return;
75352
+ }
75353
+ focusLastHumanMessageEditor();
75354
+ }, [transcript]);
75355
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
75356
+ !chatEnabled && /* @__PURE__ */ jsx("div", { className: styles$3.chatDisabled, children: "Cody chat is disabled by your Sourcegraph site administrator" }),
75357
+ /* @__PURE__ */ jsx(
75358
+ Transcript,
75359
+ {
75360
+ transcript,
75361
+ messageInProgress,
75362
+ feedbackButtonsOnSubmit,
75363
+ copyButtonOnSubmit,
75364
+ insertButtonOnSubmit,
75365
+ smartApply,
75366
+ isTranscriptError,
75367
+ userInfo,
75368
+ chatEnabled,
75369
+ postMessage,
75370
+ guardrails,
75371
+ smartApplyEnabled
75372
+ }
75373
+ ),
75374
+ transcript.length === 0 && /* @__PURE__ */ jsx(
75375
+ PromptList,
75376
+ {
75377
+ telemetryLocation: "ChatTab",
75378
+ showSearch: false,
75379
+ showSwitchToPromptAction: true,
75380
+ showInitialSelectedItem: false,
75381
+ showCommandOrigins: true,
75382
+ showPromptLibraryUnsupportedMessage: false,
75383
+ className: "tw-rounded-none tw-px-4 tw-flex-shrink-0",
75384
+ onSelectActionLabels: onPromptSelectInPanelActionLabels,
75385
+ onSwitchToPromptsTab: () => setView(View.Prompts),
75386
+ onSelect: (item2) => onPromptSelectInPanel(item2, setView, dispatchClientAction)
75387
+ }
75388
+ ),
75389
+ transcript.length === 0 && showWelcomeMessage && /* @__PURE__ */ jsx(WelcomeMessage, { IDE: userInfo.ide, setView }),
75390
+ scrollableParent && /* @__PURE__ */ jsx(ScrollDown, { scrollableParent, onClick: handleScrollDownClick })
75391
+ ] });
75392
+ };
75393
+ const TabRoot = React__default.forwardRef(({ className, ...props }, ref2) => {
75394
+ return /* @__PURE__ */ jsx(Root2, { ref: ref2, ...props, orientation: "vertical", className });
75395
+ });
75396
+ const TabContainer = React__default.forwardRef(({ className, ...props }, ref2) => {
75397
+ return /* @__PURE__ */ jsx(
75398
+ Content,
75399
+ {
75400
+ ref: ref2,
75401
+ ...props,
75402
+ className: "tw-h-full tw-flex tw-flex-col tw-overflow-auto tw-gap-4"
75403
+ }
75404
+ );
75405
+ });
75289
75406
  const CodyPanel = ({
75290
75407
  view,
75291
75408
  setView,
@@ -75336,6 +75453,7 @@ const CodyPanel = ({
75336
75453
  view === View.Chat && /* @__PURE__ */ jsx(
75337
75454
  Chat,
75338
75455
  {
75456
+ IDE: config.agentIDE || CodyIDE.VSCode,
75339
75457
  chatEnabled,
75340
75458
  messageInProgress,
75341
75459
  transcript,
@@ -75359,7 +75477,7 @@ const CodyPanel = ({
75359
75477
  userHistory
75360
75478
  }
75361
75479
  ),
75362
- view === View.Prompts && /* @__PURE__ */ jsx(PromptsTab, { setView }),
75480
+ view === View.Prompts && /* @__PURE__ */ jsx(PromptsTab, { setView, IDE: config.agentIDE || CodyIDE.VSCode }),
75363
75481
  view === View.Account && /* @__PURE__ */ jsx(AccountTab, {}),
75364
75482
  view === View.Settings && /* @__PURE__ */ jsx(SettingsTab, {})
75365
75483
  ] })
@@ -75382,7 +75500,7 @@ const ErrorBanner = ({ errors, setErrors }) => /* @__PURE__ */ jsx("div", { clas
75382
75500
  )
75383
75501
  ] }, i2)
75384
75502
  )) });
75385
- function getAppWrappers(vscodeAPI, telemetryRecorder, chatModelContext, clientState, config, chatEnvironmentContext) {
75503
+ function getAppWrappers(vscodeAPI, telemetryRecorder, clientState, config, chatEnvironmentContext) {
75386
75504
  return [
75387
75505
  {
75388
75506
  provider: TelemetryRecorderContext.Provider,
@@ -75392,10 +75510,6 @@ function getAppWrappers(vscodeAPI, telemetryRecorder, chatModelContext, clientSt
75392
75510
  component: ExtensionAPIProviderFromVSCodeAPI,
75393
75511
  props: { vscodeAPI }
75394
75512
  },
75395
- {
75396
- provider: ChatModelContextProvider,
75397
- value: chatModelContext
75398
- },
75399
75513
  {
75400
75514
  provider: ClientStateContextProvider,
75401
75515
  value: clientState
@@ -75475,14 +75589,7 @@ async function createAgentClient({
75475
75589
  }
75476
75590
  const GLOBAL_MESSAGE_TYPES = ["rpc/response"];
75477
75591
  function useCodyWebAgent(input) {
75478
- const {
75479
- serverEndpoint,
75480
- accessToken,
75481
- telemetryClientName,
75482
- customHeaders,
75483
- initialContext,
75484
- createAgentWorker
75485
- } = input;
75592
+ const { serverEndpoint, accessToken, telemetryClientName, customHeaders, createAgentWorker } = input;
75486
75593
  const activeWebviewPanelIDRef = useRef("");
75487
75594
  const [client, setClient] = useState(null);
75488
75595
  useEffectOnce(() => {
@@ -75498,29 +75605,17 @@ function useCodyWebAgent(input) {
75498
75605
  setClient(() => error2);
75499
75606
  });
75500
75607
  }, [accessToken, serverEndpoint, createAgentWorker, customHeaders, telemetryClientName]);
75501
- const createNewChat = useCallback(
75502
- async (agent) => {
75503
- if (!agent || isErrorLike(agent)) {
75504
- return;
75505
- }
75506
- const { panelId, chatId } = await agent.rpc.sendRequest("chat/web/new", null);
75507
- activeWebviewPanelIDRef.current = panelId;
75508
- await agent.rpc.sendRequest("webview/receiveMessage", {
75509
- id: activeWebviewPanelIDRef.current,
75510
- message: { chatID: chatId, command: "restoreHistory" }
75511
- });
75512
- if (initialContext == null ? void 0 : initialContext.repository) {
75513
- void agent.rpc.sendRequest("webview/receiveMessage", {
75514
- id: activeWebviewPanelIDRef.current,
75515
- message: {
75516
- command: "context/choose-remote-search-repo",
75517
- explicitRepos: [initialContext.repository]
75518
- }
75519
- });
75520
- }
75521
- },
75522
- [initialContext]
75523
- );
75608
+ const createNewChat = useCallback(async (agent) => {
75609
+ if (!agent || isErrorLike(agent)) {
75610
+ return;
75611
+ }
75612
+ const { panelId, chatId } = await agent.rpc.sendRequest("chat/web/new", null);
75613
+ activeWebviewPanelIDRef.current = panelId;
75614
+ await agent.rpc.sendRequest("webview/receiveMessage", {
75615
+ id: activeWebviewPanelIDRef.current,
75616
+ message: { chatID: chatId, command: "restoreHistory" }
75617
+ });
75618
+ }, []);
75524
75619
  const isInitRef = useRef(false);
75525
75620
  const vscodeAPI = useVSCodeAPI({ activeWebviewPanelIDRef, createNewChat, client });
75526
75621
  useEffect(() => {
@@ -75739,9 +75834,6 @@ const CodyWebChat = ({
75739
75834
  }
75740
75835
  ) }) });
75741
75836
  };
75742
- const CONTEXT_MENTIONS_SETTINGS = {
75743
- resolutionMode: "remote"
75744
- };
75745
75837
  const CodyWebPanel = (props) => {
75746
75838
  const { vscodeAPI, initialContext, className } = props;
75747
75839
  const dispatchClientAction = useClientActionDispatcher();
@@ -75749,7 +75841,6 @@ const CodyWebPanel = (props) => {
75749
75841
  const [isTranscriptError, setIsTranscriptError] = useState(false);
75750
75842
  const [messageInProgress, setMessageInProgress] = useState(null);
75751
75843
  const [transcript, setTranscript] = useState([]);
75752
- const [chatModels, setChatModels] = useState();
75753
75844
  const [config, setConfig] = useState(null);
75754
75845
  const [view, setView] = useState();
75755
75846
  const [userHistory, setUserHistory] = useState();
@@ -75781,9 +75872,6 @@ const CodyWebPanel = (props) => {
75781
75872
  case "transcript-errors":
75782
75873
  setIsTranscriptError(message2.isTranscriptError);
75783
75874
  break;
75784
- case "chatModels":
75785
- setChatModels(message2.models);
75786
- break;
75787
75875
  case "config":
75788
75876
  message2.config.webviewType = "sidebar";
75789
75877
  message2.config.multipleWebviewsEnabled = false;
@@ -75799,26 +75887,6 @@ const CodyWebPanel = (props) => {
75799
75887
  });
75800
75888
  }, [vscodeAPI, dispatchClientAction]);
75801
75889
  const telemetryRecorder = useMemo(() => createWebviewTelemetryRecorder(vscodeAPI), [vscodeAPI]);
75802
- const onCurrentChatModelChange = useCallback(
75803
- (selected) => {
75804
- if (!chatModels || !setChatModels) {
75805
- return;
75806
- }
75807
- vscodeAPI.postMessage({
75808
- command: "chatModel",
75809
- model: selected.id
75810
- });
75811
- },
75812
- [chatModels, vscodeAPI]
75813
- );
75814
- const chatModelContext = useMemo(
75815
- () => ({
75816
- chatModels,
75817
- onCurrentChatModelChange,
75818
- serverSentModelsEnabled: config == null ? void 0 : config.configFeatures.serverSentModels
75819
- }),
75820
- [chatModels, onCurrentChatModelChange, config]
75821
- );
75822
75890
  const clientState = useMemo(() => {
75823
75891
  const { repository, fileURL, isDirectory } = initialContext ?? {};
75824
75892
  if (!repository) {
@@ -75879,10 +75947,17 @@ const CodyWebPanel = (props) => {
75879
75947
  }, [initialContext]);
75880
75948
  const envVars = useMemo(() => ({ clientType: CodyIDE.Web }), []);
75881
75949
  const wrappers = useMemo(
75882
- () => getAppWrappers(vscodeAPI, telemetryRecorder, chatModelContext, clientState, config, envVars),
75883
- [vscodeAPI, telemetryRecorder, chatModelContext, clientState, config, envVars]
75950
+ () => getAppWrappers(vscodeAPI, telemetryRecorder, clientState, config, envVars),
75951
+ [vscodeAPI, telemetryRecorder, clientState, config, envVars]
75884
75952
  );
75885
- const isLoading = !chatModels || !config || !view || !userHistory;
75953
+ const CONTEXT_MENTIONS_SETTINGS = useMemo(() => {
75954
+ const { repository } = initialContext ?? {};
75955
+ return {
75956
+ resolutionMode: "remote",
75957
+ remoteRepositoriesNames: (repository == null ? void 0 : repository.name) ? [repository.name] : []
75958
+ };
75959
+ }, [initialContext]);
75960
+ const isLoading = !config || !view || !userHistory;
75886
75961
  return /* @__PURE__ */ jsx("div", { className, "data-cody-web-chat": true, children: !isLoading && /* @__PURE__ */ jsx(ChatEnvironmentContext.Provider, { value: envVars, children: /* @__PURE__ */ jsx(ChatMentionContext.Provider, { value: CONTEXT_MENTIONS_SETTINGS, children: /* @__PURE__ */ jsx(ComposedWrappers, { wrappers, children: /* @__PURE__ */ jsx(
75887
75962
  CodyPanel,
75888
75963
  {