@sourcegraph/cody-web 0.23.0 → 0.24.0

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.
@@ -18,9 +18,9 @@ var __privateWrapper = (obj, member, setter2, getter) => ({
18
18
  }
19
19
  });
20
20
  var _a2, _b, _constructing, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn, moveToTail_fn, _c, _d, _e, _f, _g, _h, _constructing2, _i, _j, _max2, _maxSize2, _dispose2, _disposeAfter2, _fetchMethod2, _size2, _calculatedSize2, _keyMap2, _keyList2, _valList2, _next2, _prev2, _head2, _tail2, _free2, _disposed2, _sizes2, _starts2, _ttls2, _hasDispose2, _hasFetchMethod2, _hasDisposeAfter2, _LRUCache_instances2, initializeTTLTracking_fn2, _updateItemAge2, _statusTTL2, _setItemTTL2, _isStale2, initializeSizeTracking_fn2, _removeItemSize2, _addItemSize2, _requireSize2, indexes_fn2, rindexes_fn2, isValidIndex_fn2, evict_fn2, backgroundFetch_fn2, isBackgroundFetch_fn2, connect_fn2, moveToTail_fn2, _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
21
- import { aS as Observable, bZ as unsubscribe, b_ as AsyncSerialScheduler, b$ as authStatus, c0 as debounceTime, c1 as switchMapReplayOperation, c2 as interval, c3 as map$1, c4 as filter$3, c5 as startWith$1, c6 as switchMap$1, c7 as promiseFactoryToObservable, bg as isError$3, c8 as distinctUntilChanged$1, bG as firstValueFrom$1, bH as skipPendingOperation, c9 as logDebug$1, ca as graphqlClient, cb as isAbortError, cc as logError$2, cd as semver, ce as pendingOperation, cf as pick, bq as ModelTag, cg as getModelInfo, bQ as CHAT_INPUT_TOKEN_BUDGET, ch as CHAT_OUTPUT_TOKEN_BUDGET, ci as EXTENDED_CHAT_INPUT_TOKEN_BUDGET, cj as EXTENDED_USER_CONTEXT_TOKEN_BUDGET, ck as createSubscriber, cl as fromVSCodeEvent, aZ as isEqual, cm as cenv, b5 as isDotCom, cn as currentAuthStatus, co as isFileURI, w as wrapInActiveSpan, cp as INCLUDE_EVERYTHING_CONTEXT_FILTERS, cq as EXCLUDE_EVERYTHING_CONTEXT_FILTERS, cr as onAbort, cs as addCodyClientIdentificationHeaders, ct as addAuthHeaders, cu as addTraceparent, cv as fetch$3, cw as verifyResponseCode, cx as combineLatest$1, cy as take$2, cz as clientCapabilities, cA as shareReplay$1, cB as tap$2, cC as featureFlagProvider, ba as FeatureFlag, cD as getEnterpriseContextWindow, cE as ANSWER_TOKENS, cF as storeLastValue, cG as resolvedConfig, cH as userProductSubscription, bB as firstResultFromOperation, cI as isEnterpriseUser, bc as isCodyProUser, p as ps, cJ as currentResolvedConfig, bV as PromptString, bd as CodyIDE, cK as isCustomModel, cL as recordErrorToSpan, cM as addClientInfoParams, cN as dependentAbortController, am as FILE_CONTEXT_MENTION_PROVIDER, an as SYMBOL_CONTEXT_MENTION_PROVIDER, ao as REMOTE_REPOSITORY_PROVIDER_URI, ap as REMOTE_FILE_PROVIDER_URI, aq as REMOTE_DIRECTORY_PROVIDER_URI, ar as WEB_PROVIDER_URI, t as telemetryRecorder, C as ContextItemSource, bl as lodashExports, cO as truncatePromptString, cP as isS2, cQ as GIT_OPENCTX_PROVIDER_URI, bf as cryptoJsExports, cR as openCtx, aF as URI, cS as MulticastSubject, cT as AsyncSerialScheduler_1, g as getDefaultExportFromCjs, cU as Utils$1, cV as toString_1, cW as upperFirst_1, cX as _, cY as extensionForLanguage, cZ as setClientNameVersion, c_ as base64Js, c as commonjsGlobal, c$ as _baseAssignValue, d0 as eq_1, d1 as isArrayLike_1, d2 as isObjectLike_1, d3 as _copyObject, d4 as keysIn_1, d5 as _cloneBufferExports, d6 as _cloneTypedArray, d7 as _copyArray, d8 as _initCloneObject, d9 as isArguments_1, da as isArray_1, db as isBufferExports, dc as isFunction_1, dd as isObject_1, de as isPlainObject_1, df as isTypedArray_1, dg as _Stack, dh as identity_1, di as _overRest, dj as _setToString, dk as _isIndex, b6 as isSourcegraphToken, bT as CodyAutoSuggestionMode, dl as setExtensionVersion, dm as withLatestFrom, dn as NEVER, dp as abortableOperation, dq as disposableSubscription, dr as setAuthStatusObservable, ds as DOTCOM_URL, dt as normalizeServerEndpointURL, du as SourcegraphGraphQLAPIClient, dv as isNetworkLikeError, dw as resolveAuth, dx as getAuthErrorMessage, dy as SUPPORTED_URI_SCHEMAS, dz as _baseIsEqual, dA as keys_1, dB as _baseGet, dC as _castPath, dD as isLength_1, dE as _toKey, dF as _isKey, dG as toNumber_1, dH as _baseFindIndex, dI as require$$1$4, dJ as NetworkError, dK as isRateLimitError, dL as isAuthError, d as dedent$1, dM as convertGitCloneURLToCodebaseName, bj as isDefined, dN as pluck, dO as TokenCounterUtils, dP as toRangeData, dQ as DefaultChatCommands, dR as pathFunctionsForURI, dS as uriParseNameAndExtension, dT as uriDirname, dU as uriExtname, dV as uriBasename, dW as DefaultEditCommands, dX as subscriptionDisposable, dY as NoOpTelemetryRecorderProvider, dZ as TimestampTelemetryProcessor_1, d_ as updateGlobalTelemetryInstances, d$ as TelemetryRecorderProvider, e0 as telemetryRecorderProvider, e1 as createGitDiff, e2 as catchError$1, e3 as omit$1, e4 as displayPathWithoutWorkspaceFolderPrefix, e5 as getEditorInsertSpaces, e6 as escapeRegExp$1, e7 as isNetworkError, bx as isCodyProModel, e8 as http, be as CodyTaskState, aT as createExtensionAPI, aU as createMessageAPIForWebview, e9 as getAugmentedNamespace, ea as main$1, eb as firstNonPendingAuthStatus, ec as TESTING_TELEMETRY_EXPORTER, ed as dist, ee as checkIfEnterpriseUser, ef as currentAuthStatusAuthed, eg as waitUntilComplete, bA as isMacOS, bv as CustomCommandType, bW as setDisplayPathEnvInfo, eh as isWindows, ei as currentAuthStatusOrNotReadyYet, ej as currentUserProductSubscription, bD as ACCOUNT_USAGE_URL, aV as debounce$1, as as displayPath, ek as structuredPatch, el as isDotComAuthed, em as dedupeWith$1, en as AbortError, eo as TimeoutError, ep as createDisposables, eq as getClientInfoQueryParams, er as tracer, es as getClientIdentificationHeaders, et as logResponseHeadersToSpan, eu as getActiveTraceAndSpanId, ev as TracedError, ew as isNodeResponse, b9 as SpanStatusCode, bh as RateLimitError$2, ex as createTwoFilesPatch, ey as getEditorTabSize$1, ez as isFreeUser, eA as _baseGetTag, eB as truncateTextNearestLine, eC as MAX_BYTES_PER_FILE, eD as debounce_1, bU as isErrorLike, eE as TokenCounter, eF as mentionProvidersMetadata, eG as expandToLineRange, av as displayPathBasename, at as displayLineRange, aP as parseMentionQuery, eH as openCtxProviderMetadata, eI as editorStateFromPromptString, eJ as getTokenCounterUtils, eK as inputTextWithoutContextChipsFromPromptEditorState, bp as isAbortErrorOrSocketHangUp, eL as PromptMode, eM as skip$1, b8 as context$1, eN as extractContextFromTraceparent, bK as inputTextWithMappedContextChipsFromPromptEditorState, eO as isContextWindowLimitError, b3 as forceHydration, bo as reformatBotMessageForChat, b4 as hydrateAfterPostMessage, eP as addMessageListenersForExtensionAPI, eQ as createMessageAPIForExtension, bw as View, eR as CODY_BLOG_URL_o1_WAITLIST, eS as CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID, bu as pluralize, eT as assertFileURI, eU as setOpenCtx, eV as createCodeSearchProvider, eW as CODE_SEARCH_PROVIDER_URI, eX as psDedent, eY as languageFromFilename, eZ as ProgrammingLanguage, e_ as truncatePromptStringStart, e$ as MAX_CURRENT_FILE_TOKENS, f0 as posixFilePaths, f1 as SURROUNDING_LINES, f2 as ACCOUNT_UPGRADE_URL, a_ as scanForMentionTriggerInUserTextInput, ax as LARGE_FILE_WARNING_LABEL, f3 as GENERAL_HELP_LABEL, f4 as diffLines, f5 as CODY_SUPPORT_URL, f6 as CODY_DOC_URL, bi as CODY_FEEDBACK_URL, f7 as DISCORD_URL, bz as getRelativeChatPeriod, f8 as globalAgentRef, f9 as VSCODE_CHANGELOG_URL, fa as SG_CHANGELOG_URL, fb as ACCOUNT_LIMITS_INFO_URL, fc as assertUnreachable, fd as promise, fe as setLogger, ff as setClientCapabilities, fg as setResolvedConfigurationObservable, fh as CODY_OLLAMA_DOCS_URL, bS as browser$3 } from "./browser-mfOl2gpJ.mjs";
21
+ import { aS as Observable, bZ as unsubscribe, b_ as AsyncSerialScheduler, b$ as MulticastSubject, bF as firstValueFrom$1, bH as skipPendingOperation, c0 as authStatus, c1 as debounceTime, c2 as switchMapReplayOperation, c3 as interval, c4 as map$1, c5 as filter$3, c6 as startWith$1, c7 as switchMap$1, c8 as promiseFactoryToObservable, bg as isError$3, c9 as distinctUntilChanged$1, ca as logDebug$1, cb as graphqlClient, cc as isAbortError, cd as logError$2, ce as semver, cf as pendingOperation, cg as pick, bq as ModelTag, ch as getModelInfo, bQ as CHAT_INPUT_TOKEN_BUDGET, ci as CHAT_OUTPUT_TOKEN_BUDGET, cj as EXTENDED_CHAT_INPUT_TOKEN_BUDGET, ck as EXTENDED_USER_CONTEXT_TOKEN_BUDGET, cl as createSubscriber, cm as fromVSCodeEvent, aZ as isEqual, cn as cenv, b5 as isDotCom, co as currentAuthStatus, cp as isFileURI, w as wrapInActiveSpan, cq as INCLUDE_EVERYTHING_CONTEXT_FILTERS, cr as EXCLUDE_EVERYTHING_CONTEXT_FILTERS, cs as onAbort, ct as addCodyClientIdentificationHeaders, cu as addTraceparent, cv as addAuthHeaders, cw as fetch$3, cx as verifyResponseCode, cy as combineLatest$1, cz as take$2, cA as clientCapabilities, cB as shareReplay$1, cC as tap$2, cD as featureFlagProvider, ba as FeatureFlag, cE as getEnterpriseContextWindow, cF as ANSWER_TOKENS, cG as storeLastValue, cH as resolvedConfig, cI as userProductSubscription, bB as firstResultFromOperation, cJ as isEnterpriseUser, bc as isCodyProUser, p as ps, cK as currentResolvedConfig, bV as PromptString, bd as CodyIDE, cL as isCustomModel, cM as recordErrorToSpan, cN as addClientInfoParams, cO as dependentAbortController, am as FILE_CONTEXT_MENTION_PROVIDER, an as SYMBOL_CONTEXT_MENTION_PROVIDER, ao as REMOTE_REPOSITORY_PROVIDER_URI, ap as REMOTE_FILE_PROVIDER_URI, aq as REMOTE_DIRECTORY_PROVIDER_URI, ar as WEB_PROVIDER_URI, t as telemetryRecorder, C as ContextItemSource, bl as lodashExports, cP as truncatePromptString, cQ as isS2, cR as GIT_OPENCTX_PROVIDER_URI, bf as cryptoJsExports, cS as openCtx, aF as URI, cT as AsyncSerialScheduler_1, g as getDefaultExportFromCjs, cU as Utils$1, cV as toString_1, cW as upperFirst_1, cX as _, cY as extensionForLanguage, cZ as setClientNameVersion, c_ as base64Js, c as commonjsGlobal, c$ as _baseAssignValue, d0 as eq_1, d1 as isArrayLike_1, d2 as isObjectLike_1, d3 as _copyObject, d4 as keysIn_1, d5 as _cloneBufferExports, d6 as _cloneTypedArray, d7 as _copyArray, d8 as _initCloneObject, d9 as isArguments_1, da as isArray_1, db as isBufferExports, dc as isFunction_1, dd as isObject_1, de as isPlainObject_1, df as isTypedArray_1, dg as _Stack, dh as identity_1, di as _overRest, dj as _setToString, dk as _isIndex, b6 as isSourcegraphToken, bT as CodyAutoSuggestionMode, dl as setExtensionVersion, dm as withLatestFrom, dn as NEVER, dp as abortableOperation, dq as disposableSubscription, dr as setAuthStatusObservable, ds as DOTCOM_URL, dt as normalizeServerEndpointURL, du as SourcegraphGraphQLAPIClient, dv as isExternalProviderAuthError, dw as isNetworkLikeError, dx as resolveAuth, dy as getAuthErrorMessage, dz as isWorkspaceInstance, dA as SUPPORTED_URI_SCHEMAS, dB as _baseIsEqual, dC as keys_1, dD as _baseGet, dE as _castPath, dF as isLength_1, dG as _toKey, dH as _isKey, dI as toNumber_1, dJ as _baseFindIndex, dK as require$$1$4, dL as NetworkError, dM as isRateLimitError, dN as isAuthError, d as dedent$1, dO as convertGitCloneURLToCodebaseName, bj as isDefined, dP as pluck, dQ as TokenCounterUtils, dR as toRangeData, dS as DefaultChatCommands, dT as pathFunctionsForURI, dU as uriParseNameAndExtension, dV as uriDirname, dW as uriExtname, dX as uriBasename, dY as DefaultEditCommands, dZ as subscriptionDisposable, d_ as NoOpTelemetryRecorderProvider, d$ as TimestampTelemetryProcessor_1, e0 as updateGlobalTelemetryInstances, e1 as TelemetryRecorderProvider, e2 as telemetryRecorderProvider, e3 as createGitDiff, e4 as catchError$1, e5 as omit$1, e6 as displayPathWithoutWorkspaceFolderPrefix, e7 as getEditorInsertSpaces, e8 as escapeRegExp$1, e9 as isNetworkError, bx as isCodyProModel, ea as http, be as CodyTaskState, aT as createExtensionAPI, aU as createMessageAPIForWebview, eb as getAugmentedNamespace, ec as main$1, ed as firstNonPendingAuthStatus, ee as TESTING_TELEMETRY_EXPORTER, ef as dist, eg as checkIfEnterpriseUser, eh as currentAuthStatusAuthed, ei as waitUntilComplete, bA as isMacOS, bv as CustomCommandType, bW as setDisplayPathEnvInfo, ej as isWindows, ek as currentAuthStatusOrNotReadyYet, el as currentUserProductSubscription, bD as ACCOUNT_USAGE_URL, aV as debounce$1, as as displayPath, em as structuredPatch, en as isDotComAuthed, eo as dedupeWith$1, ep as AbortError, eq as TimeoutError, er as createDisposables, es as getClientInfoQueryParams, et as tracer, eu as getClientIdentificationHeaders, ev as logResponseHeadersToSpan, ew as getActiveTraceAndSpanId, ex as TracedError, ey as isNodeResponse, b9 as SpanStatusCode, bh as RateLimitError$2, ez as createTwoFilesPatch, eA as getEditorTabSize$1, eB as isFreeUser, eC as _baseGetTag, eD as truncateTextNearestLine, eE as MAX_BYTES_PER_FILE, eF as debounce_1, bU as isErrorLike, eG as TokenCounter, eH as mentionProvidersMetadata, eI as expandToLineRange, av as displayPathBasename, at as displayLineRange, aP as parseMentionQuery, eJ as openCtxProviderMetadata, eK as editorStateFromPromptString, eL as getTokenCounterUtils, eM as inputTextWithoutContextChipsFromPromptEditorState, bp as isAbortErrorOrSocketHangUp, eN as PromptMode, eO as skip$1, b8 as context$1, eP as extractContextFromTraceparent, bK as inputTextWithMappedContextChipsFromPromptEditorState, eQ as isContextWindowLimitError, b3 as forceHydration, bo as reformatBotMessageForChat, b4 as hydrateAfterPostMessage, eR as addMessageListenersForExtensionAPI, eS as createMessageAPIForExtension, bw as View, eT as CODY_BLOG_URL_o1_WAITLIST, eU as CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID, bu as pluralize, eV as assertFileURI, eW as setOpenCtx, eX as createCodeSearchProvider, eY as CODE_SEARCH_PROVIDER_URI, eZ as psDedent, e_ as languageFromFilename, e$ as ProgrammingLanguage, f0 as truncatePromptStringStart, f1 as MAX_CURRENT_FILE_TOKENS, f2 as posixFilePaths, f3 as SURROUNDING_LINES, f4 as ACCOUNT_UPGRADE_URL, a_ as scanForMentionTriggerInUserTextInput, ax as LARGE_FILE_WARNING_LABEL, f5 as GENERAL_HELP_LABEL, f6 as diffLines, f7 as CODY_SUPPORT_URL, f8 as CODY_DOC_URL, bi as CODY_FEEDBACK_URL, f9 as DISCORD_URL, bz as getRelativeChatPeriod, fa as globalAgentRef, fb as VSCODE_CHANGELOG_URL, fc as SG_CHANGELOG_URL, fd as ACCOUNT_LIMITS_INFO_URL, fe as assertUnreachable, ff as promise, fg as setLogger, fh as setClientCapabilities, fi as setResolvedConfigurationObservable, fj as CODY_OLLAMA_DOCS_URL, bS as browser$3 } from "./browser-DRpAM7mB.mjs";
22
22
  import { execSync, exec } from "./child_process-C6OZyNb4.mjs";
23
- import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-B6KeX3WC.mjs";
23
+ import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-DeyYSaNB.mjs";
24
24
  var NOTHING = Symbol.for("immer-nothing");
25
25
  var DRAFTABLE = Symbol.for("immer-draftable");
26
26
  var DRAFT_STATE = Symbol.for("immer-state");
@@ -698,6 +698,35 @@ function filter$2(test) {
698
698
  });
699
699
  };
700
700
  }
701
+ function merge$2(...observables) {
702
+ if (observables.length === 0) {
703
+ return Observable.from([]);
704
+ }
705
+ return new Observable((observer) => {
706
+ let completed = 0;
707
+ const subscriptions = observables.map((input) => {
708
+ return input.subscribe({
709
+ error(error) {
710
+ observer.error(error);
711
+ unsubscribeAll();
712
+ },
713
+ next(value) {
714
+ observer.next(value);
715
+ },
716
+ complete() {
717
+ if (++completed === observables.length) {
718
+ observer.complete();
719
+ unsubscribeAll();
720
+ }
721
+ }
722
+ });
723
+ });
724
+ const unsubscribeAll = () => {
725
+ subscriptions.forEach((subscription) => unsubscribe(subscription));
726
+ };
727
+ return unsubscribeAll;
728
+ });
729
+ }
701
730
  var define_process_default$p = { env: {} };
702
731
  let _editorWindowIsFocused;
703
732
  function setEditorWindowIsFocused(editorWindowIsFocused2) {
@@ -723,11 +752,15 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
723
752
  commands: true,
724
753
  attribution: false
725
754
  });
755
+ __publicField2(this, "forceUpdateSubject", new MulticastSubject());
726
756
  /**
727
757
  * An observable that immediately emits the last-cached value (or fetches it if needed) and then
728
758
  * emits changes.
729
759
  */
730
- __publicField2(this, "changes", authStatus.pipe(
760
+ __publicField2(this, "changes", merge$2(
761
+ authStatus,
762
+ this.forceUpdateSubject
763
+ ).pipe(
731
764
  debounceTime(0),
732
765
  // wait a tick for graphqlClient's auth to be updated
733
766
  switchMapReplayOperation(
@@ -750,6 +783,17 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
750
783
  distinctUntilChanged$1()
751
784
  ));
752
785
  }
786
+ /**
787
+ * Forces an immediate update of the client configuration by triggering a new fetch.
788
+ * This method is called when temporary settings are edited from the client to ensure
789
+ * the configuration is immediately synchronized with the latest changes.
790
+ *
791
+ * @returns A promise that resolves to the updated CodyClientConfig or undefined
792
+ */
793
+ async forceUpdate() {
794
+ this.forceUpdateSubject.next(true);
795
+ return firstValueFrom$1(this.changes.pipe(skipPendingOperation()));
796
+ }
753
797
  // Static method to get the singleton instance
754
798
  static getInstance() {
755
799
  if (!_ClientConfigSingleton.instance) {
@@ -798,23 +842,33 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
798
842
  }).then((clientConfig) => {
799
843
  signal2 == null ? void 0 : signal2.throwIfAborted();
800
844
  logDebug$1("ClientConfigSingleton", "refreshed", JSON.stringify(clientConfig));
801
- return graphqlClient.viewerSettings(signal2).then((viewerSettings) => {
802
- if (isError$3(viewerSettings)) {
803
- return { ...clientConfig, notices: [] };
804
- }
805
- return {
845
+ return Promise.all([
846
+ graphqlClient.viewerSettings(signal2),
847
+ graphqlClient.temporarySettings(signal2)
848
+ ]).then(([viewerSettings, temporarySettings]) => {
849
+ const config = {
806
850
  ...clientConfig,
807
- // Make sure that notice object will have all important field (notices come from
808
- // instance global JSONC configuration so they can have any arbitrary field values.
809
- notices: Array.from(
851
+ intentDetection: "enabled",
852
+ notices: [],
853
+ temporarySettings: {}
854
+ };
855
+ if (!isError$3(viewerSettings)) {
856
+ config.intentDetection = ["disabled", "enabled", "opt-in"].includes(
857
+ viewerSettings["omnibox.intentDetection"]
858
+ ) ? viewerSettings["omnibox.intentDetection"] : "enabled";
859
+ config.notices = Array.from(
810
860
  viewerSettings["cody.notices"] ?? [],
811
861
  (notice, index2) => ({
812
862
  key: (notice == null ? void 0 : notice.key) ?? index2.toString(),
813
863
  title: (notice == null ? void 0 : notice.title) ?? "",
814
864
  message: (notice == null ? void 0 : notice.message) ?? ""
815
865
  })
816
- )
817
- };
866
+ );
867
+ }
868
+ if (!isError$3(temporarySettings)) {
869
+ config.temporarySettings = temporarySettings;
870
+ }
871
+ return config;
818
872
  });
819
873
  }).catch((e) => {
820
874
  if (!isAbortError(e)) {
@@ -835,9 +889,11 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
835
889
  attributionEnabled: features2.attribution,
836
890
  smartContextWindowEnabled: smartContextWindow,
837
891
  // Things that did not exist before logically default to disabled.
892
+ intentDetection: "disabled",
838
893
  modelsAPIEnabled: false,
839
894
  userShouldUseEnterprise: false,
840
- notices: []
895
+ notices: [],
896
+ temporarySettings: {}
841
897
  };
842
898
  }
843
899
  // Fetches the config features from the server and handles errors, using the old/legacy GraphQL API.
@@ -7957,14 +8013,18 @@ class RestClient {
7957
8013
  }
7958
8014
  // Make an authenticated HTTP request to the Sourcegraph instance.
7959
8015
  // "name" is a developer-friendly term to label the request's trace span.
7960
- getRequest(name2, urlSuffix, signal2) {
8016
+ async getRequest(name2, urlSuffix, signal2) {
7961
8017
  const headers = new Headers(this.customHeaders);
7962
8018
  const endpoint = new URL(this.auth.serverEndpoint);
7963
8019
  endpoint.pathname = urlSuffix;
7964
8020
  const url = endpoint.href;
7965
8021
  addCodyClientIdentificationHeaders(headers);
7966
- addAuthHeaders(this.auth, headers, endpoint);
7967
8022
  addTraceparent(headers);
8023
+ try {
8024
+ await addAuthHeaders(this.auth, headers, endpoint);
8025
+ } catch (error) {
8026
+ return error;
8027
+ }
7968
8028
  return wrapInActiveSpan(
7969
8029
  `rest-api.${name2}`,
7970
8030
  () => fetch$3(url, {
@@ -11406,8 +11466,15 @@ class SourcegraphBrowserCompletionsClient extends SourcegraphCompletionsClient {
11406
11466
  ...requestParams.customHeaders
11407
11467
  });
11408
11468
  addCodyClientIdentificationHeaders(headersInstance);
11409
- addAuthHeaders(config.auth, headersInstance, url);
11410
11469
  headersInstance.set("Content-Type", "application/json; charset=utf-8");
11470
+ try {
11471
+ await addAuthHeaders(config.auth, headersInstance, url);
11472
+ } catch (error) {
11473
+ cb.onError(error.message);
11474
+ abort2.abort();
11475
+ console.error(error);
11476
+ return;
11477
+ }
11411
11478
  const parameters = new URLSearchParams(globalThis.location.search);
11412
11479
  const trace = parameters.get("trace");
11413
11480
  if (trace) {
@@ -11485,11 +11552,11 @@ class SourcegraphBrowserCompletionsClient extends SourcegraphCompletionsClient {
11485
11552
  ...requestParams.customHeaders
11486
11553
  });
11487
11554
  addCodyClientIdentificationHeaders(headersInstance);
11488
- addAuthHeaders(auth, headersInstance, url);
11489
11555
  if (new URLSearchParams(globalThis.location.search).get("trace")) {
11490
11556
  headersInstance.set("X-Sourcegraph-Should-Trace", "true");
11491
11557
  }
11492
11558
  try {
11559
+ await addAuthHeaders(auth, headersInstance, url);
11493
11560
  const response = await fetch(url.toString(), {
11494
11561
  method: "POST",
11495
11562
  headers: headersInstance,
@@ -11687,19 +11754,20 @@ const events$2 = [
11687
11754
  metadata: pickDefined({
11688
11755
  userSpecifiedIntent: params.userSpecifiedIntent ? map2.intent(params.userSpecifiedIntent) : void 0,
11689
11756
  detectedIntent: params.detectedIntent ? map2.intent(params.detectedIntent) : void 0,
11757
+ // Each intent is mapped to a `detectedIntentScores.{intent}` field inside the metadata
11758
+ ...(_a3 = params.detectedIntentScores) == null ? void 0 : _a3.reduce(
11759
+ (scores, intentScore) => {
11760
+ scores["detectedIntentScores." + intentScore.intent] = intentScore.score;
11761
+ return scores;
11762
+ },
11763
+ {}
11764
+ ),
11690
11765
  // TODO: Remove this field when the transition from commands to prompts is complete
11691
11766
  isCommand: params.command ? 1 : 0,
11692
11767
  ...metadata2,
11693
11768
  recordsPrivateMetadataTranscript: recordTranscript ? 1 : 0
11694
11769
  }),
11695
11770
  privateMetadata: {
11696
- detectedIntentScores: ((_a3 = params.detectedIntentScores) == null ? void 0 : _a3.length) ? params.detectedIntentScores.reduce(
11697
- (scores, value) => {
11698
- scores[value.intent] = value.score;
11699
- return scores;
11700
- },
11701
- {}
11702
- ) : void 0,
11703
11771
  detectedIntent: params.detectedIntent,
11704
11772
  // TODO: Remove this field when the transition from commands to prompts is complete
11705
11773
  command: params.command,
@@ -11725,6 +11793,8 @@ const events$2 = [
11725
11793
  },
11726
11794
  {
11727
11795
  intent: {
11796
+ // This mapping must remain stable to avoid breaking the telemetry data.
11797
+ // Do not remove intents without putting in a placeholder.
11728
11798
  [fallbackValue]: 0,
11729
11799
  auto: 1,
11730
11800
  chat: 2,
@@ -11734,13 +11804,6 @@ const events$2 = [
11734
11804
  }
11735
11805
  }
11736
11806
  )
11737
- // //TODO
11738
- // event(
11739
- // 'cody.chat-question/response',
11740
- // ({ feature, action }) =>
11741
- // () => {},
11742
- // {}
11743
- // ),
11744
11807
  ];
11745
11808
  function publicContextSummary(globalPrefix, context2) {
11746
11809
  const global2 = lodashExports.cloneDeep(defaultSharedItemCount);
@@ -19058,6 +19121,7 @@ const dependencies = {
19058
19121
  "@radix-ui/react-popover": "^1.0.7",
19059
19122
  "@radix-ui/react-progress": "^1.1.0",
19060
19123
  "@radix-ui/react-slot": "^1.0.2",
19124
+ "@radix-ui/react-switch": "^1.1.2",
19061
19125
  "@radix-ui/react-tabs": "^1.1.0",
19062
19126
  "@radix-ui/react-tooltip": "^1.0.7",
19063
19127
  "@sentry/browser": "^7.107.0",
@@ -28639,6 +28703,21 @@ function closeAuthProgressIndicator() {
28639
28703
  runningAuthProgressIndicator == null ? void 0 : runningAuthProgressIndicator();
28640
28704
  runningAuthProgressIndicator = null;
28641
28705
  }
28706
+ async function showEnterpriseInstanceUrlFlow(endpoint) {
28707
+ const { configuration: configuration2 } = await currentResolvedConfig();
28708
+ const auth = await resolveAuth(endpoint, configuration2, secretStorage);
28709
+ const authStatus2 = await authProvider.validateAndStoreCredentials(auth, "store-if-valid");
28710
+ if (!(authStatus2 == null ? void 0 : authStatus2.authenticated)) {
28711
+ const instanceUrl = await showInstanceURLInputBox(endpoint);
28712
+ if (!instanceUrl) {
28713
+ return;
28714
+ }
28715
+ authProvider.setAuthPendingToEndpoint(instanceUrl);
28716
+ redirectToEndpointLogin(instanceUrl);
28717
+ } else {
28718
+ await showAuthResultMessage(endpoint, authStatus2);
28719
+ }
28720
+ }
28642
28721
  async function showSignInMenu(type, uri) {
28643
28722
  const authStatus2 = currentAuthStatus();
28644
28723
  const mode = authStatus2.authenticated ? "switch" : "signin";
@@ -28718,12 +28797,12 @@ async function showAuthMenu(type) {
28718
28797
  ];
28719
28798
  return window$1.showQuickPick(optionItems, AuthMenuOptions[type]);
28720
28799
  }
28721
- async function showInstanceURLInputBox(title) {
28800
+ async function showInstanceURLInputBox(url) {
28722
28801
  const result = await window$1.showInputBox({
28723
- title,
28802
+ title: "Connect to a Sourcegraph instance",
28724
28803
  prompt: "Enter the URL of the Sourcegraph instance. For example, https://sourcegraph.example.com.",
28725
28804
  placeHolder: "https://sourcegraph.example.com",
28726
- value: "https://",
28805
+ value: url ?? "https://",
28727
28806
  password: false,
28728
28807
  ignoreFocusOut: true,
28729
28808
  // valide input to ensure the user is not entering a token as URL
@@ -28850,6 +28929,12 @@ async function tokenCallbackHandler(uri) {
28850
28929
  const params = new URLSearchParams(uri.query);
28851
28930
  const token = params.get("code") || params.get("token");
28852
28931
  const endpoint = currentAuthStatus().endpoint;
28932
+ const instanceHost = params.get("instance");
28933
+ const instanceUrl = instanceHost ? new URL(instanceHost).origin : void 0;
28934
+ if (instanceUrl && isWorkspaceInstance(instanceUrl)) {
28935
+ await showEnterpriseInstanceUrlFlow(instanceUrl);
28936
+ return;
28937
+ }
28853
28938
  if (!token || !endpoint) {
28854
28939
  return;
28855
28940
  }
@@ -28928,7 +29013,6 @@ async function validateCredentials(config, signal2, clientConfig) {
28928
29013
  pendingValidation: false,
28929
29014
  error: {
28930
29015
  type: "auth-config-error",
28931
- title: "Auth config error",
28932
29016
  message: ((_a3 = config.auth.error) == null ? void 0 : _a3.message) ?? config.auth.error
28933
29017
  }
28934
29018
  };
@@ -28949,18 +29033,29 @@ async function validateCredentials(config, signal2, clientConfig) {
28949
29033
  try {
28950
29034
  const userInfo = await client.getCurrentUserInfo(signal2);
28951
29035
  signal2 == null ? void 0 : signal2.throwIfAborted();
28952
- if (isError$3(userInfo) && isNetworkLikeError(userInfo)) {
28953
- logDebug(
28954
- "auth",
28955
- `Failed to authenticate to ${config.auth.serverEndpoint} due to likely network error`,
28956
- userInfo.message
28957
- );
28958
- return {
28959
- authenticated: false,
28960
- error: { type: "network-error" },
28961
- endpoint: config.auth.serverEndpoint,
28962
- pendingValidation: false
28963
- };
29036
+ if (isError$3(userInfo)) {
29037
+ if (isExternalProviderAuthError(userInfo)) {
29038
+ logDebug("auth", userInfo.message);
29039
+ return {
29040
+ authenticated: false,
29041
+ error: { type: "external-auth-provider-error", message: userInfo.message },
29042
+ endpoint: config.auth.serverEndpoint,
29043
+ pendingValidation: false
29044
+ };
29045
+ }
29046
+ if (isNetworkLikeError(userInfo)) {
29047
+ logDebug(
29048
+ "auth",
29049
+ `Failed to authenticate to ${config.auth.serverEndpoint} due to likely network error`,
29050
+ userInfo.message
29051
+ );
29052
+ return {
29053
+ authenticated: false,
29054
+ error: { type: "network-error" },
29055
+ endpoint: config.auth.serverEndpoint,
29056
+ pendingValidation: false
29057
+ };
29058
+ }
28964
29059
  }
28965
29060
  if (!userInfo || isError$3(userInfo)) {
28966
29061
  logDebug(
@@ -39551,7 +39646,7 @@ class UpstreamHealthProvider {
39551
39646
  addCodyClientIdentificationHeaders(sharedHeaders);
39552
39647
  const url = new URL("/healthz", auth.serverEndpoint);
39553
39648
  const upstreamHeaders = new Headers(sharedHeaders);
39554
- addAuthHeaders(auth, upstreamHeaders, url);
39649
+ await addAuthHeaders(auth, upstreamHeaders, url);
39555
39650
  const upstreamResult = await wrapInActiveSpan("upstream-latency.upstream", (span2) => {
39556
39651
  span2.setAttribute("sampled", true);
39557
39652
  return measureLatencyToUri(upstreamHeaders, url.toString());
@@ -40030,84 +40125,93 @@ function getLinesContext(params) {
40030
40125
  nextNonEmptyLine
40031
40126
  };
40032
40127
  }
40128
+ const completionsOutputChannelLogger = new Logger("Completions");
40033
40129
  const autocompleteOutputChannelLogger = new Logger("Autocomplete");
40034
- const autocompleteLifecycleOutputChannelLogger = {
40035
- startCompletion(params, endpoint) {
40036
- const outputChannelId = v4();
40037
- const start2 = Date.now();
40038
- const shouldLogFullPrompt = workspace.getConfiguration().get("cody.autocomplete.logFullPrompt", false);
40039
- let hasFinished = false;
40040
- let lastCompletion = "";
40041
- function onError(err2, rawError) {
40042
- if (hasFinished) {
40043
- return;
40044
- }
40045
- hasFinished = true;
40046
- const duration = Date.now() - start2;
40047
- autocompleteOutputChannelLogger.logError(
40048
- "onError",
40049
- `duration:"${duration}ms" endpoint:"${endpoint}" outputChannelId:"${outputChannelId}"`,
40050
- JSON.stringify({
40051
- outputChannelId,
40052
- duration: Date.now() - start2,
40053
- err: err2
40054
- }),
40055
- { verbose: { params } }
40056
- );
40057
- }
40058
- function onComplete({ completion, stopReason }) {
40059
- if (hasFinished) {
40060
- return;
40130
+ function createCompletionLogger(logger2) {
40131
+ return {
40132
+ startCompletion(params, endpoint) {
40133
+ const outputChannelId = v4();
40134
+ const start2 = Date.now();
40135
+ const shouldLogFullPrompt = workspace.getConfiguration().get("cody.autocomplete.logFullPrompt", false);
40136
+ let hasFinished = false;
40137
+ let lastCompletion = "";
40138
+ function onError(err2, rawError) {
40139
+ if (hasFinished) {
40140
+ return;
40141
+ }
40142
+ hasFinished = true;
40143
+ const duration = Date.now() - start2;
40144
+ logger2.logError(
40145
+ "onError",
40146
+ `duration:"${duration}ms" endpoint:"${endpoint}" outputChannelId:"${outputChannelId}"`,
40147
+ JSON.stringify({
40148
+ outputChannelId,
40149
+ duration: Date.now() - start2,
40150
+ err: err2
40151
+ }),
40152
+ { verbose: { params } }
40153
+ );
40061
40154
  }
40062
- hasFinished = true;
40063
- const duration = Date.now() - start2;
40064
- autocompleteOutputChannelLogger.logDebug(
40065
- "onComplete",
40066
- `duration:"${duration}ms" stopReason:"${stopReason}" outputChannelId:"${outputChannelId}"`,
40067
- { verbose: { completion } }
40068
- );
40069
- }
40070
- function onEvents(events2) {
40071
- for (const event2 of events2) {
40072
- switch (event2.type) {
40073
- case "completion":
40074
- lastCompletion = event2.completion;
40075
- break;
40076
- case "error":
40077
- onError(event2.error);
40078
- break;
40079
- case "done":
40080
- onComplete({ completion: lastCompletion });
40081
- break;
40155
+ function onComplete({ completion, stopReason }) {
40156
+ if (hasFinished) {
40157
+ return;
40082
40158
  }
40159
+ hasFinished = true;
40160
+ const duration = Date.now() - start2;
40161
+ logger2.logDebug(
40162
+ "onComplete",
40163
+ `duration:"${duration}ms" stopReason:"${stopReason}" outputChannelId:"${outputChannelId}"`,
40164
+ { verbose: { completion } }
40165
+ );
40083
40166
  }
40084
- }
40085
- return {
40086
- onFetch(httpClientLabel, body2) {
40087
- const bodyToLog = { ...body2 };
40088
- const { stopSequences = [] } = params;
40089
- if (!shouldLogFullPrompt) {
40090
- if ("messages" in body2) {
40091
- bodyToLog.messages = body2.messages.map((message) => {
40092
- return message.text ? shortenPromptForOutputChannel(message.text, stopSequences) : message;
40093
- });
40094
- }
40095
- if ("prompt" in body2) {
40096
- bodyToLog.prompt = shortenPromptForOutputChannel(body2.prompt, stopSequences);
40167
+ function onEvents(events2) {
40168
+ for (const event2 of events2) {
40169
+ switch (event2.type) {
40170
+ case "completion":
40171
+ lastCompletion = event2.completion;
40172
+ break;
40173
+ case "error":
40174
+ onError(event2.error);
40175
+ break;
40176
+ case "done":
40177
+ onComplete({ completion: lastCompletion });
40178
+ break;
40097
40179
  }
40098
40180
  }
40099
- autocompleteOutputChannelLogger.logDebug(
40100
- `${httpClientLabel}:fetch`,
40101
- `endpoint: "${endpoint}" outputChannelId: "${outputChannelId}"`,
40102
- { verbose: bodyToLog }
40103
- );
40104
- },
40105
- onError,
40106
- onComplete,
40107
- onEvents
40108
- };
40109
- }
40110
- };
40181
+ }
40182
+ return {
40183
+ onFetch(httpClientLabel, body2) {
40184
+ const bodyToLog = { ...body2 };
40185
+ const { stopSequences = [] } = params;
40186
+ if (!shouldLogFullPrompt) {
40187
+ if ("messages" in body2) {
40188
+ bodyToLog.messages = body2.messages.map((message) => {
40189
+ return message.text ? shortenPromptForOutputChannel(message.text, stopSequences) : message;
40190
+ });
40191
+ }
40192
+ if ("prompt" in body2) {
40193
+ bodyToLog.prompt = shortenPromptForOutputChannel(body2.prompt, stopSequences);
40194
+ }
40195
+ }
40196
+ logger2.logDebug(
40197
+ `${httpClientLabel}:fetch`,
40198
+ `endpoint: "${endpoint}" outputChannelId: "${outputChannelId}"`,
40199
+ { verbose: bodyToLog }
40200
+ );
40201
+ },
40202
+ onError,
40203
+ onComplete,
40204
+ onEvents
40205
+ };
40206
+ }
40207
+ };
40208
+ }
40209
+ const completionsLifecycleOutputChannelLogger = createCompletionLogger(
40210
+ completionsOutputChannelLogger
40211
+ );
40212
+ const autocompleteLifecycleOutputChannelLogger = createCompletionLogger(
40213
+ autocompleteOutputChannelLogger
40214
+ );
40111
40215
  const MAX_SEGMENT_LENGTH = 200;
40112
40216
  function shortenPromptForOutputChannel(prompt, stopSequences) {
40113
40217
  const stopSequencesWithoutNewLines = stopSequences.filter((seq) => !isNewlineSequence(seq));
@@ -49229,7 +49333,7 @@ class CommandsProvider {
49229
49333
  if (!isFileURI(uri)) {
49230
49334
  throw new Error("history only supported on local file paths");
49231
49335
  }
49232
- const { getContextFileFromGitLog } = await import("./git-log-CQBLbIm5.mjs");
49336
+ const { getContextFileFromGitLog } = await import("./git-log--I-rJJIH.mjs");
49233
49337
  return getContextFileFromGitLog(uri, options);
49234
49338
  }
49235
49339
  dispose() {
@@ -153449,11 +153553,15 @@ class DefaultCodeCompletionsClient {
153449
153553
  });
153450
153554
  headers.set("Content-Type", "application/json; charset=utf-8");
153451
153555
  addCodyClientIdentificationHeaders(headers);
153452
- addAuthHeaders(auth, headers, url);
153453
153556
  if (tracingFlagEnabled) {
153454
153557
  headers.set("X-Sourcegraph-Should-Trace", "1");
153455
153558
  addTraceparent(headers);
153456
153559
  }
153560
+ try {
153561
+ await addAuthHeaders(auth, headers, url);
153562
+ } catch (error) {
153563
+ throw recordErrorToSpan(span2, error);
153564
+ }
153457
153565
  const isNode = typeof define_process_default$2 !== "undefined";
153458
153566
  const enableStreaming = !!isNode;
153459
153567
  span2.setAttribute("enableStreaming", enableStreaming);
@@ -155451,11 +155559,24 @@ function convertToSpaceIndentation(document2, addedLines) {
155451
155559
  }));
155452
155560
  }
155453
155561
  const tabSize = getEditorTabSize$1(document2.uri, workspace, window$1);
155454
- const tabAsSpace = UNICODE_SPACE$1.repeat(tabSize);
155455
- return addedLines.map((line) => ({
155456
- ...line,
155457
- lineText: line.lineText.replace(/^(\t+)/, (match2) => tabAsSpace.repeat(match2.length))
155458
- }));
155562
+ return addedLines.map((line) => {
155563
+ const newLineText = line.lineText.replace(
155564
+ /^(\t+)/,
155565
+ (match2) => UNICODE_SPACE$1.repeat(match2.length * tabSize)
155566
+ );
155567
+ const newRanges = line.ranges.map(([start2, end]) => {
155568
+ const tabsBeforeStart = (line.lineText.slice(0, start2).match(/\t/g) || []).length;
155569
+ const tabsBeforeEnd = (line.lineText.slice(0, end).match(/\t/g) || []).length;
155570
+ const adjustedStart = start2 + tabsBeforeStart * (tabSize - 1);
155571
+ const adjustedEnd = end + tabsBeforeEnd * (tabSize - 1);
155572
+ return [adjustedStart, adjustedEnd];
155573
+ });
155574
+ return {
155575
+ ...line,
155576
+ lineText: newLineText,
155577
+ ranges: newRanges
155578
+ };
155579
+ });
155459
155580
  }
155460
155581
  function padTrailingWhitespaceBlock(addedLines) {
155461
155582
  let maxLineWidth = 0;
@@ -162789,7 +162910,7 @@ async function doSendTraceData(spanData) {
162789
162910
  }
162790
162911
  const traceUrl = new URL("/-/debug/otlp/v1/traces", auth.serverEndpoint);
162791
162912
  const headers = new Headers({ "Content-Type": "application/json" });
162792
- addAuthHeaders(auth, headers, traceUrl);
162913
+ await addAuthHeaders(auth, headers, traceUrl);
162793
162914
  const response = await fetch$3(traceUrl, {
162794
162915
  method: "POST",
162795
162916
  headers,
@@ -163909,10 +164030,10 @@ class ChatController {
163909
164030
  inputText: PromptString.unsafe_fromUserQuery(message.text),
163910
164031
  mentions: message.contextItems ?? [],
163911
164032
  editorState: message.editorState,
163912
- signal: this.startNewSubmitOrEditOperation(),
164033
+ signal: await this.startNewSubmitOrEditOperation(),
163913
164034
  source: "chat",
163914
- intent: message.intent,
163915
- intentScores: message.intentScores,
164035
+ preDetectedIntent: message.preDetectedIntent,
164036
+ preDetectedIntentScores: message.preDetectedIntentScores,
163916
164037
  manuallySelectedIntent: message.manuallySelectedIntent,
163917
164038
  traceparent: message.traceparent
163918
164039
  });
@@ -163925,8 +164046,8 @@ class ChatController {
163925
164046
  index: message.index ?? void 0,
163926
164047
  contextFiles: message.contextItems ?? [],
163927
164048
  editorState: message.editorState,
163928
- intent: message.intent,
163929
- intentScores: message.intentScores,
164049
+ preDetectedIntent: message.preDetectedIntent,
164050
+ preDetectedIntentScores: message.preDetectedIntentScores,
163930
164051
  manuallySelectedIntent: message.manuallySelectedIntent
163931
164052
  });
163932
164053
  break;
@@ -164227,8 +164348,8 @@ class ChatController {
164227
164348
  signal: signal2,
164228
164349
  source,
164229
164350
  command,
164230
- intent: detectedIntent,
164231
- intentScores: detectedIntentScores,
164351
+ preDetectedIntent,
164352
+ preDetectedIntentScores,
164232
164353
  manuallySelectedIntent,
164233
164354
  traceparent
164234
164355
  }) {
@@ -164250,8 +164371,8 @@ class ChatController {
164250
164371
  this.chatBuilder.addHumanMessage({
164251
164372
  text: inputText,
164252
164373
  editorState,
164253
- intent: detectedIntent,
164254
- manuallySelectedIntent: manuallySelectedIntent ? detectedIntent : void 0,
164374
+ intent: manuallySelectedIntent || preDetectedIntent,
164375
+ manuallySelectedIntent,
164255
164376
  agent: selectedAgent
164256
164377
  });
164257
164378
  this.postViewTranscript({ speaker: "assistant" });
@@ -164266,8 +164387,8 @@ class ChatController {
164266
164387
  signal: signal2,
164267
164388
  source,
164268
164389
  command,
164269
- intent: detectedIntent,
164270
- intentScores: detectedIntentScores,
164390
+ preDetectedIntent,
164391
+ preDetectedIntentScores,
164271
164392
  manuallySelectedIntent,
164272
164393
  selectedAgent
164273
164394
  },
@@ -164319,8 +164440,8 @@ class ChatController {
164319
164440
  signal: signal2,
164320
164441
  source,
164321
164442
  command,
164322
- intent: preDetectedIntent,
164323
- intentScores: preDetectedIntentScores,
164443
+ preDetectedIntent,
164444
+ preDetectedIntentScores,
164324
164445
  manuallySelectedIntent,
164325
164446
  selectedAgent
164326
164447
  }, span2) {
@@ -164362,7 +164483,7 @@ class ChatController {
164362
164483
  chatClient: this.chatClient
164363
164484
  });
164364
164485
  recorder2.setIntentInfo({
164365
- userSpecifiedIntent: manuallySelectedIntent ? manuallySelectedIntent : this.featureCodyExperimentalOneBox ? "auto" : "chat",
164486
+ userSpecifiedIntent: manuallySelectedIntent ?? this.featureCodyExperimentalOneBox ? "auto" : "chat",
164366
164487
  detectedIntent,
164367
164488
  detectedIntentScores
164368
164489
  });
@@ -164494,15 +164615,19 @@ class ChatController {
164494
164615
  startNewSubmitOrEditOperation() {
164495
164616
  var _a3;
164496
164617
  (_a3 = this.submitOrEditOperation) == null ? void 0 : _a3.abort();
164497
- this.submitOrEditOperation = new AbortController();
164498
- return this.submitOrEditOperation.signal;
164618
+ return new Promise((resolve2) => {
164619
+ setTimeout(() => {
164620
+ this.submitOrEditOperation = new AbortController();
164621
+ resolve2(this.submitOrEditOperation.signal);
164622
+ }, 500);
164623
+ });
164499
164624
  }
164500
164625
  cancelSubmitOrEditOperation() {
164501
164626
  if (this.submitOrEditOperation) {
164502
164627
  this.submitOrEditOperation.abort();
164503
164628
  this.submitOrEditOperation = void 0;
164504
164629
  }
164505
- void this.saveSession();
164630
+ return this.saveSession();
164506
164631
  }
164507
164632
  async reevaluateSearchWithSelectedFilters({
164508
164633
  index: index2,
@@ -164512,6 +164637,7 @@ class ChatController {
164512
164637
  if (index2 === void 0 || !Array.isArray(selectedFilters)) {
164513
164638
  return;
164514
164639
  }
164640
+ await this.handleAbort();
164515
164641
  const humanMessage = this.chatBuilder.getMessages().at(index2);
164516
164642
  const assistantMessage = this.chatBuilder.getMessages().at(index2 + 1);
164517
164643
  if ((humanMessage == null ? void 0 : humanMessage.speaker) !== "human" || humanMessage.intent !== "search" || (assistantMessage == null ? void 0 : assistantMessage.speaker) !== "assistant" || !((_a3 = assistantMessage == null ? void 0 : assistantMessage.search) == null ? void 0 : _a3.query)) {
@@ -164584,11 +164710,11 @@ class ChatController {
164584
164710
  index: index2,
164585
164711
  contextFiles,
164586
164712
  editorState,
164587
- intent,
164588
- intentScores,
164713
+ preDetectedIntent,
164714
+ preDetectedIntentScores,
164589
164715
  manuallySelectedIntent
164590
164716
  }) {
164591
- const abortSignal = this.startNewSubmitOrEditOperation();
164717
+ const abortSignal = await this.startNewSubmitOrEditOperation();
164592
164718
  telemetryRecorder.recordEvent("cody.editChatButton", "clicked", {
164593
164719
  billingMetadata: {
164594
164720
  product: "cody",
@@ -164608,16 +164734,19 @@ class ChatController {
164608
164734
  editorState,
164609
164735
  signal: abortSignal,
164610
164736
  source: "chat",
164611
- intent,
164612
- intentScores,
164737
+ preDetectedIntent,
164738
+ preDetectedIntentScores,
164613
164739
  manuallySelectedIntent
164614
164740
  });
164615
- } catch {
164741
+ } catch (error) {
164742
+ if (isAbortErrorOrSocketHangUp(error)) {
164743
+ return;
164744
+ }
164616
164745
  this.postError(new Error("Failed to edit prompt"), "transcript");
164617
164746
  }
164618
164747
  }
164619
- handleAbort() {
164620
- this.cancelSubmitOrEditOperation();
164748
+ async handleAbort() {
164749
+ await this.cancelSubmitOrEditOperation();
164621
164750
  this.postViewTranscript();
164622
164751
  telemetryRecorder.recordEvent("cody.sidebar.abortButton", "clicked", {
164623
164752
  billingMetadata: {
@@ -165006,6 +165135,16 @@ class ChatController {
165006
165135
  this.chatBuilder.setSelectedAgent((_a3 = settings.agent) == null ? void 0 : _a3.name);
165007
165136
  await toolboxManager.updateSettings(settings);
165008
165137
  });
165138
+ },
165139
+ editTemporarySettings: (settingsToEdit) => {
165140
+ return promiseFactoryToObservable(async () => {
165141
+ const dataOrError = await graphqlClient.editTemporarySettings(settingsToEdit);
165142
+ if (!isError$3(dataOrError)) {
165143
+ await ClientConfigSingleton.getInstance().forceUpdate();
165144
+ return true;
165145
+ }
165146
+ return false;
165147
+ });
165009
165148
  }
165010
165149
  }
165011
165150
  )
@@ -165389,7 +165528,7 @@ class ChatsController {
165389
165528
  if (submitType === "new-chat") {
165390
165529
  await provider.clearAndRestartSession();
165391
165530
  }
165392
- const abortSignal = provider.startNewSubmitOrEditOperation();
165531
+ const abortSignal = await provider.startNewSubmitOrEditOperation();
165393
165532
  const editorState = editorStateFromPromptString(text);
165394
165533
  await provider.handleUserMessage({
165395
165534
  requestID: v4(),
@@ -166542,7 +166681,7 @@ function parseMentionURI(uri) {
166542
166681
  }
166543
166682
  }
166544
166683
  async function execFileAsync(program2, args2, { cwd }) {
166545
- const { promisify: promisify2 } = await import("./util-B6KeX3WC.mjs").then((n) => n.u);
166684
+ const { promisify: promisify2 } = await import("./util-DeyYSaNB.mjs").then((n) => n.u);
166546
166685
  const { execFile } = await import("./child_process-C6OZyNb4.mjs");
166547
166686
  return promisify2(execFile)(program2, args2, { cwd });
166548
166687
  }
@@ -170845,7 +170984,7 @@ async function configureExternalServices(context2, platform2) {
170845
170984
  if (sentryService) disposables.push(sentryService);
170846
170985
  const openTelemetryService = (_b2 = platform2.createOpenTelemetryService) == null ? void 0 : _b2.call(platform2);
170847
170986
  if (openTelemetryService) disposables.push(openTelemetryService);
170848
- const completionsClient = platform2.createCompletionsClient(autocompleteLifecycleOutputChannelLogger);
170987
+ const completionsClient = platform2.createCompletionsClient(completionsLifecycleOutputChannelLogger);
170849
170988
  const symfRunner = (_c2 = platform2.createSymfRunner) == null ? void 0 : _c2.call(platform2, context2);
170850
170989
  if (symfRunner) disposables.push(symfRunner);
170851
170990
  const chatClient = new ChatClient(completionsClient);
@@ -176241,7 +176380,7 @@ async function registerDebugCommands(context2, disposables) {
176241
176380
  }
176242
176381
  async function tryRegisterTutorial(context2, disposables) {
176243
176382
  if (!isRunningInsideAgent()) {
176244
- const { registerInteractiveTutorial } = await import("./index-Bs5wfOm2.mjs");
176383
+ const { registerInteractiveTutorial } = await import("./index-BGjmPMun.mjs");
176245
176384
  registerInteractiveTutorial(context2).then((disposable) => disposables.push(...disposable));
176246
176385
  }
176247
176386
  }