@sourcegraph/cody-web 0.32.4 → 0.32.5

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,8 +2,8 @@ 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 as Fragment$1 } from "react/jsx-runtime";
5
- import { g as getDefaultExportFromCjs, F as FILE_CONTEXT_MENTION_PROVIDER, S as SYMBOL_CONTEXT_MENTION_PROVIDER, R as REMOTE_REPOSITORY_PROVIDER_URI, a as REMOTE_FILE_PROVIDER_URI, b as REMOTE_DIRECTORY_PROVIDER_URI, W as WEB_PROVIDER_URI, d as RULES_PROVIDER_URI, e as displayPath, f as displayLineRange, h as displayPathDirname, i as displayPathBasename, I as IGNORED_FILE_WARNING_LABEL, L as LARGE_FILE_WARNING_LABEL, o as object, l as literal, j as string$2, C as ContextItemSource, k as displayPathWithLines, m as URI, n as is$3, q as serializeContextItem, r as CONTEXT_ITEM_MENTION_NODE_TYPE, t as contextItemMentionNodeDisplayText, T as TEMPLATE_INPUT_NODE_TYPE, u as parseMentionQuery, N as NO_SYMBOL_MATCHES_HELP_LABEL, v as FILE_RANGE_TOOLTIP_LABEL, O as Observable, x as createExtensionAPI, y as createMessageAPIForWebview, z as debounce, A as memoizeLastValue, B as toSerializedPromptEditorValue$1, D as isEqual, E as scanForMentionTriggerInUserTextInput, G as getMentionOperations, H as combineLatest, J as map$3, K as forceHydration, M as hydrateAfterPostMessage, P as isDotCom, Q as isAuthError, V as isAvailabilityError, X as isSourcegraphToken, Y as trace, Z as context$1, _ as SpanStatusCode, $ as FeatureFlag, c as commonjsGlobal, a0 as svg, a1 as html$2, a2 as whitespace, a3 as find, a4 as stringify, a5 as stringify$1, a6 as ccount, a7 as isCodyProUser, a8 as CodyIDE, a9 as CodyTaskState, aa as cryptoJsExports, ab as GuardrailsCheckStatus, ac as LRUCache, ad as isError, ae as RateLimitError, af as upperFirst, ag as lodashExports, ah as createContextItem, ai as isDefined, aj as isCodeSearchContextItem, ak as reformatBotMessageForChat, al as isAbortErrorOrSocketHangUp, am as ModelTag, an as DeepCodyAgentID, ao as serializedPromptEditorStateFromChatMessage, ap as contextItemsFromPromptEditorValue, aq as filterContextItemsFromPromptEditorValue, ar as CustomCommandType, as as View, at as isCodyProModel, au as isMacOS, av as ToolCodyModelName, aw as getRelativeChatPeriod, ax as firstResultFromOperation, ay as ENTERPRISE_STARTER_LEARN_MORE_URL, az as CODY_PRO_SUBSCRIPTION_URL, aA as ACCOUNT_USAGE_URL, aB as ENTERPRISE_STARTER_PRICING_URL, aC as textContentFromSerializedLexicalNode, aD as firstValueFrom, aE as skipPendingOperation, aF as FAST_CHAT_INPUT_TOKEN_BUDGET, aG as webviewOpenURIForContextItem, aH as pluralize, aI as UIToolStatus, aJ as getFileDiff, aK as diffWithLineNum, aL as UITerminalOutputType, aM as serializedPromptEditorStateFromText, aN as deserializeContextItem, aO as S2_URL, aP as browser, aQ as CodyAutoSuggestionMode, aR as setDisplayPathEnvInfo, aS as isErrorLike, aT as PromptString, aU as createGuardrailsImpl, U as Uri } from "./vscode-shim-OXKwh9cI.mjs";
6
- import { aW, aV } from "./vscode-shim-OXKwh9cI.mjs";
5
+ import { g as getDefaultExportFromCjs, F as FILE_CONTEXT_MENTION_PROVIDER, S as SYMBOL_CONTEXT_MENTION_PROVIDER, R as REMOTE_REPOSITORY_PROVIDER_URI, a as REMOTE_FILE_PROVIDER_URI, b as REMOTE_DIRECTORY_PROVIDER_URI, W as WEB_PROVIDER_URI, d as RULES_PROVIDER_URI, e as displayPath, f as displayLineRange, h as displayPathDirname, i as displayPathBasename, I as IGNORED_FILE_WARNING_LABEL, L as LARGE_FILE_WARNING_LABEL, o as object, l as literal, j as string$2, C as ContextItemSource, k as displayPathWithLines, m as URI, n as is$3, q as serializeContextItem, r as CONTEXT_ITEM_MENTION_NODE_TYPE, t as contextItemMentionNodeDisplayText, T as TEMPLATE_INPUT_NODE_TYPE, u as parseMentionQuery, N as NO_SYMBOL_MATCHES_HELP_LABEL, v as FILE_RANGE_TOOLTIP_LABEL, O as Observable, x as createExtensionAPI, y as createMessageAPIForWebview, z as debounce, A as memoizeLastValue, B as toSerializedPromptEditorValue$1, D as isEqual, E as scanForMentionTriggerInUserTextInput, G as getMentionOperations, H as combineLatest, J as map$3, K as forceHydration, M as hydrateAfterPostMessage, P as isDotCom, Q as isAuthError, V as isAvailabilityError, X as isSourcegraphToken, Y as trace, Z as context$1, _ as SpanStatusCode, $ as FeatureFlag, c as commonjsGlobal, a0 as svg, a1 as html$2, a2 as whitespace, a3 as find, a4 as stringify, a5 as stringify$1, a6 as ccount, a7 as isCodyProUser, a8 as CodyIDE, a9 as CodyTaskState, aa as cryptoJsExports, ab as GuardrailsCheckStatus, ac as LRUCache, ad as isError, ae as RateLimitError, af as upperFirst, ag as lodashExports, ah as createContextItem, ai as isDefined, aj as isCodeSearchContextItem, ak as reformatBotMessageForChat, al as isAbortErrorOrSocketHangUp, am as ModelTag, an as DeepCodyAgentID, ao as serializedPromptEditorStateFromChatMessage, ap as contextItemsFromPromptEditorValue, aq as filterContextItemsFromPromptEditorValue, ar as CustomCommandType, as as View, at as isCodyProModel, au as isMacOS, av as ToolCodyModelName, aw as firstResultFromOperation, ax as ChatHistoryType, ay as ENTERPRISE_STARTER_LEARN_MORE_URL, az as CODY_PRO_SUBSCRIPTION_URL, aA as ACCOUNT_USAGE_URL, aB as ENTERPRISE_STARTER_PRICING_URL, aC as textContentFromSerializedLexicalNode, aD as firstValueFrom, aE as skipPendingOperation, aF as FAST_CHAT_INPUT_TOKEN_BUDGET, aG as webviewOpenURIForContextItem, aH as pluralize, aI as UIToolStatus, aJ as getFileDiff, aK as diffWithLineNum, aL as UITerminalOutputType, aM as serializedPromptEditorStateFromText, aN as v4, aO as deserializeContextItem, aP as getRelativeChatPeriod, aQ as S2_URL, aR as browser, aS as CodyAutoSuggestionMode, aT as setDisplayPathEnvInfo, aU as isErrorLike, aV as PromptString, aW as createGuardrailsImpl, U as Uri } from "./vscode-shim-DmIsJbkd.mjs";
6
+ import { aY, aX } from "./vscode-shim-DmIsJbkd.mjs";
7
7
  import * as React$2 from "react";
8
8
  import React__default, { createContext, useContext, useMemo as useMemo$1, useLayoutEffect as useLayoutEffect$1, useEffect as useEffect$2, forwardRef, useState as useState$1, useCallback, useRef as useRef$1, Suspense, createElement, memo as memo$2, useImperativeHandle, Children, isValidElement, cloneElement, Fragment as Fragment$2, useReducer, useId as useId$2, useInsertionEffect as useInsertionEffect$1, Component } from "react";
9
9
  var classnames = { exports: {} };
@@ -83,7 +83,7 @@ function t$2(t2) {
83
83
  }
84
84
  const e = {}, n$1 = {}, r$4 = {}, i$2 = {}, s$2 = {}, o$4 = {}, l$2 = {}, c$3 = {}, a$3 = {}, u$6 = {}, f$2 = {}, d$2 = {}, h$4 = {}, g$5 = {}, _$2 = {}, p$8 = {}, y$3 = {}, m$8 = {}, x$6 = {}, v$4 = {}, S$4 = {}, T$3 = {}, C$3 = {}, k$3 = {}, b$2 = {}, w$3 = {}, N$2 = {}, E$6 = {}, P$2 = {}, D$5 = {}, F$1 = {}, L$3 = {}, O$2 = {}, I$2 = {}, A$3 = {}, M$4 = {}, z$1 = {}, W$2 = {}, B$2 = {}, R$3 = {}, K$2 = {}, J$2 = {}, U$2 = {}, V$2 = {}, $$1 = {}, H$2 = "undefined" != typeof window && void 0 !== window.document && void 0 !== window.document.createElement, j = H$2 && "documentMode" in document ? document.documentMode : null, q = H$2 && /Mac|iPod|iPhone|iPad/.test(navigator.platform), Q$3 = H$2 && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent), X$4 = !(!H$2 || !("InputEvent" in window) || j) && "getTargetRanges" in new window.InputEvent("input"), Y$3 = H$2 && /Version\/[\d.]+.*Safari/.test(navigator.userAgent), Z$2 = H$2 && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream, G$3 = H$2 && /Android/.test(navigator.userAgent), tt = H$2 && /^(?=.*Chrome).*/i.test(navigator.userAgent), et = H$2 && G$3 && tt, nt = H$2 && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !tt, rt = 1, it = 3, st$1 = 0, ot = 1, lt$1 = 2, ct$1 = 0, at$1 = 1, ut$1 = 2, ht = 4, gt$1 = 8, mt$1 = 128, xt = 112 | (3 | ht | gt$1) | mt$1, vt = 1, St = 2, Tt$1 = 3, Ct = 4, kt = 5, bt = 6, wt = Y$3 || Z$2 || nt ? " " : "​", Nt$1 = "\n\n", Et = Q$3 ? " " : wt, Pt = "֑-߿יִ-﷽ﹰ-ﻼ", Dt = "A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿", Ft = new RegExp("^[^" + Dt + "]*[" + Pt + "]"), Lt = new RegExp("^[^" + Pt + "]*[" + Dt + "]"), Ot$1 = { bold: 1, code: 16, highlight: mt$1, italic: 2, strikethrough: ht, subscript: 32, superscript: 64, underline: gt$1 }, It$1 = { directionless: 1, unmergeable: 2 }, At = { center: St, end: bt, justify: Ct, left: vt, right: Tt$1, start: kt }, Mt = { [St]: "center", [bt]: "end", [Ct]: "justify", [vt]: "left", [Tt$1]: "right", [kt]: "start" }, zt = { normal: 0, segmented: 2, token: 1 }, Wt = { [ct$1]: "normal", [ut$1]: "segmented", [at$1]: "token" };
85
85
  function Bt(t2) {
86
- return t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
86
+ return t2 && t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
87
87
  }
88
88
  var Rt = Bt(function(t2) {
89
89
  const e2 = new URLSearchParams();
@@ -3748,7 +3748,7 @@ function Fs(t2, e2, n2, r2) {
3748
3748
  null !== s2 && (s2.disconnect(), t2._observer = null), null !== e2 && (e2.textContent = ""), null !== n2 && (n2.textContent = "", i.set("root", n2));
3749
3749
  }
3750
3750
  function Ls(t2) {
3751
- const e2 = t2, n2 = Gi$1(), r2 = e2.theme || {}, i = void 0 === t2 ? n2 : e2.parentEditor || null, s2 = e2.disableEvents || false, o2 = ms(), l2 = e2.namespace || (null !== i ? i._config.namespace : Fe$1()), c2 = e2.editorState, a2 = [ps, qr, zr, oi$1, Ts, Ss, ...e2.nodes || []], { onError: u2, html: f2 } = e2, d2 = void 0 === e2.editable || e2.editable;
3751
+ const e2 = t2 || {}, n2 = Gi$1(), r2 = e2.theme || {}, i = void 0 === t2 ? n2 : e2.parentEditor || null, s2 = e2.disableEvents || false, o2 = ms(), l2 = e2.namespace || (null !== i ? i._config.namespace : Fe$1()), c2 = e2.editorState, a2 = [ps, qr, zr, oi$1, Ts, Ss, ...e2.nodes || []], { onError: u2, html: f2 } = e2, d2 = void 0 === e2.editable || e2.editable;
3752
3752
  let h2;
3753
3753
  if (void 0 === t2 && null !== n2) h2 = n2._nodes;
3754
3754
  else {
@@ -3998,7 +3998,7 @@ class Os {
3998
3998
  }
3999
3999
  }
4000
4000
  function r$3(e2) {
4001
- return e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
4001
+ return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
4002
4002
  }
4003
4003
  var t$1 = r$3(function(e2) {
4004
4004
  const n2 = new URLSearchParams();
@@ -4083,7 +4083,7 @@ function g$4(t2) {
4083
4083
  return () => c$2(t2);
4084
4084
  }
4085
4085
  function d$1(t2) {
4086
- return t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
4086
+ return t2 && t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
4087
4087
  }
4088
4088
  d$1(function(t2) {
4089
4089
  const e2 = new URLSearchParams();
@@ -4092,7 +4092,7 @@ d$1(function(t2) {
4092
4092
  throw Error(`Minified Lexical error #${t2}; visit https://lexical.dev/docs/error?${e2} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
4093
4093
  });
4094
4094
  function m$6(e2) {
4095
- return e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
4095
+ return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
4096
4096
  }
4097
4097
  m$6(function(e2) {
4098
4098
  const t2 = new URLSearchParams();
@@ -4147,7 +4147,7 @@ function M$3(e2, t2, n2) {
4147
4147
  L$2(e2, t2, n2 ? !l2 : l2, "character");
4148
4148
  }
4149
4149
  function g$3(e2) {
4150
- return e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
4150
+ return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
4151
4151
  }
4152
4152
  var p$6 = g$3(function(e2) {
4153
4153
  const t2 = new URLSearchParams();
@@ -10797,6 +10797,9 @@ function jl(a2, b2) {
10797
10797
  il(a2, b2);
10798
10798
  (a2 = a2.alternate) && il(a2, b2);
10799
10799
  }
10800
+ function kl() {
10801
+ return null;
10802
+ }
10800
10803
  var ll = "function" === typeof reportError ? reportError : function(a2) {
10801
10804
  console.error(a2);
10802
10805
  };
@@ -10969,7 +10972,7 @@ var tl = { usingClientEntryPoint: false, Events: [Cb, ue$1, Db, Eb, Fb, Rk] }, u
10969
10972
  var vl = { bundleType: ul.bundleType, version: ul.version, rendererPackageName: ul.rendererPackageName, rendererConfig: ul.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, overrideProps: null, overridePropsDeletePath: null, overridePropsRenamePath: null, setErrorHandler: null, setSuspenseHandler: null, scheduleUpdate: null, currentDispatcherRef: ua.ReactCurrentDispatcher, findHostInstanceByFiber: function(a2) {
10970
10973
  a2 = Zb(a2);
10971
10974
  return null === a2 ? null : a2.stateNode;
10972
- }, findFiberByHostInstance: ul.findFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, reconcilerVersion: "18.2.0-next-9e3b772b8-20220608" };
10975
+ }, findFiberByHostInstance: ul.findFiberByHostInstance || kl, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, reconcilerVersion: "18.2.0-next-9e3b772b8-20220608" };
10973
10976
  if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
10974
10977
  var wl = __REACT_DEVTOOLS_GLOBAL_HOOK__;
10975
10978
  if (!wl.isDisabled && wl.supportsFiber) try {
@@ -11206,7 +11209,7 @@ function y$1(e2, n2, t2) {
11206
11209
  return l2;
11207
11210
  }
11208
11211
  function x$1(t2) {
11209
- return t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
11212
+ return t2 && t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
11210
11213
  }
11211
11214
  var w$1 = x$1(function(t2) {
11212
11215
  const e2 = new URLSearchParams();
@@ -11718,17 +11721,6 @@ const AtSign = createLucideIcon("AtSign", [
11718
11721
  ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
11719
11722
  ["path", { d: "M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8", key: "7n84p3" }]
11720
11723
  ]);
11721
- /**
11722
- * @license lucide-react v0.378.0 - ISC
11723
- *
11724
- * This source code is licensed under the ISC license.
11725
- * See the LICENSE file in the root directory of this source tree.
11726
- */
11727
- const BetweenHorizontalEnd = createLucideIcon("BetweenHorizontalEnd", [
11728
- ["rect", { width: "13", height: "7", x: "3", y: "3", rx: "1", key: "11xb64" }],
11729
- ["path", { d: "m22 15-3-3 3-3", key: "26chmm" }],
11730
- ["rect", { width: "13", height: "7", x: "3", y: "14", rx: "1", key: "k6ky7n" }]
11731
- ]);
11732
11724
  /**
11733
11725
  * @license lucide-react v0.378.0 - ISC
11734
11726
  *
@@ -12014,6 +12006,39 @@ const Columns2 = createLucideIcon("Columns2", [
12014
12006
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
12015
12007
  ["path", { d: "M12 3v18", key: "108xh3" }]
12016
12008
  ]);
12009
+ /**
12010
+ * @license lucide-react v0.378.0 - ISC
12011
+ *
12012
+ * This source code is licensed under the ISC license.
12013
+ * See the LICENSE file in the root directory of this source tree.
12014
+ */
12015
+ const DatabaseBackup = createLucideIcon("DatabaseBackup", [
12016
+ ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
12017
+ ["path", { d: "M3 12a9 3 0 0 0 5 2.69", key: "1ui2ym" }],
12018
+ ["path", { d: "M21 9.3V5", key: "6k6cib" }],
12019
+ ["path", { d: "M3 5v14a9 3 0 0 0 6.47 2.88", key: "i62tjy" }],
12020
+ ["path", { d: "M12 12v4h4", key: "1bxaet" }],
12021
+ [
12022
+ "path",
12023
+ {
12024
+ d: "M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",
12025
+ key: "1f4ei9"
12026
+ }
12027
+ ]
12028
+ ]);
12029
+ /**
12030
+ * @license lucide-react v0.378.0 - ISC
12031
+ *
12032
+ * This source code is licensed under the ISC license.
12033
+ * See the LICENSE file in the root directory of this source tree.
12034
+ */
12035
+ const DatabaseZap = createLucideIcon("DatabaseZap", [
12036
+ ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
12037
+ ["path", { d: "M3 5V19A9 3 0 0 0 15 21.84", key: "14ibmq" }],
12038
+ ["path", { d: "M21 5V8", key: "1marbg" }],
12039
+ ["path", { d: "M21 12L18 17H22L19 22", key: "zafso" }],
12040
+ ["path", { d: "M3 12A9 3 0 0 0 14.59 14.87", key: "1y4wr8" }]
12041
+ ]);
12017
12042
  /**
12018
12043
  * @license lucide-react v0.378.0 - ISC
12019
12044
  *
@@ -12206,6 +12231,17 @@ const GitCompare = createLucideIcon("GitCompare", [
12206
12231
  ["path", { d: "M13 6h3a2 2 0 0 1 2 2v7", key: "1yeb86" }],
12207
12232
  ["path", { d: "M11 18H8a2 2 0 0 1-2-2V9", key: "19pyzm" }]
12208
12233
  ]);
12234
+ /**
12235
+ * @license lucide-react v0.378.0 - ISC
12236
+ *
12237
+ * This source code is licensed under the ISC license.
12238
+ * See the LICENSE file in the root directory of this source tree.
12239
+ */
12240
+ const Globe = createLucideIcon("Globe", [
12241
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
12242
+ ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
12243
+ ["path", { d: "M2 12h20", key: "9i4pu4" }]
12244
+ ]);
12209
12245
  /**
12210
12246
  * @license lucide-react v0.378.0 - ISC
12211
12247
  *
@@ -12485,6 +12521,16 @@ const Plus = createLucideIcon("Plus", [
12485
12521
  ["path", { d: "M5 12h14", key: "1ays0h" }],
12486
12522
  ["path", { d: "M12 5v14", key: "s699le" }]
12487
12523
  ]);
12524
+ /**
12525
+ * @license lucide-react v0.378.0 - ISC
12526
+ *
12527
+ * This source code is licensed under the ISC license.
12528
+ * See the LICENSE file in the root directory of this source tree.
12529
+ */
12530
+ const Power = createLucideIcon("Power", [
12531
+ ["path", { d: "M12 2v10", key: "mnfbl" }],
12532
+ ["path", { d: "M18.4 6.6a9 9 0 1 1-12.77.04", key: "obofu9" }]
12533
+ ]);
12488
12534
  /**
12489
12535
  * @license lucide-react v0.378.0 - ISC
12490
12536
  *
@@ -12497,6 +12543,23 @@ const RefreshCw = createLucideIcon("RefreshCw", [
12497
12543
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
12498
12544
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
12499
12545
  ]);
12546
+ /**
12547
+ * @license lucide-react v0.378.0 - ISC
12548
+ *
12549
+ * This source code is licensed under the ISC license.
12550
+ * See the LICENSE file in the root directory of this source tree.
12551
+ */
12552
+ const Save = createLucideIcon("Save", [
12553
+ [
12554
+ "path",
12555
+ {
12556
+ d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
12557
+ key: "1c8476"
12558
+ }
12559
+ ],
12560
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
12561
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
12562
+ ]);
12500
12563
  /**
12501
12564
  * @license lucide-react v0.378.0 - ISC
12502
12565
  *
@@ -12507,6 +12570,18 @@ const Search = createLucideIcon("Search", [
12507
12570
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
12508
12571
  ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
12509
12572
  ]);
12573
+ /**
12574
+ * @license lucide-react v0.378.0 - ISC
12575
+ *
12576
+ * This source code is licensed under the ISC license.
12577
+ * See the LICENSE file in the root directory of this source tree.
12578
+ */
12579
+ const Server = createLucideIcon("Server", [
12580
+ ["rect", { width: "20", height: "8", x: "2", y: "2", rx: "2", ry: "2", key: "ngkwjq" }],
12581
+ ["rect", { width: "20", height: "8", x: "2", y: "14", rx: "2", ry: "2", key: "iecqi9" }],
12582
+ ["line", { x1: "6", x2: "6.01", y1: "6", y2: "6", key: "16zg32" }],
12583
+ ["line", { x1: "6", x2: "6.01", y1: "18", y2: "18", key: "nzw8ys" }]
12584
+ ]);
12510
12585
  /**
12511
12586
  * @license lucide-react v0.378.0 - ISC
12512
12587
  *
@@ -13872,7 +13947,7 @@ function useExtensionAPI() {
13872
13947
  new Proxy(
13873
13948
  {
13874
13949
  chatModels: () => Observable.of([]),
13875
- evaluateFeatureFlag: () => Observable.of(false)
13950
+ evaluatedFeatureFlag: () => Observable.of(false)
13876
13951
  },
13877
13952
  {
13878
13953
  get: (obj, property) => {
@@ -21302,8 +21377,8 @@ var Leaf = /* @__PURE__ */ function(RopeSequence3) {
21302
21377
  RopeSequence3.call(this);
21303
21378
  this.values = values;
21304
21379
  }
21305
- Leaf2.__proto__ = RopeSequence3;
21306
- Leaf2.prototype = Object.create(RopeSequence3.prototype);
21380
+ if (RopeSequence3) Leaf2.__proto__ = RopeSequence3;
21381
+ Leaf2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
21307
21382
  Leaf2.prototype.constructor = Leaf2;
21308
21383
  var prototypeAccessors = { length: { configurable: true }, depth: { configurable: true } };
21309
21384
  Leaf2.prototype.flatten = function flatten() {
@@ -21360,8 +21435,8 @@ var Append = /* @__PURE__ */ function(RopeSequence3) {
21360
21435
  this.length = left.length + right.length;
21361
21436
  this.depth = Math.max(left.depth, right.depth) + 1;
21362
21437
  }
21363
- Append2.__proto__ = RopeSequence3;
21364
- Append2.prototype = Object.create(RopeSequence3.prototype);
21438
+ if (RopeSequence3) Append2.__proto__ = RopeSequence3;
21439
+ Append2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
21365
21440
  Append2.prototype.constructor = Append2;
21366
21441
  Append2.prototype.flatten = function flatten() {
21367
21442
  return this.left.flatten().concat(this.right.flatten());
@@ -39058,6 +39133,7 @@ const badgeVariants = cva(
39058
39133
  ghost: "tw-bg-muted-transparent tw-text-muted-foreground",
39059
39134
  cody: "tw-bg-gradient-to-r tw-from-sourcegraph-blue tw-via-sourcegraph-purple tw-to-sourcegraph-orange tw-text-badge-foreground",
39060
39135
  warning: "tw-bg-yellow-900 tw-text-yellow-300",
39136
+ success: "tw-bg-green-900 tw-text-green-300",
39061
39137
  info: "tw-bg-blue-900 tw-text-blue-300",
39062
39138
  error: "tw-bg-pink-900 tw-text-pink-300",
39063
39139
  disabled: "tw-bg-gray-900 tw-text-gray-300"
@@ -40128,6 +40204,22 @@ const $5d3850c4d0b4e6c7$export$3ddf2d174ce01153 = (props) => {
40128
40204
  modal
40129
40205
  }, children2);
40130
40206
  };
40207
+ const $5d3850c4d0b4e6c7$var$TRIGGER_NAME = "DialogTrigger";
40208
+ const $5d3850c4d0b4e6c7$export$2e1e1122cf0cba88 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
40209
+ const { __scopeDialog, ...triggerProps } = props;
40210
+ const context2 = $5d3850c4d0b4e6c7$var$useDialogContext($5d3850c4d0b4e6c7$var$TRIGGER_NAME, __scopeDialog);
40211
+ const composedTriggerRef = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context2.triggerRef);
40212
+ return /* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends$1({
40213
+ type: "button",
40214
+ "aria-haspopup": "dialog",
40215
+ "aria-expanded": context2.open,
40216
+ "aria-controls": context2.contentId,
40217
+ "data-state": $5d3850c4d0b4e6c7$var$getState(context2.open)
40218
+ }, triggerProps, {
40219
+ ref: composedTriggerRef,
40220
+ onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onClick, context2.onOpenToggle)
40221
+ }));
40222
+ });
40131
40223
  const $5d3850c4d0b4e6c7$var$PORTAL_NAME = "DialogPortal";
40132
40224
  const [$5d3850c4d0b4e6c7$var$PortalProvider, $5d3850c4d0b4e6c7$var$usePortalContext] = $5d3850c4d0b4e6c7$var$createDialogContext($5d3850c4d0b4e6c7$var$PORTAL_NAME, {
40133
40225
  forceMount: void 0
@@ -41816,8 +41908,8 @@ function useClientConfig() {
41816
41908
  return useContext(ClientConfigContext);
41817
41909
  }
41818
41910
  function useFeatureFlag(flag) {
41819
- const evaluateFeatureFlag = useExtensionAPI().evaluateFeatureFlag;
41820
- return useObservable(useMemo$1(() => evaluateFeatureFlag(flag), [evaluateFeatureFlag, flag])).value;
41911
+ const evaluatedFeatureFlag = useExtensionAPI().evaluatedFeatureFlag;
41912
+ return useObservable(useMemo$1(() => evaluatedFeatureFlag(flag), [evaluatedFeatureFlag, flag])).value;
41821
41913
  }
41822
41914
  const useOmniBox = () => {
41823
41915
  const config = useClientConfig();
@@ -65380,7 +65472,7 @@ function escapeStringRegexp(string2) {
65380
65472
  return string2.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
65381
65473
  }
65382
65474
  function findAndReplace(tree, list2, options) {
65383
- const settings = options;
65475
+ const settings = options || {};
65384
65476
  const ignored = convert$1(settings.ignore || []);
65385
65477
  const pairs = toPairs(list2);
65386
65478
  let pairIndex = -1;
@@ -66745,7 +66837,7 @@ function replace($0, $1) {
66745
66837
  return $1 === "|" ? $1 : $0;
66746
66838
  }
66747
66839
  function gfmTableToMarkdown(options) {
66748
- const settings = options;
66840
+ const settings = options || {};
66749
66841
  const padding = settings.tableCellPadding;
66750
66842
  const alignDelimiters = settings.tablePipeAlign;
66751
66843
  const stringLength = settings.stringLength;
@@ -67554,7 +67646,7 @@ function tokenizeIndent(effects, ok2, nok) {
67554
67646
  }
67555
67647
  }
67556
67648
  function gfmStrikethrough(options) {
67557
- const options_ = options;
67649
+ const options_ = options || {};
67558
67650
  let single = options_.singleTilde;
67559
67651
  const tokenizer = {
67560
67652
  tokenize: tokenizeStrikethrough,
@@ -71760,9 +71852,14 @@ const CloseIcon = (
71760
71852
  );
71761
71853
  const RefreshIcon = /* @__PURE__ */ jsx("i", { className: "codicon codicon-refresh tw-align-middle" });
71762
71854
  function createEditButtons(params) {
71763
- return params.smartApply ? createEditButtonsSmartApply(params) : createEditButtonsBasic(params.preText, params.copyButtonOnSubmit, params.onInsert);
71855
+ return params.smartApply ? createEditButtonsSmartApply(params) : createEditButtonsBasic(
71856
+ params.preText,
71857
+ params.copyButtonOnSubmit,
71858
+ params.onInsert,
71859
+ params.onExecute
71860
+ );
71764
71861
  }
71765
- function createEditButtonsBasic(preText, copyButtonOnSubmit, insertButtonOnSubmit) {
71862
+ function createEditButtonsBasic(preText, copyButtonOnSubmit, insertButtonOnSubmit, onExecute) {
71766
71863
  if (!copyButtonOnSubmit) {
71767
71864
  return /* @__PURE__ */ jsx("div", {});
71768
71865
  }
@@ -71793,7 +71890,8 @@ function createEditButtonsBasic(preText, copyButtonOnSubmit, insertButtonOnSubmi
71793
71890
  SaveCodeBlockIcon,
71794
71891
  codeBlockActions
71795
71892
  )
71796
- ] })
71893
+ ] }),
71894
+ onExecute && createExecuteButton(onExecute)
71797
71895
  ] });
71798
71896
  }
71799
71897
  function getLineChanges(text2) {
@@ -71806,21 +71904,13 @@ function getLineChanges(text2) {
71806
71904
  }
71807
71905
  return { additions, deletions };
71808
71906
  }
71809
- function createEditButtonsSmartApply({
71810
- preText,
71907
+ function createAdditionsDeletions({
71811
71908
  hasEditIntent,
71812
- isVSCode,
71813
- isShellCommand,
71814
- copyButtonOnSubmit,
71815
- onInsert,
71816
- onSmartApply,
71817
- smartApply,
71818
- smartApplyId,
71819
- smartApplyState
71909
+ preText
71820
71910
  }) {
71821
71911
  const { additions, deletions } = getLineChanges(preText);
71822
71912
  const hasAdditionsDeletions = hasEditIntent && (additions >= 0 || deletions >= 0);
71823
- const preview = hasAdditionsDeletions && /* @__PURE__ */ jsx("div", { className: styles$q.buttonContainer, children: /* @__PURE__ */ jsx("div", { children: hasAdditionsDeletions && /* @__PURE__ */ jsxs(Fragment$1, { children: [
71913
+ return /* @__PURE__ */ jsx("div", { children: hasAdditionsDeletions && /* @__PURE__ */ jsxs(Fragment$1, { children: [
71824
71914
  /* @__PURE__ */ jsxs("span", { className: clsx$1(styles$q.addition, styles$q.stats), children: [
71825
71915
  "+",
71826
71916
  additions
@@ -71831,28 +71921,36 @@ function createEditButtonsSmartApply({
71831
71921
  "-",
71832
71922
  deletions
71833
71923
  ] })
71834
- ] }) }) });
71924
+ ] }) });
71925
+ }
71926
+ function createEditButtonsSmartApply({
71927
+ preText,
71928
+ isVSCode,
71929
+ copyButtonOnSubmit,
71930
+ onInsert,
71931
+ onSmartApply,
71932
+ onExecute,
71933
+ smartApply,
71934
+ smartApplyId,
71935
+ smartApplyState
71936
+ }) {
71835
71937
  const copyButton2 = createCopyButton(preText, copyButtonOnSubmit ?? (() => {
71836
71938
  }));
71837
- const buttons2 = /* @__PURE__ */ jsx("div", { className: styles$q.buttonContainer, children: /* @__PURE__ */ jsxs("div", { className: styles$q.buttons, children: [
71939
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
71838
71940
  smartApplyState !== CodyTaskState.Applied && copyButtonOnSubmit && copyButton2,
71839
71941
  smartApply && smartApplyId && smartApplyState === CodyTaskState.Applied && /* @__PURE__ */ jsxs(Fragment$1, { children: [
71840
71942
  createAcceptButton(smartApplyId, smartApply),
71841
71943
  createRejectButton(smartApplyId, smartApply)
71842
71944
  ] }),
71843
- smartApply && smartApplyId && smartApplyState !== CodyTaskState.Applied && /* @__PURE__ */ jsxs(Fragment$1, { children: [
71844
- isShellCommand && isVSCode && createExecuteButton(preText),
71845
- !isShellCommand && onSmartApply && createApplyButton(onSmartApply, smartApplyState)
71945
+ smartApplyState !== CodyTaskState.Applied && /* @__PURE__ */ jsxs(Fragment$1, { children: [
71946
+ onExecute && isVSCode && createExecuteButton(onExecute),
71947
+ !onExecute && smartApply && onSmartApply && createApplyButton(onSmartApply, smartApplyState)
71846
71948
  ] }),
71847
71949
  isVSCode && createActionsDropdown(preText),
71848
71950
  !isVSCode && /* @__PURE__ */ jsxs(Fragment$1, { children: [
71849
71951
  createInsertButton(preText, onInsert),
71850
71952
  createSaveButton(preText, onInsert)
71851
71953
  ] })
71852
- ] }) });
71853
- return /* @__PURE__ */ jsxs("div", { children: [
71854
- preview,
71855
- buttons2
71856
71954
  ] });
71857
71955
  }
71858
71956
  function createInsertButton(preText, insertButtonOnSubmit) {
@@ -71960,28 +72058,11 @@ function createApplyButton(onSmartApply, smartApplyState) {
71960
72058
  }
71961
72059
  );
71962
72060
  }
71963
- function createExecuteButton(command) {
71964
- const handleClick = useCallback(
71965
- () => getVSCodeAPI().postMessage({
71966
- command: "command",
71967
- id: "cody.terminal.execute",
71968
- arg: command.trim()
71969
- }),
71970
- [command]
71971
- );
71972
- return /* @__PURE__ */ jsxs(
71973
- "button",
71974
- {
71975
- type: "button",
71976
- className: styles$q.button,
71977
- onClick: handleClick,
71978
- title: "Execute in Terminal",
71979
- children: [
71980
- /* @__PURE__ */ jsx("div", { className: styles$q.iconContainer, children: /* @__PURE__ */ jsx("i", { className: "codicon codicon-terminal tw-align-middle" }) }),
71981
- "Send command to Terminal"
71982
- ]
71983
- }
71984
- );
72061
+ function createExecuteButton(onExecute) {
72062
+ return /* @__PURE__ */ jsxs("button", { type: "button", className: styles$q.button, onClick: onExecute, title: "Execute in Terminal", children: [
72063
+ /* @__PURE__ */ jsx("div", { className: clsx$1(styles$q.iconContainer, "tw-align-middle codicon codicon-terminal") }),
72064
+ "Execute"
72065
+ ] });
71985
72066
  }
71986
72067
  function createAcceptButton(id2, smartApply) {
71987
72068
  return /* @__PURE__ */ jsxs("button", { type: "button", className: styles$q.button, onClick: () => smartApply.onAccept(id2), children: [
@@ -72055,36 +72136,51 @@ function extractThinkContent(content2) {
72055
72136
  isThinking
72056
72137
  };
72057
72138
  }
72058
- const container$3 = "_container_c9w5f_15";
72059
- const line$1 = "_line_c9w5f_22";
72060
- const shimmer = "_shimmer_c9w5f_1";
72139
+ const container$3 = "_container_zq4rk_15";
72140
+ const line$1 = "_line_zq4rk_22";
72141
+ const guardrailsChecking = "_guardrails-checking_zq4rk_30";
72142
+ const shimmer = "_shimmer_zq4rk_1";
72061
72143
  const modulestyles = {
72062
72144
  container: container$3,
72063
72145
  line: line$1,
72146
+ guardrailsChecking,
72064
72147
  shimmer
72065
72148
  };
72066
72149
  const CodeBlockPlaceholder = ({
72067
72150
  text: text2,
72151
+ status: status2,
72068
72152
  className
72069
72153
  }) => {
72070
72154
  const widths = text2.split("\n").map((s2) => s2.length);
72071
- return /* @__PURE__ */ jsx("div", { className: clsx$1(styles$q.content, "tw-overflow-hidden tw-p-4", className), children: widths.map((width, index2) => /* @__PURE__ */ jsx(
72155
+ return /* @__PURE__ */ jsx(
72072
72156
  "div",
72073
72157
  {
72074
- className: clsx$1("tw-h-6 tw-my-2 tw-rounded", modulestyles.line),
72075
- style: {
72076
- width: `${width}em`
72077
- }
72078
- },
72079
- `${index2}-${width}`
72080
- )) });
72158
+ className: clsx$1(
72159
+ styles$q.content,
72160
+ "tw-overflow-hidden tw-p-4",
72161
+ className,
72162
+ status2 === GuardrailsCheckStatus.GeneratingCode || status2 === GuardrailsCheckStatus.Checking ? modulestyles.guardrailsChecking : modulestyles.guardrailsChecked
72163
+ ),
72164
+ children: widths.map((width, index2) => /* @__PURE__ */ jsx(
72165
+ "div",
72166
+ {
72167
+ className: clsx$1("tw-h-6 tw-my-2 tw-rounded", modulestyles.line),
72168
+ style: {
72169
+ width: `${width}em`
72170
+ }
72171
+ },
72172
+ `${index2}-${width}`
72173
+ ))
72174
+ }
72175
+ );
72081
72176
  };
72082
72177
  const GuardrailsStatus = ({
72178
+ children: children2,
72083
72179
  status: status2,
72084
72180
  filename,
72085
72181
  tooltip,
72086
72182
  className,
72087
- onRetry
72183
+ onSuccessAuxClick
72088
72184
  }) => {
72089
72185
  const containerClasses = clsx$1(
72090
72186
  "tw-flex tw-items-center tw-gap-1",
@@ -72101,7 +72197,7 @@ const GuardrailsStatus = ({
72101
72197
  /* @__PURE__ */ jsx(Loader, { className: clsx$1("tw-animate-spin", styles$q.iconContainer), size: 14 }),
72102
72198
  /* @__PURE__ */ jsx("span", { className: styles$q.fileNameContainer, children: "Checking Guardrails" })
72103
72199
  ] }),
72104
- status2 === GuardrailsCheckStatus.Success && /* @__PURE__ */ jsxs("div", { className: styles$q.status, title: filename, children: [
72200
+ status2 === GuardrailsCheckStatus.Success && /* @__PURE__ */ jsxs("div", { className: styles$q.status, title: filename, onAuxClick: onSuccessAuxClick, children: [
72105
72201
  /* @__PURE__ */ jsx(
72106
72202
  CircleCheckBig,
72107
72203
  {
@@ -72129,33 +72225,27 @@ const GuardrailsStatus = ({
72129
72225
  ),
72130
72226
  /* @__PURE__ */ jsx("span", { className: styles$q.fileNameContainer, children: filename.split("/").pop() })
72131
72227
  ] }),
72132
- status2 === GuardrailsCheckStatus.Failed && /* @__PURE__ */ jsx("div", { className: styles$q.status, children: /* @__PURE__ */ jsx(
72133
- TriangleAlert,
72134
- {
72135
- size: 14,
72136
- className: clsx$1(styles$q.attributionIconFound, styles$q.iconContainer)
72137
- }
72138
- ) }),
72139
- status2 === GuardrailsCheckStatus.Error && /* @__PURE__ */ jsxs("div", { className: styles$q.status, children: [
72228
+ status2 === GuardrailsCheckStatus.Failed && /* @__PURE__ */ jsxs("div", { className: styles$q.status, children: [
72140
72229
  /* @__PURE__ */ jsx(
72141
72230
  TriangleAlert,
72142
72231
  {
72143
72232
  size: 14,
72144
- className: clsx$1(styles$q.attributionIconUnavailable, styles$q.iconContainer)
72233
+ className: clsx$1(styles$q.attributionIconFound, styles$q.iconContainer)
72145
72234
  }
72146
72235
  ),
72147
- /* @__PURE__ */ jsx("span", { className: styles$q.fileNameContainer, children: "Guardrails API Error" }),
72148
- onRetry && /* @__PURE__ */ jsx(
72149
- "button",
72236
+ /* @__PURE__ */ jsx("span", { className: styles$q.fileNameContainer, children: "Guardrails: Match found" })
72237
+ ] }),
72238
+ status2 === GuardrailsCheckStatus.Error && /* @__PURE__ */ jsxs("div", { className: styles$q.status, children: [
72239
+ /* @__PURE__ */ jsx(
72240
+ TriangleAlert,
72150
72241
  {
72151
- onClick: onRetry,
72152
- type: "button",
72153
- className: styles$q.button,
72154
- title: "Retry Guardrails check",
72155
- children: /* @__PURE__ */ jsx("div", { className: styles$q.iconContainer, children: /* @__PURE__ */ jsx(RefreshCw, { size: 12 }) })
72242
+ size: 14,
72243
+ className: clsx$1(styles$q.attributionIconUnavailable, styles$q.iconContainer)
72156
72244
  }
72157
- )
72158
- ] })
72245
+ ),
72246
+ /* @__PURE__ */ jsx("span", { className: styles$q.fileNameContainer, children: "Guardrails API Error" })
72247
+ ] }),
72248
+ children2
72159
72249
  ] });
72160
72250
  };
72161
72251
  function parseAttributionResult(result2) {
@@ -72251,11 +72341,14 @@ class GuardrailsCache {
72251
72341
  }
72252
72342
  const guardrailsCache = new GuardrailsCache();
72253
72343
  const GuardrailsApplicator = ({
72254
- code: code2,
72344
+ plainCode,
72345
+ markdownCode,
72255
72346
  language: language2,
72256
72347
  fileName,
72257
72348
  guardrails,
72349
+ isMessageLoading,
72258
72350
  isCodeComplete,
72351
+ onRegenerate,
72259
72352
  children: children2
72260
72353
  }) => {
72261
72354
  const [guardrailsResult, setGuardrailsResult] = useState$1(
@@ -72264,13 +72357,13 @@ const GuardrailsApplicator = ({
72264
72357
  // TypeScript can't tie the knot of the setGuardrailsResult type if we
72265
72358
  // use setGuardrailsResult here. Instead, we rely on the effect below
72266
72359
  // collecting the asynchronous result if necessary.
72267
- guardrailsCache.getStatus(guardrails, isCodeComplete, code2, language2, () => {
72360
+ guardrailsCache.getStatus(guardrails, isCodeComplete, plainCode, language2, () => {
72268
72361
  })
72269
72362
  )
72270
72363
  );
72271
72364
  useEffect$2(() => {
72272
72365
  if (isCodeComplete) {
72273
- if (!guardrails.needsAttribution({ code: code2, language: language2 })) {
72366
+ if (!guardrails.needsAttribution({ code: plainCode, language: language2 })) {
72274
72367
  setGuardrailsResult({
72275
72368
  status: GuardrailsCheckStatus.Skipped
72276
72369
  });
@@ -72280,13 +72373,13 @@ const GuardrailsApplicator = ({
72280
72373
  guardrailsCache.getStatus(
72281
72374
  guardrails,
72282
72375
  isCodeComplete,
72283
- code2,
72376
+ plainCode,
72284
72377
  language2,
72285
72378
  setGuardrailsResult
72286
72379
  )
72287
72380
  );
72288
72381
  }
72289
- }, [guardrails, isCodeComplete, code2, language2]);
72382
+ }, [guardrails, isCodeComplete, plainCode, language2]);
72290
72383
  const hideCode = guardrails.shouldHideCodeBeforeAttribution && ![GuardrailsCheckStatus.Skipped, GuardrailsCheckStatus.Success].includes(guardrailsResult.status);
72291
72384
  const showCode = !hideCode;
72292
72385
  const tooltip = useMemo$1(() => {
@@ -72302,55 +72395,103 @@ const GuardrailsApplicator = ({
72302
72395
  return `Found in repositories: ${guardrailsResult.repositories.map((repo) => repo.name).join(", ")}…`;
72303
72396
  case GuardrailsCheckStatus.Error:
72304
72397
  return `Guardrails API error: ${((_a = guardrailsResult.error) == null ? void 0 : _a.message) || "Unknown error"}`;
72398
+ case GuardrailsCheckStatus.Skipped:
72399
+ return "Guardrails check skipped";
72305
72400
  default:
72306
72401
  return "Guardrails status unknown";
72307
72402
  }
72308
72403
  }, [guardrailsResult]);
72309
72404
  const handleRetry = () => {
72310
- guardrailsCache.delete(guardrails, code2);
72405
+ guardrailsCache.delete(guardrails, plainCode);
72311
72406
  setGuardrailsResult(
72312
- guardrailsCache.getStatus(guardrails, isCodeComplete, code2, language2, setGuardrailsResult)
72407
+ guardrailsCache.getStatus(
72408
+ guardrails,
72409
+ isCodeComplete,
72410
+ plainCode,
72411
+ language2,
72412
+ setGuardrailsResult
72413
+ )
72313
72414
  );
72314
72415
  };
72315
- const statusDisplay = /* @__PURE__ */ jsxs(Fragment$1, { children: [
72316
- /* @__PURE__ */ jsx(GuardrailsStatus, { status: guardrailsResult.status, filename: fileName, tooltip }),
72317
- guardrailsResult.status === GuardrailsCheckStatus.Error && /* @__PURE__ */ jsxs(
72318
- "button",
72319
- {
72320
- className: styles$q.button,
72321
- type: "button",
72322
- onClick: handleRetry,
72323
- title: "Retry Guardrails check",
72324
- children: [
72325
- /* @__PURE__ */ jsx("div", { className: styles$q.iconContainer, children: /* @__PURE__ */ jsx(RefreshCw, { size: 14 }) }),
72326
- /* @__PURE__ */ jsx("span", { className: "tw-hidden xs:tw-block", children: "Retry" })
72327
- ]
72416
+ const handleRegenerate = useCallback(() => {
72417
+ onRegenerate == null ? void 0 : onRegenerate(markdownCode, language2);
72418
+ }, [onRegenerate, markdownCode, language2]);
72419
+ const onSuccessAuxClick = useCallback(
72420
+ (event) => {
72421
+ if (!isMessageLoading && event.shiftKey) {
72422
+ handleRegenerate();
72328
72423
  }
72329
- )
72330
- ] });
72424
+ },
72425
+ [isMessageLoading, handleRegenerate]
72426
+ );
72427
+ const statusDisplay = /* @__PURE__ */ jsxs(
72428
+ GuardrailsStatus,
72429
+ {
72430
+ status: guardrailsResult.status,
72431
+ filename: fileName,
72432
+ tooltip,
72433
+ className: styles$q.metadataContainer,
72434
+ onSuccessAuxClick,
72435
+ children: [
72436
+ guardrailsResult.status === GuardrailsCheckStatus.Error && /* @__PURE__ */ jsxs(
72437
+ "button",
72438
+ {
72439
+ className: styles$q.button,
72440
+ type: "button",
72441
+ onClick: handleRetry,
72442
+ title: "Retry Guardrails check",
72443
+ children: [
72444
+ /* @__PURE__ */ jsx("div", { className: styles$q.iconContainer, children: /* @__PURE__ */ jsx(RefreshCw, { size: 14 }) }),
72445
+ /* @__PURE__ */ jsx("span", { className: "tw-hidden xs:tw-block", children: "Retry" })
72446
+ ]
72447
+ }
72448
+ ),
72449
+ // We only display the regenerate button when loading the whole
72450
+ // message is done. Otherwise continued streaming output would
72451
+ // clobber the regenerated code.
72452
+ guardrailsResult.status === GuardrailsCheckStatus.Failed && !isMessageLoading && /* @__PURE__ */ jsxs(
72453
+ "button",
72454
+ {
72455
+ className: styles$q.button,
72456
+ type: "button",
72457
+ onClick: handleRegenerate,
72458
+ title: "Try regenerating code",
72459
+ children: [
72460
+ /* @__PURE__ */ jsx("div", { className: styles$q.iconContainer, children: /* @__PURE__ */ jsx(RefreshCw, { size: 14 }) }),
72461
+ /* @__PURE__ */ jsx("span", { className: "tw-hidden xs:tw-block", children: "Regenerate" })
72462
+ ]
72463
+ }
72464
+ )
72465
+ ]
72466
+ }
72467
+ );
72331
72468
  return /* @__PURE__ */ jsx(Fragment$1, { children: children2({
72332
72469
  showCode,
72333
- guardrailsStatus: statusDisplay
72470
+ guardrailsStatus: guardrailsResult.status,
72471
+ guardrailsStatusDisplay: statusDisplay
72334
72472
  }) });
72335
72473
  };
72336
72474
  const prefetchedEdits = new LRUCache({ max: 100 });
72337
72475
  const RichCodeBlock = ({
72338
72476
  hasEditIntent,
72339
- code: code2,
72477
+ plainCode,
72478
+ markdownCode,
72340
72479
  language: language2,
72341
72480
  fileName,
72481
+ isMessageLoading,
72342
72482
  isCodeComplete,
72343
72483
  isShellCommand,
72344
72484
  guardrails,
72345
72485
  onCopy,
72346
72486
  onInsert,
72347
72487
  onExecute,
72488
+ onRegenerate,
72348
72489
  smartApply,
72349
72490
  className,
72350
72491
  children: children2
72351
72492
  }) => {
72352
72493
  const config = useConfig();
72353
- const smartApplyCode = smartApply && isCodeComplete && !isShellCommand ? code2 : void 0;
72494
+ const smartApplyCode = smartApply && isCodeComplete && !isShellCommand ? plainCode : void 0;
72354
72495
  const smartApplyFilename = smartApply && isCodeComplete && !isShellCommand ? fileName : void 0;
72355
72496
  const thisTaskId = useMemo$1(() => {
72356
72497
  if (!smartApplyCode) {
@@ -72397,42 +72538,49 @@ const RichCodeBlock = ({
72397
72538
  [thisTaskId]
72398
72539
  )
72399
72540
  );
72400
- const actionButtons2 = /* @__PURE__ */ jsxs("div", { className: styles$q.actionButtons, children: [
72401
- isCodeComplete && createEditButtons({
72402
- hasEditIntent,
72403
- isVSCode: config.clientCapabilities.isVSCode,
72404
- preText: code2,
72405
- copyButtonOnSubmit: onCopy,
72406
- onInsert,
72407
- onSmartApply,
72408
- smartApply,
72409
- smartApplyId: thisTaskId,
72410
- smartApplyState,
72411
- isCodeComplete,
72412
- fileName,
72413
- isShellCommand
72414
- }),
72415
- isCodeComplete && isShellCommand && onExecute && createExecuteButton(code2)
72416
- ] });
72541
+ const onExecuteThisScript = useCallback(() => {
72542
+ onExecute == null ? void 0 : onExecute(plainCode);
72543
+ }, [onExecute, plainCode]);
72544
+ const additionsDeletions = smartApply ? /* @__PURE__ */ jsx("div", { className: styles$q.buttonContainer, children: createAdditionsDeletions({
72545
+ hasEditIntent,
72546
+ preText: plainCode
72547
+ }) }) : void 0;
72548
+ const actionButtons2 = /* @__PURE__ */ jsx("div", { className: styles$q.actionButtons, children: isCodeComplete && createEditButtons({
72549
+ isVSCode: config.clientCapabilities.isVSCode,
72550
+ preText: plainCode,
72551
+ copyButtonOnSubmit: onCopy,
72552
+ onInsert,
72553
+ onSmartApply,
72554
+ onExecute: onExecute && onExecuteThisScript,
72555
+ smartApply,
72556
+ smartApplyId: thisTaskId,
72557
+ smartApplyState,
72558
+ isCodeComplete,
72559
+ fileName
72560
+ }) });
72417
72561
  return /* @__PURE__ */ jsx(
72418
72562
  GuardrailsApplicator,
72419
72563
  {
72420
- code: code2,
72564
+ plainCode,
72565
+ markdownCode,
72421
72566
  language: language2,
72422
72567
  fileName,
72423
72568
  guardrails,
72569
+ isMessageLoading,
72424
72570
  isCodeComplete,
72425
- children: ({ showCode, guardrailsStatus }) => /* @__PURE__ */ jsxs("div", { className: clsx$1("tw-overflow-hidden", className), children: [
72571
+ onRegenerate,
72572
+ children: ({ showCode, guardrailsStatus, guardrailsStatusDisplay }) => /* @__PURE__ */ jsxs("div", { className: clsx$1("tw-overflow-hidden", className), children: [
72426
72573
  !showCode ? (
72427
72574
  // When code shouldn't be show, display a placeholder
72428
- /* @__PURE__ */ jsx(CodeBlockPlaceholder, { text: code2 })
72575
+ /* @__PURE__ */ jsx(CodeBlockPlaceholder, { text: plainCode, status: guardrailsStatus })
72429
72576
  ) : (
72430
72577
  // Otherwise show the actual code with syntax highlighting
72431
72578
  /* @__PURE__ */ jsx("pre", { className: styles$q.content, children: children2 })
72432
72579
  ),
72580
+ additionsDeletions,
72433
72581
  /* @__PURE__ */ jsx("div", { className: styles$q.buttonsContainer, children: /* @__PURE__ */ jsxs("div", { className: styles$q.buttons, children: [
72434
72582
  showCode && actionButtons2,
72435
- /* @__PURE__ */ jsx("div", { className: styles$q.metadataContainer, children: guardrailsStatus })
72583
+ guardrailsStatusDisplay
72436
72584
  ] }) })
72437
72585
  ] })
72438
72586
  }
@@ -72455,16 +72603,15 @@ const remarkAttachCompletedCodeBlocks = () => {
72455
72603
  });
72456
72604
  };
72457
72605
  };
72458
- const highlightedMarkdownCache = new LRUCache({
72459
- max: 100
72460
- });
72461
72606
  const RichMarkdown = ({
72462
72607
  markdown: markdown2,
72463
- isLoading = false,
72608
+ isMessageLoading,
72609
+ regeneratingCodeBlocks,
72464
72610
  guardrails,
72465
72611
  onCopy,
72466
72612
  onInsert,
72467
72613
  onExecute,
72614
+ onRegenerate,
72468
72615
  smartApply,
72469
72616
  className,
72470
72617
  hasEditIntent
@@ -72476,100 +72623,43 @@ const RichMarkdown = ({
72476
72623
  }
72477
72624
  const codeNode = node2.children.length === 1 && node2.children[0].type === "element" ? node2.children[0] : null;
72478
72625
  const {
72479
- "data-source-text": cacheKey,
72626
+ "data-source-text": sourceText,
72480
72627
  "data-is-code-complete": isThisBlockComplete,
72481
72628
  "data-file-path": filePath,
72482
72629
  "data-language": language2
72483
72630
  } = (codeNode == null ? void 0 : codeNode.properties) || {
72484
72631
  "data-is-code-complete": false
72485
72632
  };
72486
- let cached = cacheKey && highlightedMarkdownCache.get(cacheKey);
72487
- if (!cached) {
72488
- try {
72489
- const extractText = (node22) => {
72490
- if (typeof node22 === "string") return node22;
72491
- if (!node22) return "";
72492
- if (node22.type === "text" && node22.value) return node22.value;
72493
- if (node22.children) {
72494
- return node22.children.map(extractText).join("");
72495
- }
72496
- return "";
72497
- };
72498
- const plainText = extractText(node2);
72499
- const highlightedHtml = node2.children ? node2.children.map((child) => {
72500
- if (typeof child === "string") return child;
72501
- if (child.type === "text" && child.value) {
72502
- return child.value;
72503
- }
72504
- if (child.type === "element" && child.properties) {
72505
- const childProps = child.properties;
72506
- const childChildren = child.children;
72507
- if (childChildren) {
72508
- const processNode = (node22) => {
72509
- if (typeof node22 === "string") return node22;
72510
- if (!node22) return "";
72511
- if (node22.type === "text" && node22.value) {
72512
- return node22.value;
72513
- }
72514
- if (node22.type === "element" && node22.properties) {
72515
- const props2 = node22.properties;
72516
- const className4 = typeof props2.className === "string" ? props2.className : Array.isArray(props2.className) ? props2.className.join(" ") : "";
72517
- if (node22.children) {
72518
- const content2 = node22.children.map(processNode).join("");
72519
- return `<span class="${className4}">${content2}</span>`;
72520
- }
72521
- return `<span class="${className4}"></span>`;
72522
- }
72523
- if (node22.value) return node22.value;
72524
- if (node22.children) {
72525
- return node22.children.map(processNode).join("");
72526
- }
72527
- return "";
72528
- };
72529
- const childContent = childChildren.map(processNode).join("");
72530
- const className3 = typeof childProps.className === "string" ? childProps.className : Array.isArray(childProps.className) ? childProps.className.join(" ") : "";
72531
- return `<span class="${className3}">${childContent}</span>`;
72532
- }
72533
- }
72534
- if (child.value) return child.value;
72535
- if (child.children) {
72536
- return child.children.map((c2) => {
72537
- if (typeof c2 === "string") return c2;
72538
- if (c2.value) return c2.value;
72539
- return "";
72540
- }).join("");
72541
- }
72542
- return "";
72543
- }).join("") : plainText;
72544
- cached = {
72545
- language: language2,
72546
- highlightedHtml,
72547
- plainText
72548
- };
72549
- if (cacheKey && isThisBlockComplete) {
72550
- highlightedMarkdownCache.set(cacheKey, cached);
72551
- }
72552
- } catch (error2) {
72553
- console.error("Error processing code block:", error2);
72554
- const fallbackCode = String(children2).replace(/\n$/, "");
72555
- const fallbackLanguage = (className2 == null ? void 0 : className2.replace(/language-/, "")) || void 0;
72556
- return guardrails.shouldHideCodeBeforeAttribution ? /* @__PURE__ */ jsx("pre", { children: "Error processing code block." }) : /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { className: clsx$1(fallbackLanguage && `language-${fallbackLanguage}`), children: fallbackCode }) });
72633
+ const extractText = (node22) => {
72634
+ if (typeof node22 === "string") return node22;
72635
+ if (!node22) return "";
72636
+ if (node22.type === "text" && node22.value) return node22.value;
72637
+ if (node22.children) {
72638
+ return node22.children.map(extractText).join("");
72557
72639
  }
72558
- }
72559
- const isShellCommand = cached.language === "bash" || cached.language === "sh";
72640
+ return "";
72641
+ };
72642
+ const plainText = extractText(node2);
72643
+ const isShellCommand = language2 === "bash" || language2 === "sh";
72644
+ const regenerating = regeneratingCodeBlocks.find(
72645
+ (block) => block.code === plainText && !block.error
72646
+ );
72560
72647
  return /* @__PURE__ */ jsx(
72561
72648
  RichCodeBlock,
72562
72649
  {
72563
72650
  hasEditIntent,
72564
- code: cached.plainText,
72565
- language: cached.language,
72651
+ plainCode: plainText,
72652
+ markdownCode: sourceText ?? "",
72653
+ language: language2,
72566
72654
  fileName: filePath,
72567
- isCodeComplete: isThisBlockComplete || !isLoading,
72655
+ isMessageLoading,
72656
+ isCodeComplete: !regenerating && (isThisBlockComplete || !isMessageLoading),
72568
72657
  isShellCommand,
72569
72658
  guardrails,
72570
72659
  onCopy,
72571
72660
  onInsert,
72572
72661
  onExecute: isShellCommand ? onExecute : void 0,
72662
+ onRegenerate,
72573
72663
  smartApply,
72574
72664
  children: children2
72575
72665
  }
@@ -73028,6 +73118,10 @@ const stepsOrder = [
73028
73118
  "postRender"
73029
73119
  // Compute
73030
73120
  ];
73121
+ const statsBuffer = {
73122
+ value: null,
73123
+ addProjectionMetrics: null
73124
+ };
73031
73125
  function createRenderStep(runNextFrame, stepName) {
73032
73126
  let thisFrame = /* @__PURE__ */ new Set();
73033
73127
  let nextFrame = /* @__PURE__ */ new Set();
@@ -73039,11 +73133,13 @@ function createRenderStep(runNextFrame, stepName) {
73039
73133
  timestamp: 0,
73040
73134
  isProcessing: false
73041
73135
  };
73136
+ let numCalls = 0;
73042
73137
  function triggerCallback(callback) {
73043
73138
  if (toKeepAlive.has(callback)) {
73044
73139
  step.schedule(callback);
73045
73140
  runNextFrame();
73046
73141
  }
73142
+ numCalls++;
73047
73143
  callback(latestFrameData);
73048
73144
  }
73049
73145
  const step = {
@@ -73078,6 +73174,10 @@ function createRenderStep(runNextFrame, stepName) {
73078
73174
  isProcessing = true;
73079
73175
  [thisFrame, nextFrame] = [nextFrame, thisFrame];
73080
73176
  thisFrame.forEach(triggerCallback);
73177
+ if (stepName && statsBuffer.value) {
73178
+ statsBuffer.value.frameloop[stepName].push(numCalls);
73179
+ }
73180
+ numCalls = 0;
73081
73181
  thisFrame.clear();
73082
73182
  isProcessing = false;
73083
73183
  if (flushNextFrame) {
@@ -73099,7 +73199,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
73099
73199
  };
73100
73200
  const flagRunNextFrame = () => runNextFrame = true;
73101
73201
  const steps = stepsOrder.reduce((acc, key) => {
73102
- acc[key] = createRenderStep(flagRunNextFrame);
73202
+ acc[key] = createRenderStep(flagRunNextFrame, allowKeepAlive ? key : void 0);
73103
73203
  return acc;
73104
73204
  }, {});
73105
73205
  const { read, resolveKeyframes, update: update2, preRender, render, postRender } = steps;
@@ -74654,7 +74754,7 @@ function binarySubdivide(x2, lowerBound, upperBound, mX1, mX2) {
74654
74754
  function cubicBezier(mX1, mY1, mX2, mY2) {
74655
74755
  if (mX1 === mY1 && mX2 === mY2)
74656
74756
  return noop;
74657
- const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
74757
+ const getTForX = (aX2) => binarySubdivide(aX2, 0, 1, mX1, mX2);
74658
74758
  return (t2) => t2 === 0 || t2 === 1 ? t2 : calcBezier(getTForX(t2), mY1, mY2);
74659
74759
  }
74660
74760
  const mirrorEasing = (easing) => (p2) => p2 <= 0.5 ? easing(2 * p2) / 2 : (2 - easing(2 * (1 - p2))) / 2;
@@ -77540,7 +77640,7 @@ class VisualElementDragControls {
77540
77640
  if (!shouldDrag(axis, drag2, this.currentDirection)) {
77541
77641
  return;
77542
77642
  }
77543
- let transition = constraints[axis] || {};
77643
+ let transition = constraints && constraints[axis] || {};
77544
77644
  if (dragSnapToOrigin)
77545
77645
  transition = { min: 0, max: 0 };
77546
77646
  const bounceStiffness = dragElastic ? 200 : 1e6;
@@ -80771,6 +80871,8 @@ const ChatMessageContent = ({
80771
80871
  humanMessage,
80772
80872
  copyButtonOnSubmit,
80773
80873
  insertButtonOnSubmit,
80874
+ onRegenerate,
80875
+ regeneratingCodeBlocks,
80774
80876
  guardrails,
80775
80877
  className,
80776
80878
  smartApply,
@@ -80783,15 +80885,15 @@ const ChatMessageContent = ({
80783
80885
  [displayMarkdown]
80784
80886
  );
80785
80887
  const onInsert = config.config.hasEditCapability ? insertButtonOnSubmit : void 0;
80786
- const onExecute = useCallback((command) => {
80787
- var _a;
80788
- const vscodeApi = (_a = window.acquireVsCodeApi) == null ? void 0 : _a.call(window);
80789
- vscodeApi == null ? void 0 : vscodeApi.postMessage({
80888
+ let onExecute = useCallback((command) => {
80889
+ const vscodeAPI = getVSCodeAPI();
80890
+ vscodeAPI.postMessage({
80790
80891
  command: "command",
80791
80892
  id: "cody.terminal.execute",
80792
80893
  arg: command.trim()
80793
80894
  });
80794
80895
  }, []);
80896
+ onExecute = config.clientCapabilities.isVSCode ? onExecute : void 0;
80795
80897
  const onCopy = useCallback(
80796
80898
  (code2) => copyButtonOnSubmit == null ? void 0 : copyButtonOnSubmit(code2, "Button"),
80797
80899
  [copyButtonOnSubmit]
@@ -80810,11 +80912,13 @@ const ChatMessageContent = ({
80810
80912
  RichMarkdown,
80811
80913
  {
80812
80914
  markdown: displayContent,
80813
- isLoading: isMessageLoading,
80915
+ isMessageLoading,
80814
80916
  guardrails,
80815
80917
  onCopy,
80816
80918
  onInsert,
80817
80919
  onExecute,
80920
+ onRegenerate,
80921
+ regeneratingCodeBlocks,
80818
80922
  smartApply,
80819
80923
  className: clsx$1(styles$q.content, className),
80820
80924
  hasEditIntent: (humanMessage == null ? void 0 : humanMessage.intent) === "edit"
@@ -80913,13 +81017,23 @@ const RateLimitErrorItem = ({ error: error2, userInfo, postMessage }) => {
80913
81017
  },
80914
81018
  [postMessage, tier, telemetryRecorder]
80915
81019
  );
81020
+ let ctaText = canUpgrade ? "Upgrade to Cody Pro" : "Unable to Send Message";
81021
+ const fallbackToFlash = useFeatureFlag(FeatureFlag.FallbackToFlash);
81022
+ if (fallbackToFlash) {
81023
+ if (userInfo == null ? void 0 : userInfo.isCodyProUser) {
81024
+ ctaText = "Upgrade to Cody Enterprise";
81025
+ } else if (!canUpgrade) {
81026
+ ctaText = "Usage limit of premium models reached, switching the model to Gemini Flash.";
81027
+ }
81028
+ }
80916
81029
  return /* @__PURE__ */ jsxs("div", { className: styles$n.errorItem, children: [
80917
81030
  canUpgrade && /* @__PURE__ */ jsx("div", { className: styles$n.icon, children: "⚡️" }),
80918
81031
  /* @__PURE__ */ jsxs("div", { className: styles$n.body, children: [
80919
81032
  /* @__PURE__ */ jsxs("header", { children: [
80920
- /* @__PURE__ */ jsx("h1", { children: canUpgrade ? "Upgrade to Cody Pro" : "Unable to Send Message" }),
81033
+ /* @__PURE__ */ jsx("h1", { children: ctaText }),
80921
81034
  /* @__PURE__ */ jsxs("p", { children: [
80922
81035
  error2.userMessage,
81036
+ fallbackToFlash && !canUpgrade && " You can continue using Gemini Flash, or other standard models.",
80923
81037
  canUpgrade && " Upgrade to Cody Pro for unlimited autocomplete suggestions, and increased limits for chat messages and commands."
80924
81038
  ] })
80925
81039
  ] }),
@@ -82800,7 +82914,7 @@ const SearchResults = ({
82800
82914
  );
82801
82915
  const initialResults = useMemo$1(() => totalResults == null ? void 0 : totalResults.slice(0, DEFAULT_RESULTS_LIMIT), [totalResults]);
82802
82916
  const resultsToShow = (initialResults == null ? void 0 : initialResults.length) === (totalResults == null ? void 0 : totalResults.length) || showAll ? totalResults : initialResults;
82803
- const boostedRepo = (_a = message2.search.query.match(/boost:repo\(([^)]+)\)/)) == null ? void 0 : _a[1];
82917
+ const boostedRepo = (_a = message2.search.query.match(/repo:boost\(([^)]+)\)/)) == null ? void 0 : _a[1];
82804
82918
  const firstNonBoostedRepoIndex = boostedRepo ? resultsToShow.findIndex(
82805
82919
  (result2) => result2.__typename === "FileMatch" && result2.repository.name !== boostedRepo
82806
82920
  ) : void 0;
@@ -83110,7 +83224,7 @@ const stepContainer = "_step-container_1xbw7_1";
83110
83224
  const styles$e = {
83111
83225
  stepContainer
83112
83226
  };
83113
- const SubMessageCell = ({ piece, guardrails }) => {
83227
+ const SubMessageCell = ({ piece, guardrails, onRegenerate, regeneratingCodeBlocks }) => {
83114
83228
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
83115
83229
  piece.text && /* @__PURE__ */ jsx(
83116
83230
  ChatMessageContent,
@@ -83118,7 +83232,9 @@ const SubMessageCell = ({ piece, guardrails }) => {
83118
83232
  displayMarkdown: piece.text.toString(),
83119
83233
  isMessageLoading: false,
83120
83234
  humanMessage: null,
83121
- guardrails
83235
+ guardrails,
83236
+ onRegenerate,
83237
+ regeneratingCodeBlocks
83122
83238
  }
83123
83239
  ),
83124
83240
  piece.step && /* @__PURE__ */ jsxs("div", { className: `${styles$e.stepContainer} tw-flex tw-items-center tw-gap-2 tw-w-fit`, children: [
@@ -83133,10 +83249,11 @@ const AssistantMessageCell = memo$2(
83133
83249
  models,
83134
83250
  humanMessage,
83135
83251
  userInfo,
83136
- chatEnabled,
83137
83252
  isLoading,
83138
83253
  copyButtonOnSubmit,
83139
83254
  insertButtonOnSubmit,
83255
+ onRegenerate,
83256
+ regeneratingCodeBlocks,
83140
83257
  postMessage,
83141
83258
  guardrails,
83142
83259
  smartApply,
@@ -83183,6 +83300,8 @@ const AssistantMessageCell = memo$2(
83183
83300
  isMessageLoading: isLoading,
83184
83301
  copyButtonOnSubmit,
83185
83302
  insertButtonOnSubmit,
83303
+ onRegenerate,
83304
+ regeneratingCodeBlocks,
83186
83305
  guardrails,
83187
83306
  humanMessage,
83188
83307
  smartApply,
@@ -83194,7 +83313,9 @@ const AssistantMessageCell = memo$2(
83194
83313
  SubMessageCell,
83195
83314
  {
83196
83315
  piece,
83197
- guardrails
83316
+ guardrails,
83317
+ onRegenerate,
83318
+ regeneratingCodeBlocks
83198
83319
  },
83199
83320
  `piece-${i}`
83200
83321
  ))
@@ -83260,7 +83381,12 @@ function useChatModelByID(model, chatModels) {
83260
83381
  function useLocalStorage(key, defaultValue) {
83261
83382
  const [value, setValue] = useState$1(() => {
83262
83383
  const json2 = localStorage.getItem(key);
83263
- return json2 ? JSON.parse(json2) : defaultValue;
83384
+ if (!json2) return defaultValue;
83385
+ try {
83386
+ return JSON.parse(json2);
83387
+ } catch {
83388
+ return defaultValue;
83389
+ }
83264
83390
  });
83265
83391
  const persistValue = useCallback(
83266
83392
  (value2) => {
@@ -83304,7 +83430,8 @@ const InnerUserAvatar = ({
83304
83430
  }) => {
83305
83431
  const title2 = user.displayName || user.username;
83306
83432
  const highDPISize = size2 * 2;
83307
- if (user == null ? void 0 : user.avatarURL) {
83433
+ const [imgError, setImgError] = useState$1(false);
83434
+ if ((user == null ? void 0 : user.avatarURL) && !imgError) {
83308
83435
  let url = user.avatarURL;
83309
83436
  try {
83310
83437
  const urlObject = new URL(user.avatarURL);
@@ -83323,7 +83450,8 @@ const InnerUserAvatar = ({
83323
83450
  title: title2,
83324
83451
  alt: `Avatar for ${user.username}`,
83325
83452
  width: size2,
83326
- height: size2
83453
+ height: size2,
83454
+ onError: () => setImgError(true)
83327
83455
  }
83328
83456
  );
83329
83457
  }
@@ -84076,7 +84204,7 @@ const styles$9 = {
84076
84204
  promptsContainer,
84077
84205
  promptMigrationWidget
84078
84206
  };
84079
- const PromptsTab = ({ IDE, setView }) => {
84207
+ const PromptsTab = ({ setView }) => {
84080
84208
  const runAction = useActionSelect();
84081
84209
  const [promptsFilter, setPromptsFilter] = useState$1({});
84082
84210
  return /* @__PURE__ */ jsxs("div", { className: "tw-overflow-auto tw-h-full tw-flex tw-flex-col", children: [
@@ -84599,7 +84727,8 @@ const ModelSelectField = ({
84599
84727
  className,
84600
84728
  intent,
84601
84729
  __storybook__open,
84602
- modelSelectorRef
84730
+ modelSelectorRef,
84731
+ modelsData
84603
84732
  }) => {
84604
84733
  var _a;
84605
84734
  const telemetryRecorder = useTelemetryRecorder();
@@ -84643,7 +84772,7 @@ const ModelSelectField = ({
84643
84772
  isCodyProUser2
84644
84773
  ]
84645
84774
  );
84646
- const readOnly = intent === "agentic" || !(userInfo.isDotComUser || serverSentModelsEnabled);
84775
+ const readOnly = !(userInfo.isDotComUser || serverSentModelsEnabled);
84647
84776
  const onOpenChange = useCallback(
84648
84777
  (open) => {
84649
84778
  if (open) {
@@ -84663,7 +84792,7 @@ const ModelSelectField = ({
84663
84792
  );
84664
84793
  const options = useMemo$1(
84665
84794
  () => models.map((m2) => {
84666
- const availability = modelAvailability(userInfo, serverSentModelsEnabled, m2);
84795
+ const availability = modelAvailability(userInfo, serverSentModelsEnabled, m2, intent);
84667
84796
  return {
84668
84797
  value: m2.id,
84669
84798
  title: /* @__PURE__ */ jsx(
@@ -84682,7 +84811,7 @@ const ModelSelectField = ({
84682
84811
  tooltip: getTooltip(m2, availability)
84683
84812
  };
84684
84813
  }),
84685
- [models, userInfo, serverSentModelsEnabled]
84814
+ [models, userInfo, serverSentModelsEnabled, intent]
84686
84815
  );
84687
84816
  const optionsByGroup = useMemo$1(() => {
84688
84817
  return optionByGroup(options);
@@ -84704,6 +84833,7 @@ const ModelSelectField = ({
84704
84833
  if (!models.length || models.length < 1) {
84705
84834
  return null;
84706
84835
  }
84836
+ const isRateLimited = useMemo$1(() => models.some((model) => model.disabled), [models]);
84707
84837
  const value = selectedModel.id;
84708
84838
  return /* @__PURE__ */ jsx(
84709
84839
  ToolbarPopoverItem,
@@ -84717,7 +84847,7 @@ const ModelSelectField = ({
84717
84847
  tooltip: readOnly ? void 0 : isMacOS() ? "Switch model (⌘M)" : "Switch model (Ctrl+M)",
84718
84848
  "aria-label": "Select a model or an agent",
84719
84849
  controlRef: modelSelectorRef,
84720
- popoverContent: (close2) => /* @__PURE__ */ jsx(
84850
+ popoverContent: (close2) => /* @__PURE__ */ jsxs(
84721
84851
  Command,
84722
84852
  {
84723
84853
  loop: true,
@@ -84725,91 +84855,101 @@ const ModelSelectField = ({
84725
84855
  tabIndex: 0,
84726
84856
  className: `focus:tw-outline-none ${styles$7.chatModelPopover}`,
84727
84857
  "data-testid": "chat-model-popover",
84728
- children: /* @__PURE__ */ jsxs(
84729
- CommandList,
84730
- {
84731
- className: "model-selector-popover tw-max-h-[80vh] tw-overflow-y-auto",
84732
- "data-testid": "chat-model-popover-option",
84733
- children: [
84734
- optionsByGroup.map(({ group, options: options2 }) => /* @__PURE__ */ jsx(CommandGroup, { heading: group, children: options2.map((option) => /* @__PURE__ */ jsx(
84735
- CommandItem,
84736
- {
84737
- "data-testid": "chat-model-popover-option",
84738
- value: option.value,
84739
- onSelect: (currentValue) => {
84740
- onChange(currentValue);
84741
- close2();
84858
+ children: [
84859
+ intent === "agentic" && /* @__PURE__ */ jsx("div", { className: "tw-pl-5 tw-pr-3 tw-py-1.5 tw-text-sm tw-text-foreground tw-flex tw-justify-center", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-start tw-gap-2 tw-bg-muted tw-px-2 tw-py-0.5 tw-rounded", children: [
84860
+ /* @__PURE__ */ jsx(TriangleAlert, { className: "tw-w-[16px] tw-h-[16px] tw-mt-[2px]" }),
84861
+ /* @__PURE__ */ jsx("span", { className: "tw-leading-4 tw-font-semibold", children: "Only Claude 3.7 Sonnet is currently available in Agent Mode" })
84862
+ ] }) }),
84863
+ /* @__PURE__ */ jsxs(
84864
+ CommandList,
84865
+ {
84866
+ className: "model-selector-popover tw-max-h-[80vh] tw-overflow-y-auto",
84867
+ "data-testid": "chat-model-popover-option",
84868
+ children: [
84869
+ isRateLimited && /* @__PURE__ */ jsx("div", { className: "tw-pl-5 tw-pr-3 tw-py-1.5 tw-text-sm tw-text-foreground tw-flex tw-justify-center", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center tw-gap-2 tw-bg-muted tw-px-2 tw-py-0.5 tw-rounded", children: [
84870
+ /* @__PURE__ */ jsx(TriangleAlert, { className: "tw-w-[16px] tw-h-[16px]" }),
84871
+ /* @__PURE__ */ jsx("span", { className: "tw-font-semibold", children: "Usage limit reached: Premium models disabled" })
84872
+ ] }) }),
84873
+ optionsByGroup.map(({ group, options: options2 }) => /* @__PURE__ */ jsx(CommandGroup, { heading: group, children: options2.map((option) => /* @__PURE__ */ jsx(
84874
+ CommandItem,
84875
+ {
84876
+ "data-testid": "chat-model-popover-option",
84877
+ value: option.value,
84878
+ onSelect: (currentValue) => {
84879
+ onChange(currentValue);
84880
+ close2();
84881
+ },
84882
+ disabled: option.disabled,
84883
+ tooltip: option.tooltip,
84884
+ children: option.title
84742
84885
  },
84743
- disabled: option.disabled,
84744
- tooltip: option.tooltip,
84745
- children: option.title
84746
- },
84747
- option.value
84748
- )) }, group)),
84749
- /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
84750
- CommandLink,
84751
- {
84752
- href: "https://sourcegraph.com/docs/cody/clients/install-vscode#supported-llm-models",
84753
- target: "_blank",
84754
- rel: "noreferrer",
84755
- className: styles$7.modelTitleWithIcon,
84756
- children: [
84757
- /* @__PURE__ */ jsxs("span", { className: styles$7.modelIcon, children: [
84758
- /* @__PURE__ */ jsx(BookOpen, { size: 16, strokeWidth: 2 }),
84759
- " "
84760
- ] }),
84761
- /* @__PURE__ */ jsx("span", { className: styles$7.modelName, children: "Documentation" }),
84762
- /* @__PURE__ */ jsx("span", { className: styles$7.rightIcon, children: /* @__PURE__ */ jsx(
84763
- ExternalLink,
84764
- {
84765
- size: 16,
84766
- strokeWidth: 1.25,
84767
- className: "tw-opacity-80"
84768
- }
84769
- ) })
84770
- ]
84771
- }
84772
- ) }),
84773
- userInfo.isDotComUser && /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
84774
- CommandLink,
84775
- {
84776
- href: ENTERPRISE_MODEL_DOCS_PAGE,
84777
- target: "_blank",
84778
- rel: "noreferrer",
84779
- onSelect: () => {
84780
- telemetryRecorder.recordEvent(
84781
- "cody.modelSelector",
84782
- "clickEnterpriseModelOption",
84783
- {
84784
- billingMetadata: {
84785
- product: "cody",
84786
- category: "billable"
84886
+ option.value
84887
+ )) }, group)),
84888
+ /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
84889
+ CommandLink,
84890
+ {
84891
+ href: "https://sourcegraph.com/docs/cody/clients/install-vscode#supported-llm-models",
84892
+ target: "_blank",
84893
+ rel: "noreferrer",
84894
+ className: styles$7.modelTitleWithIcon,
84895
+ children: [
84896
+ /* @__PURE__ */ jsxs("span", { className: styles$7.modelIcon, children: [
84897
+ /* @__PURE__ */ jsx(BookOpen, { size: 16, strokeWidth: 2 }),
84898
+ " "
84899
+ ] }),
84900
+ /* @__PURE__ */ jsx("span", { className: styles$7.modelName, children: "Documentation" }),
84901
+ /* @__PURE__ */ jsx("span", { className: styles$7.rightIcon, children: /* @__PURE__ */ jsx(
84902
+ ExternalLink,
84903
+ {
84904
+ size: 16,
84905
+ strokeWidth: 1.25,
84906
+ className: "tw-opacity-80"
84787
84907
  }
84788
- }
84789
- );
84908
+ ) })
84909
+ ]
84910
+ }
84911
+ ) }),
84912
+ userInfo.isDotComUser && /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
84913
+ CommandLink,
84914
+ {
84915
+ href: ENTERPRISE_MODEL_DOCS_PAGE,
84916
+ target: "_blank",
84917
+ rel: "noreferrer",
84918
+ onSelect: () => {
84919
+ telemetryRecorder.recordEvent(
84920
+ "cody.modelSelector",
84921
+ "clickEnterpriseModelOption",
84922
+ {
84923
+ billingMetadata: {
84924
+ product: "cody",
84925
+ category: "billable"
84926
+ }
84927
+ }
84928
+ );
84929
+ },
84930
+ className: styles$7.modelTitleWithIcon,
84931
+ children: [
84932
+ /* @__PURE__ */ jsxs("span", { className: styles$7.modelIcon, children: [
84933
+ /* @__PURE__ */ jsx(Building, { size: 16, strokeWidth: 2 }),
84934
+ " "
84935
+ ] }),
84936
+ /* @__PURE__ */ jsx("span", { className: styles$7.modelName, children: "Enterprise Model Options" }),
84937
+ /* @__PURE__ */ jsx("span", { className: styles$7.rightIcon, children: /* @__PURE__ */ jsx(
84938
+ ExternalLink,
84939
+ {
84940
+ size: 16,
84941
+ strokeWidth: 1.25,
84942
+ className: "tw-opacity-80"
84943
+ }
84944
+ ) })
84945
+ ]
84790
84946
  },
84791
- className: styles$7.modelTitleWithIcon,
84792
- children: [
84793
- /* @__PURE__ */ jsxs("span", { className: styles$7.modelIcon, children: [
84794
- /* @__PURE__ */ jsx(Building, { size: 16, strokeWidth: 2 }),
84795
- " "
84796
- ] }),
84797
- /* @__PURE__ */ jsx("span", { className: styles$7.modelName, children: "Enterprise Model Options" }),
84798
- /* @__PURE__ */ jsx("span", { className: styles$7.rightIcon, children: /* @__PURE__ */ jsx(
84799
- ExternalLink,
84800
- {
84801
- size: 16,
84802
- strokeWidth: 1.25,
84803
- className: "tw-opacity-80"
84804
- }
84805
- ) })
84806
- ]
84807
- },
84808
- "enterprise-model-options"
84809
- ) })
84810
- ]
84811
- }
84812
- )
84947
+ "enterprise-model-options"
84948
+ ) })
84949
+ ]
84950
+ }
84951
+ )
84952
+ ]
84813
84953
  }
84814
84954
  ),
84815
84955
  popoverRootProps: { onOpenChange },
@@ -84820,18 +84960,24 @@ const ModelSelectField = ({
84820
84960
  event.preventDefault();
84821
84961
  }
84822
84962
  },
84823
- children: intent === "agentic" ? "Claude 3.7 Sonnet" : value !== void 0 ? (_a = options.find((option) => option.value === value)) == null ? void 0 : _a.title : "Select..."
84963
+ children: value !== void 0 ? (_a = options.find((option) => option.value === value)) == null ? void 0 : _a.title : "Select..."
84824
84964
  }
84825
84965
  );
84826
84966
  };
84827
84967
  const ENTERPRISE_MODEL_DOCS_PAGE = "https://sourcegraph.com/docs/cody/clients/enable-cody-enterprise?utm_source=cody.modelSelector";
84828
- function modelAvailability(userInfo, serverSentModelsEnabled, model) {
84968
+ function modelAvailability(userInfo, serverSentModelsEnabled, model, intent) {
84969
+ if (model.disabled) {
84970
+ return "not-selectable-on-enterprise";
84971
+ }
84829
84972
  if (!userInfo.isDotComUser && !serverSentModelsEnabled) {
84830
84973
  return "not-selectable-on-enterprise";
84831
84974
  }
84832
84975
  if (isCodyProModel(model) && userInfo.isDotComUser && !userInfo.isCodyProUser) {
84833
84976
  return "needs-cody-pro";
84834
84977
  }
84978
+ if (intent === "agentic" && !model.tags.includes(ModelTag.Default)) {
84979
+ return "not-selectable-on-enterprise";
84980
+ }
84835
84981
  return "available";
84836
84982
  }
84837
84983
  function getTooltip(model, availability) {
@@ -84844,6 +84990,9 @@ function getTooltip(model, availability) {
84844
84990
  if (model.tags.includes(ModelTag.OnWaitlist)) {
84845
84991
  return "Request received, we will reach out with next steps";
84846
84992
  }
84993
+ if (model.disabled) {
84994
+ return "This model is currently unavailable due to rate limiting. Please try a faster model.";
84995
+ }
84847
84996
  const capitalizedProvider = model.provider === "openai" ? "OpenAI" : model.provider.charAt(0).toUpperCase() + model.provider.slice(1);
84848
84997
  switch (availability) {
84849
84998
  case "not-selectable-on-enterprise":
@@ -84932,39 +85081,116 @@ const optionByGroup = (options) => {
84932
85081
  }
84933
85082
  return [...groups.entries()].sort(([a2], [b2]) => groupOrder.indexOf(a2) - groupOrder.indexOf(b2)).map(([group, options2]) => ({ group, options: options2 }));
84934
85083
  };
85084
+ async function downloadChatHistory(extensionAPI) {
85085
+ const userHistory = await firstResultFromOperation(extensionAPI.userHistory(ChatHistoryType.Full));
85086
+ const chatHistory = (userHistory == null ? void 0 : userHistory.chat) ? Object.values(userHistory.chat) : null;
85087
+ if (!chatHistory || chatHistory.length === 0) {
85088
+ return;
85089
+ }
85090
+ const json2 = JSON.stringify(chatHistory, null, 2);
85091
+ const blob = new Blob([json2], { type: "application/json" });
85092
+ const url = URL.createObjectURL(blob);
85093
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
85094
+ const a2 = document.createElement("a");
85095
+ a2.href = url;
85096
+ a2.download = `cody-chat-history-${timestamp}.json`;
85097
+ a2.target = "_blank";
85098
+ a2.click();
85099
+ }
85100
+ function useUserHistory(type = ChatHistoryType.Lightweight) {
85101
+ const userHistory = useExtensionAPI().userHistory;
85102
+ return useObservable(useMemo$1(() => userHistory(type), [userHistory, type])).value;
85103
+ }
85104
+ const historyRow = "_history-row_k3x5q_5";
85105
+ const deleteButton = "_delete-button_k3x5q_10";
85106
+ const deletingButton = "_deleting-button_k3x5q_18";
85107
+ const historyItem = "_history-item_k3x5q_23";
85108
+ const styles$6 = {
85109
+ historyRow,
85110
+ deleteButton,
85111
+ deletingButton,
85112
+ historyItem
85113
+ };
84935
85114
  function getCreateNewChatCommand(options) {
84936
85115
  const { IDE, webviewType, multipleWebviewsEnabled } = options;
84937
85116
  return IDE === CodyIDE.Web ? "cody.chat.new" : webviewType === "sidebar" || !multipleWebviewsEnabled ? "cody.chat.newPanel" : "cody.chat.newEditorPanel";
84938
85117
  }
84939
- const historyRow = "_history-row_r1hp5_6";
84940
- const historyItem = "_history-item_r1hp5_11";
84941
- const historyDeleteBtn = "_history-delete-btn_r1hp5_20";
84942
- const styles$6 = {
84943
- historyRow,
84944
- historyItem,
84945
- historyDeleteBtn
84946
- };
84947
- const HistoryTab = (props) => {
84948
- const userHistory = useUserHistory$1();
84949
- const chats = useMemo$1(
84950
- () => userHistory ? Object.values(userHistory.chat) : userHistory,
84951
- [userHistory]
84952
- );
84953
- return /* @__PURE__ */ jsx("div", { className: "tw-px-8 tw-pt-6 tw-pb-12 tw-overflow-y-scroll", children: chats === void 0 ? /* @__PURE__ */ jsx(LoadingDots, {}) : chats === null ? /* @__PURE__ */ jsx("p", { children: "History is not available." }) : /* @__PURE__ */ jsx(HistoryTabWithData, { ...props, chats }) });
85118
+ const HISTORY_ITEMS_PER_PAGE = 20;
85119
+ const HistoryTab = ({
85120
+ IDE,
85121
+ webviewType,
85122
+ multipleWebviewsEnabled,
85123
+ setView,
85124
+ extensionAPI
85125
+ }) => {
85126
+ const userHistory = useUserHistory();
85127
+ const chats = useMemo$1(() => userHistory ? Object.values(userHistory) : userHistory, [userHistory]);
85128
+ return /* @__PURE__ */ jsx("div", { className: "tw-flex tw-overflow-hidden tw-h-full tw-w-full", children: !chats ? /* @__PURE__ */ jsx(LoadingDots, {}) : /* @__PURE__ */ jsx(
85129
+ HistoryTabWithData,
85130
+ {
85131
+ chats: [...chats].reverse(),
85132
+ extensionAPI,
85133
+ IDE,
85134
+ setView,
85135
+ webviewType,
85136
+ multipleWebviewsEnabled
85137
+ }
85138
+ ) });
84954
85139
  };
84955
- const HistoryTabWithData = ({ IDE, webviewType, multipleWebviewsEnabled, setView, chats }) => {
84956
- const nonEmptyChats = useMemo$1(() => chats.filter((chat2) => chat2.interactions.length > 0), [chats]);
85140
+ const HistoryTabWithData = ({
85141
+ IDE,
85142
+ webviewType,
85143
+ multipleWebviewsEnabled,
85144
+ setView,
85145
+ chats,
85146
+ extensionAPI
85147
+ }) => {
85148
+ const vscodeAPI = getVSCodeAPI();
85149
+ const nonEmptyChats = useMemo$1(() => chats.filter((c2) => {
85150
+ var _a;
85151
+ return (_a = c2 == null ? void 0 : c2.firstHumanMessageText) == null ? void 0 : _a.length;
85152
+ }), [chats]);
85153
+ const [isDeleteAllActive, setIsDeleteAllActive] = useState$1(false);
85154
+ const [deletingChatIds, setDeletingChatIds] = useState$1(/* @__PURE__ */ new Set());
85155
+ const [searchText, setSearchText] = useState$1("");
85156
+ const [visibleItems, setVisibleItems] = useState$1(HISTORY_ITEMS_PER_PAGE);
85157
+ const [isLoading, setIsLoading] = useState$1(false);
85158
+ const observerRef = useRef$1(null);
85159
+ const loadingRef = useRef$1(null);
85160
+ const filteredChats = useMemo$1(() => {
85161
+ const searchTerm = searchText.trim().toLowerCase();
85162
+ if (!searchTerm) {
85163
+ return nonEmptyChats;
85164
+ }
85165
+ return nonEmptyChats.filter((chat2) => {
85166
+ var _a, _b;
85167
+ if ((_a = chat2.chatTitle) == null ? void 0 : _a.toLowerCase().includes(searchTerm)) {
85168
+ return true;
85169
+ }
85170
+ return ((_b = chat2.firstHumanMessageText) == null ? void 0 : _b.toLowerCase().includes(searchTerm)) || false;
85171
+ });
85172
+ }, [nonEmptyChats, searchText]);
85173
+ const hasMoreItems = visibleItems < filteredChats.length;
85174
+ const displayedChats = filteredChats.slice(0, visibleItems);
84957
85175
  const onDeleteButtonClick = useCallback(
84958
- (id2) => {
84959
- if (chats.find((chat2) => chat2.id === id2)) {
84960
- getVSCodeAPI().postMessage({
84961
- command: "command",
84962
- id: "cody.chat.history.clear",
84963
- arg: id2
84964
- });
85176
+ (e2, id2) => {
85177
+ e2.preventDefault();
85178
+ e2.stopPropagation();
85179
+ setDeletingChatIds((prev) => {
85180
+ const newSet = new Set(prev);
85181
+ newSet.add(id2);
85182
+ return newSet;
85183
+ });
85184
+ vscodeAPI.postMessage({
85185
+ command: "command",
85186
+ id: "cody.chat.history.clear",
85187
+ arg: id2
85188
+ });
85189
+ if (id2 === "clear-all-no-confirm") {
85190
+ setVisibleItems((prev) => Math.min(prev, filteredChats.length - deletingChatIds.size));
84965
85191
  }
84966
85192
  },
84967
- [chats]
85193
+ [vscodeAPI, filteredChats.length, deletingChatIds]
84968
85194
  );
84969
85195
  const handleStartNewChat = () => {
84970
85196
  getVSCodeAPI().postMessage({
@@ -84973,93 +85199,69 @@ const HistoryTabWithData = ({ IDE, webviewType, multipleWebviewsEnabled, setView
84973
85199
  });
84974
85200
  setView(View.Chat);
84975
85201
  };
84976
- const [searchText, setSearchText] = useState$1("");
84977
- const filteredChats = useMemo$1(() => {
84978
- const searchTerm = searchText.trim().toLowerCase();
84979
- if (!searchTerm) {
84980
- return nonEmptyChats;
84981
- }
84982
- return nonEmptyChats.filter((chat2) => {
84983
- return chat2.interactions.some((c2) => {
84984
- var _a, _b, _c, _d;
84985
- return (_d = (_c = (_b = (_a = c2.humanMessage) == null ? void 0 : _a.text) == null ? void 0 : _b.trim()) == null ? void 0 : _c.toLowerCase()) == null ? void 0 : _d.includes(searchTerm);
85202
+ const onExportClick = useCallback(() => downloadChatHistory(extensionAPI), [extensionAPI]);
85203
+ useEffect$2(() => {
85204
+ setVisibleItems(HISTORY_ITEMS_PER_PAGE);
85205
+ }, []);
85206
+ useEffect$2(() => {
85207
+ const handleMessage = (event) => {
85208
+ const message2 = event.data;
85209
+ if (message2.type === "deletionComplete" && message2.chatID) {
85210
+ setDeletingChatIds((prev) => {
85211
+ const newSet = new Set(prev);
85212
+ newSet.delete(message2.chatID);
85213
+ return newSet;
85214
+ });
85215
+ }
85216
+ };
85217
+ window.addEventListener("message", handleMessage);
85218
+ return () => window.removeEventListener("message", handleMessage);
85219
+ }, []);
85220
+ useEffect$2(() => {
85221
+ if (deletingChatIds.size > 0) {
85222
+ setVisibleItems((prev) => {
85223
+ const newVisibleItems = Math.min(
85224
+ prev,
85225
+ filteredChats.length + Math.min(HISTORY_ITEMS_PER_PAGE, deletingChatIds.size)
85226
+ );
85227
+ return Math.max(HISTORY_ITEMS_PER_PAGE, newVisibleItems);
84986
85228
  });
84987
- });
84988
- }, [nonEmptyChats, searchText]);
84989
- const sortedChatsByPeriod = useMemo$1(
84990
- () => Array.from(
84991
- filteredChats.filter((chat2) => chat2.interactions.length).reverse().reduce((acc, chat2) => {
84992
- const period = getRelativeChatPeriod(new Date(chat2.lastInteractionTimestamp));
84993
- acc.set(period, [...acc.get(period) || [], chat2]);
84994
- return acc;
84995
- }, /* @__PURE__ */ new Map())
84996
- ),
84997
- [filteredChats]
84998
- );
84999
- return /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-col", children: [
85000
- /* @__PURE__ */ jsx("div", { className: "tw-flex tw-py-2", children: /* @__PURE__ */ jsx(
85001
- Input,
85002
- {
85003
- className: "tw-flex-1 tw-text-sm",
85004
- placeholder: "Search chat history",
85005
- value: searchText,
85006
- onChange: (event) => setSearchText(event.target.value)
85229
+ }
85230
+ }, [deletingChatIds.size, filteredChats.length]);
85231
+ useEffect$2(() => {
85232
+ const loadMoreItems = () => {
85233
+ if (hasMoreItems && !isLoading) {
85234
+ setIsLoading(true);
85235
+ setTimeout(() => {
85236
+ setVisibleItems(
85237
+ (prev) => Math.min(prev + HISTORY_ITEMS_PER_PAGE, filteredChats.length)
85238
+ );
85239
+ setIsLoading(false);
85240
+ }, 300);
85007
85241
  }
85008
- ) }),
85009
- sortedChatsByPeriod.map(([period, chats2]) => /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-col", children: [
85010
- /* @__PURE__ */ jsx("h4", { className: "tw-font-semibold tw-text-muted-foreground tw-py-2 tw-my-4", children: period }),
85011
- chats2.map((chat2) => {
85012
- var _a, _b, _c;
85013
- const id2 = chat2.lastInteractionTimestamp;
85014
- const interactions = chat2.interactions;
85015
- const chatTitle = chat2.chatTitle;
85016
- const lastMessage = (_c = (_b = (_a = interactions[interactions.length - 1]) == null ? void 0 : _a.humanMessage) == null ? void 0 : _b.text) == null ? void 0 : _c.trim();
85017
- return /* @__PURE__ */ jsxs("div", { className: `tw-flex tw-flex-row tw-p-1 ${styles$6.historyRow}`, children: [
85018
- /* @__PURE__ */ jsx(
85019
- Button,
85020
- {
85021
- variant: "ghost",
85022
- className: `tw-text-left tw-truncate tw-w-full ${styles$6.historyItem}`,
85023
- onClick: () => getVSCodeAPI().postMessage({
85024
- command: "restoreHistory",
85025
- chatID: id2
85026
- }),
85027
- children: /* @__PURE__ */ jsx("span", { className: "tw-truncate tw-w-full", children: chatTitle || lastMessage })
85028
- }
85029
- ),
85030
- /* @__PURE__ */ jsx(
85031
- Button,
85032
- {
85033
- variant: "ghost",
85034
- title: "Delete chat",
85035
- "aria-label": "Delete chat",
85036
- className: `${styles$6.historyDeleteBtn}`,
85037
- onClick: () => onDeleteButtonClick(id2),
85038
- onKeyDown: () => onDeleteButtonClick(id2),
85039
- children: /* @__PURE__ */ jsx(
85040
- Trash,
85041
- {
85042
- className: "tw-w-8 tw-h-8 tw-opacity-80",
85043
- size: 16,
85044
- strokeWidth: "1.25"
85045
- }
85046
- )
85047
- }
85048
- )
85049
- ] }, id2);
85050
- })
85051
- ] }, period)),
85052
- nonEmptyChats.length === 0 && /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-col tw-items-center tw-mt-6", children: [
85053
- /* @__PURE__ */ jsx(
85054
- History,
85055
- {
85056
- size: 20,
85057
- strokeWidth: 1.25,
85058
- className: "tw-mb-5 tw-text-muted-foreground"
85242
+ };
85243
+ observerRef.current = new IntersectionObserver(
85244
+ (entries) => {
85245
+ if (entries[0].isIntersecting) {
85246
+ loadMoreItems();
85059
85247
  }
85060
- ),
85248
+ },
85249
+ { threshold: 0.1 }
85250
+ );
85251
+ if (loadingRef.current && hasMoreItems) {
85252
+ observerRef.current.observe(loadingRef.current);
85253
+ }
85254
+ return () => {
85255
+ if (observerRef.current) {
85256
+ observerRef.current.disconnect();
85257
+ }
85258
+ };
85259
+ }, [hasMoreItems, filteredChats.length, isLoading]);
85260
+ if (!filteredChats.length && !searchText) {
85261
+ return /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-col tw-items-center tw-p-6", children: [
85262
+ /* @__PURE__ */ jsx(History, { size: 20, strokeWidth: 1.25, className: "tw-mb-5 tw-text-muted-foreground" }),
85061
85263
  /* @__PURE__ */ jsx("span", { className: "tw-text-lg tw-mb-4 tw-text-muted-foreground", children: "You have no chat history" }),
85062
- /* @__PURE__ */ jsxs("span", { className: "tw-text-sm tw-text-muted-foreground tw-mb-8", children: [
85264
+ /* @__PURE__ */ jsxs("span", { className: "tw-text-sm tw-text-muted-foreground tw-mb-8 tw-text-center", children: [
85063
85265
  "Explore all your previous chats here. Track and ",
85064
85266
  /* @__PURE__ */ jsx("br", {}),
85065
85267
  " search through what you've been working on."
@@ -85073,32 +85275,144 @@ const HistoryTabWithData = ({ IDE, webviewType, multipleWebviewsEnabled, setView
85073
85275
  className: "tw-px-4 tw-py-2",
85074
85276
  onClick: handleStartNewChat,
85075
85277
  children: [
85076
- /* @__PURE__ */ jsx(MessageSquarePlus, { size: 16, className: "tw-w-8 tw-h-8", strokeWidth: 1.25 }),
85278
+ /* @__PURE__ */ jsx(
85279
+ MessageSquarePlus,
85280
+ {
85281
+ size: 16,
85282
+ className: "tw-w-4 tw-h-4 tw-mr-2",
85283
+ strokeWidth: 1.25
85284
+ }
85285
+ ),
85077
85286
  "Start a new chat"
85078
85287
  ]
85079
85288
  }
85080
85289
  )
85081
- ] })
85082
- ] });
85083
- };
85084
- function useUserHistory$1() {
85085
- const userHistory = useExtensionAPI().userHistory;
85086
- return useObservable(useMemo$1(() => userHistory(), [userHistory])).value;
85087
- }
85088
- const SettingsTab = () => {
85089
- 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(
85090
- Button,
85290
+ ] });
85291
+ }
85292
+ return /* @__PURE__ */ jsxs(
85293
+ Command,
85091
85294
  {
85092
- variant: "secondary",
85093
- className: "tw-w-full tw-bg-popover",
85094
- onClick: () => getVSCodeAPI().postMessage({
85095
- command: "command",
85096
- id: "cody.status-bar.interacted"
85097
- }),
85098
- children: "Cody Settings"
85099
- },
85100
- "settings"
85101
- ) });
85295
+ loop: true,
85296
+ tabIndex: 0,
85297
+ shouldFilter: false,
85298
+ defaultValue: "empty",
85299
+ className: "tw-flex tw-flex-col tw-h-full tw-py-4 tw-bg-transparent tw-px-2 tw-mb-4 tw-overscroll-auto",
85300
+ disablePointerSelection: true,
85301
+ children: [
85302
+ IDE !== CodyIDE.Web && /* @__PURE__ */ jsxs("header", { className: "tw-inline-flex tw-mt-4 tw-px-4 tw-gap-4", children: [
85303
+ /* @__PURE__ */ jsx(
85304
+ Button,
85305
+ {
85306
+ variant: "secondary",
85307
+ className: "tw-bg-popover tw-border tw-border-border !tw-justify-between",
85308
+ onClick: onExportClick,
85309
+ children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center", children: [
85310
+ /* @__PURE__ */ jsx(Download, { size: 16, className: "tw-mr-3" }),
85311
+ " Export"
85312
+ ] })
85313
+ }
85314
+ ),
85315
+ /* @__PURE__ */ jsx(
85316
+ Button,
85317
+ {
85318
+ variant: "secondary",
85319
+ className: "tw-bg-popover tw-border tw-border-border !tw-justify-between",
85320
+ onClick: () => setIsDeleteAllActive(true),
85321
+ children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center", children: [
85322
+ /* @__PURE__ */ jsx(Trash2, { size: 16, className: "tw-mr-3" }),
85323
+ " Delete all"
85324
+ ] })
85325
+ }
85326
+ )
85327
+ ] }),
85328
+ isDeleteAllActive && /* @__PURE__ */ jsxs(
85329
+ "div",
85330
+ {
85331
+ className: "tw-my-4 tw-p-4 tw-mx-[0.5rem] tw-border tw-border-red-300 tw-rounded-lg tw-bg-muted-transparent dark:tw-text-red-400 dark:tw-border-red-800",
85332
+ role: "alert",
85333
+ children: [
85334
+ /* @__PURE__ */ jsx("div", { className: "tw-flex tw-items-center", children: /* @__PURE__ */ jsx("h3", { className: "tw-text-lg tw-font-medium", children: "Are you sure you want to delete all of your chats?" }) }),
85335
+ /* @__PURE__ */ jsx("div", { className: "tw-mt-2 tw-mb-4 tw-text-sm tw-text-muted-foreground", children: "You will not be able to recover them once deleted." }),
85336
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex", children: [
85337
+ /* @__PURE__ */ jsx(
85338
+ Button,
85339
+ {
85340
+ size: "sm",
85341
+ "aria-label": "Delete all chats",
85342
+ className: "tw-text-white tw-bg-red-800 hover:tw-bg-red-900 focus:tw-ring-4 focus:tw-outline-none focus:tw-ring-red-200 tw-font-medium tw-rounded-lg tw-text-xs tw-px-3 tw-py-1.5 tw-me-2 tw-text-center tw-inline-flex tw-items-center dark:tw-bg-red-600 dark:hover:tw-bg-red-700 dark:focus:tw-ring-red-800",
85343
+ onClick: (e2) => {
85344
+ onDeleteButtonClick(e2, "clear-all-no-confirm");
85345
+ setIsDeleteAllActive(false);
85346
+ },
85347
+ children: "Delete all chats"
85348
+ }
85349
+ ),
85350
+ /* @__PURE__ */ jsx(
85351
+ Button,
85352
+ {
85353
+ size: "sm",
85354
+ className: "tw-text-red-800 tw-bg-transparent tw-border tw-border-red-800 hover:tw-bg-red-900 hover:tw-text-white focus:tw-ring-4 focus:tw-outline-none focus:tw-ring-red-200 tw-font-medium tw-rounded-lg tw-text-xs tw-px-3 tw-py-1.5 tw-text-center dark:hover:tw-bg-red-600 dark:tw-border-red-600 dark:tw-text-red-400 dark:hover:tw-text-white dark:focus:tw-ring-red-800",
85355
+ onClick: () => setIsDeleteAllActive(false),
85356
+ "aria-label": "Cancel",
85357
+ children: "Cancel"
85358
+ }
85359
+ )
85360
+ ] })
85361
+ ]
85362
+ }
85363
+ ),
85364
+ /* @__PURE__ */ jsx(CommandList, { children: /* @__PURE__ */ jsx(
85365
+ CommandInput,
85366
+ {
85367
+ value: searchText,
85368
+ onValueChange: setSearchText,
85369
+ placeholder: "Search...",
85370
+ autoFocus: true,
85371
+ className: "tw-m-[0.5rem] !tw-p-[0.5rem] tw-rounded tw-bg-input-background tw-text-input-foreground focus:tw-shadow-[0_0_0_0.125rem_var(--vscode-focusBorder)]",
85372
+ disabled: chats.length === 0
85373
+ }
85374
+ ) }),
85375
+ /* @__PURE__ */ jsxs(CommandList, { className: "tw-flex-1 tw-overflow-y-auto tw-m-2", children: [
85376
+ displayedChats.map((chat2) => {
85377
+ const id2 = chat2.lastInteractionTimestamp;
85378
+ const chatTitle = chat2.chatTitle;
85379
+ const lastMessage = chat2.firstHumanMessageText;
85380
+ const timestamp = new Date(chat2.lastInteractionTimestamp).toLocaleString().replace("T", ", ").replace("Z", "");
85381
+ return /* @__PURE__ */ jsxs(
85382
+ CommandItem,
85383
+ {
85384
+ className: `tw-text-left tw-truncate tw-w-full tw-rounded-md tw-text-sm ${styles$6.historyItem} tw-overflow-hidden tw-text-sidebar-foreground tw-align-baseline`,
85385
+ onSelect: () => vscodeAPI.postMessage({
85386
+ command: "restoreHistory",
85387
+ chatID: id2
85388
+ }),
85389
+ children: [
85390
+ /* @__PURE__ */ jsxs("div", { className: "tw-truncate tw-w-full tw-flex tw-flex-col tw-gap-2", children: [
85391
+ /* @__PURE__ */ jsx("div", { children: chatTitle || lastMessage }),
85392
+ /* @__PURE__ */ jsx("div", { className: "tw-text-left tw-text-muted-foreground", children: timestamp })
85393
+ ] }),
85394
+ /* @__PURE__ */ jsx(
85395
+ Button,
85396
+ {
85397
+ variant: "outline",
85398
+ title: "Delete chat history",
85399
+ "aria-label": "delete-history-button",
85400
+ className: styles$6.deleteButton,
85401
+ onClick: (e2) => onDeleteButtonClick(e2, id2),
85402
+ onKeyDown: (e2) => onDeleteButtonClick(e2, id2),
85403
+ children: /* @__PURE__ */ jsx(Trash, { className: "tw-w-8 tw-h-8", size: 16, strokeWidth: "1.25" })
85404
+ }
85405
+ )
85406
+ ]
85407
+ },
85408
+ id2
85409
+ );
85410
+ }),
85411
+ hasMoreItems && /* @__PURE__ */ jsx("div", { ref: loadingRef, className: "tw-flex tw-justify-center tw-items-center tw-py-4", children: isLoading ? /* @__PURE__ */ jsx(LoadingDots, {}) : /* @__PURE__ */ jsx("span", { className: "tw-text-sm tw-text-muted-foreground", children: "Scroll for more" }) })
85412
+ ] })
85413
+ ]
85414
+ }
85415
+ );
85102
85416
  };
85103
85417
  var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
85104
85418
  var EVENT_OPTIONS = { bubbles: false, cancelable: true };
@@ -85479,22 +85793,6 @@ var Root2 = Tabs;
85479
85793
  var List = TabsList;
85480
85794
  var Trigger = TabsTrigger;
85481
85795
  var Content = TabsContent;
85482
- async function downloadChatHistory(extensionAPI) {
85483
- const userHistory = await firstResultFromOperation(extensionAPI.userHistory());
85484
- const chatHistory = userHistory ? Object.values(userHistory.chat) : null;
85485
- if (!chatHistory) {
85486
- return;
85487
- }
85488
- const json2 = JSON.stringify(chatHistory, null, 2);
85489
- const blob = new Blob([json2], { type: "application/json" });
85490
- const url = URL.createObjectURL(blob);
85491
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
85492
- const a2 = document.createElement("a");
85493
- a2.href = url;
85494
- a2.download = `cody-chat-history-${timestamp}.json`;
85495
- a2.target = "_blank";
85496
- a2.click();
85497
- }
85498
85796
  const SourcegraphLogo = (props) => /* @__PURE__ */ jsxs("svg", { id: "Layer_2", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 155 155", ...props, children: [
85499
85797
  /* @__PURE__ */ jsx("title", { children: "Sourcegraph logo" }),
85500
85798
  /* @__PURE__ */ jsx("g", { id: "Flattened", children: /* @__PURE__ */ jsxs("g", { id: "pictogram-light-mode", children: [
@@ -86204,19 +86502,34 @@ const TabsBar = memo$2((props) => {
86204
86502
  TabButton,
86205
86503
  {
86206
86504
  prominent: true,
86207
- Icon: showOpenInEditor ? Columns2 : MessageSquarePlus,
86208
- title: showOpenInEditor ? "Open in Editor" : "New Chat",
86505
+ Icon: MessageSquarePlus,
86506
+ title: "New Chat",
86209
86507
  IDE,
86210
86508
  tooltipExtra: IDE === CodyIDE.VSCode && "(⇧⌥/)",
86211
86509
  view: View.Chat,
86212
86510
  "data-testid": "new-chat-button",
86213
86511
  onClick: () => handleSubActionClick({
86214
86512
  changesView: View.Chat,
86215
- command: `${showOpenInEditor ? "cody.chat.moveToEditor" : getCreateNewChatCommand({
86513
+ command: getCreateNewChatCommand({
86216
86514
  IDE,
86217
86515
  webviewType,
86218
86516
  multipleWebviewsEnabled
86219
- })}`
86517
+ })
86518
+ })
86519
+ }
86520
+ ),
86521
+ showOpenInEditor && /* @__PURE__ */ jsx(
86522
+ TabButton,
86523
+ {
86524
+ prominent: true,
86525
+ Icon: Columns2,
86526
+ title: "Open in Editor",
86527
+ IDE,
86528
+ view: View.Chat,
86529
+ "data-testid": "open-in-editor-button",
86530
+ onClick: () => handleSubActionClick({
86531
+ changesView: View.Chat,
86532
+ command: "cody.chat.moveToEditor"
86220
86533
  })
86221
86534
  }
86222
86535
  ),
@@ -86359,6 +86672,7 @@ const TabButton = forwardRef((props, ref) => {
86359
86672
  TabButton.displayName = "TabButton";
86360
86673
  function useTabs(input2) {
86361
86674
  const IDE = input2.user.IDE;
86675
+ const isMcpEnabled = useFeatureFlag(FeatureFlag.NextAgenticChatInternal);
86362
86676
  const extensionAPI = useExtensionAPI();
86363
86677
  return useMemo$1(
86364
86678
  () => [
@@ -86372,7 +86686,7 @@ function useTabs(input2) {
86372
86686
  view: View.History,
86373
86687
  title: "History",
86374
86688
  Icon: History,
86375
- subActions: [
86689
+ subActions: IDE === CodyIDE.Web ? [
86376
86690
  {
86377
86691
  title: "Export",
86378
86692
  Icon: Download,
@@ -86386,17 +86700,17 @@ function useTabs(input2) {
86386
86700
  // Show Cody Chat UI confirmation modal with this message only for
86387
86701
  // Cody Web. All other IDE either implements their own native confirmation UI
86388
86702
  // or don't have confirmation UI at all.
86389
- confirmation: IDE === CodyIDE.Web ? {
86703
+ confirmation: {
86390
86704
  title: "Are you sure you want to delete all of your chats?",
86391
86705
  description: "You will not be able to recover them once deleted.",
86392
86706
  confirmationAction: "Delete all chats"
86393
- } : void 0,
86707
+ },
86394
86708
  // We don't have a way to request user confirmation in Cody Agent
86395
86709
  // (vscode.window.showWarningMessage is overridable there), so bypass
86396
86710
  // confirmation in cody agent and use confirmation UI above.
86397
- arg: IDE === CodyIDE.VSCode ? void 0 : "clear-all-no-confirm"
86711
+ arg: "clear-all-no-confirm"
86398
86712
  }
86399
- ].filter(isDefined),
86713
+ ].filter(isDefined) : void 0,
86400
86714
  changesView: true
86401
86715
  },
86402
86716
  {
@@ -86404,9 +86718,15 @@ function useTabs(input2) {
86404
86718
  title: "Prompts",
86405
86719
  Icon: BookText,
86406
86720
  changesView: true
86407
- }
86721
+ },
86722
+ isMcpEnabled ? {
86723
+ view: View.Settings,
86724
+ title: "Settings",
86725
+ Icon: Settings2,
86726
+ changesView: true
86727
+ } : null
86408
86728
  ].filter(isDefined),
86409
- [IDE, extensionAPI]
86729
+ [IDE, extensionAPI, isMcpEnabled]
86410
86730
  );
86411
86731
  }
86412
86732
  const TabViewContext = createContext({
@@ -86691,14 +87011,22 @@ const ModeSelectorField = ({ isDotComUser, className, _intent = "chat", omniBoxE
86691
87011
  },
86692
87012
  {
86693
87013
  title: "Search",
86694
- badge: isDotComUser ? "Enterprise" : "Beta",
87014
+ badge: isDotComUser ? "Enterprise" : void 0,
86695
87015
  icon: Search,
86696
87016
  intent: "search",
86697
- hidden: !omniBoxEnabled,
86698
87017
  disabled: isDotComUser,
86699
87018
  value: "Search"
86700
87019
  /* Search */
86701
87020
  },
87021
+ {
87022
+ title: "Edit",
87023
+ icon: Pencil,
87024
+ intent: "edit",
87025
+ hidden: !isEditEnabled,
87026
+ disabled: !isEditEnabled,
87027
+ value: "Edit"
87028
+ /* Edit */
87029
+ },
86702
87030
  {
86703
87031
  title: "Agent",
86704
87032
  badge: agenticChatEnabled ? "Experimental" : "Pro",
@@ -86709,35 +87037,18 @@ const ModeSelectorField = ({ isDotComUser, className, _intent = "chat", omniBoxE
86709
87037
  disabled: !agenticChatEnabled || !isEditEnabled,
86710
87038
  value: "Agent"
86711
87039
  /* Agentic */
86712
- },
86713
- {
86714
- title: "Edit Code",
86715
- badge: "Experimental",
86716
- icon: Pencil,
86717
- intent: "edit",
86718
- hidden: true,
86719
- disabled: !isEditEnabled,
86720
- value: "Edit"
86721
- /* Edit */
86722
- },
86723
- {
86724
- title: "Insert Code",
86725
- badge: "Experimental",
86726
- icon: BetweenHorizontalEnd,
86727
- intent: "insert",
86728
- hidden: true,
86729
- disabled: !isEditEnabled,
86730
- value: "Insert"
86731
- /* Insert */
86732
87040
  }
86733
87041
  ].filter((option) => !option.hidden);
86734
- }, [edit, config == null ? void 0 : config.experimentalAgenticChatEnabled, isDotComUser, omniBoxEnabled]);
87042
+ }, [edit, config == null ? void 0 : config.experimentalAgenticChatEnabled, isDotComUser]);
86735
87043
  const availableOptions = useMemo$1(
86736
87044
  () => intentOptions.filter((option) => !option.disabled),
86737
87045
  [intentOptions]
86738
87046
  );
86739
87047
  const [currentSelectedIntent, setCurrentSelectedIntent] = useState$1(() => {
86740
87048
  const mappedIntent = INTENT_MAPPING[_intent || "chat"];
87049
+ if (_intent === "agentic" && !(config == null ? void 0 : config.experimentalAgenticChatEnabled)) {
87050
+ return "Chat";
87051
+ }
86741
87052
  const isValidIntent = intentOptions.some(
86742
87053
  (option) => option.value === mappedIntent && !option.disabled
86743
87054
  );
@@ -86746,13 +87057,34 @@ const ModeSelectorField = ({ isDotComUser, className, _intent = "chat", omniBoxE
86746
87057
  const handleSelectIntent = useCallback(
86747
87058
  (intent, close2) => {
86748
87059
  manuallySelectIntent(intent);
86749
- setCurrentSelectedIntent(INTENT_MAPPING[intent || "chat"]);
87060
+ setCurrentSelectedIntent(
87061
+ INTENT_MAPPING[intent || "chat"] || "Chat"
87062
+ /* Chat */
87063
+ );
86750
87064
  close2 == null ? void 0 : close2();
86751
87065
  },
86752
87066
  [manuallySelectIntent]
86753
87067
  );
86754
87068
  useEffect$2(() => {
86755
87069
  if (availableOptions.length <= 1) return;
87070
+ if (_intent === "agentic" && !(config == null ? void 0 : config.experimentalAgenticChatEnabled)) {
87071
+ if (currentSelectedIntent !== "Chat") {
87072
+ setCurrentSelectedIntent(
87073
+ "Chat"
87074
+ /* Chat */
87075
+ );
87076
+ }
87077
+ return;
87078
+ }
87079
+ if (INTENT_MAPPING[
87080
+ _intent || "Chat"
87081
+ /* Chat */
87082
+ ] !== currentSelectedIntent) {
87083
+ setCurrentSelectedIntent(
87084
+ INTENT_MAPPING[_intent || "chat"] || "Chat"
87085
+ /* Chat */
87086
+ );
87087
+ }
86756
87088
  const handleKeyDown = (event) => {
86757
87089
  if ((isMac ? event.metaKey : event.ctrlKey) && event.key === ".") {
86758
87090
  event.preventDefault();
@@ -86765,7 +87097,13 @@ const ModeSelectorField = ({ isDotComUser, className, _intent = "chat", omniBoxE
86765
87097
  };
86766
87098
  document.addEventListener("keydown", handleKeyDown);
86767
87099
  return () => document.removeEventListener("keydown", handleKeyDown);
86768
- }, [availableOptions, currentSelectedIntent, handleSelectIntent]);
87100
+ }, [
87101
+ availableOptions,
87102
+ currentSelectedIntent,
87103
+ handleSelectIntent,
87104
+ _intent,
87105
+ config == null ? void 0 : config.experimentalAgenticChatEnabled
87106
+ ]);
86769
87107
  return /* @__PURE__ */ jsx(
86770
87108
  ToolbarPopoverItem,
86771
87109
  {
@@ -86834,10 +87172,10 @@ const Toolbar = ({
86834
87172
  className,
86835
87173
  models,
86836
87174
  intent,
86837
- manuallySelectIntent,
86838
87175
  extensionAPI,
86839
87176
  omniBoxEnabled,
86840
- onMediaUpload
87177
+ onMediaUpload,
87178
+ setLastManuallySelectedIntent
86841
87179
  }) => {
86842
87180
  const onMaybeGapClick = useCallback(
86843
87181
  (event) => {
@@ -86909,7 +87247,7 @@ const Toolbar = ({
86909
87247
  _intent: intent,
86910
87248
  isDotComUser: userInfo == null ? void 0 : userInfo.isDotComUser,
86911
87249
  isCodyProUser: userInfo == null ? void 0 : userInfo.isCodyProUser,
86912
- manuallySelectIntent
87250
+ manuallySelectIntent: setLastManuallySelectedIntent
86913
87251
  }
86914
87252
  ),
86915
87253
  /* @__PURE__ */ jsx(
@@ -86945,6 +87283,15 @@ const PromptSelectFieldToolbarItem = ({ focusEditor, className }) => {
86945
87283
  const ModelSelectFieldToolbarItem = ({ userInfo, focusEditor, className, models, extensionAPI, modelSelectorRef, intent }) => {
86946
87284
  const clientConfig = useClientConfig();
86947
87285
  const serverSentModelsEnabled = !!(clientConfig == null ? void 0 : clientConfig.modelsAPIEnabled);
87286
+ const agenticModel = useMemo$1(() => models.find((m2) => m2.tags.includes(ModelTag.Default)), [models]);
87287
+ useEffect$2(() => {
87288
+ var _a;
87289
+ if (intent === "agentic" && agenticModel && ((_a = models[0]) == null ? void 0 : _a.id) !== agenticModel.id) {
87290
+ extensionAPI.setChatModel(agenticModel.id).subscribe({
87291
+ error: (error2) => console.error("Failed to set chat model:", error2)
87292
+ });
87293
+ }
87294
+ }, [intent, agenticModel, models, extensionAPI.setChatModel]);
86948
87295
  const onModelSelect = useCallback(
86949
87296
  (model) => {
86950
87297
  extensionAPI.setChatModel(model.id).subscribe({
@@ -86990,7 +87337,7 @@ const HumanMessageEditor = ({
86990
87337
  editorRef: parentEditorRef,
86991
87338
  __storybook__focus,
86992
87339
  onEditorFocusChange: parentOnEditorFocusChange,
86993
- intent,
87340
+ selectedIntent,
86994
87341
  manuallySelectIntent
86995
87342
  }) => {
86996
87343
  var _a, _b, _c;
@@ -87010,7 +87357,7 @@ const HumanMessageEditor = ({
87010
87357
  );
87011
87358
  const submitState = isPendingPriorResponse ? "waitingResponseComplete" : isEmptyEditorValue ? "emptyEditorValue" : "submittable";
87012
87359
  const onSubmitClick = useCallback(
87013
- (intent2, forceSubmit) => {
87360
+ (_intent, forceSubmit) => {
87014
87361
  if (!forceSubmit && submitState === "emptyEditorValue") {
87015
87362
  return;
87016
87363
  }
@@ -87022,14 +87369,14 @@ const HumanMessageEditor = ({
87022
87369
  throw new Error("No editorRef");
87023
87370
  }
87024
87371
  const value = editorRef.current.getSerializedValue();
87025
- parentOnSubmit(intent2);
87372
+ parentOnSubmit(_intent);
87026
87373
  telemetryRecorder.recordEvent("cody.humanMessageEditor", "submit", {
87027
87374
  metadata: {
87028
87375
  isFirstMessage: isFirstMessage ? 1 : 0,
87029
87376
  isEdit: isSent ? 1 : 0,
87030
87377
  messageLength: value.text.length,
87031
87378
  contextItems: value.contextItems.length,
87032
- intent: [void 0, "chat", "search"].findIndex((i) => i === intent2)
87379
+ intent: [void 0, "chat", "search", "edit"].findIndex((i) => i === _intent)
87033
87380
  },
87034
87381
  billingMetadata: {
87035
87382
  product: "cody",
@@ -87039,7 +87386,7 @@ const HumanMessageEditor = ({
87039
87386
  },
87040
87387
  [submitState, parentOnSubmit, onStop, telemetryRecorder.recordEvent, isFirstMessage, isSent]
87041
87388
  );
87042
- const omniBoxEnabled = useOmniBox();
87389
+ const omniBoxEnabled = useOmniBox() && !userInfo.isDotComUser;
87043
87390
  const {
87044
87391
  config: { experimentalPromptEditorEnabled }
87045
87392
  } = useConfig();
@@ -87049,9 +87396,9 @@ const HumanMessageEditor = ({
87049
87396
  return;
87050
87397
  }
87051
87398
  event.preventDefault();
87052
- onSubmitClick();
87399
+ onSubmitClick(selectedIntent);
87053
87400
  },
87054
- [isEmptyEditorValue, onSubmitClick]
87401
+ [isEmptyEditorValue, onSubmitClick, selectedIntent]
87055
87402
  );
87056
87403
  const [isEditorFocused, setIsEditorFocused] = useState$1(false);
87057
87404
  const onEditorFocusChange = useCallback(
@@ -87150,9 +87497,10 @@ const HumanMessageEditor = ({
87150
87497
  })
87151
87498
  );
87152
87499
  }
87153
- let promptIntent = void 0;
87500
+ let promptIntent = selectedIntent;
87154
87501
  if (setPromptAsInput) {
87155
87502
  promptIntent = promptModeToIntent(setPromptAsInput.mode);
87503
+ manuallySelectIntent(promptIntent);
87156
87504
  updates.push(
87157
87505
  // biome-ignore lint/suspicious/noAsyncPromiseExecutor: <explanation>
87158
87506
  new Promise(async (resolve) => {
@@ -87162,7 +87510,6 @@ const HumanMessageEditor = ({
87162
87510
  const promptEditorState = await firstValueFrom(
87163
87511
  extensionAPI.hydratePromptMessage(setPromptAsInput.text, initialContext)
87164
87512
  );
87165
- manuallySelectIntent(promptIntent);
87166
87513
  requestAnimationFrame(async () => {
87167
87514
  if (editorRef.current) {
87168
87515
  await Promise.all([
@@ -87175,20 +87522,19 @@ const HumanMessageEditor = ({
87175
87522
  })
87176
87523
  );
87177
87524
  } else if (setLastHumanInputIntent) {
87525
+ promptIntent = setLastHumanInputIntent;
87178
87526
  manuallySelectIntent(setLastHumanInputIntent);
87179
87527
  }
87180
87528
  if (submitHumanInput || (setPromptAsInput == null ? void 0 : setPromptAsInput.autoSubmit)) {
87181
- Promise.all(updates).then(
87182
- () => onSubmitClick(promptIntent || setLastHumanInputIntent || intent, true)
87183
- );
87529
+ Promise.all(updates).then(() => onSubmitClick(promptIntent, true));
87184
87530
  }
87185
87531
  },
87186
87532
  [
87533
+ selectedIntent,
87187
87534
  onSubmitClick,
87188
- intent,
87189
- manuallySelectIntent,
87190
87535
  extensionAPI.hydratePromptMessage,
87191
- extensionAPI.defaultContext
87536
+ extensionAPI.defaultContext,
87537
+ manuallySelectIntent
87192
87538
  ]
87193
87539
  )
87194
87540
  );
@@ -87196,20 +87542,19 @@ const HumanMessageEditor = ({
87196
87542
  const defaultContext = useDefaultContextForChat();
87197
87543
  useEffect$2(() => {
87198
87544
  var _a2;
87199
- if (isSent || !isFirstMessage || !(editorRef == null ? void 0 : editorRef.current) || intent === "agentic") {
87545
+ if (isSent || !isFirstMessage || !(editorRef == null ? void 0 : editorRef.current) || selectedIntent === "agentic") {
87200
87546
  return;
87201
87547
  }
87202
87548
  const editor2 = editorRef.current;
87203
87549
  const excludedTypes = /* @__PURE__ */ new Set([
87204
87550
  "open-link",
87205
- "current-selection",
87206
87551
  ...((_a2 = currentChatModel == null ? void 0 : currentChatModel.tags) == null ? void 0 : _a2.includes(ModelTag.StreamDisabled)) ? ["tree"] : []
87207
87552
  ]);
87208
87553
  const filteredItems = defaultContext == null ? void 0 : defaultContext.initialContext.filter(
87209
87554
  (item2) => !excludedTypes.has(item2.type)
87210
87555
  );
87211
87556
  void editor2.setInitialContextMentions(filteredItems);
87212
- }, [defaultContext == null ? void 0 : defaultContext.initialContext, isSent, isFirstMessage, currentChatModel, intent]);
87557
+ }, [defaultContext == null ? void 0 : defaultContext.initialContext, isSent, isFirstMessage, currentChatModel, selectedIntent]);
87213
87558
  const focusEditor = useCallback(() => {
87214
87559
  var _a2;
87215
87560
  return (_a2 = editorRef.current) == null ? void 0 : _a2.setFocus(true);
@@ -87281,15 +87626,15 @@ const HumanMessageEditor = ({
87281
87626
  isEditorFocused: focused2,
87282
87627
  omniBoxEnabled,
87283
87628
  onSubmitClick,
87284
- manuallySelectIntent,
87285
87629
  submitState,
87286
87630
  onGapClick,
87287
87631
  focusEditor,
87288
87632
  hidden: !focused2 && isSent,
87289
87633
  className: styles$8.toolbar,
87290
- intent,
87634
+ intent: selectedIntent,
87291
87635
  extensionAPI,
87292
- onMediaUpload
87636
+ onMediaUpload,
87637
+ setLastManuallySelectedIntent: manuallySelectIntent
87293
87638
  }
87294
87639
  )
87295
87640
  ]
@@ -87327,8 +87672,8 @@ const HumanMessageCellContent = memo$2((props) => {
87327
87672
  editorRef,
87328
87673
  __storybook__focus,
87329
87674
  onEditorFocusChange,
87330
- intent,
87331
- manuallySelectIntent
87675
+ manuallySelectIntent,
87676
+ intent
87332
87677
  } = props;
87333
87678
  return /* @__PURE__ */ jsx(
87334
87679
  BaseMessageCell,
@@ -87353,14 +87698,14 @@ const HumanMessageCellContent = memo$2((props) => {
87353
87698
  editorRef,
87354
87699
  __storybook__focus,
87355
87700
  onEditorFocusChange,
87356
- intent,
87701
+ selectedIntent: intent,
87357
87702
  manuallySelectIntent
87358
87703
  }
87359
87704
  ),
87360
87705
  className
87361
87706
  }
87362
87707
  );
87363
- }, isEqual);
87708
+ });
87364
87709
  const CELL_NAME = "agentic-chat-items";
87365
87710
  const AgenticContextCell = memo$2(({ className, isContextLoading, processes }) => {
87366
87711
  var _a;
@@ -89071,16 +89416,13 @@ const DiffCell = ({
89071
89416
  const oldFile = ((_a = item2.metadata) == null ? void 0 : _a[0]) || "";
89072
89417
  const newFile = ((_b = item2.metadata) == null ? void 0 : _b[1]) || "";
89073
89418
  if (!oldFile && !newFile) {
89074
- return { result: null, content: null };
89419
+ return { result: null, content: (item2 == null ? void 0 : item2.content) ?? "Empty output" };
89075
89420
  }
89076
89421
  return {
89077
89422
  result: getFileDiff(item2.uri, oldFile, newFile),
89078
89423
  content: diffWithLineNum(oldFile, newFile, false)
89079
89424
  };
89080
89425
  }, [item2]);
89081
- if (!result2) {
89082
- return null;
89083
- }
89084
89426
  const renderHeaderContent = () => /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center tw-gap-2 tw-overflow-hidden", children: [
89085
89427
  /* @__PURE__ */ jsx(
89086
89428
  Button,
@@ -89096,7 +89438,8 @@ const DiffCell = ({
89096
89438
  children: /* @__PURE__ */ jsx("span", { className: "tw-font-mono", children: fileName })
89097
89439
  }
89098
89440
  ),
89099
- /* @__PURE__ */ jsxs("div", { className: "tw-ml-2 tw-flex tw-flex-shrink-0 tw-items-center tw-gap-2", children: [
89441
+ item2.status === UIToolStatus.Error && /* @__PURE__ */ jsx(Badge, { className: "tw-mx-1", variant: "error", children: "Failed" }),
89442
+ item2.status !== UIToolStatus.Error && result2 && /* @__PURE__ */ jsxs("div", { className: "tw-ml-2 tw-flex tw-flex-shrink-0 tw-items-center tw-gap-2", children: [
89100
89443
  result2.total.added > 0 && /* @__PURE__ */ jsxs("span", { className: "tw-flex tw-items-center tw-text-emerald-500", children: [
89101
89444
  /* @__PURE__ */ jsx(Plus, { size: 14, className: "tw-mr-0.5" }),
89102
89445
  " ",
@@ -89114,30 +89457,33 @@ const DiffCell = ({
89114
89457
  ] })
89115
89458
  ] })
89116
89459
  ] });
89117
- const renderBodyContent = () => /* @__PURE__ */ jsx("pre", { className: "tw-font-mono tw-text-xs tw-leading-relaxed tw-bg-zinc-950", children: /* @__PURE__ */ jsx("table", { className: "tw-w-full tw-h-full tw-border-collapse", children: /* @__PURE__ */ jsx("tbody", { children: result2.changes.map((change, index2) => {
89118
- var _a;
89119
- return /* @__PURE__ */ jsxs(
89120
- "tr",
89121
- {
89122
- className: cn(
89123
- "hover:tw-bg-zinc-800/50",
89124
- change.type === "added" && "tw-bg-emerald-950/30",
89125
- change.type === "removed" && "tw-bg-rose-950/30"
89126
- ),
89127
- children: [
89128
- /* @__PURE__ */ jsx("td", { className: "tw-select-none tw-border-r tw-border-r-zinc-700 tw-px-2 tw-text-right tw-text-zinc-500 tw-w-12", children: index2 === 0 && ((_a = change.content) == null ? void 0 : _a.startsWith("@@")) ? "" : change.lineNumber }),
89129
- /* @__PURE__ */ jsx("td", { className: "tw-px-4 tw-py-0.5 tw-text-zinc-200 tw-whitespace-pre", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center", children: [
89130
- /* @__PURE__ */ jsxs("span", { className: "tw-mr-2 tw-w-4 tw-text-center", children: [
89131
- change.type === "added" && /* @__PURE__ */ jsx("span", { className: "tw-text-emerald-500", children: "+" }),
89132
- change.type === "removed" && /* @__PURE__ */ jsx("span", { className: "tw-text-rose-500", children: "-" })
89133
- ] }),
89134
- change.content
89135
- ] }) })
89136
- ]
89137
- },
89138
- change.lineNumber
89139
- );
89140
- }) }) }) });
89460
+ const renderBodyContent = () => /* @__PURE__ */ jsxs("pre", { className: "tw-font-mono tw-text-xs tw-leading-relaxed tw-bg-zinc-950", children: [
89461
+ /* @__PURE__ */ jsx("table", { className: "tw-w-full tw-h-full tw-border-collapse", children: /* @__PURE__ */ jsx("tbody", { children: result2 == null ? void 0 : result2.changes.map((change, index2) => {
89462
+ var _a;
89463
+ return /* @__PURE__ */ jsxs(
89464
+ "tr",
89465
+ {
89466
+ className: cn(
89467
+ "hover:tw-bg-zinc-800/50",
89468
+ change.type === "added" && "tw-bg-emerald-950/30",
89469
+ change.type === "removed" && "tw-bg-rose-950/30"
89470
+ ),
89471
+ children: [
89472
+ /* @__PURE__ */ jsx("td", { className: "tw-select-none tw-border-r tw-border-r-zinc-700 tw-px-2 tw-text-right tw-text-zinc-500 tw-w-12", children: index2 === 0 && ((_a = change.content) == null ? void 0 : _a.startsWith("@@")) ? "" : change.lineNumber }),
89473
+ /* @__PURE__ */ jsx("td", { className: "tw-px-4 tw-py-0.5 tw-text-zinc-200 tw-whitespace-pre", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center", children: [
89474
+ /* @__PURE__ */ jsxs("span", { className: "tw-mr-2 tw-w-4 tw-text-center", children: [
89475
+ change.type === "added" && /* @__PURE__ */ jsx("span", { className: "tw-text-emerald-500", children: "+" }),
89476
+ change.type === "removed" && /* @__PURE__ */ jsx("span", { className: "tw-text-rose-500", children: "-" })
89477
+ ] }),
89478
+ change.content
89479
+ ] }) })
89480
+ ]
89481
+ },
89482
+ change.lineNumber
89483
+ );
89484
+ }) }) }),
89485
+ /* @__PURE__ */ jsx("div", { className: "tw-rounded-md tw-p-3 tw-font-mono tw-text-xs tw-mb-4 tw-overflow-x-auto", children: /* @__PURE__ */ jsx("pre", { className: "tw-whitespace-pre-wrap tw-break-words tw-text-zinc-300", children: item2.content }) })
89486
+ ] });
89141
89487
  return /* @__PURE__ */ jsx(
89142
89488
  BaseCell,
89143
89489
  {
@@ -89202,46 +89548,22 @@ const getStatusClass = (status2) => {
89202
89548
  case UIToolStatus.Pending:
89203
89549
  return "tw-bg-yellow-950/30 tw-border-yellow-800/50";
89204
89550
  default:
89205
- return "tw-bg-blue-950/30 tw-border-blue-800/50";
89206
- }
89207
- };
89208
- const getStatusLabel = (status2) => {
89209
- switch (status2) {
89210
- case UIToolStatus.Done:
89211
- return "Success";
89212
- case UIToolStatus.Error:
89213
- return "Error";
89214
- default:
89215
- return "Info";
89216
- }
89217
- };
89218
- const getBadgeClass = (status2) => {
89219
- switch (status2) {
89220
- case "success":
89221
- return "tw-bg-emerald-900/50 tw-text-emerald-200 tw-border-emerald-700";
89222
- case "error":
89223
- return "tw-bg-red-900/50 tw-text-red-200 tw-border-red-700";
89224
- case "warning":
89225
- return "tw-bg-yellow-900/50 tw-text-yellow-200 tw-border-yellow-700";
89226
- default:
89227
- return "tw-bg-blue-900/50 tw-text-blue-200 tw-border-blue-700";
89551
+ return "";
89228
89552
  }
89229
89553
  };
89230
89554
  const OutputStatusCell = ({ item: item2, className, defaultOpen = false }) => {
89231
89555
  if (!item2.title) {
89232
- return null;
89556
+ item2.title = item2.toolName;
89233
89557
  }
89234
- const status2 = item2.status || UIToolStatus.Info;
89558
+ const status2 = item2.status || "success";
89235
89559
  const StatusIcon = getStatusIcon(status2);
89236
- const headerContent = /* @__PURE__ */ jsx("div", { className: "tw-flex tw-flex-row tw-items-center tw-gap-2 tw-overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center tw-gap-2 tw-text-left tw-truncate tw-w-full", children: [
89237
- /* @__PURE__ */ jsx("span", { className: "tw-font-sm", children: item2.title }),
89238
- /* @__PURE__ */ jsx(Badge, { variant: "outline", className: cn(getBadgeClass(status2)), children: getStatusLabel(status2) })
89239
- ] }) });
89560
+ const outputTypeIcon = item2.outputType === "mcp" ? Server : StatusIcon;
89561
+ const headerContent = /* @__PURE__ */ jsx("div", { className: "tw-flex tw-flex-row tw-items-center tw-gap-2 tw-overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "tw-flex tw-items-center tw-gap-2 tw-text-left tw-truncate tw-w-full", children: /* @__PURE__ */ jsx("span", { className: "tw-font-sm", children: item2.title ?? item2.toolName }) }) });
89240
89562
  const bodyContent = /* @__PURE__ */ jsx("div", { className: cn("tw-p-4", getStatusClass(status2)), children: item2.content && /* @__PURE__ */ jsx("div", { className: "tw-rounded-md tw-p-3 tw-font-mono tw-text-xs tw-mb-4 tw-overflow-x-auto", children: /* @__PURE__ */ jsx("pre", { className: "tw-whitespace-pre-wrap tw-break-words tw-text-zinc-300", children: item2.content }) }) });
89241
89563
  return /* @__PURE__ */ jsx(
89242
89564
  BaseCell,
89243
89565
  {
89244
- icon: StatusIcon,
89566
+ icon: outputTypeIcon,
89245
89567
  headerContent,
89246
89568
  bodyContent,
89247
89569
  className,
@@ -89508,44 +89830,13 @@ const Transcript = (props) => {
89508
89830
  postMessage,
89509
89831
  copyButtonOnSubmit,
89510
89832
  insertButtonOnSubmit,
89511
- smartApply,
89512
- manuallySelectedIntent,
89513
- setManuallySelectedIntent
89833
+ smartApply
89514
89834
  } = props;
89515
89835
  const interactions = useMemo$1(
89516
89836
  () => transcriptToInteractionPairs(transcript, messageInProgress),
89517
- [transcript, messageInProgress, manuallySelectedIntent]
89837
+ [transcript, messageInProgress]
89518
89838
  );
89519
89839
  const lastHumanEditorRef = useRef$1(null);
89520
- const onAddToFollowupChat = useCallback(
89521
- ({
89522
- repoName,
89523
- filePath,
89524
- fileURL
89525
- }) => {
89526
- var _a;
89527
- (_a = lastHumanEditorRef.current) == null ? void 0 : _a.addMentions([
89528
- {
89529
- providerUri: REMOTE_FILE_PROVIDER_URI,
89530
- provider: "openctx",
89531
- type: "openctx",
89532
- uri: URI.parse(fileURL),
89533
- title: filePath.split("/").at(-1) ?? filePath,
89534
- description: filePath,
89535
- source: ContextItemSource.User,
89536
- mention: {
89537
- uri: fileURL,
89538
- description: filePath,
89539
- data: {
89540
- repoName,
89541
- filePath
89542
- }
89543
- }
89544
- }
89545
- ]);
89546
- },
89547
- []
89548
- );
89549
89840
  return /* @__PURE__ */ jsx(
89550
89841
  "div",
89551
89842
  {
@@ -89574,10 +89865,13 @@ const Transcript = (props) => {
89574
89865
  messageInProgress && ((_b = (_a = interactions.at(i - 1)) == null ? void 0 : _a.assistantMessage) == null ? void 0 : _b.isLoading)
89575
89866
  ),
89576
89867
  smartApply,
89577
- editorRef: interaction.humanMessage.index === -1 && !messageInProgress ? lastHumanEditorRef : void 0,
89578
- onAddToFollowupChat,
89579
- manuallySelectedIntent,
89580
- setManuallySelectedIntent
89868
+ editorRef: (
89869
+ // Only set the editor ref for:
89870
+ // 1. The first unsent agentic message (index -1), or
89871
+ // 2. The last interaction in the transcript
89872
+ // And only when there's no message currently in progress
89873
+ (interaction.humanMessage.intent === "agentic" && interaction.humanMessage.index === -1 || i === interactions.length - 1) && !messageInProgress ? lastHumanEditorRef : void 0
89874
+ )
89581
89875
  },
89582
89876
  interaction.humanMessage.index
89583
89877
  );
@@ -89585,7 +89879,7 @@ const Transcript = (props) => {
89585
89879
  }
89586
89880
  );
89587
89881
  };
89588
- function transcriptToInteractionPairs(transcript, assistantMessageInProgress, manuallySelectedIntent) {
89882
+ function transcriptToInteractionPairs(transcript, assistantMessageInProgress) {
89589
89883
  const pairs = [];
89590
89884
  const transcriptLength = transcript.length;
89591
89885
  for (let i = 0; i < transcriptLength; i += 2) {
@@ -89618,9 +89912,7 @@ function transcriptToInteractionPairs(transcript, assistantMessageInProgress, ma
89618
89912
  index: (lastHumanMessage == null ? void 0 : lastHumanMessage.intent) === "agentic" ? -1 : pairs.length * 2,
89619
89913
  speaker: "human",
89620
89914
  isUnsentFollowup: true,
89621
- // If the last submitted message was a search, default to chat for the followup. Else,
89622
- // keep the manually selected intent, if any, or the last human message's intent.
89623
- intent: (lastHumanMessage == null ? void 0 : lastHumanMessage.intent) === "search" ? "chat" : lastHumanMessage == null ? void 0 : lastHumanMessage.intent
89915
+ intent: (lastHumanMessage == null ? void 0 : lastHumanMessage.intent) === "agentic" ? "agentic" : "chat"
89624
89916
  },
89625
89917
  assistantMessage: null
89626
89918
  });
@@ -89643,17 +89935,22 @@ const TranscriptInteraction = memo$2((props) => {
89643
89935
  insertButtonOnSubmit,
89644
89936
  copyButtonOnSubmit,
89645
89937
  smartApply,
89646
- editorRef: parentEditorRef,
89647
- manuallySelectedIntent,
89648
- setManuallySelectedIntent
89938
+ editorRef: parentEditorRef
89649
89939
  } = props;
89650
89940
  const { activeChatContext, setActiveChatContext } = props;
89651
89941
  const humanEditorRef = useRef$1(null);
89652
89942
  const lastEditorRef = useContext(LastEditorContext);
89653
89943
  useImperativeHandle(parentEditorRef, () => humanEditorRef.current);
89944
+ const [selectedIntent, setSelectedIntent] = useState$1(humanMessage == null ? void 0 : humanMessage.intent);
89945
+ useEffect$2(() => {
89946
+ if (isFirstInteraction && isLastInteraction && humanMessage.isUnsentFollowup) {
89947
+ humanMessage.intent = "chat";
89948
+ setSelectedIntent("chat");
89949
+ }
89950
+ }, [humanMessage, isFirstInteraction, isLastInteraction]);
89654
89951
  const usingToolCody = (_a = assistantMessage == null ? void 0 : assistantMessage.model) == null ? void 0 : _a.includes(ToolCodyModelName);
89655
89952
  const onUserAction = useCallback(
89656
- (action, intentFromSubmit) => {
89953
+ (action, manuallySelectedIntent) => {
89657
89954
  var _a2, _b;
89658
89955
  const startMark = performance.mark("startSubmit");
89659
89956
  const spanManager2 = new SpanManager("cody-webview");
@@ -89678,8 +89975,8 @@ const TranscriptInteraction = memo$2((props) => {
89678
89975
  }
89679
89976
  const commonProps = {
89680
89977
  editorValue,
89681
- manuallySelectedIntent: intentFromSubmit || manuallySelectedIntent,
89682
- traceparent
89978
+ traceparent,
89979
+ manuallySelectedIntent
89683
89980
  };
89684
89981
  if (action === "edit") {
89685
89982
  if (isLastSentInteraction) {
@@ -89695,27 +89992,9 @@ const TranscriptInteraction = memo$2((props) => {
89695
89992
  });
89696
89993
  }
89697
89994
  },
89698
- [
89699
- humanMessage,
89700
- setActiveChatContext,
89701
- isLastSentInteraction,
89702
- lastEditorRef,
89703
- manuallySelectedIntent
89704
- ]
89705
- );
89706
- const onEditSubmit = useCallback(
89707
- (intentFromSubmit) => {
89708
- onUserAction("edit", intentFromSubmit);
89709
- },
89710
- [onUserAction]
89711
- );
89712
- const onFollowupSubmit = useCallback(
89713
- (intentFromSubmit) => {
89714
- onUserAction("submit", intentFromSubmit);
89715
- },
89716
- [onUserAction]
89995
+ [humanMessage, setActiveChatContext, isLastSentInteraction, lastEditorRef]
89717
89996
  );
89718
- const omniboxEnabled = useOmniBox() && !usingToolCody;
89997
+ const omniboxEnabled = useOmniBox() && !(userInfo == null ? void 0 : userInfo.isDotComUser);
89719
89998
  const vscodeAPI = getVSCodeAPI();
89720
89999
  const onStop = useCallback(() => {
89721
90000
  vscodeAPI.postMessage({
@@ -89832,15 +90111,18 @@ const TranscriptInteraction = memo$2((props) => {
89832
90111
  return null;
89833
90112
  }, [humanMessage, assistantMessage, isContextLoading]);
89834
90113
  const onHumanMessageSubmit = useCallback(
89835
- (intent) => {
90114
+ (intentOnSubmit) => {
90115
+ const currentIntent = selectedIntent || (humanMessage == null ? void 0 : humanMessage.intent);
90116
+ const newIntent = intentOnSubmit === void 0 ? currentIntent : intentOnSubmit;
90117
+ setSelectedIntent(newIntent);
89836
90118
  if (humanMessage.isUnsentFollowup) {
89837
- onFollowupSubmit(intent);
90119
+ onUserAction("submit", newIntent);
89838
90120
  } else {
89839
- onEditSubmit(intent);
90121
+ onUserAction("edit", newIntent);
89840
90122
  }
89841
90123
  humanMessage.isUnsentFollowup = false;
89842
90124
  },
89843
- [humanMessage, onFollowupSubmit, onEditSubmit]
90125
+ [humanMessage, onUserAction, selectedIntent]
89844
90126
  );
89845
90127
  const onSelectedFiltersUpdate = useCallback(
89846
90128
  (selectedFilters) => {
@@ -89852,19 +90134,62 @@ const TranscriptInteraction = memo$2((props) => {
89852
90134
  [humanMessage.index]
89853
90135
  );
89854
90136
  const editAndSubmitSearch = useCallback(
89855
- (text2) => editHumanMessage({
89856
- messageIndexInTranscript: humanMessage.index,
89857
- editorValue: {
89858
- text: text2,
89859
- contextItems: [],
89860
- editorState: serializedPromptEditorStateFromText(text2)
89861
- },
89862
- manuallySelectedIntent: "search"
89863
- }),
90137
+ (text2) => {
90138
+ setSelectedIntent("search");
90139
+ editHumanMessage({
90140
+ messageIndexInTranscript: humanMessage.index,
90141
+ editorValue: {
90142
+ text: text2,
90143
+ contextItems: [],
90144
+ editorState: serializedPromptEditorStateFromText(text2)
90145
+ },
90146
+ manuallySelectedIntent: "search"
90147
+ });
90148
+ },
89864
90149
  [humanMessage]
89865
90150
  );
90151
+ const [regeneratingCodeBlocks, setRegeneratingCodeBlocks] = useState$1(
90152
+ []
90153
+ );
90154
+ useClientActionListener(
90155
+ { isActive: true, selector: (event) => Boolean(event.regenerateStatus) },
90156
+ useCallback((event) => {
90157
+ setRegeneratingCodeBlocks((blocks) => {
90158
+ var _a2;
90159
+ switch ((_a2 = event.regenerateStatus) == null ? void 0 : _a2.status) {
90160
+ case "done": {
90161
+ const regenerateStatus = event.regenerateStatus;
90162
+ return blocks.filter((block) => block.id !== regenerateStatus.id).slice();
90163
+ }
90164
+ case "error": {
90165
+ const regenerateStatus = event.regenerateStatus;
90166
+ return blocks.map(
90167
+ (block) => block.id === regenerateStatus.id ? { ...block, error: regenerateStatus.error } : block
90168
+ ).slice();
90169
+ }
90170
+ default:
90171
+ return blocks;
90172
+ }
90173
+ });
90174
+ }, [])
90175
+ );
90176
+ const onRegenerate = useCallback(
90177
+ (code2, language2) => {
90178
+ if (assistantMessage) {
90179
+ const id2 = v4();
90180
+ regenerateCodeBlock({ id: id2, code: code2, language: language2, index: assistantMessage.index });
90181
+ setRegeneratingCodeBlocks((blocks) => [
90182
+ { id: id2, index: assistantMessage.index, code: code2, error: void 0 },
90183
+ ...blocks
90184
+ ]);
90185
+ } else {
90186
+ console.warn("tried to regenerate a code block, but there is no assistant message");
90187
+ }
90188
+ },
90189
+ [assistantMessage]
90190
+ );
89866
90191
  const isAgenticMode = useMemo$1(
89867
- () => (humanMessage == null ? void 0 : humanMessage.intent) === "agentic" || (humanMessage == null ? void 0 : humanMessage.manuallySelectedIntent) === "agentic",
90192
+ () => (humanMessage == null ? void 0 : humanMessage.manuallySelectedIntent) === "agentic" || (humanMessage == null ? void 0 : humanMessage.intent) === "agentic",
89868
90193
  [humanMessage == null ? void 0 : humanMessage.intent, humanMessage == null ? void 0 : humanMessage.manuallySelectedIntent]
89869
90194
  );
89870
90195
  const agentToolCalls = useMemo$1(() => {
@@ -89890,18 +90215,20 @@ const TranscriptInteraction = memo$2((props) => {
89890
90215
  isEditorInitiallyFocused: isLastInteraction,
89891
90216
  editorRef: humanEditorRef,
89892
90217
  className: !isFirstInteraction && isLastInteraction ? "tw-mt-auto" : "",
89893
- intent: manuallySelectedIntent,
89894
- manuallySelectIntent: setManuallySelectedIntent
90218
+ intent: selectedIntent,
90219
+ manuallySelectIntent: setSelectedIntent
89895
90220
  },
89896
90221
  humanMessage.index
89897
90222
  ),
89898
90223
  !isAgenticMode && /* @__PURE__ */ jsxs(Fragment$1, { children: [
89899
- omniboxEnabled && (assistantMessage == null ? void 0 : assistantMessage.didYouMeanQuery) && /* @__PURE__ */ jsx(
90224
+ !usingToolCody && omniboxEnabled && (assistantMessage == null ? void 0 : assistantMessage.didYouMeanQuery) && /* @__PURE__ */ jsx(
89900
90225
  DidYouMeanNotice,
89901
90226
  {
89902
90227
  query: assistantMessage == null ? void 0 : assistantMessage.didYouMeanQuery,
89903
90228
  disabled: !!(assistantMessage == null ? void 0 : assistantMessage.isLoading),
89904
- switchToSearch: () => editAndSubmitSearch((assistantMessage == null ? void 0 : assistantMessage.didYouMeanQuery) ?? "")
90229
+ switchToSearch: () => {
90230
+ editAndSubmitSearch((assistantMessage == null ? void 0 : assistantMessage.didYouMeanQuery) ?? "");
90231
+ }
89905
90232
  }
89906
90233
  ),
89907
90234
  !usingToolCody && !isSearchIntent && humanMessage.agent && /* @__PURE__ */ jsx(
@@ -89936,6 +90263,8 @@ const TranscriptInteraction = memo$2((props) => {
89936
90263
  message: assistantMessage,
89937
90264
  copyButtonOnSubmit,
89938
90265
  insertButtonOnSubmit,
90266
+ onRegenerate,
90267
+ regeneratingCodeBlocks,
89939
90268
  postMessage,
89940
90269
  guardrails,
89941
90270
  humanMessage: humanMessageInfo,
@@ -89972,6 +90301,20 @@ function focusLastHumanMessageEditor() {
89972
90301
  container2.scrollTop = editorScrollItemInContainer.offsetTop - container2.offsetTop;
89973
90302
  }
89974
90303
  }
90304
+ function regenerateCodeBlock({
90305
+ id: id2,
90306
+ code: code2,
90307
+ language: language2,
90308
+ index: index2
90309
+ }) {
90310
+ getVSCodeAPI().postMessage({
90311
+ command: "regenerateCodeBlock",
90312
+ id: id2,
90313
+ code: code2,
90314
+ language: language2,
90315
+ index: index2
90316
+ });
90317
+ }
89975
90318
  function editHumanMessage({
89976
90319
  messageIndexInTranscript,
89977
90320
  editorValue,
@@ -90012,28 +90355,70 @@ function reevaluateSearchWithSelectedFilters({
90012
90355
  selectedFilters
90013
90356
  });
90014
90357
  }
90015
- function useUserHistory() {
90016
- const userHistory = useExtensionAPI().userHistory;
90017
- return useObservable(useMemo$1(() => userHistory(), [userHistory])).value;
90018
- }
90019
- const LastConversation = ({ setView, IDE }) => {
90020
- var _a, _b, _c, _d;
90358
+ const Card = React$2.forwardRef(
90359
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
90360
+ "div",
90361
+ {
90362
+ ref,
90363
+ className: cn(
90364
+ "tw-border tw-border-input-border tw-rounded-lg tw-shadow-sm tw-transition-all",
90365
+ className
90366
+ ),
90367
+ ...props
90368
+ }
90369
+ )
90370
+ );
90371
+ Card.displayName = "Card";
90372
+ const CardHeader = React$2.forwardRef(
90373
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
90374
+ "div",
90375
+ {
90376
+ ref,
90377
+ className: cn("tw-flex tw-flex-col tw-space-y-1.5 tw-p-[0.25rem 0.5rem]", className),
90378
+ ...props
90379
+ }
90380
+ )
90381
+ );
90382
+ CardHeader.displayName = "CardHeader";
90383
+ const CardTitle = React$2.forwardRef(
90384
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
90385
+ "h3",
90386
+ {
90387
+ ref,
90388
+ className: cn("tw-text-2xl tw-font-semibold tw-leading-none tw-tracking-tight", className),
90389
+ ...props
90390
+ }
90391
+ )
90392
+ );
90393
+ CardTitle.displayName = "CardTitle";
90394
+ const CardDescription = React$2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { ref, className: cn("tw-text-sm tw-text-muted-foreground", className), ...props }));
90395
+ CardDescription.displayName = "CardDescription";
90396
+ const CardContent = React$2.forwardRef(
90397
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("tw-p-6", className), ...props })
90398
+ );
90399
+ CardContent.displayName = "CardContent";
90400
+ const CardFooter = React$2.forwardRef(
90401
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("tw-flex tw-items-center tw-p-6", className), ...props })
90402
+ );
90403
+ CardFooter.displayName = "CardFooter";
90404
+ const LastConversation = ({ setView }) => {
90405
+ var _a, _b;
90021
90406
  const userHistory = useUserHistory();
90022
90407
  const lastChat = useMemo$1(() => {
90023
- if (!(userHistory == null ? void 0 : userHistory.chat)) {
90408
+ if (!userHistory) {
90024
90409
  return null;
90025
90410
  }
90026
- const chats = Object.values(userHistory.chat).filter((chat2) => chat2.interactions.length > 0).sort(
90411
+ return Object.values(userHistory).filter((chat2) => {
90412
+ var _a2;
90413
+ return (_a2 = chat2.firstHumanMessageText) == null ? void 0 : _a2.trim();
90414
+ }).sort(
90027
90415
  (a2, b2) => new Date(b2.lastInteractionTimestamp).getTime() - new Date(a2.lastInteractionTimestamp).getTime()
90028
- );
90029
- return chats[0] || null;
90416
+ )[0] || null;
90030
90417
  }, [userHistory]);
90031
- if (!lastChat) {
90418
+ if (!((_a = lastChat == null ? void 0 : lastChat.chatTitle) == null ? void 0 : _a.trim())) {
90032
90419
  return null;
90033
90420
  }
90034
- const lastMessage = ((_c = (_b = (_a = lastChat.interactions[lastChat.interactions.length - 1]) == null ? void 0 : _a.humanMessage) == null ? void 0 : _b.text) == null ? void 0 : _c.trim()) || "";
90035
- const displayText = ((_d = lastChat.chatTitle) == null ? void 0 : _d.trim()) || lastMessage;
90036
- const truncatedText = displayText.length > 50 ? displayText.slice(0, 47) + "..." : displayText;
90421
+ const displayText = (_b = lastChat.chatTitle) == null ? void 0 : _b.trim();
90037
90422
  const timePeriod = getRelativeChatPeriod(new Date(lastChat.lastInteractionTimestamp));
90038
90423
  const handleClick = () => {
90039
90424
  getVSCodeAPI().postMessage({
@@ -90042,21 +90427,27 @@ const LastConversation = ({ setView, IDE }) => {
90042
90427
  });
90043
90428
  setView(View.Chat);
90044
90429
  };
90045
- return /* @__PURE__ */ jsxs(
90046
- Button,
90047
- {
90048
- variant: "outline",
90049
- className: "tw-w-full tw-flex tw-items-center tw-gap-2 tw-px-3 tw-py-2 tw-text-left tw-border-gray-500/20 dark:tw-border-gray-600/40",
90050
- onClick: handleClick,
90051
- children: [
90052
- /* @__PURE__ */ jsx(History, { size: 16, className: "tw-text-foreground/80" }),
90053
- /* @__PURE__ */ jsxs("div", { className: "tw-flex-1 tw-min-w-0", children: [
90054
- /* @__PURE__ */ jsx("div", { className: "tw-text-sm tw-font-medium tw-text-foreground/80 tw-truncate", children: truncatedText }),
90055
- /* @__PURE__ */ jsx("div", { className: "tw-text-xs tw-text-foreground/60", children: timePeriod })
90056
- ] })
90057
- ]
90058
- }
90059
- );
90430
+ const handleViewAllClick = () => setView(View.History);
90431
+ return /* @__PURE__ */ jsxs("div", { children: [
90432
+ /* @__PURE__ */ jsx("div", { className: "tw-mb-4 tw-flex tw-items-center tw-justify-end tw-border-1 tw-border-[var(--vscode-dropdown-border, transparent)]", children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "tw-pl-2", onClick: handleViewAllClick, children: [
90433
+ "View all",
90434
+ /* @__PURE__ */ jsx(ArrowRight, { size: 14, className: "tw-ml-2" })
90435
+ ] }) }),
90436
+ /* @__PURE__ */ jsx(
90437
+ Card,
90438
+ {
90439
+ className: "tw-overflow-hidden tw-transition-all hover:tw-bg-muted/5 tw-cursor-pointer",
90440
+ onClick: handleClick,
90441
+ children: /* @__PURE__ */ jsx(CardContent, { className: "tw-p-4", children: /* @__PURE__ */ jsx("div", { className: "tw-flex tw-items-start", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex-1 tw-space-y-1 tw-overflow-y-auto", children: [
90442
+ /* @__PURE__ */ jsx("h3", { className: "tw-font-normal tw-text-left tw-truncate tw-w-full", children: displayText }),
90443
+ /* @__PURE__ */ jsx("p", { className: "tw-line-clamp-1 tw-text-sm tw-text-muted-foreground", children: /* @__PURE__ */ jsxs("div", { className: "tw-inline-flex tw-items-center tw-text-xs tw-text-muted-foreground", children: [
90444
+ /* @__PURE__ */ jsx(History, { size: 12, className: "tw-inline-block tw-mr-1" }),
90445
+ timePeriod
90446
+ ] }) })
90447
+ ] }) }) })
90448
+ }
90449
+ )
90450
+ ] });
90060
90451
  };
90061
90452
  const localStorageKey = "chat.welcome-message-dismissed";
90062
90453
  const WelcomeMessage = ({ setView, IDE }) => {
@@ -90176,7 +90567,6 @@ const ScrollDown = (props) => {
90176
90567
  }
90177
90568
  ) }) : null;
90178
90569
  };
90179
- const LAST_SELECTED_INTENT_KEY = "last-selected-intent";
90180
90570
  const Chat = ({
90181
90571
  messageInProgress,
90182
90572
  transcript,
@@ -90193,7 +90583,6 @@ const Chat = ({
90193
90583
  const transcriptRef = useRef$1(transcript);
90194
90584
  transcriptRef.current = transcript;
90195
90585
  const userInfo = useUserAccountInfo();
90196
- const [lastManuallySelectedIntent, setLastManuallySelectedIntent] = useLocalStorage(LAST_SELECTED_INTENT_KEY, "chat");
90197
90586
  const copyButtonOnSubmit = useCallback(
90198
90587
  (text2, eventType = "Button") => {
90199
90588
  const op = "copy";
@@ -90320,9 +90709,7 @@ const Chat = ({
90320
90709
  userInfo,
90321
90710
  chatEnabled,
90322
90711
  postMessage,
90323
- guardrails,
90324
- manuallySelectedIntent: lastManuallySelectedIntent,
90325
- setManuallySelectedIntent: setLastManuallySelectedIntent
90712
+ guardrails
90326
90713
  }
90327
90714
  ),
90328
90715
  transcript.length === 0 && showWelcomeMessage && /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -90655,6 +91042,360 @@ const DebugActions = ({ className }) => {
90655
91042
  ) })
90656
91043
  ] });
90657
91044
  };
91045
+ function ServerCard({ server, onClick }) {
91046
+ var _a;
91047
+ const ServerIcon = server.icon ?? DatabaseZap;
91048
+ const [showAllTags, setShowAllTags] = useState$1(false);
91049
+ const maxVisibleTags = 3;
91050
+ const hasMoreTags = server.tools && server.tools.length > maxVisibleTags;
91051
+ return /* @__PURE__ */ jsxs(
91052
+ Card,
91053
+ {
91054
+ className: "tw-overflow-hidden tw-hover:border-primary/50 tw-transition-colors tw-cursor-pointer",
91055
+ onClick: (e2) => {
91056
+ if (e2.target.closest("[data-tag-expansion]")) {
91057
+ e2.stopPropagation();
91058
+ return;
91059
+ }
91060
+ onClick();
91061
+ },
91062
+ children: [
91063
+ /* @__PURE__ */ jsx(CardHeader, { className: "tw-p-2 tw-m-2", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-justify-between tw-items-start", children: [
91064
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center tw-gap-2", children: [
91065
+ /* @__PURE__ */ jsx("div", { className: "tw-p-1.5 tw-rounded-md tw-bg-primary/10", children: /* @__PURE__ */ jsx(ServerIcon, { className: "tw-h-full tw-text-primary" }) }),
91066
+ /* @__PURE__ */ jsx(CardTitle, { className: "tw-text-base tw-text-md", children: server.name })
91067
+ ] }),
91068
+ /* @__PURE__ */ jsx(
91069
+ Badge,
91070
+ {
91071
+ variant: server.status === "online" ? "success" : "error",
91072
+ className: "tw-whitespace-nowrap tw-overflow-hidden tw-ring-1 tw-ring-inset",
91073
+ children: server.status
91074
+ }
91075
+ )
91076
+ ] }) }),
91077
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "tw-flex tw-align-top tw-justify-between tw-my-1 tw-flex-wrap", children: server.tools && ((_a = server.tools) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ jsx("div", { className: "tw-mt-2", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-wrap tw-gap-4", children: [
91078
+ server.tools.slice(0, maxVisibleTags).map((t2) => /* @__PURE__ */ jsx(
91079
+ Badge,
91080
+ {
91081
+ variant: "ghost",
91082
+ className: "tw-truncate tw-max-w-[250px] tw-text-foreground",
91083
+ title: t2.description,
91084
+ children: t2.name
91085
+ },
91086
+ t2.name
91087
+ )),
91088
+ hasMoreTags && /* @__PURE__ */ jsx(
91089
+ TagsPopover,
91090
+ {
91091
+ tags: server.tools.map((t2) => t2.name),
91092
+ visibleCount: maxVisibleTags,
91093
+ showAllTags,
91094
+ setShowAllTags
91095
+ }
91096
+ )
91097
+ ] }) }) }) })
91098
+ ]
91099
+ }
91100
+ );
91101
+ }
91102
+ function TagsPopover({ tags, visibleCount, showAllTags, setShowAllTags }) {
91103
+ const remainingCount = tags.length - visibleCount;
91104
+ return /* @__PURE__ */ jsxs(Popover, { open: showAllTags, onOpenChange: setShowAllTags, children: [
91105
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
91106
+ Badge,
91107
+ {
91108
+ variant: "ghost",
91109
+ className: "text-xs px-1.5 py-0 cursor-pointer hover:bg-secondary/80",
91110
+ "data-tag-expansion": "true",
91111
+ children: [
91112
+ "+",
91113
+ remainingCount,
91114
+ " more"
91115
+ ]
91116
+ }
91117
+ ) }),
91118
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "w-auto p-2", align: "start", children: [
91119
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium mb-1.5", children: "All Tags" }),
91120
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5 max-w-[300px]", children: tags.map((tag) => /* @__PURE__ */ jsx(Badge, { variant: "ghost", className: "text-xs", children: tag }, tag)) })
91121
+ ] })
91122
+ ] });
91123
+ }
91124
+ const DEFAULT_CONFIG = {
91125
+ id: crypto.randomUUID(),
91126
+ // Add a unique id
91127
+ name: "",
91128
+ type: "MCP",
91129
+ status: "online",
91130
+ icon: Globe,
91131
+ url: "",
91132
+ command: "",
91133
+ args: [""],
91134
+ env: [{ name: "", value: "" }]
91135
+ };
91136
+ function AddServerForm({ onAddServer, _server }) {
91137
+ var _a, _b;
91138
+ const [formData, setFormData] = React$2.useState({ ...DEFAULT_CONFIG, ..._server });
91139
+ const handleSubmit = (e2) => {
91140
+ e2.preventDefault();
91141
+ onAddServer(formData);
91142
+ setFormData({ ...DEFAULT_CONFIG });
91143
+ };
91144
+ const addArg = (index2, arg) => {
91145
+ const args = formData.args || [];
91146
+ args[index2] = arg;
91147
+ setFormData({
91148
+ ...formData,
91149
+ args
91150
+ });
91151
+ };
91152
+ const addEnvVar = () => {
91153
+ var _a2;
91154
+ const newFormData = { ...formData };
91155
+ (_a2 = newFormData.env) == null ? void 0 : _a2.push({ name: "", value: "" });
91156
+ setFormData(newFormData);
91157
+ };
91158
+ const removeArg = (index2) => {
91159
+ const newArgs = formData.args || DEFAULT_CONFIG.args;
91160
+ setFormData({
91161
+ ...formData,
91162
+ args: newArgs.splice(index2, 1)
91163
+ });
91164
+ };
91165
+ const updateEnvVar = (index2, field, value) => {
91166
+ const env2 = formData.env || DEFAULT_CONFIG.env;
91167
+ const newEnv = [...env2];
91168
+ newEnv[index2][field] = value;
91169
+ setFormData({
91170
+ ...formData,
91171
+ env: newEnv
91172
+ });
91173
+ };
91174
+ const removeEnvVar = (index2) => {
91175
+ const env2 = formData.env || DEFAULT_CONFIG.env;
91176
+ const newEnv = [...env2];
91177
+ newEnv.splice(index2, 1);
91178
+ setFormData({
91179
+ ...formData,
91180
+ env: newEnv
91181
+ });
91182
+ };
91183
+ return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
91184
+ /* @__PURE__ */ jsxs("div", { className: "tw-grid tw-gap-4 tw-py-4 tw-text-sm", children: [
91185
+ /* @__PURE__ */ jsx("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4", children: /* @__PURE__ */ jsxs("div", { className: "tw-space-y-2", children: [
91186
+ /* @__PURE__ */ jsx(Label, { htmlFor: "name", children: "Name" }),
91187
+ /* @__PURE__ */ jsx(
91188
+ "input",
91189
+ {
91190
+ type: "text",
91191
+ id: "name",
91192
+ value: formData.name,
91193
+ name: "name",
91194
+ onChange: (e2) => setFormData({ ...formData, name: e2.target.value }),
91195
+ className: "tw-block tw-py-2.5 tw-px-0 tw-w-full tw-text-sm tw-text-gray-900 tw-bg-transparent tw-border-0 tw-border-b-2 tw-border-gray-300 tw-appearance-none dark:tw-text-white dark:tw-border-gray-600 dark:focus:tw-border-blue-500 focus:tw-outline-none focus:tw-ring-0 focus:tw-border-blue-600 peer",
91196
+ placeholder: " ",
91197
+ required: true
91198
+ }
91199
+ )
91200
+ ] }) }),
91201
+ /* @__PURE__ */ jsxs("div", { className: "tw-space-y-2", children: [
91202
+ /* @__PURE__ */ jsx(Label, { htmlFor: "command", children: "Command" }),
91203
+ /* @__PURE__ */ jsx(
91204
+ "input",
91205
+ {
91206
+ id: "command",
91207
+ value: formData.command,
91208
+ onChange: (e2) => setFormData({ ...formData, type: e2.target.value }),
91209
+ className: "tw-block tw-py-2.5 tw-px-0 tw-w-full tw-text-sm tw-text-gray-900 tw-bg-transparent tw-border-0 tw-border-b-2 tw-border-gray-300 tw-appearance-none dark:tw-text-white dark:tw-border-gray-600 dark:focus:tw-border-blue-500 focus:tw-outline-none focus:tw-ring-0 focus:tw-border-blue-600 peer",
91210
+ placeholder: "npx",
91211
+ required: true
91212
+ }
91213
+ )
91214
+ ] }),
91215
+ /* @__PURE__ */ jsxs("div", { className: "tw-space-y-2", children: [
91216
+ /* @__PURE__ */ jsx(Label, { htmlFor: "url", children: "URL" }),
91217
+ /* @__PURE__ */ jsx(
91218
+ "input",
91219
+ {
91220
+ id: "url",
91221
+ size: 12,
91222
+ value: formData.url,
91223
+ onChange: (e2) => setFormData({ ...formData, url: e2.target.value }),
91224
+ className: "tw-block tw-py-2.5 tw-px-0 tw-w-full tw-text-sm tw-text-gray-900 tw-bg-transparent tw-border-0 tw-border-b-2 tw-border-gray-300 tw-appearance-none dark:tw-text-white dark:tw-border-gray-600 dark:focus:tw-border-blue-500 focus:tw-outline-none focus:tw-ring-0 focus:tw-border-blue-600 peer",
91225
+ placeholder: "Make sure you pass in the absolute path to your server.",
91226
+ required: true
91227
+ }
91228
+ )
91229
+ ] }),
91230
+ /* @__PURE__ */ jsxs("div", { className: "tw-space-y-3", children: [
91231
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center tw-justify-between", children: [
91232
+ /* @__PURE__ */ jsx(Label, { children: "Arguments" }),
91233
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: addEnvVar, children: /* @__PURE__ */ jsx(Plus, { size: 14 }) })
91234
+ ] }),
91235
+ (_a = formData == null ? void 0 : formData.args) == null ? void 0 : _a.map((arg, index2) => (
91236
+ // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
91237
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-gap-2 tw-items-center", children: [
91238
+ /* @__PURE__ */ jsx(
91239
+ "input",
91240
+ {
91241
+ value: arg,
91242
+ placeholder: "",
91243
+ onChange: (e2) => addArg(index2, e2.target.value),
91244
+ className: "tw-block tw-py-2.5 tw-px-0 tw-w-full tw-text-sm tw-text-gray-900 tw-bg-transparent tw-border-0 tw-border-b-2 tw-border-gray-300 tw-appearance-none dark:tw-text-white dark:tw-border-gray-600 dark:focus:tw-border-blue-500 focus:tw-outline-none focus:tw-ring-0 focus:tw-border-blue-600 peer"
91245
+ }
91246
+ ),
91247
+ /* @__PURE__ */ jsx(
91248
+ Button,
91249
+ {
91250
+ type: "button",
91251
+ variant: "ghost",
91252
+ size: "icon",
91253
+ className: "tw-shrink-0",
91254
+ onClick: () => removeArg(index2),
91255
+ children: /* @__PURE__ */ jsx(X$2, { size: 14, className: "tw-ml-1" })
91256
+ }
91257
+ )
91258
+ ] }, index2)
91259
+ ))
91260
+ ] }),
91261
+ /* @__PURE__ */ jsx("div", { className: "tw-space-y-2", children: /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-items-center tw-justify-between", children: [
91262
+ /* @__PURE__ */ jsx(Label, { children: "Environment Variables" }),
91263
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: addEnvVar, children: /* @__PURE__ */ jsx(Plus, { size: 14 }) })
91264
+ ] }) }),
91265
+ /* @__PURE__ */ jsx("div", { className: "tw-space-y-3 tw-w-full", children: (_b = formData == null ? void 0 : formData.env) == null ? void 0 : _b.map((env2, index2) => (
91266
+ // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
91267
+ /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-gap-2 tw-items-center", children: [
91268
+ /* @__PURE__ */ jsx(
91269
+ "input",
91270
+ {
91271
+ value: env2.name,
91272
+ placeholder: "",
91273
+ onChange: (e2) => updateEnvVar(index2, "name", e2.target.value),
91274
+ className: "tw-block tw-py-2.5 tw-px-0 tw-w-full tw-text-sm tw-text-gray-900 tw-bg-transparent tw-border-0 tw-border-b-2 tw-border-gray-300 tw-appearance-none dark:tw-text-white dark:tw-border-gray-600 dark:focus:tw-border-blue-500 focus:tw-outline-none focus:tw-ring-0 focus:tw-border-blue-600 peer"
91275
+ }
91276
+ ),
91277
+ /* @__PURE__ */ jsx("span", { className: "tw-mx-1", children: "=" }),
91278
+ /* @__PURE__ */ jsx(
91279
+ "input",
91280
+ {
91281
+ value: env2.value,
91282
+ placeholder: "",
91283
+ onChange: (e2) => updateEnvVar(index2, "value", e2.target.value),
91284
+ className: "tw-block tw-py-2.5 tw-px-0 tw-w-full tw-text-sm tw-text-gray-900 tw-bg-transparent tw-border-0 tw-border-b-2 tw-border-gray-300 tw-appearance-none dark:tw-text-white dark:tw-border-gray-600 dark:focus:tw-border-blue-500 focus:tw-outline-none focus:tw-ring-0 focus:tw-border-blue-600 peer"
91285
+ }
91286
+ ),
91287
+ /* @__PURE__ */ jsx(
91288
+ Button,
91289
+ {
91290
+ type: "button",
91291
+ variant: "ghost",
91292
+ size: "icon",
91293
+ className: "tw-shrink-0",
91294
+ onClick: () => removeEnvVar(index2),
91295
+ children: /* @__PURE__ */ jsx(X$2, { size: 14, className: "tw-ml-1" })
91296
+ }
91297
+ )
91298
+ ] }, index2)
91299
+ )) })
91300
+ ] }),
91301
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Button, { variant: "default", size: "sm", className: "tw-inline-flex tw-w-full", children: [
91302
+ /* @__PURE__ */ jsx(Save, { size: 12, className: "tw-mr-1" }),
91303
+ " Save"
91304
+ ] }) })
91305
+ ] });
91306
+ }
91307
+ function AddServerView({ onAddServer, className }) {
91308
+ const [open, setOpen] = React$2.useState(false);
91309
+ const handleAddServer = (server) => {
91310
+ onAddServer(server);
91311
+ setOpen(false);
91312
+ };
91313
+ return /* @__PURE__ */ jsxs($5d3850c4d0b4e6c7$export$3ddf2d174ce01153, { open, onOpenChange: setOpen, children: [
91314
+ /* @__PURE__ */ jsx($5d3850c4d0b4e6c7$export$2e1e1122cf0cba88, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "tw-inline-flex tw-w-full", disabled: open, children: [
91315
+ /* @__PURE__ */ jsx(Plus, { size: 12, className: "tw-mr-1" }),
91316
+ " Add Server"
91317
+ ] }) }),
91318
+ /* @__PURE__ */ jsx($5d3850c4d0b4e6c7$export$b6d9565de1e068cf, { className: "tw-sm:max-w-[500px] tw-my-4", children: /* @__PURE__ */ jsx(AddServerForm, { onAddServer: handleAddServer }) })
91319
+ ] });
91320
+ }
91321
+ function ServerDetailView({ server, onAddServer }) {
91322
+ return /* @__PURE__ */ jsx("div", { className: "tw-container tw-p-6 tw-w-full", children: /* @__PURE__ */ jsxs(Card, { className: "tw-m-6 tw-w-full", children: [
91323
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
91324
+ /* @__PURE__ */ jsx(CardTitle, { children: server.name }),
91325
+ /* @__PURE__ */ jsx(CardDescription, { children: /* @__PURE__ */ jsxs(Button, { variant: "default", size: "sm", children: [
91326
+ /* @__PURE__ */ jsx(Power, { size: 12 }),
91327
+ server.status === "online" ? "Disconnet" : "Connet"
91328
+ ] }) })
91329
+ ] }),
91330
+ /* @__PURE__ */ jsx(CardContent, { className: "tw-space-y-6", children: /* @__PURE__ */ jsx(AddServerForm, { _server: server, onAddServer }) }),
91331
+ /* @__PURE__ */ jsxs(CardFooter, { className: "tw-flex tw-justify-between", children: [
91332
+ /* @__PURE__ */ jsx(Button, { variant: "outline", children: "Reset" }),
91333
+ /* @__PURE__ */ jsx(Button, { children: "Save Changes" })
91334
+ ] })
91335
+ ] }) });
91336
+ }
91337
+ function ServersView({ servers, selectedServer, onSelectServer, addServers }) {
91338
+ if (selectedServer) {
91339
+ return /* @__PURE__ */ jsx(ServerDetailView, { server: selectedServer, onAddServer: addServers });
91340
+ }
91341
+ return /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-flex-col tw-gap-4 tw-p-4 tw-w-full", children: [
91342
+ /* @__PURE__ */ jsx("h3", { className: "tw-text-xl tw-font-bold tw-mb-6", children: "MCP Servers" }),
91343
+ /* @__PURE__ */ jsxs("div", { className: "tw-w-full tw-grid tw-grid-cols-2 md:tw-grid-cols-3 lg:tw-grid-cols-4 tw-gap-4", children: [
91344
+ servers == null ? void 0 : servers.map((server) => /* @__PURE__ */ jsx(ServerCard, { server, onClick: () => onSelectServer(server) }, server.id)),
91345
+ servers.length === 0 && /* @__PURE__ */ jsxs("div", { className: "tw-w-full tw-col-span-full tw-text-center tw-py-12 tw-border tw-rounded-lg tw-border-dashed", children: [
91346
+ /* @__PURE__ */ jsx(Server, { className: "tw-h-12 tw-w-12 tw-mx-auto tw-mb-4 tw-text-muted-foreground" }),
91347
+ /* @__PURE__ */ jsx("h3", { className: "tw-text-md tw-font-medium", children: "No servers found" }),
91348
+ /* @__PURE__ */ jsx("p", { className: "tw-text-muted-foreground tw-mt-1", children: "Add a new server to get started" })
91349
+ ] })
91350
+ ] }),
91351
+ /* @__PURE__ */ jsx(AddServerView, { onAddServer: addServers, className: "tw-mt-4 tw-w-full" })
91352
+ ] });
91353
+ }
91354
+ function ServerHome({ mcpServers = [] }) {
91355
+ const [servers, setServers] = useState$1([]);
91356
+ const [selectedServer, setSelectedServer] = useState$1(null);
91357
+ const [searchQuery, setSearchQuery] = useState$1("");
91358
+ if (!servers) {
91359
+ return /* @__PURE__ */ jsx("div", { children: "Loading..." });
91360
+ }
91361
+ const addServers = useCallback(
91362
+ (server) => {
91363
+ setServers([...servers, server]);
91364
+ },
91365
+ [servers]
91366
+ );
91367
+ const filteredServers = useMemo$1(() => {
91368
+ if (mcpServers) {
91369
+ setServers(mcpServers);
91370
+ }
91371
+ return servers.filter(
91372
+ (server) => server.name.toLowerCase().includes(searchQuery.toLowerCase()) || server.type.toLowerCase().includes(searchQuery.toLowerCase())
91373
+ );
91374
+ }, [searchQuery, servers, mcpServers]);
91375
+ return /* @__PURE__ */ jsx("div", { className: "tw-flex tw-flex-col tw-gap-4 tw-flex-grow tw-overflow-y-scroll", children: /* @__PURE__ */ jsx("div", { className: "tw-flex tw-h-full tw-transition-all tw-duration-300 tw-flex-col", children: /* @__PURE__ */ jsxs("div", { className: cn("tw-flex-1 tw-overflow-auto"), children: [
91376
+ /* @__PURE__ */ jsx("div", { className: "tw-flex tw-items-center tw-p-6", children: /* @__PURE__ */ jsx("div", { className: "tw-w-full", children: /* @__PURE__ */ jsx("div", { className: "tw-flex tw-items-center tw-gap-4", children: /* @__PURE__ */ jsxs("div", { className: "tw-relative tw-w-full", children: [
91377
+ /* @__PURE__ */ jsx(Search, { className: "tw-absolute tw-left-2 tw-h-auto tw-w-2 tw-text-muted-foreground" }),
91378
+ /* @__PURE__ */ jsx(
91379
+ Input,
91380
+ {
91381
+ placeholder: "Search...",
91382
+ className: "tw-p-2 tw-h-9 tw-bg-muted/50 tw-border-none",
91383
+ value: searchQuery,
91384
+ onChange: (e2) => setSearchQuery(e2.target.value)
91385
+ }
91386
+ )
91387
+ ] }) }) }) }),
91388
+ /* @__PURE__ */ jsx(
91389
+ ServersView,
91390
+ {
91391
+ servers: filteredServers,
91392
+ selectedServer,
91393
+ onSelectServer: setSelectedServer,
91394
+ addServers
91395
+ }
91396
+ )
91397
+ ] }) }) });
91398
+ }
90658
91399
  const CodyPanel = ({
90659
91400
  view,
90660
91401
  setView,
@@ -90678,6 +91419,27 @@ const CodyPanel = ({
90678
91419
  const externalAPI = useExternalAPI();
90679
91420
  const api2 = useExtensionAPI();
90680
91421
  const { value: chatModels } = useObservable(useMemo$1(() => api2.chatModels(), [api2.chatModels]));
91422
+ const { value: mcpServers } = useObservable(
91423
+ useMemo$1(
91424
+ () => {
91425
+ var _a2;
91426
+ return (_a2 = api2.mcpSettings()) == null ? void 0 : _a2.map(
91427
+ (servers) => {
91428
+ var _a3;
91429
+ return (_a3 = servers || []) == null ? void 0 : _a3.map((s2) => ({
91430
+ id: s2.name,
91431
+ name: s2.name,
91432
+ tools: s2.tools,
91433
+ status: s2.status === "connected" ? "online" : "offline",
91434
+ icon: DatabaseBackup,
91435
+ type: "mcp"
91436
+ }));
91437
+ }
91438
+ );
91439
+ },
91440
+ [api2.mcpSettings]
91441
+ )
91442
+ );
90681
91443
  const isWorkspacesUpgradeCtaEnabled = useFeatureFlag(FeatureFlag.SourcegraphTeamsUpgradeCTA) && isDotComUser && ((_a = config.endpointHistory) == null ? void 0 : _a.length) === 1;
90682
91444
  useEffect$2(() => {
90683
91445
  onExternalApiReady == null ? void 0 : onExternalApiReady(externalAPI);
@@ -90740,13 +91502,17 @@ const CodyPanel = ({
90740
91502
  HistoryTab,
90741
91503
  {
90742
91504
  IDE: clientCapabilities.agentIDE,
91505
+ extensionAPI: api2,
90743
91506
  setView,
90744
91507
  webviewType: config.webviewType,
90745
91508
  multipleWebviewsEnabled: config.multipleWebviewsEnabled
90746
91509
  }
90747
91510
  ),
90748
91511
  view === View.Prompts && /* @__PURE__ */ jsx(PromptsTab, { IDE: clientCapabilities.agentIDE, setView }),
90749
- view === View.Settings && /* @__PURE__ */ jsx(SettingsTab, {})
91512
+ view === View.Settings && // NOTE: This is temporary to hide the MCP UI until it is implemented.
91513
+ // During internal dogfooding, users will be using the vscode config to set up
91514
+ // their servers.
91515
+ (mcpServers == null ? void 0 : mcpServers.length) !== -1 && (config == null ? void 0 : config.experimentalAgenticChatEnabled) && /* @__PURE__ */ jsx(ServerHome, { mcpServers })
90750
91516
  ] }),
90751
91517
  /* @__PURE__ */ jsx(StateDebugOverlay, {})
90752
91518
  ]
@@ -90918,14 +91684,20 @@ function releaseGlobalAgent() {
90918
91684
  }
90919
91685
  function useCodyWebAgent(input2) {
90920
91686
  const [agent2, setAgent] = useState$1(null);
90921
- if (!globalAgent) {
90922
- globalAgent = createCodyAgent(input2);
90923
- }
90924
91687
  useEffect$2(() => {
90925
- globalAgent == null ? void 0 : globalAgent.then(setAgent, setAgent);
91688
+ const createAndSetNewAgent = () => {
91689
+ globalAgent = createCodyAgent(input2);
91690
+ globalAgent.then(setAgent, setAgent);
91691
+ };
91692
+ if (globalAgent) {
91693
+ globalAgent.then((existingAgent) => existingAgent.client.dispose()).catch(() => {
91694
+ }).finally(createAndSetNewAgent);
91695
+ } else {
91696
+ createAndSetNewAgent();
91697
+ }
90926
91698
  retainGlobalAgent();
90927
91699
  return releaseGlobalAgent;
90928
- }, []);
91700
+ }, [input2.serverEndpoint, input2.accessToken, input2.telemetryClientName, input2.customHeaders]);
90929
91701
  return agent2;
90930
91702
  }
90931
91703
  async function createCodyAgent(input2) {
@@ -90972,6 +91744,14 @@ function createVSCodeAPI(input2) {
90972
91744
  postMessage: (message2) => {
90973
91745
  if (message2.command === "command" && message2.id === "cody.chat.new") {
90974
91746
  void createNewChat();
91747
+ for (const callback of onMessageCallbacks) {
91748
+ callback({
91749
+ type: "transcript",
91750
+ messages: [],
91751
+ isMessageInProgress: false,
91752
+ chatID: message2.id
91753
+ });
91754
+ }
90975
91755
  return;
90976
91756
  }
90977
91757
  void client.rpc.sendRequest("webview/receiveMessage", {
@@ -91531,6 +92311,6 @@ export {
91531
92311
  ChatSkeleton,
91532
92312
  CodyPromptTemplate,
91533
92313
  CodyWebChat,
91534
- aW as deserialize,
91535
- aV as serialize
92314
+ aY as deserialize,
92315
+ aX as serialize
91536
92316
  };